[Freeswitch-svn] [commit] r8692 - in freeswitch/branches/lukedashjr/syslibs: freeswitch freeswitch/build freeswitch/debian freeswitch/docs freeswitch/src freeswitch/src/include freeswitch/src/mod/applications/mod_commands freeswitch/src/mod/applications/mod_conference freeswitch/src/mod/applications/mod_dptools freeswitch/src/mod/applications/mod_enum freeswitch/src/mod/applications/mod_esf freeswitch/src/mod/applications/mod_expr freeswitch/src/mod/applications/mod_fifo freeswitch/src/mod/applications/mod_fsv freeswitch/src/mod/applications/mod_limit freeswitch/src/mod/applications/mod_rss freeswitch/src/mod/applications/mod_skel freeswitch/src/mod/applications/mod_soundtouch freeswitch/src/mod/applications/mod_voicemail freeswitch/src/mod/asr_tts/mod_cepstral freeswitch/src/mod/asr_tts/mod_lumenvox freeswitch/src/mod/asr_tts/mod_openmrcp freeswitch/src/mod/codecs/mod_amr freeswitch/src/mod/codecs/mod_g723_1 freeswitch/src/mod/codecs/mod_g729 freeswitch/src/mod/codecs/mod_h26x freeswitch/src/mod/codecs/mod_ilbc freeswitch/src/mod/codecs/mod_speex freeswitch/src/mod/codecs/mod_voipcodecs freeswitch/src/mod/dialplans/mod_dialplan_asterisk freeswitch/src/mod/dialplans/mod_dialplan_directory freeswitch/src/mod/dialplans/mod_dialplan_xml freeswitch/src/mod/endpoints/mod_alsa freeswitch/src/mod/endpoints/mod_dingaling freeswitch/src/mod/endpoints/mod_iax freeswitch/src/mod/endpoints/mod_portaudio freeswitch/src/mod/endpoints/mod_reference freeswitch/src/mod/endpoints/mod_sofia freeswitch/src/mod/endpoints/mod_wanpipe freeswitch/src/mod/endpoints/mod_woomera freeswitch/src/mod/event_handlers/mod_cdr_csv freeswitch/src/mod/event_handlers/mod_event_multicast freeswitch/src/mod/event_handlers/mod_event_socket freeswitch/src/mod/event_handlers/mod_event_test freeswitch/src/mod/event_handlers/mod_radius_cdr freeswitch/src/mod/formats/mod_local_stream freeswitch/src/mod/formats/mod_shout freeswitch/src/mod/formats/mod_sndfile freeswitch/src/mod/formats/mod_tone_stream freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig freeswitch/src/mod/languages/mod_lua freeswitch/src/mod/languages/mod_mono freeswitch/src/mod/languages/mod_perl freeswitch/src/mod/languages/mod_python freeswitch/src/mod/languages/mod_spidermonkey freeswitch/src/mod/languages/mod_spidermonkey_core_db freeswitch/src/mod/languages/mod_spidermonkey_curl freeswitch/src/mod/languages/mod_spidermonkey_odbc freeswitch/src/mod/languages/mod_spidermonkey_rsa freeswitch/src/mod/languages/mod_spidermonkey_skel freeswitch/src/mod/languages/mod_spidermonkey_socket freeswitch/src/mod/languages/mod_spidermonkey_teletone freeswitch/src/mod/loggers/mod_console freeswitch/src/mod/loggers/mod_logfile freeswitch/src/mod/loggers/mod_syslog freeswitch/src/mod/say/mod_say_de freeswitch/src/mod/say/mod_say_en freeswitch/src/mod/say/mod_say_es freeswitch/src/mod/say/mod_say_fr freeswitch/src/mod/say/mod_say_it freeswitch/src/mod/say/mod_say_nl freeswitch/src/mod/say/mod_say_zh freeswitch/src/mod/xml_int/mod_xml_cdr freeswitch/src/mod/xml_int/mod_xml_curl freeswitch/src/mod/xml_int/mod_xml_ldap freeswitch/src/mod/xml_int/mod_xml_rpc libs/sofia-sip libs/sofia-sip/libsofia-sip-ua/nth libs/sofia-sip/libsofia-sip-ua/su libs/sofia-sip/tests libs/voipcodecs/src

Freeswitch SVN lukedashjr at freeswitch.org
Tue May 27 07:24:14 EDT 2008


Author: lukedashjr
Date: Tue May 27 07:24:06 2008
New Revision: 8692

Added:
   freeswitch/branches/lukedashjr/syslibs/freeswitch/build/gen_indent.pl
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/build/gen_indent.pl
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/API.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/IVRMenu.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/IVRMenu.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_event_t.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_event_t.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_priority_t.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_priority_t.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_size_t.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_size_t.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_stream_handle_t.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/SWIGTYPE_p_switch_stream_handle_t.java
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_java/src/org/freeswitch/swig/Stream.java
      - copied unchanged from r8691, /freeswitch/tags/1.0.0/src/mod/languages/mod_java/src/org/freeswitch/swig/Stream.java
Removed:
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_rsa/
Modified:
   freeswitch/branches/lukedashjr/syslibs/freeswitch/build/indent_options.sh
   freeswitch/branches/lukedashjr/syslibs/freeswitch/configure.in
   freeswitch/branches/lukedashjr/syslibs/freeswitch/debian/changelog
   freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/ChangeLog
   freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/Doxygen.conf
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/SimpleGlob.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/g711.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_apr.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_bitpack.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_buffer.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_caller.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_channel.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_config.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_console.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core_event_hook.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_cpp.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_event.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_frame.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_ivr.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_loadable_module.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_log.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_module_interfaces.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_odbc.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_platform.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_rtp.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_stun.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_types.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_utils.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_xml.h
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_enum/mod_enum.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_esf/mod_esf.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/expreval.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprfunc.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprinit.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprmem.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprobj.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprpars.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprutil.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprval.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/mod_expr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fifo/mod_fifo.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fsv/mod_fsv.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_limit/mod_limit.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_rss/mod_rss.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_skel/mod_skel.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_voicemail/mod_voicemail.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_lumenvox/mod_lumenvox.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_amr/mod_amr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g723_1/mod_g723_1.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g729/mod_g729.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_h26x/mod_h26x.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_ilbc/mod_ilbc.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_speex/mod_speex.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_alsa/mod_alsa.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax-mutex.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax2-parser.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/jitterbuf.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/md5.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_portaudio/pablio.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_reference/mod_reference.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_sofia/sofia_reg.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_wanpipe/lib_api.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_wanpipe/ss7boost_client.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_wanpipe/testapp.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_woomera/mod_woomera.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/event_handlers/mod_event_test/mod_event_test.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/formats/mod_local_stream/mod_local_stream.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/formats/mod_shout/layer3.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/formats/mod_shout/mod_shout.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/formats/mod_sndfile/mod_sndfile.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/formats/mod_tone_stream/mod_tone_stream.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_lua/freeswitch_lua.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_lua/mod_lua.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_lua/mod_lua_extra.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_lua/mod_lua_wrap.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_mono/freeswitch_mono.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_mono/mod_mono.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_perl/freeswitch_perl.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_perl/mod_perl.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_perl/mod_perl_extra.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_perl/mod_perl_wrap.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_perl/perlxsi.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_python/freeswitch_python.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_python/mod_python.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_python/mod_python_wrap.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_python/switch_swig_wrap.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/loggers/mod_console/mod_console.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/loggers/mod_logfile/mod_logfile.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/loggers/mod_syslog/mod_syslog.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_de/mod_say_de.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_en/mod_say_en.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_es/mod_say_es.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_fr/mod_say_fr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_it/mod_say_it.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_nl/mod_say_nl.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/say/mod_say_zh/mod_say_zh.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_apr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_buffer.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_caller.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_channel.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_config.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_console.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_asr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_codec.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_db.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_event_hook.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_file.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_hash.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_io.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_media_bug.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_memory.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_port_allocator.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_rwlock.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_session.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_speech.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_sqldb.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_state_machine.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_core_timer.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_cpp.cpp
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_event.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr_async.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr_bridge.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr_menu.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr_originate.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_ivr_play_say.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_loadable_module.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_log.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_odbc.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_pcm.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_regex.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_resample.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_rtp.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_scheduler.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_stun.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_swig.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_time.c
   freeswitch/branches/lukedashjr/syslibs/freeswitch/src/switch_utils.c
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/.update
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/RELEASE
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/configure.ac
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/libsofia-sip-ua/su/su_wait.c
   freeswitch/branches/lukedashjr/syslibs/libs/sofia-sip/tests/test_call_hold.c
   freeswitch/branches/lukedashjr/syslibs/libs/voipcodecs/src/lpc10_decode.c

Log:
MERGE to: http://svn.freeswitch.org/svn/freeswitch/tags/1.0.0

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/build/indent_options.sh
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/build/indent_options.sh	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/build/indent_options.sh	Tue May 27 07:24:06 2008
@@ -1,4 +1,5 @@
 #!/bin/bash
 echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro
-grep typedef ./src/include/*.h | grep switch_ | grep -v "\*\|{"  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
+grep typedef `find ./src/include/ -name \*.h` | grep apr_ | grep -v "\*\|{"  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
+grep typedef `find ./src/include/ -name \*.h` | grep switch_ | grep -v "\*\|{"  | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
 grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/configure.in
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/configure.in	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/configure.in	Tue May 27 07:24:06 2008
@@ -3,12 +3,12 @@
 
 # Must change all of the below together
 # For a release, set revision for that tagged release as well and uncomment
-AC_INIT([freeswitch], [1.0.pre4], BUG-REPORT-ADDRESS)
+AC_INIT([freeswitch], [1.0.0], BUG-REPORT-ADDRESS)
 AC_SUBST(SWITCH_VERSION_MAJOR, [1])
 AC_SUBST(SWITCH_VERSION_MINOR, [0])
-AC_SUBST(SWITCH_VERSION_MICRO, [pre4])
-#AC_SUBST(SWITCH_VERSION_REVISION, [svn-revision-here])
-AC_SUBST(SOUNDS_VERSION, [1.0.1])
+AC_SUBST(SWITCH_VERSION_MICRO, [0])
+AC_SUBST(SWITCH_VERSION_REVISION, [8691])
+AC_SUBST(SOUNDS_VERSION, [1.0.2])
 
 AC_CONFIG_FILES([src/include/switch_version.h.in:src/include/switch_version.h.template])
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/debian/changelog
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/debian/changelog	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/debian/changelog	Tue May 27 07:24:06 2008
@@ -1,3 +1,33 @@
+freeswitch (1.0.0-1) unstable; urgency=low
+
+   * Enhanced sofia sip nat handling
+   * Many fixes found by Klockwork (www.klocwork.com)
+   * Added disable_app_log variable
+   * Fixed mod_local_stream with rates on windows
+   * Fixed finding of files in rate dirs on windows
+   * Fixed memory corruption from sofia_contact function
+   * Added sofia profile param NDLB-received-in-nat-reg-contact
+   * Added sofia profile param aggressive-nat-detection
+   * Fixed video sip calls in proxy media mode
+   * Added bridge_terminate_key var
+   * Update xmlrpc-c lib to trunk revision from upstream, fix windows xmlrpc
+   * Enhanced nat handling in proxy media mode in sip
+   * Add progress media to timetable so you can calculate pdd
+   * Fixed seg when using unicast on socket when call has no read_codec
+   * Fixed missed log events on busy box
+   * Added -bleg to intercept
+   * Enhance configure detection of python
+   * Fixed build on solaris and freebsd for several modules
+   * Added param "vm-email-only" to make voicemail sent by email only (previously default behavior)
+   * Added param "vm-mailto-notify" to allow sending a notification email
+   * Fixed mod_java build
+   * Fixed mwi failures for some devices that don't subscribe
+   * Removed fsapi functions (killchan, transfer, session_displace, reject)
+   * Removed fsapi functions (session_record, broadcast, hold, media)
+   * Many updates to sofia-sip library including over 100 fixes
+
+ -- Michael Jerris <mike at jerris.com>  Tue, 27 May 2008 01:30:00 -0400
+
 freeswitch (1.0~rc6-1) unstable; urgency=low
 
    * Changed to not allow pass_2833 on transcoded calls 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/ChangeLog
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/ChangeLog	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/ChangeLog	Tue May 27 07:24:06 2008
@@ -1,4 +1,33 @@
+freeswitch (1.0.0)
+
+	Enhanced sofia sip nat handling
+	Many fixes found by Klockwork (www.klocwork.com)
+	Added disable_app_log variable
+	Fixed mod_local_stream with rates on windows
+	Fixed finding of files in rate dirs on windows
+	Fixed memory corruption from sofia_contact function
+	Added sofia profile param NDLB-received-in-nat-reg-contact
+	Added sofia profile param aggressive-nat-detection
+	Fixed video sip calls in proxy media mode
+	Added bridge_terminate_key var
+	Update xmlrpc-c lib to trunk revision from upstream, fix windows xmlrpc
+	Enhanced nat handling in proxy media mode in sip
+	Add progress media to timetable so you can calculate pdd
+	Fixed seg when using unicast on socket when call has no read_codec
+	Fixed missed log events on busy box
+	Added -bleg to intercept
+	Enhance configure detection of python
+	Fixed build on solaris and freebsd for several modules
+	Added param "vm-email-only" to make voicemail sent by email only (previously default behavior)
+	Added param "vm-mailto-notify" to allow sending a notification email
+	Fixed mod_java build
+	Fixed mwi failures for some devices that don't subscribe
+	Removed fsapi functions (killchan, transfer, session_displace, reject)
+	Removed fsapi functions (session_record, broadcast, hold, media)
+	Many updates to sofia-sip library including over 100 fixes
+	
 freeswitch (1.0.rc6)
+
 	Changed to not allow pass_2833 on transcoded calls (it never worked, now it will tell you)
 	Enhanced sofia sip nat handling
 	Fix libedit build on solaris

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/Doxygen.conf
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/Doxygen.conf	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/docs/Doxygen.conf	Tue May 27 07:24:06 2008
@@ -3,8 +3,8 @@
 #---------------------------------------------------------------------------
 # Project related configuration options
 #---------------------------------------------------------------------------
-PROJECT_NAME           = FreeSwitch
-PROJECT_NUMBER         = 
+PROJECT_NAME           = FreeSWITCH
+PROJECT_NUMBER         = 1.0.0
 OUTPUT_DIRECTORY       = .
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
@@ -30,7 +30,7 @@
 SHORT_NAMES            = NO
 JAVADOC_AUTOBRIEF      = NO
 MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = NO
+DETAILS_AT_TOP         = YES
 INHERIT_DOCS           = YES
 SEPARATE_MEMBER_PAGES  = NO
 TAB_SIZE               = 8

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/SimpleGlob.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/SimpleGlob.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/SimpleGlob.h	Tue May 27 07:24:06 2008
@@ -123,23 +123,23 @@
         Do not return the "." or ".." special directories.
  */
 enum SG_Flags {
-    SG_GLOB_ERR         = 1 << 0,
-    SG_GLOB_MARK        = 1 << 1,
-    SG_GLOB_NOSORT      = 1 << 2,
-    SG_GLOB_NOCHECK     = 1 << 3,
-    SG_GLOB_TILDE       = 1 << 4,
-    SG_GLOB_ONLYDIR     = 1 << 5,
-    SG_GLOB_ONLYFILE    = 1 << 6,
-    SG_GLOB_NODOT       = 1 << 7,
-    SG_GLOB_FULLSORT    = 1 << 8
+	SG_GLOB_ERR = 1 << 0,
+	SG_GLOB_MARK = 1 << 1,
+	SG_GLOB_NOSORT = 1 << 2,
+	SG_GLOB_NOCHECK = 1 << 3,
+	SG_GLOB_TILDE = 1 << 4,
+	SG_GLOB_ONLYDIR = 1 << 5,
+	SG_GLOB_ONLYFILE = 1 << 6,
+	SG_GLOB_NODOT = 1 << 7,
+	SG_GLOB_FULLSORT = 1 << 8
 };
 
 /*! @brief Error return codes */
 enum SG_Error {
-    SG_SUCCESS          =  0,
-    SG_ERR_NOMATCH      =  1,
-    SG_ERR_MEMORY       = -1,
-    SG_ERR_FAILURE      = -2
+	SG_SUCCESS = 0,
+	SG_ERR_NOMATCH = 1,
+	SG_ERR_MEMORY = -1,
+	SG_ERR_FAILURE = -2
 };
 
 // ----------------------------------------------------------------------------
@@ -196,61 +196,63 @@
 #endif
 
 /*! @brief String manipulation functions. */
-class SimpleGlobUtil
-{
-public:
-    static const char * strchr(const char *s, char c) {
-        return (char *) sg_strchr((const SOCHAR_T *)s, c);
-    }
-    static const wchar_t * strchr(const wchar_t *s, wchar_t c) {
-        return ::wcschr(s, c);
-    }
-
-    static const char * strrchr(const char *s, char c) {
-        return (char *) sg_strrchr((const SOCHAR_T *)s, c);
-    }
-    static const wchar_t * strrchr(const wchar_t *s, wchar_t c) {
-        return ::wcsrchr(s, c);
-    }
-
-    // Note: char strlen returns number of bytes, not characters
-    static size_t strlen(const char *s) { return ::strlen(s); }
-    static size_t strlen(const wchar_t *s) { return ::wcslen(s); }
-
-    static void strcpy_s(char *dst, size_t n, const char *src)  {
-        (void) n;
-        sg_strcpy_s((SOCHAR_T *)dst, n, (const SOCHAR_T *)src);
-    }
-    static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
+class SimpleGlobUtil {
+  public:
+	static const char *strchr(const char *s, char c) {
+		return (char *) sg_strchr((const SOCHAR_T *) s, c);
+	} static const wchar_t *strchr(const wchar_t *s, wchar_t c) {
+		return::wcschr(s, c);
+	}
+
+	static const char *strrchr(const char *s, char c) {
+		return (char *) sg_strrchr((const SOCHAR_T *) s, c);
+	}
+	static const wchar_t *strrchr(const wchar_t *s, wchar_t c) {
+		return::wcsrchr(s, c);
+	}
+
+	// Note: char strlen returns number of bytes, not characters
+	static size_t strlen(const char *s) {
+		return::strlen(s);
+	}
+	static size_t strlen(const wchar_t *s) {
+		return::wcslen(s);
+	}
+
+	static void strcpy_s(char *dst, size_t n, const char *src) {
+		(void) n;
+		sg_strcpy_s((SOCHAR_T *) dst, n, (const SOCHAR_T *) src);
+	}
+	static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
 # if __STDC_WANT_SECURE_LIB__
-        ::wcscpy_s(dst, n, src);
+		::wcscpy_s(dst, n, src);
 #else
-        (void) n;
-        ::wcscpy(dst, src);
+		(void) n;
+		::wcscpy(dst, src);
 #endif
-    }
+	}
 
-    static int strcmp(const char *s1, const char *s2) {
-        return sg_strcmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
-    }
-    static int strcmp(const wchar_t *s1, const wchar_t *s2) {
-        return ::wcscmp(s1, s2);
-    }
-
-    static int strcasecmp(const char *s1, const char *s2) {
-        return sg_strcasecmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
-    }
+	static int strcmp(const char *s1, const char *s2) {
+		return sg_strcmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
+	}
+	static int strcmp(const wchar_t *s1, const wchar_t *s2) {
+		return::wcscmp(s1, s2);
+	}
+
+	static int strcasecmp(const char *s1, const char *s2) {
+		return sg_strcasecmp((const SOCHAR_T *) s1, (const SOCHAR_T *) s2);
+	}
 #if _WIN32
-    static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
-        return ::_wcsicmp(s1, s2);
-    }
+	static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
+		return::_wcsicmp(s1, s2);
+	}
 #endif // _WIN32
 };
 
 enum SG_FileType {
-    SG_FILETYPE_INVALID,
-    SG_FILETYPE_FILE,
-    SG_FILETYPE_DIR
+	SG_FILETYPE_INVALID,
+	SG_FILETYPE_FILE,
+	SG_FILETYPE_DIR
 };
 
 #ifdef _WIN32
@@ -262,79 +264,70 @@
 #define SG_PATH_CHAR    '\\'
 
 /*! @brief Windows glob implementation. */
-template<class SOCHAR>
-struct SimpleGlobBase
-{
-    SimpleGlobBase() : m_hFind(INVALID_HANDLE_VALUE) { }
-
-    int FindFirstFileS(const char * a_pszFileSpec, unsigned int) {
-        m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA);
-        if (m_hFind != INVALID_HANDLE_VALUE) {
-            return SG_SUCCESS;
-        }
-        DWORD dwErr = GetLastError();
-        if (dwErr == ERROR_FILE_NOT_FOUND) {
-            return SG_ERR_NOMATCH;
-        }
-        return SG_ERR_FAILURE;
-    }
-    int FindFirstFileS(const wchar_t * a_pszFileSpec, unsigned int) {
-        m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW);
-        if (m_hFind != INVALID_HANDLE_VALUE) {
-            return SG_SUCCESS;
-        }
-        DWORD dwErr = GetLastError();
-        if (dwErr == ERROR_FILE_NOT_FOUND) {
-            return SG_ERR_NOMATCH;
-        }
-        return SG_ERR_FAILURE;
-    }
-
-    bool FindNextFileS(char) {
-        return FindNextFileA(m_hFind, &m_oFindDataA) != FALSE;
-    }
-    bool FindNextFileS(wchar_t) {
-        return FindNextFileW(m_hFind, &m_oFindDataW) != FALSE;
-    }
-
-    void FindDone() {
-        FindClose(m_hFind);
-    }
-
-    const char * GetFileNameS(char) const {
-        return m_oFindDataA.cFileName;
-    }
-    const wchar_t * GetFileNameS(wchar_t) const {
-        return m_oFindDataW.cFileName;
-    }
-
-    bool IsDirS(char) const {
-        return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
-    }
-    bool IsDirS(wchar_t) const {
-        return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
-    }
-
-    SG_FileType GetFileTypeS(const char * a_pszPath) {
-        return GetFileTypeS(GetFileAttributesA(a_pszPath));
-    }
-    SG_FileType GetFileTypeS(const wchar_t * a_pszPath)  {
-        return GetFileTypeS(GetFileAttributesW(a_pszPath));
-    }
-    SG_FileType GetFileTypeS(DWORD a_dwAttribs) const {
-        if (a_dwAttribs == INVALID_FILE_ATTRIBUTES) {
-            return SG_FILETYPE_INVALID;
-        }
-        if (a_dwAttribs & FILE_ATTRIBUTE_DIRECTORY) {
-            return SG_FILETYPE_DIR;
-        }
-        return SG_FILETYPE_FILE;
-    }
-
-private:
-    HANDLE              m_hFind;
-    WIN32_FIND_DATAA    m_oFindDataA;
-    WIN32_FIND_DATAW    m_oFindDataW;
+template < class SOCHAR > struct SimpleGlobBase {
+	SimpleGlobBase():m_hFind(INVALID_HANDLE_VALUE) {
+	} int FindFirstFileS(const char *a_pszFileSpec, unsigned int) {
+		m_hFind = FindFirstFileA(a_pszFileSpec, &m_oFindDataA);
+		if (m_hFind != INVALID_HANDLE_VALUE) {
+			return SG_SUCCESS;
+		}
+		DWORD dwErr = GetLastError();
+		if (dwErr == ERROR_FILE_NOT_FOUND) {
+			return SG_ERR_NOMATCH;
+		}
+		return SG_ERR_FAILURE;
+	}
+	int FindFirstFileS(const wchar_t *a_pszFileSpec, unsigned int) {
+		m_hFind = FindFirstFileW(a_pszFileSpec, &m_oFindDataW);
+		if (m_hFind != INVALID_HANDLE_VALUE) {
+			return SG_SUCCESS;
+		}
+		DWORD dwErr = GetLastError();
+		if (dwErr == ERROR_FILE_NOT_FOUND) {
+			return SG_ERR_NOMATCH;
+		}
+		return SG_ERR_FAILURE;
+	}
+
+	bool FindNextFileS(char) {
+		return FindNextFileA(m_hFind, &m_oFindDataA) != FALSE;
+	}
+	bool FindNextFileS(wchar_t) {
+		return FindNextFileW(m_hFind, &m_oFindDataW) != FALSE;
+	}
+
+	void FindDone() {
+		FindClose(m_hFind);
+	}
+
+	const char *GetFileNameS(char) const {
+		return m_oFindDataA.cFileName;
+	} const wchar_t *GetFileNameS(wchar_t) const {
+		return m_oFindDataW.cFileName;
+	} bool IsDirS(char) const {
+		return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
+	} bool IsDirS(wchar_t) const {
+		return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
+	} SG_FileType GetFileTypeS(const char *a_pszPath) {
+		return GetFileTypeS(GetFileAttributesA(a_pszPath));
+	}
+	SG_FileType GetFileTypeS(const wchar_t *a_pszPath) {
+		return GetFileTypeS(GetFileAttributesW(a_pszPath));
+	}
+	SG_FileType GetFileTypeS(DWORD a_dwAttribs) const {
+		if (a_dwAttribs == INVALID_FILE_ATTRIBUTES) {
+			return SG_FILETYPE_INVALID;
+		}
+		if    (a_dwAttribs & FILE_ATTRIBUTE_DIRECTORY) {
+			return SG_FILETYPE_DIR;
+		}
+		return SG_FILETYPE_FILE;
+	}
+
+  private:
+	HANDLE m_hFind;
+	WIN32_FIND_DATAA m_oFindDataA;
+	WIN32_FIND_DATAW m_oFindDataW;
 };
 
 #else // !_WIN32
@@ -342,85 +335,82 @@
 #define SG_PATH_CHAR    '/'
 
 /*! @brief Unix glob implementation. */
-template<class SOCHAR>
-struct SimpleGlobBase
-{
-    SimpleGlobBase() {
-        memset(&m_glob, 0, sizeof(m_glob));
-        m_uiCurr = (size_t)-1;
-    }
-
-    ~SimpleGlobBase() {
-        globfree(&m_glob);
-    }
-
-    void FilePrep() {
-        m_bIsDir = false;
-        size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
-        if (m_glob.gl_pathv[m_uiCurr][len-1] == '/') {
-            m_bIsDir = true;
-            m_glob.gl_pathv[m_uiCurr][len-1] = 0;
-        }
-    }
-
-    int FindFirstFileS(const char * a_pszFileSpec, unsigned int a_uiFlags) {
-        int nFlags = GLOB_MARK | GLOB_NOSORT;
-        if (a_uiFlags & SG_GLOB_ERR)    nFlags |= GLOB_ERR;
+template < class SOCHAR > struct SimpleGlobBase {
+	SimpleGlobBase() {
+		memset(&m_glob, 0, sizeof(m_glob));
+		m_uiCurr = (size_t) -1;
+	}             ~SimpleGlobBase() {
+		globfree(&m_glob);
+	}
+
+	void FilePrep() {
+		m_bIsDir = false;
+		size_t len = strlen(m_glob.gl_pathv[m_uiCurr]);
+		if (m_glob.gl_pathv[m_uiCurr][len - 1] == '/') {
+			m_bIsDir = true;
+			m_glob.gl_pathv[m_uiCurr][len - 1] = 0;
+		}
+	}
+
+	int FindFirstFileS(const char *a_pszFileSpec, unsigned int a_uiFlags) {
+		int nFlags = GLOB_MARK | GLOB_NOSORT;
+		if (a_uiFlags & SG_GLOB_ERR)
+			nFlags |= GLOB_ERR;
 #ifdef GLOB_TILDE
-        if (a_uiFlags & SG_GLOB_TILDE)  nFlags |= GLOB_TILDE;
+		if (a_uiFlags & SG_GLOB_TILDE)
+			nFlags |= GLOB_TILDE;
 #endif
-        int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
-        if (rc == GLOB_NOSPACE) return SG_ERR_MEMORY;
-        if (rc == GLOB_ABORTED) return SG_ERR_FAILURE;
-        if (rc == GLOB_NOMATCH) return SG_ERR_NOMATCH;
-        m_uiCurr = 0;
-        FilePrep();
-        return SG_SUCCESS;
-    }
-
-    bool FindNextFileS(char) {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        if (++m_uiCurr >= m_glob.gl_pathc) {
-            return false;
-        }
-        FilePrep();
-        return true;
-    }
-
-    void FindDone() {
-        globfree(&m_glob);
-        memset(&m_glob, 0, sizeof(m_glob));
-        m_uiCurr = (size_t)-1;
-    }
-
-    const char * GetFileNameS(char) const {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        return m_glob.gl_pathv[m_uiCurr];
-    }
-
-    bool IsDirS(char) const {
-        SG_ASSERT(m_uiCurr != (size_t)-1);
-        return m_bIsDir;
-    }
-
-    SG_FileType GetFileTypeS(const char * a_pszPath) const {
-        struct stat sb;
-        if (0 != stat(a_pszPath, &sb)) {
-            return SG_FILETYPE_INVALID;
-        }
-        if (S_ISDIR(sb.st_mode)) {
-            return SG_FILETYPE_DIR;
-        }
-        if (S_ISREG(sb.st_mode)) {
-            return SG_FILETYPE_FILE;
-        }
-        return SG_FILETYPE_INVALID;
-    }
-
-private:
-    glob_t  m_glob;
-    size_t  m_uiCurr;
-    bool    m_bIsDir;
+		int rc = glob(a_pszFileSpec, nFlags, NULL, &m_glob);
+		if (rc == GLOB_NOSPACE)
+			return SG_ERR_MEMORY;
+		if (rc == GLOB_ABORTED)
+			return SG_ERR_FAILURE;
+		if (rc == GLOB_NOMATCH)
+			return SG_ERR_NOMATCH;
+		m_uiCurr = 0;
+		FilePrep();
+		return SG_SUCCESS;
+	}
+
+	bool FindNextFileS(char) {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		if (++m_uiCurr >= m_glob.gl_pathc) {
+			return false;
+		}
+		FilePrep();
+		return true;
+	}
+
+	void FindDone() {
+		globfree(&m_glob);
+		memset(&m_glob, 0, sizeof(m_glob));
+		m_uiCurr = (size_t) -1;
+	}
+
+	const char *GetFileNameS(char) const {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		return m_glob.gl_pathv[m_uiCurr];
+	} bool IsDirS(char) const {
+		SG_ASSERT(m_uiCurr != (size_t) -1);
+		return m_bIsDir;
+	} SG_FileType GetFileTypeS(const char *a_pszPath) const {
+		struct stat sb;
+		if   (0 != stat(a_pszPath, &sb)) {
+			return SG_FILETYPE_INVALID;
+		}
+		if    (S_ISDIR(sb.st_mode)) {
+			return SG_FILETYPE_DIR;
+		}
+		if (S_ISREG(sb.st_mode)) {
+			return SG_FILETYPE_FILE;
+		}
+		return SG_FILETYPE_INVALID;
+	}
+
+  private:
+	glob_t m_glob;
+	size_t m_uiCurr;
+	bool m_bIsDir;
 };
 
 #endif // _WIN32
@@ -432,419 +422,366 @@
 // ---------------------------------------------------------------------------
 
 /*! @brief Implementation of the SimpleGlob class */
-template<class SOCHAR>
-class CSimpleGlobTempl : private SimpleGlobBase<SOCHAR>
-{
-public:
-    /*! @brief Initialize the class.
-
-        @param a_uiFlags            Combination of SG_GLOB flags.
-        @param a_nReservedSlots     Number of slots in the argv array that
-            should be reserved. In the returned array these slots
-            argv[0] ... argv[a_nReservedSlots-1] will be left empty for
-            the caller to fill in.
-     */
-    CSimpleGlobTempl(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
-
-    /*! @brief Deallocate all memory buffers. */
-    ~CSimpleGlobTempl();
-
-    /*! @brief Initialize (or re-initialize) the class in preparation for
-        adding new filespecs.
-
-        All existing files are cleared. Note that allocated memory is only
-        deallocated at object destruction.
-
-        @param a_uiFlags            Combination of SG_GLOB flags.
-        @param a_nReservedSlots     Number of slots in the argv array that
-            should be reserved. In the returned array these slots
-            argv[0] ... argv[a_nReservedSlots-1] will be left empty for
-            the caller to fill in.
-     */
-    int Init(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
-
-    /*! @brief Add a new filespec to the glob.
-
-        The filesystem will be immediately scanned for all matching files and
-        directories and they will be added to the glob.
-
-        @param a_pszFileSpec    Filespec to add to the glob.
-
-        @return SG_SUCCESS      Matching files were added to the glob.
-        @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
-                                compare the return value to >= SG_SUCCESS.
-        @return SG_ERR_MEMORY   Out of memory failure.
-        @return SG_ERR_FAILURE  General failure.
-     */
-    int Add(const SOCHAR *a_pszFileSpec);
-
-    /*! @brief Add an array of filespec to the glob.
-
-        The filesystem will be immediately scanned for all matching files and
-        directories in each filespec and they will be added to the glob.
-
-        @param a_nCount         Number of filespec in the array.
-        @param a_rgpszFileSpec  Array of filespec to add to the glob.
-
-        @return SG_SUCCESS      Matching files were added to the glob.
-        @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
-                                compare the return value to >= SG_SUCCESS.
-        @return SG_ERR_MEMORY   Out of memory failure.
-        @return SG_ERR_FAILURE  General failure.
-     */
-    int Add(int a_nCount, const SOCHAR * const * a_rgpszFileSpec);
-
-    /*! @brief Return the number of files in the argv array.
-     */
-    inline int FileCount() const { return m_nArgsLen; }
-
-    /*! @brief Return the full argv array. */
-    inline SOCHAR ** Files() {
-        SetArgvArrayType(POINTERS);
-        return m_rgpArgs;
-    }
-
-    /*! @brief Return the a single file. */
-    inline SOCHAR * File(int n) {
-        SG_ASSERT(n >= 0 && n < m_nArgsLen);
-        return Files()[n];
-    }
-
-private:
-    /*! @brief The argv array has it's members stored as either an offset into
-        the string buffer, or as pointers to their string in the buffer. The offsets
-        are used because if the string buffer is dynamically resized, all pointers
-        into that buffer would become invalid.
-     */
-    enum ARG_ARRAY_TYPE { OFFSETS, POINTERS };
-
-    /*! @brief Change the type of data stored in the argv array. */
-    void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType);
-
-    /*! @brief Add a filename to the array if it passes all requirements. */
-    int AppendName(const SOCHAR *a_pszFileName, bool a_bIsDir);
-
-    /*! @brief Grow the argv array to the required size. */
-    bool GrowArgvArray(int a_nNewLen);
-
-    /*! @brief Grow the string buffer to the required size. */
-    bool GrowStringBuffer(size_t a_uiMinSize);
-
-    /*! @brief Compare two (possible NULL) strings */
-    static int fileSortCompare(const void *a1, const void *a2);
-
-private:
-    unsigned int        m_uiFlags;
-    ARG_ARRAY_TYPE      m_nArgArrayType;    //!< is the argv array storing indexes or pointers
-    SOCHAR **           m_rgpArgs;          //!< argv array
-    int                 m_nReservedSlots;   //!< number of client reserved slots in the argv array
-    int                 m_nArgsSize;        //!< allocated size of array
-    int                 m_nArgsLen;         //!< used length
-    SOCHAR *            m_pBuffer;          //!< argv string buffer
-    size_t              m_uiBufferSize;     //!< allocated size of buffer
-    size_t              m_uiBufferLen;      //!< used length of buffer
-    SOCHAR              m_szPathPrefix[MAX_PATH]; //!< path prefix of any wildcard filenames
+template < class SOCHAR > class CSimpleGlobTempl:private SimpleGlobBase < SOCHAR > {
+  public:
+	/*! @brief Initialize the class.
+
+	   @param a_uiFlags            Combination of SG_GLOB flags.
+	   @param a_nReservedSlots     Number of slots in the argv array that
+	   should be reserved. In the returned array these slots
+	   argv[0] ... argv[a_nReservedSlots-1] will be left empty for
+	   the caller to fill in.
+	 */
+	CSimpleGlobTempl(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
+
+	/*! @brief Deallocate all memory buffers. */
+	~CSimpleGlobTempl();
+
+	/*! @brief Initialize (or re-initialize) the class in preparation for
+	   adding new filespecs.
+
+	   All existing files are cleared. Note that allocated memory is only
+	   deallocated at object destruction.
+
+	   @param a_uiFlags            Combination of SG_GLOB flags.
+	   @param a_nReservedSlots     Number of slots in the argv array that
+	   should be reserved. In the returned array these slots
+	   argv[0] ... argv[a_nReservedSlots-1] will be left empty for
+	   the caller to fill in.
+	 */
+	int Init(unsigned int a_uiFlags = 0, int a_nReservedSlots = 0);
+
+	/*! @brief Add a new filespec to the glob.
+
+	   The filesystem will be immediately scanned for all matching files and
+	   directories and they will be added to the glob.
+
+	   @param a_pszFileSpec    Filespec to add to the glob.
+
+	   @return SG_SUCCESS      Matching files were added to the glob.
+	   @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
+	   compare the return value to >= SG_SUCCESS.
+	   @return SG_ERR_MEMORY   Out of memory failure.
+	   @return SG_ERR_FAILURE  General failure.
+	 */
+	int Add(const SOCHAR * a_pszFileSpec);
+
+	/*! @brief Add an array of filespec to the glob.
+
+	   The filesystem will be immediately scanned for all matching files and
+	   directories in each filespec and they will be added to the glob.
+
+	   @param a_nCount         Number of filespec in the array.
+	   @param a_rgpszFileSpec  Array of filespec to add to the glob.
+
+	   @return SG_SUCCESS      Matching files were added to the glob.
+	   @return SG_ERR_NOMATCH  Nothing matched the pattern. To ignore this error
+	   compare the return value to >= SG_SUCCESS.
+	   @return SG_ERR_MEMORY   Out of memory failure.
+	   @return SG_ERR_FAILURE  General failure.
+	 */
+	int Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec);
+
+	/*! @brief Return the number of files in the argv array.
+	 */
+	inline int FileCount() const {
+		return m_nArgsLen;
+	}
+	/*! @brief Return the full argv array. */ inline SOCHAR **Files() {
+		SetArgvArrayType(POINTERS);
+		return m_rgpArgs;
+	}
+
+	/*! @brief Return the a single file. */
+	inline SOCHAR *File(int n) {
+		SG_ASSERT(n >= 0 && n < m_nArgsLen);
+		return Files()[n];
+	}
+
+  private:
+	/*! @brief The argv array has it's members stored as either an offset into
+	   the string buffer, or as pointers to their string in the buffer. The offsets
+	   are used because if the string buffer is dynamically resized, all pointers
+	   into that buffer would become invalid.
+	 */
+	enum ARG_ARRAY_TYPE { OFFSETS, POINTERS };
+
+	/*! @brief Change the type of data stored in the argv array. */
+	void SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType);
+
+	/*! @brief Add a filename to the array if it passes all requirements. */
+	int AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir);
+
+	/*! @brief Grow the argv array to the required size. */
+	bool GrowArgvArray(int a_nNewLen);
+
+	/*! @brief Grow the string buffer to the required size. */
+	bool GrowStringBuffer(size_t a_uiMinSize);
+
+	/*! @brief Compare two (possible NULL) strings */
+	static int fileSortCompare(const void *a1, const void *a2);
+
+  private:
+	unsigned int m_uiFlags;
+	ARG_ARRAY_TYPE m_nArgArrayType;	//!< is the argv array storing indexes or pointers
+	SOCHAR **m_rgpArgs;			//!< argv array
+	int m_nReservedSlots;		//!< number of client reserved slots in the argv array
+	int m_nArgsSize;			//!< allocated size of array
+	int m_nArgsLen;				//!< used length
+	SOCHAR *m_pBuffer;			//!< argv string buffer
+	size_t m_uiBufferSize;		//!< allocated size of buffer
+	size_t m_uiBufferLen;		//!< used length of buffer
+	SOCHAR m_szPathPrefix[MAX_PATH];	//!< path prefix of any wildcard filenames
 };
 
 // ---------------------------------------------------------------------------
 //                                  IMPLEMENTATION
 // ---------------------------------------------------------------------------
 
-template<class SOCHAR>
-CSimpleGlobTempl<SOCHAR>::CSimpleGlobTempl(
-    unsigned int    a_uiFlags,
-    int             a_nReservedSlots
-    )
+template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::CSimpleGlobTempl(unsigned int a_uiFlags, int a_nReservedSlots)
 {
-    m_rgpArgs           = NULL;
-    m_nArgsSize         = 0;
-    m_pBuffer           = NULL;
-    m_uiBufferSize      = 0;
+	m_rgpArgs = NULL;
+	m_nArgsSize = 0;
+	m_pBuffer = NULL;
+	m_uiBufferSize = 0;
 
-    Init(a_uiFlags, a_nReservedSlots);
+	Init(a_uiFlags, a_nReservedSlots);
 }
 
-template<class SOCHAR>
-CSimpleGlobTempl<SOCHAR>::~CSimpleGlobTempl()
+template < class SOCHAR > CSimpleGlobTempl < SOCHAR >::~CSimpleGlobTempl()
 {
-    if (m_rgpArgs) free(m_rgpArgs);
-    if (m_pBuffer) free(m_pBuffer);
+	if (m_rgpArgs)
+		free(m_rgpArgs);
+	if (m_pBuffer)
+		free(m_pBuffer);
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Init(
-    unsigned int    a_uiFlags,
-    int             a_nReservedSlots
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Init(unsigned int a_uiFlags, int a_nReservedSlots)
 {
-    m_nArgArrayType     = POINTERS;
-    m_uiFlags           = a_uiFlags;
-    m_nArgsLen          = a_nReservedSlots;
-    m_nReservedSlots    = a_nReservedSlots;
-    m_uiBufferLen       = 0;
-
-    if (m_nReservedSlots > 0) {
-        if (!GrowArgvArray(m_nReservedSlots)) {
-            return SG_ERR_MEMORY;
-        }
-        for (int n = 0; n < m_nReservedSlots; ++n) {
-            m_rgpArgs[n] = NULL;
-        }
-    }
+	m_nArgArrayType = POINTERS;
+	m_uiFlags = a_uiFlags;
+	m_nArgsLen = a_nReservedSlots;
+	m_nReservedSlots = a_nReservedSlots;
+	m_uiBufferLen = 0;
+
+	if (m_nReservedSlots > 0) {
+		if (!GrowArgvArray(m_nReservedSlots)) {
+			return SG_ERR_MEMORY;
+		}
+		for (int n = 0; n < m_nReservedSlots; ++n) {
+			m_rgpArgs[n] = NULL;
+		}
+	}
 
-    return SG_SUCCESS;
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Add(
-    const SOCHAR *a_pszFileSpec
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(const SOCHAR * a_pszFileSpec)
 {
 #ifdef _WIN32
-    // Windows FindFirst/FindNext recognizes forward slash as the same as backward slash
-    // and follows the directories. We need to do the same when calculating the prefix
-    // and when we have no wildcards.
-    SOCHAR szFileSpec[MAX_PATH];
-    SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
-    const SOCHAR * pszPath = SimpleGlobUtil::strchr(szFileSpec, '/');
-    while (pszPath) {
-        szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR;
-        pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/');
-    }
-    a_pszFileSpec = szFileSpec;
+	// Windows FindFirst/FindNext recognizes forward slash as the same as backward slash
+	// and follows the directories. We need to do the same when calculating the prefix
+	// and when we have no wildcards.
+	SOCHAR szFileSpec[MAX_PATH];
+	SimpleGlobUtil::strcpy_s(szFileSpec, MAX_PATH, a_pszFileSpec);
+	const SOCHAR *pszPath = SimpleGlobUtil::strchr(szFileSpec, '/');
+	while (pszPath) {
+		szFileSpec[pszPath - szFileSpec] = SG_PATH_CHAR;
+		pszPath = SimpleGlobUtil::strchr(pszPath + 1, '/');
+	}
+	a_pszFileSpec = szFileSpec;
 #endif
 
-    // if this doesn't contain wildcards then we can just add it directly
-    m_szPathPrefix[0] = 0;
-    if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') &&
-        !SimpleGlobUtil::strchr(a_pszFileSpec, '?'))
-    {
-        SG_FileType nType = GetFileTypeS(a_pszFileSpec);
-        if (nType == SG_FILETYPE_INVALID) {
-            if (m_uiFlags & SG_GLOB_NOCHECK) {
-                return AppendName(a_pszFileSpec, false);
-            }
-            return SG_ERR_NOMATCH;
-        }
-        return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR);
-    }
-
+	// if this doesn't contain wildcards then we can just add it directly
+	m_szPathPrefix[0] = 0;
+	if (!SimpleGlobUtil::strchr(a_pszFileSpec, '*') && !SimpleGlobUtil::strchr(a_pszFileSpec, '?')) {
+		SG_FileType nType = GetFileTypeS(a_pszFileSpec);
+		if (nType == SG_FILETYPE_INVALID) {
+			if (m_uiFlags & SG_GLOB_NOCHECK) {
+				return AppendName(a_pszFileSpec, false);
+			}
+			return SG_ERR_NOMATCH;
+		}
+		return AppendName(a_pszFileSpec, nType == SG_FILETYPE_DIR);
+	}
 #ifdef _WIN32
-    // Windows doesn't return the directory with the filename, so we need to extract the
-    // path from the search string ourselves and prefix it to the filename we get back.
-    const SOCHAR * pszFilename = SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
-    if (pszFilename) {
-        SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
-        m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0;
-    }
+	// Windows doesn't return the directory with the filename, so we need to extract the
+	// path from the search string ourselves and prefix it to the filename we get back.
+	const SOCHAR *pszFilename = SimpleGlobUtil::strrchr(a_pszFileSpec, SG_PATH_CHAR);
+	if (pszFilename) {
+		SimpleGlobUtil::strcpy_s(m_szPathPrefix, MAX_PATH, a_pszFileSpec);
+		m_szPathPrefix[pszFilename - a_pszFileSpec + 1] = 0;
+	}
 #endif
 
-    // search for the first match on the file
-    int rc = FindFirstFileS(a_pszFileSpec, m_uiFlags);
-    if (rc != SG_SUCCESS) {
-        if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) {
-            int ok = AppendName(a_pszFileSpec, false);
-            if (ok != SG_SUCCESS) rc = ok;
-        }
-        return rc;
-    }
-
-    // add it and find all subsequent matches
-    int nError, nStartLen = m_nArgsLen;
-    bool bSuccess;
-    do {
-        nError = AppendName(GetFileNameS((SOCHAR)0), IsDirS((SOCHAR)0));
-        bSuccess = FindNextFileS((SOCHAR)0);
-    }
-    while (nError == SG_SUCCESS && bSuccess);
-    SimpleGlobBase<SOCHAR>::FindDone();
-
-    // sort these files if required
-    if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) {
-        if (m_uiFlags & SG_GLOB_FULLSORT) {
-            nStartLen = m_nReservedSlots;
-        }
-        SetArgvArrayType(POINTERS);
-        qsort(
-            m_rgpArgs + nStartLen,
-            m_nArgsLen - nStartLen,
-            sizeof(m_rgpArgs[0]), fileSortCompare);
-    }
+	// search for the first match on the file
+	int rc = FindFirstFileS(a_pszFileSpec, m_uiFlags);
+	if (rc != SG_SUCCESS) {
+		if (rc == SG_ERR_NOMATCH && (m_uiFlags & SG_GLOB_NOCHECK)) {
+			int ok = AppendName(a_pszFileSpec, false);
+			if (ok != SG_SUCCESS)
+				rc = ok;
+		}
+		return rc;
+	}
+	// add it and find all subsequent matches
+	int nError, nStartLen = m_nArgsLen;
+	bool bSuccess;
+	do {
+		nError = AppendName(GetFileNameS((SOCHAR) 0), IsDirS((SOCHAR) 0));
+		bSuccess = FindNextFileS((SOCHAR) 0);
+	}
+	while (nError == SG_SUCCESS && bSuccess);
+	SimpleGlobBase < SOCHAR >::FindDone();
+
+	// sort these files if required
+	if (m_nArgsLen > nStartLen && !(m_uiFlags & SG_GLOB_NOSORT)) {
+		if (m_uiFlags & SG_GLOB_FULLSORT) {
+			nStartLen = m_nReservedSlots;
+		}
+		SetArgvArrayType(POINTERS);
+		qsort(m_rgpArgs + nStartLen, m_nArgsLen - nStartLen, sizeof(m_rgpArgs[0]), fileSortCompare);
+	}
 
-    return nError;
+	return nError;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::Add(
-    int                     a_nCount,
-    const SOCHAR * const *  a_rgpszFileSpec
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::Add(int a_nCount, const SOCHAR * const *a_rgpszFileSpec)
 {
-    int nResult;
-    for (int n = 0; n < a_nCount; ++n) {
-        nResult = Add(a_rgpszFileSpec[n]);
-        if (nResult != SG_SUCCESS) {
-            return nResult;
-        }
-    }
-    return SG_SUCCESS;
+	int nResult;
+	for (int n = 0; n < a_nCount; ++n) {
+		nResult = Add(a_rgpszFileSpec[n]);
+		if (nResult != SG_SUCCESS) {
+			return nResult;
+		}
+	}
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::AppendName(
-    const SOCHAR *  a_pszFileName,
-    bool            a_bIsDir
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::AppendName(const SOCHAR * a_pszFileName, bool a_bIsDir)
 {
-    // we need the argv array as offsets in case we resize it
-    SetArgvArrayType(OFFSETS);
+	// we need the argv array as offsets in case we resize it
+	SetArgvArrayType(OFFSETS);
 
-    // check for special cases which cause us to ignore this entry
-    if ((m_uiFlags & SG_GLOB_ONLYDIR) && !a_bIsDir) {
-        return SG_SUCCESS;
-    }
-    if ((m_uiFlags & SG_GLOB_ONLYFILE) && a_bIsDir) {
-        return SG_SUCCESS;
-    }
-    if ((m_uiFlags & SG_GLOB_NODOT) && a_bIsDir) {
-        if (a_pszFileName[0] == '.') {
-            if (a_pszFileName[1] == '\0') {
-                return SG_SUCCESS;
-            }
-            if (a_pszFileName[1] == '.' && a_pszFileName[2] == '\0') {
-                return SG_SUCCESS;
-            }
-        }
-    }
-
-    // ensure that we have enough room in the argv array
-    if (!GrowArgvArray(m_nArgsLen + 1)) {
-        return SG_ERR_MEMORY;
-    }
-
-    // ensure that we have enough room in the string buffer
-    size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
-    size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1; // + null character
-    if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
-        ++uiLen;    // need space for the backslash
-    }
-    if (!GrowStringBuffer(m_uiBufferLen + uiLen)) {
-        return SG_ERR_MEMORY;
-    }
-
-    // add this entry
-    m_rgpArgs[m_nArgsLen++] = (SOCHAR*)m_uiBufferLen;    // offset from beginning of buffer
-    SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen,
-        m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
-    SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen,
-        m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
-    m_uiBufferLen += uiLen;
-
-    // add the directory slash if desired
-    if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
-        const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 };
-        SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2,
-            m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
-    }
+	// check for special cases which cause us to ignore this entry
+	if ((m_uiFlags & SG_GLOB_ONLYDIR) && !a_bIsDir) {
+		return SG_SUCCESS;
+	}
+	if ((m_uiFlags & SG_GLOB_ONLYFILE) && a_bIsDir) {
+		return SG_SUCCESS;
+	}
+	if ((m_uiFlags & SG_GLOB_NODOT) && a_bIsDir) {
+		if (a_pszFileName[0] == '.') {
+			if (a_pszFileName[1] == '\0') {
+				return SG_SUCCESS;
+			}
+			if (a_pszFileName[1] == '.' && a_pszFileName[2] == '\0') {
+				return SG_SUCCESS;
+			}
+		}
+	}
+	// ensure that we have enough room in the argv array
+	if (!GrowArgvArray(m_nArgsLen + 1)) {
+		return SG_ERR_MEMORY;
+	}
+	// ensure that we have enough room in the string buffer
+	size_t uiPrefixLen = SimpleGlobUtil::strlen(m_szPathPrefix);
+	size_t uiLen = uiPrefixLen + SimpleGlobUtil::strlen(a_pszFileName) + 1;	// + null character
+	if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
+		++uiLen;				// need space for the backslash
+	}
+	if (!GrowStringBuffer(m_uiBufferLen + uiLen)) {
+		return SG_ERR_MEMORY;
+	}
+	// add this entry
+	m_rgpArgs[m_nArgsLen++] = (SOCHAR *) m_uiBufferLen;	// offset from beginning of buffer
+	SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen, m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
+	SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen, m_uiBufferSize - m_uiBufferLen - uiPrefixLen, a_pszFileName);
+	m_uiBufferLen += uiLen;
+
+	// add the directory slash if desired
+	if (a_bIsDir && (m_uiFlags & SG_GLOB_MARK) == SG_GLOB_MARK) {
+		const static SOCHAR szDirSlash[] = { SG_PATH_CHAR, 0 };
+		SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen - 2, m_uiBufferSize - (m_uiBufferLen - 2), szDirSlash);
+	}
 
-    return SG_SUCCESS;
+	return SG_SUCCESS;
 }
 
-template<class SOCHAR>
-void
-CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
-    ARG_ARRAY_TYPE  a_nNewType
-    )
+template < class SOCHAR > void CSimpleGlobTempl < SOCHAR >::SetArgvArrayType(ARG_ARRAY_TYPE a_nNewType)
 {
-    if (m_nArgArrayType == a_nNewType) return;
-    if (a_nNewType == POINTERS) {
-        SG_ASSERT(m_nArgArrayType == OFFSETS);
-        for (int n = 0; n < m_nArgsLen; ++n) {
-            m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR*)-1) ?
-                NULL : m_pBuffer + (size_t) m_rgpArgs[n];
-        }
-    }
-    else {
-        SG_ASSERT(a_nNewType == OFFSETS);
-        SG_ASSERT(m_nArgArrayType == POINTERS);
-        for (int n = 0; n < m_nArgsLen; ++n) {
-            m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ?
-                (SOCHAR*) -1 : (SOCHAR*) (m_rgpArgs[n] - m_pBuffer);
-        }
-    }
-    m_nArgArrayType = a_nNewType;
+	if (m_nArgArrayType == a_nNewType)
+		return;
+	if (a_nNewType == POINTERS) {
+		SG_ASSERT(m_nArgArrayType == OFFSETS);
+		for (int n = 0; n < m_nArgsLen; ++n) {
+			m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR *) - 1) ? NULL : m_pBuffer + (size_t) m_rgpArgs[n];
+		}
+	} else {
+		SG_ASSERT(a_nNewType == OFFSETS);
+		SG_ASSERT(m_nArgArrayType == POINTERS);
+		for (int n = 0; n < m_nArgsLen; ++n) {
+			m_rgpArgs[n] = (m_rgpArgs[n] == NULL) ? (SOCHAR *) - 1 : (SOCHAR *) (m_rgpArgs[n] - m_pBuffer);
+		}
+	}
+	m_nArgArrayType = a_nNewType;
 }
 
-template<class SOCHAR>
-bool
-CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
-    int a_nNewLen
-    )
+template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowArgvArray(int a_nNewLen)
 {
-    if (a_nNewLen >= m_nArgsSize) {
-        static const int SG_ARGV_INITIAL_SIZE = 32;
-        int nNewSize = (m_nArgsSize > 0) ? m_nArgsSize * 2 : SG_ARGV_INITIAL_SIZE;
-        while (a_nNewLen >= nNewSize) {
-            nNewSize *= 2;
-        }
-        void * pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR*));
-        if (!pNewBuffer) return false;
-        m_nArgsSize = nNewSize;
-        m_rgpArgs = (SOCHAR**) pNewBuffer;
-    }
-    return true;
+	if (a_nNewLen >= m_nArgsSize) {
+		static const int SG_ARGV_INITIAL_SIZE = 32;
+		int nNewSize = (m_nArgsSize > 0) ? m_nArgsSize * 2 : SG_ARGV_INITIAL_SIZE;
+		while (a_nNewLen >= nNewSize) {
+			nNewSize *= 2;
+		}
+		void *pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR *));
+		if (!pNewBuffer)
+			return false;
+		m_nArgsSize = nNewSize;
+		m_rgpArgs = (SOCHAR **) pNewBuffer;
+	}
+	return true;
 }
 
-template<class SOCHAR>
-bool
-CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
-    size_t a_uiMinSize
-    )
+template < class SOCHAR > bool CSimpleGlobTempl < SOCHAR >::GrowStringBuffer(size_t a_uiMinSize)
 {
-    if (a_uiMinSize >= m_uiBufferSize) {
-        static const int SG_BUFFER_INITIAL_SIZE = 1024;
-        size_t uiNewSize = (m_uiBufferSize > 0) ? m_uiBufferSize * 2 : SG_BUFFER_INITIAL_SIZE;
-        while (a_uiMinSize >= uiNewSize) {
-            uiNewSize *= 2;
-        }
-        void * pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
-        if (!pNewBuffer) return false;
-        m_uiBufferSize = uiNewSize;
-        m_pBuffer = (SOCHAR*) pNewBuffer;
-    }
-    return true;
+	if (a_uiMinSize >= m_uiBufferSize) {
+		static const int SG_BUFFER_INITIAL_SIZE = 1024;
+		size_t uiNewSize = (m_uiBufferSize > 0) ? m_uiBufferSize * 2 : SG_BUFFER_INITIAL_SIZE;
+		while (a_uiMinSize >= uiNewSize) {
+			uiNewSize *= 2;
+		}
+		void *pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
+		if (!pNewBuffer)
+			return false;
+		m_uiBufferSize = uiNewSize;
+		m_pBuffer = (SOCHAR *) pNewBuffer;
+	}
+	return true;
 }
 
-template<class SOCHAR>
-int
-CSimpleGlobTempl<SOCHAR>::fileSortCompare(
-    const void *a1,
-    const void *a2
-    )
+template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::fileSortCompare(const void *a1, const void *a2)
 {
-    const SOCHAR * s1 = *(const SOCHAR **)a1;
-    const SOCHAR * s2 = *(const SOCHAR **)a2;
-    if (s1 && s2) {
-        return SimpleGlobUtil::strcasecmp(s1, s2);
-    }
-    // NULL sorts first
-    return s1 == s2 ? 0 : (s1 ? 1 : -1);
+	const SOCHAR *s1 = *(const SOCHAR **) a1;
+	const SOCHAR *s2 = *(const SOCHAR **) a2;
+	if (s1 && s2) {
+		return SimpleGlobUtil::strcasecmp(s1, s2);
+	}
+	// NULL sorts first
+	return s1 == s2 ? 0 : (s1 ? 1 : -1);
 }
 
 // ---------------------------------------------------------------------------
 //                                  TYPE DEFINITIONS
 // ---------------------------------------------------------------------------
 
-typedef CSimpleGlobTempl<char>    CSimpleGlobA; /*!< @brief ASCII/MBCS version of CSimpleGlob */
-typedef CSimpleGlobTempl<wchar_t> CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */
+typedef CSimpleGlobTempl < char >CSimpleGlobA;	/*!< @brief ASCII/MBCS version of CSimpleGlob */
+typedef CSimpleGlobTempl < wchar_t >CSimpleGlobW;	/*!< @brief wchar_t version of CSimpleGlob */
 #if defined(_UNICODE)
-# define CSimpleGlob CSimpleGlobW   /*!< @brief TCHAR version dependent on if _UNICODE is defined */
+# define CSimpleGlob CSimpleGlobW	/*!< @brief TCHAR version dependent on if _UNICODE is defined */
 #else
-# define CSimpleGlob CSimpleGlobA   /*!< @brief TCHAR version dependent on if _UNICODE is defined */
+# define CSimpleGlob CSimpleGlobA	/*!< @brief TCHAR version dependent on if _UNICODE is defined */
 #endif
 
 #endif // INCLUDED_SimpleGlob

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/g711.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/g711.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/g711.h	Tue May 27 07:24:06 2008
@@ -50,137 +50,108 @@
 #ifndef __inline__
 #define __inline__ __inline
 #endif
-typedef unsigned __int8 uint8_t;
-typedef __int16 int16_t;
-typedef __int32 int32_t;
-typedef unsigned __int16 uint16_t;
+	typedef unsigned __int8 uint8_t;
+	typedef __int16 int16_t;
+	typedef __int32 int32_t;
+	typedef unsigned __int16 uint16_t;
 #endif
 
 #if defined(__i386__)
 /*! \brief Find the bit position of the highest set bit in a word
     \param bits The word to be searched
     \return The bit number of the highest set bit, or -1 if the word is zero. */
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsrl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+	static __inline__ int top_bit(unsigned int bits) {
+		int res;
 
-/*! \brief Find the bit position of the lowest set bit in a word
-    \param bits The word to be searched
-    \return The bit number of the lowest set bit, or -1 if the word is zero. */
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsfl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
+		__asm__ __volatile__(" movl $-1,%%edx;\n" " bsrl %%eax,%%edx;\n":"=d"(res)
+							 :"a"    (bits));
+		        return res;
+	}
+	/*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
+	   \param bits The word to be searched
+	   \return The bit number of the lowest set bit, or -1 if the word is zero. */ static __inline__ int bottom_bit(unsigned int bits) {
+		int res;
+
+		__asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
+							 :"a"    (bits));
+		return res;
+	}
 /*- End of function --------------------------------------------------------*/
 #elif defined(__x86_64__)
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsrq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+	static __inline__ int top_bit(unsigned int bits) {
+		int res;
 
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsfq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
+		__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsrq %%rax,%%rdx;\n":"=d"(res)
+							 :"a"    (bits));
+		        return res;
+	}
+/*- End of function --------------------------------------------------------*/ static __inline__ int bottom_bit(unsigned int bits) {
+		int res;
+
+		__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
+							 :"a"    (bits));
+		return res;
+	}
 /*- End of function --------------------------------------------------------*/
 #else
-static __inline__ int top_bit(unsigned int bits)
-{
-    int i;
-    
-    if (bits == 0)
-        return -1;
-    i = 0;
-    if (bits & 0xFFFF0000)
-    {
-        bits &= 0xFFFF0000;
-        i += 16;
-    }
-    if (bits & 0xFF00FF00)
-    {
-        bits &= 0xFF00FF00;
-        i += 8;
-    }
-    if (bits & 0xF0F0F0F0)
-    {
-        bits &= 0xF0F0F0F0;
-        i += 4;
-    }
-    if (bits & 0xCCCCCCCC)
-    {
-        bits &= 0xCCCCCCCC;
-        i += 2;
-    }
-    if (bits & 0xAAAAAAAA)
-    {
-        bits &= 0xAAAAAAAA;
-        i += 1;
-    }
-    return i;
-}
+	static __inline__ int top_bit(unsigned int bits) {
+		int i;
+
+		if  (bits == 0)
+			return -1;
+		    i = 0;
+		if  (bits & 0xFFFF0000) {
+			bits &= 0xFFFF0000;
+			i += 16;
+		}
+		if     (bits & 0xFF00FF00) {
+			bits &= 0xFF00FF00;
+			i += 8;
+		}
+		if (bits & 0xF0F0F0F0) {
+			bits &= 0xF0F0F0F0;
+			i += 4;
+		}
+		if (bits & 0xCCCCCCCC) {
+			bits &= 0xCCCCCCCC;
+			i += 2;
+		}
+		if (bits & 0xAAAAAAAA) {
+			bits &= 0xAAAAAAAA;
+			i += 1;
+		}
+		return i;
+	}
 /*- End of function --------------------------------------------------------*/
 
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int i;
-    
-    if (bits == 0)
-        return -1;
-    i = 32;
-    if (bits & 0x0000FFFF)
-    {
-        bits &= 0x0000FFFF;
-        i -= 16;
-    }
-    if (bits & 0x00FF00FF)
-    {
-        bits &= 0x00FF00FF;
-        i -= 8;
-    }
-    if (bits & 0x0F0F0F0F)
-    {
-        bits &= 0x0F0F0F0F;
-        i -= 4;
-    }
-    if (bits & 0x33333333)
-    {
-        bits &= 0x33333333;
-        i -= 2;
-    }
-    if (bits & 0x55555555)
-    {
-        bits &= 0x55555555;
-        i -= 1;
-    }
-    return i;
-}
+	static __inline__ int bottom_bit(unsigned int bits) {
+		int i;
+
+		if (bits == 0)
+			return -1;
+		i = 32;
+		if (bits & 0x0000FFFF) {
+			bits &= 0x0000FFFF;
+			i -= 16;
+		}
+		if (bits & 0x00FF00FF) {
+			bits &= 0x00FF00FF;
+			i -= 8;
+		}
+		if (bits & 0x0F0F0F0F) {
+			bits &= 0x0F0F0F0F;
+			i -= 4;
+		}
+		if (bits & 0x33333333) {
+			bits &= 0x33333333;
+			i -= 2;
+		}
+		if (bits & 0x55555555) {
+			bits &= 0x55555555;
+			i -= 1;
+		}
+		return i;
+	}
 /*- End of function --------------------------------------------------------*/
 #endif
 
@@ -194,7 +165,7 @@
  *      segment, but a little inline assembly can fix that on an i386, x86_64 and
  *      many other modern processors.
  */
- 
+
 /*
  * Mu-law is basically as follows:
  *
@@ -222,66 +193,61 @@
  */
 
 //#define ULAW_ZEROTRAP                 /* turn on the trap as per the MIL-STD */
-#define ULAW_BIAS        0x84           /* Bias for linear code. */
+#define ULAW_BIAS        0x84	/* Bias for linear code. */
 
 /*! \brief Encode a linear sample to u-law
     \param linear The sample to encode.
     \return The u-law value.
 */
-static __inline__ uint8_t linear_to_ulaw(int linear)
-{
-    uint8_t u_val;
-    int mask;
-    int seg;
-
-    /* Get the sign and the magnitude of the value. */
-    if (linear < 0)
-    {
-        linear = ULAW_BIAS - linear;
-        mask = 0x7F;
-    }
-    else
-    {
-        linear = ULAW_BIAS + linear;
-        mask = 0xFF;
-    }
-
-    seg = top_bit(linear | 0xFF) - 7;
-
-    /*
-     * Combine the sign, segment, quantization bits,
-     * and complement the code word.
-     */
-    if (seg >= 8)
-        u_val = (uint8_t) (0x7F ^ mask);
-    else
-        u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
+	static __inline__ uint8_t linear_to_ulaw(int linear) {
+		uint8_t u_val;
+		int mask;
+		int seg;
+
+		/* Get the sign and the magnitude of the value. */
+		if (linear < 0) {
+			linear = ULAW_BIAS - linear;
+			mask = 0x7F;
+		} else {
+			linear = ULAW_BIAS + linear;
+			mask = 0xFF;
+		}
+
+		seg = top_bit(linear | 0xFF) - 7;
+
+		/*
+		 * Combine the sign, segment, quantization bits,
+		 * and complement the code word.
+		 */
+		if (seg >= 8)
+			u_val = (uint8_t) (0x7F ^ mask);
+		else
+			u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
 #ifdef ULAW_ZEROTRAP
-    /* Optional ITU trap */
-    if (u_val == 0)
-        u_val = 0x02;
+		/* Optional ITU trap */
+		if (u_val == 0)
+			u_val = 0x02;
 #endif
-    return  u_val;
-}
+		return u_val;
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Decode an u-law sample to a linear value.
     \param ulaw The u-law sample to decode.
     \return The linear value.
 */
-static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
-{
-    int t;
-    
-    /* Complement to obtain normal u-law value. */
-    ulaw = ~ulaw;
-    /*
-     * Extract and bias the quantization bits. Then
-     * shift up by the segment number and subtract out the bias.
-     */
-    t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
-    return  (int16_t) ((ulaw & 0x80)  ?  (ULAW_BIAS - t)  :  (t - ULAW_BIAS));
-}
+	static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) {
+		int t;
+
+		/* Complement to obtain normal u-law value. */
+		ulaw = ~ulaw;
+		/*
+		 * Extract and bias the quantization bits. Then
+		 * shift up by the segment number and subtract out the bias.
+		 */
+		t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
+		return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*
@@ -308,71 +274,64 @@
     \param linear The sample to encode.
     \return The A-law value.
 */
-static __inline__ uint8_t linear_to_alaw(int linear)
-{
-    int mask;
-    int seg;
-    
-    if (linear >= 0)
-    {
-        /* Sign (bit 7) bit = 1 */
-        mask = ALAW_AMI_MASK | 0x80;
-    }
-    else
-    {
-        /* Sign (bit 7) bit = 0 */
-        mask = ALAW_AMI_MASK;
-        linear = -linear - 8;
-    }
-
-    /* Convert the scaled magnitude to segment number. */
-    seg = top_bit(linear | 0xFF) - 7;
-    if (seg >= 8)
-    {
-        if (linear >= 0)
-        {
-            /* Out of range. Return maximum value. */
-            return (uint8_t) (0x7F ^ mask);
-        }
-        /* We must be just a tiny step below zero */
-        return (uint8_t) (0x00 ^ mask);
-    }
-    /* Combine the sign, segment, and quantization bits. */
-    return (uint8_t) (((seg << 4) | ((linear >> ((seg)  ?  (seg + 3)  :  4)) & 0x0F)) ^ mask);
-}
+	static __inline__ uint8_t linear_to_alaw(int linear) {
+		int mask;
+		int seg;
+
+		if (linear >= 0) {
+			/* Sign (bit 7) bit = 1 */
+			mask = ALAW_AMI_MASK | 0x80;
+		} else {
+			/* Sign (bit 7) bit = 0 */
+			mask = ALAW_AMI_MASK;
+			linear = -linear - 8;
+		}
+
+		/* Convert the scaled magnitude to segment number. */
+		seg = top_bit(linear | 0xFF) - 7;
+		if (seg >= 8) {
+			if (linear >= 0) {
+				/* Out of range. Return maximum value. */
+				return (uint8_t) (0x7F ^ mask);
+			}
+			/* We must be just a tiny step below zero */
+			return (uint8_t) (0x00 ^ mask);
+		}
+		/* Combine the sign, segment, and quantization bits. */
+		return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Decode an A-law sample to a linear value.
     \param alaw The A-law sample to decode.
     \return The linear value.
 */
-static __inline__ int16_t alaw_to_linear(uint8_t alaw)
-{
-    int i;
-    int seg;
-
-    alaw ^= ALAW_AMI_MASK;
-    i = ((alaw & 0x0F) << 4);
-    seg = (((int) alaw & 0x70) >> 4);
-    if (seg)
-        i = (i + 0x108) << (seg - 1);
-    else
-        i += 8;
-    return (int16_t) ((alaw & 0x80)  ?  i  :  -i);
-}
+	static __inline__ int16_t alaw_to_linear(uint8_t alaw) {
+		int i;
+		int seg;
+
+		alaw ^= ALAW_AMI_MASK;
+		i = ((alaw & 0x0F) << 4);
+		seg = (((int) alaw & 0x70) >> 4);
+		if (seg)
+			i = (i + 0x108) << (seg - 1);
+		else
+			i += 8;
+		return (int16_t) ((alaw & 0x80) ? i : -i);
+	}
 /*- End of function --------------------------------------------------------*/
 
 /*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
     \param alaw The A-law sample to transcode.
     \return The best matching u-law value.
 */
-uint8_t alaw_to_ulaw(uint8_t alaw);
+	uint8_t alaw_to_ulaw(uint8_t alaw);
 
 /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
     \param ulaw The u-law sample to transcode.
     \return The best matching A-law value.
 */
-uint8_t ulaw_to_alaw(uint8_t ulaw);
+	uint8_t ulaw_to_alaw(uint8_t ulaw);
 
 #ifdef __cplusplus
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_apr.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_apr.h	Tue May 27 07:24:06 2008
@@ -56,8 +56,6 @@
  */
 /** The fundamental pool type */
 /* see switch types.h 	typedef struct apr_pool_t switch_memory_pool_t;*/
-
-
 /**
  * Clear all memory in the pool and run all the cleanups. This also destroys all
  * subpools.
@@ -93,13 +91,13 @@
  * @bug We aught to provide an alternative to RTLD_GLOBAL, which
  * is the only supported method of loading DSOs today.
  */
-SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx);
+SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, const char *path, switch_memory_pool_t *ctx);
 
 /**
  * Close a DSO library.
  * @param handle handle to close.
  */
-SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t * handle);
+SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle);
 
 /**
  * Load a symbol from a DSO handle.
@@ -107,7 +105,7 @@
  * @param handle handle to load the symbol from.
  * @param symname Name of the symbol to load.
  */
-SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t * ressym, switch_dso_handle_t * handle, const char *symname);
+SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t *ressym, switch_dso_handle_t *handle, const char *symname);
 
 /**
  * Report more information when a DSO function fails.
@@ -115,7 +113,7 @@
  * @param buf Location to store the dso error
  * @param bufsize The size of the provided buffer
  */
-SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t * dso, char *buf, size_t bufsize);
+SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t *dso, char *buf, size_t bufsize);
 
 /** @} */
 
@@ -125,11 +123,13 @@
  * @{
  */
 
-SWITCH_DECLARE(int) switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format, ...);
+SWITCH_DECLARE(int) switch_snprintf(_Out_z_cap_(len)
+									char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format, ...);
 
 SWITCH_DECLARE(int) switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap);
 
-SWITCH_DECLARE(char *) switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size);
+SWITCH_DECLARE(char *) switch_copy_string(_Out_z_cap_(dst_size)
+										  char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size);
 
 /** @} */
 
@@ -164,7 +164,7 @@
  * progress at the same time.
 
  */
-SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p, switch_hash_t * ht);
+SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p, switch_hash_t *ht);
 
 /**
  * Continue iterating over the entries in a hash table.
@@ -172,7 +172,7 @@
  * @return a pointer to the updated iteration state.  NULL if there are no more  
  *         entries.
  */
-SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t * ht);
+SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t *ht);
 
 /**
  * Get the current entry's details from the iteration state.
@@ -183,11 +183,11 @@
  * @remark The return pointers should point to a variable that will be set to the
  *         corresponding data, or they may be NULL if the data isn't interesting.
  */
-SWITCH_DECLARE(void) switch_hash_this(switch_hash_index_t * hi, const void **key, switch_ssize_t *klen, void **val);
+SWITCH_DECLARE(void) switch_hash_this(switch_hash_index_t *hi, const void **key, switch_ssize_t *klen, void **val);
 
 
 
-SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t * ht);
+SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t *ht);
 
 /** @} */
 
@@ -258,7 +258,7 @@
  * @param result the resulting imploded time
  * @param input the input exploded time
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result, switch_time_exp_t * input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, switch_time_exp_t *input);
 
 /**
  * formats the exploded time according to the format specified
@@ -268,7 +268,7 @@
  * @param format The format for the time string
  * @param tm The time to convert
  */
-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);
+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);
 
 /**
  * switch_rfc822_date formats dates in the RFC822
@@ -285,7 +285,7 @@
  * @param result the exploded time
  * @param input the time to explode
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result, switch_time_t input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input);
 
 /**
  * Convert time value from human readable format to a numeric apr_time_t 
@@ -293,14 +293,14 @@
  * @param result the resulting imploded time
  * @param input the input exploded time
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t * result, switch_time_exp_t * input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t *result, switch_time_exp_t *input);
 
 /**
  * convert a time to its human readable components in local timezone
  * @param result the exploded time
  * @param input the time to explode
  */
-SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t * result, switch_time_t input);
+SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input);
 
 /**
  * Sleep for the specified number of micro-seconds.
@@ -341,27 +341,27 @@
  * it will behave as either a nested or an unnested lock.
  *
 */
-SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool);
 
 
 /**
  * Destroy the mutex and free the memory associated with the lock.
  * @param lock the mutex to destroy.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t *lock);
 
 /**
  * Acquire the lock for the given mutex. If the mutex is already locked,
  * the current thread will be put to sleep until the lock becomes available.
  * @param lock the mutex on which to acquire the lock.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t *lock);
 
 /**
  * Release the lock for the given mutex.
  * @param lock the mutex from which to release the lock.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t *lock);
 
 /**
  * Attempt to acquire the lock for the given mutex. If the mutex has already
@@ -370,7 +370,7 @@
  * if the return value was APR_EBUSY, for portability reasons.
  * @param lock the mutex on which to attempt the lock acquiring.
  */
-SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t * lock);
+SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock);
 
 /** @} */
 
@@ -383,14 +383,14 @@
 /** Opaque structure used for the rwlock */
 	 typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
 
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t * rwlock);
-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t * rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_trywrlock(switch_thread_rwlock_t *rwlock);
+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock);
 
 /** @} */
 
@@ -416,7 +416,7 @@
  *        will be stored.
  * @param pool the pool from which to allocate the mutex.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool);
 
 /**
  * Put the active calling thread to sleep until signaled to wake up. Each
@@ -430,7 +430,7 @@
  *        is released while the thread is asleep, and is again acquired before
  *        returning from this function.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t * cond, switch_mutex_t * mutex);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex);
 
 /**
  * Put the active calling thread to sleep until signaled to wake up or
@@ -448,7 +448,7 @@
  *        will wake up before this time, otherwise the error APR_TIMEUP
  *        is returned.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t * cond, switch_mutex_t * mutex, switch_interval_time_t timeout);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, switch_interval_time_t timeout);
 
 /**
  * Signals a single thread, if one exists, that is blocking on the given
@@ -457,7 +457,7 @@
  * is desired, that mutex must be locked while calling this function.
  * @param cond the condition variable on which to produce the signal.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_signal(switch_thread_cond_t *cond);
 
 /**
  * Signals all threads blocking on the given condition variable.
@@ -465,13 +465,13 @@
  * the associated mutex. This will happen in a serialized manner.
  * @param cond the condition variable on which to produce the broadcast.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_broadcast(switch_thread_cond_t *cond);
 
 /**
  * Destroy the condition variable and free the associated memory.
  * @param cond the condition variable to destroy.
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t * cond);
+SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t *cond);
 
 /** @} */
 
@@ -498,20 +498,20 @@
  *               the formatted UUID and a null terminator
  * @param uuid The UUID to format
  */
-SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t * uuid);
+SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid);
 
 /**
  * Generate and return a (new) UUID
  * @param uuid The resulting UUID
  */
-SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t * uuid);
+SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t *uuid);
 
 /**
  * Parse a standard-format string into a UUID
  * @param uuid The resulting UUID
  * @param uuid_str The formatted UUID
  */
-SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t * uuid, const char *uuid_str);
+SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str);
 
 /** @} */
 
@@ -530,7 +530,7 @@
  * @param queue_capacity maximum size of the queue
  * @param pool a pool to allocate queue from
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, unsigned int queue_capacity, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool);
 
 /**
  * pop/get an object from the queue, blocking if the queue is already empty
@@ -541,7 +541,7 @@
  * @returns APR_EOF if the queue has been terminated
  * @returns APR_SUCCESS on a successfull pop
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t * queue, void **data);
+SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t *queue, void **data);
 
 /**
  * push/add a object to the queue, blocking if the queue is already full
@@ -552,7 +552,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void *data);
+SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t *queue, void *data);
 
 /**
  * returns the size of the queue.
@@ -562,7 +562,7 @@
  * @param queue the queue
  * @returns the size of the queue
  */
-SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t * queue);
+SWITCH_DECLARE(unsigned int) switch_queue_size(switch_queue_t *queue);
 
 /**
  * pop/get an object to the queue, returning immediatly if the queue is empty
@@ -574,7 +574,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t * queue, void **data);
+SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t *queue, void **data);
 
 /**
  * push/add a object to the queue, returning immediatly if the queue is full
@@ -586,7 +586,7 @@
  * @returns APR_EOF the queue has been terminated
  * @returns APR_SUCCESS on a successfull push
  */
-SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t * queue, void *data);
+SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void *data);
 
 /** @} */
 
@@ -650,13 +650,13 @@
  * @{
  */
 
-#define SWITCH_FLOCK_SHARED        1       /**< Shared lock. More than one process
+#define SWITCH_FLOCK_SHARED        1	   /**< Shared lock. More than one process
                                            or thread can hold a shared lock
                                            at any given time. Essentially,
                                            this is a "read lock", preventing
                                            writers from establishing an
                                            exclusive lock. */
-#define SWITCH_FLOCK_EXCLUSIVE     2       /**< Exclusive lock. Only one process
+#define SWITCH_FLOCK_EXCLUSIVE     2	   /**< Exclusive lock. Only one process
                                            may hold an exclusive lock at any
                                            given time. This is analogous to
                                            a "write lock". */
@@ -722,19 +722,19 @@
  * @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created,
  * appropriate default permissions will be used.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t ** newf, const char *fname, int32_t flag, switch_fileperms_t perm,
+SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm,
 												 switch_memory_pool_t *pool);
 
 
-SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t * thefile, switch_seek_where_t where, int64_t *offset);
+SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset);
 
 /**
  * Close the specified file.
  * @param thefile The file descriptor to close.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t * thefile);
+SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t *thefile);
 
-SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t * thefile, int type);
+SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t *thefile, int type);
 
 /**
  * Delete the specified file.
@@ -764,7 +764,7 @@
  * @remark It is not possible for both bytes to be read and an APR_EOF
  * or other error to be returned.  APR_EINTR is never returned.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t * thefile, void *buf, switch_size_t *nbytes);
+SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t *thefile, void *buf, switch_size_t *nbytes);
 
 /**
  * Write data to the specified file.
@@ -781,7 +781,7 @@
  * @remark It is possible for both bytes to be written and an error to
  * be returned.  APR_EINTR is never returned.
  */
-SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const void *buf, switch_size_t *nbytes);
+SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes);
 SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...);
 
 SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool);
@@ -798,8 +798,7 @@
 * @param perm Permissions for the new direcoty.
 * @param pool the pool to use.
 */
-SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm,
-												switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
 
 /** Creates a new directory on the file system, but behaves like
 * 'mkdir -p'. Creates intermediate directories as required. No error
@@ -808,24 +807,23 @@
 * @param perm Permissions for the new direcoty.
 * @param pool the pool to use.
 */
-SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm,
-														  switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool);
 
-typedef struct switch_dir switch_dir_t;
+	 typedef struct switch_dir switch_dir_t;
 
-struct switch_array_header_t {
-    /** The pool the array is allocated out of */
-    switch_memory_pool_t *pool;
-    /** The amount of memory allocated for each element of the array */
-    int elt_size;
-    /** The number of active elements in the array */
-    int nelts;
-    /** The number of elements allocated in the array */
-    int nalloc;
-    /** The elements in the array */
-    char *elts;
-};
-typedef struct switch_array_header_t switch_array_header_t;
+	 struct switch_array_header_t {
+	/** The pool the array is allocated out of */
+		 switch_memory_pool_t *pool;
+	/** The amount of memory allocated for each element of the array */
+		 int elt_size;
+	/** The number of active elements in the array */
+		 int nelts;
+	/** The number of elements allocated in the array */
+		 int nalloc;
+	/** The elements in the array */
+		 char *elts;
+	 };
+	 typedef struct switch_array_header_t switch_array_header_t;
 
 SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool);
 SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir);
@@ -852,7 +850,7 @@
 	 typedef void *(SWITCH_THREAD_FUNC * switch_thread_start_t) (switch_thread_t *, void *);
 
 //APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, switch_size_t stacksize)
-SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t * attr, switch_size_t stacksize);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize);
 
 SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threadattr_t *attr);
 
@@ -862,14 +860,14 @@
  * @param new_attr The newly created threadattr.
  * @param pool The pool to use
  */
-SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool);
 
 /**
  * Set if newly created threads should be created in detached state.
  * @param attr The threadattr to affect 
  * @param on Non-zero if detached threads should be created.
  */
-SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t * attr, int32_t on);
+SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on);
 
 /**
  * Create a new thread of execution
@@ -879,7 +877,7 @@
  * @param data Any data to be passed to the starting function
  * @param cont The pool to use
  */
-SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t * attr,
+SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr,
 													 switch_thread_start_t func, void *data, switch_memory_pool_t *cont);
 
 /** @} */
@@ -946,7 +944,7 @@
  * @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP).
  * @param pool The pool to use
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool);
 
 /**
  * Shutdown either reading, writing, or both sides of a socket.
@@ -961,13 +959,13 @@
  * @remark This does not actually close the socket descriptor, it just
  *      controls which calls are still valid on the socket.
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t * sock, switch_shutdown_how_e how);
+SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how);
 
 /**
  * Close a socket.
  * @param sock The socket to close 
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t * sock);
+SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock);
 
 /**
  * Bind the socket to its associated port
@@ -976,7 +974,7 @@
  * @remark This may be where we will find out if there is any other process
  *      using the selected port.
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t * sock, switch_sockaddr_t * sa);
+SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa);
 
 /**
  * Listen to a bound socket for connections.
@@ -985,7 +983,7 @@
  *                listen queue.  If this value is less than zero, the listen
  *                queue size is set to zero.  
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t * sock, int32_t backlog);
+SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int32_t backlog);
 
 /**
  * Accept a new connection request
@@ -995,7 +993,7 @@
  * @param sock The socket we are listening on.
  * @param pool The pool for the new socket.
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock, switch_socket_t * sock, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool);
 
 /**
  * Issue a connection request to a socket either on the same machine 
@@ -1003,12 +1001,12 @@
  * @param sock The socket we wish to use for our side of the connection 
  * @param sa The address of the machine we wish to connect to.
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t * sock, switch_sockaddr_t * sa);
+SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa);
 
-SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t * sa);
-SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t * in);
-SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t * sa);
-SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t * sa);
+SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa);
+SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in);
+SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa);
+SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa);
 
 
 /**
@@ -1034,7 +1032,7 @@
  * </PRE>
  * @param pool The pool for the apr_sockaddr_t and associated storage.
  */
-SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname,
+SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname,
 														 int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
 
 /**
@@ -1054,7 +1052,7 @@
  * APR_EINTR is never returned.
  * </PRE>
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t * sock, const char *buf, switch_size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len);
 
 /**
  * @param sock The socket to send from
@@ -1063,8 +1061,7 @@
  * @param buf  The data to send
  * @param len  The length of the data to send
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t * sock, switch_sockaddr_t * where, int32_t flags, const char *buf,
-													 switch_size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len);
 
 /**
  * @param from The apr_sockaddr_t to fill in the recipient info
@@ -1074,7 +1071,7 @@
  * @param len  The length of the available buffer
  *
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t * from, switch_socket_t * sock, int32_t flags, char *buf, size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len);
 
 
 /**
@@ -1096,7 +1093,7 @@
  * APR_EINTR is never returned.
  * </PRE>
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t * sock, char *buf, switch_size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len);
 
 /**
  * Setup socket options for the specified socket
@@ -1120,7 +1117,7 @@
  * </PRE>
  * @param on Value for the option.
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t * sock, int32_t opt, int32_t on);
+SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on);
 
 /**
  * Setup socket timeout for the specified socket
@@ -1133,7 +1130,7 @@
  *   t < 0  -- read and write calls block
  * </PRE>
  */
-SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t * sock, switch_interval_time_t t);
+SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t);
 
 /**
  * Join a Multicast Group
@@ -1144,7 +1141,7 @@
  * @param source Source Address to accept transmissions from (non-NULL 
  *               implies Source-Specific Multicast)
  */
-SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t * sock, switch_sockaddr_t * join, switch_sockaddr_t * iface, switch_sockaddr_t * source);
+SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join, switch_sockaddr_t *iface, switch_sockaddr_t *source);
 
 
 
@@ -1185,7 +1182,7 @@
  * platforms; the apr_pollset_create() call will fail with
  * APR_ENOTIMPL on platforms where it is not supported.
  */
-SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t ** pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags);
+SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags);
 
 /**
  * Add a socket or file descriptor to a pollset
@@ -1204,7 +1201,7 @@
  *         allowed for implementations where option (1) is impossible
  *         or impractical.
  */
-SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t * pollset, const switch_pollfd_t * descriptor);
+SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor);
 
 /**
  * Poll the sockets in the poll structure
@@ -1219,7 +1216,7 @@
  *         This is a blocking call, and it will not return until either a 
  *         socket has been signalled, or the timeout has expired. 
  */
-SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t * aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout);
+SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout);
 
 /*!
   \brief Create a set of file descriptors to poll
@@ -1229,7 +1226,7 @@
   \param pool the memory pool to use
   \return SWITCH_STATUS_SUCCESS when successful
 */
-SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t ** poll, switch_socket_t * sock, int16_t flags, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool);
 
 SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p);
 SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock);

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_bitpack.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_bitpack.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_bitpack.h	Tue May 27 07:24:06 2008
@@ -106,7 +106,7 @@
 			pack->cur++;
 		} else {
 			switch_byte_t mask = SWITCH_BITS_PER_BYTE - pack->over;
-			switch_assert(mask < 8); /* if pack->over this will allways be true */
+			switch_assert(mask < 8);	/* if pack->over this will allways be true */
 			this_byte &= SWITCH_REVERSE_BITPACKED_MASKS[mask];
 			this_byte >>= mask;
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_buffer.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_buffer.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_buffer.h	Tue May 27 07:24:06 2008
@@ -122,7 +122,8 @@
  * \param datalen amount of data to be written
  * \return int amount of buffer used after the write, or 0 if no space available
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen)
+												  const void *data, _In_ switch_size_t datalen);
 
 /*! \brief Remove data from the buffer
  * \param buffer any buffer of type switch_buffer_t
@@ -142,7 +143,8 @@
  */
 SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer);
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_zwrite(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_zwrite(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen)
+												   const void *data, _In_ switch_size_t datalen);
 
 /** @} */
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_caller.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_caller.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_caller.h	Tue May 27 07:24:06 2008
@@ -140,8 +140,7 @@
   \return a new extension object allocated from the session's memory pool
 */
 SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session,
-																		_In_z_ const char *extension_name,
-																		_In_z_ const char *extension_number);
+																		_In_z_ const char *extension_name, _In_z_ const char *extension_number);
 
 /*!
   \brief Add an application (instruction) to the given extension
@@ -152,8 +151,7 @@
 */
 SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_session_t *session,
 															 _In_ switch_caller_extension_t *caller_extension,
-															 _In_z_ const char *application_name,
-															 _In_z_ const char *extra_data);
+															 _In_z_ const char *application_name, _In_z_ const char *extra_data);
 
 
 /*!
@@ -162,8 +160,8 @@
   \param name the name
   \note this function is meant for situations where the name paramater is the contents of the variable
 */
-_Check_return_ _Ret_opt_z_ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile,
-																						_In_z_ const char *name);
+	 _Check_return_ _Ret_opt_z_ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile,
+																							 _In_z_ const char *name);
 
 /*!
   \brief Create a new caller profile object
@@ -191,8 +189,7 @@
 																	_In_opt_z_ const char *aniii,
 																	_In_opt_z_ const char *rdnis,
 																	_In_opt_z_ const char *source,
-																	_In_opt_z_ const char *context,
-																	_In_opt_z_ const char *destination_number);
+																	_In_opt_z_ const char *context, _In_opt_z_ const char *destination_number);
 
 /*!
   \brief Clone an existing caller profile object
@@ -216,8 +213,7 @@
 */
 
 SWITCH_DECLARE(void) switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile,
-														  _In_opt_z_ const char *prefix,
-														  _In_ switch_event_t *event);
+														  _In_opt_z_ const char *prefix, _In_ switch_event_t *event);
 
 SWITCH_END_EXTERN_C
 /** @} */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_channel.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_channel.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_channel.h	Tue May 27 07:24:06 2008
@@ -438,7 +438,8 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf);
 SWITCH_DECLARE(void) switch_channel_flush_dtmf(_In_ switch_channel_t *channel);
-SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len) char *dtmf_str, _In_ switch_size_t len);
+SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len)
+																 char *dtmf_str, _In_ switch_size_t len);
 
 /*!
   \brief Render the name of the provided state enum
@@ -469,7 +470,8 @@
   \note it's necessary to test if the return val is the same as the input and free the string if it is not.
 */
 SWITCH_DECLARE(char *) switch_channel_expand_variables(_In_ switch_channel_t *channel, _In_ const char *in);
-SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile, _In_opt_ const char *prefix);
+SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile,
+														 _In_opt_ const char *prefix);
 SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(_In_ switch_channel_t *channel);
 
 #define switch_channel_stop_broadcast(_channel)	if (switch_channel_test_flag(_channel, CF_BROADCAST)) switch_channel_set_flag(_channel, CF_BREAK | CF_STOP_BROADCAST)

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_config.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_config.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_config.h	Tue May 27 07:24:06 2008
@@ -88,13 +88,13 @@
   \param file_path path to the file
   \return 1 (true) on success 0 (false) on failure
 */
-SWITCH_DECLARE(int) switch_config_open_file(switch_config_t * cfg, char *file_path);
+SWITCH_DECLARE(int) switch_config_open_file(switch_config_t *cfg, char *file_path);
 
 /*!
   \brief Close a previously opened configuration file
   \param cfg (switch_config_t *) config handle to use
 */
-SWITCH_DECLARE(void) switch_config_close_file(switch_config_t * cfg);
+SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg);
 
 /*!
   \brief Retrieve next name/value pair from configuration file
@@ -102,7 +102,7 @@
   \param var pointer to aim at the new variable name
   \param val pointer to aim at the new value
 */
-SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t * cfg, char **var, char **val);
+SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val);
 
 SWITCH_END_EXTERN_C
 /** @} */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_console.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_console.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_console.h	Tue May 27 07:24:06 2008
@@ -52,7 +52,6 @@
 	s.raw_write_function = switch_console_stream_raw_write;				\
 	s.alloc_len = SWITCH_CMD_CHUNK_LEN;									\
 	s.alloc_chunk = SWITCH_CMD_CHUNK_LEN
-
 /*!
   \brief A simple comand loop that reads input from the terminal
 */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core.h	Tue May 27 07:24:06 2008
@@ -43,7 +43,7 @@
 SWITCH_BEGIN_EXTERN_C
 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
 #define SWITCH_MAX_STREAMS 128
-struct switch_core_time_duration {
+	struct switch_core_time_duration {
 	uint32_t mms;
 	uint32_t ms;
 	uint32_t sec;
@@ -132,9 +132,7 @@
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_session_t *session,
 														  _In_ switch_media_bug_callback_t callback,
 														  _In_opt_ void *user_data,
-														  _In_ time_t stop_time,
-														  _In_ switch_media_bug_flag_t flags,
-														  _Out_ switch_media_bug_t **new_bug);
+														  _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
 /*!
   \brief Obtain private data from a media bug
   \param bug the bug to get the data from
@@ -220,9 +218,8 @@
   \return SWITCH_STATUS_SUCCESS if the operation was a success
 */
 SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(_In_ switch_port_t start,
-								   _In_ switch_port_t end,
-								   _In_ switch_port_flag_t flags,
-								   _Out_ switch_core_port_allocator_t **new_allocator);
+															   _In_ switch_port_t end,
+															   _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator);
 
 /*!
   \brief Get a port from the port allocator
@@ -395,59 +392,74 @@
 */
 SWITCH_DECLARE(unsigned int) switch_core_session_running(_In_ switch_core_session_t *session);
 
+SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+
 /*! 
   \brief Allocate memory from the main pool with no intention of returning it
-  \param memory the number of bytes to allocate
+  \param _memory the number of bytes to allocate
   \return a void pointer to the allocated memory
   \note this memory never goes out of scope until the core is destroyed
 */
-SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-#define switch_core_permanent_alloc(m) switch_core_perform_permanent_alloc(m, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
+
+
+SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file,
+												 _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Allocate memory directly from a memory pool
-  \param pool the memory pool to allocate from
-  \param memory the number of bytes to allocate
+  \param _pool the memory pool to allocate from
+  \param _mem the number of bytes to allocate
   \return a void pointer to the allocated memory
 */
-SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-#define switch_core_alloc(p, m) switch_core_perform_alloc(p, m, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
+
+	 _Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file,
+																	const char *func, int line);
+
 /*! 
   \brief Allocate memory from a session's pool
-  \param session the session to request memory from
-  \param memory the amount of memory to allocate
+  \param _session the session to request memory from
+  \param _memory the amount of memory to allocate
   \return a void pointer to the newly allocated memory
   \note the memory will be in scope as long as the session exists
 */
-_Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file, const char *func, int line);
-#define switch_core_session_alloc(s, m) switch_core_perform_session_alloc(s, m, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_session_alloc(_session, _memory) switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
+
+SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
+
 /*! 
   \brief Copy a string using permanent memory allocation
-  \param todup the string to duplicate
+  \param _todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup,  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-#define switch_core_permanent_strdup(t) switch_core_perform_permanent_strdup(t, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
+
+
+SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file,
+														  _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Copy a string using memory allocation from a session's pool
-  \param session a session to use for allocation
-  \param todup the string to duplicate
+  \param _session a session to use for allocation
+  \param _todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-#define switch_core_session_strdup(s, t) switch_core_perform_session_strdup(s, t, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
+
+
+SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
+												  _In_z_ const char *func, _In_ int line);
 
 /*! 
   \brief Copy a string using memory allocation from a given pool
-  \param pool the pool to use for allocation
-  \param todup the string to duplicate
+  \param _pool the pool to use for allocation
+  \param _todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-#define switch_core_strdup(p, t)  switch_core_perform_strdup(p, t, __FILE__, __SWITCH_FUNC__, __LINE__)
+#define switch_core_strdup(_pool, _todup)  switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 /*!
   \brief printf-style style printing routine.  The data is output to a string allocated from the session
@@ -531,7 +543,7 @@
   \param session the session to retrieve from
   \return a pointer to the channel object
 */
-_Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
+	 _Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
 
 /*! 
   \brief Signal a session's state machine thread that a state change has occured
@@ -609,7 +621,8 @@
   \param indication the indication message to pass
   \return SWITCH_STATUS_SUCCESS if the message was passed
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication);
+SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_core_session_t *session,
+																	_In_ switch_core_session_message_types_t indication);
 
 /*! 
   \brief Queue an indication message on a session
@@ -617,7 +630,8 @@
   \param indication the indication message to queue
   \return SWITCH_STATUS_SUCCESS if the message was queued
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication);
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(_In_ switch_core_session_t *session,
+																	 _In_ switch_core_session_message_types_t indication);
 
 /*! 
   \brief DE-Queue an message on a given session
@@ -645,17 +659,14 @@
 SWITCH_DECLARE(switch_app_log_t *) switch_core_session_get_app_log(_In_ switch_core_session_t *session);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_exec(_In_ switch_core_session_t *session,
-														 _In_ const switch_application_interface_t *application_interface,
-														 _In_opt_z_ const char *arg);
+														 _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application(_In_ switch_core_session_t *session,
-																		_In_ const char *app,
-																		_In_opt_z_ const char *arg);
+																		_In_ const char *app, _In_opt_z_ const char *arg);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(_In_ switch_core_session_t *session,
 																  _In_z_ const char *exten,
-																  _In_opt_z_ const char *dialplan,
-																  _In_opt_z_ const char *context);
+																  _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
 
 /*! 
   \brief Send an event to a session translating it to it's native message format
@@ -710,8 +721,7 @@
   \param obj an arguement
 */
 SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session,
-													   _In_ void *(*func) (switch_thread_t *, void *),
-													   _In_opt_ void *obj);
+													   _In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
 
 /*! 
   \brief Signal a thread using a thread session to terminate
@@ -726,13 +736,12 @@
   \param thread_session the thread_session to use
 */
 SWITCH_DECLARE(void) switch_core_service_session(_In_ switch_core_session_t *session,
-												 _In_ switch_core_thread_session_t *thread_session,
-												 _In_ int stream_id);
+												 _In_ switch_core_thread_session_t *thread_session, _In_ int stream_id);
 
 /*! 
   \brief Request an outgoing session spawned from an existing session using a desired endpoing module
   \param session the originating session
-  \param var_event - NEEDDESC -
+  \param var_event switch_event_t containing paramaters
   \param endpoint_name the name of the module to use for the new session
   \param caller_profile the originator's caller profile
   \param new_session a NULL pointer to aim at the newly created session
@@ -745,13 +754,11 @@
 																		 _In_z_ const char *endpoint_name,
 																		 _In_ switch_caller_profile_t *caller_profile,
 																		 _Inout_ switch_core_session_t **new_session,
-																		 _Inout_ switch_memory_pool_t **pool,
-																		 _In_ switch_originate_flag_t flags);
+																		 _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags);
 
 SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name,
 																		  _Inout_ switch_core_session_t **new_session,
-																		  _Inout_ switch_memory_pool_t **pool,
-																		  _In_ void *data);
+																		  _Inout_ switch_memory_pool_t **pool, _In_ void *data);
 
 /*! 
   \brief Receive a message on a given session
@@ -822,31 +829,34 @@
   \brief Read a frame from a session
   \param session the session to read from
   \param frame a NULL pointer to a frame to aim at the newly read frame
-  \param flags - NEEDDESC -
+  \param flags I/O flags to modify behavior (i.e. non blocking)
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a the frame was read
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+															   int stream_id);
 
 /*! 
   \brief Read a video frame from a session
   \param session the session to read from
   \param frame a NULL pointer to a frame to aim at the newly read frame
-  \param flags - NEEDDESC -
+  \param flags I/O flags to modify behavior (i.e. non blocking)
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a if the frame was read
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
+																	 int stream_id);
 
 /*! 
   \brief Write a video frame to a session
   \param session the session to write to
   \param frame a pointer to a frame to write
-  \param flags - NEEDDESC -
+  \param flags I/O flags to modify behavior (i.e. non blocking)
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a if the frame was written
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																	  int stream_id);
 
 /*! 
   \brief Reset the buffers and resampler on a session
@@ -859,11 +869,12 @@
   \brief Write a frame to a session
   \param session the session to write to
   \param frame the frame to write
-  \param flags - NEEDDESC -
+  \param flags I/O flags to modify behavior (i.e. non blocking)
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a the frame was written
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
+																int stream_id);
 
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(_In_ switch_core_session_t *session,
@@ -905,7 +916,7 @@
   \param pool the pool to use for the new hash
   \return SWITCH_STATUS_SUCCESS if the hash is created
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_init(_Out_ switch_hash_t ** hash, _In_ switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init(_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool);
 
 /*! 
   \brief Destroy an existing hash table
@@ -922,7 +933,7 @@
   \return SWITCH_STATUS_SUCCESS if the data is added
   \note the string key must be a constant or a dynamic string
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_opt_ const void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data);
 
 /*! 
   \brief Insert data into a hash
@@ -933,7 +944,8 @@
   \return SWITCH_STATUS_SUCCESS if the data is added
   \note the string key must be a constant or a dynamic string
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_opt_ const void *data, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data,
+															   _In_ switch_mutex_t *mutex);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -941,7 +953,7 @@
   \param key the key from which to delete the data
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t * hash, _In_z_ const char *key);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -950,7 +962,7 @@
   \param mutex optional mutex to lock
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
 
 /*! 
   \brief Retrieve data from a given hash
@@ -958,7 +970,7 @@
   \param key the key to retrieve
   \return a pointer to the data held in the key
 */
-SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t * hash, _In_z_ const char *key);
+SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key);
 
 
 /*! 
@@ -968,11 +980,12 @@
   \param mutex optional mutex to lock
   \return a pointer to the data held in the key
 */
-SWITCH_DECLARE(void *) switch_core_hash_find_locked(_In_ switch_hash_t * hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
+SWITCH_DECLARE(void *) switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
 
 SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(char *depricate_me, _In_ switch_hash_t *hash);
 SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(_In_ switch_hash_index_t *hi);
-SWITCH_DECLARE(void) switch_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
+SWITCH_DECLARE(void) switch_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen)
+									  const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
 
 ///\}
 
@@ -988,7 +1001,8 @@
   \param pool the memory pool to use for allocation
   \return
 */
-SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples,
+													   switch_memory_pool_t *pool);
 
 /*! 
   \brief Wait for one cycle on an existing timer
@@ -1067,7 +1081,7 @@
 														 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);
+														 void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
 
 /*! 
   \brief Decode data using a codec handle
@@ -1088,7 +1102,7 @@
 														 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);
+														 void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
 
 /*! 
   \brief Destroy an initalized codec handle
@@ -1198,24 +1212,24 @@
 ///\defgroup Media File Functions
 ///\ingroup core1
 ///\{
+
+SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
+															  _In_ switch_file_handle_t *fh,
+															  _In_z_ const char *file_path,
+															  _In_ uint8_t channels,
+															  _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
+
 /*! 
   \brief Open a media file using file format modules
-  \param fh a file handle to use
-  \param file_path the path to the file
-  \param channels the number of channels
-  \param rate the sample rate
-  \param flags read/write flags
-  \param pool the pool to use (NULL for new pool)
+  \param _fh a file handle to use
+  \param _file_path the path to the file
+  \param _channels the number of channels
+  \param _rate the sample rate
+  \param _flags read/write flags
+  \param _pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the file is opened
   \note the loadable module used is chosen based on the file extension
 */
-SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
-															  _In_ switch_file_handle_t *fh,
-															  _In_z_ const char *file_path,
-															  _In_ uint8_t channels,
-															  _In_ uint32_t rate,
-															  _In_ unsigned int flags,
-															  _In_opt_ switch_memory_pool_t *pool);
 #define switch_core_file_open(_fh, _file_path, _channels, _rate, _flags, _pool) \
 	switch_core_perform_file_open(__FILE__, __SWITCH_FUNC__, __LINE__, _fh, _file_path, _channels, _rate, _flags, _pool)
 
@@ -1290,10 +1304,9 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_speech_open(_In_ switch_speech_handle_t *sh,
 														const char *module_name,
-														const char *voice_name, 
-														_In_ unsigned int rate, 
-														_In_ unsigned int interval, 
-														switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
+														const char *voice_name,
+														_In_ unsigned int rate,
+														_In_ unsigned int interval, switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
 /*! 
   \brief Feed text to the TTS module
   \param sh the speech handle to feed
@@ -1343,7 +1356,7 @@
   \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
 */
 SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh,
-															void *data, switch_size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags);
+															void *data, switch_size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags);
 /*! 
   \brief Close an open speech handle
   \param sh the speech handle to close
@@ -1366,11 +1379,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
 													 const char *module_name,
-													 const char *codec,
-													 int rate,
-													 const char *dest,
-													 switch_asr_flag_t *flags,
-													 switch_memory_pool_t *pool);
+													 const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
 
 /*!
   \brief Close an asr handle
@@ -1574,7 +1583,7 @@
   \param val the command arguement (if needed)
   \return 0 on success nonzero on error
 */
-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t * val);
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val);
 
 /*!
   \brief Get the output console

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core_event_hook.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core_event_hook.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_core_event_hook.h	Tue May 27 07:24:06 2008
@@ -32,8 +32,7 @@
 #define SWITCH_EVENT_HOOKS_H
 
 #include <switch.h>
-SWITCH_BEGIN_EXTERN_C 
-typedef struct switch_io_event_hooks switch_io_event_hooks_t;
+SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
 
 typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
 typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
@@ -48,7 +47,7 @@
 typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
 typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t;
 typedef switch_status_t (*switch_outgoing_channel_hook_t)
-(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
+                               (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
 typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
 typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
 typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
@@ -59,7 +58,7 @@
 typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
 typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
 typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *);
-typedef switch_call_cause_t (*switch_resurrect_session_hook_t)(switch_core_session_t **, switch_memory_pool_t **, void *);
+typedef switch_call_cause_t (*switch_resurrect_session_hook_t) (switch_core_session_t **, switch_memory_pool_t **, void *);
 
 /*! \brief Node in which to store custom receive message callback hooks */
 struct switch_io_event_hook_outgoing_channel {
@@ -210,7 +209,7 @@
 			last = ptr;													\
 		}																\
 		return SWITCH_STATUS_FALSE;										\
-	}																	
+	}
 
 
 NEW_HOOK_DECL_ADD_P(outgoing_channel);
@@ -238,7 +237,7 @@
 NEW_HOOK_DECL_REM_P(send_dtmf);
 NEW_HOOK_DECL_REM_P(recv_dtmf);
 NEW_HOOK_DECL_REM_P(resurrect_session);
-///\}
+
 
 SWITCH_END_EXTERN_C
 #endif

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_cpp.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_cpp.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_cpp.h	Tue May 27 07:24:06 2008
@@ -8,41 +8,28 @@
 #ifdef DOH
 }
 #endif
-
 #include <switch.h>
-
 #define this_check(x) do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)
 #define this_check_void() do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n");}} while(0)
-
 #define sanity_check(x) do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
 #define sanity_check_noreturn do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
 #define init_vars() do { allocated = 0; session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; xml_cdr_text = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown";  caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = "";  caller_profile.username = ""; on_hangup = NULL; memset(&cb_state, 0, sizeof(cb_state)); hook_state = CS_NEW; } while(0)
-
-
-//
-// C++ Interface: switch_to_cpp_mempool
-//
-// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t
-//
-// Author: Yossi Neiman <freeswitch at cartissolutions.com>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-
+//// C++ Interface: switch_to_cpp_mempool//// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t//// Author: Yossi Neiman <freeswitch at cartissolutions.com>, (C) 2007//// Copyright: See COPYING file that comes with this distribution//
 #if 0
 #ifndef SWITCHTOMEMPOOL
 #define SWITCHTOMEMPOOL
 class SwitchToMempool {
-	public:
-		SwitchToMempool() { }
-		SwitchToMempool(switch_memory_pool_t *mem) { memorypool = mem; }
-		void *operator new(switch_size_t num_bytes, switch_memory_pool_t *mem)
-		{
-			void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
-			return ptr;
-		}
-	protected:
-		switch_memory_pool_t *memorypool;
+  public:
+	SwitchToMempool() {
+	} SwitchToMempool(switch_memory_pool_t *mem) {
+		memorypool = mem;
+	}
+	void *operator  new(switch_size_t num_bytes, switch_memory_pool_t *mem) {
+		void *ptr = switch_core_alloc(mem, (switch_size_t) num_bytes);
+		return ptr;
+	}
+  protected:
+	switch_memory_pool_t *memorypool;
 };
 #endif
 #endif
@@ -66,135 +53,130 @@
 SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
 SWITCH_DECLARE(void) consoleCleanLog(char *msg);
 
-class CoreSession;
-
-class IVRMenu {
- protected:
-	switch_ivr_menu_t *menu;
-	switch_memory_pool_t *pool;
- public:
-	SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu *main,
-									   const char *name,
-									   const char *greeting_sound,
-									   const char *short_greeting_sound,
-									   const char *invalid_sound,
-									   const char *exit_sound,
-									   const char *confirm_macro,
-									   const char *confirm_key,
-									   int confirm_attempts,
-									   int inter_timeout,
-									   int digit_len,
-									   int timeout,
-									   int max_failures
-									   );
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~IVRMenu();
-	SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
-	SWITCH_DECLARE(void) execute(CoreSession *session, const char *name);
-};
-
-
-class API {
- protected:
-	char *last_data;
- public:
-	SWITCH_DECLARE_CONSTRUCTOR API(void);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~API();
-	SWITCH_DECLARE(char *) execute(const char *command, const char *data);
-	SWITCH_DECLARE(char *) executeString(const char *command);
-};
+	 class CoreSession;
 
-
-typedef struct input_callback_state {
-    void *function;           // pointer to the language specific callback function
-                              // eg, PyObject *pyfunc
-    void *threadState;        // pointer to the language specific thread state
-                              // eg, PyThreadState *threadState
-    void *extra;              // currently used to store a switch_file_handle_t
-    char *funcargs;           // extra string that will be passed to callback function 
-} input_callback_state_t;
-
-typedef enum {
-	S_HUP = (1 << 0),
-	S_FREE = (1 << 1),
-	S_RDLOCK = (1 << 2)
-} session_flag_t;
-
-class Stream {
- protected: 
-	switch_stream_handle_t mystream;
-	switch_stream_handle_t *stream_p;
-	int mine;
- public: 
-	SWITCH_DECLARE_CONSTRUCTOR Stream(void);
-	SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~Stream();
-	SWITCH_DECLARE(void) write(const char *data);	
-	SWITCH_DECLARE(const char *)get_data(void);
-};
-
-class Event {
- protected:
- public:
-	switch_event_t *event;
-	char *serialized_string;
-	int mine;
-
-	SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL);
-	SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me=0);
-	virtual SWITCH_DECLARE_CONSTRUCTOR ~Event();
-	SWITCH_DECLARE(const char *)serialize(const char *format=NULL);
-	SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
-	SWITCH_DECLARE(char *)getHeader(char *header_name);
-	SWITCH_DECLARE(char *)getBody(void);
-	SWITCH_DECLARE(const char *)getType(void);
-	SWITCH_DECLARE(bool) addBody(const char *value);
-	SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
-	SWITCH_DECLARE(bool) delHeader(const char *header_name);
-	SWITCH_DECLARE(bool) fire(void);
-	
-};
-
-
-class CoreSession {
- protected:
-	switch_input_args_t args; // holds ptr to cb function and input_callback_state struct
-                              // which has a language specific callback function
-	switch_input_args_t *ap;  // ptr to args .. (is this really needed?)
-	switch_caller_profile_t caller_profile; // avoid passing so many args to originate, 
-	                                        // instead set them here first
-	char *xml_cdr_text;
-	char *uuid;
-	char *tts_name;
-	char *voice_name;
-	void store_file_handle(switch_file_handle_t *fh);
-	void *on_hangup; // language specific callback function, cast as void * 
-	switch_file_handle_t local_fh;
-	switch_file_handle_t *fhp;
-	char dtmf_buf[512];
-
- public:
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession();
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
-	SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
-	SWITCH_DECLARE_CONSTRUCTOR ~CoreSession();
-	switch_core_session_t *session;
-	switch_channel_t *channel;
-	unsigned int flags;
-	int allocated;
-	input_callback_state cb_state; // callback state, always pointed to by the buf
-                                   // field in this->args
-	switch_channel_state_t hook_state; // store hookstate for on_hangup callback
-
-	SWITCH_DECLARE(int) answer();
-	SWITCH_DECLARE(int) preAnswer();
-	SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing");
-	SWITCH_DECLARE(void) setVariable(char *var, char *val);
-	SWITCH_DECLARE(void) setPrivate(char *var, void *val);
-	SWITCH_DECLARE(void *)getPrivate(char *var);
-	SWITCH_DECLARE(const char *)getVariable(char *var);
-	SWITCH_DECLARE(switch_status_t) process_callback_result(char *result);	
-	SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method);
-	SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
+	 class IVRMenu {
+	   protected:
+		 switch_ivr_menu_t *menu;
+		 switch_memory_pool_t *pool;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR IVRMenu(IVRMenu * main,
+											const char *name,
+											const char *greeting_sound,
+											const char *short_greeting_sound,
+											const char *invalid_sound,
+											const char *exit_sound,
+											const char *confirm_macro,
+											const char *confirm_key,
+											int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
+		 SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
+		 SWITCH_DECLARE(void) execute(CoreSession * session, const char *name);
+	 };
+
+
+	 class API {
+	   protected:
+		 char *last_data;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR API(void);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ API();
+		 SWITCH_DECLARE(const char *) execute(const char *command, const char *data);
+		 SWITCH_DECLARE(const char *) executeString(const char *command);
+	 };
+
+
+	 typedef struct input_callback_state {
+		 void *function;		// pointer to the language specific callback function
+		 // eg, PyObject *pyfunc
+		 void *threadState;		// pointer to the language specific thread state
+		 // eg, PyThreadState *threadState
+		 void *extra;			// currently used to store a switch_file_handle_t
+		 char *funcargs;		// extra string that will be passed to callback function 
+	 } input_callback_state_t;
+
+	 typedef enum {
+		 S_HUP = (1 << 0),
+		 S_FREE = (1 << 1),
+		 S_RDLOCK = (1 << 2)
+	 } session_flag_t;
+
+	 class Stream {
+	   protected:
+		 switch_stream_handle_t mystream;
+		 switch_stream_handle_t *stream_p;
+		 int mine;
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR Stream(void);
+		 SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
+		 SWITCH_DECLARE(void) write(const char *data);
+		 SWITCH_DECLARE(const char *) get_data(void);
+	 };
+
+	 class Event {
+	   protected:
+	   public:
+		 switch_event_t *event;
+		 char *serialized_string;
+		 int mine;
+
+		 SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL);
+		 SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me = 0);
+		 virtual SWITCH_DECLARE_CONSTRUCTOR ~ Event();
+		 SWITCH_DECLARE(const char *) serialize(const char *format = NULL);
+		 SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
+		 SWITCH_DECLARE(const char *) getHeader(char *header_name);
+		 SWITCH_DECLARE(char *) getBody(void);
+		 SWITCH_DECLARE(const char *) getType(void);
+		 SWITCH_DECLARE(bool) addBody(const char *value);
+		 SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
+		 SWITCH_DECLARE(bool) delHeader(const char *header_name);
+		 SWITCH_DECLARE(bool) fire(void);
+
+	 };
+
+
+	 class CoreSession {
+	   protected:
+		 switch_input_args_t args;	// holds ptr to cb function and input_callback_state struct
+		 // which has a language specific callback function
+		 switch_input_args_t *ap;	// ptr to args .. (is this really needed?)
+		 switch_caller_profile_t caller_profile;	// avoid passing so many args to originate, 
+		 // instead set them here first
+		 char *xml_cdr_text;
+		 char *uuid;
+		 char *tts_name;
+		 char *voice_name;
+		 void store_file_handle(switch_file_handle_t *fh);
+		 void *on_hangup;		// language specific callback function, cast as void * 
+		 switch_file_handle_t local_fh;
+		 switch_file_handle_t *fhp;
+		 char dtmf_buf[512];
+
+	   public:
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession();
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
+		 SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
+		 SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession();
+		 switch_core_session_t *session;
+		 switch_channel_t *channel;
+		 unsigned int flags;
+		 int allocated;
+		 input_callback_state cb_state;	// callback state, always pointed to by the buf
+		 // field in this->args
+		 switch_channel_state_t hook_state;	// store hookstate for on_hangup callback
+
+		 SWITCH_DECLARE(int) answer();
+		 SWITCH_DECLARE(int) preAnswer();
+		 SWITCH_DECLARE(void) hangup(char *cause = "normal_clearing");
+		 SWITCH_DECLARE(void) setVariable(char *var, char *val);
+		 SWITCH_DECLARE(void) setPrivate(char *var, void *val);
+		 SWITCH_DECLARE(void *) getPrivate(char *var);
+		 SWITCH_DECLARE(const char *) getVariable(char *var);
+		 SWITCH_DECLARE(switch_status_t) process_callback_result(char *result);
+		 SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method);
+		 SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
 
 	/** \brief Record to a file
 	 * \param file_name 
@@ -203,28 +185,26 @@
 	 *        to be considered silence (500 is a good starting point).
 	 * \param <[silence_secs]> seconds of silence to interrupt the record.
 	 */
-	SWITCH_DECLARE(int) recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
+		 SWITCH_DECLARE(int) recordFile(char *file_name, int max_len = 0, int silence_threshold = 0, int silence_secs = 0);
 
 
 	/** \brief Set attributes of caller data for purposes of outgoing calls
 	 * \param var - the variable name, eg, "caller_id_name"
 	 * \param val - the data to set, eg, "bob"
 	 */
-	SWITCH_DECLARE(void) setCallerData(char *var, char *val);
+		 SWITCH_DECLARE(void) setCallerData(char *var, char *val);
 
 	/** \brief Originate a call to a destination
 	 *
 	 * \param a_leg_session - the session where the call is originating from 
 	 *                        and also the session in which _this_ session was 
 	 *                        created
-	 * \param dest - a string representing destination, eg, sofia/mydomain.com/foo at bar.com
+	 * \param dest - a string representing destination, eg, sofia/mydomain.com/foo\@bar.com
 	 * \param timeout - time to wait for call to be answered
 	 * \return an int status code indicating success or failure
 	 *
 	 */
-	SWITCH_DECLARE(int) originate(CoreSession *a_leg_session, 
-				  char *dest, 
-				  int timeout=60);
+		 SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60);
 
 
 	/** \brief set a DTMF callback function
@@ -235,16 +215,16 @@
 	 * certain other methods are executing.
 	 *
 	 */
-	SWITCH_DECLARE(void) setDTMFCallback(void *cbfunc, char *funcargs);
+		 SWITCH_DECLARE(void) setDTMFCallback(void *cbfunc, char *funcargs);
 
-	SWITCH_DECLARE(int) speak(char *text);
-	SWITCH_DECLARE(void) set_tts_parms(char *tts_name, char *voice_name);
+		 SWITCH_DECLARE(int) speak(char *text);
+		 SWITCH_DECLARE(void) set_tts_parms(char *tts_name, char *voice_name);
 
 	/**
 	 * For timeout milliseconds, call the dtmf function set previously
 	 * by setDTMFCallback whenever a dtmf or event is received
 	 */
-	SWITCH_DECLARE(int) collectDigits(int timeout);
+		 SWITCH_DECLARE(int) collectDigits(int timeout);
 
 	/** 
 	 * Collect up to maxdigits digits worth of digits
@@ -253,20 +233,13 @@
 	 * (see mod_python.i).  This does NOT call any callbacks upon
 	 * receiving dtmf digits.  For that, use collectDigits.
 	 */
-	SWITCH_DECLARE(char *) getDigits(
-								  int maxdigits, 
-								  char *terminators, 
-								  int timeout);
-	
-	SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
+		 SWITCH_DECLARE(char *) getDigits(int maxdigits, char *terminators, int timeout);
+
+		 SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
+
 
+		 SWITCH_DECLARE(char *) read(int min_digits, int max_digits, const char *prompt_audio_file, int timeout, const char *valid_terminators);
 
-	SWITCH_DECLARE(char *) read(int min_digits,
-								int max_digits,
-								const char *prompt_audio_file,
-								int timeout,
-								const char *valid_terminators);
-	
 	/** \brief Play a file into channel and collect dtmfs
 	 * 
 	 * See API docs in switch_ivr.h: switch_play_and_get_digits(..)
@@ -275,14 +248,10 @@
 	 *       setDTMFCallback(..) as it uses its own internal callback
 	 *       handler.
 	 */
-	SWITCH_DECLARE(char *) playAndGetDigits(int min_digits, 
-						 int max_digits, 
-						 int max_tries, 
-						 int timeout, 
-						 char *terminators,
-						 char *audio_files, 
-						 char *bad_input_audio_files, 
-						 char *digits_regex);
+		 SWITCH_DECLARE(char *) playAndGetDigits(int min_digits,
+												 int max_digits,
+												 int max_tries,
+												 int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *digits_regex);
 
 	/** \brief Play a file that resides on disk into the channel
 	 *
@@ -292,53 +261,56 @@
 	 * \return an int status code indicating success or failure
 	 *
 	 */
-	SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count=0);
+		 SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0);
 
 	/** \brief flush any pending events
 	 */
-	SWITCH_DECLARE(int) flushEvents();
+		 SWITCH_DECLARE(int) flushEvents();
 
 	/** \brief flush any pending digits
 	 */
-	SWITCH_DECLARE(int) flushDigits();
+		 SWITCH_DECLARE(int) flushDigits();
 
-	SWITCH_DECLARE(int) setAutoHangup(bool val);
+		 SWITCH_DECLARE(int) setAutoHangup(bool val);
 
 	/** \brief Set the hangup callback function
 	 * \param hangup_func - language specific function ptr cast into void *
 	 */
-	SWITCH_DECLARE(void) setHangupHook(void *hangup_func);
+		 SWITCH_DECLARE(void) setHangupHook(void *hangup_func);
 
-	SWITCH_DECLARE(bool) ready();
+		 SWITCH_DECLARE(bool) ready();
 
-	SWITCH_DECLARE(void) execute(char *app, char *data=NULL);
+		 SWITCH_DECLARE(void) execute(char *app, char *data = NULL);
 
-	SWITCH_DECLARE(void) sendEvent(Event *sendME);
+		 SWITCH_DECLARE(void) sendEvent(Event * sendME);
 
-	SWITCH_DECLARE(void) setEventData(Event *e);
-	SWITCH_DECLARE(char *) getXMLCDR();
+		 SWITCH_DECLARE(void) setEventData(Event * e);
+		 SWITCH_DECLARE(char *) getXMLCDR();
 
-	virtual bool begin_allow_threads() = 0;
-	virtual bool end_allow_threads() = 0;
+		 virtual bool begin_allow_threads() = 0;
+		 virtual bool end_allow_threads() = 0;
 
 	/** \brief Get the uuid of this session	
 	 * \return the uuid of this session
 	 */
-	char* get_uuid() const { return uuid; };
+		 char *get_uuid() const {
+			 return uuid;
+		 };
 
 	/** \brief Get the callback function arguments associated with this session
 	 * \return a const reference to the callback function arguments
 	 */
-	const switch_input_args_t& get_cb_args() const { return args; };
+		 const switch_input_args_t &get_cb_args() const {
+			 return args;
+		 };
 
 	/** \brief Callback to the language specific hangup callback
 	 */
-	virtual void check_hangup_hook() = 0;
+		 virtual void check_hangup_hook() = 0;
 
-	virtual switch_status_t run_dtmf_callback(void *input, 
-											  switch_input_type_t itype) = 0;
+		 virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype) = 0;
 
-};
+	 };
 
 
 /* ---- functions not bound to CoreSession instance ----- */
@@ -351,7 +323,7 @@
  * NOTE: the stuff regarding the dtmf callback might be completely
  *       wrong and has not been reviewed or tested
  */
-SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b);
+SWITCH_DECLARE(void) bridge(CoreSession & session_a, CoreSession & session_b);
 
 
 /** \brief the actual hangup hook called back by freeswitch core
@@ -360,11 +332,8 @@
  */
 SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session);
 
-SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session, 
-							  void *input, 
-							  switch_input_type_t itype, 
-							  void *buf,  
-							  unsigned int buflen);
+SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session,
+													 void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
 
 
 #ifdef __cplusplus
@@ -382,4 +351,3 @@
  * For VIM:
  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
  */
-

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_event.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_event.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_event.h	Tue May 27 07:24:06 2008
@@ -156,7 +156,7 @@
   \param header_name the name of the header to read
   \return the value of the requested header
 */
-_Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name);
+	 _Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name);
 
 #define switch_event_get_header_nil(e, h) switch_str_nil(switch_event_get_header(e,h))
 
@@ -292,7 +292,7 @@
 #endif
 SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const char *in);
 
-SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char *file, _In_z_ char *func, _In_ int line, 
+SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char *file, _In_z_ char *func, _In_ int line,
 																	 _In_z_ const char *proto, _In_z_ const char *login,
 																	 _In_z_ const char *from, _In_z_ const char *from_domain,
 																	 _In_z_ const char *status, _In_z_ const char *event_type,
@@ -344,7 +344,7 @@
 */
 #define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, data)
 
-SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix,switch_hash_t* vars_map);
+SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map);
 
 ///\}
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_frame.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_frame.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_frame.h	Tue May 27 07:24:06 2008
@@ -40,7 +40,7 @@
 
 SWITCH_BEGIN_EXTERN_C
 /*! \brief An abstraction of a data frame */
-struct switch_frame {
+	struct switch_frame {
 	/*! a pointer to the codec information */
 	switch_codec_t *codec;
 	/*! the originating source of the frame */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_ivr.h	Tue May 27 07:24:06 2008
@@ -41,9 +41,7 @@
 
 #include <switch.h>
 
-SWITCH_BEGIN_EXTERN_C
-
-struct switch_unicast_conninfo {
+SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo {
 	switch_core_session_t *session;
 	switch_codec_t read_codec;
 	switch_frame_t write_frame;
@@ -73,13 +71,10 @@
  */
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session,
 															char *local_ip,
 															switch_port_t local_port,
-															char *remote_ip,
-															switch_port_t remote_port,
-															char *transport,
-															char *flags);
+															char *remote_ip, switch_port_t remote_port, char *transport, char *flags);
 
 /*!
   \brief Generate an XML CDR report.
@@ -88,7 +83,7 @@
   \return SWITCH_STATUS_SUCCESS if successful
   \note on success the xml object must be freed
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t * xml_cdr);
+SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr);
 SWITCH_DECLARE(int) switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_caller_profile_t *caller_profile, int off);
 SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channel_t *channel, int off);
 
@@ -143,11 +138,9 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
 																char *buf,
 																switch_size_t buflen,
-																switch_size_t maxdigits, 
-																const char *terminators, char *terminator, 
-																uint32_t first_timeout,
-																uint32_t digit_timeout,
-																uint32_t abs_timeout);
+																switch_size_t maxdigits,
+																const char *terminators, char *terminator,
+																uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout);
 
 /*!
   \brief Engage background Speech detection on a session
@@ -161,9 +154,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
 														 const char *mod_name,
-														 const char *grammar,
-														 const char *path,
-														 const char *dest, switch_asr_handle_t *ah);
+														 const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah);
 
 /*!
   \brief Stop background Speech detection on a session
@@ -217,21 +208,19 @@
   \brief Eavesdrop on a another session
   \param session our session
   \param uuid the uuid of the session to spy on
-  \param require_group - NEEDDESC -
-  \param flags - NEEDDESC -
+  \param require_group group name to use to limit by group
+  \param flags tweak read-mux, write-mux and dtmf
   \return SWITCH_STATUS_SUCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, 
-															 const char *uuid, 
-															 const char *require_group, 
-															 switch_eavesdrop_flag_t flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session,
+															 const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags);
 
 /*!
-  \brief - NEEDDESC -
+  \brief displace the media for a session with the audio from a file
   \param session the session to displace
-  \param file
-  \param limit
-  \param flags
+  \param file filename
+  \param limit time limit in ms
+  \param flags m (mux) l (loop) or r(read session instead of write session)
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
@@ -239,7 +228,7 @@
 /*!
   \brief Stop displacing a session
   \param session the session
-  \param file - NEEDDESC -
+  \param file file name from the switch_ivr_displace_session call
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file);
@@ -270,7 +259,7 @@
 /*!
   \brief Start generating DTMF inband
   \param session the session to generate on
-  \param read_stream - NEEDDESC -
+  \param read_stream true to use the session we are reading from, false for the session we are writing to.
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_generate_session(switch_core_session_t *session, switch_bool_t read_stream);
@@ -307,10 +296,9 @@
   \param data optional data for appliaction
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
 															   const char *key, const char *tone_spec,
-															   const char *flags, time_t timeout,
-															   const char *app, const char *data);
+															   const char *flags, time_t timeout, const char *app, const char *data);
 
 
 
@@ -322,7 +310,8 @@
   \param args arguements to pass for callbacks etc
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file,
+													 switch_input_args_t *args);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args);
 
@@ -337,9 +326,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(_In_ switch_core_session_t *session,
 													   _In_ switch_file_handle_t *fh,
-													   _In_z_ const char *file,
-													   _In_opt_ switch_input_args_t *args,
-													   _In_ uint32_t limit);
+													   _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit);
 
 
 /*!
@@ -407,8 +394,7 @@
 													 const switch_state_handler_table_t *table,
 													 const char *cid_name_override,
 													 const char *cid_num_override,
-													 switch_caller_profile_t *caller_profile_override,
-													 switch_originate_flag_t flags);
+													 switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags);
 
 /*!
   \brief Bridge Audio from one session to another
@@ -439,7 +425,8 @@
   \param dialplan the new dialplan (OPTIONAL, may be NULL)
   \param context the new context (OPTIONAL, may be NULL)
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context);
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan,
+															const char *context);
 
 /*!
   \brief Transfer an existing session to another location in the future
@@ -560,14 +547,14 @@
   \param parser a pointer to the object pointer
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser);
 
 /*!
   \brief Destroy a digit stream parser object
   \param parser a pointer to the parser object
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t * parser);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser);
 
 /*!
   \brief Create a new digit stream object
@@ -575,14 +562,14 @@
   \param stream a pointer to the stream object pointer
   \return NULL if no match found or consumer data that was associated with a given digit string when matched
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t * parser, switch_ivr_digit_stream_t ** stream);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream);
 
 /*!
   \brief Destroys a digit stream object
   \param stream a pointer to the stream object
   \return NULL if no match found or consumer data that was associated with a given digit string when matched
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t * stream);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t *stream);
 
 /*!
   \brief Set a digit string to action mapping
@@ -591,7 +578,7 @@
   \param data consumer data attached to this digit string
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t * parser, char *digits, void *data);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, char *digits, void *data);
 
 /*!
   \brief Delete a string to action mapping
@@ -599,7 +586,7 @@
   \param digits the digit string to be removed from the map
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t * parser, char *digits);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits);
 
 /*!
   \brief Feed digits collected into the stream for event match testing
@@ -608,14 +595,14 @@
   \param digit a digit to collect and test against the map of digit strings
   \return NULL if no match found or consumer data that was associated with a given digit string when matched
 */
-SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t * parser, switch_ivr_digit_stream_t * stream, char digit);
+SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit);
 
 /*!
   \brief Reset the collected digit stream to nothing
   \param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t * stream);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream);
 
 /*!
   \brief Set a digit string terminator
@@ -623,7 +610,7 @@
   \param digit the terminator digit
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t * parser, char digit);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit);
 
 
 /******************************************************************************************************/
@@ -655,7 +642,7 @@
 		 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 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;
 /******************************************************************************************************/
@@ -669,31 +656,28 @@
  *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops.
  *\param invalid_sound Optional pointer to a sound to play after invalid input.
  *\param exit_sound Optional pointer to a sound to play upon exiting the menu.
- *\param confirm_macro - NEEDDESC -
- *\param confirm_key   - NEEDDESC -
- *\param confirm_attempts - NEEDDESC -
- *\param inter_timeout - NEEDDESC -
- *\param digit_len     - NEEDDESC -
+ *\param confirm_macro phrase macro name to confirm input
+ *\param confirm_key the dtmf key required for positive confirmation
+ *\param confirm_attempts number of times to prompt to confirm input before failure
+ *\param inter_timeout inter-digit timeout
+ *\param digit_len max number of digits
  *\param timeout A number of milliseconds to pause before looping.
  *\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
  *\param pool memory pool (NULL to create one).
  *\return SWITCH_STATUS_SUCCESS if the menu was created.
  */
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu,
-													 switch_ivr_menu_t * main,
-													 const char *name,
-													 const char *greeting_sound,
-													 const char *short_greeting_sound,
-													 const char *invalid_sound,
-													 const char *exit_sound,
-													 const char *confirm_macro,
-													 const char *confirm_key,
-													 int confirm_attempts,
-													 int inter_timeout,
-													 int digit_len,
-													 int timeout, int max_failures,
-													 switch_memory_pool_t *pool);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
+														  switch_ivr_menu_t *main,
+														  const char *name,
+														  const char *greeting_sound,
+														  const char *short_greeting_sound,
+														  const char *invalid_sound,
+														  const char *exit_sound,
+														  const char *confirm_macro,
+														  const char *confirm_key,
+														  int confirm_attempts,
+														  int inter_timeout, int digit_len, int timeout, int max_failures, switch_memory_pool_t *pool);
 
 /*!
  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
@@ -703,7 +687,8 @@
  *\param bind KeyStrokes to bind the action to.
  *\return SWUTCH_STATUS_SUCCESS if the action was binded
  */
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t * menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg,
+																 const char *bind);
 
 
 /*!
@@ -717,8 +702,8 @@
  *\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args.
  *\return SWUTCH_STATUS_SUCCESS if the function was binded
  */
-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);
+	 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);
 
 
 /*!
@@ -729,14 +714,14 @@
  *\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function.
  *\return SWITCH_STATUS_SUCCESS if all is well
  */
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t * stack, char *name, void *obj);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj);
 
 /*!
  *\brief free a stack of menu objects.
  *\param stack The top level menu you wish to destroy.
  *\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed
  */
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t * stack);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack);
 
 	 struct switch_ivr_menu_xml_ctx;
 	 typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
@@ -748,10 +733,10 @@
  *\param xml_menu The xml Menu source of the menu to be created
  *\return SWITCH_STATUS_SUCCESS if all is well
  */
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t * xml_menu_ctx,
-																switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
+																	 switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
 
 /*!
  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
@@ -759,46 +744,45 @@
  *\param function The menu function callback that will be executed when menu digits are bound to this name
  *\return SWITCH_STATUS_SUCCESS if all is well
  */
-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);
+	 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);
 
 /*!
  *\param xml_menu_ctx A pointer of a XML menu parser context to be created
  *\param pool memory pool (NULL to create one)
  *\return SWITCH_STATUS_SUCCESS if all is well
  */
-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t ** xml_menu_ctx, switch_memory_pool_t *pool);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool);
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang,
-														switch_input_args_t *args);
-SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
-SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
-SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg);
-SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
-
-SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
-												uint32_t min_digits,
-												uint32_t max_digits,
-												const char *prompt_audio_file,
-												const char *var_name,
-												char *digit_buffer, 
-												switch_size_t digit_buffer_length,
-												uint32_t timeout,
-												const char *valid_terminators);
-
-SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, 
-																  switch_bind_flag_t bind_flags, const char *app);
-SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
-SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, switch_input_args_t *args);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang,
+															 switch_input_args_t *args);
+	 SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
+	 SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg);
+	 SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
+
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
+													 uint32_t min_digits,
+													 uint32_t max_digits,
+													 const char *prompt_audio_file,
+													 const char *var_name,
+													 char *digit_buffer,
+													 switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators);
+
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key,
+																	   switch_bind_flag_t bind_flags, const char *app);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
+	 SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type,
+													const char *say_method, switch_input_args_t *args);
 
-SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
-SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
+	 SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
+	 SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
 
 /** @} */
 
-SWITCH_END_EXTERN_C
+	 SWITCH_END_EXTERN_C
 #endif
 /* For Emacs:
  * Local Variables:

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_loadable_module.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_loadable_module.h	Tue May 27 07:24:06 2008
@@ -128,9 +128,8 @@
 SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename,
 																	 switch_module_load_t switch_module_load,
 																	 switch_module_runtime_t switch_module_runtime,
-																	 switch_module_shutdown_t switch_module_shutdown,
-																	 switch_bool_t runtime);
-																	 
+																	 switch_module_shutdown_t switch_module_shutdown, switch_bool_t runtime);
+
 
 /*!
   \brief Retrieve the timer interface by it's registered name
@@ -259,7 +258,7 @@
   \param filename the path to the module's dll or so file
   \return SWITCH_STATUS_SUCCESS on a successful load
 */
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load( switch_loadable_module_interface_t **module_interface, char *filename);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface, char *filename);
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
 
 /*!
@@ -317,44 +316,43 @@
 	}
 
 
-static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool,
-                                                        switch_codec_interface_t *codec_interface,
-                                                        /*! enumeration defining the type of the codec */
-                                                        const switch_codec_type_t codec_type,
-                                                        /*! the IANA code number */
-                                                        switch_payload_t ianacode,
-                                                        /*! the IANA code name */
-                                                        const char *iananame,
-                                                        /*! default fmtp to send (can be overridden by the init function) */
-                                                        char *fmtp,
-                                                        /*! samples transferred per second */
-                                                        uint32_t samples_per_second,
-                                                        /*! actual samples transferred per second for those who are not moron g722 RFC writers*/
-                                                        uint32_t actual_samples_per_second,
-                                                        /*! bits transferred per second */
-                                                        int bits_per_second,
-                                                        /*! number of microseconds that denote one frame */
-                                                        int microseconds_per_frame,
-                                                        /*! number of samples that denote one frame */
-                                                        uint32_t samples_per_frame,
-                                                        /*! number of bytes that denote one frame decompressed */
-                                                        uint32_t bytes_per_frame,
-                                                        /*! number of bytes that denote one frame compressed */
-                                                        uint32_t encoded_bytes_per_frame,
-                                                        /*! number of channels represented */
-                                                        uint8_t number_of_channels,
-                                                        /*! number of frames to send in one netowrk packet */
-                                                        int pref_frames_per_packet,
-                                                        /*! max number of frames to send in one network packet */
-                                                        int max_frames_per_packet,
-                                                        /*! function to initialize a codec handle using this implementation */
-                                                        switch_core_codec_init_func_t init,
-                                                        /*! function to encode raw data into encoded data */
-                                                        switch_core_codec_encode_func_t encode,
-                                                        /*! function to decode encoded data into raw data */
-                                                        switch_core_codec_decode_func_t decode,
-                                                        /*! deinitalize a codec handle using this implementation */
-                                                        switch_core_codec_destroy_func_t destroy)
+	 static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface,
+															 /*! enumeration defining the type of the codec */
+															 const switch_codec_type_t codec_type,
+															 /*! the IANA code number */
+															 switch_payload_t ianacode,
+															 /*! the IANA code name */
+															 const char *iananame,
+															 /*! default fmtp to send (can be overridden by the init function) */
+															 char *fmtp,
+															 /*! samples transferred per second */
+															 uint32_t samples_per_second,
+															 /*! actual samples transferred per second for those who are not moron g722 RFC writers */
+															 uint32_t actual_samples_per_second,
+															 /*! bits transferred per second */
+															 int bits_per_second,
+															 /*! number of microseconds that denote one frame */
+															 int microseconds_per_frame,
+															 /*! number of samples that denote one frame */
+															 uint32_t samples_per_frame,
+															 /*! number of bytes that denote one frame decompressed */
+															 uint32_t bytes_per_frame,
+															 /*! number of bytes that denote one frame compressed */
+															 uint32_t encoded_bytes_per_frame,
+															 /*! number of channels represented */
+															 uint8_t number_of_channels,
+															 /*! number of frames to send in one netowrk packet */
+															 int pref_frames_per_packet,
+															 /*! max number of frames to send in one network packet */
+															 int max_frames_per_packet,
+															 /*! function to initialize a codec handle using this implementation */
+															 switch_core_codec_init_func_t init,
+															 /*! function to encode raw data into encoded data */
+															 switch_core_codec_encode_func_t encode,
+															 /*! function to decode encoded data into raw data */
+															 switch_core_codec_decode_func_t decode,
+															 /*! deinitalize a codec handle using this implementation */
+															 switch_core_codec_destroy_func_t destroy)
 {
 	if (codec_type == SWITCH_CODEC_TYPE_VIDEO || SWITCH_ACCEPTABLE_INTERVAL(microseconds_per_frame / 1000)) {
 		switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_log.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_log.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_log.h	Tue May 27 07:24:06 2008
@@ -111,7 +111,7 @@
   \param level the level
   \return the name of the log level
 */
-_Ret_z_  SWITCH_DECLARE(const char *) switch_log_level2str(_In_ switch_log_level_t level);
+	 _Ret_z_ SWITCH_DECLARE(const char *) switch_log_level2str(_In_ switch_log_level_t level);
 
 /*! 
   \brief Return the level number of the specified log level name

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_module_interfaces.h	Tue May 27 07:24:06 2008
@@ -45,8 +45,7 @@
 SWITCH_BEGIN_EXTERN_C
 /*! \brief A table of functions to execute at various states 
 */
-
-typedef enum {
+	typedef enum {
 	SWITCH_SHN_ON_INIT,
 	SWITCH_SHN_ON_ROUTING,
 	SWITCH_SHN_ON_EXECUTE,
@@ -100,7 +99,31 @@
 
 
 typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
-(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
+ 
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	    (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t);
 typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
@@ -108,9 +131,9 @@
 typedef switch_status_t (*switch_io_receive_message_t) (switch_core_session_t *, switch_core_session_message_t *);
 typedef switch_status_t (*switch_io_receive_event_t) (switch_core_session_t *, switch_event_t *);
 typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_t *);
-typedef	switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
+typedef switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
 typedef switch_status_t (*switch_io_write_video_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
-typedef switch_call_cause_t (*switch_io_resurrect_session_t)(switch_core_session_t **, switch_memory_pool_t **, void *);
+typedef switch_call_cause_t (*switch_io_resurrect_session_t) (switch_core_session_t **, switch_memory_pool_t **, void *);
 
 typedef enum {
 	SWITCH_IO_OUTGOING_CHANNEL,
@@ -192,7 +215,7 @@
 	switch_memory_pool_t *memory_pool;
 	/*! private data for loadable modules to store information */
 	void *private_info;
-	/*! remaining time from last call to _check()*/
+	/*! remaining time from last call to _check() */
 	switch_size_t diff;
 	switch_size_t tick;
 };
@@ -346,7 +369,7 @@
 	/*! The Rate */
 	uint32_t rate;
 	char *grammar;
-	/*! module specific param*/
+	/*! module specific param */
 	char *param;
 	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
@@ -365,7 +388,7 @@
 	/*! function to feed audio to the ASR */
 	switch_status_t (*speech_feed_tts) (switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags);
 	/*! function to read audio from the TTS */
-	switch_status_t (*speech_read_tts) (switch_speech_handle_t *sh, void *data, switch_size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags);
+	switch_status_t (*speech_read_tts) (switch_speech_handle_t *sh, void *data, switch_size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags);
 	void (*speech_flush_tts) (switch_speech_handle_t *sh);
 	void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, const char *val);
 	void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
@@ -389,7 +412,7 @@
 	uint32_t samples;
 	char voice[80];
 	char *engine;
-	/*! module specific param*/
+	/*! module specific param */
 	char *param;
 	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
@@ -526,7 +549,7 @@
 	char *fmtp;
 	/*! samples transferred per second */
 	uint32_t samples_per_second;
-	/*! actual samples transferred per second for those who are not moron g722 RFC writers*/
+	/*! actual samples transferred per second for those who are not moron g722 RFC writers */
 	uint32_t actual_samples_per_second;
 	/*! bits transferred per second */
 	int bits_per_second;
@@ -545,13 +568,13 @@
 	/*! max number of frames to send in one network packet */
 	int max_frames_per_packet;
 	/*! function to initialize a codec handle using this implementation */
-    switch_core_codec_init_func_t init;
+	switch_core_codec_init_func_t init;
 	/*! function to encode raw data into encoded data */
-    switch_core_codec_encode_func_t encode;
+	switch_core_codec_encode_func_t encode;
 	/*! function to decode encoded data into raw data */
-    switch_core_codec_decode_func_t decode;
+	switch_core_codec_decode_func_t decode;
 	/*! deinitalize a codec handle using this implementation */
-    switch_core_codec_destroy_func_t destroy;
+	switch_core_codec_destroy_func_t destroy;
 	uint32_t codec_id;
 	struct switch_codec_implementation *next;
 };

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_odbc.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_odbc.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_odbc.h	Tue May 27 07:24:06 2008
@@ -44,9 +44,7 @@
 #endif
 #include <sqltypes.h>
 
-SWITCH_BEGIN_EXTERN_C 
-
-struct switch_odbc_handle;
+SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle;
 
 typedef enum {
 	SWITCH_ODBC_STATE_INIT,
@@ -70,7 +68,6 @@
 																	  char *sql, switch_core_db_callback_func_t callback, void *pdata);
 SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt);
 SWITCH_END_EXTERN_C
-
 #endif
 /* For Emacs:
  * Local Variables:

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_platform.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_platform.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_platform.h	Tue May 27 07:24:06 2008
@@ -59,17 +59,13 @@
  * C4610: struct  can never be instantiated - user defined constructor required
  */
 #pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996)
-
 #define SWITCH_HAVE_ODBC 1
-
 #ifdef _MSC_VER
 #  pragma comment(lib, "odbc32.lib")
 #endif
-
 #if (_MSC_VER >= 1400)			// VC8+
 #define switch_assert(expr) assert(expr);__analysis_assume( expr )
 #endif
-
 #if (_MSC_VER >= 1400)			// VC8+
 #ifndef _CRT_SECURE_NO_DEPRECATE
 #define _CRT_SECURE_NO_DEPRECATE
@@ -86,7 +82,7 @@
 #undef inline
 #define inline __inline
 #ifndef uint32_t
-typedef unsigned __int8 uint8_t;
+	typedef unsigned __int8 uint8_t;
 typedef unsigned __int16 uint16_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
@@ -183,9 +179,9 @@
 #define PRINTF_FUNCTION(fmtstr,vars)
 #endif
 #ifdef SWITCH_INT32
-	typedef SWITCH_INT32 switch_int32_t;
+typedef SWITCH_INT32 switch_int32_t;
 #else
-	typedef int32_t switch_int32_t;
+typedef int32_t switch_int32_t;
 #endif
 
 #ifdef SWITCH_SIZE_T
@@ -294,10 +290,9 @@
 #ifndef switch_assert
 #define switch_assert(expr) assert(expr)
 #endif
-
 #ifndef __ATTR_SAL
- /* used for msvc code analysis */
- /* http://msdn2.microsoft.com/en-us/library/ms235402.aspx */
+	/* used for msvc code analysis */
+	/* http://msdn2.microsoft.com/en-us/library/ms235402.aspx */
 #define _In_
 #define _In_z_
 #define _In_opt_z_
@@ -320,8 +315,6 @@
 #define _Out_ptrdiff_cap_(x)
 #define _Out_opt_ptrdiff_cap_(x)
 #endif
-
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_rtp.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_rtp.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_rtp.h	Tue May 27 07:24:06 2008
@@ -45,9 +45,7 @@
 #define SWITCH_RTP_KEY_LEN 30
 #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32"
 #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80"
-
-
-typedef enum {
+	typedef enum {
 	SWITCH_RTP_CRYPTO_SEND,
 	SWITCH_RTP_CRYPTO_RECV,
 	SWITCH_RTP_CRYPTO_MAX
@@ -72,16 +70,13 @@
 
 SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session,
 														  switch_rtp_crypto_direction_t direction,
-														  uint32_t index,
-														  switch_rtp_crypto_key_type_t type,
-														  unsigned char *key,
-														  switch_size_t keylen);
+														  uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen);
 
 ///\defgroup rtp RTP (RealTime Transport Protocol)
 ///\ingroup core1
 ///\{
-typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session,
-											  switch_socket_t * sock, void *data, switch_size_t datalen, switch_sockaddr_t * from_addr);
+	 typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session,
+												   switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr);
 
 
 SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len);
@@ -130,10 +125,7 @@
 												  switch_payload_t payload,
 												  uint32_t samples_per_interval,
 												  uint32_t ms_per_packet,
-												  switch_rtp_flag_t flags,
-												  char *timer_name, 
-												  const char **err,
-												  switch_memory_pool_t *pool);
+												  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
 
 
 /*!
@@ -158,10 +150,7 @@
 											  switch_payload_t payload,
 											  uint32_t samples_per_interval,
 											  uint32_t ms_per_packet,
-											  switch_rtp_flag_t flags,
-											  char *timer_name,
-											  const char **err,
-											  switch_memory_pool_t *pool);
+											  switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool);
 
 
 /*! 
@@ -296,7 +285,7 @@
   \param io_flags i/o flags
   \return the number of bytes read
 */
-SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t * datalen,
+SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen,
 												switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags);
 
 /*! 
@@ -308,7 +297,7 @@
 SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf);
 
 /*! 
-  \brief Queue RFC2833 DTMF data into an RTP Session - NEEDDESC -
+  \brief Queue RFC2833 DTMF data into an RTP Session
   \param rtp_session the rtp session to use
   \param dtmf the dtmf digits to queue
   \return SWITCH_STATUS_SUCCESS on success
@@ -341,7 +330,8 @@
   \return the number of bytes read
 */
 SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session,
-														 void **data, uint32_t * datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags);
+														 void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags,
+														 switch_io_flag_t io_flags);
 
 /*! 
   \brief Read data from a given RTP session without copying
@@ -390,9 +380,7 @@
   \return the number of bytes written
 */
 SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
-											void *data,
-											uint32_t datalen,
-											uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
+											void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
 
 /*! 
   \brief Retrieve the SSRC from a given RTP session

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_stun.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_stun.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_stun.h	Tue May 27 07:24:06 2008
@@ -137,7 +137,7 @@
   \param len the length of the data
   \return a stun packet pointer to buf to use as an access point
 */
-SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t * buf, uint32_t len);
+SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t *buf, uint32_t len);
 
 /*!
   \brief Obtain a printable string form of a given value
@@ -155,7 +155,7 @@
   \param port the port
   \return true or false
 */
-SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute, char *ipstr, uint16_t * port);
+SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute, char *ipstr, uint16_t *port);
 
 /*!
   \brief Extract a username from a packet attribute
@@ -174,7 +174,7 @@
   \param buf a pointer to data to use for the packet
   \return a pointer to a ready-to-use stun packet
 */
-SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_build_header(switch_stun_message_t type, char *id, uint8_t * buf);
+SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_build_header(switch_stun_message_t type, char *id, uint8_t *buf);
 
 /*!
   \brief Add a username packet attribute

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_types.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_types.h	Tue May 27 07:24:06 2008
@@ -91,11 +91,9 @@
 #define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR
 #define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
 #define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
-
 #define SWITCH_DEFAULT_DTMF_DURATION 2000
 #define SWITCH_MAX_DTMF_DURATION 192000
 #define SWITCH_DEFAULT_DIR_PERMS SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE | SWITCH_FPROT_UEXECUTE | SWITCH_FPROT_GREAD | SWITCH_FPROT_GEXECUTE
-
 #ifdef WIN32
 #define SWITCH_PATH_SEPARATOR "\\"
 #else
@@ -144,7 +142,7 @@
 #define SWITCH_SPEECH_KEY "speech"
 #define SWITCH_UUID_BRIDGE "uuid_bridge"
 #define SWITCH_BITS_PER_BYTE 8
-typedef uint8_t switch_byte_t;
+	typedef uint8_t switch_byte_t;
 
 typedef struct {
 	char digit;
@@ -168,7 +166,7 @@
 typedef enum {
 	SOF_NONE = 0,
 	SOF_NOBLOCK = (1 << 0),
-	SOF_FORKED_DIAL = (1 << 1) 
+	SOF_FORKED_DIAL = (1 << 1)
 } switch_originate_flag_t;
 
 typedef enum {
@@ -185,7 +183,7 @@
 
 typedef enum {
 	SCF_NONE = 0,
-	SCF_USE_SQL = ( 1 << 0),
+	SCF_USE_SQL = (1 << 0),
 	SCF_NO_NEW_SESSIONS = (1 << 1),
 	SCF_SHUTTING_DOWN = (1 << 2),
 	SCF_CRASH_PROT = (1 << 3)
@@ -320,10 +318,10 @@
 
 #define SWITCH_MAX_STACKS 32
 #define SWITCH_THREAD_STACKSIZE 240 * 1024
-#define SWITCH_MAX_INTERVAL 120 /* we only do up to 120ms */
-#define SWITCH_INTERVAL_PAD 10 /* A little extra buffer space to be safe */
+#define SWITCH_MAX_INTERVAL 120	/* we only do up to 120ms */
+#define SWITCH_INTERVAL_PAD 10	/* A little extra buffer space to be safe */
 #define SWITCH_MAX_SAMPLE_LEN 32
-#define SWITCH_BYTES_PER_SAMPLE 2 /* slin is 2 bytes per sample */
+#define SWITCH_BYTES_PER_SAMPLE 2	/* slin is 2 bytes per sample */
 #define SWITCH_RECOMMENDED_BUFFER_SIZE (SWITCH_BYTES_PER_SAMPLE * SWITCH_MAX_SAMPLE_LEN * (SWITCH_MAX_INTERVAL + SWITCH_INTERVAL_PAD))
 #define SWITCH_MAX_CODECS 30
 #define SWITCH_MAX_STATE_HANDLERS 30
@@ -425,29 +423,29 @@
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 typedef struct {
-	unsigned version:2;   /* protocol version       */
-	unsigned p:1;     /* padding flag           */
-	unsigned x:1;     /* header extension flag  */
-	unsigned cc:4;    /* CSRC count             */
-	unsigned m:1;     /* marker bit             */
-	unsigned pt:7;    /* payload type           */
-	unsigned seq:16;      /* sequence number        */
-	unsigned ts:32;       /* timestamp              */
-	unsigned ssrc:32; /* synchronization source */
+	unsigned version:2;			/* protocol version       */
+	unsigned p:1;				/* padding flag           */
+	unsigned x:1;				/* header extension flag  */
+	unsigned cc:4;				/* CSRC count             */
+	unsigned m:1;				/* marker bit             */
+	unsigned pt:7;				/* payload type           */
+	unsigned seq:16;			/* sequence number        */
+	unsigned ts:32;				/* timestamp              */
+	unsigned ssrc:32;			/* synchronization source */
 } switch_rtp_hdr_t;
 
 #else /*  BIG_ENDIAN */
 
 typedef struct {
-	unsigned cc:4;    /* CSRC count             */
-	unsigned x:1;     /* header extension flag  */
-	unsigned p:1;     /* padding flag           */
-	unsigned version:2;   /* protocol version       */
-	unsigned pt:7;    /* payload type           */
-	unsigned m:1;     /* marker bit             */
-	unsigned seq:16;      /* sequence number        */
-	unsigned ts:32;       /* timestamp              */
-	unsigned ssrc:32; /* synchronization source */
+	unsigned cc:4;				/* CSRC count             */
+	unsigned x:1;				/* header extension flag  */
+	unsigned p:1;				/* padding flag           */
+	unsigned version:2;			/* protocol version       */
+	unsigned pt:7;				/* payload type           */
+	unsigned m:1;				/* marker bit             */
+	unsigned seq:16;			/* sequence number        */
+	unsigned ts:32;				/* timestamp              */
+	unsigned ssrc:32;			/* synchronization source */
 } switch_rtp_hdr_t;
 
 #endif
@@ -1210,25 +1208,19 @@
 
 
 typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *codec,
-                                                            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);
+															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);
 
 
 typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *codec,
-                                                            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);
+															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);
 
 typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
 typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
@@ -1255,7 +1247,8 @@
 typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
 typedef switch_status_t (*switch_stream_handle_raw_write_function_t) (switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen);
 
-typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream);
+typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session,
+												  _In_ switch_stream_handle_t *stream);
 
 #define SWITCH_STANDARD_API(name) static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream)
 
@@ -1274,9 +1267,9 @@
 												  char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
 typedef struct switch_xml *switch_xml_t;
 typedef struct switch_core_time_duration switch_core_time_duration_t;
-typedef switch_xml_t(*switch_xml_search_function_t) (const char *section,
-													 const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
-													 void *user_data);
+typedef switch_xml_t (*switch_xml_search_function_t) (const char *section,
+													  const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
+													  void *user_data);
 
 typedef struct switch_hash switch_hash_t;
 struct HashElem;
@@ -1290,9 +1283,9 @@
 #define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
 #define SWITCH_MODULE_RUNTIME_ARGS (void)
 #define SWITCH_MODULE_SHUTDOWN_ARGS (void)
-typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS ;
-typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS ;
-typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS ;
+typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS;
+typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS;
+typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS;
 #define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_ARGS
 #define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS
 #define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_utils.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_utils.h	Tue May 27 07:24:06 2008
@@ -54,15 +54,12 @@
 #else
 #define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)))
 #endif
-
 /*!
   \brief Test for NULL or zero length string
   \param s the string to test
   \return true value if the string is NULL or zero length
 */
 #define switch_strlen_zero(s) (!s || *s == '\0')
-
-
 static inline switch_bool_t switch_is_moh(const char *s)
 {
 	if (switch_strlen_zero(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) {
@@ -78,9 +75,10 @@
 SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen);
 SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len);
 
-static inline switch_bool_t switch_is_digit_string(const char *s) {
+	 static inline switch_bool_t switch_is_digit_string(const char *s)
+{
 
-	while(s && *s) {
+	while (s && *s) {
 		if (*s < 48 || *s > 57) {
 			return SWITCH_FALSE;
 		}
@@ -113,7 +111,8 @@
   \param family the address family to return (AF_INET or AF_INET6)
   \return SWITCH_STATUS_SUCCESSS for success, otherwise failure
 */
-SWITCH_DECLARE(switch_status_t) switch_find_local_ip(_Out_opt_bytecapcount_(len) char *buf, _In_ int len, _In_ int family);
+SWITCH_DECLARE(switch_status_t) switch_find_local_ip(_Out_opt_bytecapcount_(len)
+													 char *buf, _In_ int len, _In_ int family);
 
 /*!
   \brief find the char representation of an ip adress
@@ -205,7 +204,7 @@
 
 #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
 
-static inline char *switch_clean_string(char *s)
+	 static inline char *switch_clean_string(char *s)
 {
 	char *p;
 	for (p = s; p && *p; p++) {
@@ -247,11 +246,11 @@
 	}
 
 	S = strdup(s);
-	
+
 	assert(S != NULL);
 
 	for (p = S; p && *p; p++) {
-		*p = (char)toupper(*p);
+		*p = (char) toupper(*p);
 	}
 
 	if (strstr(S, q)) {
@@ -263,9 +262,9 @@
 	assert(Q != NULL);
 
 	for (p = Q; p && *p; p++) {
-		*p = (char)toupper(*p);
+		*p = (char) toupper(*p);
 	}
-	
+
 	if (strstr(s, Q)) {
 		tf = SWITCH_TRUE;
 		goto done;
@@ -275,8 +274,8 @@
 		tf = SWITCH_TRUE;
 		goto done;
 	}
-	
- done:
+
+  done:
 	switch_safe_free(S);
 	switch_safe_free(Q);
 
@@ -345,7 +344,7 @@
   \param ms the number of milliseconds to wait
   \return the requested condition
 */
-SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t * poll, int ms);
+SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
 
 /*!
   \brief Create a pointer to the file name in a given file path eliminating the directory name
@@ -369,7 +368,7 @@
 SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip(switch_network_list_t *list, uint32_t ip);
 #define switch_test_subnet(_ip, _net, _mask) (_mask ? ((_net & _mask) == (_ip & _mask)) : _net ? _net == _ip : 1)
 
-int switch_inet_pton(int af, const char *src, void *dst);
+	 int switch_inet_pton(int af, const char *src, void *dst);
 
 /* malloc or DIE macros */
 #ifdef NDEBUG

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_xml.h
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_xml.h	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/include/switch_xml.h	Tue May 27 07:24:06 2008
@@ -184,7 +184,7 @@
 ///\ Returns NULL if not found.
 ///\param xml the xml node
 ///\return an xml node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml,...);
+SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...);
 
 ///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that
 ///\ must be freed.
@@ -234,7 +234,7 @@
 ///\param name the name of the tag
 ///\param off the offset
 ///\return an xml node or NULL
-	 SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
+SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
 
 ///\brief wrapper for switch_xml_add_child() that strdup()s name
 ///\param xml the xml node
@@ -247,7 +247,7 @@
 ///\param xml the xml node
 ///\param txt the text
 ///\return an xml node or NULL
-	 SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt);
+SWITCH_DECLARE(switch_xml_t) switch_xml_set_txt(switch_xml_t xml, const char *txt);
 
 ///\brief wrapper for switch_xml_set_txt() that strdup()s txt
 ///\ sets the character content for the given tag and returns the tag
@@ -324,25 +324,22 @@
 ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
 SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
 												  const char *tag_name,
-												  const char *key_name, const char *key_value, switch_xml_t * root, switch_xml_t * node,
+												  const char *key_name, const char *key_value, switch_xml_t *root, switch_xml_t *node,
 												  switch_event_t *params);
 
 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);
 SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
-													   const char *user_name, 
-													   const char *domain_name, 
-													   const char *ip, 
-													   switch_xml_t *root,
-													   switch_xml_t *domain,
-													   switch_xml_t *user,
-													   switch_event_t *params);
+													   const char *user_name,
+													   const char *domain_name,
+													   const char *ip,
+													   switch_xml_t *root, switch_xml_t *domain, switch_xml_t *user, switch_event_t *params);
 
 ///\brief open a config in the core registry
 ///\param file_path the name of the config section e.g. modules.conf
 ///\param node a pointer to point to the node if it is found
 ///\param params optional URL formatted params to pass to external gateways
 ///\return the root xml node associated with the current request or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t * node, switch_event_t *params);
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t *node, switch_event_t *params);
 
 ///\brief bind a search function to an external gateway
 ///\param function the search function to bind

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_commands/mod_commands.c	Tue May 27 07:24:06 2008
@@ -43,7 +43,7 @@
 
 SWITCH_STANDARD_API(user_data_function)
 {
-	switch_xml_t x_domain, xml = NULL, x_user = NULL, x_param, x_params;	
+	switch_xml_t x_domain, xml = NULL, x_user = NULL, x_param, x_params;
 	int argc;
 	char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain;
 	char delim = ' ';
@@ -94,7 +94,7 @@
 		}
 	}
 
-end:
+  end:
 	switch_xml_free(xml);
 	free(mydata);
 	switch_event_destroy(&params);
@@ -115,7 +115,7 @@
 	const char *err = NULL;
 
 	if (stream->param_event && (host = switch_event_get_header(stream->param_event, "http-host"))) {
-		stream->write_function(stream,  "Content-Type: text/xml\r\n\r\n");
+		stream->write_function(stream, "Content-Type: text/xml\r\n\r\n");
 		if ((path_info = switch_event_get_header(stream->param_event, "http-path-info"))) {
 			cmd = path_info;
 			delim = '/';
@@ -151,16 +151,16 @@
 		goto end;
 	}
 
-end:
+  end:
 	if (session || tf) {
 		stream->write_function(stream, err ? "false" : "true");
 		switch_xml_free(xml);
 	} else {
 		if (err) {
 			if (host) {
-				stream->write_function(stream,  "<error>%s</error>\n", err);
+				stream->write_function(stream, "<error>%s</error>\n", err);
 			} else {
-				stream->write_function(stream,  "-Error %s\n", err);
+				stream->write_function(stream, "-Error %s\n", err);
 			}
 		}
 
@@ -168,7 +168,7 @@
 			xmlstr = switch_xml_toxml(x_user, SWITCH_FALSE);
 			switch_assert(xmlstr);
 
-			stream->write_function(stream,  "%s", xmlstr);
+			stream->write_function(stream, "%s", xmlstr);
 			free(xmlstr);
 			switch_xml_free(xml);
 		}
@@ -201,7 +201,7 @@
 	const char *err = NULL;
 
 	if (stream->param_event && (host = switch_event_get_header(stream->param_event, "http-host"))) {
-		stream->write_function(stream,  "Content-Type: text/xml\r\n\r\n");
+		stream->write_function(stream, "Content-Type: text/xml\r\n\r\n");
 		if ((path_info = switch_event_get_header(stream->param_event, "http-path-info"))) {
 			cmd = path_info;
 			delim = '/';
@@ -243,16 +243,16 @@
 	switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_val", tag_attr_val);
 
 	if (switch_xml_locate(section, tag, tag_attr_name, tag_attr_val, &xml, &obj, params) != SWITCH_STATUS_SUCCESS) {
-		stream->write_function(stream,  "can't find anything\n");
+		stream->write_function(stream, "can't find anything\n");
 		goto end;
 	}
 
-end:
+  end:
 	if (err) {
 		if (host) {
-			stream->write_function(stream,  "<error>%s</error>\n", err);
+			stream->write_function(stream, "<error>%s</error>\n", err);
 		} else {
-			stream->write_function(stream,  "-Error %s\n", err);
+			stream->write_function(stream, "-Error %s\n", err);
 		}
 	}
 
@@ -260,7 +260,7 @@
 		xmlstr = switch_xml_toxml(obj, SWITCH_FALSE);
 		switch_assert(xmlstr);
 
-		stream->write_function(stream,  "%s", xmlstr);
+		stream->write_function(stream, "%s", xmlstr);
 		free(xmlstr);
 		switch_xml_free(xml);
 
@@ -274,11 +274,11 @@
 SWITCH_STANDARD_API(reload_acl_function)
 {
 	const char *err;
-    switch_xml_t xml_root;
+	switch_xml_t xml_root;
 
-    if (session) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
 
 	if (cmd && !strcmp(cmd, "reloadxml")) {
 		if ((xml_root = switch_xml_open_root(1, &err))) {
@@ -311,15 +311,15 @@
 	}
 
 	if (switch_check_network_list_ip(argv[0], argv[1])) {
-		stream->write_function(stream, "true");    
+		stream->write_function(stream, "true");
 		goto ok;
 	}
 
-error:
+  error:
 
-	stream->write_function(stream, "false");    
+	stream->write_function(stream, "false");
 
-ok:
+  ok:
 
 	switch_safe_free(mydata);
 
@@ -357,10 +357,10 @@
 			substituted = malloc(len);
 			switch_assert(substituted);
 			memset(substituted, 0, len);
-			switch_replace_char(argv[2], '%','$', SWITCH_FALSE);
+			switch_replace_char(argv[2], '%', '$', SWITCH_FALSE);
 			switch_perform_substitution(re, proceed, argv[2], argv[0], substituted, len, ovector);
 
-			stream->write_function(stream, "%s", substituted);    			
+			stream->write_function(stream, "%s", substituted);
 			free(substituted);
 		} else {
 			stream->write_function(stream, "true");
@@ -370,9 +370,9 @@
 	}
 	goto ok;
 
-error:
-	stream->write_function(stream, "-ERR");    
-ok:
+  error:
+	stream->write_function(stream, "-ERR");
+  ok:
 	switch_regex_safe_free(re);
 	switch_safe_free(mydata);
 	return SWITCH_STATUS_SUCCESS;
@@ -426,14 +426,14 @@
 			o = O_NE;
 		}
 	} else if ((expr = strchr(a, '>'))) {
-		if (*(expr+1) == '=') {
+		if (*(expr + 1) == '=') {
 			*expr++ = '\0';
 			o = O_GE;
 		} else {
 			o = O_GT;
 		}
 	} else if ((expr = strchr(a, '<'))) {
-		if (*(expr+1) == '=') {
+		if (*(expr + 1) == '=') {
 			*expr++ = '\0';
 			o = O_LE;
 		} else {
@@ -493,11 +493,11 @@
 		switch_safe_free(s_b);
 		stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]);
 		goto ok;
-	} 
+	}
 
-error:
-	stream->write_function(stream, "-ERR");    
-ok:
+  error:
+	stream->write_function(stream, "-ERR");
+  ok:
 
 	switch_safe_free(mydata);
 	return SWITCH_STATUS_SUCCESS;
@@ -512,7 +512,7 @@
 SWITCH_STANDARD_API(status_function)
 {
 	uint8_t html = 0;
-	switch_core_time_duration_t duration = {0};
+	switch_core_time_duration_t duration = { 0 };
 	char *http = NULL;
 	int sps = 0, last_sps = 0;
 
@@ -532,13 +532,13 @@
 	}
 
 	stream->write_function(stream,
-		"UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
-		duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s",
-		duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s",
-		duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms,
-		duration.mms == 1 ? "" : "s");
+						   "UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
+						   duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s",
+						   duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s",
+						   duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms,
+						   duration.mms == 1 ? "" : "s");
 
-	stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" session(s) since startup\n", switch_core_session_id() - 1 );
+	stream->write_function(stream, "%" SWITCH_SIZE_T_FMT " session(s) since startup\n", switch_core_session_id() - 1);
 	switch_core_session_ctl(SCSC_LAST_SPS, &last_sps);
 	switch_core_session_ctl(SCSC_SPS, &sps);
 	stream->write_function(stream, "%d session(s) %d/%d\n", switch_core_session_count(), last_sps, sps);
@@ -644,10 +644,10 @@
 		} else {
 			stream->write_function(stream, "-ERR INVALID COMMAND\nUSAGE: fsctl %s", CTL_SYNTAX);
 			goto end;
-		} 
+		}
 
 		stream->write_function(stream, "+OK\n");
-end:
+	  end:
 		free(mydata);
 	} else {
 		stream->write_function(stream, "-ERR Memory error\n");
@@ -831,7 +831,7 @@
 
 	switch_core_session_rwunlock(tsession);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -866,7 +866,7 @@
 	if (argv[4]) {
 		uint32_t mto;
 		if (*argv[4] == '+') {
-			if ((mto = atoi(argv[4]+1)) > 0) {
+			if ((mto = atoi(argv[4] + 1)) > 0) {
 				to = switch_timestamp(NULL) + mto;
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
@@ -884,7 +884,7 @@
 	switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]);
 	stream->write_function(stream, "+OK Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]);
 
-done:
+  done:
 
 	free(mydata);
 	switch_core_session_rwunlock(rsession);
@@ -1246,13 +1246,13 @@
 	} else {
 		switch_status_t status;
 		char *who = NULL;
-		
+
 		if ((status = switch_ivr_uuid_bridge(argv[0], argv[1])) != SWITCH_STATUS_SUCCESS) {
 			if (argv[2]) {
 				if ((status = switch_ivr_uuid_bridge(argv[0], argv[2])) == SWITCH_STATUS_SUCCESS) {
 					who = argv[2];
 				}
-			} 
+			}
 		} else {
 			who = argv[1];
 		}
@@ -1317,11 +1317,11 @@
 
 	goto done;
 
-usage:
+  usage:
 	stream->write_function(stream, "-USAGE: %s\n", SESS_REC_SYNTAX);
 	switch_safe_free(mycmd);
 
-done:
+  done:
 	if (rsession) {
 		switch_core_session_rwunlock(rsession);
 	}
@@ -1377,11 +1377,11 @@
 
 	goto done;
 
-usage:
+  usage:
 	stream->write_function(stream, "-USAGE: %s\n", DISPLACE_SYNTAX);
 	switch_safe_free(mycmd);
 
-done:
+  done:
 	if (rsession) {
 		switch_core_session_rwunlock(rsession);
 	}
@@ -1513,7 +1513,8 @@
 		timeout = atoi(argv[6]);
 	}
 
-	if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS || !caller_session) {
+	if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS
+		|| !caller_session) {
 		if (machine) {
 			stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
 		} else {
@@ -1557,7 +1558,7 @@
 
 	switch_core_session_rwunlock(caller_session);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return status;
 }
@@ -1594,7 +1595,7 @@
 		int64_t tmp;
 		tmp = (uint32_t) atoi(cmd);
 		if (tmp > 0) {
-			cnt = switch_scheduler_del_task_id((uint32_t)tmp);
+			cnt = switch_scheduler_del_task_id((uint32_t) tmp);
 		}
 	} else {
 		cnt = switch_scheduler_del_task_group(cmd);
@@ -1643,14 +1644,7 @@
 			}
 		}
 
-		stream->write_function(stream, 
-			"<result>\n"
-			"  <row id=\"1\">\n"
-			"    <data>%s</data>\n"
-			"  </row>\n"
-			"</result>\n",
-			send ? send : "ERROR"
-			);
+		stream->write_function(stream, "<result>\n" "  <row id=\"1\">\n" "    <data>%s</data>\n" "  </row>\n" "</result>\n", send ? send : "ERROR");
 		switch_safe_free(mystream.data);
 		switch_safe_free(edata);
 		free(dcommand);
@@ -1688,12 +1682,12 @@
 			id = switch_scheduler_add_task(when, sch_api_callback, (char *) __SWITCH_FUNC__, group, 0, strdup(dcmd), SSHF_FREE_ARG);
 			stream->write_function(stream, "+OK Added: %u\n", id);
 			goto good;
-		} 
+		}
 	}
 
 	stream->write_function(stream, "-ERR Invalid syntax\n");
 
-good:
+  good:
 	switch_safe_free(tm);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1701,7 +1695,7 @@
 struct bg_job {
 	char *cmd;
 	char *arg;
-	char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];	
+	char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
 	switch_memory_pool_t *pool;
 };
 
@@ -1715,7 +1709,8 @@
 	char *arg;
 	switch_memory_pool_t *pool;
 
-	if (!job) return NULL;
+	if (!job)
+		return NULL;
 
 	pool = job->pool;
 
@@ -1817,7 +1812,7 @@
 
 	switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id));
 
-	for(x = 0; x < argc; x++) {
+	for (x = 0; x < argc; x++) {
 		char *name = columnNames[x];
 		char *val = switch_str_nil(argv[x]);
 
@@ -1896,7 +1891,7 @@
 	} else {
 		stream->write_function(stream, "-USAGE: %s\n", COMPLETE_SYNTAX);
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1912,7 +1907,7 @@
 	} else {
 		stream->write_function(stream, "-USAGE: %s\n", ALIAS_SYNTAX);
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1924,7 +1919,7 @@
 	switch_core_db_t *db;
 	struct holder holder = { 0 };
 	int help = 0;
-	char *mydata = NULL, *argv[6] = {0};
+	char *mydata = NULL, *argv[6] = { 0 };
 	int argc;
 	char *command = NULL, *as = NULL;
 	switch_core_flag_t cflags = switch_core_flags();
@@ -1980,7 +1975,8 @@
 		holder.print_title = 0;
 		if ((cmdname = strchr(command, ' ')) != 0) {
 			*cmdname++ = '\0';
-			switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s' order by name", cmdname);
+			switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s' order by name",
+							cmdname);
 		} else {
 			switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' order by name");
 		}
@@ -2127,10 +2123,10 @@
 
 	stream->write_function(stream, "-USAGE: %s\n", SETVAR_SYNTAX);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
-} 
+}
 
 #define GETVAR_SYNTAX "<uuid> <var>"
 SWITCH_STANDARD_API(uuid_getvar_function)
@@ -2177,7 +2173,7 @@
 
 	stream->write_function(stream, "-USAGE: %s\n", GETVAR_SYNTAX);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -2224,7 +2220,7 @@
 					}
 
 					switch_assert(buf);
-					stream->raw_write_function(stream, (unsigned char *)buf, strlen(buf));
+					stream->raw_write_function(stream, (unsigned char *) buf, strlen(buf));
 					switch_event_destroy(&event);
 					free(buf);
 				} else {
@@ -2242,7 +2238,7 @@
 
 	stream->write_function(stream, "-USAGE: %s\n", DUMP_SYNTAX);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -2270,10 +2266,10 @@
 
 	stream->write_function(stream, "-USAGE: %s\n", GLOBAL_SETVAR_SYNTAX);
 
-done:
+  done:
 	switch_safe_free(mycmd);
 	return SWITCH_STATUS_SUCCESS;
-} 
+}
 
 #define GLOBAL_GETVAR_SYNTAX "<var>"
 SWITCH_STANDARD_API(global_getvar_function)
@@ -2285,7 +2281,7 @@
 	}
 
 	stream->write_function(stream, "-USAGE: %s\n", GLOBAL_GETVAR_SYNTAX);
-done:
+  done:
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -2296,14 +2292,12 @@
 
 	SWITCH_ADD_API(commands_api_interface, "originate", "Originate a Call", originate_function, ORIGINATE_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "tone_detect", "Start Tone Detection on a channel", tone_detect_session_function, TONE_DETECT_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "killchan", "Kill Channel (depricated)", kill_function, KILL_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill Channel", kill_function, KILL_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_park", "Park Channel", park_function, PARK_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload ACL", reload_acl_function, "[reloadxml]");
 	SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_function, "");
 	SWITCH_ADD_API(commands_api_interface, "unload", "Unload Module", unload_function, LOAD_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "load", "Load Module", load_function, LOAD_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "transfer", "Transfer (depricated)", transfer_function, TRANSFER_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_transfer", "Transfer a session", transfer_function, TRANSFER_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "pause", "Pause", pause_function, PAUSE_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "break", "Break", break_function, BREAK_SYNTAX);
@@ -2317,23 +2311,20 @@
 	SWITCH_ADD_API(commands_api_interface, "uuid_dump", "uuid_dump", uuid_dump_function, DUMP_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "global_setvar", "global_setvar", global_setvar_function, GLOBAL_SETVAR_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "global_getvar", "global_getvar", global_getvar_function, GLOBAL_GETVAR_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace (depricated)", session_displace_function, DISPLACE_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_displace", "session displace", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
-	SWITCH_ADD_API(commands_api_interface, "session_record", "session record (depricated)", session_record_function, SESS_REC_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_record", "session record", session_record_function, SESS_REC_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "broadcast", "broadcast (depricated)", uuid_broadcast_function, BROADCAST_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "help", "Show help for all the api commands", help_function, "");
 	SWITCH_ADD_API(commands_api_interface, "version", "Show version of the switch", version_function, "");
 	SWITCH_ADD_API(commands_api_interface, "sched_hangup", "Schedule a running call to hangup", sched_hangup_function, SCHED_HANGUP_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function, SCHED_BROADCAST_SYNTAX);
-	SWITCH_ADD_API(commands_api_interface, "sched_transfer", "Schedule a broadcast event to a running call", sched_transfer_function, SCHED_TRANSFER_SYNTAX);
+	SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function,
+				   SCHED_BROADCAST_SYNTAX);
+	SWITCH_ADD_API(commands_api_interface, "sched_transfer", "Schedule a broadcast event to a running call", sched_transfer_function,
+				   SCHED_TRANSFER_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "create_uuid", "Create a uuid", uuid_function, UUID_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "sched_api", "Schedule an api command", sched_api_function, "[+]<time> <group_name> <command_string>");
 	SWITCH_ADD_API(commands_api_interface, "bgapi", "Execute an api command in a thread", bgapi_function, "<command>[ <arg>]");

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_conference/mod_conference.c	Tue May 27 07:24:06 2008
@@ -137,7 +137,7 @@
 	MFLAG_WASTE_BANDWIDTH = (1 << 7),
 	MFLAG_FLUSH_BUFFER = (1 << 8),
 	MFLAG_ENDCONF = (1 << 9),
-    MFLAG_HAS_AUDIO = (1 << 10),
+	MFLAG_HAS_AUDIO = (1 << 10),
 	MFLAG_TALKING = (1 << 11)
 } member_flag_t;
 
@@ -257,9 +257,9 @@
 	uint8_t min;
 	switch_speech_handle_t lsh;
 	switch_speech_handle_t *sh;
-    switch_byte_t *not_talking_buf;
-    uint32_t not_talking_buf_len;
-    int comfort_noise_level;
+	switch_byte_t *not_talking_buf;
+	uint32_t not_talking_buf_len;
+	int comfort_noise_level;
 	int video_running;
 	uint32_t eflags;
 } conference_obj_t;
@@ -290,7 +290,7 @@
 	switch_codec_t write_codec;
 	char *rec_path;
 	uint8_t *frame;
-    uint32_t frame_size;
+	uint32_t frame_size;
 	uint8_t *mux_frame;
 	uint32_t read;
 	int32_t energy_level;
@@ -298,8 +298,8 @@
 	int32_t volume_out_level;
 	uint32_t native_rate;
 	switch_audio_resampler_t *read_resampler;
-    int16_t *resample_out;
-    uint32_t resample_out_len;
+	int16_t *resample_out;
+	uint32_t resample_out_len;
 	conference_file_node_t *fnode;
 	conference_relationship_t *relationships;
 	switch_ivr_digit_stream_parser_t *dtmf_parser;
@@ -335,54 +335,54 @@
 
 /* Function Prototypes */
 static uint32_t next_member_id(void);
-static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member);
-static conference_member_t *conference_member_get(conference_obj_t * conference, uint32_t id);
-static conference_relationship_t *member_add_relationship(conference_member_t * member, uint32_t id);
-static switch_status_t member_del_relationship(conference_member_t * member, uint32_t id);
-static switch_status_t conference_add_member(conference_obj_t * conference, conference_member_t * member);
-static switch_status_t conference_del_member(conference_obj_t * conference, conference_member_t * member);
-static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, void *obj);
-static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t * thread, void *obj);
-static void conference_loop_output(conference_member_t * member);
-static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t stop);
-static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async);
-static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin);
-static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim);
+static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member);
+static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id);
+static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id);
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id);
+static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member);
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member);
+static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj);
+static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj);
+static void conference_loop_output(conference_member_t *member);
+static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop);
+static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async);
+static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin);
+static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim);
 SWITCH_STANDARD_API(conf_api_main);
 
-static switch_status_t conference_outcall(conference_obj_t * conference,
+static switch_status_t conference_outcall(conference_obj_t *conference,
 										  char *conference_name,
 										  switch_core_session_t *session,
 										  char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause);
-static switch_status_t conference_outcall_bg(conference_obj_t * conference,
+static switch_status_t conference_outcall_bg(conference_obj_t *conference,
 											 char *conference_name,
-											 switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, const char *cid_num);
+											 switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
+											 const char *cid_num);
 SWITCH_STANDARD_APP(conference_function);
-static void launch_conference_thread(conference_obj_t * conference);
-static void launch_conference_video_thread(conference_obj_t * conference);
-static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread, void *obj);
-static switch_status_t conference_local_play_file(conference_obj_t * conference,
-												  switch_core_session_t *session, char *path, uint32_t leadin);
-static switch_status_t conference_member_play_file(conference_member_t * member, char *file, uint32_t leadin);
-static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin);
-static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop);
+static void launch_conference_thread(conference_obj_t *conference);
+static void launch_conference_video_thread(conference_obj_t *conference);
+static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj);
+static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin);
+static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin);
+static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
+static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
 static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool);
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
-static void launch_conference_record_thread(conference_obj_t * conference, char *path);
+static void launch_conference_record_thread(conference_obj_t *conference, char *path);
 
 typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **);
 typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *);
 typedef switch_status_t (*conf_api_text_cmd_t) (conference_obj_t *, switch_stream_handle_t *, const char *);
 
-static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data);
-static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data);
-static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data);
-static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data);
-static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data);
-static switch_status_t conference_add_event_data(conference_obj_t * conference, switch_event_t *event);
-static switch_status_t conference_add_event_member_data(conference_member_t * member, switch_event_t *event);
+static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data);
+static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data);
+static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event);
+static switch_status_t conference_add_event_member_data(conference_member_t *member, switch_event_t *event);
 
-static switch_status_t conference_add_event_data(conference_obj_t * conference, switch_event_t *event)
+static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
@@ -392,11 +392,12 @@
 
 	return status;
 }
-static switch_status_t conference_add_event_member_data(conference_member_t * member, switch_event_t *event)
+static switch_status_t conference_add_event_member_data(conference_member_t *member, switch_event_t *event)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	
-	if (!member) return status;
+
+	if (!member)
+		return status;
 
 	if (member->session) {
 		switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -426,11 +427,12 @@
 }
 
 /* if other_member has a relationship with member, produce it */
-static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member)
+static conference_relationship_t *member_get_relationship(conference_member_t *member, conference_member_t *other_member)
 {
 	conference_relationship_t *rel = NULL, *global = NULL;
 
-	if (member == NULL || other_member == NULL || member->relationships == NULL) return NULL;
+	if (member == NULL || other_member == NULL || member->relationships == NULL)
+		return NULL;
 
 	switch_mutex_lock(member->flag_mutex);
 	switch_mutex_lock(other_member->flag_mutex);
@@ -453,11 +455,11 @@
 }
 
 /* traverse the conference member list for the specified member id and return it's pointer */
-static conference_member_t *conference_member_get(conference_obj_t * conference, uint32_t id)
+static conference_member_t *conference_member_get(conference_obj_t *conference, uint32_t id)
 {
 	conference_member_t *member = NULL;
 
-	switch_assert(conference != NULL); 
+	switch_assert(conference != NULL);
 	if (!id) {
 		return NULL;
 	}
@@ -484,7 +486,7 @@
 }
 
 /* stop the specified recording */
-static switch_status_t conference_record_stop(conference_obj_t * conference, char *path)
+static switch_status_t conference_record_stop(conference_obj_t *conference, char *path)
 {
 	conference_member_t *member = NULL;
 	int count = 0;
@@ -502,11 +504,12 @@
 }
 
 /* Add a custom relationship to a member */
-static conference_relationship_t *member_add_relationship(conference_member_t * member, uint32_t id)
+static conference_relationship_t *member_add_relationship(conference_member_t *member, uint32_t id)
 {
 	conference_relationship_t *rel = NULL;
 
-	if (member == NULL || id == 0 || !(rel = switch_core_alloc(member->pool, sizeof(*rel)))) return NULL;
+	if (member == NULL || id == 0 || !(rel = switch_core_alloc(member->pool, sizeof(*rel))))
+		return NULL;
 
 	rel->id = id;
 
@@ -519,12 +522,13 @@
 }
 
 /* Remove a custom relationship from a member */
-static switch_status_t member_del_relationship(conference_member_t * member, uint32_t id)
+static switch_status_t member_del_relationship(conference_member_t *member, uint32_t id)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	conference_relationship_t *rel, *last = NULL;
 
-	if (member == NULL || id == 0) return status;
+	if (member == NULL || id == 0)
+		return status;
 
 	switch_mutex_lock(member->flag_mutex);
 	for (rel = member->relationships; rel; rel = rel->next) {
@@ -546,11 +550,11 @@
 }
 
 /* Gain exclusive access and add the member to the list */
-static switch_status_t conference_add_member(conference_obj_t * conference, conference_member_t * member)
+static switch_status_t conference_add_member(conference_obj_t *conference, conference_member_t *member)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_event_t *event;
-	char msg[512];					/* conference count anouncement */
+	char msg[512];				/* conference count anouncement */
 	call_list_t *call_list = NULL;
 	switch_channel_t *channel;
 
@@ -600,7 +604,7 @@
 
 		channel = switch_core_session_get_channel(member->session);
 		call_list = (call_list_t *) switch_channel_get_private(channel, "_conference_autocall_list_");
-			
+
 		if (call_list) {
 			char saymsg[1024];
 			switch_snprintf(saymsg, sizeof(saymsg), "Auto Calling %d parties", call_list->itteration);
@@ -613,13 +617,14 @@
 					conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
 				} else if (conference->count == 1 && !conference->perpetual_sound) {
 					if (conference->alone_sound) {
-						conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+						conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session),
+											 0);
 					} else {
 						switch_snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
 						conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
 					}
 				}
-			} 
+			}
 		}
 
 		if (conference->count == 1) {
@@ -650,7 +655,7 @@
 }
 
 /* Gain exclusive access and remove the member from the list */
-static switch_status_t conference_del_member(conference_obj_t * conference, conference_member_t * member)
+static switch_status_t conference_del_member(conference_obj_t *conference, conference_member_t *member)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	conference_member_t *imember, *last = NULL;
@@ -712,7 +717,7 @@
 	}
 
 	member->conference = NULL;
-	
+
 	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
 		conference->count--;
 		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
@@ -773,7 +778,7 @@
 	switch_frame_t *vid_frame;
 	switch_status_t status;
 	int has_vid = 1, req_iframe = 0;
-	
+
 	conference->video_running = 1;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Video thread started for conference %s\n", conference->name);
 
@@ -781,17 +786,17 @@
 		if (!conference->floor_holder) {
 			switch_yield(100000);
 			continue;
-		} 
-		
+		}
+
 		if (switch_channel_test_flag(switch_core_session_get_channel(conference->floor_holder->session), CF_VIDEO)) {
 			status = switch_core_session_read_video_frame(conference->floor_holder->session, &vid_frame, SWITCH_IO_FLAG_NONE, 0);
-			
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				conference->floor_holder = NULL;
 				req_iframe = 0;
 				continue;
 			}
-			
+
 			if (switch_test_flag(vid_frame, SFF_CNG)) {
 				continue;
 			}
@@ -810,18 +815,18 @@
 					req_iframe = 1;
 				}
 #endif
-		
-				if (vid_frame->codec->implementation->ianacode == 34) { /* h.263 */
-					iframe = (*((int16_t*)vid_frame->data) >> 12 == 6);
-				} else if (vid_frame->codec->implementation->ianacode == 115) { /* h.263-1998 */
-					int y = *((int8_t*)vid_frame->data + 2) & 0xfe;
-					iframe = (y == 0x80 || y == 0x82);					
-				} else if (vid_frame->codec->implementation->ianacode == 99) { /* h.264 */
-					iframe = (*((int16_t*)vid_frame->data) >> 5 == 0x11);
-				} else { /* we need more defs */
+
+				if (vid_frame->codec->implementation->ianacode == 34) {	/* h.263 */
+					iframe = (*((int16_t *) vid_frame->data) >> 12 == 6);
+				} else if (vid_frame->codec->implementation->ianacode == 115) {	/* h.263-1998 */
+					int y = *((int8_t *) vid_frame->data + 2) & 0xfe;
+					iframe = (y == 0x80 || y == 0x82);
+				} else if (vid_frame->codec->implementation->ianacode == 99) {	/* h.264 */
+					iframe = (*((int16_t *) vid_frame->data) >> 5 == 0x11);
+				} else {		/* we need more defs */
 					iframe = 1;
 				}
-				
+
 				if (!iframe) {
 					continue;
 				}
@@ -830,8 +835,8 @@
 			}
 
 			last_member = conference->floor_holder;
-			
-			switch_mutex_lock(conference->member_mutex);	
+
+			switch_mutex_lock(conference->member_mutex);
 			has_vid = 0;
 			for (imember = conference->members; imember; imember = imember->next) {
 				if (switch_channel_test_flag(switch_core_session_get_channel(imember->session), CF_VIDEO)) {
@@ -849,7 +854,7 @@
 }
 
 /* Main monitor thread (1 per distinct conference room) */
-static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *obj)
 {
 	conference_obj_t *conference = (conference_obj_t *) obj;
 	conference_member_t *imember, *omember;
@@ -860,7 +865,7 @@
 	switch_event_t *event;
 	uint8_t *file_frame;
 	uint8_t *async_file_frame;
-	
+
 	file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
 	async_file_frame = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
 
@@ -879,7 +884,7 @@
 		switch_size_t file_sample_len = samples;
 		switch_size_t file_data_len = samples * 2;
 		int has_file_data = 0, members_with_video = 0;
-		
+
 		if (conference->perpetual_sound && !conference->async_fnode) {
 			conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
 		} else if (conference->moh_sound && conference->count == 1 && !conference->async_fnode) {
@@ -891,7 +896,7 @@
 			switch_set_flag(conference, CFLAG_DESTRUCT);
 			break;
 		}
-		
+
 		switch_mutex_lock(conference->mutex);
 		has_file_data = ready = total = 0;
 
@@ -908,11 +913,11 @@
 			switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
 			switch_mutex_lock(imember->audio_in_mutex);
 
-			if (switch_buffer_inuse(imember->audio_buffer) >= bytes 
-                && (buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, bytes))) {
-                imember->read = buf_read;
-                switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
-                ready++;
+			if (switch_buffer_inuse(imember->audio_buffer) >= bytes
+				&& (buf_read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, bytes))) {
+				imember->read = buf_read;
+				switch_set_flag_locked(imember, MFLAG_HAS_AUDIO);
+				ready++;
 			}
 			switch_mutex_unlock(imember->audio_in_mutex);
 		}
@@ -940,15 +945,15 @@
 				} else if (conference->fnode->type == NODE_TYPE_FILE) {
 					switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len);
 				}
-				
+
 				if (file_sample_len <= 0) {
 					conference->fnode->done++;
 				} else {
 					has_file_data = 1;
 				}
-			}			
+			}
 		}
-		
+
 		if (conference->async_fnode) {
 			/* Lead in time */
 			if (conference->async_fnode->leadin) {
@@ -984,25 +989,25 @@
 		if (ready || has_file_data) {
 			//int nt = 0;
 			/* Build a muxed frame for every member that contains the mixed audio of everyone else */
-			
+
 			for (omember = conference->members; omember; omember = omember->next) {
 				if (has_file_data && file_sample_len) {
-                    uint32_t sample_bytes = file_sample_len * 2;
+					uint32_t sample_bytes = file_sample_len * 2;
 					memcpy(omember->mux_frame, file_frame, sample_bytes);
-                    if (sample_bytes < bytes) {
-                        if (conference->comfort_noise_level) {
-                            switch_generate_sln_silence((int16_t *)omember->mux_frame + sample_bytes, 
-                                                        (bytes - sample_bytes) / 2, conference->comfort_noise_level);
-                        } else {
-                            memset(omember->mux_frame + sample_bytes, 255, bytes - sample_bytes);
-                        }
-                    }
-                } else {
-                    if (conference->comfort_noise_level) {
-                        switch_generate_sln_silence((int16_t *)omember->mux_frame, bytes / 2, conference->comfort_noise_level);
-                    } else {
-                        memset(omember->mux_frame, 255, bytes);
-                    }
+					if (sample_bytes < bytes) {
+						if (conference->comfort_noise_level) {
+							switch_generate_sln_silence((int16_t *) omember->mux_frame + sample_bytes,
+														(bytes - sample_bytes) / 2, conference->comfort_noise_level);
+						} else {
+							memset(omember->mux_frame + sample_bytes, 255, bytes - sample_bytes);
+						}
+					}
+				} else {
+					if (conference->comfort_noise_level) {
+						switch_generate_sln_silence((int16_t *) omember->mux_frame, bytes / 2, conference->comfort_noise_level);
+					} else {
+						memset(omember->mux_frame, 255, bytes);
+					}
 				}
 				for (imember = conference->members; imember; imember = imember->next) {
 					uint32_t x;
@@ -1022,7 +1027,7 @@
 								continue;
 							}
 						}
-					} 
+					}
 
 					/* If we are not supposed to hear them then don't let it happen */
 					if (imember->relationships) {
@@ -1168,7 +1173,7 @@
 
 	if (conference->video_running == 1) {
 		conference->video_running = -1;
-		while(conference->video_running) {
+		while (conference->video_running) {
 			switch_yield(1000);
 		}
 	}
@@ -1207,9 +1212,10 @@
 	return NULL;
 }
 
-static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_mute_toggle(conference_member_t *member, caller_control_action_t *action)
 {
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
 		conf_api_sub_mute(member, NULL, NULL);
@@ -1221,9 +1227,10 @@
 	}
 }
 
-static void conference_loop_fn_deafmute_toggle(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_deafmute_toggle(conference_member_t *member, caller_control_action_t *action)
 {
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
 		conf_api_sub_mute(member, NULL, NULL);
@@ -1238,12 +1245,13 @@
 	}
 }
 
-static void conference_loop_fn_energy_up(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_energy_up(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->energy_level += 200;
@@ -1264,12 +1272,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_energy_equ_conf(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_energy_equ_conf(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->energy_level = member->conference->energy_level;
@@ -1287,12 +1296,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_energy_dn(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_energy_dn(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->energy_level -= 100;
@@ -1313,12 +1323,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_talk_up(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_talk_up(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_out_level++;
@@ -1337,12 +1348,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_talk_zero(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_talk_zero(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_out_level = 0;
@@ -1360,12 +1372,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_talk_dn(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_out_level--;
@@ -1384,12 +1397,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_listen_up(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_in_level++;
@@ -1408,12 +1422,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_listen_zero(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_listen_zero(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_in_level = 0;
@@ -1431,12 +1446,13 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_volume_listen_dn(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_volume_listen_dn(conference_member_t *member, caller_control_action_t *action)
 {
 	char msg[512];
 	switch_event_t *event;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_mutex_lock(member->flag_mutex);
 	member->volume_in_level--;
@@ -1455,11 +1471,10 @@
 	conference_member_say(member, msg, 0);
 }
 
-static void conference_loop_fn_event(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action)
 {
 	switch_event_t *event;
-	if (test_eflag(member->conference, EFLAG_DTMF) &&
-		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+	if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_member_data(member, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "dtmf");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Key", "%s", action->binded_dtmf);
@@ -1467,13 +1482,13 @@
 	}
 }
 
-static void conference_loop_fn_hangup(conference_member_t * member, caller_control_action_t * action)
+static void conference_loop_fn_hangup(conference_member_t *member, caller_control_action_t *action)
 {
 	switch_clear_flag_locked(member, MFLAG_RUNNING);
 }
 
 /* marshall frames from the call leg to the conference thread for muxing to other call legs */
-static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj)
 {
 	conference_member_t *member = obj;
 	switch_channel_t *channel;
@@ -1564,23 +1579,22 @@
 						switch_event_t *event;
 						switch_set_flag_locked(member, MFLAG_TALKING);
 						switch_mutex_lock(member->conference->member_mutex);
-						if (!member->conference->floor_holder || 
-							!switch_test_flag(member->conference->floor_holder, MFLAG_TALKING) || member->score > 
+						if (!member->conference->floor_holder ||
+							!switch_test_flag(member->conference->floor_holder, MFLAG_TALKING) || member->score >
 							member->conference->floor_holder->score + 200) {
 							if (test_eflag(member->conference, EFLAG_FLOOR_CHANGE) &&
 								switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 								conference_add_event_member_data(member, event);
 								switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "floor-change");
-								switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "%d", 
+								switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-ID", "%d",
 														member->conference->floor_holder ? member->conference->floor_holder->id : 0);
-								switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "%d", 
-														member->conference->floor_holder ? member->id : 0);
+								switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "%d", member->conference->floor_holder ? member->id : 0);
 								switch_event_fire(&event);
 							}
 							member->conference->floor_holder = member;
 						}
 						switch_mutex_unlock(member->conference->member_mutex);
-						
+
 						if (test_eflag(member->conference, EFLAG_START_TALKING) &&
 							switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 							conference_add_event_member_data(member, event);
@@ -1621,11 +1635,9 @@
 				int len = (int) read_frame->datalen;
 
 				read_resampler->from_len = switch_short_to_float(bptr, read_resampler->from, (int) len / 2);
-				read_resampler->to_len = switch_resample_process(read_resampler, 
+				read_resampler->to_len = switch_resample_process(read_resampler,
 																 read_resampler->from,
-																 read_resampler->from_len, 
-																 read_resampler->to, 
-																 read_resampler->to_size, 0);
+																 read_resampler->from_len, read_resampler->to, read_resampler->to_size, 0);
 
 				switch_float_to_short(read_resampler->to, member->resample_out, read_resampler->to_len);
 				len = read_resampler->to_len * 2;
@@ -1655,12 +1667,13 @@
 }
 
 /* launch an input thread for the call leg */
-static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t *pool)
+static void launch_conference_loop_input(conference_member_t *member, switch_memory_pool_t *pool)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
-	if (member == NULL) return;
+	if (member == NULL)
+		return;
 
 	switch_threadattr_create(&thd_attr, pool);
 	switch_threadattr_detach_set(thd_attr, 1);
@@ -1689,7 +1702,7 @@
 
 /* marshall frames from the conference (or file or tts output) to the call leg */
 /* NB. this starts the input thread after some initial setup for the call leg */
-static void conference_loop_output(conference_member_t * member)
+static void conference_loop_output(conference_member_t *member)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(member->session);
 	switch_frame_t write_frame = { 0 };
@@ -1698,12 +1711,12 @@
 	switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session);
 	uint32_t interval = read_codec->implementation->microseconds_per_frame / 1000;
 	uint32_t samples = switch_samples_per_frame(member->conference->rate, interval);
-    uint32_t csamples = samples;
+	uint32_t csamples = samples;
 	uint32_t tsamples = member->orig_read_codec->implementation->samples_per_frame;
 	uint32_t flush_len = 0;
 	uint32_t low_count = 0, bytes = samples * 2;
 	call_list_t *call_list = NULL, *cp = NULL;
-    
+
 	switch_assert(member->conference != NULL);
 
 	flush_len = switch_samples_per_frame(member->conference->rate, member->conference->interval) * 10;
@@ -1770,8 +1783,8 @@
 		int use_timer = 0;
 		switch_size_t file_sample_len = csamples;
 		switch_size_t file_data_len = file_sample_len * 2;
-			
-			
+
+
 		switch_mutex_lock(member->flag_mutex);
 
 
@@ -1894,7 +1907,7 @@
 						switch_core_session_write_frame(member->session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
 						switch_core_timer_next(&timer);
 
-                            
+
 						/* forget the conference data we played file node data instead */
 						switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
 					}
@@ -1914,9 +1927,9 @@
 					/* getting behind, clear the buffer */
 					switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
 				}
-			} 
-				
-				
+			}
+
+
 			use_timer = 1;
 
 			if (mux_used) {
@@ -1962,7 +1975,7 @@
 			}
 			switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
 		}
-			
+
 		switch_mutex_unlock(member->flag_mutex);
 
 		if (use_timer) {
@@ -1971,7 +1984,7 @@
 			switch_yield(1000);
 		}
 
-	} /* Rinse ... Repeat */
+	}							/* Rinse ... Repeat */
 
 	if (member->digit_stream != NULL) {
 		switch_ivr_digit_stream_destroy(member->digit_stream);
@@ -1995,7 +2008,7 @@
 }
 
 /* Sub-Routine called by a record entity inside a conference */
-static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj)
 {
 	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	switch_file_handle_t fh = { 0 };
@@ -2029,9 +2042,9 @@
 	member->id = next_member_id();
 	member->pool = rec->pool;
 
-    member->frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
-    member->frame = switch_core_alloc(member->pool, member->frame_size);
-    member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
+	member->frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
+	member->frame = switch_core_alloc(member->pool, member->frame_size);
+	member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
 
 
 	switch_mutex_init(&member->flag_mutex, SWITCH_MUTEX_NESTED, rec->pool);
@@ -2080,7 +2093,7 @@
 	while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
 		switch_size_t len;
 		mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
-		
+
 		if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
 			if (mux_used) {
 				switch_mutex_lock(member->audio_out_mutex);
@@ -2095,7 +2108,7 @@
 			/* Flush the output buffer and write all the data (presumably muxed) to the file */
 			switch_mutex_lock(member->audio_out_mutex);
 			low_count = 0;
-			
+
 			if ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data, sizeof(data)))) {
 				if (!switch_test_flag((&fh), SWITCH_FILE_PAUSE)) {
 					len = (switch_size_t) rlen / sizeof(int16_t);
@@ -2117,9 +2130,9 @@
 		}
 
 		switch_core_timer_next(&timer);
-	} /* Rinse ... Repeat */
+	}							/* Rinse ... Repeat */
 
- end:
+  end:
 
 	switch_core_timer_destroy(&timer);
 	conference_del_member(conference, member);
@@ -2146,7 +2159,7 @@
 }
 
 /* Make files stop playing in a conference either the current one or all of them */
-static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t stop)
+static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop)
 {
 	uint32_t count = 0;
 	conference_file_node_t *nptr;
@@ -2182,12 +2195,13 @@
 }
 
 /* stop playing a file for the member of the conference */
-static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop)
+static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop)
 {
 	conference_file_node_t *nptr;
 	uint32_t count = 0;
 
-	if (member == NULL) return count;
+	if (member == NULL)
+		return count;
 
 	switch_mutex_lock(member->flag_mutex);
 
@@ -2209,7 +2223,7 @@
 }
 
 /* Play a file in the conference room */
-static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async)
+static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	conference_file_node_t *fnode, *nptr = NULL;
@@ -2225,7 +2239,8 @@
 	switch_mutex_unlock(conference->member_mutex);
 	switch_mutex_unlock(conference->mutex);
 
-	if (!count) return SWITCH_STATUS_FALSE;
+	if (!count)
+		return SWITCH_STATUS_FALSE;
 
 	if (channel) {
 		if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
@@ -2310,7 +2325,7 @@
 
 	switch_mutex_unlock(conference->mutex);
 
- done:
+  done:
 
 	switch_safe_free(expanded);
 	switch_safe_free(dfile);
@@ -2319,14 +2334,15 @@
 }
 
 /* Play a file in the conference room to a member */
-static switch_status_t conference_member_play_file(conference_member_t * member, char *file, uint32_t leadin)
+static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	char *dfile = NULL, *expanded = NULL;
 	conference_file_node_t *fnode, *nptr = NULL;
 	switch_memory_pool_t *pool;
 
-	if (member == NULL || file == NULL) return status;
+	if (member == NULL || file == NULL)
+		return status;
 
 	if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
 		file = expanded;
@@ -2384,7 +2400,7 @@
 	switch_mutex_unlock(member->flag_mutex);
 	status = SWITCH_STATUS_SUCCESS;
 
- done:
+  done:
 
 	switch_safe_free(expanded);
 	switch_safe_free(dfile);
@@ -2393,7 +2409,7 @@
 }
 
 /* Say some thing with TTS in the conference room */
-static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin)
+static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin)
 {
 	conference_obj_t *conference = (member != NULL ? member->conference : NULL);
 	conference_file_node_t *fnode, *nptr;
@@ -2401,7 +2417,8 @@
 	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
-	if (member == NULL || switch_strlen_zero(text)) return SWITCH_STATUS_FALSE;
+	if (member == NULL || switch_strlen_zero(text))
+		return SWITCH_STATUS_FALSE;
 
 	switch_assert(conference != NULL);
 
@@ -2428,7 +2445,7 @@
 
 	if (!member->sh) {
 		memset(&member->lsh, 0, sizeof(member->lsh));
-		if (switch_core_speech_open(&member->lsh, conference->tts_engine, conference->tts_voice, 
+		if (switch_core_speech_open(&member->lsh, conference->tts_engine, conference->tts_voice,
 									conference->rate, conference->interval, &flags, switch_core_session_get_pool(member->session)) !=
 			SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
@@ -2452,7 +2469,7 @@
 	switch_sleep(200000);
 
 	if (*text == '#') {
-		char *tmp = (char *)text + 1;
+		char *tmp = (char *) text + 1;
 		char *vp = tmp, voice[128] = "";
 		if ((tmp = strchr(tmp, '#'))) {
 			text = tmp + 1;
@@ -2472,7 +2489,7 @@
 }
 
 /* Say some thing with TTS in the conference room */
-static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin)
+static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	conference_file_node_t *fnode, *nptr;
@@ -2514,12 +2531,11 @@
 
 	fnode->type = NODE_TYPE_SPEECH;
 	fnode->leadin = leadin;
-	
+
 	if (!conference->sh) {
 		memset(&conference->lsh, 0, sizeof(conference->lsh));
-		if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice, 
-									conference->rate, conference->interval, &flags, conference->pool) !=
-			SWITCH_STATUS_SUCCESS) {
+		if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice,
+									conference->rate, conference->interval, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
 			return SWITCH_STATUS_FALSE;
 		}
@@ -2540,7 +2556,7 @@
 
 	fnode->sh = conference->sh;
 	if (*text == '#') {
-		char *tmp = (char *)text + 1;
+		char *tmp = (char *) text + 1;
 		char *vp = tmp, voice[128] = "";
 		if ((tmp = strchr(tmp, '#'))) {
 			text = tmp + 1;
@@ -2562,7 +2578,7 @@
 }
 
 /* execute a callback for every member of the conference */
-static void conference_member_itterator(conference_obj_t * conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data)
+static void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, conf_api_member_cmd_t pfncallback, void *data)
 {
 	conference_member_t *member = NULL;
 
@@ -2578,7 +2594,7 @@
 
 }
 
-static void conference_list_pretty(conference_obj_t * conference, switch_stream_handle_t *stream)
+static void conference_list_pretty(conference_obj_t *conference, switch_stream_handle_t *stream)
 {
 	conference_member_t *member = NULL;
 
@@ -2603,7 +2619,7 @@
 	switch_mutex_unlock(conference->member_mutex);
 }
 
-static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim)
+static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim)
 {
 	conference_member_t *member = NULL;
 
@@ -2663,11 +2679,12 @@
 	switch_mutex_unlock(conference->member_mutex);
 }
 
-static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL)  return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
 	if (member->conference->muted_sound) {
@@ -2691,11 +2708,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
 	if (stream != NULL) {
@@ -2719,11 +2737,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
 	if (stream != NULL) {
@@ -2738,11 +2757,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
-	
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	switch_set_flag_locked(member, MFLAG_CAN_HEAR);
 	if (stream != NULL) {
@@ -2757,11 +2777,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_kick(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_kick(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	switch_mutex_lock(member->flag_mutex);
 	switch_clear_flag(member, MFLAG_RUNNING);
@@ -2781,11 +2802,11 @@
 }
 
 
-static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_dtmf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 	char *dtmf = (char *) data;
-	
+
 	if (member == NULL) {
 		stream->write_function(stream, "Invalid member!\n");
 		return SWITCH_STATUS_GENERR;
@@ -2798,7 +2819,7 @@
 
 	switch_mutex_lock(member->flag_mutex);
 	switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
-	switch_core_session_send_dtmf_string(member->session, (char *)data);
+	switch_core_session_send_dtmf_string(member->session, (char *) data);
 	switch_mutex_unlock(member->flag_mutex);
 
 	if (stream != NULL) {
@@ -2816,11 +2837,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_energy(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_energy(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	if (data) {
 		switch_mutex_lock(member->flag_mutex);
@@ -2831,21 +2853,22 @@
 		stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
 	}
 	if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL_MEMBER) &&
-		data && switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		data && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_member_data(member, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
-		switch_event_fire(& event);
+		switch_event_fire(&event);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_volume_in(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_volume_in(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	if (data) {
 		switch_mutex_lock(member->flag_mutex);
@@ -2857,21 +2880,22 @@
 		stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
 	}
 	if (test_eflag(member->conference, EFLAG_VOLUME_IN_MEMBER) &&
-		data && switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		data && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_member_data(member, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level);
-		switch_event_fire(& event);
+		switch_event_fire(&event);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_volume_out(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+static switch_status_t conf_api_sub_volume_out(conference_member_t *member, switch_stream_handle_t *stream, void *data)
 {
 	switch_event_t *event;
 
-	if (member == NULL) return SWITCH_STATUS_GENERR;
+	if (member == NULL)
+		return SWITCH_STATUS_GENERR;
 
 	if (data) {
 		switch_mutex_lock(member->flag_mutex);
@@ -2883,17 +2907,17 @@
 		stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
 	}
 	if (test_eflag(member->conference, EFLAG_VOLUME_OUT_MEMBER) && data &&
-		switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_member_data(member, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level);
-		switch_event_fire(& event);
+		switch_event_fire(&event);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	int ret_status = SWITCH_STATUS_GENERR;
 	int count = 0;
@@ -2955,7 +2979,7 @@
 	return ret_status;
 }
 
-static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	int ret_status = SWITCH_STATUS_GENERR;
 	switch_event_t *event;
@@ -3009,7 +3033,7 @@
 	return ret_status;
 }
 
-static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
+static switch_status_t conf_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
 {
 	switch_event_t *event;
 
@@ -3024,8 +3048,7 @@
 	}
 
 	stream->write_function(stream, "(say) OK\n");
-	if (test_eflag(conference, EFLAG_SPEAK_TEXT) &&
-		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+	if (test_eflag(conference, EFLAG_SPEAK_TEXT) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_data(conference, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
@@ -3034,7 +3057,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
+static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
 {
 	int ret_status = SWITCH_STATUS_GENERR;
 	char *expanded = NULL;
@@ -3077,10 +3100,10 @@
 		expanded = NULL;
 	}
 
-	if (!text || conference_member_say(member, (char*)text, 0) != SWITCH_STATUS_SUCCESS) {
+	if (!text || conference_member_say(member, (char *) text, 0) != SWITCH_STATUS_SUCCESS) {
 		stream->write_function(stream, "(saymember) Error!");
 		goto done;
-	} 
+	}
 
 	stream->write_function(stream, "(saymember) OK\n");
 	if (test_eflag(member->conference, EFLAG_SPEAK_TEXT_MEMBER) &&
@@ -3092,13 +3115,13 @@
 	}
 	ret_status = SWITCH_STATUS_SUCCESS;
 
- done:
+  done:
 	switch_safe_free(workspace);
 	switch_safe_free(expanded);
 	return ret_status;
 }
 
-static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_stop(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	uint8_t current = 0, all = 0;
 
@@ -3112,7 +3135,8 @@
 		all = 1;
 	}
 
-	if (!(current || all)) return SWITCH_STATUS_GENERR;
+	if (!(current || all))
+		return SWITCH_STATUS_GENERR;
 
 	if (argc == 4) {
 		uint32_t id = atoi(argv[3]);
@@ -3131,14 +3155,15 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	uint8_t nospeak = 0, nohear = 0, clear = 0;
 
 	switch_assert(conference != NULL);
 	switch_assert(stream != NULL);
 
-	if (argc <= 4) return SWITCH_STATUS_GENERR;
+	if (argc <= 4)
+		return SWITCH_STATUS_GENERR;
 
 	nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
 	nohear = strstr(argv[4], "nohear") ? 1 : 0;
@@ -3150,7 +3175,7 @@
 	if (!(clear || nospeak || nohear)) {
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	if (clear) {
 		conference_member_t *member = NULL;
 		uint32_t id = atoi(argv[2]);
@@ -3163,8 +3188,8 @@
 			stream->write_function(stream, "relationship %u->%u not found", id, oid);
 		}
 		return SWITCH_STATUS_SUCCESS;
-	} 
-	
+	}
+
 	if (nospeak || nohear) {
 		conference_member_t *member = NULL, *other_member = NULL;
 		uint32_t id = atoi(argv[2]);
@@ -3199,7 +3224,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_lock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_event_t *event;
 
@@ -3212,8 +3237,7 @@
 
 	switch_set_flag_locked(conference, CFLAG_LOCKED);
 	stream->write_function(stream, "OK %s locked\n", argv[0]);
-	if (test_eflag(conference, EFLAG_LOCK) &&
-		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+	if (test_eflag(conference, EFLAG_LOCK) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_data(conference, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
 		switch_event_fire(&event);
@@ -3222,7 +3246,7 @@
 	return 0;
 }
 
-static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_unlock(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_event_t *event;
 
@@ -3235,8 +3259,7 @@
 
 	switch_clear_flag_locked(conference, CFLAG_LOCKED);
 	stream->write_function(stream, "OK %s unlocked\n", argv[0]);
-	if (test_eflag(conference, EFLAG_UNLOCK) &&
-		switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+	if (test_eflag(conference, EFLAG_UNLOCK) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 		conference_add_event_data(conference, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
 		switch_event_fire(&event);
@@ -3245,7 +3268,7 @@
 	return 0;
 }
 
-static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_call_cause_t cause;
 
@@ -3267,7 +3290,7 @@
 }
 
 
-static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_assert(stream != NULL);
 
@@ -3285,7 +3308,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 	char *conf_name = NULL, *profile_name;
@@ -3303,7 +3326,7 @@
 		} else {
 			profile_name = "default";
 		}
-		
+
 		for (x = 3; x < argc; x++) {
 			conference_member_t *member = NULL;
 			uint32_t id = atoi(argv[x]);
@@ -3393,7 +3416,7 @@
 			switch_mutex_unlock(new_conference->mutex);
 			switch_mutex_unlock(member->flag_mutex);
 			stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
-			
+
 			/* tell them what happened */
 			if (test_eflag(conference, EFLAG_TRANSFER) &&
 				switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
@@ -3408,7 +3431,7 @@
 		ret_status = SWITCH_STATUS_GENERR;
 	}
 
- done:
+  done:
 	if (params) {
 		switch_event_destroy(&params);
 	}
@@ -3416,26 +3439,28 @@
 	return ret_status;
 }
 
-static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_assert(conference != NULL);
 	switch_assert(stream != NULL);
 
-	if (argc <= 2) return SWITCH_STATUS_GENERR;
+	if (argc <= 2)
+		return SWITCH_STATUS_GENERR;
 
 	stream->write_function(stream, "Record file %s\n", argv[2]);
 	launch_conference_record_thread(conference, argv[2]);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_norecord(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	int all;
 
 	switch_assert(conference != NULL);
 	switch_assert(stream != NULL);
 
-	if (argc <= 2) return SWITCH_STATUS_GENERR;
+	if (argc <= 2)
+		return SWITCH_STATUS_GENERR;
 
 	all = (strcasecmp(argv[2], "all") == 0);
 	stream->write_function(stream, "Stop recording file %s\n", argv[2]);
@@ -3446,7 +3471,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_api_sub_pin(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+static switch_status_t conf_api_sub_pin(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	switch_assert(conference != NULL);
 	switch_assert(stream != NULL);
@@ -3493,47 +3518,47 @@
 /* API Interface Function sub-commands */
 /* Entries in this list should be kept in sync with the enum above */
 static api_command_t conf_api_sub_commands[] = {
-	{"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
-	{"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
+	{"list", (void_fn_t) &conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
+	{"energy", (void_fn_t) &conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> energy <member_id|all|last> [<newval>]"},
-	{"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
+	{"volume_in", (void_fn_t) &conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> volume_in <member_id|all|last> [<newval>]"},
-	{"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
+	{"volume_out", (void_fn_t) &conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> volume_out <member_id|all|last> [<newval>]"},
-	{"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [<member_id>]"},
-	{"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
-	{"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
+	{"play", (void_fn_t) &conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [<member_id>]"},
+	{"say", (void_fn_t) &conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
+	{"saymember", (void_fn_t) &conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
 	 "<confname> saymember <member_id> <text>"},
-	{"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
+	{"stop", (void_fn_t) &conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
 	 "<confname> stop <[current|all|last]> [<member_id>]"},
-	{"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
+	{"dtmf", (void_fn_t) &conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> dtmf <[member_id|all|last]> <digits>"},
-	{"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
-	{"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
-	{"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
+	{"kick", (void_fn_t) &conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
+	{"mute", (void_fn_t) &conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
+	{"unmute", (void_fn_t) &conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> unmute <[member_id|all]|last>"},
-	{"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
-	{"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
+	{"deaf", (void_fn_t) &conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
+	{"undeaf", (void_fn_t) &conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
 	 "<confname> undeaf <[member_id|all]|last>"},
-	{"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
+	{"relate", (void_fn_t) &conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
 	 "<confname> relate <member_id> <other_member_id> [nospeak|nohear|clear]"},
-	{"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
-	{"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
-	{"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
+	{"lock", (void_fn_t) &conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
+	{"unlock", (void_fn_t) &conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
+	{"dial", (void_fn_t) &conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
 	 "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
-	{"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
+	{"bgdial", (void_fn_t) &conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
 	 "<confname> bgdial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
-	{"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
+	{"transfer", (void_fn_t) &conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
 	 "<confname> transfer <conference_name> <member id> [...<member id>]"},
-	{"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
-	{"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
-	{"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> pin <pin#>"},
-	{"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> nopin"},
+	{"record", (void_fn_t) &conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
+	{"norecord", (void_fn_t) &conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
+	{"pin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> pin <pin#>"},
+	{"nopin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> nopin"},
 };
 
 #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
 
-switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
+switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	uint32_t i, found = 0;
@@ -3719,7 +3744,7 @@
 		stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n");
 	}
 
- done:
+  done:
 	switch_safe_free(lbuf);
 
 	return status;
@@ -3727,7 +3752,7 @@
 }
 
 /* generate an outbound call from the conference */
-static switch_status_t conference_outcall(conference_obj_t * conference,
+static switch_status_t conference_outcall(conference_obj_t *conference,
 										  char *conference_name,
 										  switch_core_session_t *session,
 										  char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
@@ -3776,21 +3801,19 @@
 	}
 
 	/* establish an outbound call leg */
-		
-	if (switch_ivr_originate(session,
-							 &peer_session, cause, bridgeto, timeout, NULL,  cid_name, cid_num,
-							 NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+
+	if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause));
 		if (caller_channel) {
 			switch_channel_hangup(caller_channel, *cause);
 		}
 		goto done;
 	}
-	
+
 	rdlock = 1;
 	peer_channel = switch_core_session_get_channel(peer_session);
 	switch_channel_set_state(peer_channel, CS_SOFT_EXECUTE);
-	
+
 	/* make sure the conference still exists */
 	if (!switch_test_flag(conference, CFLAG_RUNNING)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference is gone now, nevermind..\n");
@@ -3805,7 +3828,7 @@
 		switch_channel_answer(caller_channel);
 	}
 
- callup:
+  callup:
 
 	/* if the outbound call leg is ready */
 	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
@@ -3834,7 +3857,7 @@
 		goto done;
 	}
 
- done:
+  done:
 	if (conference) {
 		switch_thread_rwlock_unlock(conference->rwlock);
 	}
@@ -3856,7 +3879,7 @@
 	char *conference_name;
 };
 
-static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, void *obj)
 {
 	struct bg_call *call = (struct bg_call *) obj;
 
@@ -3864,7 +3887,7 @@
 		switch_call_cause_t cause;
 		switch_event_t *event;
 
-		conference_outcall(call->conference, call->conference_name, 
+		conference_outcall(call->conference, call->conference_name,
 						   call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
 
 		if (test_eflag(call->conference, EFLAG_BGDIAL_RESULT) &&
@@ -3885,15 +3908,17 @@
 	return NULL;
 }
 
-static switch_status_t conference_outcall_bg(conference_obj_t * conference,
+static switch_status_t conference_outcall_bg(conference_obj_t *conference,
 											 char *conference_name,
-											 switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, const char *cid_num)
+											 switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
+											 const char *cid_num)
 {
 	struct bg_call *call = NULL;
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
-	if (!(call = malloc(sizeof(*call)))) return SWITCH_STATUS_MEMERR;
+	if (!(call = malloc(sizeof(*call))))
+		return SWITCH_STATUS_MEMERR;
 
 	memset(call, 0, sizeof(*call));
 	call->conference = conference;
@@ -3927,8 +3952,7 @@
 }
 
 /* Play a file */
-static switch_status_t conference_local_play_file(conference_obj_t * conference,
-												  switch_core_session_t *session, char *path, uint32_t leadin)
+static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin)
 {
 	uint32_t x = 0;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -3948,7 +3972,7 @@
 	/* if all is well, really play the file */
 	if (status == SWITCH_STATUS_SUCCESS) {
 		char *dpath = NULL;
-	
+
 		channel = switch_core_session_get_channel(session);
 		if ((expanded = switch_channel_expand_variables(channel, path)) != path) {
 			path = expanded;
@@ -3977,13 +4001,13 @@
 		switch_safe_free(dpath);
 	}
 
- done:
+  done:
 	switch_safe_free(expanded);
-	
+
 	return status;
 }
 
-static void set_mflags(char *flags, member_flag_t * f)
+static void set_mflags(char *flags, member_flag_t *f)
 {
 	if (flags) {
 		if (strstr(flags, "mute")) {
@@ -3999,11 +4023,11 @@
 
 }
 
-static void clear_eflags(char *events, uint32_t * f)
+static void clear_eflags(char *events, uint32_t *f)
 {
 	char buf[512] = "";
-	char* next = NULL;
-	char* event = buf;
+	char *next = NULL;
+	char *event = buf;
 
 	if (events) {
 		switch_copy_string(buf, events, sizeof(buf));
@@ -4122,7 +4146,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Channel has no media!\n");
 		return;
 	}
-	
+
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
@@ -4176,7 +4200,7 @@
 	if (0) {
 		member.dtmf_parser = conference->dtmf_parser;
 	} else {
-		
+
 	}
 #endif
 
@@ -4245,7 +4269,7 @@
 		if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
 			/* couldn't find the conference, create one */
 			conference = conference_new(conf_name, xml_cfg, NULL);
-			
+
 			if (!conference) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 				goto done;
@@ -4317,7 +4341,7 @@
 				goto done;
 			}
 		}
-		
+
 		if (conference->special_announce) {
 			conference_local_play_file(conference, session, conference->special_announce, CONF_DEFAULT_LEADIN);
 		}
@@ -4367,7 +4391,7 @@
 		if (!switch_channel_test_flag(channel, CF_OUTBOUND))
 			switch_set_flag(conference, CFLAG_ANSWERED);
 	}
-	
+
 	member.orig_read_codec = read_codec;
 	member.native_rate = read_codec->implementation->samples_per_second;
 	member.pool = switch_core_session_get_pool(session);
@@ -4375,9 +4399,7 @@
 	/* Setup a Signed Linear codec for reading audio. */
 	if (switch_core_codec_init(&member.read_codec,
 							   "L16",
-							   NULL,
-							   read_codec->implementation->actual_samples_per_second,
-							   read_codec->implementation->microseconds_per_frame / 1000,
+							   NULL, read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000,
 							   //conference->interval,
 							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
@@ -4387,30 +4409,27 @@
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
 						  read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
-                          
+
 		flags = 0;
 		goto done;
 	}
 
-    member.frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
-    member.frame = switch_core_alloc(member.pool, member.frame_size);
-    member.mux_frame = switch_core_alloc(member.pool, member.frame_size);
-    
+	member.frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
+	member.frame = switch_core_alloc(member.pool, member.frame_size);
+	member.mux_frame = switch_core_alloc(member.pool, member.frame_size);
+
 	if (read_codec->implementation->actual_samples_per_second != conference->rate) {
 		if (switch_resample_create(&member.read_resampler,
 								   read_codec->implementation->actual_samples_per_second,
-								   member.frame_size,
-								   conference->rate,
-                                   member.frame_size,
-								   member.pool) != SWITCH_STATUS_SUCCESS) {
+								   member.frame_size, conference->rate, member.frame_size, member.pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
 			goto done;
 		}
 
 
-        member.resample_out = switch_core_alloc(member.pool, member.frame_size);
-        member.resample_out_len = member.frame_size;
-        
+		member.resample_out = switch_core_alloc(member.pool, member.frame_size);
+		member.resample_out_len = member.frame_size;
+
 		/* Setup an audio buffer for the resampled audio */
 		if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX)
 			!= SWITCH_STATUS_SUCCESS) {
@@ -4478,7 +4497,7 @@
 	/* Run the confernece loop */
 	conference_loop_output(&member);
 	switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
-	
+
 	/* Tell the channel we are no longer going to be in a bridge */
 	msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
 	switch_core_session_receive_message(session, &msg);
@@ -4490,11 +4509,11 @@
 	switch_core_session_set_read_codec(member.session, read_codec);
 
 	/* Clean Up.  codec_done(X): is for error situations after the codecs were setup and done: is for situations before */
- codec_done1:
+  codec_done1:
 	switch_core_codec_destroy(&member.read_codec);
- codec_done2:
+  codec_done2:
 	switch_core_codec_destroy(&member.write_codec);
- done:
+  done:
 	switch_event_destroy(&params);
 	switch_buffer_destroy(&member.resample_buffer);
 	switch_buffer_destroy(&member.audio_buffer);
@@ -4521,7 +4540,7 @@
 		char *dfile = NULL;
 
 		if (conference->sound_prefix) {
-			dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR,  conference->kicked_sound);
+			dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, conference->kicked_sound);
 			switch_assert(dfile);
 			toplay = dfile;
 		} else {
@@ -4541,7 +4560,7 @@
 }
 
 /* Create a thread for the conference and launch it */
-static void launch_conference_thread(conference_obj_t * conference)
+static void launch_conference_thread(conference_obj_t *conference)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
@@ -4569,7 +4588,7 @@
 	switch_thread_create(&thread, thd_attr, conference_video_thread_run, conference, conference->pool);
 }
 
-static void launch_conference_record_thread(conference_obj_t * conference, char *path)
+static void launch_conference_record_thread(conference_obj_t *conference, char *path)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
@@ -4624,7 +4643,7 @@
 	} else {
 		switch_copy_string(name, to, sizeof(name));
 	}
-	
+
 
 	if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) {
 		ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL);
@@ -4638,8 +4657,7 @@
 		if (switch_stristr("list", lbuf)) {
 			conference_list_pretty(conference, &stream);
 			/* provide help */
-		}
-		else {
+		} else {
 			return SWITCH_STATUS_SUCCESS;
 		}
 #if 0
@@ -4660,7 +4678,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t conf_default_controls(conference_obj_t * conference)
+static switch_status_t conf_default_controls(conference_obj_t *conference)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	uint32_t i;
@@ -4688,7 +4706,7 @@
 	return status;
 }
 
-static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t * conference, switch_xml_t xml_controls, switch_xml_t xml_menus)
+static switch_status_t conference_new_install_caller_controls_custom(conference_obj_t *conference, switch_xml_t xml_controls, switch_xml_t xml_menus)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_xml_t xml_kvp;
@@ -4778,7 +4796,7 @@
 	char *maxmember_sound = NULL;
 	uint32_t rate = 8000, interval = 20;
 	switch_status_t status;
-    int comfort_noise_level = 0;
+	int comfort_noise_level = 0;
 	char *suppress_events = NULL;
 
 	/* Validate the conference name */
@@ -4805,10 +4823,10 @@
 		}
 
 		if (!strcasecmp(var, "rate") && !switch_strlen_zero(val)) {
-            uint32_t tmp = atoi(val);
-            if (tmp == 8000 || tmp == 16000 || tmp == 32000) {
-                rate = tmp;
-            }
+			uint32_t tmp = atoi(val);
+			if (tmp == 8000 || tmp == 16000 || tmp == 32000) {
+				rate = tmp;
+			}
 		} else if (!strcasecmp(var, "domain") && !switch_strlen_zero(val)) {
 			domain = val;
 		} else if (!strcasecmp(var, "interval") && !switch_strlen_zero(val)) {
@@ -4817,7 +4835,7 @@
 				interval = tmp;
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-								  "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
+								  "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
 			}
 		} else if (!strcasecmp(var, "timer-name") && !switch_strlen_zero(val)) {
 			timer_name = val;
@@ -4868,13 +4886,13 @@
 		} else if (!strcasecmp(var, "caller-controls") && !switch_strlen_zero(val)) {
 			caller_controls = val;
 		} else if (!strcasecmp(var, "comfort-noise") && !switch_strlen_zero(val)) {
-            int tmp;
-            tmp = atoi(val);
-            if (tmp > 1 && tmp < 10000) {
-                comfort_noise_level = tmp;
-            } else if (switch_true(val)) {
-                comfort_noise_level = 1400;
-            }
+			int tmp;
+			tmp = atoi(val);
+			if (tmp > 1 && tmp < 10000) {
+				comfort_noise_level = tmp;
+			} else if (switch_true(val)) {
+				comfort_noise_level = 1400;
+			}
 		} else if (!strcasecmp(var, "sound-prefix") && !switch_strlen_zero(val)) {
 			sound_prefix = val;
 		} else if (!strcasecmp(var, "max-members") && !switch_strlen_zero(val)) {
@@ -4897,7 +4915,7 @@
 			}
 		} else if (!strcasecmp(var, "suppress-events") && !switch_strlen_zero(val)) {
 			suppress_events = val;
-        }
+		}
 	}
 
 	/* Set defaults and various paramaters */
@@ -4946,7 +4964,7 @@
 		conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
 	}
 
-    conference->comfort_noise_level = comfort_noise_level;
+	conference->comfort_noise_level = comfort_noise_level;
 	conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
 	conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
 
@@ -5140,11 +5158,11 @@
 {
 	switch_xml_t cxml, cfg, advertise, room;
 	switch_event_t *params = NULL;
-	
+
 	switch_event_create(&params, SWITCH_EVENT_MESSAGE);
 	switch_assert(params);
 	switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "presence", "true");
-	
+
 
 	/* Open the config from the xml registry */
 	if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
@@ -5170,7 +5188,7 @@
 		}
 	}
 
- done:
+  done:
 	switch_event_destroy(&params);
 
 	/* Release the config registry handle */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_dptools/mod_dptools.c	Tue May 27 07:24:06 2008
@@ -49,7 +49,7 @@
 
 	if (!caller_profile) {
 		caller_profile = switch_channel_get_caller_profile(channel);
-	}	
+	}
 
 	if ((extension = switch_caller_extension_new(session, "inline", "inline")) == 0) {
 		abort();
@@ -58,26 +58,26 @@
 	if (switch_strlen_zero(target)) {
 		target = caller_profile->destination_number;
 	}
-	
+
 	if (!switch_strlen_zero(target) && (lbuf = switch_core_session_strdup(session, target))
 		&& (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 	} else {
 		return NULL;
 	}
 
-	
-	for(x = 0; x < argc; x++) {
+
+	for (x = 0; x < argc; x++) {
 		char *app = argv[x];
 		char *data = strchr(app, ':');
 
 		if (data) {
 			*data++ = '\0';
 		}
-		
-		while(*app == ' ') {
+
+		while (*app == ' ') {
 			app++;
 		}
-		
+
 		switch_caller_extension_add_application(session, extension, app, data);
 	}
 
@@ -119,7 +119,7 @@
 	char *argv[4] = { 0 };
 	int argc;
 	char *lbuf = NULL;
-	
+
 	if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		switch_core_session_execute_exten(session, argv[0], argv[1], argv[2]);
@@ -135,13 +135,13 @@
 	char *argv[4] = { 0 };
 	int argc;
 	char *lbuf = NULL;
-	
+
 	if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
 		switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], NULL);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX);
-	}	
+	}
 
 }
 
@@ -151,7 +151,7 @@
 	char *argv[3] = { 0 };
 	int argc;
 	char *lbuf = NULL;
-	
+
 	if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
 		switch_ivr_soft_hold(session, argv[0], argv[1], argv[2]);
@@ -166,7 +166,7 @@
 	char *argv[4] = { 0 };
 	int argc;
 	char *lbuf = NULL;
-	
+
 	if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
 		int kval = atoi(argv[0]);
@@ -239,7 +239,7 @@
 			} else {
 				uuid = argv[0];
 			}
-			
+
 			switch_ivr_intercept_session(session, uuid, bleg);
 		}
 		return;
@@ -275,10 +275,10 @@
 	} else {
 		switch_channel_t *channel = switch_core_session_get_channel(session);
 		const char *require_group = switch_channel_get_variable(channel, "eavesdrop_require_group");
-		if (!strcasecmp((char *)data, "all")) {
+		if (!strcasecmp((char *) data, "all")) {
 			switch_core_db_t *db = switch_core_db_handle();
 			char *errmsg = NULL;
-			struct e_data e_data = {{ 0 }};
+			struct e_data e_data = { {0} };
 			char *sql = switch_mprintf("select uuid from channels where uuid != '%q'", switch_core_session_get_uuid(session));
 			const char *file = NULL;
 			int x = 0;
@@ -286,9 +286,9 @@
 			switch_size_t buflen = sizeof(buf);
 			char terminator;
 			switch_status_t status;
-			
-			while(switch_channel_ready(channel)) {
-				for(x = 0; x < MAX_SPY; x++) {
+
+			while (switch_channel_ready(channel)) {
+				for (x = 0; x < MAX_SPY; x++) {
 					switch_safe_free(e_data.uuid_list[x]);
 				}
 				e_data.total = 0;
@@ -326,12 +326,12 @@
 				}
 			}
 
-			for(x = 0; x < MAX_SPY; x++) {
+			for (x = 0; x < MAX_SPY; x++) {
 				switch_safe_free(e_data.uuid_list[x]);
 			}
 
 			switch_core_db_close(db);
-			
+
 		} else {
 			switch_ivr_eavesdrop_session(session, data, require_group, ED_DTMF);
 		}
@@ -352,7 +352,7 @@
 #define SET_USER_SYNTAX "<user>@<domain>"
 SWITCH_STANDARD_APP(set_user_function)
 {
-	switch_xml_t x_domain, xml = NULL, x_user, x_param, x_params;	
+	switch_xml_t x_domain, xml = NULL, x_user, x_param, x_params;
 	char *user, *mailbox, *domain;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 
@@ -367,21 +367,21 @@
 	}
 
 	*domain++ = '\0';
-	
+
 	if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
 		goto done;
 	}
 
-	if ((mailbox = (char *)switch_xml_attr(x_user, "mailbox"))) {
+	if ((mailbox = (char *) switch_xml_attr(x_user, "mailbox"))) {
 		switch_channel_set_variable(channel, "mailbox", mailbox);
 	}
-	
+
 	if ((x_params = switch_xml_child(x_user, "variables"))) {
 		for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
 			const char *var = switch_xml_attr(x_param, "name");
 			const char *val = switch_xml_attr(x_param, "value");
-			
+
 			if (var && val) {
 				switch_channel_set_variable(channel, var, val);
 			}
@@ -393,10 +393,10 @@
 
 	goto done;
 
- error:
+  error:
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No user at domain specified.\n");
 
- done:
+  done:
 	if (xml) {
 		switch_xml_free(xml);
 	}
@@ -425,7 +425,7 @@
 SWITCH_STANDARD_APP(check_acl_function)
 {
 	int argc;
-    char *argv[3] = { 0 };
+	char *argv[3] = { 0 };
 	char *mydata;
 	switch_call_cause_t cause = SWITCH_CAUSE_CALL_REJECTED;
 
@@ -441,7 +441,7 @@
 			}
 		}
 	}
-	
+
 }
 
 SWITCH_STANDARD_APP(transfer_function)
@@ -451,7 +451,7 @@
 	char *mydata;
 	int bleg = 0, both = 0;
 
-	
+
 	if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
 			bleg = !strcasecmp(argv[0], "-bleg");
@@ -459,7 +459,7 @@
 
 			if (bleg || both) {
 				const char *uuid;
-				switch_channel_t *channel = switch_core_session_get_channel(session);																		
+				switch_channel_t *channel = switch_core_session_get_channel(session);
 				if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
 					switch_core_session_t *b_session;
 					if ((b_session = switch_core_session_locate(uuid))) {
@@ -592,7 +592,7 @@
 	} else {
 		len = atoi(data);
 	}
-	
+
 	switch_ivr_delay_echo(session, len);
 }
 
@@ -776,16 +776,16 @@
 			caller_profile->caller_id_number = val;
 		}
 		if (val && !strcasecmp(name, "caller_ton")) {
-			caller_profile->caller_ton = (uint8_t)atoi(val);
+			caller_profile->caller_ton = (uint8_t) atoi(val);
 		}
 		if (val && !strcasecmp(name, "caller_numplan")) {
-			caller_profile->caller_numplan = (uint8_t)atoi(val);
+			caller_profile->caller_numplan = (uint8_t) atoi(val);
 		}
 		if (val && !strcasecmp(name, "destination_number_ton")) {
-			caller_profile->destination_number_ton = (uint8_t)atoi(val);
+			caller_profile->destination_number_ton = (uint8_t) atoi(val);
 		}
 		if (val && !strcasecmp(name, "destination_number_numplan")) {
-			caller_profile->destination_number_numplan = (uint8_t)atoi(val);
+			caller_profile->destination_number_numplan = (uint8_t) atoi(val);
 		}
 		if (!strcasecmp(name, "ani")) {
 			caller_profile->ani = val;
@@ -846,7 +846,8 @@
 			}
 		}
 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var_name ? var_name : "", val ? val : "UNDEF");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var_name ? var_name : "",
+						  val ? val : "UNDEF");
 		switch_channel_set_variable(channel, var, val);
 
 		if (var && val) {
@@ -929,17 +930,20 @@
 				if (this) {
 					char *var, *val;
 					p = this;
-					while(*p == ' ') *p++ = '\0';
+					while (*p == ' ')
+						*p++ = '\0';
 					this = p;
-				
+
 					var = this;
 					val = NULL;
 					if ((val = strchr(var, '='))) {
 						p = val - 1;
 						*val++ = '\0';
-						while(*p == ' ') *p-- = '\0';
+						while (*p == ' ')
+							*p-- = '\0';
 						p = val;
-						while(*p == ' ') *p++ = '\0';
+						while (*p == ' ')
+							*p++ = '\0';
 						val = p;
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, var, "%s", val);
 					}
@@ -1019,8 +1023,8 @@
 	switch_time_t thetime;
 	char *p;
 	if (!switch_strlen_zero(cmd) && (p = strchr(cmd, '|'))) {
-		thetime = switch_time_make(atoi(cmd),0);
-		cmd = p+1;
+		thetime = switch_time_make(atoi(cmd), 0);
+		cmd = p + 1;
 	} else {
 		thetime = switch_timestamp_now();
 	}
@@ -1091,7 +1095,7 @@
 static char *ivr_cf_name = "ivr.conf";
 
 #ifdef _TEST_CALLBACK_
-static switch_ivr_action_t menu_handler(switch_ivr_menu_t * menu, char *param, char *buf, size_t buflen, void *obj)
+static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, char *buf, size_t buflen, void *obj)
 {
 	switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP;
 
@@ -1107,7 +1111,7 @@
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_event_t *params;
-	
+
 	if (channel) {
 		switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
 
@@ -1118,7 +1122,7 @@
 
 		if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, params)) != NULL) {
 			if ((xml_menus = switch_xml_child(cfg, "menus"))) {
-				xml_menu = switch_xml_find_child(xml_menus, "menu", "name", (char *)data);
+				xml_menu = switch_xml_find_child(xml_menus, "menu", "name", (char *) data);
 
 				// if the menu was found
 				if (xml_menu != NULL) {
@@ -1134,7 +1138,7 @@
 						switch_xml_free(cxml);
 						cxml = NULL;
 						switch_channel_pre_answer(channel);
-						switch_ivr_menu_execute(session, menu_stack, (char *)data, NULL);
+						switch_ivr_menu_execute(session, menu_stack, (char *) data, NULL);
 						switch_ivr_menu_stack_free(menu_stack);
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu\n");
@@ -1164,12 +1168,12 @@
 SWITCH_STANDARD_APP(dtmf_session_generate_function)
 {
 	switch_bool_t do_read = SWITCH_TRUE;
-	
+
 	if (!switch_strlen_zero(data)) {
 		if (!strcasecmp(data, "write")) {
 			do_read = SWITCH_FALSE;
 		}
-	}	
+	}
 	switch_ivr_inband_dtmf_generate_session(session, do_read);
 }
 
@@ -1185,9 +1189,9 @@
 
 SWITCH_STANDARD_APP(system_session_function)
 {
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n",data);
-    if (!system(data)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n",data);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n", data);
+	if (!system(data)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", data);
 	}
 }
 
@@ -1211,7 +1215,7 @@
 	if (argv[3]) {
 		uint32_t mto;
 		if (*argv[3] == '+') {
-			if ((mto = atol(argv[3]+1)) > 0) {
+			if ((mto = atol(argv[3] + 1)) > 0) {
 				to = switch_timestamp(NULL) + mto;
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
@@ -1225,7 +1229,7 @@
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling tone detection '%s' '%s'\n", argv[0], argv[1]);
-	
+
 	switch_ivr_tone_detect_session(session, argv[0], argv[1], argv[2], to, argv[4], argv[5]);
 }
 
@@ -1261,7 +1265,7 @@
 static switch_status_t bridge_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
 	char *str = (char *) buf;
-	
+
 	if (str && input && itype == SWITCH_INPUT_TYPE_DTMF) {
 		switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 		if (strchr(str, dtmf->digit)) {
@@ -1288,7 +1292,7 @@
 				terminators = NULL;
 			}
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digit %c\n", dtmf->digit);
-			
+
 			for (p = terminators; p && *p; p++) {
 				if (*p == dtmf->digit) {
 					return SWITCH_STATUS_BREAK;
@@ -1326,7 +1330,7 @@
 	}
 
 	argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
-	
+
 	if (argc == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
 		return;
@@ -1381,11 +1385,11 @@
 
 	switch (itype) {
 	case SWITCH_INPUT_TYPE_DTMF:
-		{			
+		{
 			switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 			switch_channel_t *channel = switch_core_session_get_channel(session);
 			switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-			
+
 			if (dtmf->digit == '#') {
 				return SWITCH_STATUS_FALSE;
 			}
@@ -1404,12 +1408,12 @@
 					}
 					switch_core_session_rwunlock(b_session);
 				}
-				
+
 				if ((extension = switch_caller_extension_new(peer_session, app, app_arg)) == 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
 					abort();
 				}
-				
+
 				switch_caller_extension_add_application(peer_session, extension, app, app_arg);
 				switch_channel_set_caller_extension(peer_channel, extension);
 				switch_channel_set_flag(peer_channel, CF_TRANSFER);
@@ -1418,7 +1422,7 @@
 
 				return SWITCH_STATUS_FALSE;
 			}
-			
+
 		}
 		break;
 	default:
@@ -1444,7 +1448,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nHangup Command uuid_bridge(%s):\n%s\n", id, switch_str_nil((char *) stream.data));
 			switch_safe_free(stream.data);
 		}
-		
+
 		switch_core_event_hook_remove_state_change(session, hanguphook);
 	}
 	return SWITCH_STATUS_SUCCESS;
@@ -1468,8 +1472,8 @@
 	}
 
 	switch_channel_set_variable(channel, SWITCH_HOLDING_UUID_VARIABLE, bond);
-	
-	
+
+
 	if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))) {
 		timelimit = atoi(var);
 	}
@@ -1481,9 +1485,9 @@
 	peer_channel = switch_core_session_get_channel(peer_session);
 	switch_channel_set_flag(peer_channel, CF_INNER_BRIDGE);
 	switch_channel_set_flag(channel, CF_INNER_BRIDGE);
-	
+
 	switch_ivr_multi_threaded_bridge(session, peer_session, xfer_on_dtmf, peer_session, NULL);
-	
+
 	switch_channel_clear_flag(peer_channel, CF_INNER_BRIDGE);
 	switch_channel_clear_flag(channel, CF_INNER_BRIDGE);
 
@@ -1510,13 +1514,13 @@
 
 			switch_core_session_rwunlock(b_session);
 		}
-		
+
 		switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
 	}
-	
+
 	switch_core_session_rwunlock(peer_session);
-	
- end:
+
+  end:
 	switch_channel_set_variable(channel, SWITCH_HOLDING_UUID_VARIABLE, NULL);
 }
 
@@ -1538,12 +1542,12 @@
 	if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
 		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No arguements specified.\n");		
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No arguements specified.\n");
 		return;
 	}
 
 	min_digits = atoi(argv[0]);
-	
+
 	if (argc > 1) {
 		max_digits = atoi(argv[1]);
 	}
@@ -1551,19 +1555,19 @@
 	if (argc > 2) {
 		prompt_audio_file = argv[2];
 	}
-	
+
 	if (argc > 3) {
 		var_name = argv[3];
 	}
-	
+
 	if (argc > 4) {
 		timeout = atoi(argv[4]);
 	}
-	
+
 	if (argc > 5) {
 		valid_terminators = argv[5];
 	}
-	
+
 	if (min_digits <= 1) {
 		min_digits = 1;
 	}
@@ -1571,7 +1575,7 @@
 	if (max_digits < min_digits) {
 		max_digits = min_digits;
 	}
-	
+
 	if (timeout <= 1000) {
 		timeout = 1000;
 	}
@@ -1634,7 +1638,7 @@
 	if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		path = argv[0];
-		for(x = 1; x < argc; x++) {
+		for (x = 1; x < argc; x++) {
 			if (strchr(argv[x], '+')) {
 				limit = atoi(argv[x]);
 			} else if (!switch_strlen_zero(argv[x])) {
@@ -1659,7 +1663,7 @@
 	switch_input_args_t args = { 0 };
 	switch_file_handle_t fh = { 0 };
 	int argc;
-    char *mydata, *argv[4] = { 0 };
+	char *mydata, *argv[4] = { 0 };
 	char *l = NULL;
 	const char *tmp;
 	int rate;
@@ -1667,10 +1671,10 @@
 	if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
 		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No file specified.\n");		
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No file specified.\n");
 		return;
 	}
-	
+
 	path = argv[0];
 	l = argv[1];
 
@@ -1726,11 +1730,12 @@
 
 	path = switch_core_session_strdup(session, data);
 
-	if (!path) return;
+	if (!path)
+		return;
 
 	if ((p = strchr(path, '+'))) {
 		char *q = p - 1;
-		while(q && *q == ' ') {
+		while (q && *q == ' ') {
 			*q = '\0';
 			q--;
 		}
@@ -1767,11 +1772,11 @@
 	}
 
 	continue_on_fail = switch_channel_get_variable(caller_channel, "continue_on_fail");
-	
+
 	if ((var = switch_channel_get_variable(caller_channel, SWITCH_PROXY_MEDIA_VARIABLE)) && switch_true(var)) {
 		switch_channel_set_flag(caller_channel, CF_PROXY_MEDIA);
 	}
-	
+
 	if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)
 		|| ((var = switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE)) && switch_true(var))) {
 		if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
@@ -1801,7 +1806,7 @@
 		   'true' to continue on all failures.
 		   'false' to not continue.
 		   A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
-		*/
+		 */
 		if (continue_on_fail) {
 			const char *cause_str;
 			char cause_num[35] = "";
@@ -1850,11 +1855,11 @@
 			} else {
 				switch_channel_t *channel = switch_core_session_get_channel(session);
 				switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-				char *a_key = (char *)switch_channel_get_variable(channel, "bridge_terminate_key");
-				char *b_key = (char *)switch_channel_get_variable(peer_channel, "bridge_terminate_key");
+				char *a_key = (char *) switch_channel_get_variable(channel, "bridge_terminate_key");
+				char *b_key = (char *) switch_channel_get_variable(peer_channel, "bridge_terminate_key");
 				int ok = 0;
 				switch_input_callback_function_t func = NULL;
-				
+
 				if (a_key) {
 					a_key = switch_core_session_strdup(session, a_key);
 					ok++;
@@ -1873,7 +1878,7 @@
 				switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, a_key);
 			}
 		}
-	end:
+	  end:
 		if (peer_session) {
 			switch_core_session_rwunlock(peer_session);
 		}
@@ -1885,9 +1890,7 @@
 static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 												 switch_event_t *var_event,
 												 switch_caller_profile_t *outbound_profile,
-												 switch_core_session_t **new_session, 
-												 switch_memory_pool_t **pool,
-												 switch_originate_flag_t flags);
+												 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 switch_io_routines_t user_io_routines = {
 	/*.outgoing_channel */ user_outgoing_channel
 };
@@ -1895,11 +1898,9 @@
 static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 												 switch_event_t *var_event,
 												 switch_caller_profile_t *outbound_profile,
-												 switch_core_session_t **new_session, 
-												 switch_memory_pool_t **pool,
-												 switch_originate_flag_t flags)
+												 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
-	switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_param, x_params;	
+	switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_param, x_params;
 	char *user = NULL, *domain = NULL;
 	const char *dest = NULL;
 	static switch_call_cause_t cause = SWITCH_CAUSE_UNALLOCATED;
@@ -1912,7 +1913,8 @@
 
 	user = strdup(outbound_profile->destination_number);
 
-	if (!user) goto done;
+	if (!user)
+		goto done;
 
 	if (!(domain = strchr(user, '@'))) {
 		goto done;
@@ -1934,7 +1936,7 @@
 		for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
 			const char *var = switch_xml_attr(x_param, "name");
 			const char *val = switch_xml_attr(x_param, "value");
-			
+
 			if (!strcasecmp(var, "dial-string")) {
 				dest = val;
 				break;
@@ -1946,7 +1948,7 @@
 		for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
 			const char *var = switch_xml_attr(x_param, "name");
 			const char *val = switch_xml_attr(x_param, "value");
-			
+
 			if (!strcasecmp(var, "dial-string")) {
 				dest = val;
 				break;
@@ -1965,10 +1967,10 @@
 			if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))) {
 				timelimit = atoi(var);
 			}
-			
+
 			switch_channel_set_variable(channel, "dialed_user", user);
 			switch_channel_set_variable(channel, "dialed_domain", domain);
-			
+
 			d_dest = switch_channel_expand_variables(channel, dest);
 
 		} else {
@@ -1977,7 +1979,7 @@
 				switch_event_create(&event, SWITCH_EVENT_MESSAGE);
 				switch_assert(event);
 			}
-			
+
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", user);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
 			d_dest = switch_event_expand_headers(event, dest);
@@ -1985,7 +1987,7 @@
 				switch_event_destroy(&event);
 			}
 		}
-		
+
 		if ((flags & SOF_FORKED_DIAL)) {
 			myflags |= SOF_NOBLOCK;
 		}
@@ -1995,7 +1997,7 @@
 			switch_caller_profile_t *cp;
 
 			new_channel = switch_core_session_get_channel(*new_session);
-			
+
 			if ((context = switch_channel_get_variable(new_channel, "user_context"))) {
 				if ((cp = switch_channel_get_caller_profile(new_channel))) {
 					cp->context = switch_core_strdup(cp->pool, context);
@@ -2027,12 +2029,12 @@
 		}
 	}
 
- done:
+  done:
 
 	if (xml) {
 		switch_xml_free(xml);
 	}
-	
+
 	if (params) {
 		switch_event_destroy(&params);
 	}
@@ -2080,20 +2082,22 @@
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	user_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
-    user_endpoint_interface->interface_name = "USER";
-    user_endpoint_interface->io_routines = &user_io_routines;
+	user_endpoint_interface->interface_name = "USER";
+	user_endpoint_interface->io_routines = &user_io_routines;
 
 	SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>");
 	SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>");
 	SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, "<format_string>");
 	SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, "<user> <rpid> <message>");
-	SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",
+				   SAF_SUPPORT_NOMEDIA);
 
 	SWITCH_ADD_APP(app_interface, "hold", "Send a hold message", "Send a hold message", hold_function, HOLD_SYNTAX, SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "unhold", "Send a un-hold message", "Send a un-hold message", unhold_function, UNHOLD_SYNTAX, SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "transfer", "Transfer a channel", TRANSFER_LONG_DESC, transfer_function, "<exten> [<dialplan> <context>]", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", 
-				   "Check an ip against an ACL list", check_acl_function, "<ip> <acl | cidr> [<hangup_cause>]", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "transfer", "Transfer a channel", TRANSFER_LONG_DESC, transfer_function, "<exten> [<dialplan> <context>]",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function,
+				   "<ip> <acl | cidr> [<hangup_cause>]", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "sleep", "Pause a channel", SLEEP_LONG_DESC, sleep_function, "<pausemilliseconds>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "delay_echo", "echo audio at a specified delay", "Delay n ms", delay_function, "<delay ms>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "strftime", NULL, NULL, strftime_function, NULL, SAF_SUPPORT_NOMEDIA);
@@ -2106,37 +2110,50 @@
 	SWITCH_ADD_APP(app_interface, "log", "Logs a channel variable", LOG_LONG_DESC, log_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function,
+				   "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>",
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "queue_dtmf", "Queue dtmf to be sent", "Queue dtmf to be sent from a session", queue_dtmf_function, "<dtmf_data>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "send_dtmf", "Send dtmf to be sent", "Send dtmf to be sent from a session", send_dtmf_function, "<dtmf_data>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]<time> [<cause>]", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "sched_broadcast", SCHED_BROADCAST_DESCR, SCHED_BROADCAST_DESCR, sched_broadcast_function, "[+]<time> <path> [aleg|bleg|both]", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function, "[+]<time> <extension> <dialplan> <context>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "queue_dtmf", "Queue dtmf to be sent", "Queue dtmf to be sent from a session", queue_dtmf_function, "<dtmf_data>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "send_dtmf", "Send dtmf to be sent", "Send dtmf to be sent from a session", send_dtmf_function, "<dtmf_data>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]<time> [<cause>]",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "sched_broadcast", SCHED_BROADCAST_DESCR, SCHED_BROADCAST_DESCR, sched_broadcast_function,
+				   "[+]<time> <path> [aleg|bleg|both]", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function,
+				   "[+]<time> <extension> <dialplan> <context>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "execute_extension", "Execute an extension", "Execute an extension", exe_function, EXE_SYNTAX, SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "soft_hold", "Put a bridged channel on hold", "Put a bridged channel on hold", soft_hold_function, SOFT_HOLD_SYNTAX, SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX, SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "soft_hold", "Put a bridged channel on hold", "Put a bridged channel on hold", soft_hold_function, SOFT_HOLD_SYNTAX,
+				   SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX,
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "intercept", "intercept", "intercept", intercept_function, INTERCEPT_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "eavesdrop", "eavesdrop on a uuid", "eavesdrop on a uuid", eavesdrop_function, eavesdrop_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "three_way", "three way call with a uuid", "three way call with a uuid", three_way_function, threeway_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "set_user", "Set a User", "Set a User", set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "stop_dtmf_generate", "stop inband dtmf generation", "Stop generating inband dtmf.", 
+	SWITCH_ADD_APP(app_interface, "stop_dtmf_generate", "stop inband dtmf generation", "Stop generating inband dtmf.",
 				   stop_dtmf_session_generate_function, "[write]", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "start_dtmf_generate", "Generate dtmf", "Generate inband dtmf on the session", dtmf_session_generate_function, "", SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "start_dtmf_generate", "Generate dtmf", "Generate inband dtmf on the session", dtmf_session_generate_function, "",
+				   SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "stop_tone_detect", "stop detecting tones", "Stop detecting tones", stop_fax_detect_session_function, "", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "fax_detect", "Detect faxes", "Detect fax send tone", fax_detect_session_function, "", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "tone_detect", "Detect tones", "Detect tones", tone_detect_session_function, "", SAF_NONE);
@@ -2149,13 +2166,19 @@
 	SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function, "<min> <max> <file> <var name> <timeout> <terminators>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "stop_record_session", "Stop Record Session", STOP_SESS_REC_DESC, stop_record_session_function, "<path>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "record_session", "Record Session", SESS_REC_DESC, record_session_function, "<path>", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "record", "Record File", "Record a file from the channels input", record_function, "<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "stop_displace_session", "Stop Displace File", "Stop Displacing to a file", stop_displace_session_function, "<path>", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "displace_session", "Displace File", DISPLACE_DESC, displace_session_function, "<path> [+time_limit_ms] [mux]", SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "record", "Record File", "Record a file from the channels input", record_function,
+				   "<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]", SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "stop_displace_session", "Stop Displace File", "Stop Displacing to a file", stop_displace_session_function, "<path>",
+				   SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "displace_session", "Displace File", DISPLACE_DESC, displace_session_function, "<path> [+time_limit_ms] [mux]",
+				   SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "speak", "Speak text", SPEAK_DESC, speak_function, "<engine>|<voice>|<text>", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "clear_speech_cache", "Clear Speech Handle Cache", "Clear Speech Handle Cache", clear_speech_cache_function, "", SAF_NONE);
-	SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "<channel_url>", SAF_SUPPORT_NOMEDIA);
-	SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "clear_speech_cache", "Clear Speech Handle Cache", "Clear Speech Handle Cache", clear_speech_cache_function, "",
+				   SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "<channel_url>",
+				   SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>",
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE);
 
 	SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt);

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_enum/mod_enum.c	Tue May 27 07:24:06 2008
@@ -203,16 +203,16 @@
 	return out;
 }
 
-static void dnserror(enum_query_t * q, int errnum)
+static void dnserror(enum_query_t *q, int errnum)
 {
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to lookup %s record for %s: %s\n",
 					  dns_typename(q->qtyp), dns_dntosp(q->dn), dns_strerror(errnum));
 	q->errs++;
 }
 
 
-static void add_result(enum_query_t * q, int order, int preference, char *service, char *route, int supported)
+static void add_result(enum_query_t *q, int order, int preference, char *service, char *route, int supported)
 {
 	enum_record_t *new_result, *rp, *prev = NULL;
 
@@ -258,7 +258,7 @@
 }
 
 
-static void free_results(enum_record_t ** results)
+static void free_results(enum_record_t **results)
 {
 	enum_record_t *fp, *rp;
 
@@ -272,7 +272,7 @@
 	*results = NULL;
 }
 
-static void parse_rr(const struct dns_parse *p, enum_query_t * q, struct dns_rr *rr)
+static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *rr)
 {
 	const unsigned char *pkt = p->dnsp_pkt;
 	const unsigned char *end = p->dnsp_end;
@@ -290,17 +290,17 @@
 	int argc = 0;
 	char *argv[4] = { 0 };
 	int n;
-	char string_arg[3][256] = {{0}};
+	char string_arg[3][256] = { {0} };
 
 	switch (rr->dnsrr_typ) {
-	case DNS_T_NAPTR:/* prio weight port targetDN */
+	case DNS_T_NAPTR:			/* prio weight port targetDN */
 		c = dptr;
-		c += 4; /* order, pref */
+		c += 4;					/* order, pref */
 
 		for (n = 0; n < 3; ++n) {
 			if (c >= dend) {
 				goto xperr;
-			} else { 
+			} else {
 				c += *c + 1;
 			}
 		}
@@ -310,18 +310,18 @@
 		}
 
 		c = dptr;
-		order = dns_get16(c+0);
-		preference = dns_get16(c+2);
+		order = dns_get16(c + 0);
+		preference = dns_get16(c + 2);
 		flags = (char) dns_get16(c + 4);
 		c += 4;
 
-		for(n = 0; n < 3; n++) {
+		for (n = 0; n < 3; n++) {
 			uint32_t len = *c++, cpylen = len;
 			switch_assert(string_arg[n]);
 			if (len > sizeof(string_arg[n]) - 1) {
 				cpylen = sizeof(string_arg[n]) - 1;
 			}
-			strncpy(string_arg[n], (char *)c, cpylen);
+			strncpy(string_arg[n], (char *) c, cpylen);
 			*(string_arg[n] + len) = '\0';
 			c += len;
 		}
@@ -360,7 +360,7 @@
 				}
 
 				switch_mutex_lock(MUTEX);
-				for(route = globals.route_order; route; route = route->next) {
+				for (route = globals.route_order; route; route = route->next) {
 					if (strcasecmp(service, route->service)) {
 						continue;
 					}
@@ -380,9 +380,9 @@
 				if (!supported) {
 					add_result(q, order, preference, service, uri, 0);
 				}
-			} 
+			}
 			switch_mutex_unlock(MUTEX);
-			
+
 
 			switch_regex_safe_free(re);
 		}
@@ -395,7 +395,7 @@
 
 	return;
 
-	xperr:
+  xperr:
 	//printf("<parse error>\n");
 	return;
 }
@@ -455,7 +455,7 @@
 }
 
 
-static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** results)
+static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results)
 {
 	switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
 	char *name = NULL;
@@ -470,7 +470,7 @@
 	char *num, *mnum = NULL, *mroot = NULL, *p;
 
 	mnum = switch_mprintf("%s%s", *in == '+' ? "" : "+", in);
-	
+
 	if ((p = strchr(mnum, '*'))) {
 		*p++ = '\0';
 		mroot = switch_mprintf("%s.%s", p, root ? root : globals.isn_root);
@@ -594,15 +594,15 @@
 		}
 		switch_channel_set_variable(channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
 
-		
+
 		for (rp = results; rp; rp = rp->next) {
 			if (!rp->supported) {
 				continue;
 			}
 
-			switch_caller_extension_add_application(session, extension, "bridge", rp->route);			
+			switch_caller_extension_add_application(session, extension, "bridge", rp->route);
 		}
-		
+
 
 		free_results(&results);
 	}
@@ -651,7 +651,7 @@
 					continue;
 				}
 				switch_snprintf(vbuf, sizeof(vbuf), "enum_route_%d", cnt++);
-				switch_channel_set_variable(channel, vbuf, rp->route);						
+				switch_channel_set_variable(channel, vbuf, rp->route);
 				if (rp->preference == last_pref && rp->order == last_order) {
 					*last_delim = ',';
 				}
@@ -663,7 +663,7 @@
 				rbp += l;
 				rbl -= l;
 			}
-			
+
 			switch_snprintf(vbuf, sizeof(vbuf), "%d", cnt);
 			switch_channel_set_variable(channel, "enum_route_count", vbuf);
 			*(rbuf + strlen(rbuf) - 1) = '\0';
@@ -688,7 +688,7 @@
 	int last_order = -1, last_pref = -2;
 	char *last_delim = "|";
 	int ok = 0;
-	
+
 	if (switch_strlen_zero(cmd)) {
 		stream->write_function(stream, "%s", "none");
 		return SWITCH_STATUS_SUCCESS;
@@ -716,7 +716,7 @@
 				l = strlen(rp->route) + 1;
 				rbp += l;
 				rbl -= l;
-			
+
 			}
 			*(rbuf + strlen(rbuf) - 1) = '\0';
 			stream->write_function(stream, "%s", rbuf);
@@ -745,7 +745,7 @@
 	memset(&globals, 0, sizeof(globals));
 	switch_core_new_memory_pool(&globals.pool);
 	globals.timeout = 10;
-    load_config();
+	load_config();
 	switch_mutex_unlock(MUTEX);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ENUM Reloaded\n");
 
@@ -779,7 +779,7 @@
 		if (!strcasecmp(dest, "reload")) {
 			do_load();
 			stream->write_function(stream, "+OK ENUM Reloaded.\n");
-            return SWITCH_STATUS_SUCCESS;
+			return SWITCH_STATUS_SUCCESS;
 
 		}
 
@@ -846,10 +846,11 @@
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_API(api_interface, "enum", "ENUM", enum_function, "");
 	SWITCH_ADD_API(api_interface, "enum_auto", "ENUM", enum_api, "");
-	SWITCH_ADD_APP(app_interface, "enum", "Perform an ENUM lookup", "Perform an ENUM lookup", enum_app_function, "[reload | <number> [<root>]]", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "enum", "Perform an ENUM lookup", "Perform an ENUM lookup", enum_app_function, "[reload | <number> [<root>]]",
+				   SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_DIALPLAN(dp_interface, "enum", enum_dialplan_hunt);
 
-	
+
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_esf/mod_esf.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_esf/mod_esf.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_esf/mod_esf.c	Tue May 27 07:24:06 2008
@@ -63,7 +63,7 @@
 	switch_status_t status;
 	switch_size_t bytes;
 	ls_control_packet_t control_packet;
-	switch_codec_t codec = { 0}, *read_codec, *orig_codec = NULL;
+	switch_codec_t codec = { 0 }, *read_codec, *orig_codec = NULL;
 	uint32_t flags = 0;
 	const char *err;
 	switch_rtp_t *rtp_session = NULL;
@@ -71,7 +71,7 @@
 	char guess_ip[25];
 	ls_how_t ready = SEND_TYPE_UNKNOWN;
 	int argc;
-    char *mydata, *argv[5];
+	char *mydata, *argv[5];
 	char *mcast_ip = "224.168.168.168";
 	switch_port_t mcast_port = 34567;
 	switch_port_t mcast_control_port = 6061;
@@ -84,7 +84,7 @@
 		assert(mydata != NULL);
 
 		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-	
+
 		if ((var = switch_channel_get_variable(channel, "esf_multicast_ip"))) {
 			mcast_ip = switch_core_session_strdup(session, var);
 		}
@@ -95,23 +95,23 @@
 
 		if (!switch_strlen_zero(argv[1])) {
 			mcast_port_str = argv[1];
-			mcast_port = (switch_port_t)atoi(mcast_port_str);
+			mcast_port = (switch_port_t) atoi(mcast_port_str);
 		}
 
 		if (!switch_strlen_zero(argv[2])) {
-			mcast_control_port = (switch_port_t)atoi(argv[2]);
+			mcast_control_port = (switch_port_t) atoi(argv[2]);
 		}
 	}
 
-	
+
 	if (switch_true(switch_channel_get_variable(channel, SWITCH_BYPASS_MEDIA_VARIABLE))) {
 		switch_core_session_message_t msg = { 0 };
 
 		ready = SEND_TYPE_NOMEDIA;
-		
+
 		switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, mcast_ip);
 		switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, mcast_port_str);
-		
+
 		/* special answer with the mcast addr */
 		msg.from = __FILE__;
 		msg.string_arg = "recvonly";
@@ -119,7 +119,7 @@
 		switch_core_session_receive_message(session, &msg);
 	} else {
 		switch_channel_answer(channel);
-	} 
+	}
 
 	read_codec = switch_core_session_get_read_codec(session);
 
@@ -128,14 +128,14 @@
 		goto fail;
 	}
 
-	if (switch_sockaddr_info_get(&control_packet_addr, mcast_ip, SWITCH_UNSPEC, 
+	if (switch_sockaddr_info_get(&control_packet_addr, mcast_ip, SWITCH_UNSPEC,
 								 mcast_control_port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error 3\n");
 		goto fail;
 	}
 
 
-	while(!ready) {
+	while (!ready) {
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 		if (read_frame && switch_test_flag(read_frame, SFF_CNG)) {
 			continue;
@@ -144,7 +144,7 @@
 		if (!SWITCH_READ_ACCEPTABLE(status) || !read_frame) {
 			goto fail;
 		}
-		
+
 		if (read_frame->packet && read_frame->packetlen && read_codec->implementation->ianacode == 0) {
 			ready = SEND_TYPE_RAW;
 		} else {
@@ -153,23 +153,23 @@
 	}
 
 	if (ready == SEND_TYPE_RTP) {
-        if (read_codec->implementation->ianacode != 0) {
-            if (switch_core_codec_init(&codec,
-                                       "PCMU",
-                                       NULL,
-                                       8000,
-                                       20,
-                                       1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
-                                       NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
-                orig_codec = read_codec;
-                read_codec = &codec;
-                switch_core_session_set_read_codec(session, read_codec);
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Activation Success\n");
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Fail\n");
-                goto fail;
-            }
-        }
+		if (read_codec->implementation->ianacode != 0) {
+			if (switch_core_codec_init(&codec,
+									   "PCMU",
+									   NULL,
+									   8000,
+									   20,
+									   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+									   NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+				orig_codec = read_codec;
+				read_codec = &codec;
+				switch_core_session_set_read_codec(session, read_codec);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Activation Success\n");
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Fail\n");
+				goto fail;
+			}
+		}
 
 		if ((var = switch_channel_get_variable(channel, "esf_broadcast_ip"))) {
 			esf_broadcast_ip = switch_core_session_strdup(session, var);
@@ -191,9 +191,8 @@
 									 read_codec->implementation->ianacode,
 									 read_codec->implementation->samples_per_frame,
 									 read_codec->implementation->microseconds_per_frame,
-									 (switch_rtp_flag_t) flags,
-									 "soft", &err, switch_core_session_get_pool(session));
-	
+									 (switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session));
+
 		if (!switch_rtp_ready(rtp_session)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Error\n");
 			goto fail;
@@ -207,23 +206,23 @@
 		}
 	}
 
-	control_packet.unique_id = htonl((u_long)switch_timestamp(NULL));
+	control_packet.unique_id = htonl((u_long) switch_timestamp(NULL));
 	control_packet.command = htonl(LS_START_BCAST);
 	control_packet.ip = inet_addr(mcast_ip);
 	control_packet.port = htonl(mcast_port);
 
 	bytes = 16;
-	switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
+	switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);
 	bytes = 16;
-	switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
+	switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);
 
-	for(;;) {
+	for (;;) {
 
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
-        if (!SWITCH_READ_ACCEPTABLE(status)) {
-            break;
-        }
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
+			break;
+		}
 		if (switch_test_flag(read_frame, SFF_CNG)) {
 			continue;
 		}
@@ -235,23 +234,23 @@
 		}
 	}
 
-	control_packet.unique_id = htonl((u_long)switch_timestamp(NULL));
+	control_packet.unique_id = htonl((u_long) switch_timestamp(NULL));
 	control_packet.command = htonl(LS_STOP_BCAST);
 	bytes = 8;
-	switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
+	switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);
 	bytes = 8;
-	switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
+	switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);
 
- fail:
+  fail:
 
-    if (orig_codec) {
-        switch_core_session_set_read_codec(session, orig_codec);
-        switch_core_codec_destroy(&codec);
-    }
+	if (orig_codec) {
+		switch_core_session_set_read_codec(session, orig_codec);
+		switch_core_codec_destroy(&codec);
+	}
 
 	if (rtp_session && ready == SEND_TYPE_RTP && switch_rtp_ready(rtp_session)) {
 		switch_rtp_destroy(&rtp_session);
-	}	
+	}
 
 	if (socket) {
 		switch_socket_close(socket);

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/expreval.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/expreval.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/expreval.c	Tue May 27 07:24:06 2008
@@ -25,244 +25,224 @@
 
 
 /* This routine will evaluate an expression */
-int exprEval(exprObj *obj, EXPRTYPE *val)
-    {
-    EXPRTYPE dummy;
-
-    if(val ==  NULL)
-        val = &dummy;
-
-    /* Make sure it was parsed successfully */
-    if(!obj->parsedbad && obj->parsedgood && obj->headnode)
-        {
-        /* Do NOT reset the break count.  Let is accumulate
-           between calls until breaker function is called */
-        return exprEvalNode(obj, obj->headnode, 0, val);
-        }
-    else
-        return EXPR_ERROR_BADEXPR;
-    }
+int exprEval(exprObj * obj, EXPRTYPE * val)
+{
+	EXPRTYPE dummy;
+
+	if (val == NULL)
+		val = &dummy;
+
+	/* Make sure it was parsed successfully */
+	if (!obj->parsedbad && obj->parsedgood && obj->headnode) {
+		/* Do NOT reset the break count.  Let is accumulate
+		   between calls until breaker function is called */
+		return exprEvalNode(obj, obj->headnode, 0, val);
+	} else
+		return EXPR_ERROR_BADEXPR;
+}
 
 /* Evaluate a node */
-int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val)
-    {
-    int err;
-    int pos;
-    EXPRTYPE d1, d2;
-
-    if(obj == NULL || nodes == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Update n to point to correct node */
-    nodes += curnode;
-
-    /* Check breaker count */
-    if(obj->breakcur-- <= 0)
-        {
-        /* Reset count before returning */
-        obj->breakcur = obj->breakcount;
-                
-        if(exprGetBreakResult(obj))
-            {
-            return EXPR_ERROR_BREAK;
-            }
-        }
-
-    switch(nodes->type)
-        {
-        case EXPR_NODETYPE_MULTI:
-            {
-            /* Multi for multiple expressions in one string */
-            for(pos = 0; pos < nodes->data.oper.nodecount; pos++)
-                {
-                err = exprEvalNode(obj, nodes->data.oper.nodes, pos, val);
-                if(err)
-                    return err;
-                }
-            break;
-            }
-
-        case EXPR_NODETYPE_ADD:
-            {
-            /* Addition */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
-            if(!err)
-                err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
-            if(!err)
-                *val = d1 + d2;
-            else
-                return err;
-
-            break;
-            }
-
-        case EXPR_NODETYPE_SUBTRACT:
-            {
-            /* Subtraction */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-            
-            if(!err)
-                err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
-            if(!err)
-                *val = d1 - d2;
-            else
-                return err;
-
-            break;
-            }
-
-        case EXPR_NODETYPE_MULTIPLY:
-            {
-            /* Multiplication */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
-            if(!err)
-                err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
-            if(!err)
-                *val = d1 * d2;
-            else
-                return err;
-
-            break;
-            }
-
-        case EXPR_NODETYPE_DIVIDE:
-            {
-            /* Division */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
-            if(!err)
-                err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
-            if(!err)
-                {
-                if(d2 != 0.0)
-                    *val = d1 / d2;
-                else
-                    {
+int exprEvalNode(exprObj * obj, exprNode * nodes, int curnode, EXPRTYPE * val)
+{
+	int err;
+	int pos;
+	EXPRTYPE d1, d2;
+
+	if (obj == NULL || nodes == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Update n to point to correct node */
+	nodes += curnode;
+
+	/* Check breaker count */
+	if (obj->breakcur-- <= 0) {
+		/* Reset count before returning */
+		obj->breakcur = obj->breakcount;
+
+		if (exprGetBreakResult(obj)) {
+			return EXPR_ERROR_BREAK;
+		}
+	}
+
+	switch (nodes->type) {
+	case EXPR_NODETYPE_MULTI:
+		{
+			/* Multi for multiple expressions in one string */
+			for (pos = 0; pos < nodes->data.oper.nodecount; pos++) {
+				err = exprEvalNode(obj, nodes->data.oper.nodes, pos, val);
+				if (err)
+					return err;
+			}
+			break;
+		}
+
+	case EXPR_NODETYPE_ADD:
+		{
+			/* Addition */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+			if (!err)
+				*val = d1 + d2;
+			else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_SUBTRACT:
+		{
+			/* Subtraction */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+			if (!err)
+				*val = d1 - d2;
+			else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_MULTIPLY:
+		{
+			/* Multiplication */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+			if (!err)
+				*val = d1 * d2;
+			else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_DIVIDE:
+		{
+			/* Division */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+			if (!err) {
+				if (d2 != 0.0)
+					*val = d1 / d2;
+				else {
 #if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
-                    return EXPR_ERROR_DIVBYZERO;
+					return EXPR_ERROR_DIVBYZERO;
 #else
-                    *val = 0.0;
-                    return EXPR_ERROR_NOERROR;
+					*val = 0.0;
+					return EXPR_ERROR_NOERROR;
 #endif
-                    }
-                }
-            else
-                return err;
-
-            break;
-            }
-
-        case EXPR_NODETYPE_EXPONENT:
-            {
-            /* Exponent */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
-            if(!err)
-                err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
-            if(!err)
-                {
-                EXPR_RESET_ERR();
-                *val = pow(d1, d2);
-                EXPR_CHECK_ERR();
-                }
-            else
-                return err;
-
-            break;
-            }
-
-        case EXPR_NODETYPE_NEGATE:
-            {
-            /* Negative value */
-            err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
-            if(!err)
-                *val = -d1;
-            else
-                return err;
-           
-            break;
-            }
-
-
-        case EXPR_NODETYPE_VALUE:
-            {
-            /* Directly access the value */
-            *val = nodes->data.value.value;
-            break;
-            }
-
-        case EXPR_NODETYPE_VARIABLE:
-            {
-            /* Directly access the variable or constant */
-            *val = *(nodes->data.variable.vaddr);
-            break;
-            }
-
-        case EXPR_NODETYPE_ASSIGN:
-            {
-            /* Evaluate assignment subnode */
-            err = exprEvalNode(obj, nodes->data.assign.node, 0, val);
-
-            if(!err)
-                {
-                /* Directly assign the variable */
-                *(nodes->data.assign.vaddr) = *val;
-                }
-            else
-                return err;
-            
-            break;
-            }
-
-        case EXPR_NODETYPE_FUNCTION:
-            {
-            /* Evaluate the function */
-            if(nodes->data.function.fptr == NULL)
-                {
-                /* No function pointer means we are not using
-                   function solvers.  See if the function has a
-                   type to solve directly. */
-                switch(nodes->data.function.type)
-                    {
-                    /* This is to keep the file from being too crowded.
-                       See exprilfs.h for the definitions. */
+				}
+			} else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_EXPONENT:
+		{
+			/* Exponent */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+			if (!err) {
+				EXPR_RESET_ERR();
+				*val = pow(d1, d2);
+				EXPR_CHECK_ERR();
+			} else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_NEGATE:
+		{
+			/* Negative value */
+			err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+			if (!err)
+				*val = -d1;
+			else
+				return err;
+
+			break;
+		}
+
+
+	case EXPR_NODETYPE_VALUE:
+		{
+			/* Directly access the value */
+			*val = nodes->data.value.value;
+			break;
+		}
+
+	case EXPR_NODETYPE_VARIABLE:
+		{
+			/* Directly access the variable or constant */
+			*val = *(nodes->data.variable.vaddr);
+			break;
+		}
+
+	case EXPR_NODETYPE_ASSIGN:
+		{
+			/* Evaluate assignment subnode */
+			err = exprEvalNode(obj, nodes->data.assign.node, 0, val);
+
+			if (!err) {
+				/* Directly assign the variable */
+				*(nodes->data.assign.vaddr) = *val;
+			} else
+				return err;
+
+			break;
+		}
+
+	case EXPR_NODETYPE_FUNCTION:
+		{
+			/* Evaluate the function */
+			if (nodes->data.function.fptr == NULL) {
+				/* No function pointer means we are not using
+				   function solvers.  See if the function has a
+				   type to solve directly. */
+				switch (nodes->data.function.type) {
+					/* This is to keep the file from being too crowded.
+					   See exprilfs.h for the definitions. */
 #include "exprilfs.h"
-                   
-
-                    default:
-                        {
-                        return EXPR_ERROR_UNKNOWN;
-                        }
-                    }
-                }
-            else
-                {
-                /* Call the correct function */
-                return (*(nodes->data.function.fptr))(obj,
-                    nodes->data.function.nodes, nodes->data.function.nodecount,
-                    nodes->data.function.refs, nodes->data.function.refcount, val);
-                }
-
-            break;
-            }
-
-        default:
-            {
-            /* Unknown node type */
-            return EXPR_ERROR_UNKNOWN;
-            }
-        }
-
-    return EXPR_ERROR_NOERROR;
-    }
 
 
+				default:
+					{
+						return EXPR_ERROR_UNKNOWN;
+					}
+				}
+			} else {
+				/* Call the correct function */
+				return (*(nodes->data.function.fptr)) (obj,
+													   nodes->data.function.nodes, nodes->data.function.nodecount,
+													   nodes->data.function.refs, nodes->data.function.refcount, val);
+			}
+
+			break;
+		}
+
+	default:
+		{
+			/* Unknown node type */
+			return EXPR_ERROR_UNKNOWN;
+		}
+	}
 
+	return EXPR_ERROR_NOERROR;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprfunc.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprfunc.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprfunc.c	Tue May 27 07:24:06 2008
@@ -17,313 +17,296 @@
 
 /* Internal functions */
 static exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax);
-static void exprFuncListFreeData(exprFunc *func);
+static void exprFuncListFreeData(exprFunc * func);
 
 
 /* This function creates the function list, */
-int exprFuncListCreate(exprFuncList **flist)
-    {
-    exprFuncList *tmp;
+int exprFuncListCreate(exprFuncList ** flist)
+{
+	exprFuncList *tmp;
 
-    if(flist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
+	if (flist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
 
-    *flist = NULL; /* Set to NULL initially */
+	*flist = NULL;				/* Set to NULL initially */
 
-    tmp = exprAllocMem(sizeof(exprFuncList));
+	tmp = exprAllocMem(sizeof(exprFuncList));
 
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY; /* Could not allocate memory */
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;	/* Could not allocate memory */
 
-    /* Update pointer */
-    *flist = tmp;
+	/* Update pointer */
+	*flist = tmp;
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Add a function to the list */
-int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax)
-    {
-    exprFunc *tmp;
-    exprFunc *cur;
-    int result;
-
-    if(flist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Make sure the name is valid */
-    if(!exprValidIdent(name))
-        return EXPR_ERROR_BADIDENTIFIER;
-
-    /* Fix values only if none are negative (negative values mean no limit) */
-
-    /* if both are neg, no min or max number of args */
-    /* if min is neg, max pos, no min number of args but a maximum */
-    /* if min is pos, max neg, there is a min number of args, but no max */
-    /* if both pos, then a min and max limit.  We swap to make sure it works
-       right. I.E.  Min of 3 and max of 2 would make function unusable */
-    if(min >= 0 && max >= 0)
-        {
-        if(min > max)
-            {
-            result = min;
-            min = max;
-            max = result;
-            }
-        }
-
-    if(refmin >= 0 && refmax >= 0)
-        {
-        if(refmin > refmax)
-            {
-            result = refmin;
-            refmin = max;
-            refmax = result;
-            }
-        }
-
-    if(flist->head == NULL)
-        {
-        /* Create the node right here */
-        tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
-
-        if(tmp == NULL)
-            return EXPR_ERROR_MEMORY;
-
-        flist->head = tmp;
-        return EXPR_ERROR_NOERROR;
-        }
-
-    /* See if it already exists */
-    cur = flist->head;
-    
-    while(cur)
-        {
-        result = strcmp(name, cur->fname);
-        
-        if(result == 0)
-            return EXPR_ERROR_ALREADYEXISTS;
-            
-        cur = cur->next;
-        }
-        
-    /* It did not exist, so add it at the head */
-    tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
-        
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-            
-    tmp->next = flist->head;
-    flist->head = tmp;
-    return EXPR_ERROR_NOERROR;
-    }
+int exprFuncListAdd(exprFuncList * flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax)
+{
+	exprFunc *tmp;
+	exprFunc *cur;
+	int result;
+
+	if (flist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Make sure the name is valid */
+	if (!exprValidIdent(name))
+		return EXPR_ERROR_BADIDENTIFIER;
+
+	/* Fix values only if none are negative (negative values mean no limit) */
+
+	/* if both are neg, no min or max number of args */
+	/* if min is neg, max pos, no min number of args but a maximum */
+	/* if min is pos, max neg, there is a min number of args, but no max */
+	/* if both pos, then a min and max limit.  We swap to make sure it works
+	   right. I.E.  Min of 3 and max of 2 would make function unusable */
+	if (min >= 0 && max >= 0) {
+		if (min > max) {
+			result = min;
+			min = max;
+			max = result;
+		}
+	}
+
+	if (refmin >= 0 && refmax >= 0) {
+		if (refmin > refmax) {
+			result = refmin;
+			refmin = max;
+			refmax = result;
+		}
+	}
+
+	if (flist->head == NULL) {
+		/* Create the node right here */
+		tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
+
+		if (tmp == NULL)
+			return EXPR_ERROR_MEMORY;
+
+		flist->head = tmp;
+		return EXPR_ERROR_NOERROR;
+	}
+
+	/* See if it already exists */
+	cur = flist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->fname);
+
+		if (result == 0)
+			return EXPR_ERROR_ALREADYEXISTS;
+
+		cur = cur->next;
+	}
+
+	/* It did not exist, so add it at the head */
+	tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
+
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+	tmp->next = flist->head;
+	flist->head = tmp;
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Add a function node type to the list
    This works pretty much the same way, except the function
    pointer is NULL and the node type specifies the function
    to do.  exprEvalNode handles this, instead of calling
    a function solver. */
-int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax)
-    {
-    exprFunc *tmp;
-    exprFunc *cur;
-    int result;
-
-    if(flist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Make sure the name is valid */
-    if(!exprValidIdent(name))
-        return EXPR_ERROR_BADIDENTIFIER;
-
-    /* Fix values only if none are negative (negative values mean no limit) */
-
-    /* if both are neg, no min or max number of args */
-    /* if min is neg, max pos, no min number of args but a maximum */
-    /* if min is pos, max neg, there is a min number of args, but no max */
-    /* if both pos, then a min and max limit.  We swap to make sure it works
-       right. I.E.  Min of 3 and max of 2 would make function unusable */
-    if(min >= 0 && max >= 0)
-        {
-        if(min > max)
-            {
-            result = min;
-            min = max;
-            max = result;
-            }
-        }
-
-    if(refmin >= 0 && refmax >= 0)
-        {
-        if(refmin > refmax)
-            {
-            result = refmin;
-            refmin = max;
-            refmax = result;
-            }
-        }
-
-    if(flist->head == NULL)
-        {
-        /* Create the node right here */
-        tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
-
-        if(tmp == NULL)
-            return EXPR_ERROR_MEMORY;
-
-        flist->head = tmp;
-        return EXPR_ERROR_NOERROR;
-        }
-
-    /* See if it already exists */
-    cur = flist->head;
-    
-    while(cur)
-        {
-        result = strcmp(name, cur->fname);
-        
-        if(result == 0)
-            return EXPR_ERROR_ALREADYEXISTS;
-            
-        cur = cur->next;
-        }
-        
-    /* It did not exist, so add it at the head */
-    tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
-    
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-        
-    tmp->next = flist->head;
-    flist->head = tmp;
-    return EXPR_ERROR_NOERROR;
-    }
+int exprFuncListAddType(exprFuncList * flist, char *name, int type, int min, int max, int refmin, int refmax)
+{
+	exprFunc *tmp;
+	exprFunc *cur;
+	int result;
+
+	if (flist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Make sure the name is valid */
+	if (!exprValidIdent(name))
+		return EXPR_ERROR_BADIDENTIFIER;
+
+	/* Fix values only if none are negative (negative values mean no limit) */
+
+	/* if both are neg, no min or max number of args */
+	/* if min is neg, max pos, no min number of args but a maximum */
+	/* if min is pos, max neg, there is a min number of args, but no max */
+	/* if both pos, then a min and max limit.  We swap to make sure it works
+	   right. I.E.  Min of 3 and max of 2 would make function unusable */
+	if (min >= 0 && max >= 0) {
+		if (min > max) {
+			result = min;
+			min = max;
+			max = result;
+		}
+	}
+
+	if (refmin >= 0 && refmax >= 0) {
+		if (refmin > refmax) {
+			result = refmin;
+			refmin = max;
+			refmax = result;
+		}
+	}
+
+	if (flist->head == NULL) {
+		/* Create the node right here */
+		tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
+
+		if (tmp == NULL)
+			return EXPR_ERROR_MEMORY;
+
+		flist->head = tmp;
+		return EXPR_ERROR_NOERROR;
+	}
+
+	/* See if it already exists */
+	cur = flist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->fname);
+
+		if (result == 0)
+			return EXPR_ERROR_ALREADYEXISTS;
+
+		cur = cur->next;
+	}
+
+	/* It did not exist, so add it at the head */
+	tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
+
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+	tmp->next = flist->head;
+	flist->head = tmp;
+	return EXPR_ERROR_NOERROR;
+}
 
 
 /* Get the function from a list along with it's min an max data */
-int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax)
-    {
-    exprFunc *cur;
-    int result;
-
-    if(flist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    if(name == NULL || name[0] == '\0')
-        return EXPR_ERROR_NOTFOUND;
-
-    /* Search for the item */
-    cur = flist->head;
-    
-    while(cur)
-        {
-        result = strcmp(name, cur->fname);
-
-        if(result == 0)
-            {
-            /* We found it. */
-            *ptr = cur->fptr;
-            *min = cur->min;
-            *max = cur->max;
-            *refmin = cur->refmin;
-            *refmax = cur->refmax;
-            *type = cur->type;
-
-            /* return now */
-            return EXPR_ERROR_NOERROR;
-            }
-            
-        cur = cur->next;
-        }
-
-    /* If we got here, we did not find the item in the list */
-    return EXPR_ERROR_NOTFOUND;
-    }
+int exprFuncListGet(exprFuncList * flist, char *name, exprFuncType * ptr, int *type, int *min, int *max, int *refmin, int *refmax)
+{
+	exprFunc *cur;
+	int result;
+
+	if (flist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	if (name == NULL || name[0] == '\0')
+		return EXPR_ERROR_NOTFOUND;
+
+	/* Search for the item */
+	cur = flist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->fname);
+
+		if (result == 0) {
+			/* We found it. */
+			*ptr = cur->fptr;
+			*min = cur->min;
+			*max = cur->max;
+			*refmin = cur->refmin;
+			*refmax = cur->refmax;
+			*type = cur->type;
+
+			/* return now */
+			return EXPR_ERROR_NOERROR;
+		}
+
+		cur = cur->next;
+	}
+
+	/* If we got here, we did not find the item in the list */
+	return EXPR_ERROR_NOTFOUND;
+}
 
 /* This routine will free the function list */
-int exprFuncListFree(exprFuncList *flist)
-    {
-    /* Make sure it exists, if not it is not error */
-    if(flist == NULL)
-        return EXPR_ERROR_NOERROR;
+int exprFuncListFree(exprFuncList * flist)
+{
+	/* Make sure it exists, if not it is not error */
+	if (flist == NULL)
+		return EXPR_ERROR_NOERROR;
 
-    /* Free the nodes */
-    exprFuncListFreeData(flist->head);
+	/* Free the nodes */
+	exprFuncListFreeData(flist->head);
 
-    /* Free the container */
-    exprFreeMem(flist);
+	/* Free the container */
+	exprFreeMem(flist);
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* This routine will clear the function list */
-int exprFuncListClear(exprFuncList *flist)
-    {
-    if(flist == NULL)
-        return EXPR_ERROR_NOERROR;
-
-    /* Free the nodes only */
-    if(flist->head)
-        {
-        exprFuncListFreeData(flist->head);
+int exprFuncListClear(exprFuncList * flist)
+{
+	if (flist == NULL)
+		return EXPR_ERROR_NOERROR;
+
+	/* Free the nodes only */
+	if (flist->head) {
+		exprFuncListFreeData(flist->head);
 
-        flist->head = NULL;
-        }
+		flist->head = NULL;
+	}
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* This routine will free any child nodes, and then free itself */
-void exprFuncListFreeData(exprFunc *func)
-    {
-    exprFunc *next;
-    
-    while(func)
-        {
-        /* Remember the next item */
-        next = func->next;
-
-        /* Free name */
-        exprFreeMem(func->fname);
-
-        /* Free ourself */
-        exprFreeMem(func);
-        
-        func = next;
-        }
-    }
+void exprFuncListFreeData(exprFunc * func)
+{
+	exprFunc *next;
+
+	while (func) {
+		/* Remember the next item */
+		next = func->next;
+
+		/* Free name */
+		exprFreeMem(func->fname);
+
+		/* Free ourself */
+		exprFreeMem(func);
+
+		func = next;
+	}
+}
 
 /* This routine will create the function object */
 exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax)
-    {
-    exprFunc *tmp;
-    char *vtmp;
-
-    /* We already checked the name in exprFuncListAdd */
-
-    /* Create it */
-    tmp = exprAllocMem(sizeof(exprFunc));
-    if(tmp == NULL)
-        return NULL;
-
-    /* Allocate space for the name */
-    vtmp = exprAllocMem(strlen(name) + 1);
-
-    if(vtmp == NULL)
-        {
-        exprFreeMem(tmp);
-        return NULL;
-        }
-
-    /* Copy the data over */
-    strcpy(vtmp, name);
-    tmp->fname = vtmp;
-    tmp->fptr = ptr;
-    tmp->min = min;
-    tmp->max = max;
-    tmp->refmin = refmin;
-    tmp->refmax = refmax;
-    tmp->type = type;
+{
+	exprFunc *tmp;
+	char *vtmp;
+
+	/* We already checked the name in exprFuncListAdd */
+
+	/* Create it */
+	tmp = exprAllocMem(sizeof(exprFunc));
+	if (tmp == NULL)
+		return NULL;
+
+	/* Allocate space for the name */
+	vtmp = exprAllocMem(strlen(name) + 1);
+
+	if (vtmp == NULL) {
+		exprFreeMem(tmp);
+		return NULL;
+	}
+
+	/* Copy the data over */
+	strcpy(vtmp, name);
+	tmp->fname = vtmp;
+	tmp->fptr = ptr;
+	tmp->min = min;
+	tmp->max = max;
+	tmp->refmin = refmin;
+	tmp->refmax = refmax;
+	tmp->type = type;
 
-    return tmp;
-    }
+	return tmp;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprinit.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprinit.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprinit.c	Tue May 27 07:24:06 2008
@@ -26,90 +26,88 @@
     return err;
 
 /* Call this function to initialize these functions into a function list */
-int exprFuncListInit(exprFuncList *flist)
-    {
-    int err;
-
-    if(flist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    EXPR_ADDFUNC_TYPE("abs", EXPR_NODEFUNC_ABS, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("mod", EXPR_NODEFUNC_MOD, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("ipart", EXPR_NODEFUNC_IPART, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("fpart", EXPR_NODEFUNC_FPART, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("min", EXPR_NODEFUNC_MIN, 1, -1, 0, 0);
-    EXPR_ADDFUNC_TYPE("max", EXPR_NODEFUNC_MAX, 1, -1, 0, 0);
-    EXPR_ADDFUNC_TYPE("pow", EXPR_NODEFUNC_POW, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("sqrt", EXPR_NODEFUNC_SQRT, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("sin", EXPR_NODEFUNC_SIN, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("sinh", EXPR_NODEFUNC_SINH, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("asin", EXPR_NODEFUNC_ASIN, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("cos", EXPR_NODEFUNC_COS, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("cosh", EXPR_NODEFUNC_COSH, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("acos", EXPR_NODEFUNC_ACOS, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("tan", EXPR_NODEFUNC_TAN, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("tanh", EXPR_NODEFUNC_TANH, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("atan", EXPR_NODEFUNC_ATAN, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("atan2", EXPR_NODEFUNC_ATAN2, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("log", EXPR_NODEFUNC_LOG, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("pow10", EXPR_NODEFUNC_POW10, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("ln", EXPR_NODEFUNC_LN, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("exp", EXPR_NODEFUNC_EXP, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("logn", EXPR_NODEFUNC_LOGN, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("ceil", EXPR_NODEFUNC_CEIL, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("floor", EXPR_NODEFUNC_FLOOR, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("rand", EXPR_NODEFUNC_RAND, 0, 0, 1, 1);
-    EXPR_ADDFUNC_TYPE("random", EXPR_NODEFUNC_RANDOM, 2, 2, 1, 1);
-    EXPR_ADDFUNC_TYPE("randomize", EXPR_NODEFUNC_RANDOMIZE, 0, 0, 1, 1);
-    EXPR_ADDFUNC_TYPE("deg", EXPR_NODEFUNC_DEG, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("rad", EXPR_NODEFUNC_RAD, 1, 1, 0, 0);
-    EXPR_ADDFUNC_TYPE("recttopolr", EXPR_NODEFUNC_RECTTOPOLR, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("recttopola", EXPR_NODEFUNC_RECTTOPOLA, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("poltorectx", EXPR_NODEFUNC_POLTORECTX, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("poltorecty", EXPR_NODEFUNC_POLTORECTY, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("if", EXPR_NODEFUNC_IF, 3, 3, 0, 0);
-    EXPR_ADDFUNC_TYPE("select", EXPR_NODEFUNC_SELECT, 3, 4, 0, 0);
-    EXPR_ADDFUNC_TYPE("equal", EXPR_NODEFUNC_EQUAL, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("above", EXPR_NODEFUNC_ABOVE, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("below", EXPR_NODEFUNC_BELOW, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("avg", EXPR_NODEFUNC_AVG, 1, -1, 0, 0);
-    EXPR_ADDFUNC_TYPE("clip", EXPR_NODEFUNC_CLIP, 3, 3, 0, 0);
-    EXPR_ADDFUNC_TYPE("clamp", EXPR_NODEFUNC_CLAMP, 3, 3, 0, 0);
-    EXPR_ADDFUNC_TYPE("pntchange", EXPR_NODEFUNC_PNTCHANGE, 5, 5, 0, 0);
-    EXPR_ADDFUNC_TYPE("poly", EXPR_NODEFUNC_POLY, 2, -1, 0, 0);
-    EXPR_ADDFUNC_TYPE("and", EXPR_NODEFUNC_AND, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("or", EXPR_NODEFUNC_OR, 2, 2, 0, 0);
-    EXPR_ADDFUNC_TYPE("not", EXPR_NODEFUNC_NOT, 1 ,1, 0, 0);
-    EXPR_ADDFUNC_TYPE("for", EXPR_NODEFUNC_FOR, 4, -1, 0, 0);
-    EXPR_ADDFUNC_TYPE("many", EXPR_NODEFUNC_MANY, 1, -1, 0, 0);
+int exprFuncListInit(exprFuncList * flist)
+{
+	int err;
+
+	if (flist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	EXPR_ADDFUNC_TYPE("abs", EXPR_NODEFUNC_ABS, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("mod", EXPR_NODEFUNC_MOD, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("ipart", EXPR_NODEFUNC_IPART, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("fpart", EXPR_NODEFUNC_FPART, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("min", EXPR_NODEFUNC_MIN, 1, -1, 0, 0);
+	EXPR_ADDFUNC_TYPE("max", EXPR_NODEFUNC_MAX, 1, -1, 0, 0);
+	EXPR_ADDFUNC_TYPE("pow", EXPR_NODEFUNC_POW, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("sqrt", EXPR_NODEFUNC_SQRT, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("sin", EXPR_NODEFUNC_SIN, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("sinh", EXPR_NODEFUNC_SINH, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("asin", EXPR_NODEFUNC_ASIN, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("cos", EXPR_NODEFUNC_COS, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("cosh", EXPR_NODEFUNC_COSH, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("acos", EXPR_NODEFUNC_ACOS, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("tan", EXPR_NODEFUNC_TAN, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("tanh", EXPR_NODEFUNC_TANH, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("atan", EXPR_NODEFUNC_ATAN, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("atan2", EXPR_NODEFUNC_ATAN2, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("log", EXPR_NODEFUNC_LOG, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("pow10", EXPR_NODEFUNC_POW10, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("ln", EXPR_NODEFUNC_LN, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("exp", EXPR_NODEFUNC_EXP, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("logn", EXPR_NODEFUNC_LOGN, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("ceil", EXPR_NODEFUNC_CEIL, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("floor", EXPR_NODEFUNC_FLOOR, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("rand", EXPR_NODEFUNC_RAND, 0, 0, 1, 1);
+	EXPR_ADDFUNC_TYPE("random", EXPR_NODEFUNC_RANDOM, 2, 2, 1, 1);
+	EXPR_ADDFUNC_TYPE("randomize", EXPR_NODEFUNC_RANDOMIZE, 0, 0, 1, 1);
+	EXPR_ADDFUNC_TYPE("deg", EXPR_NODEFUNC_DEG, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("rad", EXPR_NODEFUNC_RAD, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("recttopolr", EXPR_NODEFUNC_RECTTOPOLR, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("recttopola", EXPR_NODEFUNC_RECTTOPOLA, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("poltorectx", EXPR_NODEFUNC_POLTORECTX, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("poltorecty", EXPR_NODEFUNC_POLTORECTY, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("if", EXPR_NODEFUNC_IF, 3, 3, 0, 0);
+	EXPR_ADDFUNC_TYPE("select", EXPR_NODEFUNC_SELECT, 3, 4, 0, 0);
+	EXPR_ADDFUNC_TYPE("equal", EXPR_NODEFUNC_EQUAL, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("above", EXPR_NODEFUNC_ABOVE, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("below", EXPR_NODEFUNC_BELOW, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("avg", EXPR_NODEFUNC_AVG, 1, -1, 0, 0);
+	EXPR_ADDFUNC_TYPE("clip", EXPR_NODEFUNC_CLIP, 3, 3, 0, 0);
+	EXPR_ADDFUNC_TYPE("clamp", EXPR_NODEFUNC_CLAMP, 3, 3, 0, 0);
+	EXPR_ADDFUNC_TYPE("pntchange", EXPR_NODEFUNC_PNTCHANGE, 5, 5, 0, 0);
+	EXPR_ADDFUNC_TYPE("poly", EXPR_NODEFUNC_POLY, 2, -1, 0, 0);
+	EXPR_ADDFUNC_TYPE("and", EXPR_NODEFUNC_AND, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("or", EXPR_NODEFUNC_OR, 2, 2, 0, 0);
+	EXPR_ADDFUNC_TYPE("not", EXPR_NODEFUNC_NOT, 1, 1, 0, 0);
+	EXPR_ADDFUNC_TYPE("for", EXPR_NODEFUNC_FOR, 4, -1, 0, 0);
+	EXPR_ADDFUNC_TYPE("many", EXPR_NODEFUNC_MANY, 1, -1, 0, 0);
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Call this function to initialize some constants into a value list */
-int exprValListInit(exprValList *vlist)
-    {
-    int err;
-
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    EXPR_ADDCONST("M_E", M_E);
-    EXPR_ADDCONST("M_LOG2E", M_LOG2E);
-    EXPR_ADDCONST("M_LOG10E", M_LOG10E);
-    EXPR_ADDCONST("M_LN2", M_LN2);
-    EXPR_ADDCONST("M_LN10", M_LN10);
-    EXPR_ADDCONST("M_PI", M_PI);
-    EXPR_ADDCONST("M_PI_2", M_PI_2);
-    EXPR_ADDCONST("M_PI_4", M_PI_4);
-    EXPR_ADDCONST("M_1_PI", M_1_PI);
-    EXPR_ADDCONST("M_2_PI", M_2_PI);
-    EXPR_ADDCONST("M_1_SQRTPI", M_1_SQRTPI);
-    EXPR_ADDCONST("M_2_SQRTPI", M_2_SQRTPI);
-    EXPR_ADDCONST("M_SQRT2", M_SQRT2);
-    EXPR_ADDCONST("M_1_SQRT2", M_1_SQRT2);
-
-    return EXPR_ERROR_NOERROR;
-    }
-
+int exprValListInit(exprValList * vlist)
+{
+	int err;
+
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	EXPR_ADDCONST("M_E", M_E);
+	EXPR_ADDCONST("M_LOG2E", M_LOG2E);
+	EXPR_ADDCONST("M_LOG10E", M_LOG10E);
+	EXPR_ADDCONST("M_LN2", M_LN2);
+	EXPR_ADDCONST("M_LN10", M_LN10);
+	EXPR_ADDCONST("M_PI", M_PI);
+	EXPR_ADDCONST("M_PI_2", M_PI_2);
+	EXPR_ADDCONST("M_PI_4", M_PI_4);
+	EXPR_ADDCONST("M_1_PI", M_1_PI);
+	EXPR_ADDCONST("M_2_PI", M_2_PI);
+	EXPR_ADDCONST("M_1_SQRTPI", M_1_SQRTPI);
+	EXPR_ADDCONST("M_2_SQRTPI", M_2_SQRTPI);
+	EXPR_ADDCONST("M_SQRT2", M_SQRT2);
+	EXPR_ADDCONST("M_1_SQRT2", M_1_SQRT2);
 
+	return EXPR_ERROR_NOERROR;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprmem.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprmem.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprmem.c	Tue May 27 07:24:06 2008
@@ -13,27 +13,26 @@
 #include "exprmem.h"
 
 /* Allocate memory and zero it */
-void* exprAllocMem(size_t size)
-    {
-    void *data = malloc(size);
-    
-    if(data)
-        {
-        memset(data, 0, size);
-        }
-    
-    return data;
-    }
+void *exprAllocMem(size_t size)
+{
+	void *data = malloc(size);
+
+	if (data) {
+		memset(data, 0, size);
+	}
+
+	return data;
+}
 
 /* Free memory */
 void exprFreeMem(void *data)
-    {
-    if(data)
-        free(data);
-    }
+{
+	if (data)
+		free(data);
+}
 
 /* Allocate a list of nodes */
 exprNode *exprAllocNodes(size_t count)
-    {
-    return exprAllocMem(count * sizeof(exprNode));
-    }
+{
+	return exprAllocMem(count * sizeof(exprNode));
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprobj.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprobj.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprobj.c	Tue May 27 07:24:06 2008
@@ -14,224 +14,215 @@
 #include "exprmem.h"
 
 /* Internal functions */
-static void exprFreeNodeData(exprNode *node);
+static void exprFreeNodeData(exprNode * node);
 
 
 /* Function to create an expression object */
-int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
-    exprBreakFuncType breaker, void *userdata)
-    {
-    exprObj *tmp;
-
-    /* Allocate memory for the object */
-    tmp = exprAllocMem(sizeof(exprObj));
-
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Assign data */
-    tmp->flist = flist;
-    tmp->vlist = vlist;
-    tmp->clist = clist;
-    tmp->breakerfunc = breaker;
-    tmp->userdata = userdata;
-    tmp->breakcount = 100000; /* Default breaker count setting */
-    tmp->breakcur = 0;
+int exprCreate(exprObj ** obj, exprFuncList * flist, exprValList * vlist, exprValList * clist, exprBreakFuncType breaker, void *userdata)
+{
+	exprObj *tmp;
+
+	/* Allocate memory for the object */
+	tmp = exprAllocMem(sizeof(exprObj));
+
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Assign data */
+	tmp->flist = flist;
+	tmp->vlist = vlist;
+	tmp->clist = clist;
+	tmp->breakerfunc = breaker;
+	tmp->userdata = userdata;
+	tmp->breakcount = 100000;	/* Default breaker count setting */
+	tmp->breakcur = 0;
 
-    /* Update pointer */
-    *obj = tmp;
+	/* Update pointer */
+	*obj = tmp;
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 
 /* Free the expression */
-int exprFree(exprObj *obj)
-    {
-    if(obj == NULL)
-        return EXPR_ERROR_NOERROR;
-
-    /* First free the node data */
-    exprFreeNodeData(obj->headnode);
-    exprFreeMem(obj->headnode);
+int exprFree(exprObj * obj)
+{
+	if (obj == NULL)
+		return EXPR_ERROR_NOERROR;
+
+	/* First free the node data */
+	exprFreeNodeData(obj->headnode);
+	exprFreeMem(obj->headnode);
 
-    /* Free ourself */
-    exprFreeMem(obj);
+	/* Free ourself */
+	exprFreeMem(obj);
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Clear expression, keep lists, etc */
-int exprClear(exprObj *obj)
-    {
-    if(obj == NULL)
-        return EXPR_ERROR_NOERROR;
-
-    /* Free the node data only, keep function, variable, constant lists */
-    exprFreeNodeData(obj->headnode);
-    exprFreeMem(obj->headnode);
-
-    obj->headnode = NULL;
-    obj->parsedbad = 0;
-    obj->parsedgood = 0;
+int exprClear(exprObj * obj)
+{
+	if (obj == NULL)
+		return EXPR_ERROR_NOERROR;
+
+	/* Free the node data only, keep function, variable, constant lists */
+	exprFreeNodeData(obj->headnode);
+	exprFreeMem(obj->headnode);
+
+	obj->headnode = NULL;
+	obj->parsedbad = 0;
+	obj->parsedgood = 0;
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 
 /* Get functions to get information about the expression object */
 
 /* Get the function list */
-exprFuncList *exprGetFuncList(exprObj *obj)
-    {
-    return (obj == NULL) ? NULL : obj->flist;
-    }
+exprFuncList *exprGetFuncList(exprObj * obj)
+{
+	return (obj == NULL) ? NULL : obj->flist;
+}
 
 /* Get the variable list */
-exprValList *exprGetVarList(exprObj *obj)
-    {
-    return (obj == NULL) ? NULL : obj->vlist;
-    }
+exprValList *exprGetVarList(exprObj * obj)
+{
+	return (obj == NULL) ? NULL : obj->vlist;
+}
 
 /* Get the constant list */
-exprValList *exprGetConstList(exprObj *obj)
-    {
-    return (obj == NULL) ? NULL : obj->clist;
-    }
+exprValList *exprGetConstList(exprObj * obj)
+{
+	return (obj == NULL) ? NULL : obj->clist;
+}
 
 /* Get the breaker function */
-exprBreakFuncType exprGetBreakFunc(exprObj *obj)
-    {
-    return (obj == NULL) ? NULL : obj->breakerfunc;
-    }
+exprBreakFuncType exprGetBreakFunc(exprObj * obj)
+{
+	return (obj == NULL) ? NULL : obj->breakerfunc;
+}
 
 /* Check for break status */
-int exprGetBreakResult(exprObj *obj)
-    {
-    if(obj == NULL)
-        return 0;
+int exprGetBreakResult(exprObj * obj)
+{
+	if (obj == NULL)
+		return 0;
 
-    if(obj->breakerfunc == NULL)
-        return 0;
+	if (obj->breakerfunc == NULL)
+		return 0;
 
-    return (*(obj->breakerfunc))(obj);
-    }
+	return (*(obj->breakerfunc)) (obj);
+}
 
 /* Get the user data */
-void *exprGetUserData(exprObj *obj)
-    {
-    return (obj == NULL) ? NULL : obj->userdata;
-    }
+void *exprGetUserData(exprObj * obj)
+{
+	return (obj == NULL) ? NULL : obj->userdata;
+}
 
 
 /* Set functions to set certain data */
 
 /* Set user data */
-void exprSetUserData(exprObj *obj, void *userdata)
-    {
-    if(obj)
-        obj->userdata = userdata;
-    }
+void exprSetUserData(exprObj * obj, void *userdata)
+{
+	if (obj)
+		obj->userdata = userdata;
+}
 
 
 /* Set breaker count */
-void exprSetBreakCount(exprObj *obj, int count)
-    {
-    if(obj)
-        {
-        /* If count is negative, make it positive */
-        if(count < 0)
-            count = -count;
-
-        obj->breakcount = count;
-
-        /* Make sure the current value is not bigger than count */
-        if(obj->breakcur > count)
-            obj->breakcur = count;
-        }
-    }
+void exprSetBreakCount(exprObj * obj, int count)
+{
+	if (obj) {
+		/* If count is negative, make it positive */
+		if (count < 0)
+			count = -count;
+
+		obj->breakcount = count;
+
+		/* Make sure the current value is not bigger than count */
+		if (obj->breakcur > count)
+			obj->breakcur = count;
+	}
+}
 
 /* Get error position */
-void exprGetErrorPosition(exprObj *obj, int *start, int *end)
-    {
-    if(obj)
-        {
-        if(start)
-            *start = obj->starterr;
-
-        if(end)
-            *end = obj->enderr;
-        }
-    }
+void exprGetErrorPosition(exprObj * obj, int *start, int *end)
+{
+	if (obj) {
+		if (start)
+			*start = obj->starterr;
+
+		if (end)
+			*end = obj->enderr;
+	}
+}
 
 /* This function will free a node's data */
-static void exprFreeNodeData(exprNode *node)
-    {
-    int pos;
-
-    if(node == NULL)
-        return;
-
-    /* free data based on type */
-    switch(node->type)
-        {
-        case EXPR_NODETYPE_ADD:
-        case EXPR_NODETYPE_SUBTRACT:
-        case EXPR_NODETYPE_MULTIPLY:
-        case EXPR_NODETYPE_DIVIDE:
-        case EXPR_NODETYPE_EXPONENT:
-        case EXPR_NODETYPE_NEGATE:
-        case EXPR_NODETYPE_MULTI:
-            /* Free operation data */
-            if(node->data.oper.nodes)
-                {
-                for(pos = 0; pos < node->data.oper.nodecount; pos++)
-                    exprFreeNodeData(&(node->data.oper.nodes[pos]));
-
-                exprFreeMem(node->data.oper.nodes);
-                }
-
-            break;
-
-
-        case EXPR_NODETYPE_VALUE:
-            /* Nothing to free for value */
-            break;
-
-        case EXPR_NODETYPE_VARIABLE:
-            /* Nothing to free for variable */
-            break;
-
-        case EXPR_NODETYPE_FUNCTION:
-            /* Free data of each subnode */
-            if(node->data.function.nodes)
-                {
-                for(pos = 0; pos < node->data.function.nodecount; pos++)
-                    exprFreeNodeData(&(node->data.function.nodes[pos]));
-
-                /* Free the subnode array */
-                exprFreeMem(node->data.function.nodes);
-                }
-
-            /* Free reference variable list */
-            if(node->data.function.refs)
-                exprFreeMem(node->data.function.refs);
-
-            break;
-
-        case EXPR_NODETYPE_ASSIGN:
-            /* Free subnode data */
-            if(node->data.assign.node)
-                {
-                exprFreeNodeData(node->data.assign.node);
-
-                /* Free the subnode */
-                exprFreeMem(node->data.assign.node);
-                }
-
-            break;
-        }
-    }
-
-
+static void exprFreeNodeData(exprNode * node)
+{
+	int pos;
+
+	if (node == NULL)
+		return;
+
+	/* free data based on type */
+	switch (node->type) {
+	case EXPR_NODETYPE_ADD:
+	case EXPR_NODETYPE_SUBTRACT:
+	case EXPR_NODETYPE_MULTIPLY:
+	case EXPR_NODETYPE_DIVIDE:
+	case EXPR_NODETYPE_EXPONENT:
+	case EXPR_NODETYPE_NEGATE:
+	case EXPR_NODETYPE_MULTI:
+		/* Free operation data */
+		if (node->data.oper.nodes) {
+			for (pos = 0; pos < node->data.oper.nodecount; pos++)
+				exprFreeNodeData(&(node->data.oper.nodes[pos]));
+
+			exprFreeMem(node->data.oper.nodes);
+		}
+
+		break;
+
+
+	case EXPR_NODETYPE_VALUE:
+		/* Nothing to free for value */
+		break;
+
+	case EXPR_NODETYPE_VARIABLE:
+		/* Nothing to free for variable */
+		break;
+
+	case EXPR_NODETYPE_FUNCTION:
+		/* Free data of each subnode */
+		if (node->data.function.nodes) {
+			for (pos = 0; pos < node->data.function.nodecount; pos++)
+				exprFreeNodeData(&(node->data.function.nodes[pos]));
+
+			/* Free the subnode array */
+			exprFreeMem(node->data.function.nodes);
+		}
+
+		/* Free reference variable list */
+		if (node->data.function.refs)
+			exprFreeMem(node->data.function.refs);
+
+		break;
+
+	case EXPR_NODETYPE_ASSIGN:
+		/* Free subnode data */
+		if (node->data.assign.node) {
+			exprFreeNodeData(node->data.assign.node);
+
+			/* Free the subnode */
+			exprFreeMem(node->data.assign.node);
+		}
+
+		break;
+	}
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprpars.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprpars.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprpars.c	Tue May 27 07:24:06 2008
@@ -14,18 +14,16 @@
 #include "exprmem.h"
 
 /* Data structure used by parser */
-typedef struct _exprToken
-    {
-    int type; /* token type */
-    int start; /* token start position */
-    int end; /* token end position */
-
-    union _tdata
-        {
-        char *str; /* string data */
-        EXPRTYPE val; /* value data */
-        } data;
-    } exprToken;
+typedef struct _exprToken {
+	int type;					/* token type */
+	int start;					/* token start position */
+	int end;					/* token end position */
+
+	union _tdata {
+		char *str;				/* string data */
+		EXPRTYPE val;			/* value data */
+	} data;
+} exprToken;
 
 /* Defines for token types */
 #define EXPR_TOKEN_UNKNOWN 0
@@ -44,1515 +42,1378 @@
 #define EXPR_TOKEN_HAT 13
 
 /* Internal functions */
-int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count);
-int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
-int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2);
-int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
-int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count);
-void exprFreeTokenList(exprToken *tokens, int count);
+int exprMultiParse(exprObj * obj, exprNode * node, exprToken * tokens, int count);
+int exprInternalParse(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end);
+int exprInternalParseAssign(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseAdd(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseSub(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseMul(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseDiv(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParsePosNeg(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseExp(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index);
+int exprInternalParseFunction(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int p1, int p2);
+int exprInternalParseVarVal(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end);
+int exprStringToTokenList(exprObj * obj, char *expr, exprToken ** tokens, int *count);
+void exprFreeTokenList(exprToken * tokens, int count);
 
 /* This frees a token list */
-void exprFreeTokenList(exprToken *tokens, int count)
-    {
-    int pos;
-
-    if(tokens == NULL)
-        return;
-
-    for(pos = 0; pos < count; pos++)
-        {
-        if(tokens[pos].type == EXPR_TOKEN_IDENTIFIER)
-            exprFreeMem(tokens[pos].data.str);
-        }
+void exprFreeTokenList(exprToken * tokens, int count)
+{
+	int pos;
+
+	if (tokens == NULL)
+		return;
+
+	for (pos = 0; pos < count; pos++) {
+		if (tokens[pos].type == EXPR_TOKEN_IDENTIFIER)
+			exprFreeMem(tokens[pos].data.str);
+	}
 
-    exprFreeMem(tokens);
-    }
+	exprFreeMem(tokens);
+}
 
 /* This converts an expression string to a token list */
-int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count)
-    {
-    int found;
-    exprToken *list;
-    int pass;
-    int pos, len;
-    int tpos;
-    int comment; /* Is a comment active */
-    int start, ilen;
-    char buf[EXPR_MAXIDENTSIZE + 1];
-
-    /* Set initial variables */
-    found = 0;
-    tpos = 0;
-    list = NULL;
-    comment = 0;
-    *tokens = NULL;
-    *count = 0;
-
-
-    /* Check string length */
-    len = (int)strlen(expr);
-    if(len == 0)
-        return EXPR_ERROR_EMPTYEXPR;
-
-    /* Two passes, one to count, one to tokenize */
-    for(pass = 0; pass <= 1; pass++)
-        {
-        for(pos = 0; pos < len; pos++)
-            {
-            switch(expr[pos])
-                {
-                /* Comment */
-                case '#':
-                    {
-                    /* Only set it if a comment is not already active */
-                    if(!comment)
-                        comment = 1;
-
-                    break;
-                    }
-
-                /* Newline characters turn off comments */
-                case '\r':
-                case '\n':
-                    {
-                    /* If a comment is active, unset it */
-                    if(comment)
-                        comment = 0;
-
-                    break;
-                    }
-
-                /* Open parenthesis */
-                case '(':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_OPAREN;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Close parenthesis */
-                case ')':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_CPAREN;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Plus */
-                case '+':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_PLUS;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Hyphen */
-                case '-':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_HYPHEN;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Asterisk */
-                case '*':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_ASTERISK;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Forward slash */
-                case '/':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_FSLASH;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Hat */
-                case '^':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_HAT;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Ampersand */
-                case '&':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_AMPERSAND;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Semicolon */
-                case ';':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_SEMICOLON;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Comma */
-                case ',':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_COMMA;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Equal sign */
-                case '=':
-                    {
-                    if(!comment)
-                        {
-                        if(pass == 0)
-                            found++;
-                        else
-                            {
-                            list[tpos].type = EXPR_TOKEN_EQUAL;
-                            list[tpos].start = pos;
-                            list[tpos].end = pos;
-                            tpos++;
-                            }
-                        }
-
-                    break;
-                    }
-
-                /* Identifiers and values */
-                default:
-                    {
-                    if(!comment)
-                        {
-                        if(expr[pos] == '.' || isdigit(expr[pos]))
-                            {
-                            /* Value */
-                            start = pos;
-
-                            /* Find digits before a period */
-                            while(isdigit(expr[pos]))
-                                pos++;
-
-                            /* Find a period */
-                            if(expr[pos] == '.')
-                                pos++;
-
-                            /* Find digits after a period */
-                            while(isdigit(expr[pos]))
-                                pos++;
-
-                            /* pos is AFTER last item, back up */
-                            pos--;
-
-                            if(pass == 0)
-                                found++;
-                            else
-                                {
-                                ilen = pos - start + 1;
-
-                                /* Is the value to large */
-                                if(ilen > EXPR_MAXIDENTSIZE)
-                                    {
-                                    obj->starterr = start;
-                                    obj->enderr = pos;
-                                    exprFreeTokenList(list, found);
-                                    return EXPR_ERROR_BADIDENTIFIER;
-                                    }
-
-                                /* Create value token */
-                                strncpy(buf, expr + start, ilen);
-                                buf[ilen] = '\0';
-
-                                list[tpos].type = EXPR_TOKEN_VALUE;
-                                list[tpos].start = start;
-                                list[tpos].end = pos;
-                                list[tpos].data.val = (EXPRTYPE)atof(buf);
-                                tpos++;
-                                }
-                            }
-                        else if(expr[pos] == '_' || isalpha(expr[pos]))
-                            {
-                            /* Identifier */
-                            start = pos;
-
-                            /* Find rest of identifier */
-                            while(expr[pos] == '_' || isalnum(expr[pos]))
-                                pos++;
-
-                            /* pos is AFTER last item, back up */
-                            pos--;
-
-                            if(pass == 0)
-                                found++;
-                            else
-                                {
-                                ilen = pos - start + 1;
-
-                                /* Is the value to large */
-                                if(ilen > EXPR_MAXIDENTSIZE)
-                                    {
-                                    obj->starterr = start;
-                                    obj->enderr = pos;
-                                    exprFreeTokenList(list, found);
-                                    return EXPR_ERROR_BADIDENTIFIER;
-                                    }
-
-                                /* Create value token */
-                                strncpy(buf, expr + start, ilen);
-                                buf[ilen] = '\0';
-
-                                /* Allocate memory for identifier */
-                                list[tpos].data.str = exprAllocMem(ilen + 1);
-                                if(list[tpos].data.str == NULL)
-                                    {
-                                    exprFreeTokenList(list, found);
-                                    return EXPR_ERROR_MEMORY;
-                                    }
-
-                                list[tpos].type = EXPR_TOKEN_IDENTIFIER;
-                                list[tpos].start = start;
-                                list[tpos].end = pos;
-                                strcpy(list[tpos].data.str, buf);
-                                tpos++;
-                                }
-                            }
-                        else if(isspace(expr[pos]))
-                            {
-                            /* Spaces are ignored, do nothing */
-                            }
-                        else
-                            {
-                            /* Unknown */
-                            obj->starterr = obj->enderr = pos;
-                            exprFreeTokenList(list, found);
-                            return EXPR_ERROR_INVALIDCHAR;
-                            }
-                        }
-
-                    break;
-                    }
-                }
-            }
-
-        /* If pass is 0, allocate memory for next pass */
-        if(pass == 0)
-            {
-            /* First, make sure all comments were ended */
-            if(comment)
-                comment = 0;
-
-            /* Make sure the expression is not empty */
-            if(found == 0)
-                return EXPR_ERROR_EMPTYEXPR;
-
-            /* Allocate memory for token list */
-            list = exprAllocMem(found * sizeof(exprToken));
-            if(list == NULL)
-                return EXPR_ERROR_MEMORY;
-
-            tpos = 0;
-            }
-        }
-
-    *count = found;
-    *tokens = list;
-    return EXPR_ERROR_NOERROR;
-    }
+int exprStringToTokenList(exprObj * obj, char *expr, exprToken ** tokens, int *count)
+{
+	int found;
+	exprToken *list;
+	int pass;
+	int pos, len;
+	int tpos;
+	int comment;				/* Is a comment active */
+	int start, ilen;
+	char buf[EXPR_MAXIDENTSIZE + 1];
+
+	/* Set initial variables */
+	found = 0;
+	tpos = 0;
+	list = NULL;
+	comment = 0;
+	*tokens = NULL;
+	*count = 0;
+
+
+	/* Check string length */
+	len = (int) strlen(expr);
+	if (len == 0)
+		return EXPR_ERROR_EMPTYEXPR;
+
+	/* Two passes, one to count, one to tokenize */
+	for (pass = 0; pass <= 1; pass++) {
+		for (pos = 0; pos < len; pos++) {
+			switch (expr[pos]) {
+				/* Comment */
+			case '#':
+				{
+					/* Only set it if a comment is not already active */
+					if (!comment)
+						comment = 1;
+
+					break;
+				}
+
+				/* Newline characters turn off comments */
+			case '\r':
+			case '\n':
+				{
+					/* If a comment is active, unset it */
+					if (comment)
+						comment = 0;
+
+					break;
+				}
+
+				/* Open parenthesis */
+			case '(':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_OPAREN;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Close parenthesis */
+			case ')':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_CPAREN;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Plus */
+			case '+':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_PLUS;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Hyphen */
+			case '-':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_HYPHEN;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Asterisk */
+			case '*':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_ASTERISK;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Forward slash */
+			case '/':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_FSLASH;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Hat */
+			case '^':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_HAT;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Ampersand */
+			case '&':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_AMPERSAND;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Semicolon */
+			case ';':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_SEMICOLON;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Comma */
+			case ',':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_COMMA;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Equal sign */
+			case '=':
+				{
+					if (!comment) {
+						if (pass == 0)
+							found++;
+						else {
+							list[tpos].type = EXPR_TOKEN_EQUAL;
+							list[tpos].start = pos;
+							list[tpos].end = pos;
+							tpos++;
+						}
+					}
+
+					break;
+				}
+
+				/* Identifiers and values */
+			default:
+				{
+					if (!comment) {
+						if (expr[pos] == '.' || isdigit(expr[pos])) {
+							/* Value */
+							start = pos;
+
+							/* Find digits before a period */
+							while (isdigit(expr[pos]))
+								pos++;
+
+							/* Find a period */
+							if (expr[pos] == '.')
+								pos++;
+
+							/* Find digits after a period */
+							while (isdigit(expr[pos]))
+								pos++;
+
+							/* pos is AFTER last item, back up */
+							pos--;
+
+							if (pass == 0)
+								found++;
+							else {
+								ilen = pos - start + 1;
+
+								/* Is the value to large */
+								if (ilen > EXPR_MAXIDENTSIZE) {
+									obj->starterr = start;
+									obj->enderr = pos;
+									exprFreeTokenList(list, found);
+									return EXPR_ERROR_BADIDENTIFIER;
+								}
+
+								/* Create value token */
+								strncpy(buf, expr + start, ilen);
+								buf[ilen] = '\0';
+
+								list[tpos].type = EXPR_TOKEN_VALUE;
+								list[tpos].start = start;
+								list[tpos].end = pos;
+								list[tpos].data.val = (EXPRTYPE) atof(buf);
+								tpos++;
+							}
+						} else if (expr[pos] == '_' || isalpha(expr[pos])) {
+							/* Identifier */
+							start = pos;
+
+							/* Find rest of identifier */
+							while (expr[pos] == '_' || isalnum(expr[pos]))
+								pos++;
+
+							/* pos is AFTER last item, back up */
+							pos--;
+
+							if (pass == 0)
+								found++;
+							else {
+								ilen = pos - start + 1;
+
+								/* Is the value to large */
+								if (ilen > EXPR_MAXIDENTSIZE) {
+									obj->starterr = start;
+									obj->enderr = pos;
+									exprFreeTokenList(list, found);
+									return EXPR_ERROR_BADIDENTIFIER;
+								}
+
+								/* Create value token */
+								strncpy(buf, expr + start, ilen);
+								buf[ilen] = '\0';
+
+								/* Allocate memory for identifier */
+								list[tpos].data.str = exprAllocMem(ilen + 1);
+								if (list[tpos].data.str == NULL) {
+									exprFreeTokenList(list, found);
+									return EXPR_ERROR_MEMORY;
+								}
+
+								list[tpos].type = EXPR_TOKEN_IDENTIFIER;
+								list[tpos].start = start;
+								list[tpos].end = pos;
+								strcpy(list[tpos].data.str, buf);
+								tpos++;
+							}
+						} else if (isspace(expr[pos])) {
+							/* Spaces are ignored, do nothing */
+						} else {
+							/* Unknown */
+							obj->starterr = obj->enderr = pos;
+							exprFreeTokenList(list, found);
+							return EXPR_ERROR_INVALIDCHAR;
+						}
+					}
+
+					break;
+				}
+			}
+		}
+
+		/* If pass is 0, allocate memory for next pass */
+		if (pass == 0) {
+			/* First, make sure all comments were ended */
+			if (comment)
+				comment = 0;
+
+			/* Make sure the expression is not empty */
+			if (found == 0)
+				return EXPR_ERROR_EMPTYEXPR;
+
+			/* Allocate memory for token list */
+			list = exprAllocMem(found * sizeof(exprToken));
+			if (list == NULL)
+				return EXPR_ERROR_MEMORY;
+
+			tpos = 0;
+		}
+	}
+
+	*count = found;
+	*tokens = list;
+	return EXPR_ERROR_NOERROR;
+}
 
 
 /* This is the main parsing routine */
-int exprParse(exprObj *obj, char *expr)
-    {
-    exprToken *tokens;
-    int count;
-    int err;
-    exprNode *tmp;
-
-    /* Make sure an object was passed */
-    if(obj == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Clear expression error position */
-    obj->starterr = obj->enderr = -1;
-
-    /* Have we already been parsed? */
-    if(obj->parsedbad != 0)
-        return EXPR_ERROR_ALREADYPARSEDBAD;
-
-    if(obj->parsedgood != 0)
-        return EXPR_ERROR_ALREADYPARSEDGOOD;
-
-    /* Make sure an expression was passed */
-    if(expr == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Create token list */
-    err = exprStringToTokenList(obj, expr, &tokens, &count);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-    
-    /* Create head pointer */
-    tmp = exprAllocNodes(1);
-    if(tmp == NULL)
-        {
-        exprFreeTokenList(tokens, count);
-        return EXPR_ERROR_MEMORY;
-        }
-
-    obj->headnode = tmp;
-
-    /* Call the multiparse routine to parse subexpressions */
-    err = exprMultiParse(obj, tmp, tokens, count);
-
-    /* Free the token list */
-    exprFreeTokenList(tokens, count);
-
-    /* successful parse? */
-    if(err == EXPR_ERROR_NOERROR)
-        {
-        obj->parsedgood = 1;
-        obj->parsedbad = 0;
-        }
-    else
-        {
-        obj->parsedbad = 1;
-        obj->parsedgood = 0;
-        }
+int exprParse(exprObj * obj, char *expr)
+{
+	exprToken *tokens;
+	int count;
+	int err;
+	exprNode *tmp;
+
+	/* Make sure an object was passed */
+	if (obj == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Clear expression error position */
+	obj->starterr = obj->enderr = -1;
+
+	/* Have we already been parsed? */
+	if (obj->parsedbad != 0)
+		return EXPR_ERROR_ALREADYPARSEDBAD;
+
+	if (obj->parsedgood != 0)
+		return EXPR_ERROR_ALREADYPARSEDGOOD;
+
+	/* Make sure an expression was passed */
+	if (expr == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Create token list */
+	err = exprStringToTokenList(obj, expr, &tokens, &count);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* Create head pointer */
+	tmp = exprAllocNodes(1);
+	if (tmp == NULL) {
+		exprFreeTokenList(tokens, count);
+		return EXPR_ERROR_MEMORY;
+	}
+
+	obj->headnode = tmp;
+
+	/* Call the multiparse routine to parse subexpressions */
+	err = exprMultiParse(obj, tmp, tokens, count);
+
+	/* Free the token list */
+	exprFreeTokenList(tokens, count);
+
+	/* successful parse? */
+	if (err == EXPR_ERROR_NOERROR) {
+		obj->parsedgood = 1;
+		obj->parsedbad = 0;
+	} else {
+		obj->parsedbad = 1;
+		obj->parsedgood = 0;
+	}
 
-    return err;
-    }
+	return err;
+}
 
 
 /* Parse the subexpressions, each ending with semicolons */
-int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count)
-    {
-    int pos, plevel, last;
-    int num, cur, err;
-    exprNode *tmp;
-
-    plevel = 0;
-    num = 0;
-    last = -1;
-
-    /* First count the number of arguments */
-    for(pos = 0; pos < count; pos++)
-        {
-        switch(tokens[pos].type)
-            {
-            case EXPR_TOKEN_OPAREN:
-                /* increase plevel */
-                plevel++;
-                break;
-
-            case EXPR_TOKEN_CPAREN:
-                /* decrease plevel */
-                plevel--;
-
-                if(plevel < 0)
-                    {
-                    obj->starterr = tokens[pos].start;
-                    obj->enderr = tokens[pos].end;
-                    return EXPR_ERROR_UNMATCHEDPAREN;
-                    }
-
-                break;
-
-            case EXPR_TOKEN_SEMICOLON:
-                if(plevel == 0)
-                    {
-                    if(last == pos - 1 || pos == 0)
-                        {
-                        /* last semicolon is before us or we are at the start */
-                        obj->starterr = tokens[pos].start;
-                        obj->enderr = tokens[pos].end;
-                        return EXPR_ERROR_SYNTAX;
-                        }
-                    else
-                        {
-                        /* last semicolon is not right before us */
-                        num++;
-                        }
-                    }
-                else
-                    {
-                    /* Semicolon should not be in a parenthesis */
-                    obj->starterr = tokens[pos].start;
-                    obj->enderr = tokens[pos].end;
-                    return EXPR_ERROR_SYNTAX;
-                    }
-
-                last = pos; /* update position of last semicolon */
-                break;
-            }
-        }
-
-    /* plevel should be zero now */
-    if(plevel != 0)
-        return EXPR_ERROR_UNMATCHEDPAREN;
-
-    /* the last character should be a semicolon */
-    if(last != pos - 1)
-        return EXPR_ERROR_MISSINGSEMICOLON;
-
-    /* Now we know how many arguments there are */
-
-    /* Allocate array of subnodes */
-    tmp = exprAllocNodes(num);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-    /* Set the current node's data */
-    node->type = EXPR_NODETYPE_MULTI;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = num;
-
-    /* now we parse each subexpression */
-    last = 0; /* Not for last semicolon, but for first char of subexpr */
-    cur = 0;
-
-    for(pos = 0; pos < count; pos++)
-        {
-        if(tokens[pos].type == EXPR_TOKEN_SEMICOLON)
-            {
-            /* Everything from last up to pos - 1 is a parameter */
-            err = exprInternalParse(obj, &(tmp[cur]), tokens, last, pos - 1);
-            if(err != EXPR_ERROR_NOERROR)
-                return err;
-
-            /* Update last position and current argument */
-            last = pos + 1;
-            cur++;
-            }
-        }
+int exprMultiParse(exprObj * obj, exprNode * node, exprToken * tokens, int count)
+{
+	int pos, plevel, last;
+	int num, cur, err;
+	exprNode *tmp;
+
+	plevel = 0;
+	num = 0;
+	last = -1;
+
+	/* First count the number of arguments */
+	for (pos = 0; pos < count; pos++) {
+		switch (tokens[pos].type) {
+		case EXPR_TOKEN_OPAREN:
+			/* increase plevel */
+			plevel++;
+			break;
+
+		case EXPR_TOKEN_CPAREN:
+			/* decrease plevel */
+			plevel--;
+
+			if (plevel < 0) {
+				obj->starterr = tokens[pos].start;
+				obj->enderr = tokens[pos].end;
+				return EXPR_ERROR_UNMATCHEDPAREN;
+			}
+
+			break;
+
+		case EXPR_TOKEN_SEMICOLON:
+			if (plevel == 0) {
+				if (last == pos - 1 || pos == 0) {
+					/* last semicolon is before us or we are at the start */
+					obj->starterr = tokens[pos].start;
+					obj->enderr = tokens[pos].end;
+					return EXPR_ERROR_SYNTAX;
+				} else {
+					/* last semicolon is not right before us */
+					num++;
+				}
+			} else {
+				/* Semicolon should not be in a parenthesis */
+				obj->starterr = tokens[pos].start;
+				obj->enderr = tokens[pos].end;
+				return EXPR_ERROR_SYNTAX;
+			}
+
+			last = pos;			/* update position of last semicolon */
+			break;
+		}
+	}
+
+	/* plevel should be zero now */
+	if (plevel != 0)
+		return EXPR_ERROR_UNMATCHEDPAREN;
+
+	/* the last character should be a semicolon */
+	if (last != pos - 1)
+		return EXPR_ERROR_MISSINGSEMICOLON;
+
+	/* Now we know how many arguments there are */
+
+	/* Allocate array of subnodes */
+	tmp = exprAllocNodes(num);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+	/* Set the current node's data */
+	node->type = EXPR_NODETYPE_MULTI;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = num;
+
+	/* now we parse each subexpression */
+	last = 0;					/* Not for last semicolon, but for first char of subexpr */
+	cur = 0;
+
+	for (pos = 0; pos < count; pos++) {
+		if (tokens[pos].type == EXPR_TOKEN_SEMICOLON) {
+			/* Everything from last up to pos - 1 is a parameter */
+			err = exprInternalParse(obj, &(tmp[cur]), tokens, last, pos - 1);
+			if (err != EXPR_ERROR_NOERROR)
+				return err;
+
+			/* Update last position and current argument */
+			last = pos + 1;
+			cur++;
+		}
+	}
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* This function parses each subnode and recurses if needed */
-int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
-    {
-    int pos;
-    int plevel = 0; /* Paren level */
-    int fgopen = -1; /* First paren group open index */
-    int fgclose = -1; /* First paren group close index */
-    int assignindex = -1; /* First = at plevel 0 for assignment */
-    int addsubindex = -1; /* Last + or - at plevel 0 for adding or subtracting */
-    int muldivindex = -1; /* Last * or / at plevel 0 for multiplying or dividing */
-    int expindex = -1; /* Last ^ fount at plevel 0 for exponents */
-    int posnegindex = -1; /* First +,- at plevel 0 for positive,negative */
-
-    /* Make sure some conditions are right */
-    if(start > end)
-        return EXPR_ERROR_UNKNOWN;
-
-    /* Scan the string for certain characters */
-    for(pos = start; pos <= end; pos++)
-        {
-        switch(tokens[pos].type)
-            {
-            case EXPR_TOKEN_OPAREN:
-                plevel++;
-
-                /* First group open? */
-                if(plevel == 1 && fgopen == -1)
-                    fgopen = pos;
-                break;
-
-            case EXPR_TOKEN_CPAREN:
-                plevel--;
-
-                /* First group close? */
-                if(plevel == 0 && fgclose == -1)
-                    fgclose = pos;
-
-                if(plevel < 0)
-                    {
-                    obj->starterr = tokens[pos].start;
-                    obj->enderr = tokens[pos].end;
-                    return EXPR_ERROR_UNMATCHEDPAREN;
-                    }
-                break;
-
-            case EXPR_TOKEN_EQUAL:
-                /* Assignment found */
-                if(plevel == 0)
-                    {
-                    if(assignindex == -1)
-                        assignindex = pos;
-                    }
-                break;
-
-            case EXPR_TOKEN_ASTERISK:
-            case EXPR_TOKEN_FSLASH:
-                /* Multiplication or division */
-                if(plevel == 0)
-                    muldivindex = pos;
-                break;
-
-            case EXPR_TOKEN_HAT:
-                /* Exponent */
-                if(plevel == 0)
-                    expindex = pos;
-                break;
-
-
-            case EXPR_TOKEN_PLUS:
-            case EXPR_TOKEN_HYPHEN:
-                /* Addition or positive or subtraction or negative*/
-                if(plevel == 0)
-                    {
-                    if(pos == start)
-                        {
-                        /* At the start area, positive/negative */
-                        if(posnegindex == -1)
-                            posnegindex = pos;
-                        }
-                    else
-                        {
-                        /* Not at start, check item in front */
-                        switch(tokens[pos - 1].type)
-                            {
-                            case EXPR_TOKEN_EQUAL: /* Equal sign */
-                            case EXPR_TOKEN_PLUS: /* Add/positive sign */
-                            case EXPR_TOKEN_HYPHEN: /* Subtract/negative sign */
-                            case EXPR_TOKEN_ASTERISK: /* Multiply sign */
-                            case EXPR_TOKEN_FSLASH: /* Divide sign */
-                            case EXPR_TOKEN_HAT: /* Exponent sign */
-
-                                /* After theses, it is positive/negative */
-                                if(posnegindex == -1)
-                                    posnegindex = pos;
-
-                                break;
-
-                            default:
-                                /* Otherwise it is addition/subtraction */
-                                addsubindex = pos;
-                                break;
-                            }
-                        }
-                    }
-                break;
-
-            }
-        }
-
-    /* plevel should now be zero */
-    if(plevel != 0)
-        return EXPR_ERROR_UNMATCHEDPAREN;
-
-    /* We must parse the data in a certain order to maintain the
-       correct order of operators at evaluation time */
-
-    /* First, take care of assignment */
-    if(assignindex != -1)
-        return exprInternalParseAssign(obj, node, tokens, start, end, assignindex);
-
-    /* Addition or subtraction is next */
-    if(addsubindex != -1)
-        {
-        if(tokens[addsubindex].type == EXPR_TOKEN_PLUS)
-            return exprInternalParseAdd(obj, node, tokens, start, end, addsubindex);
-        else
-            return exprInternalParseSub(obj, node, tokens, start, end, addsubindex);
-        }
-
-
-    /* Multiplycation or division */
-    if(muldivindex != -1)
-        {
-        if(tokens[muldivindex].type == EXPR_TOKEN_ASTERISK)
-            return exprInternalParseMul(obj, node, tokens, start, end, muldivindex);
-        else
-            return exprInternalParseDiv(obj, node, tokens, start, end, muldivindex);
-        }
-
-    /* Exponent */
-    if(expindex != -1)
-        return exprInternalParseExp(obj, node, tokens, start, end, expindex);
-
-    /* Negation */
-    if(posnegindex != -1)
-        return exprInternalParsePosNeg(obj, node, tokens, start, end, posnegindex);
-
-
-    /* Grouped parenthesis */
-    if(fgopen == start)
-        {
-        /* Closing paren. should be at the end */
-        if(fgclose == end)
-            {
-            /* Anything between them */
-            if(fgclose > fgopen + 1)
-                {
-                return exprInternalParse(obj, node, tokens, fgopen + 1, fgclose - 1);
-                }
-            else
-                {
-                /* Nothing between them */
-                obj->starterr = tokens[fgopen].start;
-                obj->enderr = tokens[fgclose].end;
-                return EXPR_ERROR_SYNTAX;
-                }
-            }
-        else /* Closing paren not at the end */
-            return EXPR_ERROR_SYNTAX;
-        }
-
-    /* Functions */
-    if(fgopen > start)
-        {
-        /* Closing paren should be at end */
-        if(fgclose == end)
-            {
-            return exprInternalParseFunction(obj, node, tokens, start, end, fgopen, fgclose);
-            }
-        else /* Closing paren not at end */
-            return EXPR_ERROR_SYNTAX;
-        }
-
-    /* If it was none of the above, it must be a variable or value */
-    return exprInternalParseVarVal(obj, node, tokens, start, end);
-    }
+int exprInternalParse(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end)
+{
+	int pos;
+	int plevel = 0;				/* Paren level */
+	int fgopen = -1;			/* First paren group open index */
+	int fgclose = -1;			/* First paren group close index */
+	int assignindex = -1;		/* First = at plevel 0 for assignment */
+	int addsubindex = -1;		/* Last + or - at plevel 0 for adding or subtracting */
+	int muldivindex = -1;		/* Last * or / at plevel 0 for multiplying or dividing */
+	int expindex = -1;			/* Last ^ fount at plevel 0 for exponents */
+	int posnegindex = -1;		/* First +,- at plevel 0 for positive,negative */
+
+	/* Make sure some conditions are right */
+	if (start > end)
+		return EXPR_ERROR_UNKNOWN;
+
+	/* Scan the string for certain characters */
+	for (pos = start; pos <= end; pos++) {
+		switch (tokens[pos].type) {
+		case EXPR_TOKEN_OPAREN:
+			plevel++;
+
+			/* First group open? */
+			if (plevel == 1 && fgopen == -1)
+				fgopen = pos;
+			break;
+
+		case EXPR_TOKEN_CPAREN:
+			plevel--;
+
+			/* First group close? */
+			if (plevel == 0 && fgclose == -1)
+				fgclose = pos;
+
+			if (plevel < 0) {
+				obj->starterr = tokens[pos].start;
+				obj->enderr = tokens[pos].end;
+				return EXPR_ERROR_UNMATCHEDPAREN;
+			}
+			break;
+
+		case EXPR_TOKEN_EQUAL:
+			/* Assignment found */
+			if (plevel == 0) {
+				if (assignindex == -1)
+					assignindex = pos;
+			}
+			break;
+
+		case EXPR_TOKEN_ASTERISK:
+		case EXPR_TOKEN_FSLASH:
+			/* Multiplication or division */
+			if (plevel == 0)
+				muldivindex = pos;
+			break;
+
+		case EXPR_TOKEN_HAT:
+			/* Exponent */
+			if (plevel == 0)
+				expindex = pos;
+			break;
+
+
+		case EXPR_TOKEN_PLUS:
+		case EXPR_TOKEN_HYPHEN:
+			/* Addition or positive or subtraction or negative */
+			if (plevel == 0) {
+				if (pos == start) {
+					/* At the start area, positive/negative */
+					if (posnegindex == -1)
+						posnegindex = pos;
+				} else {
+					/* Not at start, check item in front */
+					switch (tokens[pos - 1].type) {
+					case EXPR_TOKEN_EQUAL:	/* Equal sign */
+					case EXPR_TOKEN_PLUS:	/* Add/positive sign */
+					case EXPR_TOKEN_HYPHEN:	/* Subtract/negative sign */
+					case EXPR_TOKEN_ASTERISK:	/* Multiply sign */
+					case EXPR_TOKEN_FSLASH:	/* Divide sign */
+					case EXPR_TOKEN_HAT:	/* Exponent sign */
+
+						/* After theses, it is positive/negative */
+						if (posnegindex == -1)
+							posnegindex = pos;
+
+						break;
+
+					default:
+						/* Otherwise it is addition/subtraction */
+						addsubindex = pos;
+						break;
+					}
+				}
+			}
+			break;
+
+		}
+	}
+
+	/* plevel should now be zero */
+	if (plevel != 0)
+		return EXPR_ERROR_UNMATCHEDPAREN;
+
+	/* We must parse the data in a certain order to maintain the
+	   correct order of operators at evaluation time */
+
+	/* First, take care of assignment */
+	if (assignindex != -1)
+		return exprInternalParseAssign(obj, node, tokens, start, end, assignindex);
+
+	/* Addition or subtraction is next */
+	if (addsubindex != -1) {
+		if (tokens[addsubindex].type == EXPR_TOKEN_PLUS)
+			return exprInternalParseAdd(obj, node, tokens, start, end, addsubindex);
+		else
+			return exprInternalParseSub(obj, node, tokens, start, end, addsubindex);
+	}
+
+
+	/* Multiplycation or division */
+	if (muldivindex != -1) {
+		if (tokens[muldivindex].type == EXPR_TOKEN_ASTERISK)
+			return exprInternalParseMul(obj, node, tokens, start, end, muldivindex);
+		else
+			return exprInternalParseDiv(obj, node, tokens, start, end, muldivindex);
+	}
+
+	/* Exponent */
+	if (expindex != -1)
+		return exprInternalParseExp(obj, node, tokens, start, end, expindex);
+
+	/* Negation */
+	if (posnegindex != -1)
+		return exprInternalParsePosNeg(obj, node, tokens, start, end, posnegindex);
+
+
+	/* Grouped parenthesis */
+	if (fgopen == start) {
+		/* Closing paren. should be at the end */
+		if (fgclose == end) {
+			/* Anything between them */
+			if (fgclose > fgopen + 1) {
+				return exprInternalParse(obj, node, tokens, fgopen + 1, fgclose - 1);
+			} else {
+				/* Nothing between them */
+				obj->starterr = tokens[fgopen].start;
+				obj->enderr = tokens[fgclose].end;
+				return EXPR_ERROR_SYNTAX;
+			}
+		} else					/* Closing paren not at the end */
+			return EXPR_ERROR_SYNTAX;
+	}
+
+	/* Functions */
+	if (fgopen > start) {
+		/* Closing paren should be at end */
+		if (fgclose == end) {
+			return exprInternalParseFunction(obj, node, tokens, start, end, fgopen, fgclose);
+		} else					/* Closing paren not at end */
+			return EXPR_ERROR_SYNTAX;
+	}
+
+	/* If it was none of the above, it must be a variable or value */
+	return exprInternalParseVarVal(obj, node, tokens, start, end);
+}
 
 /* Function to parse an assignment node */
-int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    exprValList *l;
-    EXPRTYPE *addr;
-
-    /* Make sure the equal sign is not at the start or end */
-    if(index != start + 1 || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-    /* Make sure item before equal sign is an identifier */
-    if(tokens[index - 1].type != EXPR_TOKEN_IDENTIFIER)
-        {
-        obj->starterr = tokens[index - 1].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-    /* Create expression subnode */
-    tmp = exprAllocNodes(1);
-    if(tmp == NULL)
-        {
-        return EXPR_ERROR_MEMORY;
-        }
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_ASSIGN;
-    node->data.assign.node = tmp;
-
-
-    /*
-        The fast access method directly accesses the memory address
-        of the variable's value at evaluation time.  Because of this,
-        we must make sure the variable does exists in the variable list.
-    */
-
-    /* Make sure name is not a constant name */
-    l = exprGetConstList(obj);
-    if(l)
-        {
-        exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
-        if(addr)
-            {
-            obj->starterr = tokens[index - 1].start;
-            obj->enderr = tokens[index].end;
-            return EXPR_ERROR_CONSTANTASSIGN;
-            }
-        }
-
-    /* Get the variable list */
-    l = exprGetVarList(obj);
-    if(l == NULL)
-        return EXPR_ERROR_NOVARLIST;
-
-    /* Get variable address if already in the list */
-    exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
-    if(addr == NULL) /* Variable not in the list, add it */
-        {
-        exprValListAdd(l, tokens[index - 1].data.str, 0.0);
-
-        /* Try to get address again */
-        exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
-        if(addr == NULL) /* Could not add variable */
-            return EXPR_ERROR_MEMORY; /* Could not add variable to list */
-        }
-
-    node->data.assign.vaddr = addr;
-
-    /* Parse the subnode */
-    return exprInternalParse(obj, tmp, tokens, index + 1, end);
-    }
+int exprInternalParseAssign(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	exprValList *l;
+	EXPRTYPE *addr;
+
+	/* Make sure the equal sign is not at the start or end */
+	if (index != start + 1 || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+	/* Make sure item before equal sign is an identifier */
+	if (tokens[index - 1].type != EXPR_TOKEN_IDENTIFIER) {
+		obj->starterr = tokens[index - 1].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+	/* Create expression subnode */
+	tmp = exprAllocNodes(1);
+	if (tmp == NULL) {
+		return EXPR_ERROR_MEMORY;
+	}
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_ASSIGN;
+	node->data.assign.node = tmp;
+
+
+	/*
+	   The fast access method directly accesses the memory address
+	   of the variable's value at evaluation time.  Because of this,
+	   we must make sure the variable does exists in the variable list.
+	 */
+
+	/* Make sure name is not a constant name */
+	l = exprGetConstList(obj);
+	if (l) {
+		exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+		if (addr) {
+			obj->starterr = tokens[index - 1].start;
+			obj->enderr = tokens[index].end;
+			return EXPR_ERROR_CONSTANTASSIGN;
+		}
+	}
+
+	/* Get the variable list */
+	l = exprGetVarList(obj);
+	if (l == NULL)
+		return EXPR_ERROR_NOVARLIST;
+
+	/* Get variable address if already in the list */
+	exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+	if (addr == NULL) {			/* Variable not in the list, add it */
+		exprValListAdd(l, tokens[index - 1].data.str, 0.0);
+
+		/* Try to get address again */
+		exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+		if (addr == NULL)		/* Could not add variable */
+			return EXPR_ERROR_MEMORY;	/* Could not add variable to list */
+	}
+
+	node->data.assign.vaddr = addr;
+
+	/* Parse the subnode */
+	return exprInternalParse(obj, tmp, tokens, index + 1, end);
+}
 
 /* Function to parse an addition operator */
-int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    int err;
-
-    /* Make sure plus sign is at a good place */
-    if(index <= start || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-    /* Allocate space for 2 subnodes */
-    tmp = exprAllocNodes(2);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_ADD;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = 2;
-
-    /* parse the left side */
-    err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-
-    /* parse the right side */
-    return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
-    }
+int exprInternalParseAdd(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	int err;
+
+	/* Make sure plus sign is at a good place */
+	if (index <= start || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+	/* Allocate space for 2 subnodes */
+	tmp = exprAllocNodes(2);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_ADD;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = 2;
+
+	/* parse the left side */
+	err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* parse the right side */
+	return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+}
 
 /* Function to parse a subtraction operator */
-int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    int err;
-
-    /* Make sure minus sign is at a good place */
-    if(index <= start || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-    /* Allocate space for 2 subnodes */
-    tmp = exprAllocNodes(2);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_SUBTRACT;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = 2;
-    
-    /* parse the left side */
-    err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-
-    /* parse the right side */
-    return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
-    }
+int exprInternalParseSub(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	int err;
+
+	/* Make sure minus sign is at a good place */
+	if (index <= start || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+	/* Allocate space for 2 subnodes */
+	tmp = exprAllocNodes(2);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_SUBTRACT;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = 2;
+
+	/* parse the left side */
+	err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* parse the right side */
+	return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+}
 
 /* Function to parse a multiplication operator */
-int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    int err;
-
-    /* Make sure times sign is at a good place */
-    if(index <= start || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-
-    /* Allocate space for 2 subnodes */
-    tmp = exprAllocNodes(2);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_MULTIPLY;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = 2;
-
-    /* parse the left side */
-    err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-
-    /* parse the right side */
-    return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
-    }
+int exprInternalParseMul(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	int err;
+
+	/* Make sure times sign is at a good place */
+	if (index <= start || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+
+	/* Allocate space for 2 subnodes */
+	tmp = exprAllocNodes(2);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_MULTIPLY;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = 2;
+
+	/* parse the left side */
+	err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* parse the right side */
+	return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+}
 
 /* Function to parse a division operator */
-int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    int err;
-
-    /* Make sure slash sign is at a good place */
-    if(index <= start || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-
-    /* Allocate space for 2 subnodes */
-    tmp = exprAllocNodes(2);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_DIVIDE;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = 2;
-
-    /* parse the left side */
-    err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-
-    /* parse the right side */
-    return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
-    }
+int exprInternalParseDiv(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	int err;
+
+	/* Make sure slash sign is at a good place */
+	if (index <= start || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+
+	/* Allocate space for 2 subnodes */
+	tmp = exprAllocNodes(2);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_DIVIDE;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = 2;
+
+	/* parse the left side */
+	err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* parse the right side */
+	return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+}
 
 /* Function to parse an exponent operator */
-int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-    int err;
-
-    /* Make sure exponent sign is at a good place */
-    if(index <= start || index >= end)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-
-    /* Allocate space for 2 subnodes */
-    tmp = exprAllocNodes(2);
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-
-
-    /* Set the data */
-    node->type = EXPR_NODETYPE_EXPONENT;
-    node->data.oper.nodes = tmp;
-    node->data.oper.nodecount = 2;
-
-    /* parse the left side */
-    err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
-    if(err != EXPR_ERROR_NOERROR)
-        return err;
-
-    /* parse the right side */
-    return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
-    }
+int exprInternalParseExp(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+	int err;
+
+	/* Make sure exponent sign is at a good place */
+	if (index <= start || index >= end) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+
+	/* Allocate space for 2 subnodes */
+	tmp = exprAllocNodes(2);
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+
+	/* Set the data */
+	node->type = EXPR_NODETYPE_EXPONENT;
+	node->data.oper.nodes = tmp;
+	node->data.oper.nodecount = 2;
+
+	/* parse the left side */
+	err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+	if (err != EXPR_ERROR_NOERROR)
+		return err;
+
+	/* parse the right side */
+	return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+}
 
 /* Function to parse for positive and negative */
-int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
-    {
-    exprNode *tmp;
-
-    /* Position should be the same as start */
-    if(index != start)
-        {
-        obj->starterr = tokens[index].start;
-        obj->enderr = tokens[index].end;
-        return EXPR_ERROR_UNKNOWN;
-        }
-
-    /* If it is a positive, just parse the internal of it */
-    if(tokens[index].type == EXPR_TOKEN_PLUS)
-        return exprInternalParse(obj, node, tokens, index + 1, end);
-    else
-        {
-        /* Allocate subnode */
-        tmp = exprAllocNodes(1);
-        if(tmp == NULL)
-            return EXPR_ERROR_NOERROR;
-
-
-        /* Set data */
-        node->type = EXPR_NODETYPE_NEGATE;
-        node->data.oper.nodes = tmp;
-        node->data.oper.nodecount = 1;
-
-        /* Parse the subnode */
-        return exprInternalParse(obj, tmp, tokens, index + 1, end);
-        }
-    }
+int exprInternalParsePosNeg(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int index)
+{
+	exprNode *tmp;
+
+	/* Position should be the same as start */
+	if (index != start) {
+		obj->starterr = tokens[index].start;
+		obj->enderr = tokens[index].end;
+		return EXPR_ERROR_UNKNOWN;
+	}
+
+	/* If it is a positive, just parse the internal of it */
+	if (tokens[index].type == EXPR_TOKEN_PLUS)
+		return exprInternalParse(obj, node, tokens, index + 1, end);
+	else {
+		/* Allocate subnode */
+		tmp = exprAllocNodes(1);
+		if (tmp == NULL)
+			return EXPR_ERROR_NOERROR;
+
+
+		/* Set data */
+		node->type = EXPR_NODETYPE_NEGATE;
+		node->data.oper.nodes = tmp;
+		node->data.oper.nodecount = 1;
+
+		/* Parse the subnode */
+		return exprInternalParse(obj, tmp, tokens, index + 1, end);
+	}
+}
 
 /* Function will parse a call to a function */
-int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2)
-    {
-    int pos;
-    int num, cur;
-    int refnum, refcur;
-    int plevel = 0;
-    int lv, err;
-    exprNode *tmp;
-    exprFuncType fptr;
-    int argmin, argmax;
-    int refargmin, refargmax;
-    int type;
-    exprFuncList *l;
-    exprValList *vars;
-    EXPRTYPE *addr;
-    EXPRTYPE **reftmp;
-
-    /* We should have a function list */
-    l = exprGetFuncList(obj);
-    if(l == NULL)
-        return EXPR_ERROR_NOSUCHFUNCTION;
-
-    /* check paren. location */
-    if(p2 <= p1)
-        return EXPR_ERROR_SYNTAX;
-
-    /* second paren. should not be after the end */
-    if(p2 > end)
-        return EXPR_ERROR_SYNTAX;
-
-    /* Item before parenthesis should be an identifier */
-    if(tokens[p1 - 1].type != EXPR_TOKEN_IDENTIFIER)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p1].end;
-        return EXPR_ERROR_SYNTAX;
-        }
-
-
-    /* Look up the function */
-    err = exprFuncListGet(l, tokens[p1 - 1].data.str, &fptr, &type, &argmin, &argmax, &refargmin, &refargmax);
-    if(err != EXPR_ERROR_NOERROR)
-        {
-        if(err == EXPR_ERROR_NOTFOUND)
-            {
-            obj->starterr = tokens[p1 - 1].start;
-            obj->enderr = tokens[p1 - 1].end;
-            return EXPR_ERROR_NOSUCHFUNCTION;
-            }
-        else
-            return err;
-        }
-
-    /* Make sure the function exists */
-    if(fptr == NULL && type == 0)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p1 - 1].end;
-        return EXPR_ERROR_NOSUCHFUNCTION;
-        }
-
-    /* Count arguments */
-    if(p2 == p1 + 1)
-        {
-        num = 0;
-        refnum = 0;
-        }
-    else
-        {
-        num = 1;
-        refnum = 0;
-
-
-        /* count commas */
-        for(pos = p1 + 1; pos < p2; pos++)
-            {
-            switch(tokens[pos].type)
-                {
-                case EXPR_TOKEN_OPAREN:
-                    plevel++;
-                    break;
-
-                case EXPR_TOKEN_CPAREN:
-                    plevel--;
-                    if(plevel < 0)
-                        {
-                        obj->starterr = tokens[pos].start;
-                        obj->enderr = tokens[pos].end;
-                        return EXPR_ERROR_UNMATCHEDPAREN;
-                        }
-                    break;
-
-                case EXPR_TOKEN_COMMA:
-                    /* Found comma */
-                    if(plevel == 0)
-                        num++;
-                    break;
-
-                case EXPR_TOKEN_AMPERSAND:
-                    /* Found reference mark */
-                    if(plevel == 0)
-                        {
-                        /* This may only occur after the open parenthesis or comma */
-                        if(tokens[pos - 1].type == EXPR_TOKEN_OPAREN || tokens[pos - 1].type == EXPR_TOKEN_COMMA)
-                            refnum++;
-                        else
-                            return EXPR_ERROR_SYNTAX;
-                        }
-                    break;
-                }
-            }
-
-        /* plevel should be zero */
-        if(plevel != 0)
-            return EXPR_ERROR_UNMATCHEDPAREN;
-        }
-
-    /* We now have the number of total arguments and
-       number of ref arguments.  Get number of normal
-       arguments */
-    num = num - refnum;
-
-    /* Make sure number of arguments is correct */
-    /* Here we make sure the limits are greater
-       or equal to zero because any negative number
-       could be used to specify no limit */
-    if(argmin >= 0 && num < argmin)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p2].end;
-        return EXPR_ERROR_BADNUMBERARGUMENTS;
-        }
-
-    if(argmax >= 0 && num > argmax)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p2].end;
-        return EXPR_ERROR_BADNUMBERARGUMENTS;
-        }
-
-    if(refargmin >= 0 && refnum < refargmin)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p2].end;
-        return EXPR_ERROR_BADNUMBERARGUMENTS;
-        }
-
-    if(refargmax >= 0 && refnum > refargmax)
-        {
-        obj->starterr = tokens[p1 - 1].start;
-        obj->enderr = tokens[p2].end;
-        return EXPR_ERROR_BADNUMBERARGUMENTS;
-        }
-
-    /* Set tmp to null in case of no arguments */
-    tmp = NULL;
-    reftmp = NULL;
-
-    if(num > 0)
-        {
-        /* Allocate subnodes */
-        tmp = exprAllocNodes(num);
-        if(tmp == NULL)
-            return EXPR_ERROR_MEMORY;
-        }
-
-    if(refnum > 0)
-        {
-        /* Allocate ref pointers */
-        reftmp = exprAllocMem(sizeof(EXPRTYPE*) * refnum);
-        if(reftmp == NULL)
-            {
-            exprFreeMem(tmp);
-            return EXPR_ERROR_MEMORY;
-            }
-        }
-
-
-
-    /* Set this node's data */
-    node->type = EXPR_NODETYPE_FUNCTION;
-    node->data.function.fptr = fptr;
-    node->data.function.nodecount = num;
-    node->data.function.nodes = tmp;
-    node->data.function.refcount = refnum;
-    node->data.function.refs = reftmp;
-    node->data.function.type = type;
-
-    /* parse each subnode */
-    if(num + refnum > 0)
-        {
-        plevel = 0;
-        cur = 0;
-        refcur = 0;
-        lv = p1 + 1;
-
-        /* look for commas if more than 1 arg */
-        if(num + refnum > 1)
-            {
-            for(pos = p1 + 1; pos < p2; pos++)
-                {
-                switch(tokens[pos].type)
-                    {
-                    case EXPR_TOKEN_OPAREN:
-                        plevel++;
-                        break;
-
-                    case EXPR_TOKEN_CPAREN:
-                        plevel--;
-                        break; /* Already checked paren nesting above */
-
-                    case EXPR_TOKEN_COMMA:
-                        /* Found comma */
-                        if(plevel == 0)
-                            {
-                            /* parse inside */
-                            if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
-                                {
-                                if(lv != pos - 2)
-                                    {
-                                    obj->starterr = tokens[lv].start;
-                                    obj->enderr = tokens[pos].end;
-                                    return EXPR_ERROR_SYNTAX;
-                                    }
-
-                                /* It is a reference */
-                                if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
-                                    {
-                                    obj->starterr = tokens[lv].start;
-                                    obj->enderr = tokens[lv + 1].end;
-                                    return EXPR_ERROR_SYNTAX;
-                                    }
-
-                                
-                                /* Make sure it is not a constant */
-                                vars = exprGetConstList(obj);
-                                if(vars)
-                                    {
-                                    exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-                                    if(addr)
-                                        {
-                                        obj->starterr = tokens[lv].start;
-                                        obj->enderr = tokens[lv + 1].start;
-                                        return EXPR_ERROR_REFCONSTANT;
-                                        }
-                                    }
-
-                                /* Get variable list */
-                                vars = exprGetVarList(obj);
-                                if(vars == NULL)
-                                    return EXPR_ERROR_NOVARLIST;
-
-                                /* Get variable address */
-                                exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-                                if(addr == NULL)
-                                    {
-                                    /* Add variable to list */
-                                    exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
-
-                                    /* Try to get address again */
-                                    exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-                                    if(addr == NULL)
-                                        return EXPR_ERROR_MEMORY; /* Could not add variable */
-                                    }
-
-                                /* Set reference item */
-                                reftmp[refcur] = addr;
-
-                                /* increase ref arg number and lv position*/
-                                refcur++;
-                                lv = pos + 1;
-                                }
-                            else
-                                {
-                                err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, pos - 1);
-                                if(err != EXPR_ERROR_NOERROR)
-                                    return err;
-
-                                /* increase arg number and lv position*/
-                                lv = pos + 1;
-                                cur++;
-                                }
-                            }
-                        break;
-                    }
-                }
-            }
-
-        /* lv should point after the last comma, or open paren. if only 1 arg */
-        if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
-            {
-            if(lv != p2 - 2)
-                {
-                obj->starterr = tokens[lv].start;
-                obj->enderr = tokens[p2].end; 
-                return EXPR_ERROR_SYNTAX;
-                }
-
-            /* It is a reference */
-            if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
-                {
-                obj->starterr = tokens[lv].start;
-                obj->enderr = tokens[lv + 1].end;
-                return EXPR_ERROR_SYNTAX;
-                }
-            
-            /* Make sure it is not a constant */
-            vars = exprGetConstList(obj);
-            if(vars)
-                {
-                exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-                if(addr)
-                    {
-                    obj->starterr = tokens[lv].start;
-                    obj->enderr = tokens[lv + 1].start;
-                    return EXPR_ERROR_REFCONSTANT;
-                    }
-                }
-
-            /* Get variable list */
-            vars = exprGetVarList(obj);
-            if(vars == NULL)
-                return EXPR_ERROR_NOVARLIST;
-
-            /* Get variable address */
-            exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-            if(addr == NULL)
-                {
-                /* Add variable to list */
-                exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
-
-                /* Try to get address again */
-                exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
-                if(addr == NULL)
-                    return EXPR_ERROR_MEMORY; /* Could not add variable */
-                }
-
-            /* Set reference item */
-            reftmp[refcur] = addr;
-            }
-        else
-            {
-            err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, p2 - 1);
-            if(err != EXPR_ERROR_NOERROR)
-                return err;
-            }
-        }
+int exprInternalParseFunction(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end, int p1, int p2)
+{
+	int pos;
+	int num, cur;
+	int refnum, refcur;
+	int plevel = 0;
+	int lv, err;
+	exprNode *tmp;
+	exprFuncType fptr;
+	int argmin, argmax;
+	int refargmin, refargmax;
+	int type;
+	exprFuncList *l;
+	exprValList *vars;
+	EXPRTYPE *addr;
+	EXPRTYPE **reftmp;
+
+	/* We should have a function list */
+	l = exprGetFuncList(obj);
+	if (l == NULL)
+		return EXPR_ERROR_NOSUCHFUNCTION;
+
+	/* check paren. location */
+	if (p2 <= p1)
+		return EXPR_ERROR_SYNTAX;
+
+	/* second paren. should not be after the end */
+	if (p2 > end)
+		return EXPR_ERROR_SYNTAX;
+
+	/* Item before parenthesis should be an identifier */
+	if (tokens[p1 - 1].type != EXPR_TOKEN_IDENTIFIER) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p1].end;
+		return EXPR_ERROR_SYNTAX;
+	}
+
+
+	/* Look up the function */
+	err = exprFuncListGet(l, tokens[p1 - 1].data.str, &fptr, &type, &argmin, &argmax, &refargmin, &refargmax);
+	if (err != EXPR_ERROR_NOERROR) {
+		if (err == EXPR_ERROR_NOTFOUND) {
+			obj->starterr = tokens[p1 - 1].start;
+			obj->enderr = tokens[p1 - 1].end;
+			return EXPR_ERROR_NOSUCHFUNCTION;
+		} else
+			return err;
+	}
+
+	/* Make sure the function exists */
+	if (fptr == NULL && type == 0) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p1 - 1].end;
+		return EXPR_ERROR_NOSUCHFUNCTION;
+	}
+
+	/* Count arguments */
+	if (p2 == p1 + 1) {
+		num = 0;
+		refnum = 0;
+	} else {
+		num = 1;
+		refnum = 0;
+
+
+		/* count commas */
+		for (pos = p1 + 1; pos < p2; pos++) {
+			switch (tokens[pos].type) {
+			case EXPR_TOKEN_OPAREN:
+				plevel++;
+				break;
+
+			case EXPR_TOKEN_CPAREN:
+				plevel--;
+				if (plevel < 0) {
+					obj->starterr = tokens[pos].start;
+					obj->enderr = tokens[pos].end;
+					return EXPR_ERROR_UNMATCHEDPAREN;
+				}
+				break;
+
+			case EXPR_TOKEN_COMMA:
+				/* Found comma */
+				if (plevel == 0)
+					num++;
+				break;
+
+			case EXPR_TOKEN_AMPERSAND:
+				/* Found reference mark */
+				if (plevel == 0) {
+					/* This may only occur after the open parenthesis or comma */
+					if (tokens[pos - 1].type == EXPR_TOKEN_OPAREN || tokens[pos - 1].type == EXPR_TOKEN_COMMA)
+						refnum++;
+					else
+						return EXPR_ERROR_SYNTAX;
+				}
+				break;
+			}
+		}
+
+		/* plevel should be zero */
+		if (plevel != 0)
+			return EXPR_ERROR_UNMATCHEDPAREN;
+	}
+
+	/* We now have the number of total arguments and
+	   number of ref arguments.  Get number of normal
+	   arguments */
+	num = num - refnum;
+
+	/* Make sure number of arguments is correct */
+	/* Here we make sure the limits are greater
+	   or equal to zero because any negative number
+	   could be used to specify no limit */
+	if (argmin >= 0 && num < argmin) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p2].end;
+		return EXPR_ERROR_BADNUMBERARGUMENTS;
+	}
+
+	if (argmax >= 0 && num > argmax) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p2].end;
+		return EXPR_ERROR_BADNUMBERARGUMENTS;
+	}
+
+	if (refargmin >= 0 && refnum < refargmin) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p2].end;
+		return EXPR_ERROR_BADNUMBERARGUMENTS;
+	}
+
+	if (refargmax >= 0 && refnum > refargmax) {
+		obj->starterr = tokens[p1 - 1].start;
+		obj->enderr = tokens[p2].end;
+		return EXPR_ERROR_BADNUMBERARGUMENTS;
+	}
+
+	/* Set tmp to null in case of no arguments */
+	tmp = NULL;
+	reftmp = NULL;
+
+	if (num > 0) {
+		/* Allocate subnodes */
+		tmp = exprAllocNodes(num);
+		if (tmp == NULL)
+			return EXPR_ERROR_MEMORY;
+	}
+
+	if (refnum > 0) {
+		/* Allocate ref pointers */
+		reftmp = exprAllocMem(sizeof(EXPRTYPE *) * refnum);
+		if (reftmp == NULL) {
+			exprFreeMem(tmp);
+			return EXPR_ERROR_MEMORY;
+		}
+	}
+
+
+
+	/* Set this node's data */
+	node->type = EXPR_NODETYPE_FUNCTION;
+	node->data.function.fptr = fptr;
+	node->data.function.nodecount = num;
+	node->data.function.nodes = tmp;
+	node->data.function.refcount = refnum;
+	node->data.function.refs = reftmp;
+	node->data.function.type = type;
+
+	/* parse each subnode */
+	if (num + refnum > 0) {
+		plevel = 0;
+		cur = 0;
+		refcur = 0;
+		lv = p1 + 1;
+
+		/* look for commas if more than 1 arg */
+		if (num + refnum > 1) {
+			for (pos = p1 + 1; pos < p2; pos++) {
+				switch (tokens[pos].type) {
+				case EXPR_TOKEN_OPAREN:
+					plevel++;
+					break;
+
+				case EXPR_TOKEN_CPAREN:
+					plevel--;
+					break;		/* Already checked paren nesting above */
+
+				case EXPR_TOKEN_COMMA:
+					/* Found comma */
+					if (plevel == 0) {
+						/* parse inside */
+						if (tokens[lv].type == EXPR_TOKEN_AMPERSAND) {
+							if (lv != pos - 2) {
+								obj->starterr = tokens[lv].start;
+								obj->enderr = tokens[pos].end;
+								return EXPR_ERROR_SYNTAX;
+							}
+
+							/* It is a reference */
+							if (tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER) {
+								obj->starterr = tokens[lv].start;
+								obj->enderr = tokens[lv + 1].end;
+								return EXPR_ERROR_SYNTAX;
+							}
+
+
+							/* Make sure it is not a constant */
+							vars = exprGetConstList(obj);
+							if (vars) {
+								exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+								if (addr) {
+									obj->starterr = tokens[lv].start;
+									obj->enderr = tokens[lv + 1].start;
+									return EXPR_ERROR_REFCONSTANT;
+								}
+							}
+
+							/* Get variable list */
+							vars = exprGetVarList(obj);
+							if (vars == NULL)
+								return EXPR_ERROR_NOVARLIST;
+
+							/* Get variable address */
+							exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+							if (addr == NULL) {
+								/* Add variable to list */
+								exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
+
+								/* Try to get address again */
+								exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+								if (addr == NULL)
+									return EXPR_ERROR_MEMORY;	/* Could not add variable */
+							}
+
+							/* Set reference item */
+							reftmp[refcur] = addr;
+
+							/* increase ref arg number and lv position */
+							refcur++;
+							lv = pos + 1;
+						} else {
+							err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, pos - 1);
+							if (err != EXPR_ERROR_NOERROR)
+								return err;
+
+							/* increase arg number and lv position */
+							lv = pos + 1;
+							cur++;
+						}
+					}
+					break;
+				}
+			}
+		}
+
+		/* lv should point after the last comma, or open paren. if only 1 arg */
+		if (tokens[lv].type == EXPR_TOKEN_AMPERSAND) {
+			if (lv != p2 - 2) {
+				obj->starterr = tokens[lv].start;
+				obj->enderr = tokens[p2].end;
+				return EXPR_ERROR_SYNTAX;
+			}
+
+			/* It is a reference */
+			if (tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER) {
+				obj->starterr = tokens[lv].start;
+				obj->enderr = tokens[lv + 1].end;
+				return EXPR_ERROR_SYNTAX;
+			}
+
+			/* Make sure it is not a constant */
+			vars = exprGetConstList(obj);
+			if (vars) {
+				exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+				if (addr) {
+					obj->starterr = tokens[lv].start;
+					obj->enderr = tokens[lv + 1].start;
+					return EXPR_ERROR_REFCONSTANT;
+				}
+			}
+
+			/* Get variable list */
+			vars = exprGetVarList(obj);
+			if (vars == NULL)
+				return EXPR_ERROR_NOVARLIST;
+
+			/* Get variable address */
+			exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+			if (addr == NULL) {
+				/* Add variable to list */
+				exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
+
+				/* Try to get address again */
+				exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+				if (addr == NULL)
+					return EXPR_ERROR_MEMORY;	/* Could not add variable */
+			}
+
+			/* Set reference item */
+			reftmp[refcur] = addr;
+		} else {
+			err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, p2 - 1);
+			if (err != EXPR_ERROR_NOERROR)
+				return err;
+		}
+	}
 
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Parse a variable or value */
-int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
-    {
-    exprValList *l;
-    EXPRTYPE *addr;
-
-
-    /* Make sure positions are correct */
-    if(start != end)
-        {
-        return EXPR_ERROR_UNKNOWN;
-        }
-    
-    
-    /* Are we an identifier */
-    if(tokens[start].type == EXPR_TOKEN_IDENTIFIER)
-        {
-        /* we are an identifier */
-
-        /* check to see if it is a constant */
-        l = exprGetConstList(obj);
-        if(l != NULL)
-            {
-            if(exprValListGetAddress(l, tokens[start].data.str, &addr) == EXPR_ERROR_NOERROR)
-                {
-                /* We found it in the constant list */
-
-                /*
-                    Treat is like a variable node so application can change
-                    constant value and it will reflect in expression
-                */
-
-                node->type = EXPR_NODETYPE_VARIABLE;
-                node->data.variable.vaddr = addr;
-                return EXPR_ERROR_NOERROR;
-                }
-            }
-
-        /* Not found in the constant list, so it must be a variable */
-
-        /* Set node type */
-        node->type = EXPR_NODETYPE_VARIABLE;
-
-        /*
-            The fast access method directly accesses the memory address
-            of the variable's value at evaluation time.  Because of this,
-            we must make sure the variable does exists in the variable list.
-        */
-
-        /* Get the variable list */
-        l = exprGetVarList(obj);
-        if(l == NULL)
-            return EXPR_ERROR_NOVARLIST;
-
-        /* Get variable address if already in the list */
-        exprValListGetAddress(l, tokens[start].data.str, &addr);
-        if(addr == NULL) /* Variable not in the list, add it */
-            {
-            exprValListAdd(l, tokens[start].data.str, 0.0);
-
-            /* Try to get address again */
-            exprValListGetAddress(l, tokens[start].data.str, &addr);
-            if(addr == NULL) /* Could not add variable */
-                return EXPR_ERROR_MEMORY; /* Could not add variable to list */
-            }
-
-        node->data.variable.vaddr = addr;
-
-        return EXPR_ERROR_NOERROR;
-        }
-    else if(tokens[start].type == EXPR_TOKEN_VALUE)
-        {
-        /* we are a value */
-        node->type = EXPR_NODETYPE_VALUE;
-        node->data.value.value = tokens[start].data.val;
-        return EXPR_ERROR_NOERROR;
-        }
-    else
-        {
-        obj->starterr = tokens[start].start;
-        obj->enderr = tokens[end].end;
-        return EXPR_ERROR_UNKNOWN;
-        }
-    }
+int exprInternalParseVarVal(exprObj * obj, exprNode * node, exprToken * tokens, int start, int end)
+{
+	exprValList *l;
+	EXPRTYPE *addr;
+
+
+	/* Make sure positions are correct */
+	if (start != end) {
+		return EXPR_ERROR_UNKNOWN;
+	}
+
+
+	/* Are we an identifier */
+	if (tokens[start].type == EXPR_TOKEN_IDENTIFIER) {
+		/* we are an identifier */
+
+		/* check to see if it is a constant */
+		l = exprGetConstList(obj);
+		if (l != NULL) {
+			if (exprValListGetAddress(l, tokens[start].data.str, &addr) == EXPR_ERROR_NOERROR) {
+				/* We found it in the constant list */
+
+				/*
+				   Treat is like a variable node so application can change
+				   constant value and it will reflect in expression
+				 */
+
+				node->type = EXPR_NODETYPE_VARIABLE;
+				node->data.variable.vaddr = addr;
+				return EXPR_ERROR_NOERROR;
+			}
+		}
+
+		/* Not found in the constant list, so it must be a variable */
+
+		/* Set node type */
+		node->type = EXPR_NODETYPE_VARIABLE;
+
+		/*
+		   The fast access method directly accesses the memory address
+		   of the variable's value at evaluation time.  Because of this,
+		   we must make sure the variable does exists in the variable list.
+		 */
+
+		/* Get the variable list */
+		l = exprGetVarList(obj);
+		if (l == NULL)
+			return EXPR_ERROR_NOVARLIST;
+
+		/* Get variable address if already in the list */
+		exprValListGetAddress(l, tokens[start].data.str, &addr);
+		if (addr == NULL) {		/* Variable not in the list, add it */
+			exprValListAdd(l, tokens[start].data.str, 0.0);
+
+			/* Try to get address again */
+			exprValListGetAddress(l, tokens[start].data.str, &addr);
+			if (addr == NULL)	/* Could not add variable */
+				return EXPR_ERROR_MEMORY;	/* Could not add variable to list */
+		}
+
+		node->data.variable.vaddr = addr;
+
+		return EXPR_ERROR_NOERROR;
+	} else if (tokens[start].type == EXPR_TOKEN_VALUE) {
+		/* we are a value */
+		node->type = EXPR_NODETYPE_VALUE;
+		node->data.value.value = tokens[start].data.val;
+		return EXPR_ERROR_NOERROR;
+	} else {
+		obj->starterr = tokens[start].start;
+		obj->enderr = tokens[end].end;
+		return EXPR_ERROR_UNKNOWN;
+	}
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprutil.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprutil.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprutil.c	Tue May 27 07:24:06 2008
@@ -15,29 +15,27 @@
 
 /* Return the version number */
 void exprGetVersion(int *major, int *minor)
-    {
-    *major = EXPR_VERSIONMAJOR;
-    *minor = EXPR_VERSIONMINOR;
-    }
+{
+	*major = EXPR_VERSIONMAJOR;
+	*minor = EXPR_VERSIONMINOR;
+}
 
 /* This utility function determines if an identifier is valid */
 int exprValidIdent(char *name)
-    {
-    if(name == NULL) /* Null string */
-        return 0;
-
-    /* First must be letter or underscore */
-    if(isalpha(*name) || *name == '_')
-        name++; /* Point to next letter */
-    else
-        return 0; /* Not letter or underscore, maybe empty*/
-
-    /* others can be letter, number, or underscore */
-    while(isalnum(*name) || *name == '_')
-        name++;
-
-    /* When the while breaks out, we should be at the end */
-    return (*name == '\0') ? 1 : 0;
-    }
-
-
+{
+	if (name == NULL)			/* Null string */
+		return 0;
+
+	/* First must be letter or underscore */
+	if (isalpha(*name) || *name == '_')
+		name++;					/* Point to next letter */
+	else
+		return 0;				/* Not letter or underscore, maybe empty */
+
+	/* others can be letter, number, or underscore */
+	while (isalnum(*name) || *name == '_')
+		name++;
+
+	/* When the while breaks out, we should be at the end */
+	return (*name == '\0') ? 1 : 0;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprval.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprval.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/exprval.c	Tue May 27 07:24:06 2008
@@ -15,381 +15,365 @@
 
 
 /* Internal functions */
-static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr);
-static void exprValListFreeData(exprVal *val);
-static void exprValListResetData(exprVal *val);
+static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE * addr);
+static void exprValListFreeData(exprVal * val);
+static void exprValListResetData(exprVal * val);
 
 /* This function creates the value list, */
-int exprValListCreate(exprValList **vlist)
-    {
-    exprValList *tmp;
+int exprValListCreate(exprValList ** vlist)
+{
+	exprValList *tmp;
 
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
 
-    *vlist = NULL; /* Set to NULL initially */
+	*vlist = NULL;				/* Set to NULL initially */
 
-    tmp = exprAllocMem(sizeof(exprValList));
+	tmp = exprAllocMem(sizeof(exprValList));
 
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY; /* Could not allocate memory */
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;	/* Could not allocate memory */
 
-    /* Update pointer */
-    *vlist = tmp;
+	/* Update pointer */
+	*vlist = tmp;
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Add a value to the list */
-int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val)
-    {
-    exprVal *tmp;
-    exprVal *cur;
-    int result;
-
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Make sure the name is valid */
-    if(!exprValidIdent(name))
-        return EXPR_ERROR_BADIDENTIFIER;
-
-    if(vlist->head == NULL)
-        {
-        /* Create the node right here */
-        tmp = exprCreateVal(name, val, NULL);
-
-        if(tmp == NULL)
-            return EXPR_ERROR_MEMORY;
-
-        vlist->head = tmp;
-        return EXPR_ERROR_NOERROR;
-        }
-
-    /* See if already exists */
-    cur = vlist->head;
-
-    while(cur)
-        {
-        result = strcmp(name, cur->vname);
-        
-        if(result == 0)
-            return EXPR_ERROR_ALREADYEXISTS;
-            
-        cur = cur->next;
-        }
-        
-    /* We did not find it, create it and add it to the beginning */
-    tmp = exprCreateVal(name, val, NULL);
-
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-        
-    tmp->next = vlist->head;
-    vlist->head = tmp;
-    
-    return EXPR_ERROR_NOERROR;
-    }
-    
+int exprValListAdd(exprValList * vlist, char *name, EXPRTYPE val)
+{
+	exprVal *tmp;
+	exprVal *cur;
+	int result;
+
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Make sure the name is valid */
+	if (!exprValidIdent(name))
+		return EXPR_ERROR_BADIDENTIFIER;
+
+	if (vlist->head == NULL) {
+		/* Create the node right here */
+		tmp = exprCreateVal(name, val, NULL);
+
+		if (tmp == NULL)
+			return EXPR_ERROR_MEMORY;
+
+		vlist->head = tmp;
+		return EXPR_ERROR_NOERROR;
+	}
+
+	/* See if already exists */
+	cur = vlist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->vname);
+
+		if (result == 0)
+			return EXPR_ERROR_ALREADYEXISTS;
+
+		cur = cur->next;
+	}
+
+	/* We did not find it, create it and add it to the beginning */
+	tmp = exprCreateVal(name, val, NULL);
+
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+	tmp->next = vlist->head;
+	vlist->head = tmp;
+
+	return EXPR_ERROR_NOERROR;
+}
+
 /* Set a value in the list */
-int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val)
-    {
-    exprVal *cur;
-    int result;
-
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    if(name == NULL || name[0] == '\0')
-        return EXPR_ERROR_NOTFOUND;
-
-    /* Find and set it */
-    cur = vlist->head;
-
-    while(cur)
-        {
-        result = strcmp(name, cur->vname);
-        
-        if(result == 0)
-            {
-            if(cur->vptr)
-                *(cur->vptr) = val;
-            else
-                cur->vval = val;
-                
-            return EXPR_ERROR_NOERROR;                
-            }
-            
-        cur = cur->next;
-        }
-        
-    return EXPR_ERROR_NOTFOUND;
-    }    
+int exprValListSet(exprValList * vlist, char *name, EXPRTYPE val)
+{
+	exprVal *cur;
+	int result;
+
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	if (name == NULL || name[0] == '\0')
+		return EXPR_ERROR_NOTFOUND;
+
+	/* Find and set it */
+	cur = vlist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->vname);
+
+		if (result == 0) {
+			if (cur->vptr)
+				*(cur->vptr) = val;
+			else
+				cur->vval = val;
+
+			return EXPR_ERROR_NOERROR;
+		}
+
+		cur = cur->next;
+	}
+
+	return EXPR_ERROR_NOTFOUND;
+}
 
 /* Get the value from a list  */
-int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val)
-    {
-    exprVal *cur;
-    int result;
-
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    if(name == NULL || name[0] == '\0')
-        return EXPR_ERROR_NOTFOUND;
-
-    /* Search for the item */
-    cur = vlist->head;
-
-    while(cur)
-        {
-        result = strcmp(name, cur->vname);
-
-        if(result == 0)
-            {
-            /* We found it. */
-            if(cur->vptr)
-                *val = *(cur->vptr);
-            else
-                *val = cur->vval;
-
-            /* return now */
-            return EXPR_ERROR_NOERROR;
-            }
-
-        cur = cur->next;
-        }
-
-    /* If we got here, we did not find the item in the list */
-    return EXPR_ERROR_NOTFOUND;
-    }
-    
+int exprValListGet(exprValList * vlist, char *name, EXPRTYPE * val)
+{
+	exprVal *cur;
+	int result;
+
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	if (name == NULL || name[0] == '\0')
+		return EXPR_ERROR_NOTFOUND;
+
+	/* Search for the item */
+	cur = vlist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->vname);
+
+		if (result == 0) {
+			/* We found it. */
+			if (cur->vptr)
+				*val = *(cur->vptr);
+			else
+				*val = cur->vval;
+
+			/* return now */
+			return EXPR_ERROR_NOERROR;
+		}
+
+		cur = cur->next;
+	}
+
+	/* If we got here, we did not find the item in the list */
+	return EXPR_ERROR_NOTFOUND;
+}
+
 /* Add an address to the list */
-int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr)
-    {
-    exprVal *tmp;
-    exprVal *cur;
-    int result;
-
-    if(vlist == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-    /* Make sure the name is valid */
-    if(!exprValidIdent(name))
-        return EXPR_ERROR_BADIDENTIFIER;
-
-    if(vlist->head == NULL)
-        {
-        /* Create the node right here */
-        tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
-
-        if(tmp == NULL)
-            return EXPR_ERROR_MEMORY;
-
-        vlist->head = tmp;
-        return EXPR_ERROR_NOERROR;
-        }
-
-    /* See if it already exists */
-    cur = vlist->head;
-    
-    while(cur)
-        {
-        result = strcmp(name, cur->vname);
-
-        if(result == 0)
-            return EXPR_ERROR_ALREADYEXISTS;
-            
-        cur = cur->next;
-        }
-        
-    /* Add it to the list */
-    tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
-
-    if(tmp == NULL)
-        return EXPR_ERROR_MEMORY;
-        
-    tmp->next = vlist->head;
-    vlist->head = tmp;
+int exprValListAddAddress(exprValList * vlist, char *name, EXPRTYPE * addr)
+{
+	exprVal *tmp;
+	exprVal *cur;
+	int result;
 
-    return EXPR_ERROR_NOERROR;
-    }    
+	if (vlist == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+	/* Make sure the name is valid */
+	if (!exprValidIdent(name))
+		return EXPR_ERROR_BADIDENTIFIER;
+
+	if (vlist->head == NULL) {
+		/* Create the node right here */
+		tmp = exprCreateVal(name, (EXPRTYPE) 0.0, addr);
+
+		if (tmp == NULL)
+			return EXPR_ERROR_MEMORY;
+
+		vlist->head = tmp;
+		return EXPR_ERROR_NOERROR;
+	}
+
+	/* See if it already exists */
+	cur = vlist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->vname);
+
+		if (result == 0)
+			return EXPR_ERROR_ALREADYEXISTS;
+
+		cur = cur->next;
+	}
+
+	/* Add it to the list */
+	tmp = exprCreateVal(name, (EXPRTYPE) 0.0, addr);
+
+	if (tmp == NULL)
+		return EXPR_ERROR_MEMORY;
+
+	tmp->next = vlist->head;
+	vlist->head = tmp;
+
+	return EXPR_ERROR_NOERROR;
+}
 
 /* Get memory address of a variable value in a value list */
-int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr)
-    {
-    exprVal *cur;
-    int result;
-
-    /* Not found yet */
-    *addr = NULL;
-
-    if(vlist == NULL || addr == NULL)
-        return EXPR_ERROR_NULLPOINTER;
-
-
-    if(name == NULL || name[0] == '\0')
-        return EXPR_ERROR_NOTFOUND;
-
-    /* Search for the item */
-    cur = vlist->head;
-
-    while(cur)
-        {
-        result = strcmp(name, cur->vname);
-
-        if(result == 0)
-            {
-            /* We found it. */
-            if(cur->vptr)
-                *addr = cur->vptr;
-            else
-                *addr = &(cur->vval);
-
-            /* return now */
-            return EXPR_ERROR_NOERROR;
-            }
-            
-        cur = cur->next;
-        }
-
-    /* If we got here, we did not find it in the list */
-    return EXPR_ERROR_NOTFOUND;
-    }
-    
+int exprValListGetAddress(exprValList * vlist, char *name, EXPRTYPE ** addr)
+{
+	exprVal *cur;
+	int result;
+
+	/* Not found yet */
+	*addr = NULL;
+
+	if (vlist == NULL || addr == NULL)
+		return EXPR_ERROR_NULLPOINTER;
+
+
+	if (name == NULL || name[0] == '\0')
+		return EXPR_ERROR_NOTFOUND;
+
+	/* Search for the item */
+	cur = vlist->head;
+
+	while (cur) {
+		result = strcmp(name, cur->vname);
+
+		if (result == 0) {
+			/* We found it. */
+			if (cur->vptr)
+				*addr = cur->vptr;
+			else
+				*addr = &(cur->vval);
+
+			/* return now */
+			return EXPR_ERROR_NOERROR;
+		}
+
+		cur = cur->next;
+	}
+
+	/* If we got here, we did not find it in the list */
+	return EXPR_ERROR_NOTFOUND;
+}
+
 /* This function is used to enumerate the values in a value list */
-void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie)
-    {
-    exprVal *cur;
-    
-    if(vlist == NULL)
-        return NULL;
-        
-    /* Get the current item */
-    cur = (exprVal*)cookie;
-    
-    /* Find the next item */
-    if(cur == NULL)
-        cur = vlist->head;
-    else
-        cur = cur->next;
-        
-    /* Set up the data */
-    if(cur)
-        {
-        if(name)
-            *name = cur->vname;
-           
-        if(value)
-            {
-            if(cur->vptr)
-                *value = *(cur->vptr);
-            else
-                *value = cur->vval;
-            }
-            
-        if(addr)
-            {
-            if(cur->vptr)
-                *addr = cur->vptr;
-            else
-                *addr = &(cur->vval);
-            }                                
-        }
-        
-    /* If there was no value, return NULL, otherwise, return the item */
-    return (void*)cur;
-    }
+void *exprValListGetNext(exprValList * vlist, char **name, EXPRTYPE * value, EXPRTYPE ** addr, void *cookie)
+{
+	exprVal *cur;
+
+	if (vlist == NULL)
+		return NULL;
+
+	/* Get the current item */
+	cur = (exprVal *) cookie;
+
+	/* Find the next item */
+	if (cur == NULL)
+		cur = vlist->head;
+	else
+		cur = cur->next;
+
+	/* Set up the data */
+	if (cur) {
+		if (name)
+			*name = cur->vname;
+
+		if (value) {
+			if (cur->vptr)
+				*value = *(cur->vptr);
+			else
+				*value = cur->vval;
+		}
+
+		if (addr) {
+			if (cur->vptr)
+				*addr = cur->vptr;
+			else
+				*addr = &(cur->vval);
+		}
+	}
+
+	/* If there was no value, return NULL, otherwise, return the item */
+	return (void *) cur;
+}
 
 /* This routine will free the value list */
-int exprValListFree(exprValList *vlist)
-    {
-    /* Make sure it exists, if not it is not error */
-    if(vlist == NULL)
-        return EXPR_ERROR_NOERROR;
+int exprValListFree(exprValList * vlist)
+{
+	/* Make sure it exists, if not it is not error */
+	if (vlist == NULL)
+		return EXPR_ERROR_NOERROR;
 
-    /* Free the nodes */
-    exprValListFreeData(vlist->head);
+	/* Free the nodes */
+	exprValListFreeData(vlist->head);
 
-    /* Freethe container */
-    exprFreeMem(vlist);
+	/* Freethe container */
+	exprFreeMem(vlist);
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* This routine will reset the value list to 0.0 */
-int exprValListClear(exprValList *vlist)
-    {
-    if(vlist == NULL)
-        return EXPR_ERROR_NOERROR;
+int exprValListClear(exprValList * vlist)
+{
+	if (vlist == NULL)
+		return EXPR_ERROR_NOERROR;
 
-    exprValListResetData(vlist->head);
+	exprValListResetData(vlist->head);
 
-    return EXPR_ERROR_NOERROR;
-    }
+	return EXPR_ERROR_NOERROR;
+}
 
 /* This routine will free any child nodes, and then free itself */
-static void exprValListFreeData(exprVal *val)
-    {
-    exprVal *next;
-    
-    while(val)
-        {
-        /* Remember the next */
-        next = val->next;
-        
-        /* Free name */
-        exprFreeMem(val->vname);
-
-        /* Free ourself */
-        exprFreeMem(val);
-        
-        val = next;
-        }
-    }
+static void exprValListFreeData(exprVal * val)
+{
+	exprVal *next;
+
+	while (val) {
+		/* Remember the next */
+		next = val->next;
+
+		/* Free name */
+		exprFreeMem(val->vname);
+
+		/* Free ourself */
+		exprFreeMem(val);
+
+		val = next;
+	}
+}
 
 /* This routine will reset variables to 0.0 */
-static void exprValListResetData(exprVal *val)
-    {
-    while(val)
-        {
-        /* Reset data */
-        if(val->vptr)
-            *(val->vptr) = 0.0;
-      
-        val->vval = 0.0;
-        
-        val = val->next;
-        }
-    }
+static void exprValListResetData(exprVal * val)
+{
+	while (val) {
+		/* Reset data */
+		if (val->vptr)
+			*(val->vptr) = 0.0;
+
+		val->vval = 0.0;
+
+		val = val->next;
+	}
+}
 
 /* This routine will create the value object */
-static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr)
-    {
-    exprVal *tmp;
-    char *vtmp;
-
-    /* Name already tested in exprValListAdd */
-
-    /* Create it */
-    tmp = exprAllocMem(sizeof(exprVal));
-    if(tmp == NULL)
-        return NULL;
-
-    /* Allocate space for the name */
-    vtmp = exprAllocMem(strlen(name) + 1);
-
-    if(vtmp == NULL)
-        {
-        exprFreeMem(tmp);
-        return NULL;
-        }
-
-    /* Copy the data over */
-    strcpy(vtmp, name);
-    tmp->vname = vtmp;
-    tmp->vval = val;
-    tmp->vptr = addr;
+static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE * addr)
+{
+	exprVal *tmp;
+	char *vtmp;
+
+	/* Name already tested in exprValListAdd */
+
+	/* Create it */
+	tmp = exprAllocMem(sizeof(exprVal));
+	if (tmp == NULL)
+		return NULL;
+
+	/* Allocate space for the name */
+	vtmp = exprAllocMem(strlen(name) + 1);
+
+	if (vtmp == NULL) {
+		exprFreeMem(tmp);
+		return NULL;
+	}
+
+	/* Copy the data over */
+	strcpy(vtmp, name);
+	tmp->vname = vtmp;
+	tmp->vval = val;
+	tmp->vptr = addr;
 
-    return tmp;
-    }
+	return tmp;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/mod_expr.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/mod_expr.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_expr/mod_expr.c	Tue May 27 07:24:06 2008
@@ -33,145 +33,145 @@
 
 /* Breaker function to break out of long expression functions
    such as the 'for' function */
-int breaker(exprObj *o)
+int breaker(exprObj * o)
 {
-    /* Return nonzero to break out */
-    return -1;
+	/* Return nonzero to break out */
+	return -1;
 }
 
 
 SWITCH_STANDARD_API(expr_function)
 {
-    exprObj *e = NULL;
-    exprFuncList *f = NULL;
-    exprValList *v = NULL;
-    exprValList *c = NULL;
-    EXPRTYPE last_expr;
+	exprObj *e = NULL;
+	exprFuncList *f = NULL;
+	exprValList *v = NULL;
+	exprValList *c = NULL;
+	EXPRTYPE last_expr;
 	const char *expr;
 	int err;
-    char val[512] = "", *p;
-    char *m_cmd = NULL;
-    size_t len;
-
-    if (switch_strlen_zero(cmd)) {
-        goto error;
-    }
-
-    len = strlen(cmd) + 3;
-
-
-    m_cmd = malloc(len);
-    switch_assert(m_cmd);
-    switch_copy_string(m_cmd, cmd, len);
-    
-    for (p = m_cmd; p && *p; p++) {
-        if (*p == '|') {
-            *p = ';';
-        }
-    }
-
-    p = m_cmd + (strlen(m_cmd) - 1);
-    if (*p != ';') {
-        p++;
-        *p = ';';
-        p++;
-        *p = '\0';
-    }
-
-    expr = m_cmd;
-
-    /* Create function list */
-    err = exprFuncListCreate(&f);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Init function list with internal functions */
-    err = exprFuncListInit(f);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Add custom function */
-    //err = exprFuncListAdd(f, my_func, "myfunc", 1, 1, 1, 1);
-    //if (err != EXPR_ERROR_NOERROR)
+	char val[512] = "", *p;
+	char *m_cmd = NULL;
+	size_t len;
+
+	if (switch_strlen_zero(cmd)) {
+		goto error;
+	}
+
+	len = strlen(cmd) + 3;
+
+
+	m_cmd = malloc(len);
+	switch_assert(m_cmd);
+	switch_copy_string(m_cmd, cmd, len);
+
+	for (p = m_cmd; p && *p; p++) {
+		if (*p == '|') {
+			*p = ';';
+		}
+	}
+
+	p = m_cmd + (strlen(m_cmd) - 1);
+	if (*p != ';') {
+		p++;
+		*p = ';';
+		p++;
+		*p = '\0';
+	}
+
+	expr = m_cmd;
+
+	/* Create function list */
+	err = exprFuncListCreate(&f);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Init function list with internal functions */
+	err = exprFuncListInit(f);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Add custom function */
+	//err = exprFuncListAdd(f, my_func, "myfunc", 1, 1, 1, 1);
+	//if (err != EXPR_ERROR_NOERROR)
 	//goto error;
 
-    /* Create constant list */
-    err = exprValListCreate(&c);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Init constant list with internal constants */
-    err = exprValListInit(c);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Create variable list */
-    err = exprValListCreate(&v);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Create expression object */
-    err = exprCreate(&e, f, v, c, breaker, NULL);
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Parse expression */
-    err = exprParse(e, (char *)expr);
-
-    if (err != EXPR_ERROR_NOERROR)
-        goto error;
-
-    /* Enable soft errors */
-    //exprSetSoftErrors(e, 1);
-    
+	/* Create constant list */
+	err = exprValListCreate(&c);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Init constant list with internal constants */
+	err = exprValListInit(c);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Create variable list */
+	err = exprValListCreate(&v);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Create expression object */
+	err = exprCreate(&e, f, v, c, breaker, NULL);
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Parse expression */
+	err = exprParse(e, (char *) expr);
+
+	if (err != EXPR_ERROR_NOERROR)
+		goto error;
+
+	/* Enable soft errors */
+	//exprSetSoftErrors(e, 1);
+
 	do {
 		err = exprEval(e, &last_expr);
 	} while (err);
 
-    switch_snprintf(val, sizeof(val), "%0.10f", last_expr);
-    for (p = (val + strlen(val) - 1); p != val; p--) {
-        if (*p != '0') {
-            *(p+1) = '\0';
-            break;
-        } 
-    }
+	switch_snprintf(val, sizeof(val), "%0.10f", last_expr);
+	for (p = (val + strlen(val) - 1); p != val; p--) {
+		if (*p != '0') {
+			*(p + 1) = '\0';
+			break;
+		}
+	}
 
-    p = val + strlen(val) - 1;
-    if (*p == '.') {
-        *p = '\0';
-    }
+	p = val + strlen(val) - 1;
+	if (*p == '.') {
+		*p = '\0';
+	}
 
-    stream->write_function(stream, "%s", val);
+	stream->write_function(stream, "%s", val);
 
 
-    goto done;
+	goto done;
 
- error:
-    /* Alert user of error */
-    stream->write_function(stream, "!err!");
+  error:
+	/* Alert user of error */
+	stream->write_function(stream, "!err!");
 
 
- done:
-    /* Do cleanup */
-    if (e) {
-        exprFree(e); 
-    }
+  done:
+	/* Do cleanup */
+	if (e) {
+		exprFree(e);
+	}
 
-    if (f) {
-        exprFuncListFree(f);
-    }
+	if (f) {
+		exprFuncListFree(f);
+	}
 
-    if (v) {
-        exprValListFree(v);
-    }
+	if (v) {
+		exprValListFree(v);
+	}
 
-    if (c) {
-        exprValListFree(c);
-    }
+	if (c) {
+		exprValListFree(c);
+	}
 
-    switch_safe_free(m_cmd);
+	switch_safe_free(m_cmd);
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
@@ -181,10 +181,10 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_expr_load)
 {
 	switch_api_interface_t *commands_api_interface;
-    
+
 	/* connect my internal structure to the blank pointer passed to me */
-    *module_interface = switch_loadable_module_create_module_interface(pool, modname);
-    
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
 	SWITCH_ADD_API(commands_api_interface, "expr", "Eval an expession", expr_function, "<expr>");
 
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fifo/mod_fifo.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fifo/mod_fifo.c	Tue May 27 07:24:06 2008
@@ -39,13 +39,13 @@
 #define MAX_PRI 10
 
 struct fifo_node {
-    char *name;
-    switch_mutex_t *mutex;
-    switch_queue_t *fifo_list[MAX_PRI];
-    switch_hash_t *caller_hash;
-    switch_hash_t *consumer_hash;
-    int caller_count;
-    int consumer_count;
+	char *name;
+	switch_mutex_t *mutex;
+	switch_queue_t *fifo_list[MAX_PRI];
+	switch_hash_t *caller_hash;
+	switch_hash_t *consumer_hash;
+	int caller_count;
+	int consumer_count;
 	switch_time_t start_waiting;
 	uint32_t importance;
 };
@@ -57,12 +57,12 @@
 
 static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-    switch_core_session_t *bleg = (switch_core_session_t *) buf;
+	switch_core_session_t *bleg = (switch_core_session_t *) buf;
 
 	switch (itype) {
 	case SWITCH_INPUT_TYPE_DTMF:
-        {
-            switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+		{
+			switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 			switch_channel_t *bchan = switch_core_session_get_channel(bleg);
 			switch_channel_t *channel = switch_core_session_get_channel(session);
 			if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_ORIGINATOR)) {
@@ -71,11 +71,11 @@
 					return SWITCH_STATUS_BREAK;
 				} else if (dtmf->digit == '0') {
 					const char *moh_a = NULL, *moh_b = NULL;
-					
+
 					if (!(moh_b = switch_channel_get_variable(bchan, "fifo_music"))) {
 						moh_b = switch_channel_get_variable(bchan, "hold_music");
 					}
-					
+
 					if (!(moh_a = switch_channel_get_variable(channel, "fifo_hold_music"))) {
 						if (!(moh_a = switch_channel_get_variable(channel, "fifo_music"))) {
 							moh_a = switch_channel_get_variable(channel, "hold_music");
@@ -86,7 +86,7 @@
 					return SWITCH_STATUS_IGNORE;
 				}
 			}
-        }
+		}
 		break;
 	default:
 		break;
@@ -101,17 +101,17 @@
 
 	switch (itype) {
 	case SWITCH_INPUT_TYPE_DTMF:
-        {
-            switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+		{
+			switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 			switch_channel_t *channel = switch_core_session_get_channel(session);
 			const char *caller_exit_key = switch_channel_get_variable(channel, "fifo_caller_exit_key");
-			
-            if (caller_exit_key && dtmf->digit == *caller_exit_key) {
+
+			if (caller_exit_key && dtmf->digit == *caller_exit_key) {
 				char *bp = buf;
 				*bp = dtmf->digit;
 				return SWITCH_STATUS_BREAK;
-            }
-        }
+			}
+		}
 		break;
 	default:
 		break;
@@ -125,7 +125,7 @@
 static int node_consumer_wait_count(fifo_node_t *node)
 {
 	int i, len = 0;
-	
+
 	for (i = 0; i < MAX_PRI; i++) {
 		len += switch_queue_size(node->fifo_list[i]);
 	}
@@ -142,9 +142,9 @@
 		if (!(len = switch_queue_size(node->fifo_list[i]))) {
 			continue;
 		}
-		while(len) {
+		while (len) {
 			if (switch_queue_trypop(node->fifo_list[i], &pop) == SWITCH_STATUS_SUCCESS && pop) {
-				if (!done && !strcmp((char *)pop, uuid)) {
+				if (!done && !strcmp((char *) pop, uuid)) {
 					free(pop);
 					done++;
 				} else {
@@ -181,7 +181,7 @@
 static switch_status_t caller_read_frame_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
 {
 	fifo_chime_data_t *cd = (fifo_chime_data_t *) user_data;
-	
+
 	if (!cd) {
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -220,8 +220,8 @@
 {
 	fifo_node_t *node, **node_list = (fifo_node_t **) user_data;
 	int x = 0, total = 0, i = 0;
-	
-	for(i = 0; ; i++) {
+
+	for (i = 0;; i++) {
 		if (!(node = node_list[i])) {
 			break;
 		}
@@ -230,74 +230,74 @@
 		}
 	}
 
-    if (total) {
-        return SWITCH_STATUS_FALSE;
-    }
+	if (total) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static struct {
-    switch_hash_t *fifo_hash;
-    switch_mutex_t *mutex;
-    switch_memory_pool_t *pool;
-    int running;
+	switch_hash_t *fifo_hash;
+	switch_mutex_t *mutex;
+	switch_memory_pool_t *pool;
+	int running;
 } globals;
 
 
 static fifo_node_t *create_node(const char *name, uint32_t importance)
 {
-    fifo_node_t *node;
+	fifo_node_t *node;
 	int x = 0;
-	
-    if (!globals.running) {
-        return NULL;
-    }
 
-    node = switch_core_alloc(globals.pool, sizeof(*node));
-    node->name = switch_core_strdup(globals.pool, name);
+	if (!globals.running) {
+		return NULL;
+	}
+
+	node = switch_core_alloc(globals.pool, sizeof(*node));
+	node->name = switch_core_strdup(globals.pool, name);
 	for (x = 0; x < MAX_PRI; x++) {
 		switch_queue_create(&node->fifo_list[x], SWITCH_CORE_QUEUE_LEN, globals.pool);
 		switch_assert(node->fifo_list[x]);
 	}
-    switch_core_hash_init(&node->caller_hash, globals.pool);
-    switch_core_hash_init(&node->consumer_hash, globals.pool);
-	
-    switch_mutex_init(&node->mutex, SWITCH_MUTEX_NESTED, globals.pool);
-    switch_core_hash_insert(globals.fifo_hash, name, node);
+	switch_core_hash_init(&node->caller_hash, globals.pool);
+	switch_core_hash_init(&node->consumer_hash, globals.pool);
+
+	switch_mutex_init(&node->mutex, SWITCH_MUTEX_NESTED, globals.pool);
+	switch_core_hash_insert(globals.fifo_hash, name, node);
 
 	node->importance = importance;
 
-    return node;
+	return node;
 }
 
 static void send_presence(fifo_node_t *node)
 {
-    switch_event_t *event;
+	switch_event_t *event;
 	int wait_count = 0;
 
-    if (!globals.running) {
-        return;
-    }
+	if (!globals.running) {
+		return;
+	}
 
 	if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", "park");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", node->name);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", node->name);
-        if ((wait_count = node_consumer_wait_count(node)) > 0) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d waiting)", wait_count);
-        } else {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle");
-        }
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", "unknown");
+		if ((wait_count = node_consumer_wait_count(node)) > 0) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d waiting)", wait_count);
+		} else {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle");
+		}
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", "unknown");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", 0);
 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", wait_count > 0 ? "CS_ROUTING" : "CS_HANGUP");
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", node->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", wait_count > 0 ? "early" : "terminated");
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", "inbound");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", wait_count > 0 ? "CS_ROUTING" : "CS_HANGUP");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", node->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", wait_count > 0 ? "early" : "terminated");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", "inbound");
 		switch_event_fire(&event);
 	}
 }
@@ -307,29 +307,29 @@
 {
 	char *to = switch_event_get_header(event, "to");
 	char *dup_to = NULL, *node_name;
-    fifo_node_t *node;
+	fifo_node_t *node;
+
+	if (!globals.running) {
+		return;
+	}
 
-    if (!globals.running) {
-        return;
-    }
-    
 	if (!to || strncasecmp(to, "park+", 5)) {
 		return;
 	}
 
 	dup_to = strdup(to);
-    switch_assert(dup_to);
+	switch_assert(dup_to);
 
 	node_name = dup_to + 5;
 
-    switch_mutex_lock(globals.mutex);
-    if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) {
-        node = create_node(node_name, 0);
-    }
+	switch_mutex_lock(globals.mutex);
+	if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) {
+		node = create_node(node_name, 0);
+	}
 
-    send_presence(node);
+	send_presence(node);
 
-    switch_mutex_unlock(globals.mutex);
+	switch_mutex_unlock(globals.mutex);
 
 	switch_safe_free(dup_to);
 }
@@ -344,18 +344,18 @@
 #define FIFO_USAGE "<fifo name> [in [<announce file>|undef] [<music file>|undef] | out [wait|nowait] [<announce file>|undef] [<music file>|undef]]"
 SWITCH_STANDARD_APP(fifo_function)
 {
-    int argc;
-    char *mydata = NULL, *argv[5] = { 0 };
-    fifo_node_t *node = NULL, *node_list[MAX_NODES_PER_CONSUMER+1] = { 0 };
-    switch_channel_t *channel = switch_core_session_get_channel(session);
-    int do_wait = 1, node_count = 0, i = 0;
-    const char *moh = NULL;
-    const char *announce = NULL;
-    switch_event_t *event = NULL;
-    char date[80] = "";
-    switch_time_exp_t tm;
-    switch_time_t ts = switch_timestamp_now();
-    switch_size_t retsize;
+	int argc;
+	char *mydata = NULL, *argv[5] = { 0 };
+	fifo_node_t *node = NULL, *node_list[MAX_NODES_PER_CONSUMER + 1] = { 0 };
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	int do_wait = 1, node_count = 0, i = 0;
+	const char *moh = NULL;
+	const char *announce = NULL;
+	switch_event_t *event = NULL;
+	char date[80] = "";
+	switch_time_exp_t tm;
+	switch_time_t ts = switch_timestamp_now();
+	switch_size_t retsize;
 	char *list_string;
 	int nlist_count;
 	char *nlist[MAX_NODES_PER_CONSUMER];
@@ -364,51 +364,51 @@
 	const char *arg_inout = NULL;
 	const char *serviced_uuid = NULL;
 
-    if (!globals.running) {
-        return;
-    }
+	if (!globals.running) {
+		return;
+	}
 
 	if (switch_strlen_zero(data)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Args\n");
-        return;
-    }
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Args\n");
+		return;
+	}
 
-    mydata = switch_core_session_strdup(session, data);
-    switch_assert(mydata);
+	mydata = switch_core_session_strdup(session, data);
+	switch_assert(mydata);
 
 	argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 	arg_fifo_name = argv[0];
 	arg_inout = argv[1];
-	
-    if (!(arg_fifo_name && arg_inout)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
-        return;
-    }
+
+	if (!(arg_fifo_name && arg_inout)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
+		return;
+	}
 
 	if (!strcasecmp(arg_inout, "out")) {
 		consumer = 1;
 	} else if (strcasecmp(arg_inout, "in")) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
-        return;
+		return;
 	}
 
 	list_string = switch_core_session_strdup(session, arg_fifo_name);
 
-    if (!(nlist_count = switch_separate_string(list_string, ',', nlist, (sizeof(nlist) / sizeof(nlist[0]))))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
-        return;
+	if (!(nlist_count = switch_separate_string(list_string, ',', nlist, (sizeof(nlist) / sizeof(nlist[0]))))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
+		return;
 	}
 
 	if (!consumer && nlist_count > 1) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
-        return;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
+		return;
 	}
 
 	switch_mutex_lock(globals.mutex);
-	for(i = 0; i < nlist_count; i++) {
+	for (i = 0; i < nlist_count; i++) {
 		int importance = 0;
 		char *p;
-		
+
 		if ((p = strrchr(nlist[i], '!'))) {
 			*p++ = '\0';
 			importance = atoi(p);
@@ -422,37 +422,37 @@
 		}
 		node_list[node_count++] = node;
 	}
-    switch_mutex_unlock(globals.mutex);
+	switch_mutex_unlock(globals.mutex);
 
 	moh = switch_channel_get_variable(channel, "fifo_music");
-    announce = switch_channel_get_variable(channel, "fifo_announce");
+	announce = switch_channel_get_variable(channel, "fifo_announce");
 
 	if (consumer) {
 		if (argc > 3) {
-            announce = argv[3];
-        }
+			announce = argv[3];
+		}
 
-        if (argc > 4) {
-            moh = argv[4];
-        }
+		if (argc > 4) {
+			moh = argv[4];
+		}
 
 	} else {
 		if (argc > 2) {
-            announce = argv[2];
-        }
+			announce = argv[2];
+		}
 
-        if (argc > 3) {
-            moh = argv[3];
-        }
+		if (argc > 3) {
+			moh = argv[3];
+		}
 	}
 
 	check_string(announce);
 	check_string(moh);
 
-    if (!consumer && node) {
-        switch_core_session_t *other_session;
+	if (!consumer && node) {
+		switch_core_session_t *other_session;
 		switch_channel_t *other_channel;
-        const char *uuid = switch_core_session_get_uuid(session);
+		const char *uuid = switch_core_session_get_uuid(session);
 		const char *pri;
 		char tmp[25] = "";
 		int p = 0;
@@ -479,8 +479,8 @@
 				cd.orbit_timeout = switch_timestamp(NULL) + to;
 			}
 		}
-		
-		
+
+
 		if (chime_freq) {
 			ftmp = atoi(chime_freq);
 			if (ftmp > 0) {
@@ -490,50 +490,50 @@
 
 
 
-        switch_channel_answer(channel);
+		switch_channel_answer(channel);
+
+		switch_mutex_lock(node->mutex);
+		node->caller_count++;
 
-        switch_mutex_lock(node->mutex);
-        node->caller_count++;
+		switch_core_hash_insert(node->caller_hash, uuid, session);
 
-        switch_core_hash_insert(node->caller_hash, uuid, session);
-		
 
-        if ((pri = switch_channel_get_variable(channel, "fifo_priority"))) {
+		if ((pri = switch_channel_get_variable(channel, "fifo_priority"))) {
 			p = atoi(pri);
 		}
 
 		if (p >= MAX_PRI) {
 			p = MAX_PRI - 1;
 		}
-		
+
 		if (!node_consumer_wait_count(node)) {
 			node->start_waiting = switch_timestamp_now();
 		}
-		
-        switch_queue_push(node->fifo_list[p], (void *)strdup(uuid));
+
+		switch_queue_push(node->fifo_list[p], (void *) strdup(uuid));
 
 		if (!pri) {
 			switch_snprintf(tmp, sizeof(tmp), "%d", p);
 			switch_channel_set_variable(channel, "fifo_priority", tmp);
 		}
 
-        switch_mutex_unlock(node->mutex);
-		
-        ts = switch_timestamp_now();
-        switch_time_exp_lt(&tm, ts);
-        switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
-        switch_channel_set_variable(channel, "fifo_status", "WAITING");
-        switch_channel_set_variable(channel, "fifo_timestamp", date);
-        
+		switch_mutex_unlock(node->mutex);
+
+		ts = switch_timestamp_now();
+		switch_time_exp_lt(&tm, ts);
+		switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
+		switch_channel_set_variable(channel, "fifo_status", "WAITING");
+		switch_channel_set_variable(channel, "fifo_timestamp", date);
+
 		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(channel, event);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "push");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Slot", "%d", p);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "push");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Slot", "%d", p);
 			switch_event_fire(&event);
 		}
-		
-        switch_channel_set_flag(channel, CF_TAGGED);
+
+		switch_channel_set_flag(channel, CF_TAGGED);
 
 		if (chime_list) {
 			char *list_dup = switch_core_session_strdup(session, chime_list);
@@ -542,12 +542,12 @@
 			cd.next = switch_timestamp(NULL) + cd.freq;
 		}
 
-        send_presence(node);
+		send_presence(node);
 
-		while(switch_channel_ready(channel)) {
+		while (switch_channel_ready(channel)) {
 			switch_input_args_t args = { 0 };
 			char buf[25] = "";
-			
+
 			args.input_callback = moh_on_dtmf;
 			args.buf = buf;
 			args.buflen = sizeof(buf);
@@ -559,7 +559,7 @@
 
 			if (cd.abort || cd.do_orbit) {
 				aborted = 1;
-                goto abort;
+				goto abort;
 			}
 
 			if ((serviced_uuid = switch_channel_get_variable(channel, "fifo_serviced_uuid"))) {
@@ -577,7 +577,7 @@
 			} else {
 				switch_ivr_collect_digits_callback(session, &args, 0);
 			}
-			
+
 			if (caller_exit_key && *buf == *caller_exit_key) {
 				aborted = 1;
 				goto abort;
@@ -596,59 +596,59 @@
 				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			}
 		}
-		
+
 		switch_core_session_flush_private_events(session);
 
 		if (switch_channel_ready(channel)) {
-            if (announce) {
-                switch_ivr_play_file(session, NULL, announce, NULL);
-            }
-        }
-
-        switch_channel_clear_flag(channel, CF_TAGGED);
-		
-	abort:
-		
-        if (!aborted && switch_channel_ready(channel)) {
-            switch_channel_set_state(channel, CS_HIBERNATE);            
-        } else {
-            ts = switch_timestamp_now();
-            switch_time_exp_lt(&tm, ts);
-            switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
-            switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED");
-            switch_channel_set_variable(channel, "fifo_timestamp", date);
-            
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_event_set_data(channel, event);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", cd.do_orbit ? "timeout" : "abort");
-                switch_event_fire(&event);
-            }
-            switch_mutex_lock(node->mutex);
+			if (announce) {
+				switch_ivr_play_file(session, NULL, announce, NULL);
+			}
+		}
+
+		switch_channel_clear_flag(channel, CF_TAGGED);
+
+	  abort:
+
+		if (!aborted && switch_channel_ready(channel)) {
+			switch_channel_set_state(channel, CS_HIBERNATE);
+		} else {
+			ts = switch_timestamp_now();
+			switch_time_exp_lt(&tm, ts);
+			switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
+			switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED");
+			switch_channel_set_variable(channel, "fifo_timestamp", date);
+
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_event_set_data(channel, event);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", cd.do_orbit ? "timeout" : "abort");
+				switch_event_fire(&event);
+			}
+			switch_mutex_lock(node->mutex);
 			node_remove_uuid(node, uuid);
-            node->caller_count--;
-            switch_core_hash_delete(node->caller_hash, uuid);
-            switch_mutex_unlock(node->mutex);
-            send_presence(node);
-			
-        }
-        
+			node->caller_count--;
+			switch_core_hash_delete(node->caller_hash, uuid);
+			switch_mutex_unlock(node->mutex);
+			send_presence(node);
+
+		}
+
 		if (cd.do_orbit && cd.orbit_exten) {
-            if (orbit_ann) {
-                switch_ivr_play_file(session, NULL, orbit_ann, NULL);
-            }
+			if (orbit_ann) {
+				switch_ivr_play_file(session, NULL, orbit_ann, NULL);
+			}
 			switch_ivr_session_transfer(session, cd.orbit_exten, NULL, NULL);
 		}
 
-        return;
-    } else { /* consumer */
-        void *pop = NULL;
-        switch_frame_t *read_frame;
-        switch_status_t status;
-        char *uuid;
-        int done = 0;
-        switch_core_session_t *other_session;
-        switch_input_args_t args = { 0 };
+		return;
+	} else {					/* consumer */
+		void *pop = NULL;
+		switch_frame_t *read_frame;
+		switch_status_t status;
+		char *uuid;
+		int done = 0;
+		switch_core_session_t *other_session;
+		switch_input_args_t args = { 0 };
 		const char *pop_order = NULL;
 		int custom_pop = 0;
 		int pop_array[MAX_PRI] = { 0 };
@@ -660,7 +660,7 @@
 		const char *strat_str = switch_channel_get_variable(channel, "fifo_strategy");
 		fifo_strategy_t strat = STRAT_WAITING_LONGER;
 
-		
+
 		if (!switch_strlen_zero(strat_str)) {
 			if (!strcasecmp(strat_str, "more_ppl")) {
 				strat = STRAT_MORE_PPL;
@@ -687,8 +687,8 @@
 			my_id = switch_core_session_get_uuid(session);
 		}
 
-        
-        if (do_wait) {
+
+		if (do_wait) {
 			for (i = 0; i < node_count; i++) {
 				if (!(node = node_list[i])) {
 					continue;
@@ -698,28 +698,28 @@
 				switch_core_hash_insert(node->consumer_hash, switch_core_session_get_uuid(session), session);
 				switch_mutex_unlock(node->mutex);
 			}
-            switch_channel_answer(channel);
-        }
-		
+			switch_channel_answer(channel);
+		}
+
 		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_event_set_data(channel, event);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_start");
-            switch_event_fire(&event);
-        }
-
-        ts = switch_timestamp_now();
-        switch_time_exp_lt(&tm, ts);
-        switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
-        switch_channel_set_variable(channel, "fifo_status", "WAITING");
-        switch_channel_set_variable(channel, "fifo_timestamp", date);
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_start");
+			switch_event_fire(&event);
+		}
+
+		ts = switch_timestamp_now();
+		switch_time_exp_lt(&tm, ts);
+		switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
+		switch_channel_set_variable(channel, "fifo_status", "WAITING");
+		switch_channel_set_variable(channel, "fifo_timestamp", date);
 
-        if ((pop_order = switch_channel_get_variable(channel, "fifo_pop_order"))) {
+		if ((pop_order = switch_channel_get_variable(channel, "fifo_pop_order"))) {
 			char *tmp = switch_core_session_strdup(session, pop_order);
 			int x;
 			custom_pop = switch_separate_string(tmp, ',', pop_list, (sizeof(pop_list) / sizeof(pop_list[0])));
 			if (custom_pop >= MAX_PRI) {
-				custom_pop = MAX_PRI -1;
+				custom_pop = MAX_PRI - 1;
 			}
 
 			for (x = 0; x < custom_pop; x++) {
@@ -731,33 +731,33 @@
 				}
 			}
 		}
-		
-		while(switch_channel_ready(channel)) {
+
+		while (switch_channel_ready(channel)) {
 			int x = 0, winner = -1;
 			switch_time_t longest = 0xFFFFFFFFFFFFFFFF / 2;
 			uint32_t importance = 0, waiting = 0, most_waiting = 0;
-			
+
 			pop = NULL;
-			
-            if (moh && do_wait) {
+
+			if (moh && do_wait) {
 				switch_status_t moh_status = switch_ivr_play_file(session, NULL, moh, &args);
 				memset(&args, 0, sizeof(args));
-                args.read_frame_callback = consumer_read_frame_callback;
-                args.user_data = node_list;
-                switch_ivr_play_file(session, NULL, moh, &args);
-				
+				args.read_frame_callback = consumer_read_frame_callback;
+				args.user_data = node_list;
+				switch_ivr_play_file(session, NULL, moh, &args);
+
 				if (!SWITCH_READ_ACCEPTABLE(moh_status)) {
 					break;
 				}
-            }
-			
-			for(i = 0; i < node_count; i++) {
+			}
+
+			for (i = 0; i < node_count; i++) {
 				if (!(node = node_list[i])) {
 					continue;
 				}
-				
+
 				if ((waiting = node_consumer_wait_count(node))) {
-					
+
 					if (!importance || node->importance > importance) {
 						if (strat == STRAT_WAITING_LONGER) {
 							if (node->start_waiting < longest) {
@@ -771,14 +771,14 @@
 							}
 						}
 					}
-					
+
 					if (node->importance > importance) {
 						importance = node->importance;
 					}
 				}
 
 			}
-			
+
 			if (winner > -1) {
 				node = node_list[winner];
 			} else {
@@ -787,76 +787,76 @@
 
 			if (node) {
 				if (custom_pop) {
-					for(x = 0; x < MAX_PRI; x++) {
+					for (x = 0; x < MAX_PRI; x++) {
 						if (switch_queue_trypop(node->fifo_list[pop_array[x]], &pop) == SWITCH_STATUS_SUCCESS && pop) {
 							break;
 						}
 					}
 				} else {
-					for(x = 0; x < MAX_PRI; x++) {
+					for (x = 0; x < MAX_PRI; x++) {
 						if (switch_queue_trypop(node->fifo_list[x], &pop) == SWITCH_STATUS_SUCCESS && pop) {
 							break;
 						}
 					}
 				}
-			
+
 				if (pop && !node_consumer_wait_count(node)) {
 					switch_mutex_lock(node->mutex);
 					node->start_waiting = 0;
 					switch_mutex_unlock(node->mutex);
 				}
 			}
-			
+
 
 			if (!pop) {
-                if (!do_wait) {
-                    break;
-                }
-
-                status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-
-                if (!SWITCH_READ_ACCEPTABLE(status)) {
-                    break;
-                }
-
-                continue;
-            }
-			
-            uuid = (char *) pop;
+				if (!do_wait) {
+					break;
+				}
+
+				status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+
+				if (!SWITCH_READ_ACCEPTABLE(status)) {
+					break;
+				}
+
+				continue;
+			}
+
+			uuid = (char *) pop;
 			pop = NULL;
 
-            if (node && (other_session = switch_core_session_locate(uuid))) {
-                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
-                switch_caller_profile_t *cloned_profile;
+			if (node && (other_session = switch_core_session_locate(uuid))) {
+				switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+				switch_caller_profile_t *cloned_profile;
 				const char *o_announce = NULL;
 				const char *record_template = switch_channel_get_variable(channel, "fifo_record_template");
 				char *expanded = NULL;
-				
+
 				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
-                    switch_channel_event_set_data(other_channel, event);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
-                    switch_event_fire(&event);
-                }
-
-                if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
-                    switch_channel_event_set_data(channel, event);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_pop");
-                    switch_event_fire(&event);
-                }
+					switch_channel_event_set_data(other_channel, event);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
+					switch_event_fire(&event);
+				}
+
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+					switch_channel_event_set_data(channel, event);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_pop");
+					switch_event_fire(&event);
+				}
 
 				if ((o_announce = switch_channel_get_variable(other_channel, "fifo_override_announce"))) {
 					announce = o_announce;
 				}
 
 				if (announce) {
-                    switch_ivr_play_file(session, NULL, announce, NULL);
-                } else {
+					switch_ivr_play_file(session, NULL, announce, NULL);
+				} else {
 					switch_ivr_sleep(session, 500);
-                }
-				
-				
+				}
+
+
 				switch_channel_set_variable(other_channel, "fifo_serviced_by", my_id);
 				switch_channel_set_variable(other_channel, "fifo_serviced_uuid", switch_core_session_get_uuid(session));
 
@@ -868,7 +868,7 @@
 						break;
 					}
 				}
-				
+
 				if (!(switch_channel_ready(channel))) {
 					switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING);
 					switch_core_session_rwunlock(other_session);
@@ -876,28 +876,28 @@
 				}
 
 
-                switch_channel_answer(channel);
+				switch_channel_answer(channel);
 				cloned_profile = switch_caller_profile_clone(other_session, switch_channel_get_caller_profile(channel));
-                switch_assert(cloned_profile);
-                switch_channel_set_originator_caller_profile(other_channel, cloned_profile);
+				switch_assert(cloned_profile);
+				switch_channel_set_originator_caller_profile(other_channel, cloned_profile);
 
 				cloned_profile = switch_caller_profile_clone(session, switch_channel_get_caller_profile(other_channel));
-                switch_assert(cloned_profile);
-                switch_assert(cloned_profile->next == NULL);
-                switch_channel_set_originatee_caller_profile(channel, cloned_profile);
-				
-                ts = switch_timestamp_now();
-                switch_time_exp_lt(&tm, ts);
-                switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
-                switch_channel_set_variable(channel, "fifo_status", "TALKING");
-                switch_channel_set_variable(channel, "fifo_target", uuid);
-                switch_channel_set_variable(channel, "fifo_timestamp", date);
-                
-                switch_channel_set_variable(other_channel, "fifo_status", "TALKING");
-                switch_channel_set_variable(other_channel, "fifo_timestamp", date);
-                switch_channel_set_variable(other_channel, "fifo_target", switch_core_session_get_uuid(session));
+				switch_assert(cloned_profile);
+				switch_assert(cloned_profile->next == NULL);
+				switch_channel_set_originatee_caller_profile(channel, cloned_profile);
+
+				ts = switch_timestamp_now();
+				switch_time_exp_lt(&tm, ts);
+				switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
+				switch_channel_set_variable(channel, "fifo_status", "TALKING");
+				switch_channel_set_variable(channel, "fifo_target", uuid);
+				switch_channel_set_variable(channel, "fifo_timestamp", date);
+
+				switch_channel_set_variable(other_channel, "fifo_status", "TALKING");
+				switch_channel_set_variable(other_channel, "fifo_timestamp", date);
+				switch_channel_set_variable(other_channel, "fifo_target", switch_core_session_get_uuid(session));
 
-                send_presence(node);
+				send_presence(node);
 
 
 				if (record_template) {
@@ -905,7 +905,7 @@
 					switch_ivr_record_session(session, expanded, 0, NULL);
 				}
 
-                switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session);
+				switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session);
 
 				if (record_template) {
 					switch_ivr_stop_record_session(session, expanded);
@@ -914,26 +914,26 @@
 					}
 				}
 
-                ts = switch_timestamp_now();
-                switch_time_exp_lt(&tm, ts);
-                switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
-                switch_channel_set_variable(channel, "fifo_status", "WAITING");
-                switch_channel_set_variable(channel, "fifo_timestamp", date);
-
-                switch_channel_set_variable(other_channel, "fifo_status", "DONE");
-                switch_channel_set_variable(other_channel, "fifo_timestamp", date);
-                
-                switch_mutex_lock(node->mutex);
-                node->caller_count--;
-                switch_core_hash_delete(node->caller_hash, uuid);
-                switch_mutex_unlock(node->mutex);
-                send_presence(node);
-                switch_core_session_rwunlock(other_session);
-
-
-                if (!do_wait) {
-                    done = 1;
-                }
+				ts = switch_timestamp_now();
+				switch_time_exp_lt(&tm, ts);
+				switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
+				switch_channel_set_variable(channel, "fifo_status", "WAITING");
+				switch_channel_set_variable(channel, "fifo_timestamp", date);
+
+				switch_channel_set_variable(other_channel, "fifo_status", "DONE");
+				switch_channel_set_variable(other_channel, "fifo_timestamp", date);
+
+				switch_mutex_lock(node->mutex);
+				node->caller_count--;
+				switch_core_hash_delete(node->caller_hash, uuid);
+				switch_mutex_unlock(node->mutex);
+				send_presence(node);
+				switch_core_session_rwunlock(other_session);
+
+
+				if (!do_wait) {
+					done = 1;
+				}
 
 				fifo_consumer_wrapup_sound = switch_channel_get_variable(channel, "fifo_consumer_wrapup_sound");
 				fifo_consumer_wrapup_key = switch_channel_get_variable(channel, "fifo_consumer_wrapup_key");
@@ -947,33 +947,33 @@
 				}
 
 				if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) {
-					for(;;) {
-						char terminator = 0;                        
-						switch_ivr_collect_digits_count(session, buf, sizeof(buf)-1, 1, fifo_consumer_wrapup_key, &terminator, 0, 0, 0);
+					for (;;) {
+						char terminator = 0;
+						switch_ivr_collect_digits_count(session, buf, sizeof(buf) - 1, 1, fifo_consumer_wrapup_key, &terminator, 0, 0, 0);
 						if (terminator == *fifo_consumer_wrapup_key) {
 							break;
 						}
 					}
 				}
 			}
-			
-            switch_safe_free(uuid);
 
-            if (done) {
-                break;
-            }
-        }
-		
+			switch_safe_free(uuid);
+
+			if (done) {
+				break;
+			}
+		}
+
 		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_event_set_data(channel, event);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_stop");
-            switch_event_fire(&event);
-        }
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_stop");
+			switch_event_fire(&event);
+		}
 
-        if (do_wait) {
+		if (do_wait) {
 			for (i = 0; i < node_count; i++) {
-                if (!(node = node_list[i])) {
+				if (!(node = node_list[i])) {
 					continue;
 				}
 				switch_mutex_lock(node->mutex);
@@ -981,150 +981,150 @@
 				node->consumer_count--;
 				switch_mutex_unlock(node->mutex);
 			}
-        }
-		
-    }
+		}
+
+	}
 }
 
 static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char *tag, int cc_off, int verbose)
 {
-    switch_xml_t x_tmp, x_caller, x_cp, variables;
-    switch_hash_index_t *hi;
-    switch_core_session_t *session;
-    switch_channel_t *channel;
-    void *val;
-    const void *var;
-
-    x_tmp = switch_xml_add_child_d(xml, container, cc_off++);
-    switch_assert(x_tmp);
-
-    for (hi = switch_hash_first(NULL, hash); hi; hi = switch_hash_next(hi)) {
-        int c_off = 0, d_off = 0;
-        const char *status;
-        const char *ts;
-
-        switch_hash_this(hi, &var, NULL, &val);
-        session = (switch_core_session_t *) val;
-        channel = switch_core_session_get_channel(session);
-        x_caller = switch_xml_add_child_d(x_tmp, tag, c_off++);
-        switch_assert(x_caller);
-        
-        switch_xml_set_attr_d(x_caller, "uuid", switch_core_session_get_uuid(session));
-
-        if ((status = switch_channel_get_variable(channel, "fifo_status"))) {
-            switch_xml_set_attr_d(x_caller, "status", status);
-        }
-
-        if ((ts = switch_channel_get_variable(channel, "fifo_timestamp"))) {
-            switch_xml_set_attr_d(x_caller, "timestamp", ts);
-        }
-
-        if ((ts = switch_channel_get_variable(channel, "fifo_target"))) {
-            switch_xml_set_attr_d(x_caller, "target", ts);
-        }
-        
+	switch_xml_t x_tmp, x_caller, x_cp, variables;
+	switch_hash_index_t *hi;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
+	void *val;
+	const void *var;
+
+	x_tmp = switch_xml_add_child_d(xml, container, cc_off++);
+	switch_assert(x_tmp);
+
+	for (hi = switch_hash_first(NULL, hash); hi; hi = switch_hash_next(hi)) {
+		int c_off = 0, d_off = 0;
+		const char *status;
+		const char *ts;
+
+		switch_hash_this(hi, &var, NULL, &val);
+		session = (switch_core_session_t *) val;
+		channel = switch_core_session_get_channel(session);
+		x_caller = switch_xml_add_child_d(x_tmp, tag, c_off++);
+		switch_assert(x_caller);
+
+		switch_xml_set_attr_d(x_caller, "uuid", switch_core_session_get_uuid(session));
+
+		if ((status = switch_channel_get_variable(channel, "fifo_status"))) {
+			switch_xml_set_attr_d(x_caller, "status", status);
+		}
+
+		if ((ts = switch_channel_get_variable(channel, "fifo_timestamp"))) {
+			switch_xml_set_attr_d(x_caller, "timestamp", ts);
+		}
+
+		if ((ts = switch_channel_get_variable(channel, "fifo_target"))) {
+			switch_xml_set_attr_d(x_caller, "target", ts);
+		}
+
 		if (!(x_cp = switch_xml_add_child_d(x_caller, "caller_profile", d_off++))) {
-            abort();
+			abort();
 		}
-        if (verbose) {
-            d_off += switch_ivr_set_xml_profile_data(x_cp, switch_channel_get_caller_profile(channel), d_off);
-        
-            if (!(variables = switch_xml_add_child_d(x_caller, "variables", c_off++))) {
-                abort();
-            }
-        
-            switch_ivr_set_xml_chan_vars(variables, channel, c_off);
-        }
-        
-    }
+		if (verbose) {
+			d_off += switch_ivr_set_xml_profile_data(x_cp, switch_channel_get_caller_profile(channel), d_off);
+
+			if (!(variables = switch_xml_add_child_d(x_caller, "variables", c_off++))) {
+				abort();
+			}
+
+			switch_ivr_set_xml_chan_vars(variables, channel, c_off);
+		}
+
+	}
 
-    return cc_off;
+	return cc_off;
 }
 
 static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int verbose)
 {
 
-    switch_xml_t x_fifo;
-    int cc_off = 0;
-    char buffer[35];
+	switch_xml_t x_fifo;
+	int cc_off = 0;
+	char buffer[35];
 	char *tmp = buffer;
 
-    x_fifo = switch_xml_add_child_d(x_report, "fifo", (*off)++);;
-    switch_assert(x_fifo);
+	x_fifo = switch_xml_add_child_d(x_report, "fifo", (*off)++);;
+	switch_assert(x_fifo);
+
+	switch_xml_set_attr_d(x_fifo, "name", node->name);
+	switch_snprintf(tmp, sizeof(buffer), "%d", node->consumer_count);
+	switch_xml_set_attr_d(x_fifo, "consumer_count", tmp);
+	switch_snprintf(tmp, sizeof(buffer), "%d", node->caller_count);
+	switch_xml_set_attr_d(x_fifo, "caller_count", tmp);
+	switch_snprintf(tmp, sizeof(buffer), "%d", node_consumer_wait_count(node));
+	switch_xml_set_attr_d(x_fifo, "waiting_count", tmp);
+	switch_snprintf(tmp, sizeof(buffer), "%u", node->importance);
+	switch_xml_set_attr_d(x_fifo, "importance", tmp);
 
-    switch_xml_set_attr_d(x_fifo, "name", node->name);
-    switch_snprintf(tmp, sizeof(buffer), "%d", node->consumer_count);
-    switch_xml_set_attr_d(x_fifo, "consumer_count", tmp);
-    switch_snprintf(tmp, sizeof(buffer), "%d", node->caller_count);
-    switch_xml_set_attr_d(x_fifo, "caller_count", tmp);
-    switch_snprintf(tmp, sizeof(buffer), "%d", node_consumer_wait_count(node));
-    switch_xml_set_attr_d(x_fifo, "waiting_count", tmp);
-    switch_snprintf(tmp, sizeof(buffer), "%u", node->importance);
-    switch_xml_set_attr_d(x_fifo, "importance", tmp);
-    
-    cc_off = xml_hash(x_fifo, node->caller_hash, "callers", "caller", cc_off, verbose);
-    cc_off = xml_hash(x_fifo, node->consumer_hash, "consumers", "consumer", cc_off, verbose);
+	cc_off = xml_hash(x_fifo, node->caller_hash, "callers", "caller", cc_off, verbose);
+	cc_off = xml_hash(x_fifo, node->consumer_hash, "consumers", "consumer", cc_off, verbose);
 
 }
 
 #define FIFO_API_SYNTAX "list|list_verbose|count|importance [<fifo name>]"
 SWITCH_STANDARD_API(fifo_api_function)
 {
-    int len = 0;
-    fifo_node_t *node;
-    char *data = NULL;
-    int argc = 0;
-    char *argv[5] = { 0 };
-    switch_hash_index_t *hi;
-    void *val;
-    const void *var;
-    int x = 0, verbose = 0;
-
-
-    if (!globals.running) {
-        return SWITCH_STATUS_FALSE;
-    }
-
-    if (!switch_strlen_zero(cmd)) {
-        data = strdup(cmd);
-        switch_assert(data);
-    }
-    
-    if (switch_strlen_zero(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1 || !argv[0]) {
-        stream->write_function(stream, "%s\n", FIFO_API_SYNTAX);
-        return SWITCH_STATUS_SUCCESS;
-    }
-
-    switch_mutex_lock(globals.mutex);
-    verbose = !strcasecmp(argv[0], "list_verbose");
-
-    if (!strcasecmp(argv[0], "list") || verbose) {    
-        char *xml_text = NULL;
-        switch_xml_t x_report = switch_xml_new("fifo_report");
-        switch_assert(x_report);
-		
-        if (argc < 2) {
-            for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
-                switch_hash_this(hi, &var, NULL, &val);
-                node = (fifo_node_t *) val;
-                switch_mutex_lock(node->mutex);
-                list_node(node, x_report, &x, verbose);
-                switch_mutex_unlock(node->mutex);
-            }
-        } else {
-            if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
-                switch_mutex_lock(node->mutex);
-                list_node(node, x_report, &x, verbose);
-                switch_mutex_unlock(node->mutex);
-            }
-        }
-        xml_text = switch_xml_toxml(x_report, SWITCH_FALSE);
-        switch_assert(xml_text);
-        stream->write_function(stream, "%s\n", xml_text);
-        switch_xml_free(x_report);
-        switch_safe_free(xml_text);
-        
-    } else if (!strcasecmp(argv[0], "importance")) {
+	int len = 0;
+	fifo_node_t *node;
+	char *data = NULL;
+	int argc = 0;
+	char *argv[5] = { 0 };
+	switch_hash_index_t *hi;
+	void *val;
+	const void *var;
+	int x = 0, verbose = 0;
+
+
+	if (!globals.running) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!switch_strlen_zero(cmd)) {
+		data = strdup(cmd);
+		switch_assert(data);
+	}
+
+	if (switch_strlen_zero(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1 || !argv[0]) {
+		stream->write_function(stream, "%s\n", FIFO_API_SYNTAX);
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	switch_mutex_lock(globals.mutex);
+	verbose = !strcasecmp(argv[0], "list_verbose");
+
+	if (!strcasecmp(argv[0], "list") || verbose) {
+		char *xml_text = NULL;
+		switch_xml_t x_report = switch_xml_new("fifo_report");
+		switch_assert(x_report);
+
+		if (argc < 2) {
+			for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
+				switch_hash_this(hi, &var, NULL, &val);
+				node = (fifo_node_t *) val;
+				switch_mutex_lock(node->mutex);
+				list_node(node, x_report, &x, verbose);
+				switch_mutex_unlock(node->mutex);
+			}
+		} else {
+			if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
+				switch_mutex_lock(node->mutex);
+				list_node(node, x_report, &x, verbose);
+				switch_mutex_unlock(node->mutex);
+			}
+		}
+		xml_text = switch_xml_toxml(x_report, SWITCH_FALSE);
+		switch_assert(xml_text);
+		stream->write_function(stream, "%s\n", xml_text);
+		switch_xml_free(x_report);
+		switch_safe_free(xml_text);
+
+	} else if (!strcasecmp(argv[0], "importance")) {
 		if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
 			int importance = 0;
 			if (argc > 2) {
@@ -1138,40 +1138,40 @@
 		} else {
 			stream->write_function(stream, "no fifo by that name\n");
 		}
-    } else if (!strcasecmp(argv[0], "count")) {
-        if (argc < 2) {
-            for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
-                switch_hash_this(hi, &var, NULL, &val);
-                node = (fifo_node_t *) val;
+	} else if (!strcasecmp(argv[0], "count")) {
+		if (argc < 2) {
+			for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
+				switch_hash_this(hi, &var, NULL, &val);
+				node = (fifo_node_t *) val;
 				len = node_consumer_wait_count(node);
-                switch_mutex_lock(node->mutex);
-                stream->write_function(stream, "%s:%d:%d:%d\n", (char *)var, node->consumer_count, node->caller_count, len);
-                switch_mutex_unlock(node->mutex);
-                x++;
-            }
-            
-            if (!x) {
-                stream->write_function(stream, "none\n");
-            }
-        } else if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
+				switch_mutex_lock(node->mutex);
+				stream->write_function(stream, "%s:%d:%d:%d\n", (char *) var, node->consumer_count, node->caller_count, len);
+				switch_mutex_unlock(node->mutex);
+				x++;
+			}
+
+			if (!x) {
+				stream->write_function(stream, "none\n");
+			}
+		} else if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
 			len = node_consumer_wait_count(node);
-            switch_mutex_lock(node->mutex);
-            stream->write_function(stream, "%s:%d:%d:%d\n", argv[1], node->consumer_count, node->caller_count, len);
-            switch_mutex_unlock(node->mutex);
+			switch_mutex_lock(node->mutex);
+			stream->write_function(stream, "%s:%d:%d:%d\n", argv[1], node->consumer_count, node->caller_count, len);
+			switch_mutex_unlock(node->mutex);
 		} else {
 			stream->write_function(stream, "none\n");
-        }
-    }
+		}
+	}
 
-    switch_mutex_unlock(globals.mutex);
-    return SWITCH_STATUS_SUCCESS;
+	switch_mutex_unlock(globals.mutex);
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
 {
 	switch_application_interface_t *app_interface;
-    switch_api_interface_t *commands_api_interface;
+	switch_api_interface_t *commands_api_interface;
 
 
 	/* create/register custom event message type */
@@ -1186,15 +1186,15 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-    switch_core_new_memory_pool(&globals.pool);
-    switch_core_hash_init(&globals.fifo_hash, globals.pool);
-    switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
+	switch_core_new_memory_pool(&globals.pool);
+	switch_core_hash_init(&globals.fifo_hash, globals.pool);
+	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_APP(app_interface, "fifo", "Park with FIFO", FIFO_DESC, fifo_function, FIFO_USAGE, SAF_NONE);
-    SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
-    globals.running = 1;
+	SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
+	globals.running = 1;
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1204,32 +1204,32 @@
 */
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
 {
-    switch_hash_index_t *hi;
-    void *val, *pop;
-    fifo_node_t *node;
-    switch_memory_pool_t *pool = globals.pool;
-    switch_mutex_t *mutex = globals.mutex;
-
-    switch_mutex_lock(mutex);
-    
-    globals.running = 0;
-    /* Cleanup*/
-    for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
-		int x = 0 ;
-        switch_hash_this(hi, NULL, NULL, &val);
-        node = (fifo_node_t *) val;
+	switch_hash_index_t *hi;
+	void *val, *pop;
+	fifo_node_t *node;
+	switch_memory_pool_t *pool = globals.pool;
+	switch_mutex_t *mutex = globals.mutex;
+
+	switch_mutex_lock(mutex);
+
+	globals.running = 0;
+	/* Cleanup */
+	for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
+		int x = 0;
+		switch_hash_this(hi, NULL, NULL, &val);
+		node = (fifo_node_t *) val;
 		for (x = 0; x < MAX_PRI; x++) {
 			while (switch_queue_trypop(node->fifo_list[x], &pop) == SWITCH_STATUS_SUCCESS) {
 				free(pop);
 			}
 		}
-        switch_core_hash_destroy(&node->caller_hash);
-        switch_core_hash_destroy(&node->consumer_hash);
-    }
-    switch_core_hash_destroy(&globals.fifo_hash);
-    memset(&globals, 0, sizeof(globals));    
-    switch_mutex_unlock(mutex);
-    switch_core_destroy_memory_pool(&pool);
+		switch_core_hash_destroy(&node->caller_hash);
+		switch_core_hash_destroy(&node->consumer_hash);
+	}
+	switch_core_hash_destroy(&globals.fifo_hash);
+	memset(&globals, 0, sizeof(globals));
+	switch_mutex_unlock(mutex);
+	switch_core_destroy_memory_pool(&pool);
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fsv/mod_fsv.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fsv/mod_fsv.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_fsv/mod_fsv.c	Tue May 27 07:24:06 2008
@@ -61,35 +61,35 @@
 	switch_status_t status;
 	switch_frame_t *read_frame;
 	int bytes;
-	
-	eh->up = 1;	
-	while(switch_channel_ready(channel)) {
+
+	eh->up = 1;
+	while (switch_channel_ready(channel)) {
 		status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
-		
+
 		if (switch_test_flag(read_frame, SFF_CNG)) {
 			continue;
 		}
 
-		bytes = read_frame->packetlen |VID_BIT;
-		
+		bytes = read_frame->packetlen | VID_BIT;
+
 		switch_mutex_lock(eh->mutex);
-		
-		if (write(eh->fd, &bytes, sizeof(bytes)) != (int)sizeof(bytes)) {
+
+		if (write(eh->fd, &bytes, sizeof(bytes)) != (int) sizeof(bytes)) {
 			switch_mutex_unlock(eh->mutex);
 			break;
 		}
 
-		if (write(eh->fd, read_frame->packet, read_frame->packetlen) != (int)read_frame->packetlen) {
+		if (write(eh->fd, read_frame->packet, read_frame->packetlen) != (int) read_frame->packetlen) {
 			switch_mutex_unlock(eh->mutex);
 			break;
 		}
 
 		switch_mutex_unlock(eh->mutex);
-        
+
 		switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
 	}
 	eh->up = 0;
@@ -101,24 +101,24 @@
 	switch_status_t status;
 	switch_frame_t *read_frame;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	struct record_helper eh = {0};
+	struct record_helper eh = { 0 };
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 	int fd;
 	switch_mutex_t *mutex = NULL;
 	switch_codec_t codec, *read_codec, *vid_codec;
-	
+
 	switch_channel_answer(channel);
-	
-	if ((fd = open((char *)data, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
+
+	if ((fd = open((char *) data, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
 		return;
 	}
-	
+
 	switch_channel_answer(channel);
 
 	read_codec = switch_core_session_get_read_codec(session);
-	
+
 	if (switch_core_codec_init(&codec,
 							   "L16",
 							   NULL,
@@ -131,14 +131,14 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Audio Codec Activation Fail\n");
 		goto end;
 	}
-	
+
 	switch_core_session_set_read_codec(session, &codec);
-	
+
 	if (switch_channel_test_flag(channel, CF_VIDEO)) {
 		struct file_header h;
 		memset(&h, 0, sizeof(h));
 		vid_codec = switch_core_session_get_video_read_codec(session);
-		
+
 		h.version = VERSION;
 		h.created = switch_timestamp_now();
 		switch_set_string(h.video_codec_name, vid_codec->implementation->iananame);
@@ -147,11 +147,11 @@
 		}
 		h.audio_rate = read_codec->implementation->samples_per_second;
 		h.audio_ptime = read_codec->implementation->microseconds_per_frame / 1000;
-		
+
 		if (write(fd, &h, sizeof(h)) != sizeof(h)) {
 			goto end;
 		}
-		
+
 		switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 		eh.mutex = mutex;
 		eh.fd = fd;
@@ -161,12 +161,12 @@
 		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 		switch_thread_create(&thread, thd_attr, record_video_thread, &eh, switch_core_session_get_pool(session));
 	}
-	
-	
-	while(switch_channel_ready(channel)) {
+
+
+	while (switch_channel_ready(channel)) {
 
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-		
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
@@ -186,7 +186,7 @@
 			break;
 		}
 
-		if (write(fd, read_frame->data, read_frame->datalen) != (int)read_frame->datalen) {
+		if (write(fd, read_frame->data, read_frame->datalen) != (int) read_frame->datalen) {
 			if (mutex) {
 				switch_mutex_unlock(mutex);
 			}
@@ -198,42 +198,44 @@
 		}
 	}
 
-	
- end:
+
+  end:
 
 	if (eh.up) {
-		while(eh.up) {
+		while (eh.up) {
 			switch_yield(1000);
 		}
 	}
 
 	switch_core_session_set_read_codec(session, read_codec);
 	switch_core_codec_destroy(&codec);
-	
+
 }
 
 SWITCH_STANDARD_APP(play_fsv_function)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	switch_frame_t write_frame = {0}, vid_frame = {0};
+	switch_frame_t write_frame = { 0 }, vid_frame = {
+	0};
 	int fd = -1;
 	int bytes;
-	switch_codec_t *read_codec = NULL, codec = {0}, vid_codec = {0}, *read_vid_codec;
+	switch_codec_t *read_codec = NULL, codec = { 0 }, vid_codec = {
+	0}, *read_vid_codec;
 	unsigned char *aud_buffer;
 	unsigned char *vid_buffer;
 	struct file_header h;
-	uint32_t ts = 0, last = 0;	
-	switch_timer_t timer = {0};
+	uint32_t ts = 0, last = 0;
+	switch_timer_t timer = { 0 };
 	switch_payload_t pt = 0;
 
 	aud_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
 	vid_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
-	
-	if ((fd = open((char *)data, O_RDONLY)) < 0) {
+
+	if ((fd = open((char *) data, O_RDONLY)) < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
 		return;
 	}
-	
+
 	if (read(fd, &h, sizeof(h)) != sizeof(h)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "error reading file header\n");
 		goto end;
@@ -246,7 +248,7 @@
 
 	switch_channel_set_variable(channel, "sip_force_video_fmtp", h.video_fmtp);
 	switch_channel_answer(channel);
-	
+
 	if ((read_vid_codec = switch_core_session_get_video_read_codec(session))) {
 		pt = read_vid_codec->agreed_pt;
 	}
@@ -254,16 +256,16 @@
 	write_frame.codec = &codec;
 	write_frame.data = aud_buffer;
 	write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
-	
+
 	vid_frame.codec = &vid_codec;
 	vid_frame.packet = vid_buffer;
 	vid_frame.data = vid_buffer + 12;
 	vid_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE - 12;
 	switch_set_flag((&vid_frame), SFF_RAW_RTP);
-	
+
 	read_codec = switch_core_session_get_read_codec(session);
 
-	if (switch_core_timer_init(&timer, "soft", read_codec->implementation->microseconds_per_frame / 1000, 
+	if (switch_core_timer_init(&timer, "soft", read_codec->implementation->microseconds_per_frame / 1000,
 							   read_codec->implementation->samples_per_frame, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "timer Activation Fail\n");
 		goto end;
@@ -281,7 +283,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Audio Codec Activation Fail\n");
 		goto end;
 	}
-	
+
 	if (switch_core_codec_init(&vid_codec,
 							   h.video_codec_name,
 							   NULL,
@@ -296,20 +298,20 @@
 	}
 	switch_core_session_set_read_codec(session, &codec);
 
-	while(switch_channel_ready(channel)) {
+	while (switch_channel_ready(channel)) {
 
 		if (read(fd, &bytes, sizeof(bytes)) != sizeof(bytes)) {
 			break;
 		}
-		
+
 		if (bytes & VID_BIT) {
 			switch_rtp_hdr_t *hdr = vid_frame.packet;
 			bytes &= ~VID_BIT;
 
-			if ((vid_frame.packetlen = read(fd, vid_frame.packet, bytes)) != (uint32_t)bytes) {
+			if ((vid_frame.packetlen = read(fd, vid_frame.packet, bytes)) != (uint32_t) bytes) {
 				break;
 			}
-			
+
 			ts = ntohl(hdr->ts);
 			if (pt) {
 				hdr->pt = pt;
@@ -322,7 +324,7 @@
 			}
 			last = ts;
 		} else {
-			if (bytes > (int)write_frame.buflen) {
+			if (bytes > (int) write_frame.buflen) {
 				bytes = write_frame.buflen;
 			}
 			if ((write_frame.datalen = read(fd, write_frame.data, bytes)) <= 0) {
@@ -333,9 +335,9 @@
 		}
 
 	}
-	
- end:
-	
+
+  end:
+
 	if (timer.interval) {
 		switch_core_timer_destroy(&timer);
 	}
@@ -343,15 +345,15 @@
 	if (read_codec) {
 		switch_core_session_set_read_codec(session, read_codec);
 	}
-	
+
 	if (codec.implementation) {
 		switch_core_codec_destroy(&codec);
 	}
-	
+
 	if (vid_codec.implementation) {
 		switch_core_codec_destroy(&vid_codec);
 	}
-	
+
 	if (fd > -1) {
 		close(fd);
 	}
@@ -362,7 +364,7 @@
 	switch_application_interface_t *app_interface;
 
 	/* connect my internal structure to the blank pointer passed to me */
-    *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	SWITCH_ADD_APP(app_interface, "play_fsv", "play an fsv file", "play an fsv file", play_fsv_function, "<file>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "record_fsv", "record an fsv file", "record an fsv file", record_fsv_function, "<file>", SAF_NONE);

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_limit/mod_limit.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_limit/mod_limit.c	Tue May 27 07:24:06 2008
@@ -53,28 +53,16 @@
 
 static char limit_sql[] =
 	"CREATE TABLE limit_data (\n"
-	"   hostname   VARCHAR(255),\n"
-	"   realm      VARCHAR(255),\n"
-	"   id         VARCHAR(255),\n" 
-	"   uuid       VARCHAR(255)\n"
-	");\n";
+	"   hostname   VARCHAR(255),\n" "   realm      VARCHAR(255),\n" "   id         VARCHAR(255),\n" "   uuid       VARCHAR(255)\n" ");\n";
 
 
 static char db_sql[] =
 	"CREATE TABLE db_data (\n"
-	"   hostname   VARCHAR(255),\n"
-	"   realm      VARCHAR(255),\n"
-	"   data_key   VARCHAR(255),\n" 
-	"   data       VARCHAR(255)\n"
-	");\n";
+	"   hostname   VARCHAR(255),\n" "   realm      VARCHAR(255),\n" "   data_key   VARCHAR(255),\n" "   data       VARCHAR(255)\n" ");\n";
 
 
 static char group_sql[] =
-	"CREATE TABLE group_data (\n"
-	"   hostname   VARCHAR(255),\n"
-	"   groupname  VARCHAR(255),\n"
-	"   url        VARCHAR(255)\n"
-	");\n";
+	"CREATE TABLE group_data (\n" "   hostname   VARCHAR(255),\n" "   groupname  VARCHAR(255),\n" "   url        VARCHAR(255)\n" ");\n";
 
 
 
@@ -86,9 +74,8 @@
 	if (mutex) {
 		switch_mutex_lock(mutex);
 	}
-
 #ifdef SWITCH_HAVE_ODBC
-    if (globals.odbc_dsn) {
+	if (globals.odbc_dsn) {
 		SQLHSTMT stmt;
 		if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
 			char *err_str;
@@ -110,33 +97,29 @@
 		switch_core_db_close(db);
 
 #ifdef SWITCH_HAVE_ODBC
-    }
+	}
 #endif
 
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
 
-    return status;
+	return status;
 }
 
 
-static switch_bool_t limit_execute_sql_callback(switch_mutex_t *mutex,
-                                                char *sql,
-                                                switch_core_db_callback_func_t callback,
-                                                void *pdata)
+static switch_bool_t limit_execute_sql_callback(switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)
 {
 	switch_bool_t ret = SWITCH_FALSE;
 	switch_core_db_t *db;
 	char *errmsg = NULL;
-	
+
 	if (mutex) {
 		switch_mutex_lock(mutex);
 	}
 
-
 #ifdef SWITCH_HAVE_ODBC
 	if (globals.odbc_dsn) {
 		switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata);
@@ -161,7 +144,7 @@
 	}
 #endif
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -185,12 +168,12 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
-    
+
 	if ((settings = switch_xml_child(cfg, "settings"))) {
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
 			char *var = NULL;
 			char *val = NULL;
-            
+
 			var = (char *) switch_xml_attr_soft(param, "name");
 			val = (char *) switch_xml_attr_soft(param, "value");
 
@@ -198,9 +181,9 @@
 #ifdef SWITCH_HAVE_ODBC
 				globals.odbc_dsn = switch_core_strdup(globals.pool, val);
 				if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
-				*odbc_user++ = '\0';
+					*odbc_user++ = '\0';
 					if ((odbc_pass = strchr(odbc_user, ':'))) {
-					*odbc_pass++ = '\0';
+						*odbc_pass++ = '\0';
 					}
 				}
 #else
@@ -214,7 +197,6 @@
 	if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) {
 		globals.dbname = "call_limit";
 	}
-    
 
 #ifdef SWITCH_HAVE_ODBC
 	if (globals.odbc_dsn) {
@@ -228,11 +210,11 @@
 			status = SWITCH_STATUS_FALSE;
 			goto done;
 		}
-        
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.odbc_dsn);
 		if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from limit_data", NULL) != SWITCH_STATUS_SUCCESS) {
 			if (switch_odbc_handle_exec(globals.master_odbc, limit_sql, NULL) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
 			}
 		}
 		if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from db_data", NULL) != SWITCH_STATUS_SUCCESS) {
@@ -258,10 +240,10 @@
 		}
 		switch_core_db_close(db);
 #ifdef SWITCH_HAVE_ODBC
-	}           
+	}
 #endif
 
- done:
+  done:
 
 	sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
 	limit_execute_sql(sql, globals.mutex);
@@ -284,8 +266,8 @@
 	if (state == CS_HANGUP || state == CS_ROUTING) {
 		id = switch_channel_get_variable(channel, "limit_id");
 		realm = switch_channel_get_variable(channel, "limit_realm");
-		sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';", 
-                             switch_core_session_get_uuid(session), globals.hostname, realm, id);
+		sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';",
+							 switch_core_session_get_uuid(session), globals.hostname, realm, id);
 		limit_execute_sql(sql, globals.mutex);
 		switch_safe_free(sql);
 		switch_core_event_hook_remove_state_change(session, hanguphook);
@@ -343,8 +325,10 @@
 		sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
 		assert(sql);
 		limit_execute_sql(sql, NULL);
-		switch_safe_free(sql);    
-		sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
+		switch_safe_free(sql);
+		sql =
+			switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2],
+						   argv[3]);
 		assert(sql);
 		limit_execute_sql(sql, NULL);
 		switch_safe_free(sql);
@@ -357,7 +341,7 @@
 		sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
 		assert(sql);
 		limit_execute_sql(sql, NULL);
-		switch_safe_free(sql);    
+		switch_safe_free(sql);
 		stream->write_function(stream, "+OK");
 		goto done;
 	} else if (!strcasecmp(argv[0], "select")) {
@@ -372,18 +356,18 @@
 		limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
 		stream->write_function(stream, "%s", buf);
 		goto done;
-	} 
+	}
 
 
- error:
+  error:
 	stream->write_function(stream, "!err!");
-    
- done:
+
+  done:
 
 	switch_mutex_unlock(globals.mutex);
 	switch_safe_free(mydata);
 	return SWITCH_STATUS_SUCCESS;
-    
+
 }
 
 
@@ -411,8 +395,10 @@
 		switch_assert(sql);
 		limit_execute_sql(sql, globals.mutex);
 		switch_safe_free(sql);
-        
-		sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
+
+		sql =
+			switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2],
+						   argv[3]);
 	} else if (!strcasecmp(argv[0], "delete")) {
 		sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
 	}
@@ -422,7 +408,7 @@
 	switch_safe_free(sql);
 	return;
 
-error:
+  error:
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
 }
 
@@ -481,7 +467,7 @@
 		callback_t cbt = { 0 };
 		cbt.buf = buf;
 		cbt.len = sizeof(buf);
-        
+
 		if (argc > 2) {
 			if (!strcasecmp(argv[2], "order")) {
 				how = "|";
@@ -497,15 +483,15 @@
 		goto done;
 	}
 
- error:
+  error:
 	stream->write_function(stream, "!err!");
-    
- done:
+
+  done:
 
 	switch_mutex_unlock(globals.mutex);
 	switch_safe_free(mydata);
 	return SWITCH_STATUS_SUCCESS;
-    
+
 }
 
 #define GROUP_USAGE "[insert|delete]:<group name>:<val>"
@@ -544,7 +530,7 @@
 
 #define LIMIT_USAGE "<realm> <id> <max> [transfer_destination_number]"
 #define LIMIT_DESC "limit access to an extension"
-static char *limit_def_xfer_exten="limit_exceeded";
+static char *limit_def_xfer_exten = "limit_exceeded";
 
 SWITCH_STANDARD_APP(limit_function)
 {
@@ -585,7 +571,7 @@
 	if (max < 0) {
 		max = 0;
 	}
-    
+
 	switch_channel_set_variable(channel, "limit_realm", realm);
 	switch_channel_set_variable(channel, "limit_id", id);
 	switch_channel_set_variable(channel, "limit_max", argv[2]);
@@ -602,11 +588,13 @@
 	}
 
 	switch_core_event_hook_add_state_change(session, hanguphook);
-	sql = switch_mprintf("insert into limit_data (hostname, realm, id, uuid) values('%q','%q','%q','%q');", globals.hostname, realm, id, switch_core_session_get_uuid(session));
+	sql =
+		switch_mprintf("insert into limit_data (hostname, realm, id, uuid) values('%q','%q','%q','%q');", globals.hostname, realm, id,
+					   switch_core_session_get_uuid(session));
 	limit_execute_sql(sql, NULL);
 	switch_safe_free(sql);
 
-done:
+  done:
 	switch_mutex_unlock(globals.mutex);
 }
 
@@ -626,7 +614,7 @@
 	}
 
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
-    
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_rss/mod_rss.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_rss/mod_rss.c	Tue May 27 07:24:06 2008
@@ -91,7 +91,7 @@
 {
 	switch (itype) {
 	case SWITCH_INPUT_TYPE_DTMF:{
-		switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+			switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
 			struct dtmf_buffer *dtb;
 			dtb = (struct dtmf_buffer *) buf;
 
@@ -175,7 +175,8 @@
 	uint32_t last;
 	char *mydata = NULL;
 	char *filename = NULL;
-	char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {0};
+	char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {
+	0};
 	int argc, feed_index = 0;
 	const char *cf = "rss.conf";
 	switch_xml_t cfg, cxml, feeds, feed;
@@ -311,12 +312,12 @@
 			switch_core_speech_flush_tts(&sh);
 #ifdef MATCH_COUNT
 			switch_snprintf(buf + len, sizeof(buf) - len, "%s",
-					 ",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
-					 "Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
+							",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
+							"Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
 #else
 			switch_snprintf(buf + len, sizeof(buf) - len, "%s",
-					 ",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
-					 "Select one of the following news sources, followed by the pound key or press 0 to exit. " ",<break time=\"600ms\"/>");
+							",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
+							"Select one of the following news sources, followed by the pound key or press 0 to exit. " ",<break time=\"600ms\"/>");
 #endif
 			len = (int32_t) strlen(buf);
 
@@ -482,8 +483,8 @@
 
 
 			switch_snprintf(buf, sizeof(buf),
-					 ",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
-					 title_txt, description_txt, rights_txt, date);
+							",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
+							title_txt, description_txt, rights_txt, date);
 			args.input_callback = NULL;
 			args.buf = dtmf;
 			args.buflen = sizeof(dtmf);
@@ -539,7 +540,8 @@
 					}
 					if (switch_test_flag(&dtb, SFLAG_INFO)) {
 						switch_clear_flag(&dtb, SFLAG_INFO);
-						switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
+						switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice,
+										dtb.speed);
 						tmplen = (uint32_t) strlen(tmpbuf);
 					}
 
@@ -547,12 +549,12 @@
 						switch_clear_flag(&dtb, SFLAG_INSTRUCT);
 						cont = 1;
 						switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s",
-								 "Press star to pause or resume speech. "
-								 "To go to the next item, press six. "
-								 "To go back, press 4. "
-								 "Press two to go faster, eight to slow down, or 7 to resume normal speed. "
-								 "To change voices, press five. To restore the original voice press 9. "
-								 "To hear these options again, press zero or press pound to return to the main menu. ");
+										"Press star to pause or resume speech. "
+										"To go to the next item, press six. "
+										"To go back, press 4. "
+										"Press two to go faster, eight to slow down, or 7 to resume normal speed. "
+										"To change voices, press five. To restore the original voice press 9. "
+										"To hear these options again, press zero or press pound to return to the main menu. ");
 					} else {
 						switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "Story %d. ", dtb.index + 1);
 						tmplen = (uint32_t) strlen(tmpbuf);

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_skel/mod_skel.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_skel/mod_skel.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_skel/mod_skel.c	Tue May 27 07:24:06 2008
@@ -41,7 +41,7 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
 {
 	/* connect my internal structure to the blank pointer passed to me */
-    *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	Tue May 27 07:24:06 2008
@@ -43,107 +43,107 @@
 SWITCH_MODULE_DEFINITION(mod_soundtouch, mod_soundtouch_load, NULL, NULL);
 
 struct soundtouch_helper {
-    SoundTouch *st;
-    switch_core_session_t *session;
-    int send;
-    int read;
-    float pitch;
-    float octaves;
-    float semi;
-    float rate;
-    float tempo;
-    int literal;
+	SoundTouch *st;
+	switch_core_session_t *session;
+	int send;
+	int read;
+	float pitch;
+	float octaves;
+	float semi;
+	float rate;
+	float tempo;
+	int literal;
 };
 
 static switch_status_t on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
 {
 
-    switch_media_bug_t *bug;
-    switch_channel_t *channel = switch_core_session_get_channel(session);
-    
-    if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
-        struct soundtouch_helper *sth = (struct soundtouch_helper *) switch_core_media_bug_get_user_data(bug);
-        
-        if (sth) {
-            if (sth->literal) {
-                sth->literal = 0;
-                return SWITCH_STATUS_SUCCESS;
-            }
-
-            
-            switch(dtmf->digit) {
-            case '*':
-                sth->literal++;
-                break;
-            case '3':
-                sth->semi += .5;
-                sth->st->setPitchSemiTones(sth->semi);
-                sth->st->flush();
-                break;
-            case '2':
-                sth->semi = 0;
-                sth->st->setPitchSemiTones(sth->semi);
-                sth->st->flush();
-                break;
-            case '1':
-                sth->semi -= .5;
-                sth->st->setPitchSemiTones(sth->semi);
-                sth->st->flush();
-                break;
-
-            case '6':
-                sth->pitch += .2;
-                sth->st->setPitch(sth->pitch);
-                sth->st->flush();
-                break;
-            case '5':
-                sth->pitch = 1;
-                sth->st->setPitch(sth->pitch);
-                sth->st->flush();
-                break;
-            case '4':
-                sth->pitch -= .2;
-                if (sth->pitch <= 0) {
-                    sth->pitch = .2;
-                }
-                sth->st->setPitch(sth->pitch);
-                sth->st->flush();
-                break;
-
-            case '9':
-                sth->octaves += .2;
-                sth->st->setPitchOctaves(sth->octaves);
-                sth->st->flush();
-                break;
-            case '8':
-                sth->octaves = 0;
-                sth->st->setPitchOctaves(sth->octaves);
-                sth->st->flush();
-                break;
-            case '7':
-                sth->octaves -= .2;
-                sth->st->setPitchOctaves(sth->octaves);
-                sth->st->flush();
-                break;
-
-
-            case '0':
-                sth->octaves = 0;
-                sth->st->setPitchOctaves(sth->octaves);
-                sth->pitch = 1;
-                sth->st->setPitch(sth->pitch);
-                sth->semi = 0;
-                sth->st->setPitchSemiTones(sth->semi);
-                sth->st->flush();
-                    
-            }
-
-        }
-        
-
-        return SWITCH_STATUS_FALSE;
-    }
-    return SWITCH_STATUS_SUCCESS;
+	switch_media_bug_t *bug;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+	if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
+		struct soundtouch_helper *sth = (struct soundtouch_helper *) switch_core_media_bug_get_user_data(bug);
+
+		if (sth) {
+			if (sth->literal) {
+				sth->literal = 0;
+				return SWITCH_STATUS_SUCCESS;
+			}
+
+
+			switch (dtmf->digit) {
+			case '*':
+				sth->literal++;
+				break;
+			case '3':
+				sth->semi += .5;
+				sth->st->setPitchSemiTones(sth->semi);
+				sth->st->flush();
+				break;
+			case '2':
+				sth->semi = 0;
+				sth->st->setPitchSemiTones(sth->semi);
+				sth->st->flush();
+				break;
+			case '1':
+				sth->semi -= .5;
+				sth->st->setPitchSemiTones(sth->semi);
+				sth->st->flush();
+				break;
+
+			case '6':
+				sth->pitch += .2;
+				sth->st->setPitch(sth->pitch);
+				sth->st->flush();
+				break;
+			case '5':
+				sth->pitch = 1;
+				sth->st->setPitch(sth->pitch);
+				sth->st->flush();
+				break;
+			case '4':
+				sth->pitch -= .2;
+				if (sth->pitch <= 0) {
+					sth->pitch = .2;
+				}
+				sth->st->setPitch(sth->pitch);
+				sth->st->flush();
+				break;
+
+			case '9':
+				sth->octaves += .2;
+				sth->st->setPitchOctaves(sth->octaves);
+				sth->st->flush();
+				break;
+			case '8':
+				sth->octaves = 0;
+				sth->st->setPitchOctaves(sth->octaves);
+				sth->st->flush();
+				break;
+			case '7':
+				sth->octaves -= .2;
+				sth->st->setPitchOctaves(sth->octaves);
+				sth->st->flush();
+				break;
+
+
+			case '0':
+				sth->octaves = 0;
+				sth->st->setPitchOctaves(sth->octaves);
+				sth->pitch = 1;
+				sth->st->setPitch(sth->pitch);
+				sth->semi = 0;
+				sth->st->setPitchSemiTones(sth->semi);
+				sth->st->flush();
+
+			}
+
+		}
+
+
+		return SWITCH_STATUS_FALSE;
+	}
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
@@ -153,85 +153,85 @@
 
 	switch (type) {
 	case SWITCH_ABC_TYPE_INIT:
-        {
-            switch_codec_t *read_codec = switch_core_session_get_read_codec(sth->session);
-            sth->st = new SoundTouch();
-            sth->st->setSampleRate(read_codec->implementation->samples_per_second);
-            sth->st->setChannels(read_codec->implementation->number_of_channels);
-            
-            sth->st->setSetting(SETTING_USE_QUICKSEEK, 1);
-            sth->st->setSetting(SETTING_USE_AA_FILTER, 1);
-
-            if (sth->semi) {
-                sth->st->setPitchSemiTones(sth->semi);
-            }
-
-            if (sth->pitch) {
-                sth->st->setPitch(sth->pitch);
-            }
-
-            if (sth->octaves) {
-                sth->st->setPitchOctaves(sth->octaves);
-            }
-
-            if (sth->rate) {
-                sth->st->setRate(sth->rate);
-            }
-
-            if (sth->tempo) {
-                sth->st->setRate(sth->tempo);
-            }
-            
-            if (sth->send) {
-                switch_core_event_hook_add_send_dtmf(sth->session, on_dtmf);
-            } else {
-                switch_core_event_hook_add_recv_dtmf(sth->session, on_dtmf);
-            }
-        }
-        break;
+		{
+			switch_codec_t *read_codec = switch_core_session_get_read_codec(sth->session);
+			sth->st = new SoundTouch();
+			sth->st->setSampleRate(read_codec->implementation->samples_per_second);
+			sth->st->setChannels(read_codec->implementation->number_of_channels);
+
+			sth->st->setSetting(SETTING_USE_QUICKSEEK, 1);
+			sth->st->setSetting(SETTING_USE_AA_FILTER, 1);
+
+			if (sth->semi) {
+				sth->st->setPitchSemiTones(sth->semi);
+			}
+
+			if (sth->pitch) {
+				sth->st->setPitch(sth->pitch);
+			}
+
+			if (sth->octaves) {
+				sth->st->setPitchOctaves(sth->octaves);
+			}
+
+			if (sth->rate) {
+				sth->st->setRate(sth->rate);
+			}
+
+			if (sth->tempo) {
+				sth->st->setRate(sth->tempo);
+			}
+
+			if (sth->send) {
+				switch_core_event_hook_add_send_dtmf(sth->session, on_dtmf);
+			} else {
+				switch_core_event_hook_add_recv_dtmf(sth->session, on_dtmf);
+			}
+		}
+		break;
 	case SWITCH_ABC_TYPE_CLOSE:
-        {
-            delete sth->st;
-            if (sth->send) {
-                switch_core_event_hook_remove_send_dtmf(sth->session, on_dtmf);
-            } else {
-                switch_core_event_hook_remove_recv_dtmf(sth->session, on_dtmf);
-            }
-        }
+		{
+			delete sth->st;
+			if (sth->send) {
+				switch_core_event_hook_remove_send_dtmf(sth->session, on_dtmf);
+			} else {
+				switch_core_event_hook_remove_recv_dtmf(sth->session, on_dtmf);
+			}
+		}
 		break;
 	case SWITCH_ABC_TYPE_READ:
 	case SWITCH_ABC_TYPE_WRITE:
-        break;
+		break;
 	case SWITCH_ABC_TYPE_READ_REPLACE:
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
-        {
-            switch_frame_t *frame;
-            
-            assert(sth != NULL);
-            assert(sth->st != NULL);
-
-            if (sth->read) {
-                frame = switch_core_media_bug_get_read_replace_frame(bug);
-            } else {
-                frame = switch_core_media_bug_get_write_replace_frame(bug);
-            }
-
-            sth->st->putSamples((SAMPLETYPE *)frame->data, frame->samples);
-
-            if (sth->st->numSamples() >= frame->samples * 2) {
-                frame->samples = sth->st->receiveSamples((SAMPLETYPE *)frame->data, frame->samples);
-                frame->datalen = frame->samples * 2;
-            } else {
-                memset(frame->data, 0, frame->datalen);
-            }
-
-            if (sth->read) {
-                switch_core_media_bug_set_read_replace_frame(bug, frame);
-            } else {
-                switch_core_media_bug_set_write_replace_frame(bug, frame);
-            }
-            
-        }
+		{
+			switch_frame_t *frame;
+
+			assert(sth != NULL);
+			assert(sth->st != NULL);
+
+			if (sth->read) {
+				frame = switch_core_media_bug_get_read_replace_frame(bug);
+			} else {
+				frame = switch_core_media_bug_get_write_replace_frame(bug);
+			}
+
+			sth->st->putSamples((SAMPLETYPE *) frame->data, frame->samples);
+
+			if (sth->st->numSamples() >= frame->samples * 2) {
+				frame->samples = sth->st->receiveSamples((SAMPLETYPE *) frame->data, frame->samples);
+				frame->datalen = frame->samples * 2;
+			} else {
+				memset(frame->data, 0, frame->datalen);
+			}
+
+			if (sth->read) {
+				switch_core_media_bug_set_read_replace_frame(bug, frame);
+			} else {
+				switch_core_media_bug_set_write_replace_frame(bug, frame);
+			}
+
+		}
 	default:
 		break;
 	}
@@ -241,68 +241,68 @@
 
 SWITCH_STANDARD_APP(soundtouch_start_function)
 {
-    switch_media_bug_t *bug;
-    switch_status_t status;
-    switch_channel_t *channel = switch_core_session_get_channel(session);
-    struct soundtouch_helper *sth;
-    char *argv[6];
+	switch_media_bug_t *bug;
+	switch_status_t status;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	struct soundtouch_helper *sth;
+	char *argv[6];
 	int argc;
 	char *lbuf = NULL;
-    int x;
- 
-    if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
-        if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) {
-            switch_channel_set_private(channel, "_soundtouch_", NULL);
-            switch_core_media_bug_remove(session, &bug);
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
-        }
-        return;
-    }
+	int x;
+
+	if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
+		if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) {
+			switch_channel_set_private(channel, "_soundtouch_", NULL);
+			switch_core_media_bug_remove(session, &bug);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
+		}
+		return;
+	}
 
-    sth = (struct soundtouch_helper *) switch_core_session_alloc(session, sizeof(*sth));
-    assert(sth != NULL);
+	sth = (struct soundtouch_helper *) switch_core_session_alloc(session, sizeof(*sth));
+	assert(sth != NULL);
 
 
 	if (data && (lbuf = switch_core_session_strdup(session, data))
 		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
-        sth->send = 0;
-        sth->read = 0;
-        sth->pitch = 1;
-        for(x = 0; x < argc; x++) {
-            if (!strncasecmp(argv[x], "send", 4)) {
-                sth->send = 1;
-            } else if (!strncasecmp(argv[x], "read", 4)) {
-                sth->read = 1;
-            } else if (strchr(argv[x], 'p')) {
-                if ((sth->pitch = atof(argv[x]) < 0)) {
-                    sth->pitch = 0;
-                }
-            } else if (strchr(argv[x], 'r')) {
-                sth->rate = atof(argv[x]);
-            } else if (strchr(argv[x], 'o')) {
-                sth->octaves = atof(argv[x]);
-            } else if (strchr(argv[x], 's')) {
-                sth->semi = atof(argv[x]);
-            } else if (strchr(argv[x], 't')) {
-                if ((sth->tempo = atof(argv[x]) < 0)) {
-                    sth->tempo = 0;
-                }
-            }
-        }
-    }
-    
-
-    sth->session = session;
-
-	if ((status = switch_core_media_bug_add(session, soundtouch_callback, sth, 0, 
-                                            sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure!\n");
+		sth->send = 0;
+		sth->read = 0;
+		sth->pitch = 1;
+		for (x = 0; x < argc; x++) {
+			if (!strncasecmp(argv[x], "send", 4)) {
+				sth->send = 1;
+			} else if (!strncasecmp(argv[x], "read", 4)) {
+				sth->read = 1;
+			} else if (strchr(argv[x], 'p')) {
+				if ((sth->pitch = atof(argv[x]) < 0)) {
+					sth->pitch = 0;
+				}
+			} else if (strchr(argv[x], 'r')) {
+				sth->rate = atof(argv[x]);
+			} else if (strchr(argv[x], 'o')) {
+				sth->octaves = atof(argv[x]);
+			} else if (strchr(argv[x], 's')) {
+				sth->semi = atof(argv[x]);
+			} else if (strchr(argv[x], 't')) {
+				if ((sth->tempo = atof(argv[x]) < 0)) {
+					sth->tempo = 0;
+				}
+			}
+		}
+	}
+
+
+	sth->session = session;
+
+	if ((status = switch_core_media_bug_add(session, soundtouch_callback, sth, 0,
+											sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure!\n");
 		return;
 	}
-    
+
 	switch_channel_set_private(channel, "_soundtouch_", bug);
-    
+
 }
 static switch_application_interface_t soundtouch_application_interface = {
 	/*.interface_name */ "soundtouch",
@@ -311,8 +311,8 @@
 	/* short_desc */ "Alter the audio stream",
 	/* syntax */ "[send|recv] [-]<X>s [.]<X>p",
 	/* flags */ SAF_NONE,
-    /* next*/ 
-    
+	/* next */
+
 };
 
 static switch_loadable_module_interface_t soundtouch_module_interface = {

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_voicemail/mod_voicemail.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/applications/mod_voicemail/mod_voicemail.c	Tue May 27 07:24:06 2008
@@ -35,7 +35,7 @@
 #include <switch_odbc.h>
 #endif
 
-#ifdef _MSC_VER /* compilers are stupid sometimes */
+#ifdef _MSC_VER					/* compilers are stupid sometimes */
 #define TRY_CODE(code) for(;;) {status = code; if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { goto end; } break;}
 #else
 #define TRY_CODE(code) do { status = code; if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { goto end; } break;} while(status)
@@ -62,7 +62,7 @@
 	char play_new_messages_key[2];
 	char play_saved_messages_key[2];
 
-	char main_menu_key[2];    
+	char main_menu_key[2];
 	char config_menu_key[2];
 	char record_greeting_key[2];
 	char choose_greeting_key[2];
@@ -141,7 +141,7 @@
 		switch_core_db_close(db);
 	}
 
-end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -149,11 +149,7 @@
 }
 
 
-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)
+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)
 {
 	switch_bool_t ret = SWITCH_FALSE;
 	switch_core_db_t *db;
@@ -185,7 +181,7 @@
 		}
 	}
 
-end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -196,26 +192,19 @@
 static char vm_sql[] =
 	"CREATE TABLE voicemail_msgs (\n"
 	"   created_epoch INTEGER,\n"
-	"   read_epoch    INTEGER,\n" 
-	"   username      VARCHAR(255),\n" 
-	"   domain        VARCHAR(255),\n" 
-	"   uuid          VARCHAR(255),\n" 
-	"   cid_name      VARCHAR(255),\n" 
-	"   cid_number    VARCHAR(255),\n" 
-	"   in_folder     VARCHAR(255),\n" 
-	"   file_path     VARCHAR(255),\n" 
-	"   message_len   INTEGER,\n" 
-	"   flags         VARCHAR(255),\n"
-	"   read_flags    VARCHAR(255)\n" 
-	");\n";
+	"   read_epoch    INTEGER,\n"
+	"   username      VARCHAR(255),\n"
+	"   domain        VARCHAR(255),\n"
+	"   uuid          VARCHAR(255),\n"
+	"   cid_name      VARCHAR(255),\n"
+	"   cid_number    VARCHAR(255),\n"
+	"   in_folder     VARCHAR(255),\n"
+	"   file_path     VARCHAR(255),\n" "   message_len   INTEGER,\n" "   flags         VARCHAR(255),\n" "   read_flags    VARCHAR(255)\n" ");\n";
 
 static char vm_pref_sql[] =
 	"CREATE TABLE voicemail_prefs (\n"
-	"   username        VARCHAR(255),\n" 
-	"   domain          VARCHAR(255),\n" 
-	"   name_path       VARCHAR(255),\n" 
-	"   greeting_path VARCHAR(255)\n" 
-	");\n";
+	"   username        VARCHAR(255),\n"
+	"   domain          VARCHAR(255),\n" "   name_path       VARCHAR(255),\n" "   greeting_path VARCHAR(255)\n" ");\n";
 
 static switch_status_t load_config(void)
 {
@@ -254,7 +243,7 @@
 		char *play_new_messages_key = "1";
 		char *play_saved_messages_key = "2";
 
-		char *main_menu_key = "0";    
+		char *main_menu_key = "0";
 		char *config_menu_key = "5";
 		char *record_greeting_key = "1";
 		char *choose_greeting_key = "2";
@@ -328,17 +317,14 @@
 					if (switch_is_file_path(val)) {
 						path = val;
 					} else {
-						dpath = switch_mprintf("%s%s%s", 
-							SWITCH_GLOBAL_dirs.conf_dir, 
-							SWITCH_PATH_SEPARATOR,
-							val);
+						dpath = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, val);
 						path = dpath;
 					}
 
 					if ((fd = open(path, O_RDONLY)) > -1) {
 						char buf[2048];
 						SWITCH_STANDARD_STREAM(stream);
-						while(switch_fd_read_line(fd, buf, sizeof(buf))) {
+						while (switch_fd_read_line(fd, buf, sizeof(buf))) {
 							stream.write_function(&stream, "%s", buf);
 						}
 						close(fd);
@@ -373,17 +359,14 @@
 				if (switch_is_file_path(val)) {
 					path = val;
 				} else {
-					dpath = switch_mprintf("%s%s%s", 
-						SWITCH_GLOBAL_dirs.conf_dir, 
-						SWITCH_PATH_SEPARATOR,
-						val);
+					dpath = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, val);
 					path = dpath;
 				}
 
 				if ((fd = open(path, O_RDONLY)) > -1) {
 					char buf[2048];
 					SWITCH_STANDARD_STREAM(stream);
-					while(switch_fd_read_line(fd, buf, sizeof(buf))) {
+					while (switch_fd_read_line(fd, buf, sizeof(buf))) {
 						stream.write_function(&stream, "%s", buf);
 					}
 					close(fd);
@@ -437,10 +420,10 @@
 				operator_key = val;
 			} else if (!strcasecmp(var, "operator-extension") && !switch_strlen_zero(val)) {
 				operator_ext = val;
-                        } else if (!strcasecmp(var, "vmain-key") && !switch_strlen_zero(val)) {
-                                vmain_key = val;
-                        } else if (!strcasecmp(var, "vmain-extension") && !switch_strlen_zero(val)) {
-                                vmain_ext = val;
+			} else if (!strcasecmp(var, "vmain-key") && !switch_strlen_zero(val)) {
+				vmain_key = val;
+			} else if (!strcasecmp(var, "vmain-extension") && !switch_strlen_zero(val)) {
+				vmain_ext = val;
 			} else if (!strcasecmp(var, "storage-dir") && !switch_strlen_zero(val)) {
 				storage_dir = val;
 			} else if (!strcasecmp(var, "callback-dialplan") && !switch_strlen_zero(val)) {
@@ -577,19 +560,18 @@
 					switch_odbc_handle_exec(profile->master_odbc, vm_pref_sql, NULL);
 				}
 
-                if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_data", NULL) == SWITCH_ODBC_SUCCESS) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Old table voicemail_data found, migrating data!\n");
-                    /* XXX: Old table found.. migrating data into new table */
-                    if (switch_odbc_handle_exec(profile->master_odbc,
+				if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_data", NULL) == SWITCH_ODBC_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Old table voicemail_data found, migrating data!\n");
+					/* XXX: Old table found.. migrating data into new table */
+					if (switch_odbc_handle_exec(profile->master_odbc,
 												"insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid,"
 												"cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data",
 												NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n");
-                        continue;
-                    }
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n");
+						continue;
+					}
 					switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL);
-                }
-
+				}
 #endif
 			} else {
 				if ((db = switch_core_db_open_file(profile->dbname))) {
@@ -604,12 +586,12 @@
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Migrating data from voicemail_data to voicemail_msgs!\n");
 						switch_core_db_exec(db, "insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid,"
 											"cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data",
-										    NULL, NULL, &errmsg);
+											NULL, NULL, &errmsg);
 						if (errmsg) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg);
 							switch_core_db_free(errmsg);
 							errmsg = NULL;
-						} 
+						}
 						switch_core_db_exec(db, "drop table voicemail_data", NULL, NULL, &errmsg);
 						if (errmsg) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg);
@@ -625,7 +607,7 @@
 					continue;
 				}
 				switch_core_db_close(db);
-			}            
+			}
 
 			profile->web_head = web_head;
 			profile->web_tail = web_tail;
@@ -660,13 +642,13 @@
 			*profile->rew_key = *rew_key;
 			*profile->urgent_key = *urgent_key;
 			*profile->operator_key = *operator_key;
-                        *profile->vmain_key = *vmain_key;
+			*profile->vmain_key = *vmain_key;
 			profile->record_threshold = record_threshold;
 			profile->record_silence_hits = record_silence_hits;
 			profile->record_sample_rate = record_sample_rate;
 
 			profile->operator_ext = switch_core_strdup(globals.pool, operator_ext);
-                        profile->vmain_ext = switch_core_strdup(globals.pool, vmain_ext);
+			profile->vmain_ext = switch_core_strdup(globals.pool, vmain_ext);
 			profile->storage_dir = switch_core_strdup(globals.pool, storage_dir);
 			profile->tone_spec = switch_core_strdup(globals.pool, tone_spec);
 			profile->callback_dialplan = switch_core_strdup(globals.pool, callback_dialplan);
@@ -684,7 +666,7 @@
 		}
 	}
 
-end:
+  end:
 	switch_xml_free(xml);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -730,7 +712,9 @@
 			switch_file_handle_t *fh = cc->fh;
 			uint32_t pos = 0;
 
-			if (!cc->noexit && (dtmf->digit == *cc->profile->delete_file_key || dtmf->digit == *cc->profile->save_file_key || dtmf->digit == *cc->profile->terminator_key)) {
+			if (!cc->noexit
+				&& (dtmf->digit == *cc->profile->delete_file_key || dtmf->digit == *cc->profile->save_file_key
+					|| dtmf->digit == *cc->profile->terminator_key)) {
 				*cc->buf = dtmf->digit;
 				return SWITCH_STATUS_BREAK;
 			}
@@ -770,7 +754,7 @@
 		break;
 	default:
 		break;
-		}
+	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -834,12 +818,7 @@
 static switch_status_t vm_macro_get(switch_core_session_t *session,
 									char *macro,
 									char *macro_arg,
-									char *buf,
-									switch_size_t buflen,
-									switch_size_t maxlen,
-									char *term_chars,
-									char *terminator_key,
-									uint32_t timeout)
+									char *buf, switch_size_t buflen, switch_size_t maxlen, char *term_chars, char *terminator_key, uint32_t timeout)
 {
 	switch_input_args_t args = { 0 }, *ap = NULL;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -849,7 +828,7 @@
 		memset(buf, 0, buflen);
 		args.input_callback = cancel_on_dtmf;
 		args.buf = buf;
-		args.buflen = (uint32_t)buflen;
+		args.buflen = (uint32_t) buflen;
 		ap = &args;
 	}
 
@@ -869,7 +848,7 @@
 	bslen = strlen(buf);
 
 	if (maxlen == 0 || maxlen > buflen - 1) {
-		maxlen = buflen -1;
+		maxlen = buflen - 1;
 	}
 	if (bslen < maxlen) {
 		status = switch_ivr_collect_digits_count(session, buf + bslen, buflen, maxlen - bslen, term_chars, terminator_key, timeout, 0, 0);
@@ -913,29 +892,26 @@
 } msg_type_t;
 
 
-static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *profile, 
-                                   char *macro_name, char *file_path, switch_size_t *message_len, switch_bool_t limit)
+static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *profile,
+								   char *macro_name, char *file_path, switch_size_t *message_len, switch_bool_t limit)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_file_handle_t fh = { 0 };
 	switch_input_args_t args = { 0 };
 	char term;
-	char input[10] = "" , key_buf[80] = "";
+	char input[10] = "", key_buf[80] = "";
 	cc_t cc = { 0 };
 	switch_codec_t *read_codec;
 
 	read_codec = switch_core_session_get_read_codec(session);
 
-	while(switch_channel_ready(channel)) {
+	while (switch_channel_ready(channel)) {
 
-		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s", 
-			profile->listen_file_key,
-			profile->save_file_key,
-			profile->record_file_key);
+		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s", profile->listen_file_key, profile->save_file_key, profile->record_file_key);
 
-record_file:
-        *message_len = 0;
+	  record_file:
+		*message_len = 0;
 		args.input_callback = cancel_on_dtmf;
 		TRY_CODE(switch_ivr_phrase_macro(session, macro_name, NULL, NULL, NULL));
 		TRY_CODE(switch_ivr_gentones(session, profile->tone_spec, 0, NULL));
@@ -946,22 +922,22 @@
 		fh.samplerate = profile->record_sample_rate;
 		switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
 		if (limit && (*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second) < profile->min_record_len) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is less than minimum record length: %d, discarding it.\n", 
-                              profile->min_record_len);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is less than minimum record length: %d, discarding it.\n",
+							  profile->min_record_len);
 			if (unlink(file_path) != 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", file_path);
 			}
-            if (switch_channel_ready(channel)) {
-                /* TODO Rel 1.0 : Add Playback of Prompt <message is too short, please rerecord your message>, then go back at record_file */
-                goto record_file;
-            } else {
-                status = SWITCH_STATUS_BREAK;
-                goto end;
-            }
-        } else {
-            status = SWITCH_STATUS_SUCCESS;
-        }
-play_file:
+			if (switch_channel_ready(channel)) {
+				/* TODO Rel 1.0 : Add Playback of Prompt <message is too short, please rerecord your message>, then go back at record_file */
+				goto record_file;
+			} else {
+				status = SWITCH_STATUS_BREAK;
+				goto end;
+			}
+		} else {
+			status = SWITCH_STATUS_SUCCESS;
+		}
+	  play_file:
 		memset(&fh, 0, sizeof(fh));
 		args.input_callback = control_playback;
 		memset(&cc, 0, sizeof(cc));
@@ -970,15 +946,14 @@
 		args.buf = &cc;
 		switch_ivr_play_file(session, &fh, file_path, &args);
 
-		while(switch_channel_ready(channel)) {
+		while (switch_channel_ready(channel)) {
 			if (*cc.buf) {
 				*input = *cc.buf;
-				*(input+1) = '\0';
+				*(input + 1) = '\0';
 				status = SWITCH_STATUS_SUCCESS;
 				*cc.buf = '\0';
 			} else {
-				status = vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, 
-					key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
+				status = vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
 			}
 
 			if (!strcmp(input, profile->listen_file_key)) {
@@ -992,7 +967,7 @@
 		}
 	}
 
-end:
+  end:
 	return status;
 }
 
@@ -1042,7 +1017,7 @@
 }
 
 
-static void message_count(vm_profile_t *profile, const char *myid, const char *domain_name, char *myfolder, 
+static void message_count(vm_profile_t *profile, const char *myid, const char *domain_name, char *myfolder,
 						  int *total_new_messages, int *total_saved_messages, int *total_new_urgent_messages, int *total_saved_urgent_messages)
 {
 	char msg_count[80] = "";
@@ -1052,37 +1027,27 @@
 	cbt.buf = msg_count;
 	cbt.len = sizeof(msg_count);
 
-	switch_snprintf(sql, sizeof(sql), 
-		"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0", 
-		myid,
-		domain_name,
-		myfolder);
+	switch_snprintf(sql, sizeof(sql),
+					"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0",
+					myid, domain_name, myfolder);
 	vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
 	*total_new_messages = atoi(msg_count);
 
-	switch_snprintf(sql, sizeof(sql), 
-		"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 and read_flags='%s'", 
-		myid,
-		domain_name,
-		myfolder, 
-		URGENT_FLAG_STRING);
+	switch_snprintf(sql, sizeof(sql),
+					"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 and read_flags='%s'",
+					myid, domain_name, myfolder, URGENT_FLAG_STRING);
 	vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
 	*total_new_urgent_messages = atoi(msg_count);
 
-	switch_snprintf(sql, sizeof(sql), 
-		"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch!=0", 
-		myid,
-		domain_name,
-		myfolder);
+	switch_snprintf(sql, sizeof(sql),
+					"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch!=0",
+					myid, domain_name, myfolder);
 	vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
 	*total_saved_messages = atoi(msg_count);
 
-	switch_snprintf(sql, sizeof(sql), 
-		"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch!=0 and read_flags='%s'", 
-		myid,
-		domain_name,
-		myfolder,
-		URGENT_FLAG_STRING);
+	switch_snprintf(sql, sizeof(sql),
+					"select count(*) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch!=0 and read_flags='%s'",
+					myid, domain_name, myfolder, URGENT_FLAG_STRING);
 	vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
 	*total_saved_urgent_messages = atoi(msg_count);
 }
@@ -1094,7 +1059,7 @@
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_input_args_t args = { 0 };
 	char term;
-	char input[10] = "" , key_buf[80] = "";
+	char input[10] = "", key_buf[80] = "";
 	switch_file_handle_t fh = { 0 };
 	cc_t cc = { 0 };
 
@@ -1102,14 +1067,10 @@
 
 		args.input_callback = cancel_on_dtmf;
 
-		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s", 
-			profile->listen_file_key,
-			profile->save_file_key,
-			profile->delete_file_key,
-			profile->email_key,
-			profile->callback_key);
+		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s",
+						profile->listen_file_key, profile->save_file_key, profile->delete_file_key, profile->email_key, profile->callback_key);
 
-		switch_snprintf(input, sizeof(input), "%s:%d", cbt->type == MSG_NEW ? "new" : "saved", cbt->want+1);
+		switch_snprintf(input, sizeof(input), "%s:%d", cbt->type == MSG_NEW ? "new" : "saved", cbt->want + 1);
 		memset(&cc, 0, sizeof(cc));
 		cc.profile = profile;
 		args.buf = &cc;
@@ -1118,7 +1079,7 @@
 		if (!*cc.buf) {
 			TRY_CODE(switch_ivr_phrase_macro(session, VM_SAY_DATE_MACRO, cbt->created_epoch, NULL, &args));
 		}
-play_file:
+	  play_file:
 
 		if (!*cc.buf) {
 			memset(&fh, 0, sizeof(fh));
@@ -1133,12 +1094,11 @@
 		if (switch_channel_ready(channel)) {
 			if (*cc.buf) {
 				*input = *cc.buf;
-				*(input+1) = '\0';
+				*(input + 1) = '\0';
 				status = SWITCH_STATUS_SUCCESS;
 				*cc.buf = '\0';
 			} else {
-				status = vm_macro_get(session, VM_LISTEN_FILE_CHECK_MACRO, 
-					key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
+				status = vm_macro_get(session, VM_LISTEN_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
 			}
 			if (!strcmp(input, profile->listen_file_key)) {
 				goto play_file;
@@ -1157,7 +1117,7 @@
 					switch_size_t retsize;
 					switch_time_exp_t tm;
 					char date[80] = "";
-					char tmp[50]="";
+					char tmp[50] = "";
 					int total_new_messages = 0;
 					int total_saved_messages = 0;
 					int total_new_urgent_messages = 0;
@@ -1173,18 +1133,18 @@
 					}
 
 					message_count(profile, cbt->user, cbt->domain, cbt->in_folder, &total_new_messages, &total_saved_messages,
-						&total_new_urgent_messages, &total_saved_urgent_messages);
+								  &total_new_urgent_messages, &total_saved_urgent_messages);
 
 					switch_time_exp_lt(&tm, atoi(cbt->created_epoch) * 1000000);
 					switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
 
-					switch_snprintf(tmp,sizeof(tmp), "%d", total_new_messages);
+					switch_snprintf(tmp, sizeof(tmp), "%d", total_new_messages);
 					switch_channel_set_variable(channel, "voicemail_total_new_messages", tmp);
-					switch_snprintf(tmp,sizeof(tmp), "%d", total_saved_messages);
+					switch_snprintf(tmp, sizeof(tmp), "%d", total_saved_messages);
 					switch_channel_set_variable(channel, "voicemail_total_saved_messages", tmp);
-					switch_snprintf(tmp,sizeof(tmp), "%d", total_new_urgent_messages);
+					switch_snprintf(tmp, sizeof(tmp), "%d", total_new_urgent_messages);
 					switch_channel_set_variable(channel, "voicemail_urgent_new_messages", tmp);
-					switch_snprintf(tmp,sizeof(tmp), "%d", total_saved_urgent_messages);
+					switch_snprintf(tmp, sizeof(tmp), "%d", total_saved_urgent_messages);
 					switch_channel_set_variable(channel, "voicemail_urgent_saved_messages", tmp);
 					switch_channel_set_variable(channel, "voicemail_current_folder", cbt->in_folder);
 					switch_channel_set_variable(channel, "voicemail_account", cbt->user);
@@ -1194,7 +1154,7 @@
 					switch_channel_set_variable(channel, "voicemail_file_path", cbt->file_path);
 					switch_channel_set_variable(channel, "voicemail_read_flags", cbt->read_flags);
 					switch_channel_set_variable(channel, "voicemail_time", date);
-					switch_snprintf(tmp,sizeof(tmp), "%d", priority);
+					switch_snprintf(tmp, sizeof(tmp), "%d", priority);
 					switch_channel_set_variable(channel, "voicemail_priority", tmp);
 					message_len = atoi(cbt->message_len);
 
@@ -1203,11 +1163,7 @@
 					duration.day += duration.yr * 365;
 					duration.hr += duration.day * 24;
 
-					switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", 
-						duration.hr,
-						duration.min,
-						duration.sec
-						);
+					switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", duration.hr, duration.min, duration.sec);
 
 					switch_channel_set_variable(channel, "voicemail_message_len", duration_str);
 					switch_channel_set_variable(channel, "voicemail_email", cbt->email);
@@ -1215,20 +1171,20 @@
 					if (switch_strlen_zero(profile->email_headers)) {
 						from = switch_core_session_sprintf(session, "%s@%s", cbt->user, cbt->domain);
 					} else {
-						from = switch_channel_expand_variables(channel,profile->email_from);
+						from = switch_channel_expand_variables(channel, profile->email_from);
 					}
 
 					if (switch_strlen_zero(profile->email_headers)) {
-						headers = switch_core_session_sprintf(session, 
-							"From: FreeSWITCH mod_voicemail <%s@%s>\nSubject: Voicemail from %s %s\nX-Priority: %d", 
-							cbt->user, cbt->domain, cbt->cid_name, cbt->cid_number, priority);
+						headers = switch_core_session_sprintf(session,
+															  "From: FreeSWITCH mod_voicemail <%s@%s>\nSubject: Voicemail from %s %s\nX-Priority: %d",
+															  cbt->user, cbt->domain, cbt->cid_name, cbt->cid_number, priority);
 					} else {
-						headers = switch_channel_expand_variables(channel,profile->email_headers);
+						headers = switch_channel_expand_variables(channel, profile->email_headers);
 					}
 
 					p = headers + (strlen(headers) - 1);
 					if (*p == '\n') {
-						if (*(p-1) == '\r') {
+						if (*(p - 1) == '\r') {
 							p--;
 						}
 						*p = '\0';
@@ -1238,8 +1194,8 @@
 
 					if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
 						/* this isnt done?  it was in the other place
-						* switch_channel_event_set_data(channel, event);
-						*/
+						 * switch_channel_event_set_data(channel, event);
+						 */
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Message-Type", "forwarded-voicemail");
 						switch_event_fire(&event);
 					}
@@ -1247,8 +1203,7 @@
 					if (profile->email_body) {
 						body = switch_channel_expand_variables(channel, profile->email_body);
 					} else {
-						body = switch_mprintf("%u second Voicemail from %s %s", message_len, 
-							cbt->cid_name, cbt->cid_number);
+						body = switch_mprintf("%u second Voicemail from %s %s", message_len, cbt->cid_name, cbt->cid_number);
 					}
 
 					switch_simple_email(cbt->email, from, header_string, body, cbt->file_path);
@@ -1267,7 +1222,7 @@
 		}
 	}
 
-end:
+  end:
 
 	return status;
 }
@@ -1307,413 +1262,407 @@
 	args.buflen = sizeof(foo);
 	status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args);
 
-	while(switch_channel_ready(channel)) {
+	while (switch_channel_ready(channel)) {
 		switch_ivr_sleep(session, 100);
 
-		switch(vm_check_state) {
-case VM_CHECK_START:
-	{
-		total_new_messages = 0;
-		total_saved_messages = 0;
-		total_new_urgent_messages = 0;
-		total_saved_urgent_messages = 0;
-		heard_auto_saved = 0;
-		heard_auto_new = 0;
-		play_msg_type = MSG_NONE;
-		attempts = profile->max_login_attempts;
-		myid = id;
-		mypass = NULL;
-		myfolder = "inbox";
-		vm_check_state = VM_CHECK_AUTH;
-		if (x_domain_root) {
-			switch_xml_free(x_domain_root);
-		}
-		x_user = x_domain = x_domain_root = NULL;
-	}
-	break;
-case VM_CHECK_FOLDER_SUMMARY:
-	{
-		int informed = 0;
-		char msg_count[80] = "";
+		switch (vm_check_state) {
+		case VM_CHECK_START:
+			{
+				total_new_messages = 0;
+				total_saved_messages = 0;
+				total_new_urgent_messages = 0;
+				total_saved_urgent_messages = 0;
+				heard_auto_saved = 0;
+				heard_auto_new = 0;
+				play_msg_type = MSG_NONE;
+				attempts = profile->max_login_attempts;
+				myid = id;
+				mypass = NULL;
+				myfolder = "inbox";
+				vm_check_state = VM_CHECK_AUTH;
+				if (x_domain_root) {
+					switch_xml_free(x_domain_root);
+				}
+				x_user = x_domain = x_domain_root = NULL;
+			}
+			break;
+		case VM_CHECK_FOLDER_SUMMARY:
+			{
+				int informed = 0;
+				char msg_count[80] = "";
 
-		switch_channel_set_variable(channel, "voicemail_current_folder", myfolder);
-		message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages, 
-			&total_new_urgent_messages, &total_saved_urgent_messages);
+				switch_channel_set_variable(channel, "voicemail_current_folder", myfolder);
+				message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages,
+							  &total_new_urgent_messages, &total_saved_urgent_messages);
 
-		if (total_new_urgent_messages > 0) {
-			switch_snprintf(msg_count, sizeof(msg_count), "%d:urgent-new", total_new_urgent_messages);
-			TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
-			informed++;
-		}
-		if (total_new_messages > 0 && total_new_messages != total_new_urgent_messages) {
-			switch_snprintf(msg_count, sizeof(msg_count), "%d:new", total_new_messages);
-			TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
-			informed++;
-		}
+				if (total_new_urgent_messages > 0) {
+					switch_snprintf(msg_count, sizeof(msg_count), "%d:urgent-new", total_new_urgent_messages);
+					TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
+					informed++;
+				}
+				if (total_new_messages > 0 && total_new_messages != total_new_urgent_messages) {
+					switch_snprintf(msg_count, sizeof(msg_count), "%d:new", total_new_messages);
+					TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
+					informed++;
+				}
 
-		if (!heard_auto_new && total_new_messages + total_new_urgent_messages> 0) {
-			heard_auto_new = 1;
-			play_msg_type = MSG_NEW;
-			vm_check_state = VM_CHECK_PLAY_MESSAGES;
-			continue;
-		}
+				if (!heard_auto_new && total_new_messages + total_new_urgent_messages > 0) {
+					heard_auto_new = 1;
+					play_msg_type = MSG_NEW;
+					vm_check_state = VM_CHECK_PLAY_MESSAGES;
+					continue;
+				}
 
-		if (total_saved_urgent_messages > 0) {
-			switch_snprintf(msg_count, sizeof(msg_count), "%d:urgent-saved", total_saved_urgent_messages);
-			TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
-			informed++;
-		}
+				if (total_saved_urgent_messages > 0) {
+					switch_snprintf(msg_count, sizeof(msg_count), "%d:urgent-saved", total_saved_urgent_messages);
+					TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
+					informed++;
+				}
+
+				if (total_saved_messages > 0 && total_saved_messages != total_saved_urgent_messages) {
+					switch_snprintf(msg_count, sizeof(msg_count), "%d:saved", total_saved_messages);
+					TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
+					informed++;
+				}
+
+				if (!heard_auto_saved && total_saved_messages + total_saved_urgent_messages > 0) {
+					heard_auto_saved = 1;
+					play_msg_type = MSG_SAVED;
+					vm_check_state = VM_CHECK_PLAY_MESSAGES;
+					continue;
+				}
 
-		if (total_saved_messages > 0 && total_saved_messages != total_saved_urgent_messages) {
-			switch_snprintf(msg_count, sizeof(msg_count), "%d:saved", total_saved_messages);
-			TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
-			informed++;
-		}
+				if (!informed) {
+					switch_snprintf(msg_count, sizeof(msg_count), "0:new");
+					TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
+					informed++;
+				}
 
-		if (!heard_auto_saved && total_saved_messages + total_saved_urgent_messages> 0) {
-			heard_auto_saved = 1;
-			play_msg_type = MSG_SAVED;
-			vm_check_state = VM_CHECK_PLAY_MESSAGES;
-			continue;
-		}
+				vm_check_state = VM_CHECK_MENU;
+			}
+			break;
+		case VM_CHECK_PLAY_MESSAGES:
+			{
+				listen_callback_t cbt;
+				char sql[256];
+				int cur_message, total_messages;
+				switch_event_t *event;
 
-		if (!informed) {
-			switch_snprintf(msg_count, sizeof(msg_count), "0:new");
-			TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, NULL));
-			informed++;
-		}
+				message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages,
+							  &total_new_urgent_messages, &total_saved_urgent_messages);
+				memset(&cbt, 0, sizeof(cbt));
+				cbt.email = email_vm;
+				switch (play_msg_type) {
+				case MSG_NEW:
+					{
+						switch_snprintf(sql, sizeof(sql),
+										"select * from voicemail_msgs where username='%s' and domain='%s' and read_epoch=0 order by read_flags", myid,
+										domain_name);
+						total_messages = total_new_messages;
+						heard_auto_new = heard_auto_saved = 1;
+					}
+					break;
+				case MSG_SAVED:
+				default:
+					{
+						switch_snprintf(sql, sizeof(sql),
+										"select * from voicemail_msgs where username='%s' and domain='%s' and read_epoch !=0 order by read_flags", myid,
+										domain_name);
+						total_messages = total_saved_messages;
+						heard_auto_new = heard_auto_saved = 1;
+					}
+					break;
+				}
+				for (cur_message = 0; cur_message < total_messages; cur_message++) {
+					cbt.index = 0;
+					cbt.want = cur_message;
+					cbt.type = play_msg_type;
+					vm_execute_sql_callback(profile, profile->mutex, sql, listen_callback, &cbt);
+					status = listen_file(session, profile, &cbt);
+					if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+						break;
+					}
+				}
+				switch_snprintf(sql, sizeof(sql), "update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and flags='save'",
+								(long) switch_timestamp(NULL), myid, domain_name);
+				vm_execute_sql(profile, sql, profile->mutex);
+				switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid,
+								domain_name);
+				vm_execute_sql_callback(profile, profile->mutex, sql, unlink_callback, NULL);
+				switch_snprintf(sql, sizeof(sql), "delete from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, domain_name);
+				vm_execute_sql(profile, sql, profile->mutex);
+				vm_check_state = VM_CHECK_FOLDER_SUMMARY;
 
-		vm_check_state = VM_CHECK_MENU;
-	}
-	break;
-case VM_CHECK_PLAY_MESSAGES:
-	{
-		listen_callback_t cbt;
-		char sql[256];
-		int cur_message, total_messages;
-		switch_event_t *event;
+				message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
+							  &total_new_urgent_messages, &total_saved_urgent_messages);
 
-		message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages, 
-			&total_new_urgent_messages, &total_saved_urgent_messages);
-		memset(&cbt, 0, sizeof(cbt));
-		cbt.email = email_vm;
-		switch(play_msg_type) {
-case MSG_NEW:
-	{
-		switch_snprintf(sql, sizeof(sql),
-			"select * from voicemail_msgs where username='%s' and domain='%s' and read_epoch=0 order by read_flags", myid, domain_name);
-		total_messages = total_new_messages;
-		heard_auto_new = heard_auto_saved = 1;
-	}
-	break;
-case MSG_SAVED:
-default:
-	{
-		switch_snprintf(sql, sizeof(sql),
-			"select * from voicemail_msgs where username='%s' and domain='%s' and read_epoch !=0 order by read_flags", myid, domain_name);
-		total_messages = total_saved_messages;
-		heard_auto_new = heard_auto_saved = 1;                        
-	}
-	break;
-		}
-		for (cur_message = 0; cur_message < total_messages; cur_message++) {
-			cbt.index = 0;
-			cbt.want = cur_message;
-			cbt.type = play_msg_type;
-			vm_execute_sql_callback(profile, profile->mutex, sql, listen_callback, &cbt);
-			status = listen_file(session, profile, &cbt);
-			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-				break;
+				if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
+					char *mwi_id;
+					const char *yn = "no";
+					if (total_new_messages || total_new_urgent_messages) {
+						yn = "yes";
+					}
+					mwi_id = switch_mprintf("%s@%s", myid, domain_name);
+					switch_assert(mwi_id);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", mwi_id);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)",
+											total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
+					switch_event_fire(&event);
+					switch_safe_free(mwi_id);
+				}
 			}
-		}
-		switch_snprintf(sql, sizeof(sql), "update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and flags='save'", 
-			(long)switch_timestamp(NULL), myid, domain_name);
-		vm_execute_sql(profile, sql, profile->mutex);
-		switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, domain_name);
-		vm_execute_sql_callback(profile, profile->mutex, sql, unlink_callback, NULL);
-		switch_snprintf(sql, sizeof(sql), "delete from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, domain_name);
-		vm_execute_sql(profile, sql, profile->mutex);
-		vm_check_state = VM_CHECK_FOLDER_SUMMARY;
+			break;
+		case VM_CHECK_CONFIG:
+			{
+				char *sql = NULL;
+				char input[10] = "";
+				char key_buf[80] = "";
+				callback_t cbt = { 0 };
+				char msg_count[80] = "";
+				cc_t cc = { 0 };
+				switch_size_t message_len = 0;
+
+				cbt.buf = msg_count;
+				cbt.len = sizeof(msg_count);
+				sql = switch_mprintf("select count(*) from voicemail_prefs where username='%q' and domain = '%q'", myid, domain_name);
+				vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
+				switch_safe_free(sql);
+				if (*msg_count == '\0' || !atoi(msg_count)) {
+					sql = switch_mprintf("insert into voicemail_prefs values('%q','%q','','')", myid, domain_name);
+					vm_execute_sql(profile, sql, profile->mutex);
+					switch_safe_free(sql);
+				}
 
-		message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
-			&total_new_urgent_messages, &total_saved_urgent_messages);
+				switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s",
+								profile->record_greeting_key, profile->choose_greeting_key, profile->record_name_key, profile->main_menu_key);
 
-		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
-			char *mwi_id;
-			const char *yn = "no";
-			if (total_new_messages || total_new_urgent_messages ) {
-				yn = "yes";
-			}
-			mwi_id = switch_mprintf("%s@%s", myid, domain_name);
-			switch_assert(mwi_id);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", mwi_id);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
-				total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
-			switch_event_fire(&event);
-			switch_safe_free(mwi_id);
-		} 
-	}
-	break;
-case VM_CHECK_CONFIG:
-	{
-		char *sql = NULL;
-		char input[10] = "";
-		char key_buf[80] = "";
-		callback_t cbt = { 0 };
-		char msg_count[80] = "";
-		cc_t cc = { 0 };
-		switch_size_t message_len = 0;
-
-		cbt.buf = msg_count;
-		cbt.len = sizeof(msg_count);
-		sql = switch_mprintf("select count(*) from voicemail_prefs where username='%q' and domain = '%q'", myid, domain_name);
-		vm_execute_sql_callback(profile, profile->mutex, sql, sql2str_callback, &cbt);
-		switch_safe_free(sql);
-		if (*msg_count == '\0' || !atoi(msg_count)) {
-			sql = switch_mprintf("insert into voicemail_prefs values('%q','%q','','')", myid, domain_name);
-			vm_execute_sql(profile, sql, profile->mutex);
-			switch_safe_free(sql);
-		}
-
-		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s", 
-			profile->record_greeting_key, 
-			profile->choose_greeting_key, 
-			profile->record_name_key,
-			profile->main_menu_key);
 
+				TRY_CODE(vm_macro_get(session, VM_CONFIG_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
+				if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+					goto end;
+				}
 
-		TRY_CODE(vm_macro_get(session, VM_CONFIG_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
-		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-			goto end;
-		}
+				if (!strcmp(input, profile->main_menu_key)) {
+					vm_check_state = VM_CHECK_MENU;
+				} else if (!strcmp(input, profile->choose_greeting_key)) {
+					int num;
+					switch_input_args_t greeting_args = { 0 };
+					greeting_args.input_callback = cancel_on_dtmf;
+
+					TRY_CODE(vm_macro_get(session, VM_CHOOSE_GREETING_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
 
-		if (!strcmp(input, profile->main_menu_key)) {
-			vm_check_state = VM_CHECK_MENU;
-		} else if (!strcmp(input, profile->choose_greeting_key)) {
-			int num;
-			switch_input_args_t greeting_args = { 0 };
-			greeting_args.input_callback = cancel_on_dtmf;
-
-			TRY_CODE(vm_macro_get(session, VM_CHOOSE_GREETING_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
 
+					num = atoi(input);
+					file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
+					if (num < 1 || num > VM_MAX_GREETINGS) {
+						status = SWITCH_STATUS_FALSE;
+					} else {
+						switch_file_handle_t fh = { 0 };
+						memset(&fh, 0, sizeof(fh));
+						greeting_args.input_callback = control_playback;
+						memset(&cc, 0, sizeof(cc));
+						cc.profile = profile;
+						cc.fh = &fh;
+						cc.noexit = 1;
+						greeting_args.buf = &cc;
+						status = switch_ivr_play_file(session, NULL, file_path, &greeting_args);
+					}
+					if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+						TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
+					} else {
+						TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_SELECTED_MACRO, input, NULL, NULL));
+						sql =
+							switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid,
+										   domain_name);
+						vm_execute_sql(profile, sql, profile->mutex);
+						switch_safe_free(sql);
+					}
+					switch_safe_free(file_path);
+				} else if (!strcmp(input, profile->record_greeting_key)) {
+					int num;
+					TRY_CODE(vm_macro_get(session, VM_CHOOSE_GREETING_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
+
+					num = atoi(input);
+					if (num < 1 || num > VM_MAX_GREETINGS) {
+						TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
+					} else {
+						file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
+						TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE));
+						sql =
+							switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid,
+										   domain_name);
+						vm_execute_sql(profile, sql, profile->mutex);
+						switch_safe_free(sql);
+						switch_safe_free(file_path);
+					}
 
-			num = atoi(input);
-			file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
-			if (num < 1 || num > VM_MAX_GREETINGS) {
-				status = SWITCH_STATUS_FALSE;
-			} else {
-				switch_file_handle_t fh = { 0 };
-				memset(&fh, 0, sizeof(fh));
-				greeting_args.input_callback = control_playback;
-				memset(&cc, 0, sizeof(cc));
-				cc.profile = profile;
-				cc.fh = &fh;
-				cc.noexit = 1;
-				greeting_args.buf = &cc;
-				status = switch_ivr_play_file(session, NULL, file_path, &greeting_args);
-			}
-			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-				TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
-			} else {
-				TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_SELECTED_MACRO, input, NULL, NULL));
-				sql = switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
-				vm_execute_sql(profile, sql, profile->mutex);
-				switch_safe_free(sql);
-			}
-			switch_safe_free(file_path);
-		} else if (!strcmp(input, profile->record_greeting_key)) {
-			int num;
-			TRY_CODE(vm_macro_get(session, VM_CHOOSE_GREETING_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
-
-			num = atoi(input);
-			if (num < 1 || num > VM_MAX_GREETINGS) {
-				TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
-			} else {
-				file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
-				TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE));
-				sql = switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
-				vm_execute_sql(profile, sql, profile->mutex);
-				switch_safe_free(sql);
-				switch_safe_free(file_path);
+				} else if (!strcmp(input, profile->record_name_key)) {
+					file_path = switch_mprintf("%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
+					TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &message_len, SWITCH_FALSE));
+					sql = switch_mprintf("update voicemail_prefs set name_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
+					vm_execute_sql(profile, sql, profile->mutex);
+					switch_safe_free(file_path);
+					switch_safe_free(sql);
+				}
+				continue;
 			}
+			break;
+		case VM_CHECK_MENU:
+			{
+				char input[10] = "";
+				char key_buf[80] = "";
+				play_msg_type = MSG_NONE;
 
-		} else if (!strcmp(input, profile->record_name_key)) {
-			file_path = switch_mprintf("%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
-			TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &message_len, SWITCH_FALSE));
-			sql = switch_mprintf("update voicemail_prefs set name_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
-			vm_execute_sql(profile, sql, profile->mutex);
-			switch_safe_free(file_path);
-			switch_safe_free(sql);
-		}
-		continue;
-	}
-	break;
-case VM_CHECK_MENU:
-	{
-		char input[10] = "";
-		char key_buf[80] = "";
-		play_msg_type = MSG_NONE;
-
-		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s", 
-			profile->play_new_messages_key, 
-			profile->play_saved_messages_key,
-			profile->config_menu_key,
-			profile->terminator_key);
+				switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s",
+								profile->play_new_messages_key, profile->play_saved_messages_key, profile->config_menu_key, profile->terminator_key);
 
-		status = vm_macro_get(session, VM_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout);
+				status = vm_macro_get(session, VM_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout);
 
-		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-			goto end;
-		}
+				if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+					goto end;
+				}
 
-		if (!strcmp(input, profile->play_new_messages_key)) {
-			play_msg_type = MSG_NEW;
-		} else if (!strcmp(input, profile->play_saved_messages_key)) {
-			play_msg_type = MSG_SAVED;
-		} else if (!strcmp(input, profile->terminator_key)) {
-			goto end;
-		} else if (!strcmp(input, profile->config_menu_key)) {
-			vm_check_state = VM_CHECK_CONFIG;
-		}
+				if (!strcmp(input, profile->play_new_messages_key)) {
+					play_msg_type = MSG_NEW;
+				} else if (!strcmp(input, profile->play_saved_messages_key)) {
+					play_msg_type = MSG_SAVED;
+				} else if (!strcmp(input, profile->terminator_key)) {
+					goto end;
+				} else if (!strcmp(input, profile->config_menu_key)) {
+					vm_check_state = VM_CHECK_CONFIG;
+				}
 
-		if (play_msg_type) {
-			vm_check_state = VM_CHECK_PLAY_MESSAGES;
-		}
+				if (play_msg_type) {
+					vm_check_state = VM_CHECK_PLAY_MESSAGES;
+				}
 
-		continue;
-	}
-	break;
-case VM_CHECK_AUTH:
-	{
-		if (!attempts) {
-			failed = 1;
-			goto end;
-		}
+				continue;
+			}
+			break;
+		case VM_CHECK_AUTH:
+			{
+				if (!attempts) {
+					failed = 1;
+					goto end;
+				}
 
-		attempts--;
+				attempts--;
 
-		if (!myid) {
-			status = vm_macro_get(session, VM_ENTER_ID_MACRO, profile->terminator_key, id_buf, sizeof(id_buf), 0, 
-				profile->terminator_key, &term, timeout);
-			if (status != SWITCH_STATUS_SUCCESS) {
-				goto end;
-			}
+				if (!myid) {
+					status = vm_macro_get(session, VM_ENTER_ID_MACRO, profile->terminator_key, id_buf, sizeof(id_buf), 0,
+										  profile->terminator_key, &term, timeout);
+					if (status != SWITCH_STATUS_SUCCESS) {
+						goto end;
+					}
 
-			if (*id_buf == '\0') {
-				continue;
-			} else {
-				myid = id_buf;
-			} 
-		}
+					if (*id_buf == '\0') {
+						continue;
+					} else {
+						myid = id_buf;
+					}
+				}
 
-		if (!x_user) {
-            switch_event_t *params;
-			int ok = 1;
-			caller_profile = switch_channel_get_caller_profile(channel);
-
-            switch_event_create(&params, SWITCH_EVENT_MESSAGE);
-            switch_assert(params);
-            switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", myid);
-            switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
-            switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_profile->caller_id_number);
-            
-            
-			if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"), 
-                                       &x_domain_root, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
-                ok = 0;
-			}
-            
-            switch_event_destroy(&params);
+				if (!x_user) {
+					switch_event_t *params;
+					int ok = 1;
+					caller_profile = switch_channel_get_caller_profile(channel);
+
+					switch_event_create(&params, SWITCH_EVENT_MESSAGE);
+					switch_assert(params);
+					switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", myid);
+					switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
+					switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_profile->caller_id_number);
+
+
+					if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
+											   &x_domain_root, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
+						ok = 0;
+					}
 
-			if (!ok) {
-				goto end;
-			}
-		}
+					switch_event_destroy(&params);
 
-		if (!mypass) {
-			if (auth) {
-				mypass = "OK";
-			} else {
-				status = vm_macro_get(session, VM_ENTER_PASS_MACRO, profile->terminator_key, 
-					pass_buf, sizeof(pass_buf), 0, profile->terminator_key, &term, timeout);
-				if (status != SWITCH_STATUS_SUCCESS) {
-					goto end;
+					if (!ok) {
+						goto end;
+					}
 				}
-				if (*pass_buf == '\0') {
-					continue;
-				} else {
-					mypass = pass_buf;
+
+				if (!mypass) {
+					if (auth) {
+						mypass = "OK";
+					} else {
+						status = vm_macro_get(session, VM_ENTER_PASS_MACRO, profile->terminator_key,
+											  pass_buf, sizeof(pass_buf), 0, profile->terminator_key, &term, timeout);
+						if (status != SWITCH_STATUS_SUCCESS) {
+							goto end;
+						}
+						if (*pass_buf == '\0') {
+							continue;
+						} else {
+							mypass = pass_buf;
+						}
+					}
 				}
-			}
-		}
 
-		if (!(x_params = switch_xml_child(x_user, "params"))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", myid, domain_name);
-			goto failed;
-		}
+				if (!(x_params = switch_xml_child(x_user, "params"))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", myid, domain_name);
+					goto failed;
+				}
+
+				thepass = NULL;
+				for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
+					const char *var = switch_xml_attr_soft(x_param, "name");
+					const char *val = switch_xml_attr_soft(x_param, "value");
+
+					if (!strcasecmp(var, "password")) {
+						thepass = val;
+					} else if (!strcasecmp(var, "vm-password")) {
+						thepass = val;
+					} else if (!strcasecmp(var, "vm-mailto")) {
+						email_vm = switch_core_session_strdup(session, val);
+					}
+				}
+				switch_xml_free(x_domain_root);
+				x_domain_root = NULL;
 
-		thepass = NULL;
-		for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
-			const char *var = switch_xml_attr_soft(x_param, "name");
-			const char *val = switch_xml_attr_soft(x_param, "value");
+				if (auth || !thepass || (thepass && mypass && !strcmp(thepass, mypass))) {
+					if (!dir_path) {
+						if (switch_strlen_zero(profile->storage_dir)) {
+							dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
+																   SWITCH_PATH_SEPARATOR,
+																   SWITCH_PATH_SEPARATOR,
+																   profile->name, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid);
+						} else {
+							dir_path = switch_core_session_sprintf(session, "%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, myid);
+						}
 
-			if (!strcasecmp(var, "password")) {
-				thepass = val;
-			} else if (!strcasecmp(var, "vm-password")) {
-				thepass = val;
-			} else if (!strcasecmp(var, "vm-mailto")) {
-				email_vm = switch_core_session_strdup(session, val);
-			}
-		}
-		switch_xml_free(x_domain_root);
-		x_domain_root = NULL;
+						if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
+							return;
+						}
+					}
 
-		if (auth || !thepass || (thepass && mypass && !strcmp(thepass, mypass))) {
-			if (!dir_path) {
-				if (switch_strlen_zero(profile->storage_dir)) {
-					dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
-						SWITCH_PATH_SEPARATOR,
-						SWITCH_PATH_SEPARATOR,
-						profile->name,
-						SWITCH_PATH_SEPARATOR,
-						domain_name,
-						SWITCH_PATH_SEPARATOR,
-						myid);
+					vm_check_state = VM_CHECK_FOLDER_SUMMARY;
 				} else {
-					dir_path = switch_core_session_sprintf(session, "%s%s%s",
-						profile->storage_dir,
-						SWITCH_PATH_SEPARATOR,
-						myid);
+					goto failed;
 				}
 
-				if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
-					return;
-				}
-			}
-
-			vm_check_state = VM_CHECK_FOLDER_SUMMARY;
-		} else {
-			goto failed;
-		}
-
-		continue;
+				continue;
 
-failed:
-		status = switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL);
-		myid = id;
-		mypass = NULL;
-		continue;
-	}
-	break;
-default:
-	break;
+			  failed:
+				status = switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL);
+				myid = id;
+				mypass = NULL;
+				continue;
+			}
+			break;
+		default:
+			break;
 		}
 	}
 
-end:
+  end:
 
 	if (switch_channel_ready(channel)) {
 		if (failed) {
@@ -1743,9 +1692,9 @@
 	switch_file_handle_t fh = { 0 };
 	switch_input_args_t args = { 0 };
 	char *email_vm = NULL;
-    char *email_vm_notify = NULL;
+	char *email_vm_notify = NULL;
 	int send_mail = 0;
-    int send_mail_only = 0;
+	int send_mail_only = 0;
 	cc_t cc = { 0 };
 	char *read_flags = NORMAL_FLAG_STRING;
 	int priority = 3;
@@ -1768,19 +1717,11 @@
 	}
 
 	if (switch_strlen_zero(profile->storage_dir)) {
-		dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
-			SWITCH_PATH_SEPARATOR,
-			SWITCH_PATH_SEPARATOR,
-			profile->name,
-			SWITCH_PATH_SEPARATOR,
-			domain_name,
-			SWITCH_PATH_SEPARATOR,
-			id);
+		dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
+											   SWITCH_PATH_SEPARATOR,
+											   SWITCH_PATH_SEPARATOR, profile->name, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id);
 	} else {
-		dir_path = switch_core_session_sprintf(session, "%s%s%s",
-			profile->storage_dir,
-			SWITCH_PATH_SEPARATOR,
-			id);
+		dir_path = switch_core_session_sprintf(session, "%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, id);
 	}
 
 	if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
@@ -1790,60 +1731,57 @@
 
 	if (id) {
 		int ok = 1;
-        switch_event_t *params = NULL;
+		switch_event_t *params = NULL;
 		switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param;
 		const char *email_addr = NULL;
-        
-        switch_event_create(&params, SWITCH_EVENT_MESSAGE);
-        switch_assert(params);
-        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", id);
-        
+
+		switch_event_create(&params, SWITCH_EVENT_MESSAGE);
+		switch_assert(params);
+		switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", id);
+
 		x_user = x_domain = x_domain_root = NULL;
-		if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"), 
-                                   &x_domain_root, &x_domain, &x_user, params) == SWITCH_STATUS_SUCCESS) {
-            if ((x_params = switch_xml_child(x_user, "params"))) {
-                for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
-						const char *var = switch_xml_attr_soft(x_param, "name");
-						const char *val = switch_xml_attr_soft(x_param, "value");
-
-						if (!strcasecmp(var, "vm-mailto")) {
-							email_vm = switch_core_session_strdup(session, val);
-                        } else if (!strcasecmp(var, "vm-mailto-notify")) {
-                            email_vm_notify = switch_core_session_strdup(session, val);
-						} else if (!strcasecmp(var, "email-addr")) {
-							email_addr = val;
-                        } else if (!strcasecmp(var, "vm-email-only")) {
-                            send_mail_only = switch_true(val);
-						} else if (!strcasecmp(var, "vm-email-all-messages")) {
-							send_mail = switch_true(val);
-						} else if (!strcasecmp(var, "vm-delete-file")) {
-							email_delete = switch_true(val);
-						} else if (!strcasecmp(var, "vm-attach-file")) {
-							email_attach = switch_true(val);
-						}
+		if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
+								   &x_domain_root, &x_domain, &x_user, params) == SWITCH_STATUS_SUCCESS) {
+			if ((x_params = switch_xml_child(x_user, "params"))) {
+				for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
+					const char *var = switch_xml_attr_soft(x_param, "name");
+					const char *val = switch_xml_attr_soft(x_param, "value");
+
+					if (!strcasecmp(var, "vm-mailto")) {
+						email_vm = switch_core_session_strdup(session, val);
+					} else if (!strcasecmp(var, "vm-mailto-notify")) {
+						email_vm_notify = switch_core_session_strdup(session, val);
+					} else if (!strcasecmp(var, "email-addr")) {
+						email_addr = val;
+					} else if (!strcasecmp(var, "vm-email-only")) {
+						send_mail_only = switch_true(val);
+					} else if (!strcasecmp(var, "vm-email-all-messages")) {
+						send_mail = switch_true(val);
+					} else if (!strcasecmp(var, "vm-delete-file")) {
+						email_delete = switch_true(val);
+					} else if (!strcasecmp(var, "vm-attach-file")) {
+						email_attach = switch_true(val);
 					}
 				}
+			}
 
-				if (send_mail && switch_strlen_zero(email_vm) && !switch_strlen_zero(email_addr)) {
-					email_vm = switch_core_session_strdup(session, email_addr);
-				}
+			if (send_mail && switch_strlen_zero(email_vm) && !switch_strlen_zero(email_addr)) {
+				email_vm = switch_core_session_strdup(session, email_addr);
+			}
 
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", id, domain_name);
 			ok = 0;
 		}
 
-        switch_event_destroy(&params);
+		switch_event_destroy(&params);
 		switch_xml_free(x_domain_root);
 		if (!ok) {
 			goto end;
 		}
 	}
 
-	switch_snprintf(sql, sizeof(sql), 
-		"select * from voicemail_prefs where username='%s' and domain='%s'", 
-		id,
-		domain_name);
+	switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", id, domain_name);
 	vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt);
 
 	file_path = switch_mprintf("%s%smsg_%s.%s", dir_path, SWITCH_PATH_SEPARATOR, uuid, profile->file_ext);
@@ -1857,7 +1795,7 @@
 		greet_path = cbt.greeting_path;
 	}
 
-greet:
+  greet:
 	memset(buf, 0, sizeof(buf));
 	args.input_callback = cancel_on_dtmf;
 	args.buf = buf;
@@ -1890,7 +1828,7 @@
 				if (argc >= 1 && argc <= 4) {
 					switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
 					/* the application still runs after we leave it so we need to make sure that we dont do anything evil */
-					send_mail=0;
+					send_mail = 0;
 					goto end;
 				}
 			}
@@ -1904,7 +1842,7 @@
 				if (argc >= 1 && argc <= 4) {
 					switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
 					/* the application still runs after we leave it so we need to make sure that we dont do anything evil */
-					send_mail=0;
+					send_mail = 0;
 					goto end;
 				}
 			}
@@ -1938,9 +1876,7 @@
 	if ((status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) && switch_channel_ready(channel)) {
 		char input[10] = "", key_buf[80] = "", term = 0;
 
-		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s", 
-			profile->urgent_key,
-			profile->terminator_key);
+		switch_snprintf(key_buf, sizeof(key_buf), "%s:%s", profile->urgent_key, profile->terminator_key);
 
 		vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
 		if (*profile->urgent_key == *input) {
@@ -1961,14 +1897,14 @@
 		int total_new_urgent_messages = 0;
 		int total_saved_urgent_messages = 0;
 
-		usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long)switch_timestamp(NULL),
-			id, domain_name, uuid, caller_profile->caller_id_name, caller_profile->caller_id_number, 
-			myfolder, file_path, message_len, read_flags);
+		usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_timestamp(NULL),
+							  id, domain_name, uuid, caller_profile->caller_id_name, caller_profile->caller_id_number,
+							  myfolder, file_path, message_len, read_flags);
 		vm_execute_sql(profile, usql, profile->mutex);
 		switch_safe_free(usql);
 
 		message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
-			&total_new_urgent_messages, &total_saved_urgent_messages);
+					  &total_new_urgent_messages, &total_saved_urgent_messages);
 
 		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
 			const char *yn = "no";
@@ -1978,14 +1914,14 @@
 			mwi_id = switch_mprintf("%s@%s", id, domain_name);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", mwi_id);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
-				total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)",
+									total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
 			switch_event_fire(&event);
 			switch_safe_free(mwi_id);
-		}    
+		}
 	}
 
-end:
+  end:
 
 	if (send_mail && !switch_strlen_zero(email_vm) && switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		switch_event_t *event;
@@ -1993,7 +1929,7 @@
 		char *body;
 		char *headers;
 		char *header_string;
-		char tmp[50]="";
+		char tmp[50] = "";
 		int total_new_messages = 0;
 		int total_saved_messages = 0;
 		int total_new_urgent_messages = 0;
@@ -2004,19 +1940,19 @@
 		char duration_str[80];
 
 		message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
-			&total_new_urgent_messages, &total_saved_urgent_messages);
+					  &total_new_urgent_messages, &total_saved_urgent_messages);
 
 		switch_time_exp_lt(&tm, switch_timestamp_now());
 		switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
 
 		switch_channel_set_variable(channel, "voicemail_current_folder", myfolder);
-		switch_snprintf(tmp,sizeof(tmp), "%d", total_new_messages);
+		switch_snprintf(tmp, sizeof(tmp), "%d", total_new_messages);
 		switch_channel_set_variable(channel, "voicemail_total_new_messages", tmp);
-		switch_snprintf(tmp,sizeof(tmp), "%d", total_saved_messages);
+		switch_snprintf(tmp, sizeof(tmp), "%d", total_saved_messages);
 		switch_channel_set_variable(channel, "voicemail_total_saved_messages", tmp);
-		switch_snprintf(tmp,sizeof(tmp), "%d", total_new_urgent_messages);
+		switch_snprintf(tmp, sizeof(tmp), "%d", total_new_urgent_messages);
 		switch_channel_set_variable(channel, "voicemail_urgent_new_messages", tmp);
-		switch_snprintf(tmp,sizeof(tmp), "%d", total_saved_urgent_messages);
+		switch_snprintf(tmp, sizeof(tmp), "%d", total_saved_urgent_messages);
 		switch_channel_set_variable(channel, "voicemail_urgent_saved_messages", tmp);
 		switch_channel_set_variable(channel, "voicemail_account", id);
 		switch_channel_set_variable(channel, "voicemail_domain", domain_name);
@@ -2025,19 +1961,15 @@
 		switch_channel_set_variable(channel, "voicemail_file_path", file_path);
 		switch_channel_set_variable(channel, "voicemail_read_flags", read_flags);
 		switch_channel_set_variable(channel, "voicemail_time", date);
-		switch_snprintf(tmp,sizeof(tmp), "%d", priority);
+		switch_snprintf(tmp, sizeof(tmp), "%d", priority);
 		switch_channel_set_variable(channel, "voicemail_priority", tmp);
 		switch_channel_set_variable(channel, "voicemail_email", email_vm);
 
-		l_duration = (long)message_len * 1000000;
+		l_duration = (long) message_len *1000000;
 		switch_core_measure_time(l_duration, &duration);
 		duration.day += duration.yr * 365;
 		duration.hr += duration.day * 24;
-		switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u",
-			duration.hr,
-			duration.min,
-			duration.sec
-			);
+		switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", duration.hr, duration.min, duration.sec);
 
 		switch_channel_set_variable(channel, "voicemail_message_len", duration_str);
 
@@ -2048,13 +1980,10 @@
 		}
 
 		if (switch_strlen_zero(profile->email_headers)) {
-			headers = switch_core_session_sprintf(session, 
-				"From: FreeSWITCH mod_voicemail <%s@%s>\n"
-				"Subject: Voicemail from %s %s\nX-Priority: %d", 
-				id, domain_name,
-				caller_profile->caller_id_name, 
-				caller_profile->caller_id_number,
-				priority);
+			headers = switch_core_session_sprintf(session,
+												  "From: FreeSWITCH mod_voicemail <%s@%s>\n"
+												  "Subject: Voicemail from %s %s\nX-Priority: %d",
+												  id, domain_name, caller_profile->caller_id_name, caller_profile->caller_id_number, priority);
 		} else {
 			headers = switch_channel_expand_variables(channel, profile->email_headers);
 		}
@@ -2062,7 +1991,7 @@
 		p = headers + (strlen(headers) - 1);
 
 		if (*p == '\n') {
-			if (*(p-1) == '\r') {
+			if (*(p - 1) == '\r') {
 				p--;
 			}
 			*p = '\0';
@@ -2079,8 +2008,7 @@
 		if (profile->email_body) {
 			body = switch_channel_expand_variables(channel, profile->email_body);
 		} else {
-			body = switch_mprintf("%u second Voicemail from %s %s", message_len,
-				caller_profile->caller_id_name, caller_profile->caller_id_number);
+			body = switch_mprintf("%u second Voicemail from %s %s", message_len, caller_profile->caller_id_name, caller_profile->caller_id_number);
 		}
 
 		if (email_attach) {
@@ -2088,9 +2016,9 @@
 		} else {
 			switch_simple_email(email_vm, from, header_string, body, NULL);
 		}
-        if (!switch_strlen_zero(email_vm_notify)) {
-            switch_simple_email(email_vm_notify, from, header_string, body, NULL);
-        }
+		if (!switch_strlen_zero(email_vm_notify)) {
+			switch_simple_email(email_vm_notify, from, header_string, body, NULL);
+		}
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", email_vm);
 		switch_safe_free(body);
@@ -2126,7 +2054,8 @@
 	int x = 0, check = 0, auth = 0;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 
-	if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) !=
+		SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", SWITCH_GLOBAL_dirs.storage_dir);
 		return;
 	}
@@ -2216,18 +2145,18 @@
 			free(dup);
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		if ((domain = strchr(id, '@'))) {
 			*domain++ = '\0';
 			if ((p = strchr(domain, '|'))) {
 				*p++ = '\0';
 				how = p;
 			}
-			
+
 			for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 				switch_hash_this(hi, NULL, NULL, &val);
 				profile = (vm_profile_t *) val;
-				total_new_messages =  total_saved_messages = 0;
+				total_new_messages = total_saved_messages = 0;
 				message_count(profile, id, domain, "inbox", &total_new_messages, &total_saved_messages,
 							  &total_new_urgent_messages, &total_saved_urgent_messages);
 			}
@@ -2285,19 +2214,19 @@
 			for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 				switch_hash_this(hi, NULL, NULL, &val);
 				profile = (vm_profile_t *) val;
-				total_new_messages =  total_saved_messages = 0;
+				total_new_messages = total_saved_messages = 0;
 				message_count(profile, id, domain, "inbox", &total_new_messages, &total_saved_messages,
-					&total_new_urgent_messages, &total_saved_urgent_messages);
+							  &total_new_urgent_messages, &total_saved_urgent_messages);
 				if (total_new_messages || total_saved_messages) {
 					if (switch_event_create(&new_event, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
 						const char *yn = "no";
-						if (total_new_messages || total_new_urgent_messages ) {
+						if (total_new_messages || total_new_urgent_messages) {
 							yn = "yes";
 						}
 						switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", "%s", yn);
 						switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", account);
-						switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", 
-							total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
+						switch_event_add_header(new_event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)",
+												total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
 						created++;
 					}
 				}
@@ -2383,8 +2312,8 @@
 	if (switch_file_open(&fd, argv[8], SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, holder->pool) == SWITCH_STATUS_SUCCESS) {
 		flen = switch_file_get_size(fd);
 		holder->stream->write_function(holder->stream, "Content-type: %s\n", mime_type);
-		holder->stream->write_function(holder->stream, "Content-length: %ld\n\n", (long)flen);
-		for(;;) {
+		holder->stream->write_function(holder->stream, "Content-length: %ld\n\n", (long) flen);
+		for (;;) {
 			switch_status_t status;
 
 			flen = sizeof(chunk);
@@ -2405,8 +2334,8 @@
 	char *sql;
 	struct holder holder;
 
-	sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and file_path like '%%%s'", 
-		(long)switch_timestamp(NULL), user, domain, file);
+	sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and file_path like '%%%s'",
+						 (long) switch_timestamp(NULL), user, domain, file);
 
 	vm_execute_sql(profile, sql, profile->mutex);
 	free(sql);
@@ -2444,9 +2373,8 @@
 	free(sql);
 
 	if (ref) {
-		stream->write_function(stream,"Content-type: text/html\n\n<h2>Message Deleted</h2>\n"
-			"<META http-equiv=\"refresh\" content=\"1;URL=%s\">",  ref);
-	} 
+		stream->write_function(stream, "Content-type: text/html\n\n<h2>Message Deleted</h2>\n" "<META http-equiv=\"refresh\" content=\"1;URL=%s\">", ref);
+	}
 }
 
 
@@ -2467,7 +2395,7 @@
 	const char *fmt = "%a, %e %b %Y %T %z";
 	char heard[80];
 	char title_b4[128] = "";
-	char title_aft[128*3] = "";
+	char title_aft[128 * 3] = "";
 
 	if (argc > 0) {
 		l_created = atol(argv[0]) * 1000000;
@@ -2495,11 +2423,7 @@
 	duration.day += duration.yr * 365;
 	duration.hr += duration.day * 24;
 
-	switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", 
-		duration.hr,
-		duration.min,
-		duration.sec
-		);
+	switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", duration.hr, duration.min, duration.sec);
 
 	if (l_created) {
 		switch_time_exp_lt(&tm, l_created);
@@ -2517,25 +2441,22 @@
 	get = switch_mprintf("http://%s:%s%s/get/%s", holder->host, holder->port, holder->uri, fname);
 	del = switch_mprintf("http://%s:%s%s/del/%s", holder->host, holder->port, holder->uri, fname);
 
-	holder->stream->write_function(holder->stream, "<font face=tahoma><div class=title><b>Message from %s %s</b></div><hr noshade size=1>\n", 
-		argv[5], argv[6]);
-	holder->stream->write_function(holder->stream, "Priority: %s<br>\n"
-		"Created: %s<br>\n"
-		"Last Heard: %s<br>\n"
-		"Duration: %s<br>\n",
-		//"<a href=%s>Delete This Message</a><br><hr noshade size=1>", 
-		strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", create_date, heard, duration_str);
+	holder->stream->write_function(holder->stream, "<font face=tahoma><div class=title><b>Message from %s %s</b></div><hr noshade size=1>\n",
+								   argv[5], argv[6]);
+	holder->stream->write_function(holder->stream, "Priority: %s<br>\n" "Created: %s<br>\n" "Last Heard: %s<br>\n" "Duration: %s<br>\n",
+								   //"<a href=%s>Delete This Message</a><br><hr noshade size=1>", 
+								   strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", create_date, heard, duration_str);
 
 	switch_snprintf(title_b4, sizeof(title_b4), "%s <%s> %s", argv[5], argv[6], rss_date);
 	switch_url_encode(title_b4, title_aft, sizeof(title_aft));
 
 	holder->stream->write_function(holder->stream,
-		"<br><object width=550 height=15 \n"
-		"type=\"application/x-shockwave-flash\" \n"
-		"data=\"http://%s:%s/pub/slim.swf?song_url=%s&player_title=%s\">\n"
-		"<param name=movie value=\"http://%s:%s/pub/slim.swf?song_url=%s&player_title=%s\"></object><br><br>\n"
-		"[<a href=%s>delete</a>] [<a href=%s>download</a>] [<a href=tel:%s>call</a>] <br><br><br></font>\n",
-		holder->host, holder->port, get, title_aft, holder->host, holder->port, get, title_aft, del, get, argv[6]);
+								   "<br><object width=550 height=15 \n"
+								   "type=\"application/x-shockwave-flash\" \n"
+								   "data=\"http://%s:%s/pub/slim.swf?song_url=%s&player_title=%s\">\n"
+								   "<param name=movie value=\"http://%s:%s/pub/slim.swf?song_url=%s&player_title=%s\"></object><br><br>\n"
+								   "[<a href=%s>delete</a>] [<a href=%s>download</a>] [<a href=tel:%s>call</a>] <br><br><br></font>\n",
+								   holder->host, holder->port, get, title_aft, holder->host, holder->port, get, title_aft, del, get, argv[6]);
 
 	free(get);
 	free(del);
@@ -2582,11 +2503,7 @@
 	duration.day += duration.yr * 365;
 	duration.hr += duration.day * 24;
 
-	switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", 
-		duration.hr,
-		duration.min,
-		duration.sec
-		);
+	switch_snprintf(duration_str, sizeof(duration_str), "%.2u:%.2u:%.2u", duration.hr, duration.min, duration.sec);
 
 	if (l_created) {
 		switch_time_exp_lt(&tm, l_created);
@@ -2622,10 +2539,9 @@
 	switch_xml_set_txt_d(x_link, del);
 
 	tmp = switch_mprintf("<![CDATA[Priority: %s<br>"
-		"Last Heard: %s<br>Duration: %s<br>"
-		"<a href=%s>Delete This Message</a><br>"
-		"]]>", 
-		strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", heard, duration_str, del);
+						 "Last Heard: %s<br>Duration: %s<br>"
+						 "<a href=%s>Delete This Message</a><br>"
+						 "]]>", strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", heard, duration_str, del);
 
 	switch_xml_set_txt_d(x_tmp, tmp);
 	free(tmp);
@@ -2740,7 +2656,7 @@
 	holder.uri = uri;
 
 	if (profile->web_head) {
-		stream->raw_write_function(stream, (uint8_t *)profile->web_head, strlen(profile->web_head));
+		stream->raw_write_function(stream, (uint8_t *) profile->web_head, strlen(profile->web_head));
 	}
 
 	cbt.buf = buf;
@@ -2758,7 +2674,7 @@
 	stream->write_function(stream, "%d message%s<br>", ttl, ttl == 1 ? "" : "s");
 
 	if (profile->web_tail) {
-		stream->raw_write_function(stream, (uint8_t *)profile->web_tail, strlen(profile->web_tail));
+		stream->raw_write_function(stream, (uint8_t *) profile->web_tail, strlen(profile->web_tail));
 	}
 }
 
@@ -2840,9 +2756,9 @@
 
 	if (path_info) {
 		if (!strncasecmp(path_info, "get/", 4)) {
-			do_play(profile, user, domain, path_info + 4, stream);        
+			do_play(profile, user, domain, path_info + 4, stream);
 		} else if (!strncasecmp(path_info, "del/", 4)) {
-			do_del(profile, user, domain, path_info + 4, stream);        
+			do_del(profile, user, domain, path_info + 4, stream);
 		} else if (!strncasecmp(path_info, "web", 3)) {
 			do_web(profile, user, domain, host, port, uri, stream);
 		}
@@ -2854,7 +2770,7 @@
 
 	goto done;
 
-error:
+  error:
 	if (host) {
 		if (!ct) {
 			stream->write_function(stream, "Content-type: text/html\n\n<h2>");
@@ -2862,7 +2778,7 @@
 	}
 	stream->write_function(stream, "Error: %s\n", VOICEMAIL_SYNTAX);
 
-done:
+  done:
 	switch_safe_free(mydata);
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -2883,13 +2799,13 @@
 
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_MESSAGE_QUERY, SWITCH_EVENT_SUBCLASS_ANY, message_query_handler, NULL)
 		!= SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
-			return SWITCH_STATUS_GENERR;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
+		return SWITCH_STATUS_GENERR;
 	}
 
 	SWITCH_ADD_API(commands_api_interface, "voicemail", "voicemail", voicemail_api_function, VOICEMAIL_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "vm_boxcount", "vm_boxcount", boxcount_api_function, BOXCOUNT_SYNTAX);
-	
+
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_NOUNLOAD;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	Tue May 27 07:24:06 2008
@@ -257,7 +257,7 @@
 	swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
 }
 
-static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags)
+static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags)
 {
 	cepstral_t *cepstral;
 	size_t desired = *datalen;

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_lumenvox/mod_lumenvox.cpp
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_lumenvox/mod_lumenvox.cpp	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_lumenvox/mod_lumenvox.cpp	Tue May 27 07:24:06 2008
@@ -56,7 +56,7 @@
 	switch_mutex_t *flag_mutex;
 } lumenvox_t;
 
-static void log_callback(const char* message, void* userdata)
+static void log_callback(const char *message, void *userdata)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", message);
 }
@@ -72,50 +72,47 @@
 	"BEEP"
 };
 
-std::ostream& operator << (std::ostream& os ,const LVSemanticData& Data)
+std::ostream & operator <<(std::ostream & os, const LVSemanticData & Data)
 {
 	int i;
 	LVSemanticObject Obj;
-	switch (Data.Type())
-		{
-		case SI_TYPE_BOOL:
-			os << Data.GetBool();
-			break;
-		case SI_TYPE_INT:
-			os << Data.GetInt();
-			break;
-		case SI_TYPE_DOUBLE:
-			os << Data.GetDouble();
-			break;
-		case SI_TYPE_STRING:
-			os << Data.GetString();
-			break;
-		case SI_TYPE_OBJECT:
-			Obj = Data.GetSemanticObject();
-			for (i = 0; i < Obj.NumberOfProperties(); ++i)
-				{
-					os << "<" << Obj.PropertyName(i) << ">";
-					os << Obj.PropertyValue(i);
-					os << "</" << Obj.PropertyName(i) << ">";
-				}
-			break;
-		case SI_TYPE_ARRAY:
-			for (i = 0; i < Data.GetSemanticArray().Size(); ++i)
-				{
-					os << Data.GetArray().At(i);
-				}
-			break;
+	switch (Data.Type()) {
+	case SI_TYPE_BOOL:
+		os << Data.GetBool();
+		break;
+	case SI_TYPE_INT:
+		os << Data.GetInt();
+		break;
+	case SI_TYPE_DOUBLE:
+		os << Data.GetDouble();
+		break;
+	case SI_TYPE_STRING:
+		os << Data.GetString();
+		break;
+	case SI_TYPE_OBJECT:
+		Obj = Data.GetSemanticObject();
+		for (i = 0; i < Obj.NumberOfProperties(); ++i) {
+			os << "<" << Obj.PropertyName(i) << ">";
+			os << Obj.PropertyValue(i);
+			os << "</" << Obj.PropertyName(i) << ">";
+		}
+		break;
+	case SI_TYPE_ARRAY:
+		for (i = 0; i < Data.GetSemanticArray().Size(); ++i) {
+			os << Data.GetArray().At(i);
 		}
+		break;
+	}
 	return os;
 }
 
 //==============================================================================================
 // code to plug LVInterpretation into any standard stream
-std::ostream& operator << (std::ostream& os, const LVInterpretation& Interp)
+std::ostream & operator <<(std::ostream & os, const LVInterpretation & Interp)
 {
-	os << "<interpretation grammar=\""<<Interp.GrammarLabel()
-	   <<"\" score=\""<<Interp.Score()<<"\">";
-	os << "<result name=\""<<Interp.ResultName()<<"\">";
+	os << "<interpretation grammar=\"" << Interp.GrammarLabel()
+		<< "\" score=\"" << Interp.Score() << "\">";
+	os << "<result name=\"" << Interp.ResultName() << "\">";
 	os << Interp.ResultData();
 	os << "</result>";
 	os << "<input>";
@@ -126,30 +123,26 @@
 }
 
 
-static void state_change_callback(long new_state, unsigned long total_bytes,
-				   unsigned long recorded_bytes, void *user_data)
+static void state_change_callback(long new_state, unsigned long total_bytes, unsigned long recorded_bytes, void *user_data)
 {
 	lumenvox_t *lv = (lumenvox_t *) user_data;
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "State: [%s] total bytes: [%ld] recorded bytes: [%ld]\n",
-					  state_names[new_state],
-					  total_bytes,
-					  recorded_bytes);
-
-	switch (new_state)
-		{
-		case STREAM_STATUS_READY:
-			break;
-		case STREAM_STATUS_STOPPED:
-			switch_clear_flag_locked(lv, LVFLAG_READY);
-			break;
-		case STREAM_STATUS_END_SPEECH:
-			switch_set_flag_locked(lv, LVFLAG_HAS_TEXT);
-			break;
-		case STREAM_STATUS_BARGE_IN:
-			switch_set_flag_locked(lv, LVFLAG_BARGE);
-			break;
-		}
+					  state_names[new_state], total_bytes, recorded_bytes);
+
+	switch (new_state) {
+	case STREAM_STATUS_READY:
+		break;
+	case STREAM_STATUS_STOPPED:
+		switch_clear_flag_locked(lv, LVFLAG_READY);
+		break;
+	case STREAM_STATUS_END_SPEECH:
+		switch_set_flag_locked(lv, LVFLAG_HAS_TEXT);
+		break;
+	case STREAM_STATUS_BARGE_IN:
+		switch_set_flag_locked(lv, LVFLAG_BARGE);
+		break;
+	}
 }
 
 static switch_status_t lumenvox_asr_pause(switch_asr_handle_t *ah)
@@ -177,20 +170,20 @@
 			lv->port.ClosePort();
 			return SWITCH_STATUS_GENERR;
 		}
-		switch_set_flag_locked(lv, LVFLAG_READY);		
+		switch_set_flag_locked(lv, LVFLAG_READY);
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	return SWITCH_STATUS_GENERR;
 }
 
 /*! function to open the asr interface */
-static switch_status_t lumenvox_asr_open(switch_asr_handle_t *ah, char *codec, int rate, char *dest, switch_asr_flag_t *flags) 
+static switch_status_t lumenvox_asr_open(switch_asr_handle_t *ah, char *codec, int rate, char *dest, switch_asr_flag_t *flags)
 {
-	
+
 	lumenvox_t *lv;
 	int error_code;
-	
+
 	if (!(lv = (lumenvox_t *) switch_core_alloc(ah->memory_pool, sizeof(*lv)))) {
 		return SWITCH_STATUS_MEMERR;
 	}
@@ -199,7 +192,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Rate: Pick 8000 or 16000\n");
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (!strcasecmp(codec, "PCMU")) {
 		switch (rate) {
 		case 8000:
@@ -238,36 +231,35 @@
 	if (!lv->sound_format) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot negotiate sound format.\n");
 		return SWITCH_STATUS_FALSE;
-	}	
+	}
 
 	ah->rate = rate;
 	ah->codec = switch_core_strdup(ah->memory_pool, codec);
-	
+
 	lv->port.OpenPort(log_callback, NULL, 5);
 	error_code = lv->port.GetOpenPortStatus();
-	
-	switch(error_code)
-		{
-		case LV_FAILURE:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Licenses Exceeded!\n");
-			return SWITCH_STATUS_GENERR;
-		case LV_OPEN_PORT_FAILED__PRIMARY_SERVER_NOT_RESPONDING:
-		case LV_NO_SERVER_RESPONDING:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SRE Server Unavailable!\n");
-			return SWITCH_STATUS_GENERR;
-		case LV_SUCCESS:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Port Opened %d %dkhz.\n", lv->sound_format, rate);
-			break;
-		}
+
+	switch (error_code) {
+	case LV_FAILURE:
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Licenses Exceeded!\n");
+		return SWITCH_STATUS_GENERR;
+	case LV_OPEN_PORT_FAILED__PRIMARY_SERVER_NOT_RESPONDING:
+	case LV_NO_SERVER_RESPONDING:
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SRE Server Unavailable!\n");
+		return SWITCH_STATUS_GENERR;
+	case LV_SUCCESS:
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Port Opened %d %dkhz.\n", lv->sound_format, rate);
+		break;
+	}
 
 
 	// turn on sound and response file logging
 	/*
-	  int save_sound_files = 1;
-	  lv->port.SetPropertyEx(PROP_EX_SAVE_SOUND_FILES,
-						   PROP_EX_VALUE_TYPE_INT_PTR,
-						   &save_sound_files);
-	*/
+	   int save_sound_files = 1;
+	   lv->port.SetPropertyEx(PROP_EX_SAVE_SOUND_FILES,
+	   PROP_EX_VALUE_TYPE_INT_PTR,
+	   &save_sound_files);
+	 */
 	lv->channel = 1;
 	lv->flags = *flags;
 	lv->port.StreamSetParameter(STREAM_PARM_DETECT_BARGE_IN, 1);
@@ -275,9 +267,9 @@
 	lv->port.StreamSetParameter(STREAM_PARM_AUTO_DECODE, 1);
 	lv->port.StreamSetParameter(STREAM_PARM_DECODE_FLAGS, LV_DECODE_SEMANTIC_INTERPRETATION);
 	lv->port.StreamSetParameter(STREAM_PARM_VOICE_CHANNEL, lv->channel);
-	lv->port.StreamSetParameter(STREAM_PARM_GRAMMAR_SET, (long unsigned int) LV_ACTIVE_GRAMMAR_SET); 
+	lv->port.StreamSetParameter(STREAM_PARM_GRAMMAR_SET, (long unsigned int) LV_ACTIVE_GRAMMAR_SET);
+
 
-	
 	lv->port.StreamSetStateChangeCallBack(state_change_callback, lv);
 	lv->port.StreamSetParameter(STREAM_PARM_SOUND_FORMAT, lv->sound_format);
 
@@ -292,7 +284,7 @@
 		lv->port.ClosePort();
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	ah->private_info = lv;
 
 	return SWITCH_STATUS_SUCCESS;
@@ -347,13 +339,13 @@
 {
 
 	lumenvox_t *lv = (lumenvox_t *) ah->private_info;
-	
+
 	if (!switch_test_flag(lv, LVFLAG_HAS_TEXT) && switch_test_flag(lv, LVFLAG_READY)) {
 		if (lv->port.StreamSendData(data, len)) {
-			return SWITCH_STATUS_FALSE;		
+			return SWITCH_STATUS_FALSE;
 		}
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -384,21 +376,21 @@
 
 		lv->port.StreamStop();
 		code = lv->port.WaitForEngineToIdle(3000, lv->channel);
-	
+
 		if (code == LV_TIME_OUT) {
 			return SWITCH_STATUS_FALSE;
 		}
-		
+
 		numInterp = lv->port.GetNumberOfInterpretations(lv->channel);
-		
+
 		for (int t = 0; t < numInterp; ++t) {
 			ss << lv->port.GetInterpretation(lv->channel, t);
 		}
-		
-		*xmlstr = strdup((char *)ss.str().c_str());
+
+		*xmlstr = strdup((char *) ss.str().c_str());
 		switch_clear_flag_locked(lv, LVFLAG_HAS_TEXT);
 
-		
+
 		if (switch_test_flag(lv, SWITCH_ASR_FLAG_AUTO_RESUME)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
 			switch_set_flag_locked(lv, LVFLAG_READY);
@@ -410,21 +402,21 @@
 
 		ret = SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	return ret;
 }
 
 static const switch_asr_interface_t lumenvox_asr_interface = {
-	/*.interface_name*/			"lumenvox",
-	/*.asr_open*/				lumenvox_asr_open,
-	/*.asr_load_grammar*/		lumenvox_asr_load_grammar,
-	/*.asr_unload_grammar*/		lumenvox_asr_unload_grammar,
-	/*.asr_close*/				lumenvox_asr_close,
-	/*.asr_feed*/				lumenvox_asr_feed,
-	/*.asr_resume*/				lumenvox_asr_resume,
-	/*.asr_pause*/				lumenvox_asr_pause,
-	/*.asr_check_results*/		lumenvox_asr_check_results,
-	/*.asr_get_results*/		lumenvox_asr_get_results
+	/*.interface_name */ "lumenvox",
+	/*.asr_open */ lumenvox_asr_open,
+	/*.asr_load_grammar */ lumenvox_asr_load_grammar,
+	/*.asr_unload_grammar */ lumenvox_asr_unload_grammar,
+	/*.asr_close */ lumenvox_asr_close,
+	/*.asr_feed */ lumenvox_asr_feed,
+	/*.asr_resume */ lumenvox_asr_resume,
+	/*.asr_pause */ lumenvox_asr_pause,
+	/*.asr_check_results */ lumenvox_asr_check_results,
+	/*.asr_get_results */ lumenvox_asr_get_results
 };
 
 static const switch_loadable_module_interface_t lumenvox_module_interface = {
@@ -447,7 +439,7 @@
 {
 	LVSpeechPort::RegisterAppLogMsg(log_callback, NULL, 5);
 	//LVSpeechPort::SetClientPropertyEx(PROP_EX_SRE_SERVERS, PROP_EX_VALUE_TYPE_STRING, (void *)"127.0.0.1");
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &lumenvox_module_interface;
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	Tue May 27 07:24:06 2008
@@ -66,40 +66,39 @@
 #include "mrcp_synthesizer.h"
 #include "mrcp_generic_header.h"
 
-	
+
 SWITCH_MODULE_LOAD_FUNCTION(mod_openmrcp_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_openmrcp_shutdown);
-SWITCH_MODULE_DEFINITION(mod_openmrcp, mod_openmrcp_load, 
-						 mod_openmrcp_shutdown, NULL);
+SWITCH_MODULE_DEFINITION(mod_openmrcp, mod_openmrcp_load, mod_openmrcp_shutdown, NULL);
 
 typedef struct {
-	char                      *name;
+	char *name;
 	openmrcp_client_options_t *mrcp_options;
-	mrcp_client_t             *mrcp_client;
-	mrcp_client_context_t     *mrcp_context;
+	mrcp_client_t *mrcp_client;
+	mrcp_client_context_t *mrcp_context;
 } openmrcp_profile_t;
 
 typedef struct {
-	openmrcp_profile_t    *profile;
-	mrcp_session_t        *client_session;
+	openmrcp_profile_t *profile;
+	mrcp_session_t *client_session;
 	mrcp_client_channel_t *control_channel;
-	mrcp_audio_channel_t  *audio_channel;
-	mrcp_message_t        *mrcp_message_last_rcvd;
-	apr_pool_t            *pool;
-	switch_speech_flag_t   flags;
-	switch_mutex_t        *flag_mutex;
-	switch_thread_cond_t  *wait_object;
+	mrcp_audio_channel_t *audio_channel;
+	mrcp_message_t *mrcp_message_last_rcvd;
+	apr_pool_t *pool;
+	switch_speech_flag_t flags;
+	switch_mutex_t *flag_mutex;
+	switch_thread_cond_t *wait_object;
 } openmrcp_session_t;
 
 typedef enum {
-	FLAG_HAS_MESSAGE =    (1 << 0), 
-	FLAG_FEED_STARTED =   (1 << 1), 
-	FLAG_TERMINATING =    (1 << 2)
+	FLAG_HAS_MESSAGE = (1 << 0),
+	FLAG_FEED_STARTED = (1 << 1),
+	FLAG_TERMINATING = (1 << 2)
 } mrcp_flag_t;
 
 typedef struct {
 	switch_memory_pool_t *pool;
-	switch_hash_t        *profile_hash;
+	switch_hash_t *profile_hash;
 	char *asr_profile_name;
 	char *tts_profile_name;
 	//openmrcp_profile_t   *asr_profile;
@@ -109,7 +108,7 @@
 static openmrcp_module_t openmrcp_module;
 static switch_status_t openmrcp_profile_run(openmrcp_profile_t *profile);
 
-static openmrcp_session_t* openmrcp_session_create(openmrcp_profile_t *profile)
+static openmrcp_session_t *openmrcp_session_create(openmrcp_profile_t *profile)
 {
 	openmrcp_session_t *openmrcp_session;
 	apr_pool_t *session_pool;
@@ -172,14 +171,14 @@
 
 	if (switch_test_flag(openmrcp_session, FLAG_TERMINATING)) {
 		openmrcp_session_destroy(openmrcp_session);
-	}
-	else {
+	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "abnormal session terminate\n");
 	}
 	return MRCP_STATUS_SUCCESS;
 }
 
-static mrcp_status_t openmrcp_on_channel_add(mrcp_client_context_t *context, mrcp_session_t *session, mrcp_client_channel_t *control_channel, mrcp_audio_channel_t *audio_channel)
+static mrcp_status_t openmrcp_on_channel_add(mrcp_client_context_t *context, mrcp_session_t *session, mrcp_client_channel_t *control_channel,
+											 mrcp_audio_channel_t *audio_channel)
 {
 	openmrcp_session_t *openmrcp_session = mrcp_client_context_session_object_get(session);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "on_channel_add called\n");
@@ -242,8 +241,9 @@
 	apr_finfo_t finfo;
 	char *buf1;
 	apr_size_t bytes2read = 0;
-	
-	mrcp_message_t *mrcp_message = mrcp_client_context_message_get(context, asr_session->client_session, asr_session->control_channel, RECOGNIZER_RECOGNIZE);
+
+	mrcp_message_t *mrcp_message =
+		mrcp_client_context_message_get(context, asr_session->client_session, asr_session->control_channel, RECOGNIZER_RECOGNIZE);
 
 	if (!mrcp_message) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create mrcp msg\n");
@@ -257,9 +257,9 @@
 		return -1;
 	}
 	rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fp);
-	
-	buf1 = apr_palloc(mp, (apr_size_t)finfo.size + 1);
-	bytes2read = (apr_size_t)finfo.size;
+
+	buf1 = apr_palloc(mp, (apr_size_t) finfo.size + 1);
+	bytes2read = (apr_size_t) finfo.size;
 	rv = apr_file_read(fp, buf1, &bytes2read);
 	buf1[bytes2read] = '\0';
 
@@ -286,27 +286,23 @@
  * This code expects certain one-time initialization of the openmrcp client
  * engine/systeme to have already taken place.function to open the asr interface 
  */
-static switch_status_t openmrcp_asr_open(switch_asr_handle_t *ah,
-										 const char *codec,
-										 int rate,
-										 const char *dest,
-										 switch_asr_flag_t *flags) 
+static switch_status_t openmrcp_asr_open(switch_asr_handle_t *ah, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags)
 {
 	openmrcp_session_t *asr_session;
 	mrcp_client_channel_t *asr_channel;
 	char *profile_name = openmrcp_module.asr_profile_name;
-	openmrcp_profile_t   *asr_profile = NULL;
+	openmrcp_profile_t *asr_profile = NULL;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "asr_open called, codec: %s, rate: %d\n", codec, rate);
 
 	if (strcmp(codec, "L16")) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sorry, only L16 codec supported\n");
-		return SWITCH_STATUS_GENERR;		
+		return SWITCH_STATUS_GENERR;
 	}
 	if (rate != 8000) {
 		// TODO: look into supporting other sample rates
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sorry, only 8kz supported\n");
-		return SWITCH_STATUS_GENERR;		
+		return SWITCH_STATUS_GENERR;
 	}
 
 	if (!switch_strlen_zero(ah->param)) {
@@ -315,7 +311,7 @@
 
 	if (!(asr_profile = switch_core_hash_find(openmrcp_module.profile_hash, profile_name))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot locate profile %s\n", profile_name);
-		return SWITCH_STATUS_GENERR;		
+		return SWITCH_STATUS_GENERR;
 	}
 
 	/* create session */
@@ -336,7 +332,7 @@
 
 	switch_mutex_lock(asr_session->flag_mutex);
 	mrcp_client_context_channel_add(asr_session->profile->mrcp_context, asr_session->client_session, asr_channel, NULL);
-	if (switch_thread_cond_timedwait(asr_session->wait_object, asr_session->flag_mutex, 5000*1000) != APR_SUCCESS) {
+	if (switch_thread_cond_timedwait(asr_session->wait_object, asr_session->flag_mutex, 5000 * 1000) != APR_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No response from client stack\n");
 	}
 	switch_mutex_unlock(asr_session->flag_mutex);
@@ -358,15 +354,15 @@
 	
 	    TODO: - how does DEFINE-GRAMMAR fit into the picture here?  (if at all) 
 	*/
-	
+
 	openmrcp_session_t *asr_session = (openmrcp_session_t *) ah->private_info;
 	mrcp_client_context_t *context = asr_session->profile->mrcp_context;
-		
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading grammar\n");
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Start Recognizer\n");
 	openmrcp_recog_start(context, asr_session, path);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Finished loading grammar\n");
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -387,22 +383,22 @@
 	/* sampling rate and frame size should be retrieved from audio sink */
 	media_frame.codec_frame.size = 160;
 	media_frame.codec_frame.buffer = data;
-	while(len >= media_frame.codec_frame.size) {
+	while (len >= media_frame.codec_frame.size) {
 		if (!audio_sink) {
 			/*!
-			  If there is no audio_sink established yet, discard the audio and
-			  return SUCCESS.  returning anything other than success causes freeswitch
-			  to abort the call and tear down the channel.  One reason there might
-			  not be an audio sink is that the openmrcp client lib is still in the startup
-			  process.  
-			*/
+			   If there is no audio_sink established yet, discard the audio and
+			   return SUCCESS.  returning anything other than success causes freeswitch
+			   to abort the call and tear down the channel.  One reason there might
+			   not be an audio sink is that the openmrcp client lib is still in the startup
+			   process.  
+			 */
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "!audio_sink\n");
-			return SWITCH_STATUS_SUCCESS;  
+			return SWITCH_STATUS_SUCCESS;
 		}
 		audio_sink->method_set->write_frame(audio_sink, &media_frame);
-		
-		len -= (unsigned int)media_frame.codec_frame.size;
-		media_frame.codec_frame.buffer = (char*)media_frame.codec_frame.buffer + media_frame.codec_frame.size;
+
+		len -= (unsigned int) media_frame.codec_frame.size;
+		media_frame.codec_frame.buffer = (char *) media_frame.codec_frame.buffer + media_frame.codec_frame.size;
 	}
 	if (len > 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "None frame alligned data len [%d]\n", len);
@@ -452,9 +448,9 @@
 
 	// terminate client session
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Going to TERMINATE SESSION\n");
-	switch_set_flag_locked(asr_session, FLAG_TERMINATING);  
+	switch_set_flag_locked(asr_session, FLAG_TERMINATING);
 	mrcp_client_context_session_terminate(context, asr_session->client_session);
-	
+
 	switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -470,7 +466,7 @@
 static switch_status_t openmrcp_asr_check_results(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
 {
 	openmrcp_session_t *asr_session = (openmrcp_session_t *) ah->private_info;
-	
+
 	switch_status_t rv = (switch_test_flag(asr_session, FLAG_HAS_MESSAGE)) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
 
 	return rv;
@@ -491,49 +487,44 @@
 	switch_clear_flag_locked(asr_session, FLAG_HAS_MESSAGE);
 
 	if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
-		if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && 
-			message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
+		if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "error code received [%d]\n", message->start_line.status_code);
 			ret = SWITCH_STATUS_FALSE;
 		}
-	} 
-	else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
+	} else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
 		if (message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
 			/*! 
 			   we have to extract the XML but stripping off the <?xml version="1.0"?>
 			   header.  the body looks like:
-			
+
 			   Completion-Cause:001 no-match
 			   Content-Type: application/nlsml+xml
 			   Content-Length: 260
-			 
-			  <?xml version="1.0"?>
-			  <result xmlns="http://www.ietf.org/xml/ns/mrcpv2" xmlns:ex="http://www.example.com/example" score="100" grammar="session:request1 at form-level.store">
-				<interpretation>             <input mode="speech">open a</input>
-				</interpretation>
-			  </result>
-			*/
+
+			   <?xml version="1.0"?>
+			   <result xmlns="http://www.ietf.org/xml/ns/mrcpv2" xmlns:ex="http://www.example.com/example" score="100" grammar="session:request1 at form-level.store">
+			   <interpretation>             <input mode="speech">open a</input>
+			   </interpretation>
+			   </result>
+			 */
 
 			if (message->body) {
-				char *marker = "?>";  // FIXME -- lame and brittle way of doing this.  use regex or better.
+				char *marker = "?>";	// FIXME -- lame and brittle way of doing this.  use regex or better.
 				char *position = strstr(message->body, marker);
 				if (!position) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", message->body);
 					ret = SWITCH_STATUS_FALSE;
-				}
-				else {
+				} else {
 					position += strlen(marker);
 					*xmlstr = strdup(position);
 				}
-			}
-			else {
+			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No result received from mrcp server\n");
 				ret = SWITCH_STATUS_FALSE;
 			}
 
-			ret = SWITCH_STATUS_SUCCESS;	
-		} 
-		else if (message->start_line.method_id == RECOGNIZER_START_OF_INPUT) {
+			ret = SWITCH_STATUS_SUCCESS;
+		} else if (message->start_line.method_id == RECOGNIZER_START_OF_INPUT) {
 			ret = SWITCH_STATUS_BREAK;
 		}
 	}
@@ -546,23 +537,17 @@
 	mrcp_generic_header_t *generic_header;
 	mrcp_message_t *mrcp_message;
 	mrcp_status_t status = MRCP_STATUS_FAILURE;
-	
+
 	char *text2speak;
-	const char v2_xml_head[] = 
-		"<?xml version=\"1.0\"?>\r\n"
-		"<speak>\r\n"
-		"<paragraph>\r\n"
-		"    <sentence><break time=\"1000ms\"/>";
+	const char v2_xml_head[] = "<?xml version=\"1.0\"?>\r\n" "<speak>\r\n" "<paragraph>\r\n" "    <sentence><break time=\"1000ms\"/>";
 
-	const char v2_xml_tail[] = "<break time=\"1000ms\"/></sentence>\r\n"
-		"</paragraph>\r\n"
-		"</speak>\r\n";
+	const char v2_xml_tail[] = "<break time=\"1000ms\"/></sentence>\r\n" "</paragraph>\r\n" "</speak>\r\n";
 
-    const char v1_xml_head[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-        "<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\">\n<break time=\"1000ms\"/>";
+	const char v1_xml_head[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+		"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\">\n<break time=\"1000ms\"/>";
 
 
-    const char v1_xml_tail[] = "<break time=\"1000ms\"/>\n</speak>\n";
+	const char v1_xml_tail[] = "<break time=\"1000ms\"/>\n</speak>\n";
 
 	const char *xml_head, *xml_tail;
 
@@ -592,7 +577,7 @@
 
 	status = mrcp_client_context_channel_modify(context, tts_session->client_session, mrcp_message);
 
- end:
+  end:
 
 	return status;
 
@@ -609,12 +594,12 @@
 }
 
 
-static switch_status_t openmrcp_tts_open(switch_speech_handle_t *sh, const char *voice_name, int rate, switch_speech_flag_t *flags) 
+static switch_status_t openmrcp_tts_open(switch_speech_handle_t *sh, const char *voice_name, int rate, switch_speech_flag_t *flags)
 {
 	openmrcp_session_t *tts_session;
 	mrcp_client_channel_t *tts_channel;
 	char *profile_name = openmrcp_module.tts_profile_name;
-	openmrcp_profile_t   *tts_profile = NULL;
+	openmrcp_profile_t *tts_profile = NULL;
 
 	if (!switch_strlen_zero(sh->param)) {
 		profile_name = sh->param;
@@ -622,7 +607,7 @@
 
 	if (!(tts_profile = switch_core_hash_find(openmrcp_module.profile_hash, profile_name))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot locate profile %s\n", profile_name);
-		return SWITCH_STATUS_GENERR;		
+		return SWITCH_STATUS_GENERR;
 	}
 
 	/* create session */
@@ -642,7 +627,7 @@
 	}
 	switch_mutex_lock(tts_session->flag_mutex);
 	mrcp_client_context_channel_add(tts_session->profile->mrcp_context, tts_session->client_session, tts_channel, NULL);
-	if (switch_thread_cond_timedwait(tts_session->wait_object, tts_session->flag_mutex, 5000*1000) != APR_SUCCESS) {
+	if (switch_thread_cond_timedwait(tts_session->wait_object, tts_session->flag_mutex, 5000 * 1000) != APR_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No response from client stack\n");
 	}
 	switch_mutex_unlock(tts_session->flag_mutex);
@@ -665,7 +650,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "terminate tts_session\n");
 	switch_set_flag_locked(tts_session, FLAG_TERMINATING);
 	mrcp_client_context_session_terminate(context, tts_session->client_session);
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t openmrcp_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
@@ -677,11 +662,11 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no synthesizer channel too feed tts\n");
 		return SWITCH_STATUS_FALSE;
 	}
-	
-	synth_speak(context, tts_session, text); 
-	
+
+	synth_speak(context, tts_session, text);
+
 	switch_clear_flag(tts_session, FLAG_FEED_STARTED);
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 /**
@@ -693,7 +678,7 @@
 static switch_status_t openmrcp_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags)
 {
 	openmrcp_session_t *tts_session = (openmrcp_session_t *) sh->private_info;
-	size_t return_len=0;
+	size_t return_len = 0;
 	media_frame_t media_frame;
 	audio_source_t *audio_source;
 
@@ -703,13 +688,11 @@
 		switch_clear_flag_locked(tts_session, FLAG_HAS_MESSAGE);
 
 		if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
-			if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && 
-				message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
+			if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "error code received [%d]\n", message->start_line.status_code);
 				return SWITCH_STATUS_BREAK;
 			}
-		} 
-		else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
+		} else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
 			if (message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
 				/* tell fs we are done */
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FLAG_SPEAK_COMPLETE\n");
@@ -724,7 +707,7 @@
 	}
 
 	if (!switch_test_flag(tts_session, FLAG_FEED_STARTED)) {
-		switch_set_flag(tts_session, FLAG_FEED_STARTED);  // shouldn't this use set_flag_locked? -tl
+		switch_set_flag(tts_session, FLAG_FEED_STARTED);	// shouldn't this use set_flag_locked? -tl
 		if (audio_source->method_set->open) {
 			audio_source->method_set->open(audio_source);
 		}
@@ -733,8 +716,8 @@
 	/* sampling rate and frame size should be retrieved from audio source */
 	*rate = 8000;
 	media_frame.codec_frame.size = 160;
-	while(return_len < *datalen) {
-		media_frame.codec_frame.buffer = (char*)data + return_len;
+	while (return_len < *datalen) {
+		media_frame.codec_frame.buffer = (char *) data + return_len;
 		audio_source->method_set->read_frame(audio_source, &media_frame);
 		if (media_frame.type != MEDIA_FRAME_TYPE_AUDIO) {
 			memset(media_frame.codec_frame.buffer, 0, media_frame.codec_frame.size);
@@ -742,7 +725,7 @@
 		return_len += media_frame.codec_frame.size;
 	}
 	*datalen = return_len;
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
@@ -752,7 +735,7 @@
 	mrcp_client_context_t *context = tts_session->profile->mrcp_context;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "flush_tts called\n");
-	synth_stop(context, tts_session); // TODO
+	synth_stop(context, tts_session);	// TODO
 }
 
 static void openmrcp_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
@@ -797,8 +780,7 @@
 				apt_log_priority_set(atoi(val));
 			}
 		}
-	}
-	else {
+	} else {
 		goto error;
 	}
 	if ((profiles = switch_xml_child(cfg, "profiles"))) {
@@ -818,9 +800,8 @@
 				const char *val = switch_xml_attr_soft(param, "value");
 
 				if (!strcasecmp(var, "proto_version")) {
-					mrcp_options->proto_version =(mrcp_version_t) atoi(val);
-				}
-				else if (!strcasecmp(var, "client_ip")) {
+					mrcp_options->proto_version = (mrcp_version_t) atoi(val);
+				} else if (!strcasecmp(var, "client_ip")) {
 					mrcp_options->client_ip = switch_core_strdup(openmrcp_module.pool, val);
 				} else if (!strcasecmp(var, "server_ip")) {
 					mrcp_options->server_ip = switch_core_strdup(openmrcp_module.pool, val);
@@ -835,27 +816,24 @@
 				}
 			}
 			mrcp_profile->mrcp_options = mrcp_options;
-			
+
 			/* add profile */
 			if (!switch_core_hash_find(openmrcp_module.profile_hash, mrcp_profile->name)) {
 				if (openmrcp_profile_run(mrcp_profile) == SWITCH_STATUS_SUCCESS) {
 					switch_core_hash_insert(openmrcp_module.profile_hash, mrcp_profile->name, mrcp_profile);
 				}
-			}
-			else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 
-					"profile with the name [%s] already exists\n", mrcp_profile->name);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "profile with the name [%s] already exists\n", mrcp_profile->name);
 			}
 		}
-	}
-	else {
+	} else {
 		goto error;
 	}
 
 	switch_xml_free(xml);
 	return SWITCH_STATUS_SUCCESS;
 
- error:
+  error:
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load module configuration\n");
 	switch_xml_free(xml);
 	return SWITCH_STATUS_TERM;
@@ -867,10 +845,10 @@
 	mrcp_client_event_handler_t *mrcp_event_handler;
 	mrcp_client_t *mrcp_client;
 	mrcp_client_context_t *mrcp_context;
-	
+
 	/*!
-	Perform one-time initialization of mrcp client library
-	*/
+	   Perform one-time initialization of mrcp client library
+	 */
 	mrcp_event_handler = switch_core_alloc(openmrcp_module.pool, sizeof(mrcp_client_event_handler_t));
 	mrcp_event_handler->on_session_initiate = openmrcp_on_session_initiate;
 	mrcp_event_handler->on_session_terminate = openmrcp_on_session_terminate;
@@ -902,7 +880,7 @@
 static switch_status_t openmrcp_init()
 {
 	/* one-time mrcp global initialization */
-	if(apr_pool_create(&openmrcp_module.pool,NULL) != APR_SUCCESS) {
+	if (apr_pool_create(&openmrcp_module.pool, NULL) != APR_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -931,7 +909,7 @@
 		/* shutdown client engine */
 		openmrcp_client_shutdown(mrcp_profile->mrcp_client);
 		/* destroy client context */
-		mrcp_client_context_destroy(mrcp_profile->mrcp_context);		
+		mrcp_client_context_destroy(mrcp_profile->mrcp_context);
 	}
 	switch_core_hash_destroy(&openmrcp_module.profile_hash);
 	openmrcp_module.profile_hash = NULL;
@@ -973,7 +951,7 @@
 
 	/* initialize openmrcp */
 	if (openmrcp_init() != SWITCH_STATUS_SUCCESS) {
-		return SWITCH_STATUS_FALSE;		
+		return SWITCH_STATUS_FALSE;
 	}
 
 	/* indicate that the module should continue to be loaded */

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_amr/mod_amr.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_amr/mod_amr.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_amr/mod_amr.c	Tue May 27 07:24:06 2008
@@ -139,8 +139,8 @@
 
 	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct amr_context))))) {
 		return SWITCH_STATUS_FALSE;
-	} else {	
-	
+	} else {
+
 		context->dtx_mode = AMR_DTX_ENABLED;
 		if (codec->fmtp_in) {
 			argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
@@ -207,7 +207,8 @@
 			context->enc_mode = globals.default_bitrate;
 		}
 
-		switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
+		switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0,
+						context->enc_mode);
 		codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
 
 		context->enc_mode = AMR_DEFAULT_BITRATE;
@@ -249,8 +250,7 @@
 										 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)
+										 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -272,8 +272,7 @@
 										 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)
+										 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -320,10 +319,9 @@
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	SWITCH_ADD_CODEC(codec_interface, "AMR");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200,
-                                         20000, 160, 320, 0, 1, 1, 1,
-                                         switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200,
+										 20000, 160, 320, 0, 1, 1, 1, switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g723_1/mod_g723_1.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g723_1/mod_g723_1.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g723_1/mod_g723_1.c	Tue May 27 07:24:06 2008
@@ -110,7 +110,7 @@
 										  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,
+										  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										  unsigned int *flag)
 {
 #ifdef G723_PASSTHROUGH
@@ -141,7 +141,7 @@
 										  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,
+										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										  unsigned int *flag)
 {
 #ifdef G723_PASSTHROUGH
@@ -170,16 +170,16 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf = 30000, spf = 240, bpf = 480, ebpf = 24, count;
+	int mpf = 30000, spf = 240, bpf = 480, ebpf = 24, count;
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_CODEC(codec_interface, "G.723.1 6.3k");
-    for (count = 1; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 4, 
-                                             switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
-    }
+	for (count = 1; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 4,
+											 switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
+	}
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g729/mod_g729.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_g729/mod_g729.c	Tue May 27 07:24:06 2008
@@ -95,7 +95,7 @@
 										  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,
+										  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										  unsigned int *flag)
 {
 #ifdef G729_PASSTHROUGH
@@ -138,7 +138,7 @@
 										  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,
+										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										  unsigned int *flag)
 {
 #ifdef G729_PASSTHROUGH
@@ -154,7 +154,7 @@
 	}
 
 	if (encoded_data_len % 2 == 0) {
-		
+
 		if (encoded_data_len == 2 || encoded_data_len % 12 == 0) {
 			return SWITCH_STATUS_BREAK;
 			//divisor = 12;
@@ -209,18 +209,18 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf = 10000, spf = 80, bpf = 160, ebpf = 10, count;
+	int mpf = 10000, spf = 80, bpf = 160, ebpf = 10, count;
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
 	SWITCH_ADD_CODEC(codec_interface, "G.729");
-    for (count = 12; count > 0; count--) { 
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 18, "G729", NULL, 8000, 8000, 8000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g729_init, switch_g729_encode, switch_g729_decode, switch_g729_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 18, "G729", NULL, 8000, 8000, 8000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g729_init, switch_g729_encode, switch_g729_decode, switch_g729_destroy);
+	}
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_h26x/mod_h26x.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_h26x/mod_h26x.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_h26x/mod_h26x.c	Tue May 27 07:24:06 2008
@@ -45,7 +45,7 @@
 	if (!(encoding || decoding)) {
 		return SWITCH_STATUS_FALSE;
 	} else {
-		if (codec->fmtp_in) { 
+		if (codec->fmtp_in) {
 			codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
 		}
 		return SWITCH_STATUS_SUCCESS;
@@ -53,21 +53,21 @@
 }
 
 static switch_status_t switch_h26x_encode(switch_codec_t *codec,
-										 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)
+										  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)
 {
 	return SWITCH_STATUS_FALSE;
 }
 
 static switch_status_t switch_h26x_decode(switch_codec_t *codec,
-										 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)
+										  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)
 {
 	return SWITCH_STATUS_FALSE;
 }
@@ -83,30 +83,25 @@
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_CODEC(codec_interface, "H.264 Video (passthru)");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-                                         switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
 	SWITCH_ADD_CODEC(codec_interface, "H.263 Video (passthru)");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 34, "H263", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-                                         switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 34, "H263", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
 	SWITCH_ADD_CODEC(codec_interface, "H.263+ Video (passthru)");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 115, "H263-1998", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-                                         switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 115, "H263-1998", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
 	SWITCH_ADD_CODEC(codec_interface, "H.263++ Video (passthru)");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 121, "H263-2000", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-                                         switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 121, "H263-2000", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
 	SWITCH_ADD_CODEC(codec_interface, "H.261 Video (passthru)");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_VIDEO, 31, "H261", NULL, 90000, 90000, 0,
-                                         0, 0, 0, 0, 1, 1, 1,
-                                         switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_VIDEO, 31, "H261", NULL, 90000, 90000, 0,
+										 0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_ilbc/mod_ilbc.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_ilbc/mod_ilbc.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_ilbc/mod_ilbc.c	Tue May 27 07:24:06 2008
@@ -97,7 +97,7 @@
 										  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,
+										  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										  unsigned int *flag)
 {
 	struct ilbc_context *context = codec->private_info;
@@ -137,7 +137,7 @@
 										  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,
+										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										  unsigned int *flag)
 {
 	struct ilbc_context *context = codec->private_info;
@@ -187,31 +187,31 @@
 
 	SWITCH_ADD_CODEC(codec_interface, "iLBC");
 
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 97, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
-                                         20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
-                                         20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC102", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
-                                         20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC20ms", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
-                                         20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
-    /* 30ms variants */
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 98, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
-                                         30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
-                                         30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
-                                         switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 97, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+										 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+										 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC102", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+										 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC20ms", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+										 20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	/* 30ms variants */
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 98, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+										 30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
+	switch_core_codec_add_implementation(pool, codec_interface,
+										 SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+										 30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
+										 switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_speex/mod_speex.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_speex/mod_speex.c	Tue May 27 07:24:06 2008
@@ -159,7 +159,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	struct speex_context *context = codec->private_info;
@@ -211,7 +211,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	struct speex_context *context = codec->private_info;
@@ -264,24 +264,24 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf = 20000, spf = 160, bpf = 320, ebpf = 0, rate = 8000, counta, countb;
-    switch_payload_t ianacode[4] = { 0, 98, 99, 103};
-    int bps[4] = { 0, 24600, 42200, 44000 };
+	int mpf = 20000, spf = 160, bpf = 320, ebpf = 0, rate = 8000, counta, countb;
+	switch_payload_t ianacode[4] = { 0, 98, 99, 103 };
+	int bps[4] = { 0, 24600, 42200, 44000 };
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_CODEC(codec_interface, "Speex");
-    for (counta = 1; counta <= 3; counta++) {
-        for (countb = 1; countb > 0; countb--) {
-            switch_core_codec_add_implementation(pool, codec_interface,
-                                                 SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "SPEEX", NULL, rate, rate, bps[counta],
-                                                 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 6,
-                                                 switch_speex_init, switch_speex_encode, switch_speex_decode, switch_speex_destroy);
-        }
-        rate = rate * 2;
-        spf = spf * 2;
-        bpf = bpf * 2;
-        ebpf = ebpf * 2;
-    }
+	for (counta = 1; counta <= 3; counta++) {
+		for (countb = 1; countb > 0; countb--) {
+			switch_core_codec_add_implementation(pool, codec_interface,
+												 SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "SPEEX", NULL, rate, rate, bps[counta],
+												 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 6,
+												 switch_speex_init, switch_speex_encode, switch_speex_decode, switch_speex_destroy);
+		}
+		rate = rate * 2;
+		spf = spf * 2;
+		bpf = bpf * 2;
+		ebpf = ebpf * 2;
+	}
 
 
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c	Tue May 27 07:24:06 2008
@@ -81,7 +81,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	struct lpc10_context *context = codec->private_info;
@@ -99,7 +99,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	struct lpc10_context *context = codec->private_info;
@@ -138,8 +138,8 @@
 		}
 		if (decoding) {
 			gsm0610_init(&context->decoder_object, GSM0610_PACKING_VOIP);
- 		}
-		
+		}
+
 		codec->private_info = context;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -149,8 +149,7 @@
 										 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)
+										 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
 {
 	struct gsm_context *context = codec->private_info;
 
@@ -167,8 +166,7 @@
 										 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)
+										 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
 {
 	struct gsm_context *context = codec->private_info;
 
@@ -187,6 +185,7 @@
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
+
 /*  GSM       - END */
 
 #ifdef ENABLE_G711
@@ -209,7 +208,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -232,7 +231,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -280,7 +279,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -303,7 +302,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	short *dbuf;
@@ -370,7 +369,7 @@
 										  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,
+										  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										  unsigned int *flag)
 {
 	struct g722_context *context = codec->private_info;
@@ -388,7 +387,7 @@
 										  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,
+										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										  unsigned int *flag)
 {
 	struct g722_context *context = codec->private_info;
@@ -416,8 +415,8 @@
 static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	uint32_t encoding, decoding;
-    int packing = G726_PACKING_RIGHT;
-    g726_state_t *context;
+	int packing = G726_PACKING_RIGHT;
+	g726_state_t *context;
 
 	encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
 	decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
@@ -426,10 +425,10 @@
 		return SWITCH_STATUS_FALSE;
 	} else {
 		if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
-            packing = G726_PACKING_LEFT;
-        } 
+			packing = G726_PACKING_LEFT;
+		}
 
-        g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
+		g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
 
 		codec->private_info = context;
 		return SWITCH_STATUS_SUCCESS;
@@ -446,7 +445,7 @@
 										  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,
+										  uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										  unsigned int *flag)
 {
 	g726_state_t *context = codec->private_info;
@@ -455,7 +454,7 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-    *encoded_data_len = g726_encode(context, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
+	*encoded_data_len = g726_encode(context, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -464,16 +463,16 @@
 										  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,
+										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										  unsigned int *flag)
 {
-    g726_state_t *context = codec->private_info;
+	g726_state_t *context = codec->private_info;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-    *decoded_data_len = (2 * g726_decode(context, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
+	*decoded_data_len = (2 * g726_decode(context, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -503,8 +502,8 @@
 		}
 		if (decoding) {
 			ima_adpcm_init(&context->decoder_object, IMA_ADPCM_DVI4, 0);
- 		}
-		
+		}
+
 		codec->private_info = context;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -514,7 +513,7 @@
 										   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,
+										   uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
 										   unsigned int *flag)
 {
 	struct ima_adpcm_context *context = codec->private_info;
@@ -532,7 +531,7 @@
 										   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,
+										   uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
 										   unsigned int *flag)
 {
 	struct ima_adpcm_context *context = codec->private_info;
@@ -559,7 +558,7 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
 {
 	switch_codec_interface_t *codec_interface;
-    int mpf, spf, bpf, ebpf, count;
+	int mpf, spf, bpf, ebpf, count;
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -567,134 +566,133 @@
 	/* IMA_ADPCM */
 	mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
 	SWITCH_ADD_CODEC(codec_interface, "ADPCM (IMA)");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 5, "DVI4", NULL, 8000, 8000, 32000,
-                                             mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
-                                             switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 5, "DVI4", NULL, 8000, 8000, 32000,
+											 mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
+											 switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
+	}
 	mpf = 10000, spf = 160, bpf = 320, ebpf = 160;
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 6, "DVI4", NULL, 16000, 16000, 64000,
-                                             mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
-                                             switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 6, "DVI4", NULL, 16000, 16000, 64000,
+											 mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
+											 switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
+	}
 
 	/* G726 */
 	mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
 	SWITCH_ADD_CODEC(codec_interface, "G.726 16k (AAL2)");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 124, "AAL2-G726-16", NULL, 8000, 8000, 16000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 124, "AAL2-G726-16", NULL, 8000, 8000, 16000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
 	SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 127, "G726-16", NULL, 8000, 8000, 16000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
-    /* Increase encoded bytes per frame by 10 */
-    ebpf = ebpf + 10;
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 127, "G726-16", NULL, 8000, 8000, 16000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
+	/* Increase encoded bytes per frame by 10 */
+	ebpf = ebpf + 10;
 
 	SWITCH_ADD_CODEC(codec_interface, "G.726 24k (AAL2)");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 123, "AAL2-G726-24", NULL, 8000, 8000, 24000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 123, "AAL2-G726-24", NULL, 8000, 8000, 24000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
 	SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 126, "G726-24", NULL, 8000, 8000, 24000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
-    /* Increase encoded bytes per frame by 10 */
-    ebpf = ebpf + 10;
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 126, "G726-24", NULL, 8000, 8000, 24000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
+	/* Increase encoded bytes per frame by 10 */
+	ebpf = ebpf + 10;
 
 	SWITCH_ADD_CODEC(codec_interface, "G.726 32k (AAL2)");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 2, "AAL2-G726-32", NULL, 8000, 8000, 32000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 2, "AAL2-G726-32", NULL, 8000, 8000, 32000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
 	SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 2, "G726-32", NULL, 8000, 8000, 32000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
-    /* Increase encoded bytes per frame by 10 */
-    ebpf = ebpf + 10;
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 2, "G726-32", NULL, 8000, 8000, 32000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
+	/* Increase encoded bytes per frame by 10 */
+	ebpf = ebpf + 10;
 
 	SWITCH_ADD_CODEC(codec_interface, "G.726 40k (AAL2)");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 122, "AAL2-G726-40", NULL, 8000, 8000, 40000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 122, "AAL2-G726-40", NULL, 8000, 8000, 40000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
 	SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 125, "G726-40", NULL, 8000, 8000, 40000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 125, "G726-40", NULL, 8000, 8000, 40000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
+	}
 
 	/* G722 */
 	mpf = 10000, spf = 80, bpf = 320, ebpf = 80;
 	SWITCH_ADD_CODEC(codec_interface, "G.722");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 9, "G722", NULL, 8000, 16000, 64000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 9, "G722", NULL, 8000, 16000, 64000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
+	}
 
 #ifdef ENABLE_G711
 	/* G711 */
 	mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
 	SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
-    }
-    
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
+	}
+
 	SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
-    for (count = 12; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
-                                             switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
-    }
+	for (count = 12; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
+											 switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
+	}
 #endif
 
 	/* GSM */
 	mpf = 20000, spf = 160, bpf = 320, ebpf = 33;
 	SWITCH_ADD_CODEC(codec_interface, "GSM");
-    for (count = 6; count > 0; count--) {
-        switch_core_codec_add_implementation(pool, codec_interface,
-                                             SWITCH_CODEC_TYPE_AUDIO, 3, "GSM", NULL, 8000, 8000, 13200,
-                                             mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 6,
-                                             switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
-    }
+	for (count = 6; count > 0; count--) {
+		switch_core_codec_add_implementation(pool, codec_interface,
+											 SWITCH_CODEC_TYPE_AUDIO, 3, "GSM", NULL, 8000, 8000, 13200,
+											 mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 6,
+											 switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
+	}
 	/* LPC10 */
 #if SWITCH_MAX_INTERVAL >= 90
 	SWITCH_ADD_CODEC(codec_interface, "LPC-10");
 	switch_core_codec_add_implementation(pool, codec_interface,
 										 SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
-										 90000, 720, 1440, 28, 1, 1, 1,
-										 switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
+										 90000, 720, 1440, 28, 1, 1, 1, switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
 #endif
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	Tue May 27 07:24:06 2008
@@ -58,31 +58,31 @@
 		if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
 			goto error;
 		}
-		
+
 		if (argc > 1) {
 			switch_channel_set_variable(channel, "call_timeout", argv[1]);
 		}
-		
-		switch_replace_char(argv[0], '&',',', SWITCH_FALSE);
-		
+
+		switch_replace_char(argv[0], '&', ',', SWITCH_FALSE);
+
 		if (exec_app(session, "bridge", argv[0]) != SWITCH_STATUS_SUCCESS) {
 			goto error;
 		}
-		
+
 		goto ok;
 	}
-	
- error:
+
+  error:
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error!\n");
 
- ok:
-	
+  ok:
+
 	return;
 }
 
 SWITCH_STANDARD_APP(avoid_function)
 {
-    void *y = NULL;
+	void *y = NULL;
 	int x = 0;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 
@@ -92,7 +92,7 @@
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "I should never be called!.\n");
-    memset((void *) y, 0, 1000);
+	memset((void *) y, 0, 1000);
 }
 
 SWITCH_STANDARD_APP(goto_function)
@@ -105,16 +105,16 @@
 		if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 1) {
 			goto error;
 		}
-		
+
 		switch_ivr_session_transfer(session, argv[1], "asterisk", argv[0]);
 		goto ok;
 	}
-	
- error:
+
+  error:
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error!\n");
 
- ok:
-	
+  ok:
+
 	return;
 }
 
@@ -134,14 +134,14 @@
 	if (!caller_profile) {
 		caller_profile = switch_channel_get_caller_profile(channel);
 	}
-	
+
 	if (!caller_profile || switch_strlen_zero(caller_profile->destination_number)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
 		return NULL;
 	}
 
 	context = caller_profile->context ? caller_profile->context : "default";
-	
+
 	if (!switch_config_open_file(&cfg, cf)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -166,11 +166,11 @@
 				const char *field_data = caller_profile->destination_number;
 				int proceed = 0;
 				switch_regex_t *re = NULL;
-				int ovector[30] = {0};
+				int ovector[30] = { 0 };
 				char *cid = NULL;
 
 				expression = expression_buf;
-						
+
 				argc = switch_separate_string(val, ',', argv, (sizeof(argv) / sizeof(argv[0])));
 				if (argc < 3) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "parse error line %d!\n", cfg.lineno);
@@ -178,14 +178,14 @@
 				}
 
 				pattern = argv[0];
-				
+
 				if (!strcasecmp(var, "exten")) {
 					char *p;
 					if (pattern && (p = strchr(pattern, '/'))) {
 						*p++ = '\0';
 						cid = pattern;
 						pattern = p;
-					}	
+					}
 				} else {
 					if (strchr(var, '$')) {
 						if ((field_expanded = switch_channel_expand_variables(channel, var)) == var) {
@@ -198,19 +198,19 @@
 						field_data = switch_caller_get_field_by_name(caller_profile, var);
 					}
 				}
-				
+
 				if (pattern && (*pattern == '_' || *pattern == '~')) {
 					if (*pattern == '_') {
 						pattern++;
 						if (switch_ast2regex(pattern, expression_buf, sizeof(expression_buf))) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "converting [%s] to real regex [%s] you should try them!\n", 
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "converting [%s] to real regex [%s] you should try them!\n",
 											  pattern, expression_buf);
 						}
 					} else {
 						pattern++;
 						expression = pattern;
 					}
-					
+
 					if (!field_data) {
 						field_data = "";
 					}
@@ -225,7 +225,7 @@
 						continue;
 					}
 				}
-				
+
 				if (cid) {
 					if (strcasecmp(cid, caller_profile->caller_id_number)) {
 						continue;
@@ -235,21 +235,21 @@
 				switch_channel_set_variable(channel, "EXTEN", caller_profile->destination_number);
 				switch_channel_set_variable(channel, "CHANNEL", switch_channel_get_name(channel));
 				switch_channel_set_variable(channel, "UNIQUEID", switch_core_session_get_uuid(session));
-				
+
 				pri = argv[1];
 				app = argv[2];
-				
+
 				if ((argument = strchr(app, '('))) {
 					char *p;
 					*argument++ = '\0';
 					p = strrchr(argument, ')');
 					if (p) {
-							*p = '\0';
+						*p = '\0';
 					}
 				} else if ((argument = strchr(app, ','))) {
 					*argument++ = '\0';
 				}
-				
+
 				if (!argument) {
 					argument = "";
 				}
@@ -274,10 +274,10 @@
 						break;
 					}
 				}
-				
+
 				switch_caller_extension_add_application(session, extension, app, argument);
 			}
-			
+
 			switch_safe_free(field_expanded);
 		}
 	}
@@ -291,18 +291,14 @@
 switch_endpoint_interface_t *sip_endpoint_interface;
 static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
 												switch_caller_profile_t *outbound_profile,
-												switch_core_session_t **new_session, 
-												switch_memory_pool_t **pool,
-												switch_originate_flag_t flags);
+												switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 switch_io_routines_t sip_io_routines = {
 	/*.outgoing_channel */ sip_outgoing_channel
 };
 
 static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
 												switch_caller_profile_t *outbound_profile,
-												switch_core_session_t **new_session, 
-												switch_memory_pool_t **pool,
-												switch_originate_flag_t flags)
+												switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 	const char *profile;
 
@@ -326,18 +322,14 @@
 switch_endpoint_interface_t *iax2_endpoint_interface;
 static switch_call_cause_t iax2_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
 												 switch_caller_profile_t *outbound_profile,
-												 switch_core_session_t **new_session, 
-												 switch_memory_pool_t **pool,
-												 switch_originate_flag_t flags);
+												 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
 switch_io_routines_t iax2_io_routines = {
 	/*.outgoing_channel */ iax2_outgoing_channel
 };
 
 static switch_call_cause_t iax2_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
 												 switch_caller_profile_t *outbound_profile,
-												 switch_core_session_t **new_session, 
-												 switch_memory_pool_t **pool,
-												 switch_originate_flag_t flags)
+												 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 	return switch_core_session_outgoing_channel(session, var_event, "iax", outbound_profile, new_session, pool, SOF_NONE);
 }
@@ -346,7 +338,7 @@
 #define WE_DONT_NEED_NO_STINKIN_KEY "true"
 static char *key()
 {
-    return WE_DONT_NEED_NO_STINKIN_KEY;
+	return WE_DONT_NEED_NO_STINKIN_KEY;
 }
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_asterisk_load)
@@ -359,7 +351,7 @@
 	if ((mykey = key())) {
 		mykey = NULL;
 	}
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	/* add a dialplan interface */
@@ -369,7 +361,7 @@
 	SWITCH_ADD_APP(app_interface, "Dial", "Dial", "Dial", dial_function, "Dial", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "Goto", "Goto", "Goto", goto_function, "Goto", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "AvoidingDeadlock", "Avoid", "Avoid", avoid_function, "Avoid", SAF_SUPPORT_NOMEDIA);
-	
+
 	/* fake chan_sip facade */
 	sip_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
 	sip_endpoint_interface->interface_name = "SIP";
@@ -379,7 +371,7 @@
 	iax2_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
 	iax2_endpoint_interface->interface_name = "IAX2";
 	iax2_endpoint_interface->io_routines = &iax2_io_routines;
-	
+
 	if (getenv("FAITHFUL_EMULATION")) {
 		for (x = 0; x < 10; x++) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Avoiding Deadlock.\n");

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	Tue May 27 07:24:06 2008
@@ -96,7 +96,7 @@
 	if (!caller_profile) {
 		caller_profile = switch_channel_get_caller_profile(channel);
 	}
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
 					  caller_profile->destination_number);
 
@@ -134,7 +134,7 @@
 			}
 		}
 	}
- out:
+  out:
 
 	switch_core_directory_close(&dh);
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Tue May 27 07:24:06 2008
@@ -185,15 +185,14 @@
 	return proceed;
 }
 
-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)
+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)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_status_t status = SWITCH_STATUS_GENERR;
 	switch_event_t *params = NULL;
 
 	switch_event_create(&params, SWITCH_EVENT_MESSAGE);
-    switch_assert(params);
+	switch_assert(params);
 
 	switch_channel_event_set_data(channel, params);
 
@@ -215,7 +214,7 @@
 			goto done;
 		}
 	}
-	
+
 	if (!caller_profile->context) {
 		caller_profile->context = "default";
 	}
@@ -265,7 +264,7 @@
 
 		proceed = parse_exten(session, caller_profile, xexten, &extension);
 
-		if (proceed && !switch_true(cont)) { 
+		if (proceed && !switch_true(cont)) {
 			break;
 		}
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_alsa/mod_alsa.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_alsa/mod_alsa.c	Tue May 27 07:24:06 2008
@@ -139,8 +139,8 @@
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_device_name, globals.device_name);
 
 #define is_master(t) switch_test_flag(t, TFLAG_MASTER)
-static void add_pvt(private_t * tech_pvt, int master);
-static void remove_pvt(private_t * tech_pvt);
+static void add_pvt(private_t *tech_pvt, int master);
+static void remove_pvt(private_t *tech_pvt);
 static switch_status_t channel_on_init(switch_core_session_t *session);
 static switch_status_t channel_on_hangup(switch_core_session_t *session);
 static switch_status_t channel_on_routing(switch_core_session_t *session);
@@ -356,7 +356,7 @@
 
 
 
-static void add_pvt(private_t * tech_pvt, int master)
+static void add_pvt(private_t *tech_pvt, int master)
 {
 	private_t *tp;
 	uint8_t in_list = 0;
@@ -399,7 +399,7 @@
 	switch_mutex_unlock(globals.pvt_lock);
 }
 
-static void remove_pvt(private_t * tech_pvt)
+static void remove_pvt(private_t *tech_pvt)
 {
 	private_t *tp, *last = NULL;
 
@@ -562,8 +562,7 @@
 										  tech_pvt->hold_file,
 										  globals.read_codec.implementation->number_of_channels,
 										  globals.read_codec.implementation->actual_samples_per_second,
-										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-										  NULL) != SWITCH_STATUS_SUCCESS) {
+										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
 					switch_core_codec_destroy(&tech_pvt->write_codec);
 					tech_pvt->hold_file = NULL;
 					goto cng;
@@ -578,12 +577,12 @@
 
 			goto hold;
 		}
-	cng:
+	  cng:
 		switch_yield(globals.read_codec.implementation->microseconds_per_frame);
 		*frame = &globals.cng_frame;
 		return SWITCH_STATUS_SUCCESS;
 
-	hold:
+	  hold:
 
 		{
 			switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
@@ -612,7 +611,7 @@
 	}
 
 	switch_mutex_lock(globals.device_lock);
-	if ((samples = snd_pcm_readi (globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) > 0) {
+	if ((samples = snd_pcm_readi(globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) > 0) {
 		globals.read_frame.datalen = samples * 2;
 		globals.read_frame.samples = samples;
 
@@ -887,7 +886,7 @@
 					globals.codec_ms = tmp;
 				} else {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-									  "codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
+									  "codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
 				}
 			} else if (!strcmp(var, "dialplan")) {
 				set_global_dialplan(val);
@@ -951,18 +950,18 @@
 	int err = 0;
 	snd_pcm_hw_params_t *hw_params = NULL;
 	char *device = globals.device_name;
-	
+
 	if (globals.audio_stream_in && globals.audio_stream_out) {
 		return SWITCH_STATUS_SUCCESS;
-	} 
+	}
 
 	if (globals.audio_stream_in) {
-		snd_pcm_close (globals.audio_stream_in);
+		snd_pcm_close(globals.audio_stream_in);
 		globals.audio_stream_in = NULL;
 	}
 
 	if (globals.audio_stream_out) {
-		snd_pcm_close (globals.audio_stream_out);
+		snd_pcm_close(globals.audio_stream_out);
 		globals.audio_stream_out = NULL;
 	}
 
@@ -976,33 +975,30 @@
 
 	if (switch_core_codec_init(&globals.read_codec,
 							   "L16",
-							   NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-							   NULL) != SWITCH_STATUS_SUCCESS) {
+							   NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
 		return SWITCH_STATUS_FALSE;
 	} else {
 		if (switch_core_codec_init(&globals.write_codec,
 								   "L16",
 								   NULL,
-								   sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-								   NULL) != SWITCH_STATUS_SUCCESS) {
+								   sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
 			switch_core_codec_destroy(&globals.read_codec);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
-	
+
 	if (switch_core_timer_init(&globals.timer,
-							   globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame,
-							   module_pool) != SWITCH_STATUS_SUCCESS) {
+							   globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame, module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
 		switch_core_codec_destroy(&globals.read_codec);
 		switch_core_codec_destroy(&globals.write_codec);
 		return SWITCH_STATUS_FALSE;
 	}
 
-	
-	
+
+
 	globals.read_frame.rate = sample_rate;
 	globals.read_frame.codec = &globals.read_codec;
 
@@ -1011,176 +1007,152 @@
 	switch_mutex_lock(globals.device_lock);
 	/* LOCKED ************************************************************************************************** */
 
-		
-	if ((err = snd_pcm_open (&globals.audio_stream_out, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot open audio device %s (%s)\n", 
-						  device,
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_open(&globals.audio_stream_out, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n", device, snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot allocate hardware parameter structure (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	 
-	if ((err = snd_pcm_hw_params_any (globals.audio_stream_out, hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot initialize hardware parameter structure (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_any(globals.audio_stream_out, hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_access (globals.audio_stream_out, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set access type (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_access(globals.audio_stream_out, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_format (globals.audio_stream_out, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set sample format (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_format(globals.audio_stream_out, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_rate_near (globals.audio_stream_out, hw_params, &sample_rate, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set sample rate (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_rate_near(globals.audio_stream_out, hw_params, &sample_rate, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_channels (globals.audio_stream_out, hw_params, 1)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set channel count (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_channels(globals.audio_stream_out, hw_params, 1)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params (globals.audio_stream_out, hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set parameters (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params(globals.audio_stream_out, hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	
-	snd_pcm_hw_params_free (hw_params);
+
+
+	snd_pcm_hw_params_free(hw_params);
 	hw_params = NULL;
 
 
-	if ((err = snd_pcm_open (&globals.audio_stream_in, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot open audio device %s (%s)\n", 
-						  device,
-						  snd_strerror (err));
+	if ((err = snd_pcm_open(&globals.audio_stream_in, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n", device, snd_strerror(err));
 		goto fail;
-	} 
+	}
 
-	if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot allocate hardware parameter structure (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	 
-	if ((err = snd_pcm_hw_params_any (globals.audio_stream_in, hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot initialize hardware parameter structure (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_any(globals.audio_stream_in, hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_access (globals.audio_stream_in, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set access type (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_access(globals.audio_stream_in, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_format (globals.audio_stream_in, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set sample format (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_format(globals.audio_stream_in, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_rate_near (globals.audio_stream_in, hw_params, &sample_rate, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set sample rate (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_rate_near(globals.audio_stream_in, hw_params, &sample_rate, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
-	if ((err = snd_pcm_hw_params_set_channels (globals.audio_stream_in, hw_params, 1)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set channel count (%s)\n",
-						  snd_strerror (err));
+
+	if ((err = snd_pcm_hw_params_set_channels(globals.audio_stream_in, hw_params, 1)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_hw_params_set_period_time (globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_frame, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set period time (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_hw_params_set_period_time(globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_frame, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period time (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_hw_params_set_period_size (globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_frame, 0)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set period size (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_hw_params_set_period_size(globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_frame, 0)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period size (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_hw_params (globals.audio_stream_in, hw_params)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot set parameters (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_hw_params(globals.audio_stream_in, hw_params)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-	
+
 	if (hw_params) {
-		snd_pcm_hw_params_free (hw_params);
+		snd_pcm_hw_params_free(hw_params);
 		hw_params = NULL;
 	}
 
-	if ((err = snd_pcm_prepare (globals.audio_stream_out)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot prepare audio interface for use (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_prepare(globals.audio_stream_out)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_start (globals.audio_stream_out)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot start audio interface for use (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_start(globals.audio_stream_out)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_prepare (globals.audio_stream_in)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot prepare audio interface for use (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_prepare(globals.audio_stream_in)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));
 		goto fail;
 	}
 
-	if ((err = snd_pcm_start (globals.audio_stream_in)) < 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,  "cannot start audio interface for use (%s)\n",
-						  snd_strerror (err));
+	if ((err = snd_pcm_start(globals.audio_stream_in)) < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n", snd_strerror(err));
 		goto fail;
 	}
-		
+
 	switch_mutex_unlock(globals.device_lock);
 	return SWITCH_STATUS_SUCCESS;
 
- fail:
+  fail:
 
 	if (hw_params) {
-		snd_pcm_hw_params_free (hw_params);
+		snd_pcm_hw_params_free(hw_params);
 		hw_params = NULL;
 	}
 
 	switch_mutex_unlock(globals.device_lock);
 
 	if (globals.audio_stream_in) {
-		snd_pcm_close (globals.audio_stream_in);
+		snd_pcm_close(globals.audio_stream_in);
 	}
 
 	if (globals.audio_stream_out) {
-		snd_pcm_close (globals.audio_stream_out);
+		snd_pcm_close(globals.audio_stream_out);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
 	switch_core_codec_destroy(&globals.read_codec);
 	switch_core_codec_destroy(&globals.write_codec);
-	
-	return SWITCH_STATUS_FALSE;	
+
+	return SWITCH_STATUS_FALSE;
 
 
 
@@ -1189,8 +1161,8 @@
 static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
 	char *dtmf_str = argv[0];
-	switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
-	
+	switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
+
 	if (switch_strlen_zero(dtmf_str)) {
 		stream->write_function(stream, "No DTMF Supplied!\n");
 	} else {
@@ -1198,7 +1170,7 @@
 		if (globals.call_list) {
 			switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
 			char *p = dtmf_str;
-			while(p && *p) {
+			while (p && *p) {
 				dtmf.digit = *p;
 				switch_channel_queue_dtmf(channel, &dtmf);
 				p++;
@@ -1250,7 +1222,7 @@
 		stream->write_function(stream, "NO SUCH CALL\n");
 	}
 
- done:
+  done:
 	switch_mutex_unlock(globals.pvt_lock);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1317,7 +1289,7 @@
 			break;
 		}
 	}
- done:
+  done:
 	switch_mutex_unlock(globals.pvt_lock);
 
 	stream->write_function(stream, "Answered %d channels.\n", x);
@@ -1371,7 +1343,7 @@
 		goto bad;
 	}
 
- desc:
+  desc:
 	x = 0;
 	stream->write_function(stream, "FLAGS: ");
 	if (switch_test_flag((&globals), GFLAG_EAR)) {
@@ -1388,9 +1360,9 @@
 
 	goto done;
 
- bad:
+  bad:
 	stream->write_function(stream, "Usage: flags [on|off] <flags>\n");
- done:
+  done:
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1487,12 +1459,9 @@
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																  NULL,
-																  dialplan, cid_name, cid_num,
-																  ip, NULL, NULL, NULL, (char *) modname, NULL,
-																  dest)) != 0) {
+																  dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, (char *) modname, NULL, dest)) != 0) {
 			char name[128];
-			snprintf(name, sizeof(name), "Alsa/%s",
-					 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
+			snprintf(name, sizeof(name), "Alsa/%s", tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
 			switch_channel_set_name(channel, name);
 
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
@@ -1504,7 +1473,7 @@
 			switch_channel_set_state(channel, CS_INIT);
 
 			if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
 				switch_core_session_destroy(&session);
 				stream->write_function(stream, "FAIL:Thread Error!\n");
 			} else {
@@ -1536,7 +1505,7 @@
 		http = switch_event_get_header(stream->param_event, "http-host");
 	}
 
-	
+
 	const char *usage_string = "USAGE:\n"
 		"--------------------------------------------------------------------------------\n"
 		"alsa help\n"
@@ -1546,8 +1515,7 @@
 		"alsa list\n"
 		"alsa switch [<call_id>|none]\n"
 		"alsa dtmf <digit string>\n"
-		"alsa flags [on|off] [ear] [mouth]\n"
-		"--------------------------------------------------------------------------------\n";
+		"alsa flags [on|off] [ear] [mouth]\n" "--------------------------------------------------------------------------------\n";
 
 	if (http) {
 #if 0
@@ -1638,14 +1606,13 @@
 		stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
 	}
 
- done:
+  done:
 
 	if (http) {
 
 		stream->write_function(stream,
 							   "<br><br><table align=center><tr><td><center><form method=post>\n"
 							   "<input type=text name=wcmd size=40><br><br>\n"
-
 							   "<input name=action type=submit value=\"call\"> "
 							   "<input name=action type=submit value=\"hangup\"> "
 							   "<input name=action type=submit value=\"list\"> "
@@ -1658,25 +1625,18 @@
 							   "<td><input name=action type=submit value=\"2\"></td>"
 							   "<td><input name=action type=submit value=\"3\"></td>\n"
 							   "<td><input name=action type=submit value=\"A\"></td></tr>\n"
-
 							   "<tr><td><input name=action type=submit value=\"4\"></td>"
 							   "<td><input name=action type=submit value=\"5\"></td>"
 							   "<td><input name=action type=submit value=\"6\"></td>\n"
 							   "<td><input name=action type=submit value=\"B\"></td></tr>\n"
-
 							   "<tr><td><input name=action type=submit value=\"7\"></td>"
 							   "<td><input name=action type=submit value=\"8\"></td>"
 							   "<td><input name=action type=submit value=\"9\"></td>\n"
 							   "<td><input name=action type=submit value=\"C\"></td></tr>\n"
-
 							   "<tr><td><input name=action type=submit value=\"*\"></td>"
 							   "<td><input name=action type=submit value=\"0\"></td>"
 							   "<td><input name=action type=submit value=\"#\"></td>\n"
-							   "<td><input name=action type=submit value=\"D\"></td></tr>\n"
-							   "</table>"
-							   
-							   "</form><br></center></td></tr></table>\n"
-							   );
+							   "<td><input name=action type=submit value=\"D\"></td></tr>\n" "</table>" "</form><br></center></td></tr></table>\n");
 	}
 
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Tue May 27 07:24:06 2008
@@ -53,11 +53,7 @@
 
 static char sub_sql[] =
 	"CREATE TABLE jabber_subscriptions (\n"
-	"   sub_from      VARCHAR(255),\n" 
-	"   sub_to        VARCHAR(255),\n" 
-	"   show_pres     VARCHAR(255),\n" 
-	"   status        VARCHAR(255)\n"
-	");\n";
+	"   sub_from      VARCHAR(255),\n" "   sub_to        VARCHAR(255),\n" "   show_pres     VARCHAR(255),\n" "   status        VARCHAR(255)\n" ");\n";
 
 
 typedef enum {
@@ -215,9 +211,9 @@
 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
 
-static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
+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);
-static ldl_status handle_response(ldl_handle_t * handle, char *id);
+static ldl_status handle_response(ldl_handle_t *handle, char *id);
 static switch_status_t load_config(void);
 static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
 
@@ -270,9 +266,8 @@
 	if (mutex) {
 		switch_mutex_lock(mutex);
 	}
-
 #ifdef SWITCH_HAVE_ODBC
-    if (profile->odbc_dsn) {
+	if (profile->odbc_dsn) {
 		SQLHSTMT stmt;
 		if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
 			char *err_str;
@@ -292,11 +287,11 @@
 		switch_core_db_close(db);
 
 #ifdef SWITCH_HAVE_ODBC
-    }
+	}
 #endif
 
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -304,22 +299,18 @@
 
 
 static switch_bool_t mdl_execute_sql_callback(mdl_profile_t *profile,
-											  switch_mutex_t *mutex,
-											  char *sql,
-											  switch_core_db_callback_func_t callback,
-											  void *pdata)
+											  switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)
 {
 	switch_bool_t ret = SWITCH_FALSE;
 	switch_core_db_t *db;
 	char *errmsg = NULL;
-	
-	if (mutex) {
-        switch_mutex_lock(mutex);
-    }
 
+	if (mutex) {
+		switch_mutex_lock(mutex);
+	}
 
 #ifdef SWITCH_HAVE_ODBC
-    if (profile->odbc_dsn) {
+	if (profile->odbc_dsn) {
 		switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
 	} else {
 #endif
@@ -331,7 +322,7 @@
 			goto end;
 		}
 
-	
+
 		switch_core_db_exec(db, sql, callback, pdata, &errmsg);
 
 		if (errmsg) {
@@ -342,18 +333,17 @@
 		if (db) {
 			switch_core_db_close(db);
 		}
-
 #ifdef SWITCH_HAVE_ODBC
-    }
+	}
 #endif
 
 
- end:
+  end:
 
 	if (mutex) {
-        switch_mutex_unlock(mutex);
-    }
-	
+		switch_mutex_unlock(mutex);
+	}
+
 
 
 	return ret;
@@ -418,11 +408,11 @@
 	char *rpid = switch_event_get_header(event, "rpid");
 	char *type = switch_event_get_header(event, "event_subtype");
 	char *sql;
-    
-    if (globals.running != 1) {
-        return;
-    }
-    
+
+	if (globals.running != 1) {
+		return;
+	}
+
 	if (!proto) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Missing 'proto' header\n");
 		return;
@@ -481,7 +471,8 @@
 	}
 
 
-	sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
+	sql =
+		switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
 
 
 	for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
@@ -495,7 +486,7 @@
 
 		if (sql) {
 			switch_bool_t worked = mdl_execute_sql_callback(profile, profile->mutex, sql, sub_callback, profile);
-			
+
 			if (!worked) {
 				continue;
 			}
@@ -564,9 +555,9 @@
 	void *val;
 	char *sql;
 
-    if (globals.running != 1) {
-        return;
-    }
+	if (globals.running != 1) {
+		return;
+	}
 
 	if (status && !strcasecmp(status, "n/a")) {
 		status = NULL;
@@ -697,7 +688,7 @@
 
 		tech_pvt = switch_core_session_get_private(*session);
 
-		
+
 		if (tech_pvt && tech_pvt->profile && tech_pvt->profile->ip && tech_pvt->local_port) {
 			switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port);
 		}
@@ -748,8 +739,7 @@
 						xml = switch_xml_parse_str(xmltxt, strlen(xmltxt));
 						form = switch_xml_toxml(xml, SWITCH_FALSE);
 						switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level,
-										  "%s:\n-------------------------------------------------------------------------------\n"
-										  "%s\n", ll, form);
+										  "%s:\n-------------------------------------------------------------------------------\n" "%s\n", ll, form);
 						switch_xml_free(xml);
 						free(data);
 					}
@@ -774,8 +764,7 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 				return 0;
 			}
-		} else if (((tech_pvt->num_codecs =
-					 switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
+		} else if (((tech_pvt->num_codecs = switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 			return 0;
 		}
@@ -786,7 +775,7 @@
 
 
 
-static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t *thread, void *obj)
 {
 	ldl_handle_t *handle = obj;
 	mdl_profile_t *profile = NULL;
@@ -805,7 +794,7 @@
 	return NULL;
 }
 
-static void handle_thread_launch(ldl_handle_t * handle)
+static void handle_thread_launch(ldl_handle_t *handle)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
@@ -873,7 +862,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
 					  tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
-	
+
 	flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
 
 	if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
@@ -1089,8 +1078,7 @@
 	while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) &&
 			 switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
 			 switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) &&
-			 tech_pvt->remote_ip && tech_pvt->remote_port
-			 && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
+			 tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
 		now = switch_timestamp_now();
 		elapsed = (unsigned int) ((now - started) / 1000);
 
@@ -1140,9 +1128,9 @@
 
 	goto done;
 
- out:
+  out:
 	terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- done:
+  done:
 
 	return ret;
 }
@@ -1222,7 +1210,7 @@
 	/* Dunno why, but if googletalk calls us for the first time, as soon as the call ends
 	   they think we are offline for no reason so we send this presence packet to stop it from happening
 	   We should find out why.....
-	*/
+	 */
 	if ((tech_pvt->profile->user_flags & LDL_FLAG_COMPONENT) && is_special(tech_pvt->them)) {
 		ldl_handle_send_presence(tech_pvt->profile->handle, tech_pvt->them, tech_pvt->us, NULL, NULL, "Click To Call", tech_pvt->profile->avatar);
 	}
@@ -1497,21 +1485,21 @@
 		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
 		/*
-		if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
-			switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
-			//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
-		}
-		*/
+		   if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+		   switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+		   switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
+		   //switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
+		   }
+		 */
 		break;
 	case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
 		/*
-		if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
-			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
-			//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
-		}
-		*/
+		   if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+		   switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+		   switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
+		   //switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
+		   }
+		 */
 		break;
 	default:
 		break;
@@ -1618,7 +1606,7 @@
 			} else {
 				if (!user) {
 					const char *id_num;
-					
+
 					if (!(id_num = outbound_profile->caller_id_number)) {
 						if (!(id_num = outbound_profile->caller_id_name)) {
 							id_num = "nobody";
@@ -1810,7 +1798,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static ldl_status handle_loop(ldl_handle_t * handle)
+static ldl_status handle_loop(ldl_handle_t *handle)
 {
 	if (!globals.running) {
 		return LDL_STATUS_FALSE;
@@ -1829,7 +1817,7 @@
 
 	if (!(profile->login && profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-						  "Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n" 
+						  "Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n"
 						  "message[%s]\n" "rtp-ip[%s]\n" "name[%s]\n" "exten[%s]\n",
 						  profile->login, profile->password, profile->dialplan, profile->message, profile->ip, profile->name, profile->exten);
 
@@ -1886,7 +1874,8 @@
 
 static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
 {
-	if (!var) return;
+	if (!var)
+		return;
 
 	if (!strcasecmp(var, "login")) {
 		profile->login = switch_core_strdup(module_pool, val);
@@ -1903,8 +1892,7 @@
 				*profile->odbc_pass++ = '\0';
 			}
 		}
-		
-		
+
 #else
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
 #endif
@@ -1912,7 +1900,7 @@
 		switch_set_flag(profile, TFLAG_TIMER);
 	} else if (!strcasecmp(var, "dialplan") && !switch_strlen_zero(val)) {
 		profile->dialplan = switch_core_strdup(module_pool, val);
-#ifdef AUTO_REPLY // gotta fix looping on this
+#ifdef AUTO_REPLY				// gotta fix looping on this
 	} else if (!strcasecmp(var, "auto-reply")) {
 		profile->auto_reply = switch_core_strdup(module_pool, val);
 #endif
@@ -2182,7 +2170,7 @@
 				if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
 					continue;
-					
+
 				}
 				if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
@@ -2292,7 +2280,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 	}
 
- end:
+  end:
 
 	switch_event_destroy(&params);
 
@@ -2307,8 +2295,7 @@
 	switch_safe_free(xmlstr);
 }
 
-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)
+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)
 {
 	mdl_profile_t *profile = NULL;
 	switch_core_session_t *session = NULL;
@@ -2350,11 +2337,8 @@
 						mdl_execute_sql(profile, sql, NULL);
 						switch_core_db_free(sql);
 					}
-					if ((sql = switch_mprintf("insert into jabber_subscriptions values('%q','%q','%q','%q');\n", 
-											  switch_str_nil(from),
-											  switch_str_nil(to),
-											  switch_str_nil(msg),
-											  switch_str_nil(subject)))) {
+					if ((sql = switch_mprintf("insert into jabber_subscriptions values('%q','%q','%q','%q');\n",
+											  switch_str_nil(from), switch_str_nil(to), switch_str_nil(msg), switch_str_nil(subject)))) {
 						mdl_execute_sql(profile, sql, NULL);
 						switch_core_db_free(sql);
 					}
@@ -2362,7 +2346,8 @@
 					if (is_special(to)) {
 						ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call", profile->avatar);
 					} else {
-						ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Authenticated.\nCome to ClueCon!\nhttp://www.cluecon.com", profile->avatar);
+						ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Authenticated.\nCome to ClueCon!\nhttp://www.cluecon.com",
+												 profile->avatar);
 					}
 #if 0
 					if (is_special(to)) {
@@ -2400,7 +2385,7 @@
 				break;
 			case LDL_SIGNAL_PRESENCE_IN:
 
-				if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'", 
+				if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
 										  switch_str_nil(msg), switch_str_nil(subject), switch_str_nil(from)))) {
 					mdl_execute_sql(profile, sql, profile->mutex);
 					switch_core_db_free(sql);
@@ -2435,7 +2420,7 @@
 
 			case LDL_SIGNAL_PRESENCE_OUT:
 
-				if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'", 
+				if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
 										  switch_str_nil(msg), switch_str_nil(subject), switch_str_nil(from)))) {
 					mdl_execute_sql(profile, sql, profile->mutex);
 					switch_core_db_free(sql);
@@ -2454,45 +2439,45 @@
 
 		switch (dl_signal) {
 		case LDL_SIGNAL_MSG:{
-			switch_chat_interface_t *ci;
-			char *proto = MDL_CHAT_PROTO;
-			char *pproto = NULL, *ffrom = NULL;
-			char *hint;
+				switch_chat_interface_t *ci;
+				char *proto = MDL_CHAT_PROTO;
+				char *pproto = NULL, *ffrom = NULL;
+				char *hint;
 #ifdef AUTO_REPLY
-			if (profile->auto_reply) {
-				ldl_handle_send_msg(handle,
-									(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "",
-									profile->auto_reply);
-			}
+				if (profile->auto_reply) {
+					ldl_handle_send_msg(handle,
+										(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "",
+										profile->auto_reply);
+				}
 #endif
 
-			if (strchr(to, '+')) {
-				pproto = strdup(to);
-				if ((to = strchr(pproto, '+'))) {
-					*to++ = '\0';
+				if (strchr(to, '+')) {
+					pproto = strdup(to);
+					if ((to = strchr(pproto, '+'))) {
+						*to++ = '\0';
+					}
+					proto = pproto;
 				}
-				proto = pproto;
-			}
 
-			hint = from;
+				hint = from;
 
-			if (strchr(from, '/') && (ffrom = strdup(from))) {
-				char *p;
-				if ((p = strchr(ffrom, '/'))) {
-					*p = '\0';
+				if (strchr(from, '/') && (ffrom = strdup(from))) {
+					char *p;
+					if ((p = strchr(ffrom, '/'))) {
+						*p = '\0';
+					}
+					from = ffrom;
 				}
-				from = ffrom;
-			}
 
-			if ((ci = switch_loadable_module_get_chat_interface(proto))) {
-				ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
-			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
-			}
+				if ((ci = switch_loadable_module_get_chat_interface(proto))) {
+					ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
+				}
 
-			switch_safe_free(pproto);
-			switch_safe_free(ffrom);
-		}
+				switch_safe_free(pproto);
+				switch_safe_free(ffrom);
+			}
 			break;
 		case LDL_SIGNAL_LOGIN_SUCCESS:
 			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) == SWITCH_STATUS_SUCCESS) {
@@ -2547,7 +2532,7 @@
 		}
 		if ((session = switch_core_session_request(dingaling_endpoint_interface, NULL)) != 0) {
 			switch_core_session_add_stream(session, NULL);
-			
+
 			if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
 				char *exten;
 				char *context;
@@ -2641,10 +2626,7 @@
 																			  ldl_session_get_ip(dlsession),
 																			  ldl_session_get_value(dlsession, "ani"),
 																			  ldl_session_get_value(dlsession, "aniii"),
-																			  ldl_session_get_value(dlsession, "rdnis"),
-																			  modname,
-																			  context,
-																			  exten)) != 0) {
+																			  ldl_session_get_value(dlsession, "rdnis"), modname, context, exten)) != 0) {
 						char name[128];
 						switch_snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
 						switch_channel_set_name(channel, name);
@@ -2669,8 +2651,8 @@
 			if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
 				terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                status = LDL_STATUS_FALSE;
-                goto done;
+				status = LDL_STATUS_FALSE;
+				goto done;
 			}
 		} else {
 			status = LDL_STATUS_FALSE;
@@ -2832,7 +2814,7 @@
 			}
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
-			
+
 			if (profile->acl_count) {
 				for (x = 0; x < len; x++) {
 					uint32_t y = 0;
@@ -2843,18 +2825,18 @@
 						}
 
 						if (ok) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n", 
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n",
 											  candidates[x].address, candidates[x].port, profile->acl[y]);
 							break;
 						} else {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n", 
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n",
 											  candidates[x].address, candidates[x].port, profile->acl[y]);
 						}
 					}
 				}
 			} else {
 				for (x = 0; x < len; x++) {
-					
+
 					if (profile->lanaddr) {
 						lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
 					}
@@ -2879,9 +2861,8 @@
 									   strncasecmp(candidates[x].address, "172.2", 5) &&
 									   strncasecmp(candidates[x].address, "172.30.", 7) &&
 									   strncasecmp(candidates[x].address, "172.31.", 7) &&
-									   strncasecmp(candidates[x].address, "192.0.2.", 8) &&
-									   strncasecmp(candidates[x].address, "169.254.", 8)
-									   ))) {
+									   strncasecmp(candidates[x].address, "192.0.2.", 8) && strncasecmp(candidates[x].address, "169.254.", 8)
+						 ))) {
 						choice = x;
 						ok = 1;
 					}
@@ -2893,7 +2874,7 @@
 
 				memset(payloads, 0, sizeof(payloads));
 
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 								  "Acceptable Candidate %s:%d\n", candidates[choice].address, candidates[choice].port);
 
 				if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
@@ -2934,7 +2915,7 @@
 				status = LDL_STATUS_SUCCESS;
 			}
 
-			goto done;				
+			goto done;
 
 		}
 		break;
@@ -2961,14 +2942,14 @@
 		break;
 	}
 
-	
- done:
+
+  done:
 
 
 	return status;
 }
 
-static ldl_status handle_response(ldl_handle_t * handle, char *id)
+static ldl_status handle_response(ldl_handle_t *handle, char *id)
 {
 	return LDL_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax-mutex.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax-mutex.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax-mutex.c	Tue May 27 07:24:06 2008
@@ -47,7 +47,7 @@
 #endif
 	mutex_t *check = NULL;
 
-	check = (mutex_t *)malloc(sizeof(**mutex));
+	check = (mutex_t *) malloc(sizeof(**mutex));
 	if (!check)
 		goto done;
 #ifdef WIN32
@@ -64,16 +64,16 @@
 
 	goto success;
 
-fail:
-        pthread_mutexattr_destroy(&attr);
-		goto done;
+  fail:
+	pthread_mutexattr_destroy(&attr);
+	goto done;
 
-success:
+  success:
 #endif
 	*mutex = check;
 	status = MUTEX_SUCCESS;
 
-done:
+  done:
 	return status;
 }
 

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax.c	Tue May 27 07:24:06 2008
@@ -1,16 +1,16 @@
  /*
- * libiax: An implementation of Inter-Asterisk eXchange
- *
- * Copyright (C) 2001, Linux Support Services, Inc.
- *
- * Mark Spencer <markster at linux-support.net>
- *
- * This program is free software, distributed under the terms of
- * the GNU Lesser (Library) General Public License
- */
- 
+  * libiax: An implementation of Inter-Asterisk eXchange
+  *
+  * Copyright (C) 2001, Linux Support Services, Inc.
+  *
+  * Mark Spencer <markster at linux-support.net>
+  *
+  * This program is free software, distributed under the terms of
+  * the GNU Lesser (Library) General Public License
+  */
+
 #ifdef	WIN32
-#undef __STRICT_ANSI__ //for strdup with ms
+#undef __STRICT_ANSI__			//for strdup with ms
 
 #include <string.h>
 #include <process.h>
@@ -35,7 +35,7 @@
 #define strdup _strdup
 #endif
 
-void gettimeofday(struct timeval *tv, void /*struct timezone*/ *tz);
+void gettimeofday(struct timeval *tv, void /*struct timezone */ *tz);
 #include "winpoop.h"
 
 #else
@@ -56,7 +56,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <time.h>
-       
+
 #endif
 
 #include "iax2.h"
@@ -79,13 +79,13 @@
 /* Define socket options for IAX2 sockets, based on platform
  * availability of flags */
 #ifdef WIN32
- #define IAX_SOCKOPTS 0
+#define IAX_SOCKOPTS 0
 #else
- #ifdef LINUX
- #define IAX_SOCKOPTS MSG_DONTWAIT | MSG_NOSIGNAL
- #else
- #define IAX_SOCKOPTS MSG_DONTWAIT
- #endif
+#ifdef LINUX
+#define IAX_SOCKOPTS MSG_DONTWAIT | MSG_NOSIGNAL
+#else
+#define IAX_SOCKOPTS MSG_DONTWAIT
+#endif
 #endif
 
 
@@ -141,12 +141,12 @@
 static int maxretries = 10;
 
 /* configurable jitterbuffer options */
-static long jb_target_extra = -1; 
+static long jb_target_extra = -1;
 
 static int do_shutdown = 0;
 
 /* external global networking replacements */
-static sendto_t	  iax_sendto = (sendto_t) sendto;
+static sendto_t iax_sendto = (sendto_t) sendto;
 static recvfrom_t iax_recvfrom = (recvfrom_t) recvfrom;
 
 /* ping interval (seconds) */
@@ -162,7 +162,7 @@
 	int quelch;
 	/* Codec Pref Order */
 	char codec_order[32];
-	/* Codec Pref Order Index*/
+	/* Codec Pref Order Index */
 	int codec_order_len;
 	/* Last received voice format */
 	int voiceformat;
@@ -238,14 +238,14 @@
 
 	/* ping scheduler id */
 	int pingid;
-	
+
 	/* Transfer stuff */
 	struct sockaddr_in transfer;
 	int transferring;
 	int transfercallno;
 	int transferid;
-	int transferpeer;	/* for attended transfer */
-	int transfer_moh;	/* for music on hold while performing attended transfer */
+	int transferpeer;			/* for attended transfer */
+	int transfer_moh;			/* for music on hold while performing attended transfer */
 
 #ifdef NEWJB
 	jitterbuf *jb;
@@ -261,7 +261,7 @@
 
 static void destroy_session(struct iax_session *session);
 
-#define IAXERROR snprintf(iax_errstr, sizeof(iax_errstr), 
+#define IAXERROR snprintf(iax_errstr, sizeof(iax_errstr),
 
 #ifdef DEBUG_SUPPORT
 
@@ -281,15 +281,15 @@
 	debug = 0;
 }
 
-/* This is a little strange, but to debug you call DEBU(G "Hello World!\n"); */ 
+/* This is a little strange, but to debug you call DEBU(G "Hello World!\n"); */
 #ifdef WIN32
-#define G __FILE__, __LINE__, __FUNCTION__, 
+#define G __FILE__, __LINE__, __FUNCTION__,
 #else
-#define G __FILE__, __LINE__, (const char *)__func__, 
+#define G __FILE__, __LINE__, (const char *)__func__,
 #endif
 
-#define DEBU __debug 
-static int __debug(char *file, int lineno, const char *func, char *fmt, ...) 
+#define DEBU __debug
+static int __debug(char *file, int lineno, const char *func, char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
@@ -311,7 +311,7 @@
 #define G
 #endif
 
-typedef void (*sched_func)(void *);
+typedef void (*sched_func) (void *);
 
 struct iax_sched {
 	/* These are scheduled things to be delivered */
@@ -396,16 +396,16 @@
 	/* Schedule event to be delivered to the client
 	   in ms milliseconds from now, or a reliable frame to be retransmitted */
 	struct iax_sched *sched, *cur, *prev = NULL;
-	
+
 	if (!event && !frame && !func) {
 		DEBU(G "No event, no frame, no func?  what are we scheduling?\n");
 		return -1;
 	}
-	
 
-	sched = (struct iax_sched*)malloc(sizeof(struct iax_sched));
+
+	sched = (struct iax_sched *) malloc(sizeof(struct iax_sched));
 	if (sched) {
-        memset(sched, 0, sizeof(struct iax_sched));
+		memset(sched, 0, sizeof(struct iax_sched));
 		sched->when = current_time_in_ms() + ms;
 		sched->event = event;
 		sched->frame = frame;
@@ -414,7 +414,7 @@
 		/* Put it in the list, in order */
 		iax_mutex_lock(sched_mutex);
 		cur = schedq;
-		while(cur && cur->when <= sched->when) {
+		while (cur && cur->when <= sched->when) {
 			prev = cur;
 			cur = cur->next;
 		}
@@ -446,7 +446,7 @@
 			else
 				schedq = cur->next;
 			tmp = cur;
-			cur = cur->next;	
+			cur = cur->next;
 			free(tmp);
 			if (!all) {
 				ret = -1;
@@ -457,7 +457,7 @@
 			cur = cur->next;
 		}
 	}
- done:
+  done:
 	iax_mutex_unlock(sched_mutex);
 
 	return 0;
@@ -469,7 +469,7 @@
 {
 	struct iax_sched *cur = NULL;
 	time_in_ms_t minimum = 999999999;
-	
+
 	iax_mutex_lock(sched_mutex);
 	cur = schedq;
 
@@ -478,7 +478,7 @@
 		iax_mutex_unlock(sched_mutex);
 		return -1;
 	}
-	while(cur) {
+	while (cur) {
 		if (cur->when < minimum) {
 			minimum = cur->when;
 		}
@@ -498,7 +498,7 @@
 struct iax_session *iax_session_new(void)
 {
 	struct iax_session *s;
-	s = (struct iax_session *)malloc(sizeof(struct iax_session));
+	s = (struct iax_session *) malloc(sizeof(struct iax_session));
 	if (s) {
 		memset(s, 0, sizeof(struct iax_session));
 		/* Initialize important fields */
@@ -507,12 +507,12 @@
 		/* Default pingtime to 30 ms */
 		s->pingtime = 30;
 		/* XXX Not quite right -- make sure it's not in use, but that won't matter
-	           unless you've had at least 65k calls.  XXX */
+		   unless you've had at least 65k calls.  XXX */
 		s->callno = callnums++;
 		if (callnums > 32767)
 			callnums = 1;
 		s->peercallno = 0;
-		s->transferpeer = 0;		/* for attended transfer */
+		s->transferpeer = 0;	/* for attended transfer */
 
 		s->sendto = iax_sendto;
 		s->pingid = -1;
@@ -542,7 +542,7 @@
 
 	iax_mutex_lock(session_mutex);
 	cur = sessions;
-	while(cur) {
+	while (cur) {
 		if (session == cur) {
 			iax_mutex_unlock(session_mutex);
 			return -1;
@@ -554,31 +554,34 @@
 	return 0;
 }
 
-int iax_get_netstats(struct iax_session *session, time_in_ms_t *rtt, struct iax_netstat *local, struct iax_netstat *remote) {
+int iax_get_netstats(struct iax_session *session, time_in_ms_t *rtt, struct iax_netstat *local, struct iax_netstat *remote)
+{
 
-  if(!iax_session_valid(session)) return -1;
+	if (!iax_session_valid(session))
+		return -1;
 
-  *rtt = session->pingtime;
+	*rtt = session->pingtime;
 
-  *remote = session->remote_netstats;
+	*remote = session->remote_netstats;
 
 #ifdef NEWJB
-  {
-      jb_info stats;
-      jb_getinfo(session->jb, &stats);
-
-      local->jitter = stats.jitter;
-      /* XXX: should be short-term loss pct.. */
-      if(stats.frames_in == 0) stats.frames_in = 1;
-      local->losspct = stats.losspct/1000;
-      local->losscnt = stats.frames_lost;
-      local->packets = stats.frames_in;
-      local->delay = stats.current - stats.min;
-      local->dropped = stats.frames_dropped;
-      local->ooo = stats.frames_ooo;
-  }
+	{
+		jb_info stats;
+		jb_getinfo(session->jb, &stats);
+
+		local->jitter = stats.jitter;
+		/* XXX: should be short-term loss pct.. */
+		if (stats.frames_in == 0)
+			stats.frames_in = 1;
+		local->losspct = stats.losspct / 1000;
+		local->losscnt = stats.frames_lost;
+		local->packets = stats.frames_in;
+		local->delay = stats.current - stats.min;
+		local->dropped = stats.frames_dropped;
+		local->ooo = stats.frames_ooo;
+	}
 #endif
-  return 0;
+	return 0;
 }
 
 static time_in_ms_t calc_timestamp(struct iax_session *session, time_in_ms_t ts, struct ast_frame *f)
@@ -587,13 +590,13 @@
 	time_in_ms_t time_in_ms;
 	int voice = 0;
 	int genuine = 0;
-	
+
 	if (f && f->frametype == AST_FRAME_VOICE) {
 		voice = 1;
 	} else if (!f || f->frametype == AST_FRAME_IAX) {
 		genuine = 1;
 	}
-	
+
 	/* If this is the first packet we're sending, get our
 	   offset now. */
 	if (!session->offset) {
@@ -616,34 +619,34 @@
 		ms = 0;
 	}
 
-	if(voice) {
+	if (voice) {
 #ifdef USE_VOICE_TS_PREDICTION
 
 		/* If we haven't most recently sent silence, and we're
 		 * close in time, use predicted time */
-		if(session->notsilenttx && iax_abs(ms - session->nextpred) <= 240) {
-		    /* Adjust our txcore, keeping voice and non-voice
-		     * synchronized */
-			session->offset += (int)(ms - session->nextpred)/10;
-		    
-		    if(!session->nextpred) {
-				session->nextpred = ms; 
+		if (session->notsilenttx && iax_abs(ms - session->nextpred) <= 240) {
+			/* Adjust our txcore, keeping voice and non-voice
+			 * synchronized */
+			session->offset += (int) (ms - session->nextpred) / 10;
+
+			if (!session->nextpred) {
+				session->nextpred = ms;
 			}
-		    ms = session->nextpred; 
+			ms = session->nextpred;
 		} else {
-		    /* in this case, just use the actual time, since
-		     * we're either way off (shouldn't happen), or we're
-		     * ending a silent period -- and seed the next predicted
-		     * time.  Also, round ms to the next multiple of
-		     * frame size (so our silent periods are multiples
-		     * of frame size too) */
-		    time_in_ms_t diff = ms % (f->samples / 8);
-		    if(diff)
-			ms += f->samples/8 - diff;
-		    session->nextpred = ms; 
+			/* in this case, just use the actual time, since
+			 * we're either way off (shouldn't happen), or we're
+			 * ending a silent period -- and seed the next predicted
+			 * time.  Also, round ms to the next multiple of
+			 * frame size (so our silent periods are multiples
+			 * of frame size too) */
+			time_in_ms_t diff = ms % (f->samples / 8);
+			if (diff)
+				ms += f->samples / 8 - diff;
+			session->nextpred = ms;
 		}
 #else
-		if(ms <= session->lastsent)
+		if (ms <= session->lastsent)
 			ms = session->lastsent + 3;
 #endif
 		session->notsilenttx = 1;
@@ -656,7 +659,7 @@
 		} else if (iax_abs(ms - session->lastsent) <= 240) {
 			ms = session->lastsent + 3;
 		}
-	      
+
 	}
 
 	/* Record the last sent packet for future reference */
@@ -666,8 +669,8 @@
 
 #ifdef USE_VOICE_TS_PREDICTION
 	/* set next predicted ts based on 8khz samples */
-	if(voice)
-	    session->nextpred = session->nextpred + f->samples / 8;
+	if (voice)
+		session->nextpred = session->nextpred + f->samples / 8;
 #endif
 
 	return ms;
@@ -676,44 +679,42 @@
 #ifdef NEWJB
 static unsigned char get_n_bits_at(unsigned char *data, int n, int bit)
 {
-	int byte = bit / 8;       /* byte containing first bit */
-	int rem = 8 - (bit % 8);  /* remaining bits in first byte */
+	int byte = bit / 8;			/* byte containing first bit */
+	int rem = 8 - (bit % 8);	/* remaining bits in first byte */
 	unsigned char ret = 0;
-	
+
 	if (n <= 0 || n > 8)
 		return 0;
 
 	if (rem < n) {
-		ret = (unsigned char)(data[byte] << (n - rem));
+		ret = (unsigned char) (data[byte] << (n - rem));
 		ret |= (data[byte + 1] >> (8 - n + rem));
 	} else {
-		ret = (unsigned char)(data[byte] >> (rem - n));
+		ret = (unsigned char) (data[byte] >> (rem - n));
 	}
 
-	return (unsigned char)(ret & (0xff >> (8 - n)));
+	return (unsigned char) (ret & (0xff >> (8 - n)));
 }
 
 static int speex_get_wb_sz_at(unsigned char *data, int len, int bit)
 {
 	static int SpeexWBSubModeSz[] = {
 		0, 36, 112, 192,
-		352, 0, 0, 0 };
+		352, 0, 0, 0
+	};
 	int off = bit;
 	unsigned char c;
 
 	/* skip up to two wideband frames */
-	if (((len * 8 - off) >= 5) && 
-		get_n_bits_at(data, 1, off)) {
+	if (((len * 8 - off) >= 5) && get_n_bits_at(data, 1, off)) {
 		c = get_n_bits_at(data, 3, off + 1);
 		off += SpeexWBSubModeSz[c];
 
-		if (((len * 8 - off) >= 5) && 
-			get_n_bits_at(data, 1, off)) {
+		if (((len * 8 - off) >= 5) && get_n_bits_at(data, 1, off)) {
 			c = get_n_bits_at(data, 3, off + 1);
 			off += SpeexWBSubModeSz[c];
 
-			if (((len * 8 - off) >= 5) && 
-				get_n_bits_at(data, 1, off)) {
+			if (((len * 8 - off) >= 5) && get_n_bits_at(data, 1, off)) {
 				/* too many in a row */
 				DEBU(G "\tCORRUPT too many wideband streams in a row\n");
 				return -1;
@@ -727,15 +728,17 @@
 static int speex_get_samples(unsigned char *data, int len)
 {
 	static int SpeexSubModeSz[] = {
-		0, 43, 119, 160, 
-		220, 300, 364, 492, 
+		0, 43, 119, 160,
+		220, 300, 364, 492,
 		79, 0, 0, 0,
-		0, 0, 0, 0 };
-	static int SpeexInBandSz[] = { 
+		0, 0, 0, 0
+	};
+	static int SpeexInBandSz[] = {
 		1, 1, 4, 4,
 		4, 4, 4, 4,
 		8, 8, 16, 16,
-		32, 32, 64, 64 };
+		32, 32, 64, 64
+	};
 	int bit = 0;
 	int cnt = 0;
 	int off = 0;
@@ -745,7 +748,7 @@
 	while ((len * 8 - bit) >= 5) {
 		/* skip wideband frames */
 		off = speex_get_wb_sz_at(data, len, bit);
-		if (off < 0)  {
+		if (off < 0) {
 			DEBU(G "\tERROR reading wideband frames\n");
 			break;
 		}
@@ -761,7 +764,7 @@
 		DEBU(G "\tCONTROL: %d at %d\n", c, bit);
 		bit += 5;
 
-		if (c == 15) { 
+		if (c == 15) {
 			DEBU(G "\tTERMINATOR\n");
 			break;
 		} else if (c == 14) {
@@ -784,7 +787,7 @@
 			DEBU(G "\tSUBMODE %d %d bits\n", c, SpeexSubModeSz[c]);
 			bit += SpeexSubModeSz[c] - 5;
 
-			cnt += 160; /* new frame */
+			cnt += 160;			/* new frame */
 		}
 	}
 	DEBU(G "\tSAMPLES: %d\n", cnt);
@@ -803,42 +806,42 @@
 	/*
 	 * In the case of zero length frames, do not return a cnt of 0
 	 */
-	if ( e->datalen == 0 ) {
-		return get_interp_len( e->subclass ) * 8;
+	if (e->datalen == 0) {
+		return get_interp_len(e->subclass) * 8;
 	}
 
 	switch (e->subclass) {
-	  case AST_FORMAT_SPEEX:
-	    cnt = speex_get_samples(e->data, e->datalen);
-	    break;
-	  case AST_FORMAT_G723_1:
-	    cnt = 240;		/* FIXME Not always the case */
-	    break;
-	  case AST_FORMAT_ILBC:
-	    cnt = 240 * (e->datalen / 50);
-	    break;
-	  case AST_FORMAT_GSM:
-	    cnt = 160 * (e->datalen / 33);
-	    break;
-	  case AST_FORMAT_G729A:
-	    cnt = 160 * (e->datalen / 20);
-	    break;
-	  case AST_FORMAT_SLINEAR:
-	    cnt = e->datalen / 2;
-	    break;
-	  case AST_FORMAT_LPC10:
-	    cnt = 22 * 8 + (((char *)(e->data))[7] & 0x1) * 8;
-	    break;
-	  case AST_FORMAT_ULAW:
-	  case AST_FORMAT_ALAW:
-	    cnt = e->datalen;
-	    break;
-	  case AST_FORMAT_ADPCM:
-	  case AST_FORMAT_G726:
-	    cnt = e->datalen * 2;
-	    break;
-	  default:
-	    return 0;
+	case AST_FORMAT_SPEEX:
+		cnt = speex_get_samples(e->data, e->datalen);
+		break;
+	case AST_FORMAT_G723_1:
+		cnt = 240;				/* FIXME Not always the case */
+		break;
+	case AST_FORMAT_ILBC:
+		cnt = 240 * (e->datalen / 50);
+		break;
+	case AST_FORMAT_GSM:
+		cnt = 160 * (e->datalen / 33);
+		break;
+	case AST_FORMAT_G729A:
+		cnt = 160 * (e->datalen / 20);
+		break;
+	case AST_FORMAT_SLINEAR:
+		cnt = e->datalen / 2;
+		break;
+	case AST_FORMAT_LPC10:
+		cnt = 22 * 8 + (((char *) (e->data))[7] & 0x1) * 8;
+		break;
+	case AST_FORMAT_ULAW:
+	case AST_FORMAT_ALAW:
+		cnt = e->datalen;
+		break;
+	case AST_FORMAT_ADPCM:
+	case AST_FORMAT_G726:
+		cnt = e->datalen * 2;
+		break;
+	default:
+		return 0;
 	}
 	return cnt;
 }
@@ -850,16 +853,13 @@
 #ifdef DEBUG_SUPPORT
 	struct ast_iax2_full_hdr *h = (f->data);
 	if (ntohs(h->scallno) & IAX_FLAG_FULL)
-		iax_showframe(f, NULL, 0, f->transfer ? 
-						&(f->session->transfer) :
-					&(f->session->peeraddr), f->datalen - sizeof(struct ast_iax2_full_hdr));
+		iax_showframe(f, NULL, 0, f->transfer ? &(f->session->transfer) : &(f->session->peeraddr), f->datalen - sizeof(struct ast_iax2_full_hdr));
 #endif
 
 	return f->session->sendto(netfd, (const char *) f->data, f->datalen,
-		IAX_SOCKOPTS,
-					f->transfer ? 
-						(struct sockaddr *)&(f->session->transfer) :
-					(struct sockaddr *)&(f->session->peeraddr), sizeof(f->session->peeraddr));
+							  IAX_SOCKOPTS,
+							  f->transfer ?
+							  (struct sockaddr *) &(f->session->transfer) : (struct sockaddr *) &(f->session->peeraddr), sizeof(f->session->peeraddr));
 }
 
 static int iax_reliable_xmit(struct iax_frame *f)
@@ -869,9 +869,9 @@
 	fh = (struct ast_iax2_full_hdr *) f->data;
 	if (!fh->type) {
 		DEBU(G "Asked to reliably transmit a non-packet.  Crashing.\n");
-		*((char *)0)=0;
+		*((char *) 0) = 0;
 	}
-	fc = (struct iax_frame *)malloc(sizeof(struct iax_frame));
+	fc = (struct iax_frame *) malloc(sizeof(struct iax_frame));
 	if (fc) {
 		/* Make a copy of the frame */
 		memcpy(fc, f, sizeof(struct iax_frame));
@@ -881,7 +881,7 @@
 			DEBU(G "No frame data?\n");
 			return -1;
 		} else {
-			fc->data = (char *)malloc(fc->datalen);
+			fc->data = (char *) malloc(fc->datalen);
 			if (!fc->data) {
 				DEBU(G "Out of memory\n");
 				IAXERROR "Out of memory\n");
@@ -895,40 +895,38 @@
 		return -1;
 }
 
-void iax_set_networking(sendto_t st, recvfrom_t rf)
-{
+void iax_set_networking(sendto_t st, recvfrom_t rf) {
 
 	init_time();
 	iax_sendto = st;
 	iax_recvfrom = rf;
 }
 
-int __iax_shutdown(void)
-{
+int __iax_shutdown(void) {
 	struct iax_sched *sp, *fp;
 
 	/* Hangup Calls */
 	if (sessions) {
 		struct iax_session *sp = NULL, *fp = NULL;
-		iax_mutex_lock(session_mutex); 
-		for(sp = sessions; sp ;) {
+		iax_mutex_lock(session_mutex);
+		for (sp = sessions; sp;) {
 			iax_hangup(sp, "System Shutdown");
 			fp = sp;
 			sp = sp->next;
 			destroy_session(fp);
 		}
-		iax_mutex_unlock(session_mutex); 
+		iax_mutex_unlock(session_mutex);
 	}
 
 	/* Clear Scheduler */
 	iax_mutex_lock(sched_mutex);
-	for(sp = schedq; sp ;) {
+	for (sp = schedq; sp;) {
 		fp = sp;
 		sp = sp->next;
 		free(fp);
 	}
 	iax_mutex_unlock(sched_mutex);
-	
+
 	if (netfd > -1) {
 		shutdown(netfd, 2);
 		close(netfd);
@@ -942,19 +940,16 @@
 	return 0;
 }
 
-int iax_shutdown(void)
-{
+int iax_shutdown(void) {
 	return do_shutdown++;
 }
 
-void iax_set_jb_target_extra( long value )
-{
+void iax_set_jb_target_extra(long value) {
 	/* store in jb_target_extra, a static global */
-	jb_target_extra = value ;
+	jb_target_extra = value;
 }
 
-int iax_init(char *ip, int preferredportno)
-{
+int iax_init(char *ip, int preferredportno) {
 	int portno = preferredportno;
 	struct sockaddr_in sin;
 #ifdef WIN32
@@ -969,102 +964,98 @@
 	iax_mutex_create(&sched_mutex);
 	iax_mutex_create(&session_mutex);
 
-	if(iax_recvfrom == (recvfrom_t) recvfrom) {
-	    if (netfd > -1) {
-		    /* Sokay, just don't do anything */
-		    DEBU(G "Already initialized.");
-		    return 0;
-	    }
-	    netfd = (int)socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
-	    if (netfd < 0) {
-		    DEBU(G "Unable to allocate UDP socket\n");
-		    IAXERROR "Unable to allocate UDP socket\n");
-		    return -1;
-	    }
-	    
-	    if (preferredportno == 0) preferredportno = IAX_DEFAULT_PORTNO;
-		if (preferredportno < 0)  preferredportno = 0;
+	if (iax_recvfrom == (recvfrom_t) recvfrom) {
+		if (netfd > -1) {
+			/* Sokay, just don't do anything */
+			DEBU(G "Already initialized.");
+			return 0;
+		}
+		netfd = (int) socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+		if (netfd < 0) {
+			DEBU(G "Unable to allocate UDP socket\n");
+			IAXERROR "Unable to allocate UDP socket\n");
+			return -1;
+		}
+
+		if (preferredportno == 0)
+			preferredportno = IAX_DEFAULT_PORTNO;
+		if (preferredportno < 0)
+			preferredportno = 0;
 
 		sin.sin_family = AF_INET;
 		sin.sin_addr.s_addr = 0;
-		sin.sin_port = htons((short)preferredportno);
-		if (bind(netfd, (struct sockaddr *) &sin, sizeof(sin)) < 0) 
-		{
+		sin.sin_port = htons((short) preferredportno);
+		if (bind(netfd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
 #if defined(WIN32)  ||  defined(_WIN32_WCE)
 			if (WSAGetLastError() == WSAEADDRINUSE)
 #else
 			if (errno == EADDRINUSE)
 #endif
 			{
-				/*the port is already in use, so bind to a free port chosen by the IP stack*/
+				/*the port is already in use, so bind to a free port chosen by the IP stack */
 				DEBU(G "Unable to bind to preferred port - port is in use. Trying to bind to a free one");
-				sin.sin_port = htons((short)0);
-				if (bind(netfd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
-				{
+				sin.sin_port = htons((short) 0);
+				if (bind(netfd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
 					IAXERROR "Unable to bind UDP socket\n");
 					return -1;
 				}
-			} else
-			{
+			} else {
 				IAXERROR "Unable to bind UDP socket\n");
 				return -1;
 			}
 		}
 		sinlen = sizeof(sin);
-	    if (getsockname(netfd, (struct sockaddr *) &sin, &sinlen) < 0) {
-		    close(netfd);
-		    netfd = -1;
-		    DEBU(G "Unable to figure out what I'm bound to.");
-		    IAXERROR "Unable to determine bound port number.");
-	    }
+		if (getsockname(netfd, (struct sockaddr *) &sin, &sinlen) < 0) {
+			close(netfd);
+			netfd = -1;
+			DEBU(G "Unable to figure out what I'm bound to.");
+			IAXERROR "Unable to determine bound port number.");
+		}
 #ifdef	WIN32
-	    flags = 1;
-	    if (ioctlsocket(netfd,FIONBIO,(unsigned long *) &flags)) {
-		    closesocket(netfd);
-		    netfd = -1;
-		    DEBU(G "Unable to set non-blocking mode.");
-		    IAXERROR "Unable to set non-blocking mode.");
-	    }
-	    
+		flags = 1;
+		if (ioctlsocket(netfd, FIONBIO, (unsigned long *) &flags)) {
+			closesocket(netfd);
+			netfd = -1;
+			DEBU(G "Unable to set non-blocking mode.");
+			IAXERROR "Unable to set non-blocking mode.");
+		}
 #else
-	    if ((flags = fcntl(netfd, F_GETFL)) < 0) {
-		    close(netfd);
-		    netfd = -1;
-		    DEBU(G "Unable to retrieve socket flags.");
-		    IAXERROR "Unable to retrieve socket flags.");
-	    }
-	    if (fcntl(netfd, F_SETFL, flags | O_NONBLOCK) < 0) {
-		    close(netfd);
-		    netfd = -1;
-		    DEBU(G "Unable to set non-blocking mode.");
-		    IAXERROR "Unable to set non-blocking mode.");
-	    }
+		if ((flags = fcntl(netfd, F_GETFL)) < 0) {
+			close(netfd);
+			netfd = -1;
+			DEBU(G "Unable to retrieve socket flags.");
+			IAXERROR "Unable to retrieve socket flags.");
+		}
+		if (fcntl(netfd, F_SETFL, flags | O_NONBLOCK) < 0) {
+			close(netfd);
+			netfd = -1;
+			DEBU(G "Unable to set non-blocking mode.");
+			IAXERROR "Unable to set non-blocking mode.");
+		}
 #endif
-	    portno = ntohs(sin.sin_port);
+		portno = ntohs(sin.sin_port);
 	}
-	srand((unsigned int)time(NULL));
+	srand((unsigned int) time(NULL));
 	callnums = rand() % 32767 + 1;
 	transfer_id = rand() % 32767 + 1;
 	DEBU(G "Started on port %d\n", portno);
-	return portno;	
+	return portno;
 }
 
 
 
-static void convert_reply(char *out, unsigned char *in)
-{
+static void convert_reply(char *out, unsigned char *in) {
 	int x;
-	for (x=0;x<16;x++)
-		out += sprintf(out, "%2.2x", (int)in[x]);
+	for (x = 0; x < 16; x++)
+		out += sprintf(out, "%2.2x", (int) in[x]);
 }
 
-static unsigned char compress_subclass(int subclass)
-{
+static unsigned char compress_subclass(int subclass) {
 	int x;
-	int power=-1;
+	int power = -1;
 	/* If it's 128 or smaller, just return it */
 	if (subclass < IAX_FLAG_SC_LOG)
-		return (unsigned char)subclass;
+		return (unsigned char) subclass;
 	/* Otherwise find its power */
 	for (x = 0; x < IAX_MAX_SHIFT; x++) {
 		if (subclass & (1 << x)) {
@@ -1075,45 +1066,45 @@
 				power = x;
 		}
 	}
-	return (unsigned char)(power | IAX_FLAG_SC_LOG);
+	return (unsigned char) (power | IAX_FLAG_SC_LOG);
 }
 
-static int iax_send(struct iax_session *pvt, struct ast_frame *f, time_in_ms_t ts, int seqno, int now, int transfer, int final) 
-{
+static int iax_send(struct iax_session *pvt, struct ast_frame *f, time_in_ms_t ts, int seqno, int now, int transfer, int final) {
 	/* Queue a packet for delivery on a given private structure.  Use "ts" for
 	   timestamp, or calculate if ts is 0.  Send immediately without retransmission
 	   or delayed, with retransmission */
 	struct ast_iax2_full_hdr *fh;
 	struct ast_iax2_mini_hdr *mh;
-	unsigned char	buf[5120];
+	unsigned char buf[5120];
 	struct iax_frame *fr;
 	int res;
-	int sendmini=0;
+	int sendmini = 0;
 	time_in_ms_t lastsent;
 	time_in_ms_t fts;
-	
+
 	if (!pvt) {
 		IAXERROR "No private structure for packet?\n");
 		return -1;
 	}
-	
+
 	/* this must come before the next call to calc_timestamp() since
-	 calc_timestamp() will change lastsent to the returned value */
+	   calc_timestamp() will change lastsent to the returned value */
 	lastsent = pvt->lastsent;
 
 	/* Calculate actual timestamp */
 	fts = calc_timestamp(pvt, ts, f);
 
 	if (((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L))
-		/* High two bits are the same on timestamp, or sending on a trunk */ &&
-	    (f->frametype == AST_FRAME_VOICE) 
-		/* is a voice frame */ &&
-		(f->subclass == pvt->svoiceformat) 
-		/* is the same type */ ) {
-			/* Force immediate rather than delayed transmission */
-			now = 1;
-			/* Mark that mini-style frame is appropriate */
-			sendmini = 1;
+		/* High two bits are the same on timestamp, or sending on a trunk */
+		&& (f->frametype == AST_FRAME_VOICE)
+		/* is a voice frame */
+		&& (f->subclass == pvt->svoiceformat)
+		/* is the same type */
+		) {
+		/* Force immediate rather than delayed transmission */
+		now = 1;
+		/* Mark that mini-style frame is appropriate */
+		sendmini = 1;
 	}
 	/* Allocate an iax_frame */
 	if (now) {
@@ -1135,7 +1126,7 @@
 		return -1;
 	}
 
-	fr->callno = (unsigned short)pvt->callno;
+	fr->callno = (unsigned short) pvt->callno;
 	fr->transfer = transfer;
 	fr->final = final;
 	fr->session = pvt;
@@ -1146,22 +1137,22 @@
 		else
 			fr->oseqno = pvt->oseqno++;
 		fr->iseqno = pvt->iseqno;
-		fh = (struct ast_iax2_full_hdr *)(((char *)fr->af.data) - sizeof(struct ast_iax2_full_hdr));
+		fh = (struct ast_iax2_full_hdr *) (((char *) fr->af.data) - sizeof(struct ast_iax2_full_hdr));
 		fh->scallno = htons(fr->callno | IAX_FLAG_FULL);
-		fh->ts = htonl((long)(fr->ts));
-		fh->oseqno = (unsigned char)fr->oseqno;
+		fh->ts = htonl((long) (fr->ts));
+		fh->oseqno = (unsigned char) fr->oseqno;
 		if (transfer) {
 			fh->iseqno = 0;
 		} else
-			fh->iseqno = (unsigned char)fr->iseqno;
+			fh->iseqno = (unsigned char) fr->iseqno;
 		/* Keep track of the last thing we've acknowledged */
-		pvt->aseqno = (unsigned char)fr->iseqno;
-		fh->type = (char)(fr->af.frametype & 0xFF);
+		pvt->aseqno = (unsigned char) fr->iseqno;
+		fh->type = (char) (fr->af.frametype & 0xFF);
 		fh->csub = compress_subclass(fr->af.subclass);
 		if (transfer) {
-			fr->dcallno = (unsigned short)pvt->transfercallno;
+			fr->dcallno = (unsigned short) pvt->transfercallno;
 		} else
-			fr->dcallno = (unsigned short)pvt->peercallno;
+			fr->dcallno = (unsigned short) pvt->peercallno;
 		fh->dcallno = htons(fr->dcallno);
 		fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_full_hdr);
 		fr->data = fh;
@@ -1187,22 +1178,21 @@
 		fr->oseqno = -1;
 		fr->iseqno = -1;
 		/* Mini frame will do */
-		mh = (struct ast_iax2_mini_hdr *)(((char *)fr->af.data) - sizeof(struct ast_iax2_mini_hdr));
+		mh = (struct ast_iax2_mini_hdr *) (((char *) fr->af.data) - sizeof(struct ast_iax2_mini_hdr));
 		mh->callno = htons(fr->callno);
-		mh->ts = htons((short)(fr->ts & 0xFFFF));
+		mh->ts = htons((short) (fr->ts & 0xFFFF));
 		fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_mini_hdr);
 		fr->data = mh;
 		fr->retries = -1;
 		res = iax_xmit_frame(fr);
 	}
-	if( !now && fr!=NULL )
-	        iax_frame_free( fr ); 
+	if (!now && fr != NULL)
+		iax_frame_free(fr);
 	return res;
 }
 
 #if 0
-static int iax_predestroy(struct iax_session *pvt)
-{
+static int iax_predestroy(struct iax_session *pvt) {
 	if (!pvt) {
 		return -1;
 	}
@@ -1226,9 +1216,8 @@
 }
 #endif
 
-static int __send_command(struct iax_session *i, char type, int command, time_in_ms_t ts, unsigned char *data, int datalen, int seqno, 
-		int now, int transfer, int final, int samples)
-{
+static int __send_command(struct iax_session *i, char type, int command, time_in_ms_t ts, unsigned char *data, int datalen, int seqno,
+						  int now, int transfer, int final, int samples) {
 	struct ast_frame f;
 	f.frametype = type;
 	f.subclass = command;
@@ -1245,77 +1234,69 @@
 	return iax_send(i, &f, ts, seqno, now, transfer, final);
 }
 
-static int send_command(struct iax_session *i, char type, int command, time_in_ms_t ts, unsigned char *data, int datalen, int seqno)
-{
+static int send_command(struct iax_session *i, char type, int command, time_in_ms_t ts, unsigned char *data, int datalen, int seqno) {
 	return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 0, 0);
 }
 
-static int send_command_final(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno)
-{
+static int send_command_final(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno) {
 #if 0
 	/* It is assumed that the callno has already been locked */
 	iax_predestroy(i);
-#endif	
+#endif
 	int r;
 	r = __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 1, 0);
 	if (r >= 0) {
-		iax_mutex_lock(session_mutex); 
+		iax_mutex_lock(session_mutex);
 		destroy_session(i);
 		iax_mutex_unlock(session_mutex);
 	}
 	return r;
 }
 
-static int send_command_immediate(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno)
-{
+static int send_command_immediate(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno) {
 	return __send_command(i, type, command, ts, data, datalen, seqno, 1, 0, 0, 0);
 }
 
-static int send_command_transfer(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen)
-{
+static int send_command_transfer(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen) {
 	return __send_command(i, type, command, ts, data, datalen, 0, 0, 1, 0, 0);
 }
 
-static int send_command_samples(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno, int samples)
-{
+static int send_command_samples(struct iax_session *i, char type, int command, unsigned int ts, unsigned char *data, int datalen, int seqno, int samples) {
 	return __send_command(i, type, command, ts, data, datalen, seqno, 0, 0, 0, samples);
 }
 
 
-int iax_transfer(struct iax_session *session, char *number)
-{	
+int iax_transfer(struct iax_session *session, char *number) {
 	static int res;				//Return Code
-	struct iax_ie_data ied;			//IE Data Structure (Stuff To Send)
+	struct iax_ie_data ied;		//IE Data Structure (Stuff To Send)
 
 	// Clear The Memory Used For IE Buffer
 	memset(&ied, 0, sizeof(ied));
-	
+
 	// Copy The Transfer Destination Into The IE Structure
 	iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, (unsigned char *) number);
-	
-	// Send The Transfer Command - Asterisk Will Handle The Rest!			
+
+	// Send The Transfer Command - Asterisk Will Handle The Rest!           
 	res = send_command(session, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
-	
+
 	// Return Success
-	return 0;	
+	return 0;
 }
 
-static void stop_transfer(struct iax_session *session)
-{
+static void stop_transfer(struct iax_session *session) {
 	struct iax_sched *sch;
 
 	iax_mutex_lock(sched_mutex);
 	sch = schedq;
-	while(sch) {
+	while (sch) {
 		if (sch->frame && (sch->frame->session == session))
-					sch->frame->retries = -1;
+			sch->frame->retries = -1;
 		sch = sch->next;
 	}
 	iax_mutex_unlock(sched_mutex);
-}	/* stop_transfer */
+}								/* stop_transfer */
 
-static void complete_transfer(struct iax_session *session, int peercallno, int xfr2peer, int preserveSeq)
-{
+static void complete_transfer(struct iax_session *session, int peercallno, int xfr2peer, int preserveSeq) {
 	session->peercallno = peercallno;
 	/* Change from transfer to session now */
 	if (xfr2peer) {
@@ -1331,20 +1312,19 @@
 	session->rxcore = session->offset = 0;
 	memset(&session->history, 0, sizeof(session->history));
 #ifdef NEWJB
-	{ /* Reset jitterbuffer */
-	    jb_frame frame;
-	    while(jb_getall(session->jb,&frame) == JB_OK) 
-		iax_event_free(frame.data);
-	
-	    jb_reset(session->jb);
+	{							/* Reset jitterbuffer */
+		jb_frame frame;
+		while (jb_getall(session->jb, &frame) == JB_OK)
+			iax_event_free(frame.data);
+
+		jb_reset(session->jb);
 	}
 #endif
 	session->jitterbuffer = 0;
 	session->jitter = 0;
 	session->lag = 0;
 
-	if (! preserveSeq)
-	{
+	if (!preserveSeq) {
 		/* Reset sequence numbers */
 		session->aseqno = 0;
 		session->oseqno = 0;
@@ -1358,10 +1338,9 @@
 	/* We have to dump anything we were going to (re)transmit now that we've been
 	   transferred since they're all invalid and for the old host. */
 	stop_transfer(session);
-}	/* complete_transfer */
+}								/* complete_transfer */
 
-int iax_setup_transfer(struct iax_session *org_session, struct iax_session *new_session)
-{
+int iax_setup_transfer(struct iax_session *org_session, struct iax_session *new_session) {
 	int res;
 	struct iax_ie_data ied0;
 	struct iax_ie_data ied1;
@@ -1374,11 +1353,11 @@
 
 	/* reversed setup */
 	iax_ie_append_addr(&ied0, IAX_IE_APPARENT_ADDR, &s1->peeraddr);
-	iax_ie_append_short(&ied0, IAX_IE_CALLNO, (unsigned short)s1->peercallno);
+	iax_ie_append_short(&ied0, IAX_IE_CALLNO, (unsigned short) s1->peercallno);
 	iax_ie_append_int(&ied0, IAX_IE_TRANSFERID, transfer_id);
 
 	iax_ie_append_addr(&ied1, IAX_IE_APPARENT_ADDR, &s0->peeraddr);
-	iax_ie_append_short(&ied1, IAX_IE_CALLNO, (unsigned short)s0->peercallno);
+	iax_ie_append_short(&ied1, IAX_IE_CALLNO, (unsigned short) s0->peercallno);
 	iax_ie_append_int(&ied1, IAX_IE_TRANSFERID, transfer_id);
 
 	s0->transfer = s1->peeraddr;
@@ -1414,8 +1393,7 @@
 	return 0;
 }
 
-static int iax_finish_transfer(struct iax_session *s, short new_peer)
-{
+static int iax_finish_transfer(struct iax_session *s, short new_peer) {
 	int res;
 	struct iax_ie_data ied;
 
@@ -1431,28 +1409,26 @@
 
 }
 
-static struct iax_session *iax_find_session2(short callno)
-{
+static struct iax_session *iax_find_session2(short callno) {
 	struct iax_session *cur;
 
-	iax_mutex_lock(session_mutex); 
+	iax_mutex_lock(session_mutex);
 	cur = sessions;
-	while(cur) {
-		if (callno == cur->callno && callno != 0)  {
-			iax_mutex_unlock(session_mutex); 
+	while (cur) {
+		if (callno == cur->callno && callno != 0) {
+			iax_mutex_unlock(session_mutex);
 			return cur;
 		}
 		cur = cur->next;
 	}
-	iax_mutex_unlock(session_mutex); 
+	iax_mutex_unlock(session_mutex);
 
 	return NULL;
 }
 
-static int iax_handle_txready(struct iax_session *s)
-{
+static int iax_handle_txready(struct iax_session *s) {
 	struct iax_session *s0, *s1;
-	short	s0_org_peer, s1_org_peer;
+	short s0_org_peer, s1_org_peer;
 
 	if (s->transfer_moh) {
 		s->transfer_moh = 0;
@@ -1464,15 +1440,12 @@
 	s->transferring = TRANSFER_REL;
 
 	s0 = s;
-	s1 = iax_find_session2((short)s0->transferpeer);
+	s1 = iax_find_session2((short) s0->transferpeer);
 
-	if (s1 != NULL &&
-	    s1->callno == s0->transferpeer &&
-		 s0->transferring == TRANSFER_REL &&
-		 s1->transferring == TRANSFER_REL) {
+	if (s1 != NULL && s1->callno == s0->transferpeer && s0->transferring == TRANSFER_REL && s1->transferring == TRANSFER_REL) {
 
-		s0_org_peer = (short)s0->peercallno;
-		s1_org_peer = (short)s1->peercallno;
+		s0_org_peer = (short) s0->peercallno;
+		s1_org_peer = (short) s1->peercallno;
 
 		iax_finish_transfer(s0, s1_org_peer);
 		iax_finish_transfer(s1, s0_org_peer);
@@ -1482,15 +1455,12 @@
 	return 0;
 }
 
-static void iax_handle_txreject(struct iax_session *s)
-{
+static void iax_handle_txreject(struct iax_session *s) {
 	struct iax_session *s0, *s1;
 
 	s0 = s;
-	s1 = iax_find_session2((short)s0->transferpeer);
-	if (s1 != NULL &&
-		 s0->transferpeer == s1->callno &&
-		 s1->transferring) {
+	s1 = iax_find_session2((short) s0->transferpeer);
+	if (s1 != NULL && s0->transferpeer == s1->callno && s1->transferring) {
 		if (s1->transfer_moh) {
 			s1->transfer_moh = 0;
 			send_command_immediate(s1, AST_FRAME_IAX, IAX_COMMAND_UNQUELCH, 0, NULL, 0, s1->iseqno);
@@ -1507,15 +1477,14 @@
 	s->transfer_moh = 0;
 }
 
-static void destroy_session(struct iax_session *session)
-{
-	struct iax_session *cur, *prev=NULL;
-	struct iax_sched *curs, *prevs=NULL, *nexts=NULL;
-	int    loop_cnt=0;
+static void destroy_session(struct iax_session *session) {
+	struct iax_session *cur, *prev = NULL;
+	struct iax_sched *curs, *prevs = NULL, *nexts = NULL;
+	int loop_cnt = 0;
 
 	iax_mutex_lock(sched_mutex);
 	curs = schedq;
-	while(curs) {
+	while (curs) {
 		nexts = curs->next;
 		if (curs->frame && curs->frame->session == session) {
 			/* Just mark these frames as if they've been sent */
@@ -1535,10 +1504,10 @@
 		loop_cnt++;
 	}
 	iax_mutex_unlock(sched_mutex);
-	
+
 
 	cur = sessions;
-	while(cur) {
+	while (cur) {
 		if (cur == session) {
 			if (prev)
 				prev->next = session->next;
@@ -1546,11 +1515,11 @@
 				sessions = session->next;
 #ifdef NEWJB
 			{
-			    jb_frame frame;
-			    while(jb_getall(session->jb,&frame) == JB_OK) 
-				iax_event_free(frame.data);
-		   	
-			    jb_destroy(session->jb);
+				jb_frame frame;
+				while (jb_getall(session->jb, &frame) == JB_OK)
+					iax_event_free(frame.data);
+
+				jb_destroy(session->jb);
 			}
 #endif
 			free(session);
@@ -1564,15 +1533,14 @@
 static int iax_send_lagrp(struct iax_session *session, time_in_ms_t ts);
 static int iax_send_pong(struct iax_session *session, time_in_ms_t ts);
 
-static struct iax_event *handle_event(struct iax_event *event)
-{
+static struct iax_event *handle_event(struct iax_event *event) {
 	/* We have a candidate event to be delievered.  Be sure
 	   the session still exists. */
 	if (event) {
 		if (iax_session_valid(event->session)) {
 			/* Lag requests are never actually sent to the client, but
 			   other than that are handled as normal packets */
-			switch(event->etype) {
+			switch (event->etype) {
 				/* the user on the outside may need to look at the session so we will not free 
 				   it here anymore we will test for hangup event in iax_event_free and do it
 				   there.
@@ -1595,48 +1563,42 @@
 				iax_send_pong(event->session, event->ts);
 				iax_destroy(event->session);
 				iax_event_free(event);
-				break;         
+				break;
 			default:
 				return event;
 			}
-		} else 
+		} else
 			iax_event_free(event);
 	}
 	return NULL;
 }
 
-static int iax2_vnak(struct iax_session *session)
-{
+static int iax2_vnak(struct iax_session *session) {
 	return send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_VNAK, 0, NULL, 0, session->iseqno);
 }
 
-int iax_send_dtmf(struct iax_session *session, char digit)
-{
+int iax_send_dtmf(struct iax_session *session, char digit) {
 	return send_command(session, AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
 }
 
-int iax_send_voice(struct iax_session *session, int format, unsigned char *data, int datalen, int samples)
-{
+int iax_send_voice(struct iax_session *session, int format, unsigned char *data, int datalen, int samples) {
 	/* Send a (possibly compressed) voice frame */
 	if (!session->quelch)
 		return send_command_samples(session, AST_FRAME_VOICE, format, 0, data, datalen, -1, samples);
 	return 0;
 }
 
-int iax_send_cng(struct iax_session *session, int level, unsigned char *data, int datalen)
-{    
+int iax_send_cng(struct iax_session *session, int level, unsigned char *data, int datalen) {
 	session->notsilenttx = 0;
 	return send_command(session, AST_FRAME_CNG, level, 0, data, datalen, -1);
 }
 
-int iax_send_image(struct iax_session *session, int format, unsigned char *data, int datalen)
-{
+int iax_send_image(struct iax_session *session, int format, unsigned char *data, int datalen) {
 	/* Send an image frame */
 	return send_command(session, AST_FRAME_IMAGE, format, 0, data, datalen, -1);
 }
 
-int iax_register(struct iax_session *session, char *server, char *peer, char *secret, int refresh)
-{
+int iax_register(struct iax_session *session, char *server, char *peer, char *secret, int refresh) {
 	/* Send a registration request */
 	char tmp[256];
 	char *p;
@@ -1644,15 +1606,15 @@
 	int portno = IAX_DEFAULT_PORTNO;
 	struct iax_ie_data ied;
 	struct hostent *hp;
-	
+
 	tmp[255] = '\0';
 	strncpy(tmp, server, sizeof(tmp) - 1);
 	p = strchr(tmp, ':');
 	if (p) {
 		*p = '\0';
-		portno = atoi(p+1);
+		portno = atoi(p + 1);
 	}
-	
+
 	memset(&ied, 0, sizeof(ied));
 	if (secret)
 		strncpy(session->secret, secret, sizeof(session->secret) - 1);
@@ -1666,44 +1628,39 @@
 		return -1;
 	}
 	memcpy(&session->peeraddr.sin_addr, hp->h_addr, sizeof(session->peeraddr.sin_addr));
-	session->peeraddr.sin_port = htons((unsigned short)portno);
+	session->peeraddr.sin_port = htons((unsigned short) portno);
 	session->peeraddr.sin_family = AF_INET;
 	strncpy(session->username, peer, sizeof(session->username) - 1);
 	session->refresh = refresh;
 	iax_ie_append_str(&ied, IAX_IE_USERNAME, (unsigned char *) peer);
-	iax_ie_append_short(&ied, IAX_IE_REFRESH, (unsigned short)refresh);
+	iax_ie_append_short(&ied, IAX_IE_REFRESH, (unsigned short) refresh);
 	res = send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREQ, 0, ied.buf, ied.pos, -1);
 	return res;
 }
 
-int iax_reject_registration(struct iax_session *session, char *reason)
-{
+int iax_reject_registration(struct iax_session *session, char *reason) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_str(&ied, IAX_IE_CAUSE, reason ? (unsigned char *) reason : (unsigned char *) "Unspecified");
 	return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGREJ, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_ack_registration(struct iax_session *session)
-{
+int iax_ack_registration(struct iax_session *session) {
 	return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, NULL, 0, -1);
 }
 
-int iax_auth_registration(struct iax_session *session)
-{
+int iax_auth_registration(struct iax_session *session) {
 	return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, NULL, 0, -1);
 }
 
-int iax_reject(struct iax_session *session, const char *reason)
-{
+int iax_reject(struct iax_session *session, const char *reason) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_str(&ied, IAX_IE_CAUSE, reason ? (unsigned char *) reason : (unsigned char *) "Unspecified");
 	return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_hangup(struct iax_session *session, char *byemsg)
-{
+int iax_hangup(struct iax_session *session, char *byemsg) {
 	struct iax_ie_data ied;
 	iax_sched_del(NULL, NULL, send_ping, (void *) session, 1);
 	memset(&ied, 0, sizeof(ied));
@@ -1711,159 +1668,139 @@
 	return send_command_final(session, AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_sendurl(struct iax_session *session, char *url)
-{
-	return send_command(session, AST_FRAME_HTML, AST_HTML_URL, 0, (unsigned char *) url, (int)strlen(url), -1);
+int iax_sendurl(struct iax_session *session, char *url) {
+	return send_command(session, AST_FRAME_HTML, AST_HTML_URL, 0, (unsigned char *) url, (int) strlen(url), -1);
 }
 
-int iax_ring_announce(struct iax_session *session)
-{
+int iax_ring_announce(struct iax_session *session) {
 	return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_RINGING, 0, NULL, 0, -1);
 }
 
-int iax_lag_request(struct iax_session *session)
-{
+int iax_lag_request(struct iax_session *session) {
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1);
 }
 
-int iax_busy(struct iax_session *session)
-{
+int iax_busy(struct iax_session *session) {
 	return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_BUSY, 0, NULL, 0, -1);
 }
 
-int iax_congestion(struct iax_session *session)
-{
+int iax_congestion(struct iax_session *session) {
 	return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_CONGESTION, 0, NULL, 0, -1);
 }
 
 
-int iax_accept(struct iax_session *session, int format)
-{
+int iax_accept(struct iax_session *session, int format) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_int(&ied, IAX_IE_FORMAT, format);
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_ACCEPT, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_answer(struct iax_session *session)
-{
+int iax_answer(struct iax_session *session) {
 	return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1);
 }
 
-int iax_load_complete(struct iax_session *session)
-{
+int iax_load_complete(struct iax_session *session) {
 	return send_command(session, AST_FRAME_HTML, AST_HTML_LDCOMPLETE, 0, NULL, 0, -1);
 }
 
-int iax_send_url(struct iax_session *session, char *url, int link)
-{
-	return send_command(session, AST_FRAME_HTML, link ? AST_HTML_LINKURL : AST_HTML_URL, 0, (unsigned char *) url, (int)strlen(url), -1);
+int iax_send_url(struct iax_session *session, char *url, int link) {
+	return send_command(session, AST_FRAME_HTML, link ? AST_HTML_LINKURL : AST_HTML_URL, 0, (unsigned char *) url, (int) strlen(url), -1);
 }
 
-int iax_send_text(struct iax_session *session, char *text)
-{
-	return send_command(session, AST_FRAME_TEXT, 0, 0, (unsigned char *) text, (int)strlen(text) + 1, -1);
+int iax_send_text(struct iax_session *session, char *text) {
+	return send_command(session, AST_FRAME_TEXT, 0, 0, (unsigned char *) text, (int) strlen(text) + 1, -1);
 }
 
-int iax_send_unlink(struct iax_session *session)
-{
+int iax_send_unlink(struct iax_session *session) {
 	return send_command(session, AST_FRAME_HTML, AST_HTML_UNLINK, 0, NULL, 0, -1);
 }
 
-int iax_send_link_reject(struct iax_session *session)
-{
+int iax_send_link_reject(struct iax_session *session) {
 	return send_command(session, AST_FRAME_HTML, AST_HTML_LINKREJECT, 0, NULL, 0, -1);
 }
 
-static int iax_send_pong(struct iax_session *session, time_in_ms_t ts)
-{
-        struct iax_ie_data ied;
+static int iax_send_pong(struct iax_session *session, time_in_ms_t ts) {
+	struct iax_ie_data ied;
 
-        memset(&ied, 0, sizeof(ied));
+	memset(&ied, 0, sizeof(ied));
 #ifdef NEWJB
 	{
-	    jb_info stats;
-	    jb_getinfo(session->jb, &stats);
+		jb_info stats;
+		jb_getinfo(session->jb, &stats);
 
-	    iax_ie_append_int(&ied,IAX_IE_RR_JITTER, (int)stats.jitter);
-	    /* XXX: should be short-term loss pct.. */
-	    if(stats.frames_in == 0) stats.frames_in = 1;
-	    iax_ie_append_int(&ied,IAX_IE_RR_LOSS, 
-		((0xff & (stats.losspct/1000)) << 24 | (stats.frames_lost & 0x00ffffff)));
-	    iax_ie_append_int(&ied,IAX_IE_RR_PKTS, stats.frames_in);
-	    iax_ie_append_short(&ied,IAX_IE_RR_DELAY, (unsigned short)(stats.current - stats.min));
-	    iax_ie_append_int(&ied,IAX_IE_RR_DROPPED, stats.frames_dropped);
-	    iax_ie_append_int(&ied,IAX_IE_RR_OOO, stats.frames_ooo);
+		iax_ie_append_int(&ied, IAX_IE_RR_JITTER, (int) stats.jitter);
+		/* XXX: should be short-term loss pct.. */
+		if (stats.frames_in == 0)
+			stats.frames_in = 1;
+		iax_ie_append_int(&ied, IAX_IE_RR_LOSS, ((0xff & (stats.losspct / 1000)) << 24 | (stats.frames_lost & 0x00ffffff)));
+		iax_ie_append_int(&ied, IAX_IE_RR_PKTS, stats.frames_in);
+		iax_ie_append_short(&ied, IAX_IE_RR_DELAY, (unsigned short) (stats.current - stats.min));
+		iax_ie_append_int(&ied, IAX_IE_RR_DROPPED, stats.frames_dropped);
+		iax_ie_append_int(&ied, IAX_IE_RR_OOO, stats.frames_ooo);
 	}
 #else
-	    iax_ie_append_int(&ied,IAX_IE_RR_JITTER, session->jitter);
-	    /* don't know, don't send! iax_ie_append_int(&ied,IAX_IE_RR_LOSS, 0); */
-	    /* don't know, don't send! iax_ie_append_int(&ied,IAX_IE_RR_PKTS, stats.frames_in); */
-	    /* don't know, don't send! iax_ie_append_short(&ied,IAX_IE_RR_DELAY, stats.current - stats.min); */
+	iax_ie_append_int(&ied, IAX_IE_RR_JITTER, session->jitter);
+	/* don't know, don't send! iax_ie_append_int(&ied,IAX_IE_RR_LOSS, 0); */
+	/* don't know, don't send! iax_ie_append_int(&ied,IAX_IE_RR_PKTS, stats.frames_in); */
+	/* don't know, don't send! iax_ie_append_short(&ied,IAX_IE_RR_DELAY, stats.current - stats.min); */
 #endif
 
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_PONG, ts, ied.buf, ied.pos, -1);
 }
 
 /* external API; deprecated since we send pings ourselves now (finally) */
-int iax_send_ping(struct iax_session *session)
-{
+int iax_send_ping(struct iax_session *session) {
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1);
 }
 
 /* scheduled ping sender; sends ping, then reschedules */
-static void send_ping(void *s)
-{
-	struct iax_session *session = (struct iax_session *)s;
+static void send_ping(void *s) {
+	struct iax_session *session = (struct iax_session *) s;
 
 	/* important, eh? */
-	if(!iax_session_valid(session)) return;
+	if (!iax_session_valid(session))
+		return;
 
 	send_command(session, AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1);
-	session->pingid = iax_sched_add(NULL,NULL, send_ping, (void *)session, ping_time * 1000);
+	session->pingid = iax_sched_add(NULL, NULL, send_ping, (void *) session, ping_time * 1000);
 	return;
 }
 
-static int iax_send_lagrp(struct iax_session *session, time_in_ms_t ts)
-{
+static int iax_send_lagrp(struct iax_session *session, time_in_ms_t ts) {
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_LAGRP, ts, NULL, 0, -1);
 }
 
-static int iax_send_txcnt(struct iax_session *session)
-{
+static int iax_send_txcnt(struct iax_session *session) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_int(&ied, IAX_IE_TRANSFERID, session->transferid);
 	return send_command_transfer(session, AST_FRAME_IAX, IAX_COMMAND_TXCNT, 0, ied.buf, ied.pos);
 }
 
-static int iax_send_txrej(struct iax_session *session)
-{
+static int iax_send_txrej(struct iax_session *session) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_int(&ied, IAX_IE_TRANSFERID, session->transferid);
 	return send_command_transfer(session, AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, ied.buf, ied.pos);
 }
 
-static int iax_send_txaccept(struct iax_session *session)
-{
+static int iax_send_txaccept(struct iax_session *session) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_int(&ied, IAX_IE_TRANSFERID, session->transferid);
 	return send_command_transfer(session, AST_FRAME_IAX, IAX_COMMAND_TXACC, 0, ied.buf, ied.pos);
 }
 
-static int iax_send_txready(struct iax_session *session)
-{
+static int iax_send_txready(struct iax_session *session) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	/* see asterisk chan_iax2.c */
-	iax_ie_append_short(&ied, IAX_IE_CALLNO, (unsigned short)session->callno);
+	iax_ie_append_short(&ied, IAX_IE_CALLNO, (unsigned short) session->callno);
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_TXREADY, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_auth_reply(struct iax_session *session, char *password, char *challenge, int methods)
-{
+int iax_auth_reply(struct iax_session *session, char *password, char *challenge, int methods) {
 	char reply[16];
 	struct MD5Context md5;
 	char realreply[256];
@@ -1871,8 +1808,8 @@
 	memset(&ied, 0, sizeof(ied));
 	if ((methods & IAX_AUTH_MD5) && challenge) {
 		MD5Init(&md5);
-		MD5Update(&md5, (const unsigned char *) challenge, (unsigned int)strlen(challenge));
-		MD5Update(&md5, (const unsigned char *) password, (unsigned int)strlen(password));
+		MD5Update(&md5, (const unsigned char *) challenge, (unsigned int) strlen(challenge));
+		MD5Update(&md5, (const unsigned char *) password, (unsigned int) strlen(password));
 		MD5Final((unsigned char *) reply, &md5);
 		memset(realreply, 0, sizeof(realreply));
 		convert_reply(realreply, (unsigned char *) reply);
@@ -1883,19 +1820,18 @@
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_AUTHREP, 0, ied.buf, ied.pos, -1);
 }
 
-static int iax_regauth_reply(struct iax_session *session, char *password, char *challenge, int methods)
-{
+static int iax_regauth_reply(struct iax_session *session, char *password, char *challenge, int methods) {
 	char reply[16];
 	struct MD5Context md5;
 	char realreply[256];
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_str(&ied, IAX_IE_USERNAME, (unsigned char *) session->username);
-	iax_ie_append_short(&ied, IAX_IE_REFRESH, (unsigned short)session->refresh);
+	iax_ie_append_short(&ied, IAX_IE_REFRESH, (unsigned short) session->refresh);
 	if ((methods & IAX_AUTHMETHOD_MD5) && challenge) {
 		MD5Init(&md5);
-		MD5Update(&md5, (const unsigned char *) challenge, (unsigned int)strlen(challenge));
-		MD5Update(&md5, (const unsigned char *) password, (unsigned int)strlen(password));
+		MD5Update(&md5, (const unsigned char *) challenge, (unsigned int) strlen(challenge));
+		MD5Update(&md5, (const unsigned char *) password, (unsigned int) strlen(password));
 		MD5Final((unsigned char *) reply, &md5);
 		memset(realreply, 0, sizeof(realreply));
 		convert_reply(realreply, (unsigned char *) reply);
@@ -1907,63 +1843,56 @@
 }
 
 
-int iax_dial(struct iax_session *session, char *number)
-{
+int iax_dial(struct iax_session *session, char *number) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, (unsigned char *) number);
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_DIAL, 0, ied.buf, ied.pos, -1);
 }
 
-int iax_quelch(struct iax_session *session)
-{
+int iax_quelch(struct iax_session *session) {
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_QUELCH, 0, NULL, 0, -1);
 }
 
-int iax_unquelch(struct iax_session *session)
-{
+int iax_unquelch(struct iax_session *session) {
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_UNQUELCH, 0, NULL, 0, -1);
 }
 
-int iax_dialplan_request(struct iax_session *session, char *number)
-{
+int iax_dialplan_request(struct iax_session *session, char *number) {
 	struct iax_ie_data ied;
 	memset(&ied, 0, sizeof(ied));
 	iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, (unsigned char *) number);
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_DPREQ, 0, ied.buf, ied.pos, -1);
 }
 
-static inline int which_bit(unsigned int i)
-{
-    unsigned char x;
-    for(x = 0; x < 32; x++) {
-        if ((unsigned)(1 << x) == i) {
-            return x + 1;
-        }
-    }
-    return 0;
+static inline int which_bit(unsigned int i) {
+	unsigned char x;
+	for (x = 0; x < 32; x++) {
+		if ((unsigned) (1 << x) == i) {
+			return x + 1;
+		}
+	}
+	return 0;
 }
 
-char iax_pref_codec_add(struct iax_session *session, unsigned int format)
-{
+char iax_pref_codec_add(struct iax_session *session, unsigned int format) {
 	int diff = (int) 'A';
-	session->codec_order[session->codec_order_len++] = (char)((which_bit(format)) + diff);
+	session->codec_order[session->codec_order_len++] = (char) ((which_bit(format)) + diff);
 	session->codec_order[session->codec_order_len] = '\0';
-	return session->codec_order[session->codec_order_len-1];
+	return session->codec_order[session->codec_order_len - 1];
 }
 
 
-void iax_pref_codec_del(struct iax_session *session, unsigned int format)
-{
+void iax_pref_codec_del(struct iax_session *session, unsigned int format) {
 	int diff = (int) 'A';
 	size_t x;
 	char old[32];
-	char remove = (char)(which_bit(format) + diff);
+	char remove = (char) (which_bit(format) + diff);
 
 	strncpy(old, session->codec_order, sizeof(old));
 	session->codec_order_len = 0;
 
-	for (x = 0; x < strlen(old) ; x++) {
+	for (x = 0; x < strlen(old); x++) {
 		if (old[x] != remove) {
 			session->codec_order[session->codec_order_len++] = old[x];
 		}
@@ -1971,11 +1900,10 @@
 	session->codec_order[session->codec_order_len] = '\0';
 }
 
-int iax_pref_codec_get(struct iax_session *session, unsigned int *array, int len)
-{
+int iax_pref_codec_get(struct iax_session *session, unsigned int *array, int len) {
 	int diff = (int) 'A';
 	int x;
-	
+
 	for (x = 0; x < session->codec_order_len && x < len; x++) {
 		array[x] = (1 << (session->codec_order[x] - diff - 1));
 	}
@@ -1983,15 +1911,13 @@
 	return x;
 }
 
-void iax_set_samplerate(struct iax_session *session, unsigned short samplemask)
-{
+void iax_set_samplerate(struct iax_session *session, unsigned short samplemask) {
 	session->samplemask = samplemask;
 }
 
 
-int iax_call(struct iax_session *session, const char *cidnum, const char *cidname, char *ich, char *lang, int wait, int formats, int capabilities)
-{
-	char tmp[256]="";
+int iax_call(struct iax_session *session, const char *cidnum, const char *cidname, char *ich, char *lang, int wait, int formats, int capabilities) {
+	char tmp[256] = "";
 	char *part1, *part2;
 	int res;
 	int portno;
@@ -2006,10 +1932,10 @@
 		return -1;
 	}
 	memset(&ied, 0, sizeof(ied));
-	strncpy(tmp, ich, sizeof(tmp) - 1);	
+	strncpy(tmp, ich, sizeof(tmp) - 1);
 
 	iax_ie_append_short(&ied, IAX_IE_VERSION, IAX_PROTO_VERSION);
-    if (session->samplemask) {
+	if (session->samplemask) {
 		iax_ie_append_short(&ied, IAX_IE_SAMPLINGRATE, session->samplemask);
 	}
 	if (cidnum)
@@ -2022,20 +1948,20 @@
 	}
 
 	session->capability = capabilities;
-	session->pingid = iax_sched_add(NULL,NULL, send_ping, (void *)session, 2 * 1000);
+	session->pingid = iax_sched_add(NULL, NULL, send_ping, (void *) session, 2 * 1000);
 
 	/* XXX We should have a preferred format XXX */
 	iax_ie_append_int(&ied, IAX_IE_FORMAT, formats);
 	iax_ie_append_int(&ied, IAX_IE_CAPABILITY, capabilities);
 	if (lang)
 		iax_ie_append_str(&ied, IAX_IE_LANGUAGE, (unsigned char *) lang);
-	
+
 	/* Part 1 is [user[:password]@]peer[:port] */
 	part1 = strtok(tmp, "/");
 
 	/* Part 2 is exten[@context] if it is anything all */
 	part2 = strtok(NULL, "/");
-	
+
 	if (strchr(part1, '@')) {
 		username = strtok(part1, "@");
 		hostname = strtok(NULL, "@");
@@ -2043,19 +1969,19 @@
 		username = NULL;
 		hostname = part1;
 	}
-	
+
 	if (username && strchr(username, ':')) {
 		username = strtok(username, ":");
 		secret = strtok(NULL, ":");
 	} else
 		secret = NULL;
 
-	if(username)
-	  strncpy(session->username, username, sizeof(session->username) - 1);
+	if (username)
+		strncpy(session->username, username, sizeof(session->username) - 1);
+
+	if (secret)
+		strncpy(session->secret, secret, sizeof(session->secret) - 1);
 
-	if(secret)
-	  strncpy(session->secret, secret, sizeof(session->secret) - 1);
-	
 	if (strchr(hostname, ':')) {
 		strtok(hostname, ":");
 		portno = atoi(strtok(NULL, ":"));
@@ -2087,7 +2013,7 @@
 		return -1;
 	}
 	memcpy(&session->peeraddr.sin_addr, hp->h_addr, sizeof(session->peeraddr.sin_addr));
-	session->peeraddr.sin_port = htons((unsigned short)portno);
+	session->peeraddr.sin_port = htons((unsigned short) portno);
 	session->peeraddr.sin_family = AF_INET;
 	res = send_command(session, AST_FRAME_IAX, IAX_COMMAND_NEW, 0, ied.buf, ied.pos, -1);
 	if (res < 0)
@@ -2099,8 +2025,7 @@
 	return res;
 }
 
-static time_in_ms_t calc_rxstamp(struct iax_session *session)
-{
+static time_in_ms_t calc_rxstamp(struct iax_session *session) {
 	time_in_ms_t time_in_ms;
 
 	time_in_ms = current_time_in_ms();
@@ -2113,20 +2038,16 @@
 }
 
 #ifdef notdef_cruft
-static int match(struct sockaddr_in *sin, short callno, short dcallno, struct iax_session *cur)
-{
-	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-		(cur->peeraddr.sin_port == sin->sin_port)) {
+static int match(struct sockaddr_in *sin, short callno, short dcallno, struct iax_session *cur) {
+	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->peeraddr.sin_port == sin->sin_port)) {
 		/* This is the main host */
-		if ((cur->peercallno == callno) || 
-			((dcallno == cur->callno) && !cur->peercallno)) {
+		if ((cur->peercallno == callno) || ((dcallno == cur->callno) && !cur->peercallno)) {
 			/* That's us.  Be sure we keep track of the peer call number */
 			cur->peercallno = callno;
 			return 1;
 		}
 	}
-	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-	    (cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
+	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
 		/* We're transferring */
 		if (dcallno == cur->callno)
 			return 1;
@@ -2141,21 +2062,17 @@
    same peercallno (from two different asterisks) exist in more than
 	one session.
  */
-static int forward_match(struct sockaddr_in *sin, short callno, short dcallno, struct iax_session *cur)
-{
-	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-		(cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
+static int forward_match(struct sockaddr_in *sin, short callno, short dcallno, struct iax_session *cur) {
+	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
 		/* We're transferring */
-		if (dcallno == cur->callno)
-		{
+		if (dcallno == cur->callno) {
 			return 1;
 		}
 	}
 
-	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-		(cur->peeraddr.sin_port == sin->sin_port)) {
-		if (dcallno == cur->callno && dcallno != 0)  {
-					/* That's us.  Be sure we keep track of the peer call number */
+	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->peeraddr.sin_port == sin->sin_port)) {
+		if (dcallno == cur->callno && dcallno != 0) {
+			/* That's us.  Be sure we keep track of the peer call number */
 			if (cur->peercallno == 0) {
 				cur->peercallno = callno;
 			}
@@ -2166,18 +2083,15 @@
 	return 0;
 }
 
-static int reverse_match(struct sockaddr_in *sin, short callno, struct iax_session *cur)
-{
-	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-		(cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
+static int reverse_match(struct sockaddr_in *sin, short callno, struct iax_session *cur) {
+	if ((cur->transfer.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->transfer.sin_port == sin->sin_port) && (cur->transferring)) {
 		/* We're transferring */
-		if (callno == cur->peercallno)  {
+		if (callno == cur->peercallno) {
 			return 1;
 		}
 	}
-	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) &&
-		(cur->peeraddr.sin_port == sin->sin_port)) {
-		if (callno == cur->peercallno)  {
+	if ((cur->peeraddr.sin_addr.s_addr == sin->sin_addr.s_addr) && (cur->peeraddr.sin_port == sin->sin_port)) {
+		if (callno == cur->peercallno) {
 			return 1;
 		}
 	}
@@ -2185,33 +2099,29 @@
 	return 0;
 }
 
-static struct iax_session *iax_find_session(struct sockaddr_in *sin, 
-											short callno, 
-											short dcallno,
-											int makenew)
-{
+static struct iax_session *iax_find_session(struct sockaddr_in *sin, short callno, short dcallno, int makenew) {
 	struct iax_session *cur;
 
-	iax_mutex_lock(session_mutex); 
+	iax_mutex_lock(session_mutex);
 	cur = sessions;
-	while(cur) {
+	while (cur) {
 		if (forward_match(sin, callno, dcallno, cur)) {
-			iax_mutex_unlock(session_mutex); 
+			iax_mutex_unlock(session_mutex);
 			return cur;
 		}
 		cur = cur->next;
 	}
 
 	cur = sessions;
-	while(cur) {
+	while (cur) {
 		if (reverse_match(sin, callno, cur)) {
-			iax_mutex_unlock(session_mutex); 
+			iax_mutex_unlock(session_mutex);
 			return cur;
 		}
 		cur = cur->next;
 	}
 
-	iax_mutex_unlock(session_mutex); 
+	iax_mutex_unlock(session_mutex);
 
 	if (makenew && !dcallno) {
 		cur = iax_session_new();
@@ -2219,18 +2129,17 @@
 		cur->peeraddr.sin_addr.s_addr = sin->sin_addr.s_addr;
 		cur->peeraddr.sin_port = sin->sin_port;
 		cur->peeraddr.sin_family = AF_INET;
-		cur->pingid = iax_sched_add(NULL,NULL, send_ping, (void *)cur, 2 * 1000);
+		cur->pingid = iax_sched_add(NULL, NULL, send_ping, (void *) cur, 2 * 1000);
 		DEBU(G "Making new session, peer callno %d, our callno %d\n", callno, cur->callno);
 	} else {
 		DEBU(G "No session, peer = %d, us = %d\n", callno, dcallno);
 	}
 
-	return cur;	
+	return cur;
 }
 
 #ifdef EXTREME_DEBUG
-static int display_time(int ms)
-{
+static int display_time(int ms) {
 	static int oldms = -1;
 	if (oldms < 0) {
 		DEBU(G "First measure\n");
@@ -2247,36 +2156,34 @@
 
 #ifdef NEWJB
 /* From chan_iax2/steve davies:  need to get permission from steve or digium, I guess */
-static time_in_ms_t unwrap_timestamp(time_in_ms_t ts, time_in_ms_t last)
-{
-        time_in_ms_t x;
+static time_in_ms_t unwrap_timestamp(time_in_ms_t ts, time_in_ms_t last) {
+	time_in_ms_t x;
 
-        if ( (ts & 0xFFFF0000) == (last & 0xFFFF0000) ) {
-                x = ts - last;
-                if (x < -50000) {
-                        /* Sudden big jump backwards in timestamp:
-                           What likely happened here is that miniframe timestamp has circled but we haven't
-                           gotten the update from the main packet.  We'll just pretend that we did, and
-                           update the timestamp appropriately. */
-                        ts = ( (last & 0xFFFF0000) + 0x10000) | (ts & 0xFFFF);
-                                DEBU(G "schedule_delivery: pushed forward timestamp\n");
-                }
-                if (x > 50000) {
-                        /* Sudden apparent big jump forwards in timestamp:
-                           What's likely happened is this is an old miniframe belonging to the previous
-                           top-16-bit timestamp that has turned up out of order.
-                           Adjust the timestamp appropriately. */
-                        ts = ( (last & 0xFFFF0000) - 0x10000) | (ts & 0xFFFF);
-                                DEBU(G "schedule_delivery: pushed back timestamp\n");
-                }
-        }
+	if ((ts & 0xFFFF0000) == (last & 0xFFFF0000)) {
+		x = ts - last;
+		if (x < -50000) {
+			/* Sudden big jump backwards in timestamp:
+			   What likely happened here is that miniframe timestamp has circled but we haven't
+			   gotten the update from the main packet.  We'll just pretend that we did, and
+			   update the timestamp appropriately. */
+			ts = ((last & 0xFFFF0000) + 0x10000) | (ts & 0xFFFF);
+			DEBU(G "schedule_delivery: pushed forward timestamp\n");
+		}
+		if (x > 50000) {
+			/* Sudden apparent big jump forwards in timestamp:
+			   What's likely happened is this is an old miniframe belonging to the previous
+			   top-16-bit timestamp that has turned up out of order.
+			   Adjust the timestamp appropriately. */
+			ts = ((last & 0xFFFF0000) - 0x10000) | (ts & 0xFFFF);
+			DEBU(G "schedule_delivery: pushed back timestamp\n");
+		}
+	}
 	return ts;
 }
 #endif
 
 
-static struct iax_event *schedule_delivery(struct iax_event *e, time_in_ms_t ts, int updatehistory)
-{
+static struct iax_event *schedule_delivery(struct iax_event *e, time_in_ms_t ts, int updatehistory) {
 	/* 
 	 * This is the core of the IAX jitterbuffer delivery mechanism: 
 	 * Dynamically adjust the jitterbuffer and decide how time_in_ms_t to wait
@@ -2285,21 +2192,21 @@
 #ifndef NEWJB
 	int ms, x;
 	int drops[MEMORY_SIZE];
-	int min, max=0, maxone=0, y, z, match;
+	int min, max = 0, maxone = 0, y, z, match;
 #endif
 
-#ifdef EXTREME_DEBUG	
+#ifdef EXTREME_DEBUG
 	DEBU(G "[%p] We are at %d, packet is for %d\n", e->session, calc_rxstamp(e->session), ts);
 #endif
-	
+
 #ifdef VOICE_SMOOTHING
 	if (e->etype == IAX_EVENT_VOICE) {
 		/* Smooth voices if we know enough about the format */
-		switch(e->event.voice.format) {
+		switch (e->event.voice.format) {
 		case AST_FORMAT_GSM:
 			/* GSM frames are 20 ms long, although there could be periods of 
 			   silence.  If the time is < 50 ms, assume it ought to be 20 ms */
-			if (ts - e->session->lastts < 50)  
+			if (ts - e->session->lastts < 50)
 				ts = e->session->lastts + 20;
 #ifdef EXTREME_DEBUG
 			display_time(ts);
@@ -2314,38 +2221,38 @@
 
 #ifdef NEWJB
 	{
-	    int type = JB_TYPE_CONTROL;
-	    int len = 0;
+		int type = JB_TYPE_CONTROL;
+		int len = 0;
+
+		if (e->etype == IAX_EVENT_VOICE) {
+			type = JB_TYPE_VOICE;
+			len = get_sample_cnt(e) / 8;
+		} else if (e->etype == IAX_EVENT_CNG) {
+			type = JB_TYPE_SILENCE;
+		}
+
+		/* unwrap timestamp */
+		ts = unwrap_timestamp(ts, e->session->last_ts);
 
-	    if(e->etype == IAX_EVENT_VOICE) {
-	      type = JB_TYPE_VOICE;
-	      len = get_sample_cnt(e) / 8;
-	    } else if(e->etype == IAX_EVENT_CNG) {
-	      type = JB_TYPE_SILENCE;	
-	    }
-
-	    /* unwrap timestamp */
-	    ts = unwrap_timestamp(ts,e->session->last_ts);
-
-	    /* move forward last_ts if it's greater.  We do this _after_ unwrapping, because
-	     * asterisk _still_ has cases where it doesn't send full frames when it ought to */
-	    if(ts > e->session->last_ts) {
-		e->session->last_ts = ts;		
-	    }
-
-
-	    /* insert into jitterbuffer */
-	    /* TODO: Perhaps we could act immediately if it's not droppable and late */
-	    if(jb_put(e->session->jb, e, type, len, ts, calc_rxstamp(e->session)) == JB_DROP) {
-		  iax_event_free(e);
-	    }
+		/* move forward last_ts if it's greater.  We do this _after_ unwrapping, because
+		 * asterisk _still_ has cases where it doesn't send full frames when it ought to */
+		if (ts > e->session->last_ts) {
+			e->session->last_ts = ts;
+		}
+
+
+		/* insert into jitterbuffer */
+		/* TODO: Perhaps we could act immediately if it's not droppable and late */
+		if (jb_put(e->session->jb, e, type, len, ts, calc_rxstamp(e->session)) == JB_DROP) {
+			iax_event_free(e);
+		}
 
 	}
 #else
-	
+
 	/* How many ms from now should this packet be delivered? (remember
 	   this can be a negative number, too */
-	ms = (int)(calc_rxstamp(e->session) - ts);
+	ms = (int) (calc_rxstamp(e->session) - ts);
 
 	/*  
 	   Drop voice frame if timestamp is way off 
@@ -2354,7 +2261,7 @@
 	   free(e);
 	   return NULL;
 	   }
-	*/
+	 */
 
 	/* Adjust if voice frame timestamp is off by a step */
 	if (ms > 32768) {
@@ -2368,33 +2275,32 @@
 		   time frame */
 		ms += 65536;
 	}
-
-#if 0	
+#if 0
 	printf("rxstamp is %d, timestamp is %d, ms is %d\n", calc_rxstamp(e->session), ts, ms);
 #endif
 	/* Rotate history queue.  Leading 0's are irrelevant. */
 	if (updatehistory) {
-	    for (x=0; x < MEMORY_SIZE - 1; x++) 
-		    e->session->history[x] = e->session->history[x+1];
-	    
-	    /* Add new entry for this time */
-	    e->session->history[x] = ms;
+		for (x = 0; x < MEMORY_SIZE - 1; x++)
+			e->session->history[x] = e->session->history[x + 1];
+
+		/* Add new entry for this time */
+		e->session->history[x] = ms;
 	}
-	
+
 	/* We have to find the maximum and minimum time delay we've had to deliver. */
 	min = e->session->history[0];
-	for (z=0;z < iax_dropcount + 1; z++) {
+	for (z = 0; z < iax_dropcount + 1; z++) {
 		/* We drop the top iax_dropcount entries.  iax_dropcount represents
 		   a tradeoff between quality of voice and latency.  3% drop seems to
 		   be unnoticable to the client and can significantly improve latency.  
 		   We add one more to our droplist, but that's the one we actually use, 
 		   and don't drop.  */
 		max = -99999999;
-		for (x=0;x<MEMORY_SIZE;x++) {
+		for (x = 0; x < MEMORY_SIZE; x++) {
 			if (max < e->session->history[x]) {
 				/* New candidate value.  Make sure we haven't dropped it. */
-				match=0;
-				for(y=0;!match && (y<z); y++) 
+				match = 0;
+				for (y = 0; !match && (y < z); y++)
 					match |= (drops[y] == x);
 				/* If there is no match, this is our new maximum */
 				if (!match) {
@@ -2413,7 +2319,7 @@
 	/* Again, just for reference.  The "jitter buffer" is the max.  The difference
 	   is the perceived jitter correction. */
 	e->session->jitter = max - min;
-	
+
 	/* If the jitter buffer is substantially too large, shrink it, slowly enough
 	   that the client won't notice ;-) . */
 	if (max < e->session->jitterbuffer - max_extra_jitterbuffer) {
@@ -2422,27 +2328,27 @@
 #endif
 		e->session->jitterbuffer -= 1;
 	}
-		
+
 	/* Keep the jitter buffer from becoming unreasonably large */
 	if (max > min + max_jitterbuffer) {
 		DEBU(G "Constraining jitter buffer (min = %d, max = %d)...\n", min, max);
 		max = min + max_jitterbuffer;
 	}
-	
+
 	/* If the jitter buffer is too small, we immediately grow our buffer to
 	   accomodate */
 	if (max > e->session->jitterbuffer)
 		e->session->jitterbuffer = max;
-	
+
 	/* Start with our jitter buffer delay, and subtract the lateness (or earliness).
 	   Remember these times are all relative to the first packet, so their absolute
 	   values are really irrelevant. */
 	ms = e->session->jitterbuffer - ms - IAX_SCHEDULE_FUZZ;
-	
+
 	/* If the jitterbuffer is disabled, always deliver immediately */
 	if (!iax_use_jitterbuffer)
 		ms = 0;
-	
+
 	if (ms < 1) {
 #ifdef EXTREME_DEBUG
 		DEBU(G "Calculated delay is only %d\n", ms);
@@ -2469,11 +2375,10 @@
 #endif
 #endif /* NEWJB */
 	return NULL;
-	
+
 }
 
-static int uncompress_subclass(unsigned char csub)
-{
+static int uncompress_subclass(unsigned char csub) {
 	/* If the SC_LOG flag is set, return 2^csub otherwise csub */
 	if (csub & IAX_FLAG_SC_LOG)
 		return 1 << (csub & ~IAX_FLAG_SC_LOG & IAX_MAX_SHIFT);
@@ -2481,8 +2386,7 @@
 		return csub;
 }
 
-static inline char *extract(char *src, char *string)
-{
+static inline char *extract(char *src, char *string) {
 	/* Extract and duplicate what we need from a string */
 	char *s, *t;
 	s = strstr(src, string);
@@ -2496,13 +2400,10 @@
 		}
 	}
 	return s;
-		
+
 }
 
-static struct iax_event *iax_header_to_event(struct iax_session *session,
-											 struct ast_iax2_full_hdr *fh,
-											 int datalen, struct sockaddr_in *sin)
-{
+static struct iax_event *iax_header_to_event(struct iax_session *session, struct ast_iax2_full_hdr *fh, int datalen, struct sockaddr_in *sin) {
 	struct iax_event *e;
 	struct iax_sched *sch;
 	unsigned int ts;
@@ -2512,14 +2413,10 @@
 	ts = ntohl(fh->ts);
 	/* don't run last_ts backwards; i.e. for retransmits and the like */
 	if (ts > session->last_ts &&
-	    (fh->type == AST_FRAME_IAX && 
-	     subclass != IAX_COMMAND_ACK &&
-	     subclass != IAX_COMMAND_PONG &&
-	     subclass != IAX_COMMAND_LAGRP)) {
-	    session->last_ts = ts;
+		(fh->type == AST_FRAME_IAX && subclass != IAX_COMMAND_ACK && subclass != IAX_COMMAND_PONG && subclass != IAX_COMMAND_LAGRP)) {
+		session->last_ts = ts;
 	}
 
-
 #ifdef DEBUG_SUPPORT
 	iax_showframe(NULL, fh, 1, sin, datalen);
 #endif
@@ -2527,89 +2424,75 @@
 	/* Get things going with it, timestamp wise, if we
 	   haven't already. */
 
-		/* Handle implicit ACKing unless this is an INVAL, and only if this is 
-		   from the real peer, not the transfer peer */
-		if (!inaddrcmp(sin, &session->peeraddr) && 
-			(((subclass != IAX_COMMAND_INVAL)) ||
-			(fh->type != AST_FRAME_IAX))) {
-			unsigned char x;
-			/* XXX This code is not very efficient.  Surely there is a better way which still
-			       properly handles boundary conditions? XXX */
-			/* First we have to qualify that the ACKed value is within our window */
-			for (x=session->rseqno; x != session->oseqno; x++)
-				if (fh->iseqno == x)
-					break;
-			if ((x != session->oseqno) || (session->oseqno == fh->iseqno)) {
-				/* The acknowledgement is within our window.  Time to acknowledge everything
-				   that it says to */
-				for (x=session->rseqno; x != fh->iseqno; x++) {
-					/* Ack the packet with the given timestamp */
-					DEBU(G "Cancelling transmission of packet %d\n", x);
-					iax_mutex_lock(sched_mutex);
-					sch = schedq;
-					while(sch) {
-						if (sch->frame && (sch->frame->session == session) && 
-						    (sch->frame->oseqno == x)) 
-							sch->frame->retries = -1;
-						sch = sch->next;
-					}
-					iax_mutex_unlock(sched_mutex);
+	/* Handle implicit ACKing unless this is an INVAL, and only if this is 
+	   from the real peer, not the transfer peer */
+	if (!inaddrcmp(sin, &session->peeraddr) && (((subclass != IAX_COMMAND_INVAL)) || (fh->type != AST_FRAME_IAX))) {
+		unsigned char x;
+		/* XXX This code is not very efficient.  Surely there is a better way which still
+		   properly handles boundary conditions? XXX */
+		/* First we have to qualify that the ACKed value is within our window */
+		for (x = session->rseqno; x != session->oseqno; x++)
+			if (fh->iseqno == x)
+				break;
+		if ((x != session->oseqno) || (session->oseqno == fh->iseqno)) {
+			/* The acknowledgement is within our window.  Time to acknowledge everything
+			   that it says to */
+			for (x = session->rseqno; x != fh->iseqno; x++) {
+				/* Ack the packet with the given timestamp */
+				DEBU(G "Cancelling transmission of packet %d\n", x);
+				iax_mutex_lock(sched_mutex);
+				sch = schedq;
+				while (sch) {
+					if (sch->frame && (sch->frame->session == session) && (sch->frame->oseqno == x))
+						sch->frame->retries = -1;
+					sch = sch->next;
 				}
-				/* Note how much we've received acknowledgement for */
-				session->rseqno = fh->iseqno;
-			} else
-				DEBU(G "Received iseqno %d not within window %d->%d\n", fh->iseqno, session->rseqno, session->oseqno);
-		}
+				iax_mutex_unlock(sched_mutex);
+			}
+			/* Note how much we've received acknowledgement for */
+			session->rseqno = fh->iseqno;
+		} else
+			DEBU(G "Received iseqno %d not within window %d->%d\n", fh->iseqno, session->rseqno, session->oseqno);
+	}
 
 	/* Check where we are */
-		if ((ntohs(fh->dcallno) & IAX_FLAG_RETRANS) || (fh->type != AST_FRAME_VOICE))
-			updatehistory = 0;
-		if ((session->iseqno != fh->oseqno) &&
-			(session->iseqno ||
-			   ((subclass != IAX_COMMAND_TXREADY) &&
-			    (subclass != IAX_COMMAND_TXREL) &&
-				(subclass != IAX_COMMAND_TXCNT) &&
-				(subclass != IAX_COMMAND_TXACC)) ||
-			  (fh->type != AST_FRAME_IAX))) {
-			if (
-			 ((subclass != IAX_COMMAND_ACK) &&
-			  (subclass != IAX_COMMAND_INVAL) &&
-			  (subclass != IAX_COMMAND_TXREADY) &&
-			  (subclass != IAX_COMMAND_TXREL) &&
-			  (subclass != IAX_COMMAND_TXCNT) &&
-			  (subclass != IAX_COMMAND_TXACC) &&
-			  (subclass != IAX_COMMAND_VNAK)) ||
-			  (fh->type != AST_FRAME_IAX)) {
-			 	/* If it's not an ACK packet, it's out of order. */
-				DEBU(G "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n", 
-					session->iseqno, fh->oseqno, fh->type, subclass);
-				if (session->iseqno > fh->oseqno) {
-					/* If we've already seen it, ack it XXX There's a border condition here XXX */
-					if ((fh->type != AST_FRAME_IAX) || 
-							((subclass != IAX_COMMAND_ACK) && (subclass != IAX_COMMAND_INVAL))) {
-						DEBU(G "Acking anyway\n");
-						/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
-						   we have anything to send, we'll retransmit and get an ACK back anyway XXX */
-						send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, ts, NULL, 0,fh->iseqno);
-					}
-				} else {
-					/* Send a VNAK requesting retransmission */
-					iax2_vnak(session);
+	if ((ntohs(fh->dcallno) & IAX_FLAG_RETRANS) || (fh->type != AST_FRAME_VOICE))
+		updatehistory = 0;
+	if ((session->iseqno != fh->oseqno) &&
+		(session->iseqno ||
+		 ((subclass != IAX_COMMAND_TXREADY) &&
+		  (subclass != IAX_COMMAND_TXREL) && (subclass != IAX_COMMAND_TXCNT) && (subclass != IAX_COMMAND_TXACC)) || (fh->type != AST_FRAME_IAX))) {
+		if (((subclass != IAX_COMMAND_ACK) &&
+			 (subclass != IAX_COMMAND_INVAL) &&
+			 (subclass != IAX_COMMAND_TXREADY) &&
+			 (subclass != IAX_COMMAND_TXREL) &&
+			 (subclass != IAX_COMMAND_TXCNT) && (subclass != IAX_COMMAND_TXACC) && (subclass != IAX_COMMAND_VNAK)) || (fh->type != AST_FRAME_IAX)) {
+			/* If it's not an ACK packet, it's out of order. */
+			DEBU(G "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
+				 session->iseqno, fh->oseqno, fh->type, subclass);
+			if (session->iseqno > fh->oseqno) {
+				/* If we've already seen it, ack it XXX There's a border condition here XXX */
+				if ((fh->type != AST_FRAME_IAX) || ((subclass != IAX_COMMAND_ACK) && (subclass != IAX_COMMAND_INVAL))) {
+					DEBU(G "Acking anyway\n");
+					/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
+					   we have anything to send, we'll retransmit and get an ACK back anyway XXX */
+					send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, ts, NULL, 0, fh->iseqno);
 				}
-				return NULL;
+			} else {
+				/* Send a VNAK requesting retransmission */
+				iax2_vnak(session);
 			}
-		} else {
-			/* Increment unless it's an ACK or VNAK */
-			if (((subclass != IAX_COMMAND_ACK) &&
-			    (subclass != IAX_COMMAND_INVAL) &&
-			    (subclass != IAX_COMMAND_TXCNT) &&
-			    (subclass != IAX_COMMAND_TXACC) &&
-				(subclass != IAX_COMMAND_VNAK)) ||
-			    (fh->type != AST_FRAME_IAX))
-				session->iseqno++;
+			return NULL;
 		}
-			
-	e = (struct iax_event *)malloc(sizeof(struct iax_event) + datalen + 1);
+	} else {
+		/* Increment unless it's an ACK or VNAK */
+		if (((subclass != IAX_COMMAND_ACK) &&
+			 (subclass != IAX_COMMAND_INVAL) &&
+			 (subclass != IAX_COMMAND_TXCNT) && (subclass != IAX_COMMAND_TXACC) && (subclass != IAX_COMMAND_VNAK)) || (fh->type != AST_FRAME_IAX))
+			session->iseqno++;
+	}
+
+	e = (struct iax_event *) malloc(sizeof(struct iax_event) + datalen + 1);
 
 	if (e) {
 		memset(e, 0, sizeof(struct iax_event) + datalen);
@@ -2618,14 +2501,14 @@
 		 */
 		e->etype = -1;
 		e->session = session;
-		switch(fh->type) {
+		switch (fh->type) {
 		case AST_FRAME_DTMF:
 			e->etype = IAX_EVENT_DTMF;
 			e->subclass = subclass;
 			/* 
-			 We want the DTMF event deliver immediately so all I/O can be
-			 terminate quickly in an IVR system.
-			e = schedule_delivery(e, ts, updatehistory); */
+			   We want the DTMF event deliver immediately so all I/O can be
+			   terminate quickly in an IVR system.
+			   e = schedule_delivery(e, ts, updatehistory); */
 			break;
 		case AST_FRAME_VOICE:
 			e->etype = IAX_EVENT_VOICE;
@@ -2640,12 +2523,12 @@
 		case AST_FRAME_CNG:
 			e->etype = IAX_EVENT_CNG;
 			e->subclass = subclass;
-                        if (datalen) {
-                                memcpy(e->data, fh->iedata, datalen);
-                                e->datalen = datalen;
-                        }
-                        e = schedule_delivery(e, ts, updatehistory);
-                        break;
+			if (datalen) {
+				memcpy(e->data, fh->iedata, datalen);
+				e->datalen = datalen;
+			}
+			e = schedule_delivery(e, ts, updatehistory);
+			break;
 		case AST_FRAME_IAX:
 			/* Parse IE's */
 			if (datalen) {
@@ -2658,14 +2541,14 @@
 				e = NULL;
 				break;
 			}
-			switch(subclass) {
+			switch (subclass) {
 			case IAX_COMMAND_NEW:
 				/* This is a new, incoming call */
 				/* save the capability for validation */
 				session->capability = e->ies.capability;
 				if (e->ies.codec_prefs) {
 					strncpy(session->codec_order, e->ies.codec_prefs, sizeof(session->codec_order));
-					session->codec_order_len = (int)strlen(session->codec_order);
+					session->codec_order_len = (int) strlen(session->codec_order);
 				}
 				e->etype = IAX_EVENT_CONNECT;
 				e = schedule_delivery(e, ts, updatehistory);
@@ -2673,13 +2556,12 @@
 			case IAX_COMMAND_AUTHREQ:
 				/* This is a request for a call */
 				e->etype = IAX_EVENT_AUTHRQ;
-				if (strlen(session->username) && !strcmp(e->ies.username, session->username) &&
-					strlen(session->secret)) {
-						/* Hey, we already know this one */
-						iax_auth_reply(session, session->secret, e->ies.challenge, e->ies.authmethods);
-						free(e);
-						e = NULL;
-						break;
+				if (strlen(session->username) && !strcmp(e->ies.username, session->username) && strlen(session->secret)) {
+					/* Hey, we already know this one */
+					iax_auth_reply(session, session->secret, e->ies.challenge, e->ies.authmethods);
+					free(e);
+					e = NULL;
+					break;
 				}
 				e = schedule_delivery(e, ts, updatehistory);
 				break;
@@ -2717,7 +2599,7 @@
 			case IAX_COMMAND_PONG:
 				e->etype = IAX_EVENT_PONG;
 				/* track weighted average of ping time */
-				session->pingtime = ((2 * session->pingtime) + (calc_timestamp(session,0,NULL) - ts)) / 3;
+				session->pingtime = ((2 * session->pingtime) + (calc_timestamp(session, 0, NULL) - ts)) / 3;
 				session->remote_netstats.jitter = e->ies.rr_jitter;
 				session->remote_netstats.losspct = e->ies.rr_loss >> 24;;
 				session->remote_netstats.losscnt = e->ies.rr_loss & 0xffffff;
@@ -2729,13 +2611,12 @@
 			case IAX_COMMAND_ACCEPT:
 				if (e->ies.format & session->capability) {
 					e->etype = IAX_EVENT_ACCEPT;
-				}
-				else {
+				} else {
 					struct iax_ie_data ied;
 					/* Although this should not happen, we added this to make sure
 					   the negotiation protocol is enforced.
-						For lack of event to notify the application we use the defined
-						REJECT event.
+					   For lack of event to notify the application we use the defined
+					   REJECT event.
 					 */
 					memset(&ied, 0, sizeof(ied));
 					iax_ie_append_str(&ied, IAX_IE_CAUSE, (unsigned char *) "Unable to negotiate codec");
@@ -2779,15 +2660,15 @@
 				 *  apparent transfer address
 				 */
 				if (e->ies.apparent_addr != NULL) {
-				    /* so a full voice frame is sent on the 
-				       next voice output */
-				    session->svoiceformat = -1;	
-				    session->transfer = *e->ies.apparent_addr;
-				    session->transfer.sin_family = AF_INET;
-				    session->transfercallno = e->ies.callno;
-				    session->transferring = TRANSFER_BEGIN;
-				    session->transferid = e->ies.transferid;
-				    iax_send_txcnt(session);
+					/* so a full voice frame is sent on the 
+					   next voice output */
+					session->svoiceformat = -1;
+					session->transfer = *e->ies.apparent_addr;
+					session->transfer.sin_family = AF_INET;
+					session->transfercallno = e->ies.callno;
+					session->transferring = TRANSFER_BEGIN;
+					session->transferid = e->ies.transferid;
+					iax_send_txcnt(session);
 				}
 				free(e);
 				e = NULL;
@@ -2798,7 +2679,7 @@
 				/* Return immediately, makes no sense to schedule */
 				break;
 			case IAX_COMMAND_TXCNT:
-				if (session->transferring)  {
+				if (session->transferring) {
 					session->transfer = *sin;
 					iax_send_txaccept(session);
 				}
@@ -2816,11 +2697,10 @@
 				break;
 			case IAX_COMMAND_TXREL:
 				/* Release the transfer */
-			   send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, fh->ts, NULL, 0, fh->iseqno);
+				send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, fh->ts, NULL, 0, fh->iseqno);
 				if (session->transferring) {
 					complete_transfer(session, e->ies.callno, 1, 0);
-				}
-				else {
+				} else {
 					complete_transfer(session, session->peercallno, 0, 1);
 				}
 				e->etype = IAX_EVENT_TRANSFER;
@@ -2844,8 +2724,7 @@
 				send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, ts, NULL, 0, fh->iseqno);
 				if (iax_handle_txready(session)) {
 					e->etype = IAX_EVENT_TXREADY;
-				}
-				else {
+				} else {
 					free(e);
 					e = NULL;
 				}
@@ -2857,7 +2736,7 @@
 			}
 			break;
 		case AST_FRAME_CONTROL:
-			switch(subclass) {
+			switch (subclass) {
 			case AST_CONTROL_ANSWER:
 				e->etype = IAX_EVENT_ANSWER;
 				e = schedule_delivery(e, ts, updatehistory);
@@ -2895,7 +2774,7 @@
 			break;
 
 		case AST_FRAME_HTML:
-			switch(fh->csub) {
+			switch (fh->csub) {
 			case AST_HTML_LINKURL:
 				e->etype = IAX_EVENT_LINKURL;
 				/* Fall through */
@@ -2934,22 +2813,19 @@
 		}
 	} else
 		DEBU(G "Out of memory\n");
-	    
+
 	/* Already ack'd iax frames */
 	if (session->aseqno != session->iseqno) {
-	    send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, ts, NULL, 0, fh->iseqno);
+		send_command_immediate(session, AST_FRAME_IAX, IAX_COMMAND_ACK, ts, NULL, 0, fh->iseqno);
 	}
 	return e;
 }
 
-static struct iax_event *iax_miniheader_to_event(struct iax_session *session,
-						struct ast_iax2_mini_hdr *mh,
-						int datalen)
-{
+static struct iax_event *iax_miniheader_to_event(struct iax_session *session, struct ast_iax2_mini_hdr *mh, int datalen) {
 	struct iax_event *e;
 	time_in_ms_t ts;
 	int updatehistory = 1;
-	e = (struct iax_event *)malloc(sizeof(struct iax_event) + datalen);
+	e = (struct iax_event *) malloc(sizeof(struct iax_event) + datalen);
 	if (e) {
 		if (session->voiceformat > 0) {
 			e->etype = IAX_EVENT_VOICE;
@@ -2974,15 +2850,13 @@
 	return e;
 }
 
-void iax_destroy(struct iax_session *session)
-{
-	iax_mutex_lock(session_mutex); 
+void iax_destroy(struct iax_session *session) {
+	iax_mutex_lock(session_mutex);
 	destroy_session(session);
-	iax_mutex_unlock(session_mutex); 
+	iax_mutex_unlock(session_mutex);
 }
 
-static struct iax_event *iax_net_read(void)
-{
+static struct iax_event *iax_net_read(void) {
 	unsigned char buf[65536];
 	int res;
 #ifndef __Linux__
@@ -2993,7 +2867,7 @@
 	struct sockaddr_in sin;
 
 	sinlen = sizeof(sin);
-	res = iax_recvfrom(netfd, (char *)buf, sizeof(buf), 0, (struct sockaddr *) &sin, &sinlen);
+	res = iax_recvfrom(netfd, (char *) buf, sizeof(buf), 0, (struct sockaddr *) &sin, &sinlen);
 
 	if (res < 0) {
 #ifdef	WIN32
@@ -3012,48 +2886,44 @@
 	return iax_net_process(buf, res, &sin);
 }
 
-static struct iax_session *iax_txcnt_session(struct ast_iax2_full_hdr *fh, int datalen,
-				struct sockaddr_in *sin, short callno, short dcallno)
-{
+static struct iax_session *iax_txcnt_session(struct ast_iax2_full_hdr *fh, int datalen, struct sockaddr_in *sin, short callno, short dcallno) {
 	int subclass = uncompress_subclass(fh->csub);
-	unsigned char buf[ 65536 ]; /* allocated on stack with same size as iax_net_read() */
+	unsigned char buf[65536];	/* allocated on stack with same size as iax_net_read() */
 	struct iax_ies ies;
 	struct iax_session *cur;
 
 	if ((fh->type != AST_FRAME_IAX) || (subclass != IAX_COMMAND_TXCNT) || (!datalen)) {
-		return NULL; /* special handling for TXCNT only */
+		return NULL;			/* special handling for TXCNT only */
 	}
 	memcpy(buf, fh->iedata, datalen);	/* prepare local buf for iax_parse_ies() */
 
 	if (iax_parse_ies(&ies, buf, datalen)) {
-		return NULL;	/* Unable to parse IE's */
+		return NULL;			/* Unable to parse IE's */
 	}
 	if (!ies.transferid) {
-		return NULL;	/* TXCNT without proper IAX_IE_TRANSFERID */
+		return NULL;			/* TXCNT without proper IAX_IE_TRANSFERID */
 	}
-	iax_mutex_lock(session_mutex); 
-	for( cur=sessions; cur; cur=cur->next ) {
-		if ((cur->transferring) && (cur->transferid == (int)ies.transferid) &&
-		   	(cur->callno == dcallno) && (cur->transfercallno == callno)) {
+	iax_mutex_lock(session_mutex);
+	for (cur = sessions; cur; cur = cur->next) {
+		if ((cur->transferring) && (cur->transferid == (int) ies.transferid) && (cur->callno == dcallno) && (cur->transfercallno == callno)) {
 			/* We're transferring ---
-			 * 	skip address/port checking which would fail while remote peer behind symmetric NAT
-			 * 	verify transferid instead
+			 *  skip address/port checking which would fail while remote peer behind symmetric NAT
+			 *  verify transferid instead
 			 */
 			cur->transfer.sin_addr.s_addr = sin->sin_addr.s_addr;	/* setup for further handling */
 			cur->transfer.sin_port = sin->sin_port;
-			break;		
+			break;
 		}
 	}
-	iax_mutex_unlock(session_mutex); 
+	iax_mutex_unlock(session_mutex);
 	return cur;
 }
 
-struct iax_event *iax_net_process(unsigned char *buf, int len, struct sockaddr_in *sin)
-{
-	struct ast_iax2_full_hdr *fh = (struct ast_iax2_full_hdr *)buf;
-	struct ast_iax2_mini_hdr *mh = (struct ast_iax2_mini_hdr *)buf;
+struct iax_event *iax_net_process(unsigned char *buf, int len, struct sockaddr_in *sin) {
+	struct ast_iax2_full_hdr *fh = (struct ast_iax2_full_hdr *) buf;
+	struct ast_iax2_mini_hdr *mh = (struct ast_iax2_mini_hdr *) buf;
 	struct iax_session *session;
-	
+
 	if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
 		int subclass = uncompress_subclass(fh->csub);
 		int makenew = 0;
@@ -3066,17 +2936,17 @@
 		}
 		/* Only allow it to make new sessions on types where that makes sense */
 		if ((fh->type == AST_FRAME_IAX) && ((subclass == IAX_COMMAND_NEW) ||
-											(subclass == IAX_COMMAND_POKE) ||
-											(subclass == IAX_COMMAND_REGREL) ||
-											(subclass == IAX_COMMAND_REGREQ))) {
+											(subclass == IAX_COMMAND_POKE) || (subclass == IAX_COMMAND_REGREL) || (subclass == IAX_COMMAND_REGREQ))) {
 			makenew = 1;
 		}
 
 		/* We have a full header, process appropriately */
 		session = iax_find_session(sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, makenew);
 		if (!session)
-			session = iax_txcnt_session(fh, len-sizeof(struct ast_iax2_full_hdr), sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS);
-		if (session) 
+			session =
+				iax_txcnt_session(fh, len - sizeof(struct ast_iax2_full_hdr), sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL,
+								  ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS);
+		if (session)
 			return iax_header_to_event(session, fh, len - sizeof(struct ast_iax2_full_hdr), sin);
 		/* if we get here, the frame was invalid for some reason, we should probably send IAX_COMMAND_INVAL (as long as the subclass was not already IAX_COMMAND_INVAL) */
 		DEBU(G "No session?\n");
@@ -3096,13 +2966,12 @@
 	}
 }
 
-static struct iax_sched *iax_get_sched(time_in_ms_t time_in_ms)
-{
-	struct iax_sched *cur, *prev=NULL;
+static struct iax_sched *iax_get_sched(time_in_ms_t time_in_ms) {
+	struct iax_sched *cur, *prev = NULL;
 	iax_mutex_lock(sched_mutex);
 	cur = schedq;
 	/* Check the event schedule first. */
-	while(cur) {
+	while (cur) {
 		if (time_in_ms > cur->when) {
 			/* Take it out of the event queue */
 			if (prev) {
@@ -3119,20 +2988,19 @@
 	return NULL;
 }
 
-struct iax_event *iax_get_event(int blocking)
-{
+struct iax_event *iax_get_event(int blocking) {
 	struct iax_event *event;
 	struct iax_frame *frame;
 	time_in_ms_t time_in_ms;
 	struct iax_sched *cur;
-	
+
 	if (do_shutdown) {
 		__iax_shutdown();
 		do_shutdown = 0;
 		return NULL;
 	}
 	time_in_ms = current_time_in_ms();
-	while((cur = iax_get_sched(time_in_ms))) {
+	while ((cur = iax_get_sched(time_in_ms))) {
 
 		event = cur->event;
 		frame = cur->frame;
@@ -3144,15 +3012,15 @@
 				free(cur);
 				return event;
 			}
-		} else if(frame) {
+		} else if (frame) {
 			/* It's a frame, transmit it and schedule a retry */
 			if (frame->retries < 0) {
 				/* It's been acked.  No need to send it.   Destroy the old
 				   frame. If final, destroy the session. */
 				if (frame->final) {
-					iax_mutex_lock(session_mutex); 
+					iax_mutex_lock(session_mutex);
 					destroy_session(frame->session);
-					iax_mutex_unlock(session_mutex); 
+					iax_mutex_unlock(session_mutex);
 				}
 				if (frame->data)
 					free(frame->data);
@@ -3170,14 +3038,14 @@
 					/* We haven't been able to get an ACK on this packet. If a 
 					   final frame, destroy the session, otherwise, pass up timeout */
 					if (frame->final) {
-						iax_mutex_lock(session_mutex); 
+						iax_mutex_lock(session_mutex);
 						destroy_session(frame->session);
-						iax_mutex_unlock(session_mutex); 
+						iax_mutex_unlock(session_mutex);
 						if (frame->data)
 							free(frame->data);
 						free(frame);
 					} else {
-						event = (struct iax_event *)malloc(sizeof(struct iax_event));
+						event = (struct iax_event *) malloc(sizeof(struct iax_event));
 						if (event) {
 							event->etype = IAX_EVENT_TIMEOUT;
 							event->session = frame->session;
@@ -3201,7 +3069,7 @@
 						frame->retrytime = MAX_RETRY_TIME;
 				} else if (frame->retrytime > 1000)
 					frame->retrytime = 1000;
-				fh = (struct ast_iax2_full_hdr *)(frame->data);
+				fh = (struct ast_iax2_full_hdr *) (frame->data);
 				fh->dcallno = htons(IAX_FLAG_RETRANS | frame->dcallno);
 				iax_xmit_frame(frame);
 				/* Schedule another retransmission */
@@ -3209,7 +3077,7 @@
 				iax_sched_add(NULL, frame, NULL, NULL, frame->retrytime);
 			}
 		} else if (cur->func) {
-		    cur->func(cur->arg);
+			cur->func(cur->arg);
 		}
 		free(cur);
 	}
@@ -3217,20 +3085,20 @@
 #ifdef NEWJB
 	/* get jitterbuffer-scheduled events */
 	{
-	    struct iax_session *cur;
-	    jb_frame frame;
-		iax_mutex_lock(session_mutex); 
-	    for(cur=sessions; cur; cur=cur->next) {
+		struct iax_session *cur;
+		jb_frame frame;
+		iax_mutex_lock(session_mutex);
+		for (cur = sessions; cur; cur = cur->next) {
 			int ret;
 			time_in_ms_t now;
 			time_in_ms_t next;
 
 			now = time_in_ms - cur->rxcore;
-			if(now > (next = jb_next(cur->jb))) {
-				ret = jb_get(cur->jb,&frame,now,get_interp_len(cur->voiceformat));
-				switch(ret) {
+			if (now > (next = jb_next(cur->jb))) {
+				ret = jb_get(cur->jb, &frame, now, get_interp_len(cur->voiceformat));
+				switch (ret) {
 				case JB_OK:
-					//			    if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(cur->jb), next);
+					//              if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(cur->jb), next);
 					event = frame.data;
 					event = handle_event(event);
 					if (event) {
@@ -3239,25 +3107,25 @@
 					}
 					break;
 				case JB_INTERP:
-					//			    if(next + 20 != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(cur->jb), next);
+					//              if(next + 20 != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(cur->jb), next);
 					/* create an interpolation frame */
 					//fprintf(stderr, "Making Interpolation frame\n");
-					event = (struct iax_event *)malloc(sizeof(struct iax_event));
+					event = (struct iax_event *) malloc(sizeof(struct iax_event));
 					if (event) {
-						event->etype    = IAX_EVENT_VOICE;
+						event->etype = IAX_EVENT_VOICE;
 						event->subclass = cur->voiceformat;
-						event->ts	    = now; /* XXX: ??? applications probably ignore this anyway */
-						event->session  = cur;
-						event->datalen  = 0;
+						event->ts = now;	/* XXX: ??? applications probably ignore this anyway */
+						event->session = cur;
+						event->datalen = 0;
 						event = handle_event(event);
-						if(event) {
+						if (event) {
 							iax_mutex_unlock(session_mutex);
 							return event;
 						}
 					}
 					break;
 				case JB_DROP:
-					//			    if(next != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(cur->jb), next);
+					//              if(next != jb_next(cur->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(cur->jb), next);
 					iax_event_free(frame.data);
 					break;
 				case JB_NOFRAME:
@@ -3269,7 +3137,7 @@
 					break;
 				}
 			}
-	    }
+		}
 		iax_mutex_unlock(session_mutex);
 	}
 
@@ -3279,97 +3147,89 @@
 		/* Block until there is data if desired */
 		fd_set fds;
 		time_in_ms_t nextEventTime;
-		
+
 		FD_ZERO(&fds);
 		FD_SET(netfd, &fds);
 
-		nextEventTime = iax_time_to_next_event(); 
-		if(nextEventTime < 0 && blocking > 1) {
+		nextEventTime = iax_time_to_next_event();
+		if (nextEventTime < 0 && blocking > 1) {
 			nextEventTime = blocking;
 		}
-		if(nextEventTime < 0) 
+		if (nextEventTime < 0)
 			select(netfd + 1, &fds, NULL, NULL, NULL);
-		else 
-		{ 
-			struct timeval nextEvent; 
+		else {
+			struct timeval nextEvent;
 
-			nextEvent.tv_sec = (long)(nextEventTime / 1000); 
-			nextEvent.tv_usec = (long)((nextEventTime % 1000) * 1000);
+			nextEvent.tv_sec = (long) (nextEventTime / 1000);
+			nextEvent.tv_usec = (long) ((nextEventTime % 1000) * 1000);
 
-			select(netfd + 1, &fds, NULL, NULL, &nextEvent); 
-		} 
+			select(netfd + 1, &fds, NULL, NULL, &nextEvent);
+		}
 
 	}
 	event = iax_net_read();
-	
+
 	return handle_event(event);
 }
 
-struct sockaddr_in iax_get_peer_addr(struct iax_session *session)
-{
+struct sockaddr_in iax_get_peer_addr(struct iax_session *session) {
 	return session->peeraddr;
 }
 
-char *iax_get_peer_ip(struct iax_session *session)
-{
+char *iax_get_peer_ip(struct iax_session *session) {
 	return inet_ntoa(session->peeraddr.sin_addr);
 }
 
-char *iax_event_get_apparent_ip(struct iax_event *event)
-{
+char *iax_event_get_apparent_ip(struct iax_event *event) {
 	return inet_ntoa(event->ies.apparent_addr->sin_addr);
 }
 
-void iax_session_destroy(struct iax_session **session) 
-{
-	iax_mutex_lock(session_mutex); 
+void iax_session_destroy(struct iax_session **session) {
+	iax_mutex_lock(session_mutex);
 	destroy_session(*session);
 	*session = NULL;
-	iax_mutex_unlock(session_mutex); 
+	iax_mutex_unlock(session_mutex);
 }
 
-void iax_event_free(struct iax_event *event)
-{
+void iax_event_free(struct iax_event *event) {
 	/* 
 	   We gave the user a chance to play with the session now we need to destroy it 
 	   if you are not calling this function on every event you read you are now going
 	   to leak sessions as well as events!
-	*/
-	switch(event->etype) {
+	 */
+	switch (event->etype) {
 	case IAX_EVENT_REJECT:
 	case IAX_EVENT_HANGUP:
 		/* Destroy this session -- it's no longer valid */
-		if (event->session) { /* maybe the user did it already */
-			iax_mutex_lock(session_mutex); 
+		if (event->session) {	/* maybe the user did it already */
+			iax_mutex_lock(session_mutex);
 			destroy_session(event->session);
-			iax_mutex_unlock(session_mutex); 
+			iax_mutex_unlock(session_mutex);
 		}
 		break;
 	}
 	free(event);
 }
 
-int iax_get_fd(void) 
-{
+int iax_get_fd(void) {
 	/* Return our network file descriptor.  The client can select on this (probably with other
 	   things, or can add it to a network add sort of gtk_input_add for example */
 	return netfd;
 }
 
-int iax_quelch_moh(struct iax_session *session, int MOH)
-{
-	
-	struct iax_ie_data ied;			//IE Data Structure (Stuff To Send)
-	memset(&ied, 0, sizeof(ied));	
-	
+int iax_quelch_moh(struct iax_session *session, int MOH) {
+
+	struct iax_ie_data ied;		//IE Data Structure (Stuff To Send)
+	memset(&ied, 0, sizeof(ied));
+
 	// You can't quelch the quelched
 	if (session->quelch == 1)
 		return -1;
-		
+
 	if (MOH) {
 		iax_ie_append(&ied, IAX_IE_MUSICONHOLD);
 		session->transfer_moh = 1;
 	}
-		
+
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_QUELCH, 0, ied.buf, ied.pos, -1);
 }

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax2-parser.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax2-parser.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/iax2-parser.c	Tue May 27 07:24:06 2008
@@ -40,12 +40,12 @@
 #ifdef ALIGN32
 static unsigned int get_uint32(unsigned char *p)
 {
-  return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+	return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
 }
 
 static unsigned short get_uint16(unsigned char *p)
 {
-  return (p[0] << 8) | p[1] ;
+	return (p[0] << 8) | p[1];
 }
 
 #else
@@ -64,8 +64,8 @@
 	fprintf(stderr, "WARNING: %s", str);
 }
 
-static void (*outputf)(const char *str) = internaloutput;
-static void (*errorf)(const char *str) = internalerror;
+static void (*outputf) (const char *str) = internaloutput;
+static void (*errorf) (const char *str) = internalerror;
 
 static void dump_addr(char *output, int maxlen, void *value, int len)
 {
@@ -83,21 +83,21 @@
 	maxlen--;
 	if (maxlen > len)
 		maxlen = len;
-	strncpy(output,value, maxlen);
+	strncpy(output, value, maxlen);
 	output[maxlen] = '\0';
 }
 
 static void dump_int(char *output, int maxlen, void *value, int len)
 {
-	if (len == (int)sizeof(unsigned int))
-		snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_uint32(value)));
+	if (len == (int) sizeof(unsigned int))
+		snprintf(output, maxlen, "%lu", (unsigned long) ntohl(get_uint32(value)));
 	else
 		snprintf(output, maxlen, "Invalid INT");
 }
 
 static void dump_short(char *output, int maxlen, void *value, int len)
 {
-	if (len == (int)sizeof(unsigned short))
+	if (len == (int) sizeof(unsigned short))
 		snprintf(output, maxlen, "%d", ntohs(get_uint16(value)));
 	else
 		snprintf(output, maxlen, "Invalid SHORT");
@@ -105,8 +105,8 @@
 
 static void dump_byte(char *output, int maxlen, void *value, int len)
 {
-	if (len == (int)sizeof(unsigned char))
-		snprintf(output, maxlen, "%d", *((unsigned char *)value));
+	if (len == (int) sizeof(unsigned char))
+		snprintf(output, maxlen, "%d", *((unsigned char *) value));
 	else
 		snprintf(output, maxlen, "Invalid BYTE");
 }
@@ -115,7 +115,7 @@
 static void dump_ipaddr(char *output, int maxlen, void *value, int len)
 {
 	struct sockaddr_in sin;
-	if (len == (int)sizeof(unsigned int)) {
+	if (len == (int) sizeof(unsigned int)) {
 		memcpy(&sin.sin_addr, value, len);
 		snprintf(output, maxlen, "%s", inet_ntoa(sin.sin_addr));
 	} else
@@ -124,9 +124,8 @@
 
 static void dump_prov_flags(char *output, int maxlen, void *value, int len)
 {
-	if (len == (int)sizeof(unsigned int))
-		snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_uint32(value)),
-			"PROVISION_PARSING_NOT_IMPLEMENTED");
+	if (len == (int) sizeof(unsigned int))
+		snprintf(output, maxlen, "%lu (%s)", (unsigned long) ntohl(get_uint32(value)), "PROVISION_PARSING_NOT_IMPLEMENTED");
 	else
 		snprintf(output, maxlen, "Invalid INT");
 }
@@ -134,10 +133,10 @@
 
 static void dump_samprate(char *output, int maxlen, void *value, int len)
 {
-	char tmp[256]="";
+	char tmp[256] = "";
 	int sr;
-	if (len == (int)sizeof(unsigned short)) {
-		sr = ntohs(*((unsigned short *)value));
+	if (len == (int) sizeof(unsigned short)) {
+		sr = ntohs(*((unsigned short *) value));
 		if (sr & IAX_RATE_8KHZ)
 			strcat(tmp, ",8khz");
 		if (sr & IAX_RATE_11KHZ)
@@ -170,61 +169,61 @@
 static struct iax2_ie {
 	int ie;
 	char *name;
-	void (*dump)(char *output, int maxlen, void *value, int len);
+	void (*dump) (char *output, int maxlen, void *value, int len);
 } ies[] = {
-	{ IAX_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string },
-	{ IAX_IE_CALLING_NUMBER, "CALLING NUMBER", dump_string },
-	{ IAX_IE_CALLING_ANI, "ANI", dump_string },
-	{ IAX_IE_CALLING_NAME, "CALLING NAME", dump_string },
-	{ IAX_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string },
-	{ IAX_IE_USERNAME, "USERNAME", dump_string },
-	{ IAX_IE_PASSWORD, "PASSWORD", dump_string },
-	{ IAX_IE_CAPABILITY, "CAPABILITY", dump_int },
-	{ IAX_IE_FORMAT, "FORMAT", dump_int },
-	{ IAX_IE_LANGUAGE, "LANGUAGE", dump_string },
-	{ IAX_IE_CODEC_PREFS, "CODEC_PREFS", dump_string },
-	{ IAX_IE_VERSION, "VERSION", dump_short },
-	{ IAX_IE_ADSICPE, "ADSICPE", dump_short },
-	{ IAX_IE_DNID, "DNID", dump_string },
-	{ IAX_IE_AUTHMETHODS, "AUTHMETHODS", dump_short },
-	{ IAX_IE_CHALLENGE, "CHALLENGE", dump_string },
-	{ IAX_IE_MD5_RESULT, "MD5 RESULT", dump_string },
-	{ IAX_IE_RSA_RESULT, "RSA RESULT", dump_string },
-	{ IAX_IE_APPARENT_ADDR, "APPARENT ADDRESS", dump_addr },
-	{ IAX_IE_REFRESH, "REFRESH", dump_short },
-	{ IAX_IE_DPSTATUS, "DIALPLAN STATUS", dump_short },
-	{ IAX_IE_CALLNO, "CALL NUMBER", dump_short },
-	{ IAX_IE_CAUSE, "CAUSE", dump_string },
-	{ IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte },
-	{ IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short },
-	{ IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" },
-	{ IAX_IE_TRANSFERID, "TRANSFER ID", dump_int },
-	{ IAX_IE_RDNIS, "REFERRING DNIS", dump_string },
-	{ IAX_IE_PROVISIONING, "PROVISIONING", dump_prov },
-	{ IAX_IE_AESPROVISIONING, "AES PROVISIONG" },
-	{ IAX_IE_DATETIME, "DATE TIME", dump_int },
-	{ IAX_IE_DEVICETYPE, "DEVICE TYPE", dump_string },
-	{ IAX_IE_SERVICEIDENT, "SERVICE IDENT", dump_string },
-	{ IAX_IE_FIRMWAREVER, "FIRMWARE VER", dump_short },
-	{ IAX_IE_FWBLOCKDESC, "FW BLOCK DESC", dump_int },
-	{ IAX_IE_FWBLOCKDATA, "FW BLOCK DATA" },
-	{ IAX_IE_PROVVER, "PROVISIONG VER", dump_int },
-	{ IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte },
-	{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
-	{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
-	{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
-	{ IAX_IE_RR_JITTER, "RR_JITTER", dump_int },
-	{ IAX_IE_RR_LOSS, "RR_LOSS", dump_int },
-	{ IAX_IE_RR_PKTS, "RR_PKTS", dump_int },
-	{ IAX_IE_RR_DELAY, "RR_DELAY", dump_short },
-	{ IAX_IE_RR_DROPPED, "RR_DROPPED", dump_int },
-	{ IAX_IE_RR_OOO, "RR_OOO", dump_int },
-};
+	{
+	IAX_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string}, {
+	IAX_IE_CALLING_NUMBER, "CALLING NUMBER", dump_string}, {
+	IAX_IE_CALLING_ANI, "ANI", dump_string}, {
+	IAX_IE_CALLING_NAME, "CALLING NAME", dump_string}, {
+	IAX_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string}, {
+	IAX_IE_USERNAME, "USERNAME", dump_string}, {
+	IAX_IE_PASSWORD, "PASSWORD", dump_string}, {
+	IAX_IE_CAPABILITY, "CAPABILITY", dump_int}, {
+	IAX_IE_FORMAT, "FORMAT", dump_int}, {
+	IAX_IE_LANGUAGE, "LANGUAGE", dump_string}, {
+	IAX_IE_CODEC_PREFS, "CODEC_PREFS", dump_string}, {
+	IAX_IE_VERSION, "VERSION", dump_short}, {
+	IAX_IE_ADSICPE, "ADSICPE", dump_short}, {
+	IAX_IE_DNID, "DNID", dump_string}, {
+	IAX_IE_AUTHMETHODS, "AUTHMETHODS", dump_short}, {
+	IAX_IE_CHALLENGE, "CHALLENGE", dump_string}, {
+	IAX_IE_MD5_RESULT, "MD5 RESULT", dump_string}, {
+	IAX_IE_RSA_RESULT, "RSA RESULT", dump_string}, {
+	IAX_IE_APPARENT_ADDR, "APPARENT ADDRESS", dump_addr}, {
+	IAX_IE_REFRESH, "REFRESH", dump_short}, {
+	IAX_IE_DPSTATUS, "DIALPLAN STATUS", dump_short}, {
+	IAX_IE_CALLNO, "CALL NUMBER", dump_short}, {
+	IAX_IE_CAUSE, "CAUSE", dump_string}, {
+	IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte}, {
+	IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short}, {
+	IAX_IE_AUTOANSWER, "AUTO ANSWER REQ"}, {
+	IAX_IE_TRANSFERID, "TRANSFER ID", dump_int}, {
+	IAX_IE_RDNIS, "REFERRING DNIS", dump_string}, {
+	IAX_IE_PROVISIONING, "PROVISIONING", dump_prov}, {
+	IAX_IE_AESPROVISIONING, "AES PROVISIONG"}, {
+	IAX_IE_DATETIME, "DATE TIME", dump_int}, {
+	IAX_IE_DEVICETYPE, "DEVICE TYPE", dump_string}, {
+	IAX_IE_SERVICEIDENT, "SERVICE IDENT", dump_string}, {
+	IAX_IE_FIRMWAREVER, "FIRMWARE VER", dump_short}, {
+	IAX_IE_FWBLOCKDESC, "FW BLOCK DESC", dump_int}, {
+	IAX_IE_FWBLOCKDATA, "FW BLOCK DATA"}, {
+	IAX_IE_PROVVER, "PROVISIONG VER", dump_int}, {
+	IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte}, {
+	IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte}, {
+	IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short}, {
+	IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate}, {
+	IAX_IE_RR_JITTER, "RR_JITTER", dump_int}, {
+	IAX_IE_RR_LOSS, "RR_LOSS", dump_int}, {
+	IAX_IE_RR_PKTS, "RR_PKTS", dump_int}, {
+	IAX_IE_RR_DELAY, "RR_DELAY", dump_short}, {
+	IAX_IE_RR_DROPPED, "RR_DROPPED", dump_int}, {
+IAX_IE_RR_OOO, "RR_OOO", dump_int},};
 
 const char *iax_ie2str(int ie)
 {
 	int x;
-	for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
+	for (x = 0; x < (int) sizeof(ies) / (int) sizeof(ies[0]); x++) {
 		if (ies[x].ie == ie)
 			return ies[x].name;
 	}
@@ -240,22 +239,25 @@
 	char tmp[256];
 	if (len < 2)
 		return;
-	strcpy(output, "\n"); 
-	maxlen -= (int)strlen(output); output += strlen(output);
-	while(len > 2) {
+	strcpy(output, "\n");
+	maxlen -= (int) strlen(output);
+	output += strlen(output);
+	while (len > 2) {
 		ie = iedata[0];
 		ielen = iedata[1];
-		if (ielen + 2> len) {
-			snprintf(tmp, (int)sizeof(tmp), "Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\n", ielen + 2, len);
+		if (ielen + 2 > len) {
+			snprintf(tmp, (int) sizeof(tmp), "Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\n", ielen + 2, len);
 			strncpy(output, tmp, maxlen - 1);
-			maxlen -= (int)strlen(output); output += strlen(output);
+			maxlen -= (int) strlen(output);
+			output += strlen(output);
 			return;
 		}
 		found = 0;
 		if (!found) {
-			snprintf(tmp, (int)sizeof(tmp), "       Unknown Prov IE %03d  : Present\n", ie);
+			snprintf(tmp, (int) sizeof(tmp), "       Unknown Prov IE %03d  : Present\n", ie);
 			strncpy(output, tmp, maxlen - 1);
-			maxlen -= (int)strlen(output); output += strlen(output);
+			maxlen -= (int) strlen(output);
+			output += strlen(output);
 		}
 		iedata += (2 + ielen);
 		len -= (2 + ielen);
@@ -272,34 +274,34 @@
 	char tmp[1024];
 	if (len < 2)
 		return;
-	while(len > 2) {
+	while (len > 2) {
 		ie = iedata[0];
 		ielen = iedata[1];
-		if (ielen + 2> len) {
-			snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
+		if (ielen + 2 > len) {
+			snprintf(tmp, (int) sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
 			outputf(tmp);
 			return;
 		}
 		found = 0;
-		for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
+		for (x = 0; x < (int) sizeof(ies) / (int) sizeof(ies[0]); x++) {
 			if (ies[x].ie == ie) {
 				if (ies[x].dump) {
-					ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
-					snprintf(tmp, (int)sizeof(tmp), "   %-15.15s : %s\n", ies[x].name, interp);
+					ies[x].dump(interp, (int) sizeof(interp), iedata + 2, ielen);
+					snprintf(tmp, (int) sizeof(tmp), "   %-15.15s : %s\n", ies[x].name, interp);
 					outputf(tmp);
 				} else {
 					if (ielen)
-						snprintf(interp, (int)sizeof(interp), "%d bytes", ielen);
+						snprintf(interp, (int) sizeof(interp), "%d bytes", ielen);
 					else
 						strcpy(interp, "Present");
-					snprintf(tmp, (int)sizeof(tmp), "   %-15.15s : %s\n", ies[x].name, interp);
+					snprintf(tmp, (int) sizeof(tmp), "   %-15.15s : %s\n", ies[x].name, interp);
 					outputf(tmp);
 				}
 				found++;
 			}
 		}
 		if (!found) {
-			snprintf(tmp, (int)sizeof(tmp), "   Unknown IE %03d  : Present\n", ie);
+			snprintf(tmp, (int) sizeof(tmp), "   Unknown IE %03d  : Present\n", ie);
 			outputf(tmp);
 		}
 		iedata += (2 + ielen);
@@ -319,7 +321,8 @@
 		"NULL   ",
 		"IAX    ",
 		"TEXT   ",
-		"IMAGE  " };
+		"IMAGE  "
+	};
 	const char *iaxs[] = {
 		"(0?)",
 		"NEW    ",
@@ -368,7 +371,8 @@
 		"ANSWER ",
 		"BUSY   ",
 		"TKOFFHK ",
-		"OFFHOOK" };
+		"OFFHOOK"
+	};
 	struct ast_iax2_full_hdr *fh;
 	char retries[20];
 	char class2[20];
@@ -379,7 +383,7 @@
 
 	if (f) {
 		fh = f->data;
-		snprintf(retries, (int)sizeof(retries), "%03d", f->retries);
+		snprintf(retries, (int) sizeof(retries), "%03d", f->retries);
 	} else {
 		fh = fhi;
 		if (ntohs(fh->dcallno) & IAX_FLAG_RETRANS)
@@ -391,43 +395,41 @@
 		/* Don't mess with mini-frames */
 		return;
 	}
-	if (fh->type > ((int)sizeof(frames)/(int)sizeof(char *)) - 1) {
-		snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type);
+	if (fh->type > ((int) sizeof(frames) / (int) sizeof(char *)) - 1) {
+		snprintf(class2, (int) sizeof(class2), "(%d?)", fh->type);
 		class = class2;
 	} else {
-		class = frames[(int)fh->type];
+		class = frames[(int) fh->type];
 	}
 	if (fh->type == AST_FRAME_DTMF) {
 		sprintf(subclass2, "%c", fh->csub);
 		subclass = subclass2;
 	} else if (fh->type == AST_FRAME_IAX) {
-		if (fh->csub >= (int)sizeof(iaxs)/(int)sizeof(iaxs[0])) {
-			snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
+		if (fh->csub >= (int) sizeof(iaxs) / (int) sizeof(iaxs[0])) {
+			snprintf(subclass2, (int) sizeof(subclass2), "(%d?)", fh->csub);
 			subclass = subclass2;
 		} else {
-			subclass = iaxs[(int)fh->csub];
+			subclass = iaxs[(int) fh->csub];
 		}
 	} else if (fh->type == AST_FRAME_CONTROL) {
-		if (fh->csub > (int)sizeof(cmds)/(int)sizeof(char *)) {
-			snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
+		if (fh->csub > (int) sizeof(cmds) / (int) sizeof(char *)) {
+			snprintf(subclass2, (int) sizeof(subclass2), "(%d?)", fh->csub);
 			subclass = subclass2;
 		} else {
-			subclass = cmds[(int)fh->csub];
+			subclass = cmds[(int) fh->csub];
 		}
 	} else {
-		snprintf(subclass2, (int)sizeof(subclass2), "%d", fh->csub);
+		snprintf(subclass2, (int) sizeof(subclass2), "%d", fh->csub);
 		subclass = subclass2;
 	}
-snprintf(tmp, (int)sizeof(tmp), 
-"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
-	(rx ? "Rx" : "Tx"),
-	retries, fh->oseqno, fh->iseqno, class, subclass);
+	snprintf(tmp, (int) sizeof(tmp),
+			 "%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
+			 (rx ? "Rx" : "Tx"), retries, fh->oseqno, fh->iseqno, class, subclass);
 	outputf(tmp);
-snprintf(tmp, (int)sizeof(tmp), 
-"   Timestamp: %05lums  SCall: %5.5d  DCall: %5.5d [%s:%d]\n",
-	(unsigned long)ntohl(fh->ts),
-	ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
-		inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
+	snprintf(tmp, (int) sizeof(tmp),
+			 "   Timestamp: %05lums  SCall: %5.5d  DCall: %5.5d [%s:%d]\n",
+			 (unsigned long) ntohl(fh->ts),
+			 ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
 	outputf(tmp);
 	if (fh->type == AST_FRAME_IAX)
 		dump_ies(fh->iedata, datalen);
@@ -436,13 +438,14 @@
 int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
 {
 	char tmp[256];
-	if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
-		snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", iax_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
+	if (datalen > ((int) sizeof(ied->buf) - ied->pos)) {
+		snprintf(tmp, (int) sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", iax_ie2str(ie), ie, datalen,
+				 (int) sizeof(ied->buf) - ied->pos);
 		errorf(tmp);
 		return -1;
 	}
 	ied->buf[ied->pos++] = ie;
-	ied->buf[ied->pos++] = (unsigned char)datalen;
+	ied->buf[ied->pos++] = (unsigned char) datalen;
 	memcpy(ied->buf + ied->pos, data, datalen);
 	ied->pos += datalen;
 	return 0;
@@ -450,26 +453,26 @@
 
 int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
 {
-	return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
+	return iax_ie_append_raw(ied, ie, sin, (int) sizeof(struct sockaddr_in));
 }
 
-int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value) 
+int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
 {
 	unsigned int newval;
 	newval = htonl(value);
-	return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
+	return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
 }
 
-int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value) 
+int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
 {
 	unsigned short newval;
 	newval = htons(value);
-	return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
+	return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
 }
 
 int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const unsigned char *str)
 {
-	return iax_ie_append_raw(ied, ie, str, (int)strlen((char *) str));
+	return iax_ie_append_raw(ied, ie, str, (int) strlen((char *) str));
 }
 
 int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
@@ -477,17 +480,17 @@
 	return iax_ie_append_raw(ied, ie, &dat, 1);
 }
 
-int iax_ie_append(struct iax_ie_data *ied, unsigned char ie) 
+int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
 {
 	return iax_ie_append_raw(ied, ie, NULL, 0);
 }
 
-void iax_set_output(void (*func)(const char *))
+void iax_set_output(void (*func) (const char *))
 {
 	outputf = func;
 }
 
-void iax_set_error(void (*func)(const char *))
+void iax_set_error(void (*func) (const char *))
 {
 	errorf = func;
 }
@@ -498,21 +501,21 @@
 	int len;
 	int ie;
 	char tmp[256];
-	memset(my_ies, 0, (int)sizeof(struct iax_ies));
+	memset(my_ies, 0, (int) sizeof(struct iax_ies));
 	my_ies->msgcount = -1;
 	my_ies->firmwarever = -1;
 	my_ies->calling_ton = -1;
 	my_ies->calling_tns = -1;
 	my_ies->calling_pres = -1;
 	my_ies->samprate = IAX_RATE_8KHZ;
-	while(datalen >= 2) {
+	while (datalen >= 2) {
 		ie = data[0];
 		len = data[1];
 		if (len > datalen - 2) {
 			errorf("Information element length exceeds message size\n");
 			return -1;
 		}
-		switch(ie) {
+		switch (ie) {
 		case IAX_IE_CALLED_NUMBER:
 			my_ies->called_number = (char *) data + 2;
 			break;
@@ -535,15 +538,15 @@
 			my_ies->password = (char *) data + 2;
 			break;
 		case IAX_IE_CAPABILITY:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else
 				my_ies->capability = ntohl(get_uint32(data + 2));
 			break;
 		case IAX_IE_FORMAT:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else
 				my_ies->format = ntohl(get_uint32(data + 2));
@@ -555,22 +558,22 @@
 			my_ies->codec_prefs = (char *) data + 2;
 			break;
 		case IAX_IE_VERSION:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp),  "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->version = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_ADSICPE:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->adsicpe = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_SAMPLINGRATE:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->samprate = ntohs(get_uint16(data + 2));
@@ -582,8 +585,8 @@
 			my_ies->rdnis = (char *) data + 2;
 			break;
 		case IAX_IE_AUTHMETHODS:
-			if (len != (int)sizeof(unsigned short))  {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->authmethods = ntohs(get_uint16(data + 2));
@@ -598,25 +601,25 @@
 			my_ies->rsa_result = (char *) data + 2;
 			break;
 		case IAX_IE_APPARENT_ADDR:
-			my_ies->apparent_addr = ((struct sockaddr_in *)(data + 2));
+			my_ies->apparent_addr = ((struct sockaddr_in *) (data + 2));
 			break;
 		case IAX_IE_REFRESH:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp),  "Expecting refresh to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->refresh = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_DPSTATUS:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp),  "Expecting dpstatus to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->dpstatus = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_CALLNO:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp),  "Expecting callno to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
 				my_ies->callno = ntohs(get_uint16(data + 2));
@@ -626,7 +629,7 @@
 			break;
 		case IAX_IE_CAUSECODE:
 			if (len != 1) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting causecode to be single byte but was %d\n", len);
+				snprintf(tmp, (int) sizeof(tmp), "Expecting causecode to be single byte but was %d\n", len);
 				errorf(tmp);
 			} else {
 				my_ies->causecode = data[2];
@@ -636,16 +639,16 @@
 			if (len == 1)
 				my_ies->iax_unknown = data[2];
 			else {
-				snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
+				snprintf(tmp, (int) sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
 				errorf(tmp);
 			}
 			break;
 		case IAX_IE_MSGCOUNT:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
-				my_ies->msgcount = ntohs(get_uint16(data + 2));	
+				my_ies->msgcount = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_AUTOANSWER:
 			my_ies->autoanswer = 1;
@@ -654,25 +657,25 @@
 			my_ies->musiconhold = 1;
 			break;
 		case IAX_IE_TRANSFERID:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else
 				my_ies->transferid = ntohl(get_uint32(data + 2));
 			break;
 		case IAX_IE_DATETIME:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else
 				my_ies->datetime = ntohl(get_uint32(data + 2));
 			break;
 		case IAX_IE_FIRMWAREVER:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
-				my_ies->firmwarever = ntohs(get_uint16(data + 2));	
+				my_ies->firmwarever = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_DEVICETYPE:
 			my_ies->devicetype = (char *) data + 2;
@@ -681,19 +684,19 @@
 			my_ies->serviceident = (char *) data + 2;
 			break;
 		case IAX_IE_FWBLOCKDESC:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else
 				my_ies->fwdesc = ntohl(get_uint32(data + 2));
 			break;
 		case IAX_IE_FWBLOCKDATA:
 			my_ies->fwdata = data + 2;
-			my_ies->fwdatalen = (unsigned char)len;
+			my_ies->fwdatalen = (unsigned char) len;
 			break;
 		case IAX_IE_PROVVER:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->provverpres = 1;
@@ -704,7 +707,7 @@
 			if (len == 1)
 				my_ies->calling_pres = data[2];
 			else {
-				snprintf(tmp, (int)sizeof(tmp), "Expected single byte callingpres, but was %d long\n", len);
+				snprintf(tmp, (int) sizeof(tmp), "Expected single byte callingpres, but was %d long\n", len);
 				errorf(tmp);
 			}
 			break;
@@ -712,67 +715,67 @@
 			if (len == 1)
 				my_ies->calling_ton = data[2];
 			else {
-				snprintf(tmp, (int)sizeof(tmp), "Expected single byte callington, but was %d long\n", len);
+				snprintf(tmp, (int) sizeof(tmp), "Expected single byte callington, but was %d long\n", len);
 				errorf(tmp);
 			}
 			break;
 		case IAX_IE_CALLINGTNS:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else
-				my_ies->calling_tns = ntohs(get_uint16(data + 2));	
+				my_ies->calling_tns = ntohs(get_uint16(data + 2));
 			break;
 		case IAX_IE_RR_JITTER:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_jitter = ntohl(get_uint32(data + 2));
 			}
 			break;
 		case IAX_IE_RR_LOSS:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_loss = ntohl(get_uint32(data + 2));
 			}
 			break;
 		case IAX_IE_RR_PKTS:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_pkts = ntohl(get_uint32(data + 2));
 			}
 			break;
 		case IAX_IE_RR_DELAY:
-			if (len != (int)sizeof(unsigned short)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+			if (len != (int) sizeof(unsigned short)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_delay = ntohs(get_uint16(data + 2));
 			}
 			break;
 		case IAX_IE_RR_DROPPED:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_dropped = ntohl(get_uint32(data + 2));
 			}
 			break;
 		case IAX_IE_RR_OOO:
-			if (len != (int)sizeof(unsigned int)) {
-				snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
+			if (len != (int) sizeof(unsigned int)) {
+				snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
 				errorf(tmp);
 			} else {
 				my_ies->rr_ooo = ntohl(get_uint32(data + 2));
 			}
 			break;
 		default:
-			snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
+			snprintf(tmp, (int) sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
 			outputf(tmp);
 		}
 		/* Overwrite information element with 0, to null terminate previous portion */
@@ -793,20 +796,20 @@
 {
 	fr->af.frametype = f->frametype;
 	fr->af.subclass = f->subclass;
-	fr->af.mallocd = 0;				/* Our frame is static relative to the container */
+	fr->af.mallocd = 0;			/* Our frame is static relative to the container */
 	fr->af.datalen = f->datalen;
 	fr->af.samples = f->samples;
 	fr->af.offset = AST_FRIENDLY_OFFSET;
 	fr->af.src = f->src;
 	fr->af.data = fr->afdata;
-	if (fr->af.datalen) 
+	if (fr->af.datalen)
 		memcpy(fr->af.data, f->data, fr->af.datalen);
 }
 
 struct iax_frame *iax_frame_new(int direction, int datalen)
 {
 	struct iax_frame *fr;
-	fr = malloc((int)sizeof(struct iax_frame) + datalen);
+	fr = malloc((int) sizeof(struct iax_frame) + datalen);
 	if (fr) {
 		fr->direction = direction;
 		fr->retrans = -1;
@@ -835,6 +838,15 @@
 	frame_count--;
 }
 
-int iax_get_frames(void) { return frame_count; }
-int iax_get_iframes(void) { return iframes; }
-int iax_get_oframes(void) { return oframes; }
+int iax_get_frames(void)
+{
+	return frame_count;
+}
+int iax_get_iframes(void)
+{
+	return iframes;
+}
+int iax_get_oframes(void)
+{
+	return oframes;
+}

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/jitterbuf.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/jitterbuf.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/jitterbuf.c	Tue May 27 07:24:06 2008
@@ -32,9 +32,9 @@
 #define jb_dbg if (dbgf) dbgf
 
 #ifdef DEEP_DEBUG
-  #define jb_dbg2 if (dbgf) dbgf
+#define jb_dbg2 if (dbgf) dbgf
 #else
-  #define jb_dbg2 if (0) dbgf
+#define jb_dbg2 if (0) dbgf
 #endif
 
 #else
@@ -60,17 +60,17 @@
 	dbgf = dbg;
 }
 
-static void increment_losspct(jitterbuf *jb)
+static void increment_losspct(jitterbuf * jb)
 {
-	jb->info.losspct = (100000 + 499 * jb->info.losspct)/500;
+	jb->info.losspct = (100000 + 499 * jb->info.losspct) / 500;
 }
 
-static void decrement_losspct(jitterbuf *jb)
+static void decrement_losspct(jitterbuf * jb)
 {
-	jb->info.losspct = (499 * jb->info.losspct)/500;
+	jb->info.losspct = (499 * jb->info.losspct) / 500;
 }
 
-void jb_reset(jitterbuf *jb)
+void jb_reset(jitterbuf * jb)
 {
 	/* only save settings */
 	jb_conf s = jb->info.conf;
@@ -82,11 +82,12 @@
 	jb->info.silence_begin_ts = -1;
 }
 
-jitterbuf * jb_new()
+jitterbuf *jb_new()
 {
-	jitterbuf *jb = (jitterbuf *)malloc(sizeof(*jb));
+	jitterbuf *jb = (jitterbuf *) malloc(sizeof(*jb));
 
-	if (!jb) return NULL;
+	if (!jb)
+		return NULL;
 
 	jb->info.conf.target_extra = JB_TARGET_EXTRA;
 
@@ -95,7 +96,7 @@
 	return jb;
 }
 
-void jb_destroy(jitterbuf *jb)
+void jb_destroy(jitterbuf * jb)
 {
 	jb_frame *frame;
 
@@ -116,7 +117,7 @@
 #if 0
 static int longcmp(const void *a, const void *b)
 {
-	return *(long *)a - *(long *)b;
+	return *(long *) a - *(long *) b;
 }
 #endif
 
@@ -124,7 +125,7 @@
 /* maybe later we can make the history buckets variable size, or something? */
 /* drop parameter determines whether we will drop outliers to minimize
  * delay */
-static int history_put(jitterbuf *jb, time_in_ms_t ts, time_in_ms_t now)
+static int history_put(jitterbuf * jb, time_in_ms_t ts, time_in_ms_t now)
 {
 	time_in_ms_t delay = now - (ts - jb->info.resync_offset);
 	time_in_ms_t threshold = 2 * jb->info.jitter + jb->info.conf.resync_threshold;
@@ -144,9 +145,10 @@
 				jb->hist_ptr = 0;
 				jb->hist_maxbuf_valid = 0;
 
-				jb_warn("Resyncing the jb. last_delay %ld, this delay %ld, threshold %ld, new offset %ld\n", jb->info.last_delay, delay, threshold, ts - now);
+				jb_warn("Resyncing the jb. last_delay %ld, this delay %ld, threshold %ld, new offset %ld\n", jb->info.last_delay, delay, threshold,
+						ts - now);
 				jb->info.resync_offset = ts - now;
-				jb->info.last_delay = delay = 0; /* after resync, frame is right on time */
+				jb->info.last_delay = delay = 0;	/* after resync, frame is right on time */
 			} else {
 				return -1;
 			}
@@ -176,18 +178,18 @@
 		goto invalidate;
 
 	/* if the new delay would go into min */
-	if (delay < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
+	if (delay < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1])
 		goto invalidate;
 
 	/* or max.. */
-	if (delay > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
+	if (delay > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1])
 		goto invalidate;
 
 	/* or the kicked delay would be in min */
-	if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
+	if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1])
 		goto invalidate;
 
-	if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
+	if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1])
 		goto invalidate;
 
 	/* if we got here, we don't need to invalidate, 'cause this delay didn't
@@ -196,21 +198,21 @@
 	/* end optimization */
 
 
-invalidate:
+  invalidate:
 	jb->hist_maxbuf_valid = 0;
 	return 0;
 }
 
-static void history_calc_maxbuf(jitterbuf *jb)
+static void history_calc_maxbuf(jitterbuf * jb)
 {
-	int i,j;
+	int i, j;
 
 	if (jb->hist_ptr == 0)
 		return;
 
 
 	/* initialize maxbuf/minbuf to the latest value */
-	for (i=0;i<JB_HISTORY_MAXBUF_SZ;i++) {
+	for (i = 0; i < JB_HISTORY_MAXBUF_SZ; i++) {
 		/*
 		 * jb->hist_maxbuf[i] = jb->history[(jb->hist_ptr-1) % JB_HISTORY_SZ];
 		 * jb->hist_minbuf[i] = jb->history[(jb->hist_ptr-1) % JB_HISTORY_SZ];
@@ -225,14 +227,14 @@
 	/* start at the beginning, or JB_HISTORY_SZ frames ago */
 	i = (jb->hist_ptr > JB_HISTORY_SZ) ? (jb->hist_ptr - JB_HISTORY_SZ) : 0;
 
-	for (;i<jb->hist_ptr;i++) {
-	time_in_ms_t toins = jb->history[i % JB_HISTORY_SZ];
+	for (; i < jb->hist_ptr; i++) {
+		time_in_ms_t toins = jb->history[i % JB_HISTORY_SZ];
 
 		/* if the maxbuf should get this */
-		if (toins > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])  {
+		if (toins > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1]) {
 
 			/* insertion-sort it into the maxbuf */
-			for (j=0;j<JB_HISTORY_MAXBUF_SZ;j++) {
+			for (j = 0; j < JB_HISTORY_MAXBUF_SZ; j++) {
 				/* found where it fits */
 				if (toins > jb->hist_maxbuf[j]) {
 					/* move over */
@@ -246,10 +248,10 @@
 		}
 
 		/* if the minbuf should get this */
-		if (toins < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])  {
+		if (toins < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1]) {
 
 			/* insertion-sort it into the maxbuf */
-			for (j=0;j<JB_HISTORY_MAXBUF_SZ;j++) {
+			for (j = 0; j < JB_HISTORY_MAXBUF_SZ; j++) {
 				/* found where it fits */
 				if (toins < jb->hist_minbuf[j]) {
 					/* move over */
@@ -261,15 +263,14 @@
 				}
 			}
 		}
-
 #if 0
 		int k;
 		fprintf(stderr, "toins = %ld\n", toins);
 		fprintf(stderr, "maxbuf =");
-		for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
+		for (k = 0; k < JB_HISTORY_MAXBUF_SZ; k++)
 			fprintf(stderr, "%ld ", jb->hist_maxbuf[k]);
 		fprintf(stderr, "\nminbuf =");
-		for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
+		for (k = 0; k < JB_HISTORY_MAXBUF_SZ; k++)
 			fprintf(stderr, "%ld ", jb->hist_minbuf[k]);
 		fprintf(stderr, "\n");
 #endif
@@ -278,9 +279,9 @@
 	jb->hist_maxbuf_valid = 1;
 }
 
-static void history_get(jitterbuf *jb)
+static void history_get(jitterbuf * jb)
 {
-    time_in_ms_t max, min, jitter;
+	time_in_ms_t max, min, jitter;
 	int index;
 	int count;
 
@@ -312,16 +313,16 @@
 	/* these debug stmts compare the difference between looking at the absolute jitter, and the
 	 * values we get by throwing away the outliers */
 	/*
-	fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", index, min, max, jitter);
-	fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", 0, jb->hist_minbuf[0], jb->hist_maxbuf[0], jb->hist_maxbuf[0]-jb->hist_minbuf[0]);
-	*/
+	   fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", index, min, max, jitter);
+	   fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", 0, jb->hist_minbuf[0], jb->hist_maxbuf[0], jb->hist_maxbuf[0]-jb->hist_minbuf[0]);
+	 */
 
 	jb->info.min = min;
 	jb->info.jitter = jitter;
 }
 
 /* returns 1 if frame was inserted into head of queue, 0 otherwise */
-static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts)
+static int queue_put(jitterbuf * jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts)
 {
 	jb_frame *frame = jb->free;
 	jb_frame *p;
@@ -331,7 +332,7 @@
 	if (frame) {
 		jb->free = frame->next;
 	} else {
-		frame = (jb_frame *)malloc(sizeof(*frame));
+		frame = (jb_frame *) malloc(sizeof(*frame));
 		if (!frame) {
 			jb_err("cannot allocate frame\n");
 			return 0;
@@ -350,7 +351,7 @@
 	 * jb->frames->prev points to the highest ts
 	 */
 
-	if (!jb->frames) {  /* queue is empty */
+	if (!jb->frames) {			/* queue is empty */
 		jb->frames = frame;
 		frame->next = frame;
 		frame->prev = frame;
@@ -371,7 +372,8 @@
 		p = jb->frames;
 
 		/* frame is out of order */
-		if (resync_ts < p->prev->ts) jb->info.frames_ooo++;
+		if (resync_ts < p->prev->ts)
+			jb->info.frames_ooo++;
 
 		while (resync_ts < p->prev->ts && p->prev != jb->frames)
 			p = p->prev;
@@ -385,7 +387,7 @@
 	return head;
 }
 
-static time_in_ms_t queue_next(jitterbuf *jb) 
+static time_in_ms_t queue_next(jitterbuf * jb)
 {
 	if (jb->frames)
 		return jb->frames->ts;
@@ -393,7 +395,7 @@
 		return -1;
 }
 
-static time_in_ms_t queue_last(jitterbuf *jb) 
+static time_in_ms_t queue_last(jitterbuf * jb)
 {
 	if (jb->frames)
 		return jb->frames->prev->ts;
@@ -401,7 +403,7 @@
 		return -1;
 }
 
-static jb_frame *_queue_get(jitterbuf *jb, time_in_ms_t ts, int all) 
+static jb_frame *_queue_get(jitterbuf * jb, time_in_ms_t ts, int all)
 {
 	jb_frame *frame;
 	frame = jb->frames;
@@ -436,46 +438,41 @@
 	return NULL;
 }
 
-static jb_frame *queue_get(jitterbuf *jb, time_in_ms_t ts) 
+static jb_frame *queue_get(jitterbuf * jb, time_in_ms_t ts)
 {
-	return _queue_get(jb,ts,0);
+	return _queue_get(jb, ts, 0);
 }
 
-static jb_frame *queue_getall(jitterbuf *jb)
+static jb_frame *queue_getall(jitterbuf * jb)
 {
-	return _queue_get(jb,0,1);
+	return _queue_get(jb, 0, 1);
 }
 
 #if 0
 /* some diagnostics */
-static void jb_dbginfo(jitterbuf *jb)
+static void jb_dbginfo(jitterbuf * jb)
 {
 	if (dbgf == NULL)
 		return;
 
 	jb_dbg("\njb info: fin=%ld fout=%ld flate=%ld flost=%ld fdrop=%ld fcur=%ld\n",
-		jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
+		   jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
 
 	jb_dbg("jitter=%ld current=%ld target=%ld min=%ld sil=%d len=%d len/fcur=%ld\n",
-		jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
-		jb->info.frames_cur ? (jb->info.current - jb->info.min)/jb->info.frames_cur : -8);
+		   jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
+		   jb->info.frames_cur ? (jb->info.current - jb->info.min) / jb->info.frames_cur : -8);
 	if (jb->info.frames_in > 0)
 		jb_dbg("jb info: Loss PCT = %ld%%, Late PCT = %ld%%\n",
-		jb->info.frames_lost * 100/(jb->info.frames_in + jb->info.frames_lost),
-		jb->info.frames_late * 100/jb->info.frames_in);
+			   jb->info.frames_lost * 100 / (jb->info.frames_in + jb->info.frames_lost), jb->info.frames_late * 100 / jb->info.frames_in);
 	jb_dbg("jb info: queue %d -> %d.  last_ts %d (queue len: %d) last_ms %d\n",
-		queue_next(jb),
-		queue_last(jb),
-		jb->info.next_voice_ts,
-		queue_last(jb) - queue_next(jb),
-		jb->info.last_voice_ms);
+		   queue_next(jb), queue_last(jb), jb->info.next_voice_ts, queue_last(jb) - queue_next(jb), jb->info.last_voice_ms);
 }
 #endif
 
 #ifdef DEEP_DEBUG
-static void jb_chkqueue(jitterbuf *jb)
+static void jb_chkqueue(jitterbuf * jb)
 {
-	int i=0;
+	int i = 0;
 	jb_frame *p = jb->frames;
 
 	if (!p) {
@@ -483,17 +480,17 @@
 	}
 
 	do {
-		if (p->next == NULL)  {
+		if (p->next == NULL) {
 			jb_err("Queue is BROKEN at item [%d]", i);
 		}
 		i++;
-		p=p->next;
+		p = p->next;
 	} while (p->next != jb->frames);
 }
 
-static void jb_dbgqueue(jitterbuf *jb)
+static void jb_dbgqueue(jitterbuf * jb)
 {
-	int i=0;
+	int i = 0;
 	jb_frame *p = jb->frames;
 
 	jb_dbg("queue: ");
@@ -505,14 +502,14 @@
 
 	do {
 		jb_dbg("[%d]=%ld ", i++, p->ts);
-		p=p->next;
+		p = p->next;
 	} while (p->next != jb->frames);
 
 	jb_dbg("\n");
 }
 #endif
 
-enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts, time_in_ms_t now)
+enum jb_return_code jb_put(jitterbuf * jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts, time_in_ms_t now)
 {
 	jb->info.frames_in++;
 
@@ -522,12 +519,12 @@
 		 * sending retransmitted control frames with their awkward
 		 * timestamps through
 		 */
-		if (history_put(jb,ts,now))
+		if (history_put(jb, ts, now))
 			return JB_DROP;
 	}
 
 	/* if put into head of queue, caller needs to reschedule */
-	if (queue_put(jb,data,type,ms,ts)) {
+	if (queue_put(jb, data, type, ms, ts)) {
 		return JB_SCHED;
 	}
 
@@ -535,7 +532,7 @@
 }
 
 
-static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms_t now, long interpl)
+static enum jb_return_code _jb_get(jitterbuf * jb, jb_frame * frameout, time_in_ms_t now, long interpl)
 {
 	jb_frame *frame;
 	time_in_ms_t diff;
@@ -557,7 +554,7 @@
 	diff = jb->info.target - jb->info.current;
 
 	/* jb_warn("diff = %d lms=%d last = %d now = %d\n", diff,  */
-	/*	jb->info.last_voice_ms, jb->info.last_adjustment, now); */
+	/*  jb->info.last_voice_ms, jb->info.last_adjustment, now); */
 
 	/* let's work on non-silent case first */
 	if (!jb->info.silence_begin_ts) {
@@ -565,8 +562,8 @@
 		if ((diff > 0) &&
 			/* we haven't grown in the delay length */
 			(((jb->info.last_adjustment + JB_ADJUST_DELAY) < now) ||
-			/* we need to grow more than the "length" we have left */
-			(diff > queue_last(jb) - queue_next(jb)) ) ) {
+			 /* we need to grow more than the "length" we have left */
+			 (diff > queue_last(jb) - queue_next(jb)))) {
 			/* grow by interp frame length */
 			jb->info.current += interpl;
 			jb->info.next_voice_ts += interpl;
@@ -619,7 +616,7 @@
 				jb->info.frames_lost--;
 				jb_dbg("l");
 				/*jb_warn("\nlate: wanted=%ld, this=%ld, next=%ld\n", jb->info.next_voice_ts - jb->info.current, frame->ts, queue_next(jb));
-				  jb_warninfo(jb); */
+				   jb_warninfo(jb); */
 				return JB_DROP;
 			}
 		}
@@ -633,9 +630,7 @@
 		/* unless we don't have a frame, then shrink 1 frame */
 		/* every 80ms (though perhaps we can shrink even faster */
 		/* in this case) */
-		if (diff < -jb->info.conf.target_extra &&
-				((!frame && jb->info.last_adjustment + 80 < now) ||
-				 (jb->info.last_adjustment + 500 < now))) {
+		if (diff < -jb->info.conf.target_extra && ((!frame && jb->info.last_adjustment + 80 < now) || (jb->info.last_adjustment + 500 < now))) {
 
 			jb->info.last_adjustment = now;
 			jb->info.cnt_contig_interp = 0;
@@ -677,11 +672,11 @@
 			 * lost frame get interpolated two or more times, when there was "room" to grow, so it might
 			 * be a bit of a bad idea overall */
 			/*if (diff > -1 * jb->info.last_voice_ms) {
-				jb->info.current += jb->info.last_voice_ms;
-				jb->info.last_adjustment = now;
-				jb_warn("g");
-				return JB_INTERP;
-			} */
+			   jb->info.current += jb->info.last_voice_ms;
+			   jb->info.last_adjustment = now;
+			   jb_warn("g");
+			   return JB_INTERP;
+			   } */
 			jb->info.frames_lost++;
 			increment_losspct(jb);
 			jb->info.next_voice_ts += interpl;
@@ -712,8 +707,7 @@
 		/* jb->info.silence_begin_ts = 0; */
 
 		/* shrink interpl len every 10ms during silence */
-		if (diff < -jb->info.conf.target_extra &&
-			jb->info.last_adjustment + 10 <= now) {
+		if (diff < -jb->info.conf.target_extra && jb->info.last_adjustment + 10 <= now) {
 			jb->info.current -= interpl;
 			jb->info.last_adjustment = now;
 		}
@@ -736,7 +730,7 @@
 			jb->info.frames_lost--;
 			jb_dbg("l");
 			/*jb_warn("\nlate: wanted=%ld, this=%ld, next=%ld\n", jb->info.next_voice_ts - jb->info.current, frame->ts, queue_next(jb));
-			  jb_warninfo(jb); */
+			   jb_warninfo(jb); */
 			return JB_DROP;
 		} else {
 			/* voice frame */
@@ -754,7 +748,7 @@
 	}
 }
 
-time_in_ms_t jb_next(jitterbuf *jb)
+time_in_ms_t jb_next(jitterbuf * jb)
 {
 	if (jb->info.silence_begin_ts) {
 		if (jb->frames) {
@@ -764,28 +758,28 @@
 			if (jb->info.target - jb->info.current < -jb->info.conf.target_extra)
 				return jb->info.last_adjustment + 10;
 			return next + jb->info.target;
-		}
-		else
+		} else
 			return JB_LONGMAX;
 	} else {
 		return jb->info.next_voice_ts;
 	}
 }
 
-enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms_t now, long interpl)
+enum jb_return_code jb_get(jitterbuf * jb, jb_frame * frameout, time_in_ms_t now, long interpl)
 {
 	enum jb_return_code ret = _jb_get(jb, frameout, now, interpl);
 #if 0
-	static int lastts=0;
+	static int lastts = 0;
 	int thists = ((ret == JB_OK) || (ret == JB_DROP)) ? frameout->ts : 0;
 	jb_warn("jb_get(%x,%x,%ld) = %d (%d)\n", jb, frameout, now, ret, thists);
-	if (thists && thists < lastts) jb_warn("XXXX timestamp roll-back!!!\n");
+	if (thists && thists < lastts)
+		jb_warn("XXXX timestamp roll-back!!!\n");
 	lastts = thists;
 #endif
 	return ret;
 }
 
-enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
+enum jb_return_code jb_getall(jitterbuf * jb, jb_frame * frameout)
 {
 	jb_frame *frame;
 	frame = queue_getall(jb);
@@ -799,7 +793,7 @@
 }
 
 
-enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
+enum jb_return_code jb_getinfo(jitterbuf * jb, jb_info * stats)
 {
 	history_get(jb);
 
@@ -808,7 +802,7 @@
 	return JB_OK;
 }
 
-enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
+enum jb_return_code jb_setconf(jitterbuf * jb, jb_conf * conf)
 {
 	/* take selected settings from the struct */
 
@@ -817,10 +811,8 @@
 	jb->info.conf.max_contig_interp = conf->max_contig_interp;
 
 	/* -1 indicates use of the default JB_TARGET_EXTRA value */
-	jb->info.conf.target_extra = ( conf->target_extra == -1 )
-		? JB_TARGET_EXTRA
-		: conf->target_extra
-		;
+	jb->info.conf.target_extra = (conf->target_extra == -1)
+		? JB_TARGET_EXTRA : conf->target_extra;
 
 	/* update these to match new target_extra setting */
 	jb->info.current = jb->info.conf.target_extra;
@@ -828,5 +820,3 @@
 
 	return JB_OK;
 }
-
-

Modified: freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/md5.c
==============================================================================
--- freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/md5.c	(original)
+++ freeswitch/branches/lukedashjr/syslibs/freeswitch/src/mod/endpoints/mod_iax/md5.c	Tue May 27 07:24:06 2008
@@ -3,13 +3,13 @@
 
 #ifdef FREEBSD
 # include <machine/endian.h>
-#elif defined(LINUX)  
+#elif defined(LINUX)
 # include <endian.h>
 # include <features.h>
 # include <sys/types.h>
 #elif defined(SOLARIS)
   /* each solaris is different -- this won't work on 2.6 or 2.7 */
-# include <sys/isa_defs.h> /* Defines either _LITTLE_ENDIAN or _BIG_ENDIAN */
+# include <sys/isa_defs.h>		/* Defines either _LITTLE_ENDIAN or _BIG_ENDIAN */
 #  define __BIG_ENDIAN		4321
 #  define __LITTLE_ENDIAN	1234
 #  define BIG_ENDIAN		4321
@@ -59,7 +59,7 @@
  * needed on buffers full of bytes, and then call MD5Final, which
  * will fill a supplied 16-byte array with the digest.
  */
-#include <string.h>		/* for memcpy() */
+#include <string.h>				/* for memcpy() */
 #include "md5.h"
 
 #ifndef HIGHFIRST
@@ -73,13 +73,12 @@
  */
 void byteReverse(unsigned char *buf, unsigned longs)
 {
-    uint32 t;
-    do {
-	t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
-	    ((unsigned) buf[1] << 8 | buf[0]);
-	*(uint32 *) buf = t;
-	buf += 4;
-    } while (--longs);
+	uint32 t;
+	do {
+		t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]);
+		*(uint32 *) buf = t;
+		buf += 4;
+	} while (--longs);
 }
 #endif
 #endif
@@ -90,13 +89,13 @@
  */
 void MD5Init(struct MD5Context *ctx)
 {
-    ctx->buf[0] = 0x67452301;
-    ctx->buf[1] = 0xefcdab89;
-    ctx->buf[2] = 0x98badcfe;
-    ctx->buf[3] = 0x10325476;
+	ctx->buf[0] = 0x67452301;
+	ctx->buf[1] = 0xefcdab89;
+	ctx->buf[2] = 0x98badcfe;
+	ctx->buf[3] = 0x10325476;
 
-    ctx->bits[0] = 0;
-    ctx->bits[1] = 0;
+	ctx->bits[0] = 0;
+	ctx->bits[1] = 0;
 }
 
 /*
@@ -105,46 +104,46 @@
  */
 void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 {
-    uint32 t;
+	uint32 t;
 
-    /* Update bitcount */
+	/* Update bitcount */
 
-    t = ctx->bits[0];
-    if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
-	ctx->bits[1]++;		/* Carry from low to high */
-    ctx->bits[1] += len >> 29;
-
-    t = (t >> 3) & 0x3f;	/* Bytes already in shsInfo->data */
-
-    /* Handle any leading odd-sized chunks */
-
-    if (t) {
-	unsigned char *p = (unsigned char *) ctx->in + t;
+	t = ctx->bits[0];
+	if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+		ctx->bits[1]++;			/* Carry from low to high */
+	ctx->bits[1] += len >> 29;
+
+	t = (t >> 3) & 0x3f;		/* Bytes already in shsInfo->data */
+
+	/* Handle any leading odd-sized chunks */
+
+	if (t) {
+		unsigned char *p = (unsigned char *) ctx->in + t;
+
+		t = 64 - t;
+		if (len < t) {
+			memcpy(p, buf, len);
+			return;
+		}
+		memcpy(p, buf, t);
+		byteReverse(ctx->in, 16);
+		MD5Transform(ctx->buf, (uint32 *) ctx->in);
+		buf += t;
+		len -= t;
+	}
+	/* Process data in 64-byte chunks */
 
-	t = 64 - t;
-	if (len < t) {
-	    memcpy(p, buf, len);
-	    return;
+	while (len >= 64) {
+		memcpy(ctx->in, buf, 64);
+		byteReverse(ctx->in, 16);
+		MD5Transform(ctx->buf, (uint32 *) ctx->in);
+		buf += 64;
+		len -= 64;
 	}
-	memcpy(p, buf, t);
-	byteReverse(ctx->in, 16);
-	MD5Transform(ctx->buf, (uint32 *) ctx->in);
-	buf += t;
-	len -= t;
-    }
-    /* Process data in 64-byte chunks */
-
-    while (len >= 64) {
-	memcpy(ctx->in, buf, 64);
-	byteReverse(ctx->in, 16);
-	MD5Transform(ctx->buf, (uint32 *) ctx->in);
-	buf += 64;
-	len -= 64;
-    }
 
-    /* Handle any remaining bytes of data. */
+	/* Handle any remaining bytes of data. */
 
-    memcpy(ctx->in, buf, len);
+	memcpy(ctx->in, buf, len);
 }
 
 /*
@@ -153,43 +152,43 @@
  */
 void MD5Final(unsigned char digest[16], struct MD5Con