[Freeswitch-branches] [commit] r4806 - in freeswitch/branches/mikej/sofiasip-upgrade: . build libs/libteletone/src src src/include src/include/private src/mod/applications/mod_bridgecall src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/applications/mod_echo src/mod/applications/mod_enum src/mod/applications/mod_ivrtest src/mod/applications/mod_park src/mod/applications/mod_playback src/mod/applications/mod_rss src/mod/asr_tts/mod_cepstral src/mod/codecs/mod_amr src/mod/codecs/mod_g711 src/mod/codecs/mod_g722 src/mod/codecs/mod_g723_1 src/mod/codecs/mod_g726 src/mod/codecs/mod_g729 src/mod/codecs/mod_gsm src/mod/codecs/mod_ilbc src/mod/codecs/mod_l16 src/mod/codecs/mod_lpc10 src/mod/codecs/mod_speex src/mod/dialplans/mod_dialplan_directory src/mod/dialplans/mod_dialplan_xml src/mod/directories/mod_ldap src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_iax src/mod/endpoints/mod_portaudio src/mod/endpoints/mod_sofia src/mod/endpoints/mod_wanpipe src/mod/endpoints/mod_wanpipe/libsangoma src/mod/endpoints/mod_woomera src/mod/event_handlers/mod_cdr src/mod/event_handlers/mod_event_multicast src/mod/event_handlers/mod_event_socket src/mod/event_handlers/mod_event_test src/mod/event_handlers/mod_xmpp_event src/mod/event_handlers/mod_zeroconf src/mod/formats/mod_native_file src/mod/formats/mod_shout src/mod/formats/mod_sndfile src/mod/languages/mod_mono src/mod/languages/mod_perl src/mod/languages/mod_python src/mod/languages/mod_spidermonkey src/mod/languages/mod_spidermonkey_core_db src/mod/languages/mod_spidermonkey_etpan src/mod/languages/mod_spidermonkey_odbc src/mod/languages/mod_spidermonkey_skel src/mod/languages/mod_spidermonkey_teletone src/mod/loggers/mod_console src/mod/loggers/mod_syslog src/mod/say/mod_say_en src/mod/timers/mod_softtimer src/mod/xml_int/mod_xml_cdr src/mod/xml_int/mod_xml_curl src/mod/xml_int/mod_xml_rpc w32/Library

Freeswitch SVN mikej at freeswitch.org
Fri Mar 30 12:19:18 EDT 2007


Author: mikej
Date: Fri Mar 30 12:19:18 2007
New Revision: 4806

Added:
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/private/
      - copied from r4805, /freeswitch/trunk/src/include/private/
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/private/switch_core.h
      - copied unchanged from r4805, /freeswitch/trunk/src/include/private/switch_core.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_event_hook.h
      - copied unchanged from r4805, /freeswitch/trunk/src/include/switch_core_event_hook.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_scheduler.h
      - copied unchanged from r4805, /freeswitch/trunk/src/include/switch_scheduler.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_asr.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_asr.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_codec.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_codec.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_directory.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_directory.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_event_hook.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_event_hook.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_file.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_file.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_hash.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_hash.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_io.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_io.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_media_bug.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_media_bug.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_memory.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_memory.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_port_allocator.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_port_allocator.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_rwlock.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_rwlock.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_session.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_session.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_speech.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_speech.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_sqldb.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_sqldb.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_state_machine.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_core_state_machine.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_timer.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_core_timer.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr_async.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_ivr_async.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr_bridge.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr_menu.c
      - copied unchanged from r4803, /freeswitch/trunk/src/switch_ivr_menu.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr_originate.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_ivr_originate.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr_play_say.c
      - copied unchanged from r4805, /freeswitch/trunk/src/switch_ivr_play_say.c
Modified:
   freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
   freeswitch/branches/mikej/sofiasip-upgrade/build/indent_options.sh
   freeswitch/branches/mikej/sofiasip-upgrade/configure.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone_detect.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_apr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_bitpack.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_buffer.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_caller.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_channel.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_console.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_event.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_frame.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_loadable_module.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_regex.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_sqlite.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_stun.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_bridgecall/mod_bridgecall.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_echo/mod_echo.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/mod_enum.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_park/mod_park.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_playback/mod_playback.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_rss/mod_rss.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_amr/mod_amr.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g711/mod_g711.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g722/mod_g722.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/mod_g723_1.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g726/mod_g726.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/mod_g729.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_gsm/mod_gsm.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_ilbc/mod_ilbc.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_l16/mod_l16.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_lpc10/mod_lpc10.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_speex/mod_speex.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/directories/mod_ldap/mod_ldap.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/sigboost.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/ss7boost_client.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/ss7boost_client.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_woomera/mod_woomera.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/basecdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/baseregistry.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/cdrcontainer.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/csvcdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/curlcdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/odbccdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/pddcdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/sqlitecdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/xmlcdr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_event_test/mod_event_test.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_native_file/mod_native_file.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/common.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/dct64_i386.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/decode_i386.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/decode_ntom.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/huffman.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/interface.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/layer3.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/mod_shout.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/mpg123.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/mpglib.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/tabinit.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_sndfile/mod_sndfile.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_mono/mod_mono.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/mod_perl.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/perlxsi.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/switch_swig_wrap.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_python/freeswitch_python.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_python/mod_python.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_python/switch_swig_wrap.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_console/mod_console.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_syslog/mod_syslog.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/say/mod_say_en/mod_say_en.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/timers/mod_softtimer/mod_softtimer.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_apr.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_buffer.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_caller.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_config.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_console.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_db.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_event.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_loadable_module.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_log.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_regex.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_stun.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_swig.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_utils.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_xml.c
   freeswitch/branches/mikej/sofiasip-upgrade/w32/Library/FreeSwitchCore.vcproj

Log:
merged changes from trunk revisions 4788-4805.

Modified: freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am	Fri Mar 30 12:19:18 2007
@@ -11,6 +11,7 @@
 OSARCH=`uname -s`
 
 LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool;  fi;`
+#LIBS+=> core.log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat core.log;fi;if test "$$error" = "yes";then exit 1;fi
 
 LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
 TOUCH_TARGET=if test -f "$@" ; then touch "$@" ; fi ;
@@ -26,7 +27,24 @@
 src/switch_caller.c \
 src/switch_channel.c \
 src/switch_console.c \
+src/switch_core_media_bug.c \
+src/switch_core_timer.c \
+src/switch_core_asr.c \
+src/switch_core_event_hook.c \
+src/switch_core_speech.c \
+src/switch_core_memory.c \
+src/switch_core_codec.c \
+src/switch_core_file.c \
+src/switch_core_hash.c \
+src/switch_core_sqldb.c \
+src/switch_core_session.c \
+src/switch_core_directory.c \
+src/switch_core_state_machine.c \
+src/switch_core_io.c \
+src/switch_core_rwlock.c \
+src/switch_core_port_allocator.c \
 src/switch_core.c \
+src/switch_scheduler.c \
 src/switch_core_db.c\
 src/switch_loadable_module.c \
 src/switch_utils.c \
@@ -34,6 +52,11 @@
 src/switch_resample.c \
 src/switch_regex.c\
 src/switch_rtp.c\
+src/switch_ivr_bridge.c \
+src/switch_ivr_originate.c \
+src/switch_ivr_async.c \
+src/switch_ivr_play_say.c \
+src/switch_ivr_menu.c \
 src/switch_ivr.c \
 src/switch_stun.c\
 src/switch_log.c\
@@ -52,6 +75,8 @@
 src/include/switch_caller.h\
 src/include/switch_channel.h\
 src/include/switch_console.h\
+src/include/switch_core_event_hook.h\
+src/include/switch_scheduler.h\
 src/include/switch_core.h\
 src/include/switch_core_db.h\
 src/include/switch_event.h\
@@ -81,7 +106,6 @@
 CORE_CFLAGS    += -I$(switch_srcdir)/libs/srtp/include
 CORE_CFLAGS    += -I$(switch_srcdir)/libs/srtp/crypto/include
 CORE_CFLAGS    += $(RESAMPLE_CFLAGS)
-CORE_CFLAGS    += -I$(switch_srcdir)/libs/libteletone/src
 
 CORE_LIBS      = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la
 CORE_LIBS     += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la

Modified: freeswitch/branches/mikej/sofiasip-upgrade/build/indent_options.sh
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/build/indent_options.sh	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/build/indent_options.sh	Fri Mar 30 12:19:18 2007
@@ -1,4 +1,4 @@
 #!/bin/bash
-echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l120 -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 "} switch_" ../src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ../.indent.pro
+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 "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro

Modified: freeswitch/branches/mikej/sofiasip-upgrade/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/configure.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/configure.in	Fri Mar 30 12:19:18 2007
@@ -78,8 +78,8 @@
 AM_CONDITIONAL([USE_INTREE_RESAMPLE],[test "${enable_resample}" = "yes"])
 
 # set defaults for use on all platforms
-SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include"
-SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include"
+SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src"
+SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src"
 SWITCH_AM_LDFLAGS="-lm -L/usr/local/lib"
 
 #set SOLINK variable based on compiler and host
@@ -171,7 +171,6 @@
 AC_CHECK_SIZEOF(long, 4)
 AC_CHECK_SIZEOF(short, 2)
 AC_CHECK_SIZEOF(long long, 8)
-AC_CHECK_SIZEOF(time_t, 4)
 AC_TYPE_SIZE_T
 AC_CHECK_TYPE(ssize_t, int)
 
@@ -247,16 +246,6 @@
     size_t_fmt='#error Can not determine the proper size for size_t'
 fi
 
-if test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_int"; then
-   time_t_fmt='#define TIME_T_FMT "d"' 
-elif  test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long"; then
-   time_t_fmt='#define TIME_T_FMT "ld"'
-elif  test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long_long"; then
-   time_t_fmt='#define TIME_T_FMT "lld"'
-else
-    time_t_fmt='#error Can not determine the proper format specifier for time_t of size $ac_cv_sizeof_time_t'
-fi
-
 # Basically, we have tried to figure out the correct format strings
 # for SWITCH types which vary between platforms, but we don't always get 
 # it right.  If you find that we don't get it right for your platform, 
@@ -305,7 +294,6 @@
 AC_SUBST(uint64_t_fmt) 
 AC_SUBST(ssize_t_fmt) 
 AC_SUBST(size_t_fmt)
-AC_SUBST(time_t_fmt)
 
 AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat)
 AC_PATH_PROGS(TAR, gtar tar)

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone.h	Fri Mar 30 12:19:18 2007
@@ -59,7 +59,7 @@
 #endif
 
 #ifdef _MSC_VER
-#define int16_t __int16
+typedef __int16 int16_t;
 #endif
 
 #include <libteletone_generate.h>

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone_detect.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone_detect.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/src/libteletone_detect.h	Fri Mar 30 12:19:18 2007
@@ -64,10 +64,12 @@
 	This module is responsible for tone detection specifics
 */
 
+#ifndef FALSE
 #define FALSE   0
 #ifndef TRUE
 #define TRUE    (!FALSE)
 #endif
+#endif
 
 /* Basic DTMF specs:
  *

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h	Fri Mar 30 12:19:18 2007
@@ -90,7 +90,9 @@
 #include <switch_stun.h>
 #include <switch_log.h>
 #include <switch_xml.h>
-
+#include <switch_core_event_hook.h>
+#include <switch_scheduler.h>
+#include <libteletone.h>
 
 /** \mainpage FreeSWITCH
  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in	Fri Mar 30 12:19:18 2007
@@ -15,6 +15,5 @@
 @size_t_fmt@
 @int64_t_fmt@
 @uint64_t_fmt@
- at time_t_fmt@
 
 #endif

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_apr.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_apr.h	Fri Mar 30 12:19:18 2007
@@ -40,25 +40,22 @@
 #define SWITCH_APR_H
 
 SWITCH_BEGIN_EXTERN_C
-
 /*
    The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
    any other apr code should be as hidden as possible.
 */
-
 /**
  * @defgroup switch_apr Brought To You By APR
  * @ingroup FREESWITCH
  * @{
- */	
-
+ */
 /**
  * @defgroup switch_memory_pool Memory Pool Functions
  * @ingroup switch_apr 
  * @{
  */
 /** The fundamental pool type */
-typedef struct apr_pool_t switch_memory_pool_t;
+	typedef struct apr_pool_t switch_memory_pool_t;
 
 
 /**
@@ -81,12 +78,12 @@
 /**
  * Structure for referencing dynamic objects
  */
-typedef struct apr_dso_handle_t       switch_dso_handle_t;
+	 typedef struct apr_dso_handle_t switch_dso_handle_t;
 
 /**
  * Structure for referencing symbols from dynamic objects
  */
-typedef void *                        switch_dso_handle_sym_t;
+	 typedef void *switch_dso_handle_sym_t;
 
 /**
  * Load a DSO library.
@@ -96,14 +93,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.
@@ -111,9 +107,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.
@@ -121,7 +115,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);
 
 /** @} */
 
@@ -146,10 +140,10 @@
  */
 
 /** Abstract type for hash tables. */
-typedef struct apr_hash_t switch_hash_t;
+	 typedef struct apr_hash_t switch_hash_t;
 
 /** Abstract type for scanning hash tables. */
-typedef struct apr_hash_index_t switch_hash_index_t;
+	 typedef struct apr_hash_index_t switch_hash_index_t;
 
 /**
  * When passing a key to switch_hashfunc_default, this value can be
@@ -169,7 +163,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.
@@ -177,7 +171,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.
@@ -188,7 +182,7 @@
  * @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);
 
 /**
  * The default hash function.
@@ -198,7 +192,7 @@
  */
 SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssize_t *klen);
 
-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);
 
 /** @} */
  /**
@@ -208,40 +202,40 @@
  */
 
  /** number of microseconds since 00:00:00 january 1, 1970 UTC */
-typedef int64_t switch_time_t;
+	 typedef int64_t switch_time_t;
 
  /** number of microseconds in the interval */
-typedef int64_t switch_interval_time_t;
+	 typedef int64_t switch_interval_time_t;
 
 /**
  * a structure similar to ANSI struct tm with the following differences:
  *  - tm_usec isn't an ANSI field
  *  - tm_gmtoff isn't an ANSI field (it's a bsdism)
  */
-typedef struct switch_time_exp_t {
-    /** microseconds past tm_sec */
-    int32_t tm_usec;
-    /** (0-61) seconds past tm_min */
-    int32_t tm_sec;
-    /** (0-59) minutes past tm_hour */
-    int32_t tm_min;
-    /** (0-23) hours past midnight */
-    int32_t tm_hour;
-    /** (1-31) day of the month */
-    int32_t tm_mday;
-    /** (0-11) month of the year */
-    int32_t tm_mon;
-    /** year since 1900 */
-    int32_t tm_year;
-    /** (0-6) days since sunday */
-    int32_t tm_wday;
-    /** (0-365) days since jan 1 */
-    int32_t tm_yday;
-    /** daylight saving time */
-    int32_t tm_isdst;
-    /** seconds east of UTC */
-    int32_t tm_gmtoff;
-} switch_time_exp_t;
+	 typedef struct switch_time_exp_t {
+	/** microseconds past tm_sec */
+		 int32_t tm_usec;
+	/** (0-61) seconds past tm_min */
+		 int32_t tm_sec;
+	/** (0-59) minutes past tm_hour */
+		 int32_t tm_min;
+	/** (0-23) hours past midnight */
+		 int32_t tm_hour;
+	/** (1-31) day of the month */
+		 int32_t tm_mday;
+	/** (0-11) month of the year */
+		 int32_t tm_mon;
+	/** year since 1900 */
+		 int32_t tm_year;
+	/** (0-6) days since sunday */
+		 int32_t tm_wday;
+	/** (0-365) days since jan 1 */
+		 int32_t tm_yday;
+	/** daylight saving time */
+		 int32_t tm_isdst;
+	/** seconds east of UTC */
+		 int32_t tm_gmtoff;
+	 } switch_time_exp_t;
 
 SWITCH_DECLARE(switch_time_t) switch_time_make(switch_time_t sec, int32_t usec);
 
@@ -256,7 +250,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
@@ -266,11 +260,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
@@ -287,7 +277,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 
@@ -295,14 +285,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.
@@ -320,7 +310,7 @@
  */
 
 /** Opaque thread-local mutex structure */
-typedef struct apr_thread_mutex_t switch_mutex_t;
+	 typedef struct apr_thread_mutex_t switch_mutex_t;
 
 /** Lock Flags */
 #define SWITCH_MUTEX_DEFAULT	0x0	/**< platform-optimal lock behavior */
@@ -343,29 +333,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
@@ -374,7 +362,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);
 
 /** @} */
 
@@ -385,17 +373,16 @@
  */
 
 /** Opaque structure used for the rwlock */
-typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
+	 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);
 
 /** @} */
 
@@ -412,7 +399,7 @@
  */
 
 /** Opaque structure for thread condition variables */
-typedef struct apr_thread_cond_t switch_thread_cond_t;
+	 typedef struct apr_thread_cond_t switch_thread_cond_t;
 
 /**
  * Create and initialize a condition variable that can be used to signal
@@ -421,7 +408,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
@@ -435,7 +422,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
@@ -453,7 +440,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
@@ -462,7 +449,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.
@@ -470,13 +457,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);
 
 /** @} */
 
@@ -488,9 +475,10 @@
 
 /** we represent a UUID as a block of 16 bytes. */
 
-typedef struct {
-    unsigned char data[16]; /**< the actual UUID */
-} switch_uuid_t;
+	 typedef struct {
+		 unsigned char data[16];
+							/**< the actual UUID */
+	 } switch_uuid_t;
 
 /** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */
 #define SWITCH_UUID_FORMATTED_LENGTH 36
@@ -501,21 +489,21 @@
  *               be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold
  *               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);
 
 /** @} */
 
@@ -526,7 +514,7 @@
  */
 
 /** Opaque structure used for queue API */
-typedef struct apr_queue_t switch_queue_t;
+	 typedef struct apr_queue_t switch_queue_t;
 
 /** 
  * create a FIFO queue
@@ -534,9 +522,7 @@
  * @param queue_capacity maximum size of the queue
  * @param 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
@@ -547,7 +533,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
@@ -558,7 +544,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.
@@ -568,7 +554,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
@@ -580,7 +566,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
@@ -592,7 +578,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);
 
 /** @} */
 
@@ -603,17 +589,17 @@
  */
 
 /** Structure for referencing files. */
-typedef struct apr_file_t switch_file_t;
+	 typedef struct apr_file_t switch_file_t;
 
-typedef int32_t switch_fileperms_t;
-typedef int     switch_seek_where_t;
+	 typedef int32_t switch_fileperms_t;
+	 typedef int switch_seek_where_t;
 
 /**
  * @defgroup switch_file_permissions File Permissions flags 
  * @ingroup switch_file_io
  * @{
  */
-    
+
 #define SWITCH_FPROT_USETID 0x8000			/**< Set user id */
 #define SWITCH_FPROT_UREAD 0x0400			/**< Read by user */
 #define SWITCH_FPROT_UWRITE 0x0200			/**< Write by user */
@@ -690,16 +676,17 @@
  * @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_memory_pool_t *pool);
+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 file 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);
 
 /**
  * Delete the specified file.
@@ -727,7 +714,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.
@@ -744,7 +731,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(switch_status_t) switch_file_exists(const char *filename);
 
@@ -757,33 +744,33 @@
  */
 
 /** Opaque Thread structure. */
-typedef struct apr_thread_t switch_thread_t;
+	 typedef struct apr_thread_t switch_thread_t;
 
 /** Opaque Thread attributes structure. */
-typedef struct apr_threadattr_t switch_threadattr_t;
+	 typedef struct apr_threadattr_t switch_threadattr_t;
 
 /**
  * The prototype for any APR thread worker functions.
  * typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*);
  */
-typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*);
+	 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);
 
 /**
  * Create and initialize a new threadattr variable
  * @param new_attr The newly created threadattr.
  * @param cont 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
@@ -793,7 +780,8 @@
  * @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_thread_start_t func, void *data, switch_memory_pool_t *cont);
+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);
 
 /** @} */
 
@@ -829,16 +817,16 @@
 #endif
 
 /** A structure to represent sockets */
-typedef struct apr_socket_t switch_socket_t;
+	 typedef struct apr_socket_t switch_socket_t;
 
 /** Freeswitch's socket address type, used to ensure protocol independence */
-typedef struct apr_sockaddr_t switch_sockaddr_t;
+	 typedef struct apr_sockaddr_t switch_sockaddr_t;
 
-typedef enum {
-    SWITCH_SHUTDOWN_READ,          /**< no longer allow read request */
-    SWITCH_SHUTDOWN_WRITE,         /**< no longer allow write requests */
-    SWITCH_SHUTDOWN_READWRITE      /**< no longer allow read or write requests */
-} switch_shutdown_how_e;
+	 typedef enum {
+		 SWITCH_SHUTDOWN_READ,	   /**< no longer allow read request */
+		 SWITCH_SHUTDOWN_WRITE,	   /**< no longer allow write requests */
+		 SWITCH_SHUTDOWN_READWRITE /**< no longer allow read or write requests */
+	 } switch_shutdown_how_e;
 
 /**
  * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets
@@ -859,7 +847,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.
@@ -874,13 +862,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
@@ -889,7 +877,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.
@@ -898,7 +886,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
@@ -908,7 +896,7 @@
  * @param sock The socket we are listening on.
  * @param connection_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 
@@ -916,12 +904,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(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(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);
 
 
 /**
@@ -947,7 +935,8 @@
  * </PRE>
  * @param p 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, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
+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);
 
 /**
  * Send data over a network.
@@ -966,7 +955,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
@@ -975,7 +964,8 @@
  * @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
@@ -985,11 +975,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);
 
 
 /**
@@ -1011,7 +997,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
@@ -1035,7 +1021,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
@@ -1048,7 +1034,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
@@ -1059,7 +1045,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);
 
 
 
@@ -1071,10 +1057,10 @@
  * @{
  */
 /** Poll descriptor set. */
-typedef struct apr_pollfd_t switch_pollfd_t;
+	 typedef struct apr_pollfd_t switch_pollfd_t;
 
 /** Opaque structure used for pollset API */
-typedef struct apr_pollset_t switch_pollset_t;
+	 typedef struct apr_pollset_t switch_pollset_t;
 
 /**
  * Poll options
@@ -1100,10 +1086,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
@@ -1122,8 +1105,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
@@ -1138,10 +1120,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
@@ -1151,9 +1130,9 @@
   \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);
+
 
- 
  /** @} */
 
 
@@ -1163,9 +1142,7 @@
 /** @} */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_bitpack.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_bitpack.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_bitpack.h	Fri Mar 30 12:19:18 2007
@@ -36,22 +36,20 @@
 #ifndef SWITCH_BITPACK_H
 #define SWITCH_BITPACK_H
 SWITCH_BEGIN_EXTERN_C
-
 #include <switch.h>
-
 #ifdef DEBUG_BITS
 static char bb[80] = "";
 static inline char *print_bits(switch_byte_t byte, char *x)
 {
 
-    int i,j = 0;
-    x[j++] = '[';
-    for (i=7;i>=0;i--) {
-        x[j++] = (byte & (1 << i)) ? '1' : '0';
-    }
-    x[j++] = ']';
-    x[j++] = '\0';
-    return x;
+	int i, j = 0;
+	x[j++] = '[';
+	for (i = 7; i >= 0; i--) {
+		x[j++] = (byte & (1 << i)) ? '1' : '0';
+	}
+	x[j++] = ']';
+	x[j++] = '\0';
+	return x;
 }
 #endif
 
@@ -63,8 +61,8 @@
   \{ 
 */
 
-static const uint8_t SWITCH_BITPACKED_MASKS[] = {0, 1, 3, 7, 15, 31, 63, 127, 255};
-static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = {255, 254, 252, 248, 240, 224, 192, 128};
+static const uint8_t SWITCH_BITPACKED_MASKS[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
+static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = { 255, 254, 252, 248, 240, 224, 192, 128 };
 
 /*!
   \brief Initialize a bitpack object
@@ -75,7 +73,8 @@
   \param mode RFC3551 or AAL2 mode (curse you backwards folks) 
 */
 DoxyDefine(void switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode))
-static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode)
+	 static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf, uint32_t buflen,
+											  switch_bitpack_mode_t mode)
 {
 	if (!pack || (bitlen > SWITCH_BITS_PER_BYTE) || !buf || !buflen) {
 		return -1;
@@ -94,7 +93,7 @@
 
 static inline void pack_check_over(switch_bitpack_t *pack)
 {
-	switch_byte_t this_byte = pack->this_byte;	
+	switch_byte_t this_byte = pack->this_byte;
 
 	if (pack->over) {
 		pack->bits_cur = pack->over;
@@ -117,7 +116,7 @@
 
 		pack->bytes++;
 		pack->over = pack->under = 0;
-	}	
+	}
 }
 
 /*!
@@ -125,14 +124,14 @@
   \param pack the pack/unpack object
 */
 DoxyDefine(int8_t switch_bitpack_done(switch_bitpack_t *pack))
-static inline int8_t switch_bitpack_done(switch_bitpack_t *pack)
+	 static inline int8_t switch_bitpack_done(switch_bitpack_t *pack)
 {
 
 	if (pack->bits_cur && pack->bits_cur < SWITCH_BITS_PER_BYTE) {
 		pack->bytes++;
 		if (pack->mode == SWITCH_BITPACK_MODE_AAL2) {
-            *pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur;
-        }
+			*pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur;
+		}
 	}
 
 	if (pack->over) {
@@ -149,11 +148,11 @@
   \return -1 if the buffer is full otherwise 0
 */
 DoxyDefine(int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in))
-static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in)
+	 static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in)
 {
 	switch_byte_t this_byte;
 
-	if ((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen) {
+	if ((uint32_t) (unpack->cur - unpack->buf) > unpack->buflen) {
 		return -1;
 	}
 
@@ -163,7 +162,7 @@
 
 
 	pack_check_over(unpack);
-	while(unpack->bits_cur <= SWITCH_BITS_PER_BYTE) {
+	while (unpack->bits_cur <= SWITCH_BITS_PER_BYTE) {
 		switch_byte_t next = unpack->bits_cur + unpack->frame_bits;
 		switch_byte_t under_in;
 		switch_byte_t mask;
@@ -220,20 +219,20 @@
   \return -1 if the buffer is full otherwise 0
 */
 DoxyDefine(int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in))
-static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
+	 static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
 {
 	int next = pack->bits_cur + pack->frame_bits;
 
-	if ((uint32_t)(pack->cur - pack->buf) > pack->buflen) {
+	if ((uint32_t) (pack->cur - pack->buf) > pack->buflen) {
 		return -1;
-	} 
+	}
 
 	pack->bits_tot += pack->frame_bits;
 
 	if (next > SWITCH_BITS_PER_BYTE) {
 		switch_byte_t a = 0, b = 0, rem, nxt;
 		rem = SWITCH_BITS_PER_BYTE - pack->bits_cur;
-		nxt = pack->frame_bits - rem ;
+		nxt = pack->frame_bits - rem;
 		if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) {
 			a = in & SWITCH_BITPACKED_MASKS[rem];
 			b = in >> rem;
@@ -250,7 +249,7 @@
 			pack->cur++;
 			*pack->cur |= b;
 			pack->bits_cur = nxt;
-			
+
 		}
 		pack->bytes++;
 
@@ -259,14 +258,14 @@
 		if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) {
 			in <<= pack->shiftby;
 			*pack->cur |= in;
-			pack->shiftby = (switch_byte_t)(pack->shiftby + pack->frame_bits);
+			pack->shiftby = (switch_byte_t) (pack->shiftby + pack->frame_bits);
 		} else {
 			*pack->cur <<= pack->frame_bits;
 			*pack->cur |= in;
 		}
 
 		if (next == SWITCH_BITS_PER_BYTE) {
-			pack->cur++;			
+			pack->cur++;
 			pack->bytes++;
 			pack->bits_cur = pack->shiftby = 0;
 		} else {
@@ -276,11 +275,11 @@
 
 	return 0;
 }
+
 ///\}
 
 SWITCH_END_EXTERN_C
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_buffer.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_buffer.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_buffer.h	Fri Mar 30 12:19:18 2007
@@ -41,7 +41,6 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /**
  * @defgroup switch_buffer Buffer Routines
  * @ingroup core1
@@ -50,8 +49,7 @@
  * and I think it can be optimized under the hood as we go using bucket brigades and/or ring buffering techniques.
  * @{
  */
-
-struct switch_buffer;
+	struct switch_buffer;
 
 
 /*! \brief Allocate a new switch_buffer 
@@ -69,9 +67,7 @@
  * \param max_len length the buffer is allowed to grow to
  * \return status
  */
-SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **buffer,
-															 switch_size_t blocksize,
-															 switch_size_t start_len,
+SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **buffer, switch_size_t blocksize, switch_size_t start_len,
 															 switch_size_t max_len);
 
 /*! \brief Get the length of a switch_buffer_t 
@@ -129,9 +125,7 @@
 /** @} */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_caller.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_caller.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_caller.h	Fri Mar 30 12:19:18 2007
@@ -56,10 +56,9 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /*! \brief Call Specific Data
  */
-struct switch_caller_profile {
+	struct switch_caller_profile {
 	/*! The Call's User Name */
 	char *username;
 	/*! The name of the dialplan */
@@ -128,10 +127,7 @@
   \param extension_number extension number
   \return a new extension object allocated from the session's memory pool
 */
-SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session,
-																	  char *extension_name,
-																	  char *extension_number
-																	  );
+SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, char *extension_name, char *extension_number);
 
 /*!
   \brief Add an application (instruction) to the given extension
@@ -141,9 +137,7 @@
   \param extra_data optional argument to the application
 */
 SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
-															 switch_caller_extension_t *caller_extension,
-															 char *application_name,
-															 char *extra_data);
+															 switch_caller_extension_t *caller_extension, char *application_name, char *extra_data);
 
 
 /*!
@@ -178,9 +172,7 @@
 																	const char *network_addr,
 																	const char *ani,
 																	const char *aniii,
-																	const char *rdnis,
-																	const char *source,
-																	const char *context,
+																	const char *rdnis, const char *source, const char *context,
 																	const char *destination_number);
 
 /*!
@@ -188,9 +180,8 @@
   \param session session associated with the profile (bound by scope)
   \param tocopy the existing profile
 */
-	
-SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session,
-																	switch_caller_profile_t *tocopy);
+
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy);
 
 /*!
   \brief Add headers to an existing event in regards to a specific profile
@@ -202,11 +193,8 @@
 SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix, switch_event_t *event);
 
 SWITCH_END_EXTERN_C
-
 /** @} */
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_channel.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_channel.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_channel.h	Fri Mar 30 12:19:18 2007
@@ -40,9 +40,7 @@
 
 #include <switch.h>
 
-SWITCH_BEGIN_EXTERN_C
-
-struct switch_channel_timetable {
+SWITCH_BEGIN_EXTERN_C struct switch_channel_timetable {
 	switch_time_t created;
 	switch_time_t answered;
 	switch_time_t hungup;
@@ -76,17 +74,14 @@
 
 
 SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
-                                                                        const char *file,
-                                                                        const char *func,
-                                                                        int line,
-                                                                        switch_channel_state_t state);
+																		const char *file, const char *func, int line, switch_channel_state_t state);
 
 /*!
   \brief Set the current state of a channel
   \param channel channel to set state of
   \param state new state
   \return current state of channel after application of new state
-*/	
+*/
 #define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state)
 
 /*!
@@ -132,10 +127,8 @@
   \param state the initial state of the channel
   \param flags the initial channel flags
 */
-SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel,
-								switch_core_session_t *session,
-								switch_channel_state_t state,
-								uint32_t flags);
+SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, switch_core_session_t *session, switch_channel_state_t state,
+													uint32_t flags);
 
 /*!
   \brief Fire A presence event for the channel
@@ -279,15 +272,9 @@
 */
 SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags);
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel,
-                                                              const char *file,
-                                                              const char *func,
-                                                              int line);
-
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel,
-                                                                     const char *file,
-                                                                     const char *func,
-                                                                     int line);
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line);
+
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel, const char *file, const char *func, int line);
 
 /*!
   \brief Answer a channel (initiate/acknowledge a successful connection)
@@ -310,10 +297,7 @@
 */
 #define switch_channel_mark_pre_answered(channel) switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel,
-																  const char *file,
-																  const char *func,
-																  int line);
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
 /*!
   \brief Send Ringing message to a channel
   \param channel channel to ring
@@ -322,33 +306,24 @@
 #define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel,
-                                                                  const char *file,
-                                                                  const char *func,
-                                                                  int line);
-
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel,
-                                                                       const char *file,
-                                                                       const char *func,
-                                                                       int line);
-
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel,
-																	   const char *file,
-																	   const char *func,
-																	   int line);
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line);
+
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel, const char *file, const char *func, int line);
+
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
 
 /*!
   \brief Indicate progress on a channel to attempt early media
   \param channel channel to pre-answer
   \return SWITCH_STATUS_SUCCESS
-*/								
+*/
 #define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 /*!
   \brief Indicate a channel is ready to provide ringback
   \param channel channel
   \return SWITCH_STATUS_SUCCESS
-*/								
+*/
 #define switch_channel_mark_ring_ready(channel) switch_channel_perform_mark_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
 /*!
@@ -407,11 +382,8 @@
 SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel);
 
 
-SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel, 
-                                                                     const char *file,
-                                                                     const char *func,
-                                                                     int line,
-                                                                     switch_call_cause_t hangup_cause);
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel,
+																	 const char *file, const char *func, int line, switch_call_cause_t hangup_cause);
 
 /*!
   \brief Hangup a channel flagging it's state machine to end
@@ -478,9 +450,7 @@
 /** @} */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h	Fri Mar 30 12:19:18 2007
@@ -58,24 +58,22 @@
 
 #include <switch.h>
 
-SWITCH_BEGIN_EXTERN_C
-
-typedef struct switch_config switch_config_t;
+SWITCH_BEGIN_EXTERN_C typedef struct switch_config switch_config_t;
 
 /*! \brief A simple file handle representing an open configuration file **/
 struct switch_config {
 	/*! FILE stream buffer to the opened file */
-    FILE *file;
+	FILE *file;
 	/*! path to the file */
-    char *path;
+	char *path;
 	/*! current category */
-    char category[256];
+	char category[256];
 	/*! current section */
-    char section[256];
+	char section[256];
 	/*! buffer of current line being read */
-    char buf[1024];
+	char buf[1024];
 	/*! current line number in file */
-    int lineno;
+	int lineno;
 	/*! current category number in file */
 	int catno;
 	/*! current section number in file */
@@ -90,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
@@ -104,14 +102,11 @@
   \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
-
 /** @} */
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_console.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_console.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_console.h	Fri Mar 30 12:19:18 2007
@@ -51,9 +51,6 @@
 		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
 */
@@ -62,16 +59,15 @@
 /*!
   \brief A method akin to printf that allows you to redirect output to a specific console "channel"
 */
-SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...) PRINTF_FUNCTION(5,6);
+SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line,
+										   const char *fmt, ...) PRINTF_FUNCTION(5, 6);
 
 /*!
   \brief A method akin to printf for dealing with api streams
 */
-SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, ...) PRINTF_FUNCTION(2,3);
+SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, ...) PRINTF_FUNCTION(2, 3);
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h	Fri Mar 30 12:19:18 2007
@@ -41,43 +41,41 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
 #define SWITCH_MAX_STREAMS 128
-
-struct switch_core_time_duration {
-    uint32_t mms;
-    uint32_t ms;
-    uint32_t sec;
-    uint32_t min;
-    uint32_t hr;
+	struct switch_core_time_duration {
+	uint32_t mms;
+	uint32_t ms;
+	uint32_t sec;
+	uint32_t min;
+	uint32_t hr;
 	uint32_t day;
 	uint32_t yr;
 };
 
 /*! \brief A message object designed to allow unlike technologies to exchange data */
 struct switch_core_session_message {
-	/*! uuid of the sender (for replies)*/
+	/*! uuid of the sender (for replies) */
 	char *from;
 	/*! enumeration of the type of message */
 	switch_core_session_message_types_t message_id;
 
-	/*! optional numeric arg*/
+	/*! optional numeric arg */
 	int numeric_arg;
-	/*! optional string arg*/
+	/*! optional string arg */
 	char *string_arg;
-	/*! optional string arg*/
+	/*! optional string arg */
 	switch_size_t string_arg_size;
 	/*! optional arbitrary pointer arg */
 	void *pointer_arg;
 	/*! optional arbitrary pointer arg's size */
 	switch_size_t pointer_arg_size;
 
-	/*! optional numeric reply*/
+	/*! optional numeric reply */
 	int numeric_reply;
-	/*! optional string reply*/
+	/*! optional string reply */
 	char *string_reply;
-	/*! optional string reply*/
+	/*! optional string reply */
 	switch_size_t string_reply_size;
 	/*! optional arbitrary pointer reply */
 	void *pointer_reply;
@@ -96,7 +94,7 @@
 	/*! array of void pointers to pass mutiple data objects */
 	void *objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS];
 	/*! a pointer to a memory pool if the thread has it's own pool */
-    switch_input_callback_function_t input_callback;
+	switch_input_callback_function_t input_callback;
 	switch_memory_pool_t *pool;
 };
 
@@ -104,16 +102,6 @@
 struct switch_core_runtime;
 struct switch_core_port_allocator;
 
-struct switch_core_scheduler_task {
-	time_t created;
-	time_t runtime;
-	uint32_t cmd_id;
-	char *group;
-	void *cmd_arg;
-	uint32_t task_id;
-};
-
-
 /*!
   \defgroup core1 Core Library 
   \ingroup FREESWITCH
@@ -125,47 +113,6 @@
 ///\{
 
 
-///\defgroup sched1 Scheduler
-///\ingroup core1
-///\{
-
-
-/*!
-  \brief Schedule a task in the future
-  \param runtime the time in epoch seconds to execute the task.
-  \param func the callback function to execute when the task is executed.
-  \param desc an arbitrary description of the task.
-  \param group a group id tag to link multiple tasks to a single entity.
-  \param cmd_id an arbitrary index number be used in the callback.
-  \param cmd_arg user data to be passed to the callback.
-  \param flags flags to alter behaviour 
-  \return the id of the task
-*/
-SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime,
-														switch_core_scheduler_func_t func,
-														char *desc,
-														char *group,
-														uint32_t cmd_id,
-														void *cmd_arg,
-														switch_scheduler_flag_t flags);
-
-/*!
-  \brief Delete a scheduled task
-  \param task_id the id of the task
-  \return SWITCH_STATUS_SUCCESS if the task was deleted.
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id);
-
-/*!
-  \brief Delete a scheduled task based on the group name
-  \param group the group name
-  \return SWITCH_STATUS_SUCCESS if any tasks were deleted
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group);
-
-
-///\}
-
 /*!
   \brief Add a media bug to the session
   \param session the session to add the bug to
@@ -177,9 +124,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
 														  switch_media_bug_callback_t callback,
-														  void *user_data,
-														  switch_media_bug_flag_t flags,
-														  switch_media_bug_t **new_bug);
+														  void *user_data, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
 /*!
   \brief Obtain private data from a media bug
   \param bug the bug to get the data from
@@ -209,6 +154,12 @@
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug);
 
 /*!
+  \brief Close and destroy a media bug
+  \param bug bug to remove
+  \return SWITCH_STATUS_SUCCESS if the operation was a success
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(switch_media_bug_t **bug);
+/*!
   \brief Remove all media bugs from the session
   \param session the session to remove the bugs from
   \return SWITCH_STATUS_SUCCESS if the operation was a success
@@ -238,9 +189,7 @@
   \return SWITCH_STATUS_SUCCESS if the operation was a success
 */
 SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t start,
-															   switch_port_t end,
-															   uint8_t inc,
-															   switch_core_port_allocator_t **new_allocator);
+															   switch_port_t end, uint8_t inc, switch_core_port_allocator_t **new_allocator);
 
 /*!
   \brief Get a port from the port allocator
@@ -295,10 +244,7 @@
 ///\{
 
 #ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session,
-                                                                      const char *file,
-                                                                      const char *func,
-                                                                      int line);
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, const char *file, const char *func, int line);
 #endif
 
 /*! 
@@ -314,10 +260,7 @@
 
 
 #ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session,
-                                                            const char *file,
-                                                            const char *func,
-                                                            int line);
+SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line);
 #endif
 
 /*! 
@@ -331,10 +274,7 @@
 #endif
 
 #ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t *session,
-                                                          const char *file,
-                                                          const char *func,
-                                                          int line);
+SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t *session, const char *file, const char *func, int line);
 #endif
 
 /*! 
@@ -479,7 +419,8 @@
   \param pool the pool to use for the allocation (a new one will be used if NULL)
   \return the newly created session
 */
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t
+																	*endpoint_interface, switch_memory_pool_t **pool);
 
 /*! 
   \brief Destroy a session and return the memory pool to the core
@@ -534,10 +475,7 @@
 SWITCH_DECLARE(char *) switch_core_get_uuid(void);
 
 #ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char *uuid_str,
-                                                                           const char *file,
-                                                                           const char *func,
-                                                                           int line);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char *uuid_str, const char *file, const char *func, int line);
 #endif
 
 /*! 
@@ -578,7 +516,7 @@
   \param message the switch_core_session_message_t object to send
   \return the status returned by the message handler
 */
-SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message);
+SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message);
 
 /*! 
   \brief Queue a message on a session
@@ -671,7 +609,7 @@
   \param func a function to execute in the thread
   \param obj an arguement
 */
-SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, void *(*func)(switch_thread_t *, void *), void *obj);
+SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, void *(*func) (switch_thread_t *, void *), void *obj);
 
 /*! 
   \brief Signal a thread using a thread session to terminate
@@ -699,8 +637,7 @@
 SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session,
 																		 char *endpoint_name,
 																		 switch_caller_profile_t *caller_profile,
-																		 switch_core_session_t **new_session,
-																		 switch_memory_pool_t **pool);
+																		 switch_core_session_t **new_session, switch_memory_pool_t **pool);
 
 /*! 
   \brief Answer the channel of a given session
@@ -793,11 +730,8 @@
 SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, int stream_id);
 
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session, 
-                                                                         const char *file, 
-                                                                         const char *func, 
-                                                                         int line, 
-                                                                         switch_signal_t sig);
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session,
+																		 const char *file, const char *func, int line, switch_signal_t sig);
 /*! 
   \brief Send a signal to a channel
   \param session session to send signal to
@@ -832,91 +766,8 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf);
 
-/*! 
-  \brief Add an event hook to be executed when a session requests an outgoing extension
-  \param session session to bind hook to
-  \param outgoing_channel hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_outgoing(switch_core_session_t *session, switch_outgoing_channel_hook_t outgoing_channel);
 ///\}
 
-///\defgroup shooks Session Hook Callbacks
-///\ingroup core1
-///\{
-/*! 
-  \brief Add an event hook to be executed when a session answers a channel
-  \param session session to bind hook to
-  \param answer_channel hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel);
-
-/*! 
-  \brief Add an event hook to be executed when a session sends a message
-  \param session session to bind hook to
-  \param receive_message hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_receive_message(switch_core_session_t *session, switch_receive_message_hook_t receive_message);
-
-/*! 
-  \brief Add an event hook to be executed when a session reads a frame
-  \param session session to bind hook to
-  \param  read_frame hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_read_frame(switch_core_session_t *session, switch_read_frame_hook_t read_frame);
-
-/*! 
-  \brief Add an event hook to be executed when a session writes a frame
-  \param session session to bind hook to
-  \param write_frame hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_write_frame(switch_core_session_t *session, switch_write_frame_hook_t write_frame);
-
-/*! 
-  \brief Add an event hook to be executed when a session kills a channel
-  \param session session to bind hook to
-  \param kill_channel hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_kill_channel(switch_core_session_t *session, switch_kill_channel_hook_t kill_channel);
-
-/*! 
-  \brief Add an event hook to be executed when a session waits for a read event
-  \param session session to bind hook to
-  \param waitfor_read hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_read(switch_core_session_t *session, switch_waitfor_read_hook_t waitfor_read);
-
-/*! 
-  \brief Add an event hook to be executed when a session waits for a write event
-  \param session session to bind hook to
-  \param waitfor_write hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_write(switch_core_session_t *session, switch_waitfor_write_hook_t waitfor_write);
-
-/*! 
-  \brief Add an event hook to be executed when a session sends dtmf
-  \param session session to bind hook to
-  \param send_dtmf hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf);
-
-/*! 
-  \brief Add an event hook to be executed when a session receives a state change signal
-  \param session session to bind hook to
-  \param state_change hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_state_change(switch_core_session_t *session,
-																				switch_answer_channel_hook_t state_change);
-///\}
 
 ///\defgroup hashf Hash Functions
 ///\ingroup core1
@@ -927,14 +778,14 @@
   \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(switch_hash_t **hash, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t ** hash, switch_memory_pool_t *pool);
 
 /*! 
   \brief Destroy an existing hash table
   \param hash the hash to destroy
   \return SWITCH_STATUS_SUCCESS if the hash is destroyed
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t *hash);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t * hash);
 
 /*! 
   \brief Insert data into a hash
@@ -944,7 +795,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(switch_hash_t *hash, const char *key, const void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(switch_hash_t * hash, const char *key, const void *data);
 
 /*! 
   \brief Insert data into a hash with dynamicly allocated key name
@@ -953,7 +804,7 @@
   \param data the data to add
   \return SWITCH_STATUS_SUCCESS if the data is added
 */
-SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_dup(switch_hash_t *hash, const char *key, const void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_dup(switch_hash_t * hash, const char *key, const void *data);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -961,7 +812,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(switch_hash_t *hash, const char *key);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(switch_hash_t * hash, const char *key);
 
 /*! 
   \brief Retrieve data from a given hash
@@ -969,7 +820,7 @@
   \param key the key to retrieve
   \return a pointer to the data held in the key
 */
-SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, const char *key);
+SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t * hash, const char *key);
 ///\}
 
 ///\defgroup timer Timer Functions
@@ -1031,15 +882,13 @@
   \param pool the memory pool to use
   \return SWITCH_STATUS_SUCCESS if the handle is allocated
 */
-SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, 
-													   char *codec_name, 
+SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec,
+													   char *codec_name,
 													   char *fmtp,
-													   uint32_t rate, 
-													   int ms, 
-													   int channels, 
-													   uint32_t flags,
-													   const switch_codec_settings_t *codec_settings, 
-													   switch_memory_pool_t *pool);
+													   uint32_t rate,
+													   int ms,
+													   int channels,
+													   uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
 
 /*! 
   \brief Encode data using a codec handle
@@ -1056,14 +905,11 @@
   \note encoded_data_len will be rewritten to the in-use size of encoded_data
 */
 SWITCH_DECLARE(switch_status_t) switch_core_codec_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);
 
 /*! 
   \brief Decode data using a codec handle
@@ -1080,14 +926,11 @@
   \note decoded_data_len will be rewritten to the in-use size of decoded_data
 */
 SWITCH_DECLARE(switch_status_t) switch_core_codec_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);
 
 /*! 
   \brief Destroy an initalized codec handle
@@ -1177,12 +1020,8 @@
   \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_file_open(switch_file_handle_t *fh, 
-													  char *file_path, 
-													  uint8_t channels,
-													  uint32_t rate,
-													  unsigned int flags,
-													  switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
+													  char *file_path, uint8_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool);
 /*! 
   \brief Read media from a file handle
   \param fh the file handle to read from (must be initilized by you memset all 0 for read, fill in channels and rate for write)
@@ -1251,12 +1090,9 @@
   \param pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the handle is opened
 */
-SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh, 
-													  char *module_name,
-													  char *voice_name,
-													  unsigned int rate,
-													  switch_speech_flag_t *flags,
-													  switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
+														char *module_name,
+														char *voice_name, unsigned int rate, switch_speech_flag_t *flags, switch_memory_pool_t *pool);
 /*! 
   \brief Feed text to the TTS module
   \param sh the speech handle to feed
@@ -1305,11 +1141,8 @@
   \param flags flags in/out for fine tuning
   \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
 */
-SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, 
-														  void *data,
-														  switch_size_t *datalen,
-														  uint32_t *rate,
-														  switch_speech_flag_t *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh,
+															void *data, switch_size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags);
 /*! 
   \brief Close an open speech handle
   \param sh the speech handle to close
@@ -1332,11 +1165,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
 													 char *module_name,
-													 char *codec,
-													 int rate,
-													 char *dest,
-													 switch_asr_flag_t *flags,
-													 switch_memory_pool_t *pool);
+													 char *codec, int rate, char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
 
 /*!
   \brief Close an asr handle
@@ -1420,12 +1249,8 @@
   \param pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the handle is opened
 */
-SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh, 
-														 char *module_name, 
-														 char *source,
-														 char *dsn,
-														 char *passwd,
-														 switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh,
+														   char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool);
 
 /*! 
   \brief Query a directory handle
@@ -1472,6 +1297,12 @@
 SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
 
 /*! 
+  \brief Determines if the core is ready to take calls
+  \return SWITCH_TRUE or SWITCH_FALSE
+*/
+SWITCH_DECLARE(switch_bool_t) switch_core_ready(void);
+
+/*! 
   \brief Execute a management operation.
   \param relative_oid the relative oid of the operation.
   \param action the action to perform.
@@ -1479,10 +1310,7 @@
   \param datalen size in bytes of data.
   \return SUCCESS on sucess.
 */
-SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid,
-															switch_management_action_t action,
-															char *data,
-															switch_size_t datalen);
+SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
 
 
 /*! 
@@ -1522,7 +1350,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, uint32_t *val);
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t * val);
 
 /*!
   \brief Get the output console
@@ -1532,7 +1360,7 @@
 /*! 
   \brief Launch a thread
 */
-SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread_t *, void*), void *obj, switch_memory_pool_t *pool);
+SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func) (switch_thread_t *, void *), void *obj, switch_memory_pool_t *pool);
 
 /*!
   \brief Initiate Globals
@@ -1553,9 +1381,7 @@
 */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h	Fri Mar 30 12:19:18 2007
@@ -36,28 +36,24 @@
 #define SWITCH_CORE_DB_H
 
 SWITCH_BEGIN_EXTERN_C
-
 /**
  * @defgroup switch_sqlite_top Brought To You By SQLite
  * @ingroup FREESWITCH
  * @{
  */
-
 /**
  * @defgroup switch_core_db Database Routines
  * @ingroup switch_sqlite_top 
  * @{
  */
-
 /**
  * Each open database is represented by an instance of the
  * following opaque structure.
 */
-
-typedef struct sqlite3 switch_core_db_t;
+	typedef struct sqlite3 switch_core_db_t;
 typedef struct sqlite3_stmt switch_core_db_stmt_t;
 
-typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
+typedef int (*switch_core_db_callback_func_t) (void *pArg, int argc, char **argv, char **columnNames);
 
 /*
 ** These are special value for the destructor that is passed in as the
@@ -71,7 +67,7 @@
 ** The typedef is necessary to work around problems in certain
 ** C++ compilers.
 */
-typedef void (*switch_core_db_destructor_type_t)(void*);
+typedef void (*switch_core_db_destructor_type_t) (void *);
 #define SWITCH_CORE_DB_STATIC      ((switch_core_db_destructor_type_t)0)
 #define SWITCH_CORE_DB_TRANSIENT   ((switch_core_db_destructor_type_t)-1)
 
@@ -144,14 +140,14 @@
  *
  *  Return the value as UTF-8 text.
  */
-SWITCH_DECLARE(const unsigned char *)switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol);
+SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol);
 
 /**
  * The first parameter is a compiled SQL statement. This function returns
  * the column heading for the Nth column of that statement, where N is the
  * second function parameter.  The string returned is UTF-8.
  */
-SWITCH_DECLARE(const char *)switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N);
+SWITCH_DECLARE(const char *) switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N);
 
 /**
  * Return the number of columns in the result set returned by the compiled
@@ -168,7 +164,7 @@
  * The string "not an error" is returned when the most recent API call was
  * successful.
  */
-SWITCH_DECLARE(const char *)switch_core_db_errmsg(switch_core_db_t *db);
+SWITCH_DECLARE(const char *) switch_core_db_errmsg(switch_core_db_t *db);
 
 /**
  * A function to executes one or more statements of SQL.
@@ -210,11 +206,7 @@
  * behavior can be modified somewhat using the sswitch_core_db_busy_handler()
  * and switch_core_db_busy_timeout() functions below.)
  */
-SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db,
-										const char *sql,
-										switch_core_db_callback_func_t callback,
-										void *data,
-										char **errmsg);
+SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, switch_core_db_callback_func_t callback, void *data, char **errmsg);
 
 /**
  * This function is called to delete a compiled
@@ -254,11 +246,7 @@
  *
  * On success, SWITCH_CORE_DB_OK is returned.  Otherwise an error code is returned.
  */
-SWITCH_DECLARE(int) switch_core_db_prepare(switch_core_db_t *db,
-										   const char *zSql,
-										   int nBytes,
-										   switch_core_db_stmt_t **ppStmt,
-										   const char **pzTail);
+SWITCH_DECLARE(int) switch_core_db_prepare(switch_core_db_t *db, const char *zSql, int nBytes, switch_core_db_stmt_t **ppStmt, const char **pzTail);
 
 /** 
  * After an SQL query has been compiled with a call to either
@@ -451,14 +439,13 @@
  *
  * The return value of this routine is the same as from switch_core_db_exec().
  */
-SWITCH_DECLARE(int) switch_core_db_get_table(
-  switch_core_db_t *db,       /* An open database */
-  const char *sql,       /* SQL to be executed */
-  char ***resultp,       /* Result written to a char *[]  that this points to */
-  int *nrow,             /* Number of result rows written here */
-  int *ncolumn,          /* Number of result columns written here */
-  char **errmsg          /* Error msg written here */
-);
+SWITCH_DECLARE(int) switch_core_db_get_table(switch_core_db_t *db,	/* An open database */
+											 const char *sql,	/* SQL to be executed */
+											 char ***resultp,	/* Result written to a char *[]  that this points to */
+											 int *nrow,	/* Number of result rows written here */
+											 int *ncolumn,	/* Number of result columns written here */
+											 char **errmsg	/* Error msg written here */
+	);
 
 /**
  * Call this routine to free the memory that sqlite3_get_table() allocated.
@@ -471,36 +458,36 @@
 SWITCH_DECLARE(void) switch_core_db_free(char *z);
 
 /** Return values for switch_core_db_exec() and switch_core_db_step()*/
-#define SWITCH_CORE_DB_OK           0   /* Successful result */
+#define SWITCH_CORE_DB_OK           0	/* Successful result */
 /* beginning-of-error-codes */
-#define SWITCH_CORE_DB_ERROR        1   /* SQL error or missing database */
-#define SWITCH_CORE_DB_INTERNAL     2   /* NOT USED. Internal logic error in SQLite */
-#define SWITCH_CORE_DB_PERM         3   /* Access permission denied */
-#define SWITCH_CORE_DB_ABORT        4   /* Callback routine requested an abort */
-#define SWITCH_CORE_DB_BUSY         5   /* The database file is locked */
-#define SWITCH_CORE_DB_LOCKED       6   /* A table in the database is locked */
-#define SWITCH_CORE_DB_NOMEM        7   /* A malloc() failed */
-#define SWITCH_CORE_DB_READONLY     8   /* Attempt to write a readonly database */
-#define SWITCH_CORE_DB_INTERRUPT    9   /* Operation terminated by switch_core_db_interrupt()*/
-#define SWITCH_CORE_DB_IOERR       10   /* Some kind of disk I/O error occurred */
-#define SWITCH_CORE_DB_CORRUPT     11   /* The database disk image is malformed */
-#define SWITCH_CORE_DB_NOTFOUND    12   /* NOT USED. Table or record not found */
-#define SWITCH_CORE_DB_FULL        13   /* Insertion failed because database is full */
-#define SWITCH_CORE_DB_CANTOPEN    14   /* Unable to open the database file */
-#define SWITCH_CORE_DB_PROTOCOL    15   /* Database lock protocol error */
-#define SWITCH_CORE_DB_EMPTY       16   /* Database is empty */
-#define SWITCH_CORE_DB_SCHEMA      17   /* The database schema changed */
-#define SWITCH_CORE_DB_TOOBIG      18   /* NOT USED. Too much data for one row */
-#define SWITCH_CORE_DB_CONSTRAINT  19   /* Abort due to contraint violation */
-#define SWITCH_CORE_DB_MISMATCH    20   /* Data type mismatch */
-#define SWITCH_CORE_DB_MISUSE      21   /* Library used incorrectly */
-#define SWITCH_CORE_DB_NOLFS       22   /* Uses OS features not supported on host */
-#define SWITCH_CORE_DB_AUTH        23   /* Authorization denied */
-#define SWITCH_CORE_DB_FORMAT      24   /* Auxiliary database format error */
-#define SWITCH_CORE_DB_RANGE       25   /* 2nd parameter to switch_core_db_bind out of range */
-#define SWITCH_CORE_DB_NOTADB      26   /* File opened that is not a database file */
-#define SWITCH_CORE_DB_ROW         100  /* switch_core_db_step() has another row ready */
-#define SWITCH_CORE_DB_DONE        101  /* switch_core_db_step() has finished executing */
+#define SWITCH_CORE_DB_ERROR        1	/* SQL error or missing database */
+#define SWITCH_CORE_DB_INTERNAL     2	/* NOT USED. Internal logic error in SQLite */
+#define SWITCH_CORE_DB_PERM         3	/* Access permission denied */
+#define SWITCH_CORE_DB_ABORT        4	/* Callback routine requested an abort */
+#define SWITCH_CORE_DB_BUSY         5	/* The database file is locked */
+#define SWITCH_CORE_DB_LOCKED       6	/* A table in the database is locked */
+#define SWITCH_CORE_DB_NOMEM        7	/* A malloc() failed */
+#define SWITCH_CORE_DB_READONLY     8	/* Attempt to write a readonly database */
+#define SWITCH_CORE_DB_INTERRUPT    9	/* Operation terminated by switch_core_db_interrupt() */
+#define SWITCH_CORE_DB_IOERR       10	/* Some kind of disk I/O error occurred */
+#define SWITCH_CORE_DB_CORRUPT     11	/* The database disk image is malformed */
+#define SWITCH_CORE_DB_NOTFOUND    12	/* NOT USED. Table or record not found */
+#define SWITCH_CORE_DB_FULL        13	/* Insertion failed because database is full */
+#define SWITCH_CORE_DB_CANTOPEN    14	/* Unable to open the database file */
+#define SWITCH_CORE_DB_PROTOCOL    15	/* Database lock protocol error */
+#define SWITCH_CORE_DB_EMPTY       16	/* Database is empty */
+#define SWITCH_CORE_DB_SCHEMA      17	/* The database schema changed */
+#define SWITCH_CORE_DB_TOOBIG      18	/* NOT USED. Too much data for one row */
+#define SWITCH_CORE_DB_CONSTRAINT  19	/* Abort due to contraint violation */
+#define SWITCH_CORE_DB_MISMATCH    20	/* Data type mismatch */
+#define SWITCH_CORE_DB_MISUSE      21	/* Library used incorrectly */
+#define SWITCH_CORE_DB_NOLFS       22	/* Uses OS features not supported on host */
+#define SWITCH_CORE_DB_AUTH        23	/* Authorization denied */
+#define SWITCH_CORE_DB_FORMAT      24	/* Auxiliary database format error */
+#define SWITCH_CORE_DB_RANGE       25	/* 2nd parameter to switch_core_db_bind out of range */
+#define SWITCH_CORE_DB_NOTADB      26	/* File opened that is not a database file */
+#define SWITCH_CORE_DB_ROW         100	/* switch_core_db_step() has another row ready */
+#define SWITCH_CORE_DB_DONE        101	/* switch_core_db_step() has finished executing */
 /* end-of-error-codes */
 
 
@@ -547,12 +534,10 @@
  * should always use %q instead of %s when inserting text into a string 
  * literal.
  */
-SWITCH_DECLARE(char *)switch_mprintf(const char *zFormat,...);
+SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...);
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_event.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_event.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_event.h	Fri Mar 30 12:19:18 2007
@@ -61,9 +61,8 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /*! \brief An event Header */
-struct switch_event_header{
+	struct switch_event_header {
 	/*! the header name */
 	char *name;
 	/*! the header value */
@@ -172,7 +171,8 @@
   \param fmt the value of the header (varargs see standard sprintf family)
   \return SWITCH_STATUS_SUCCESS if the header was added
 */
-SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt, ...) PRINTF_FUNCTION(4,5);
+SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack,
+														const char *header_name, const char *fmt, ...) PRINTF_FUNCTION(4, 5);
 
 /*!
   \brief Destroy an event
@@ -208,7 +208,8 @@
   \param user_data optional user specific data to pass whenever the callback is invoked
   \return SWITCH_STATUS_SUCCESS if the event was binded
 */
-SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, void *user_data);
+SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback,
+												  void *user_data);
 
 /*!
   \brief Render the name of an event id enumeration
@@ -251,7 +252,7 @@
   \return the xml object if the operation was successful
   \note the body supplied by this function will supersede an existing body the event may have
 */
-SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3);
+SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, 3);
 
 /*!
   \brief Determine if the event system has been initilized
@@ -266,7 +267,7 @@
   \return SWITCH_STATUS_SUCCESS if the body was added to the event
   \note the body parameter can be shadowed by the switch_event_reserve_subclass_detailed function
 */
-SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3);
+SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, 3);
 
 
 /*!
@@ -311,9 +312,7 @@
 ///\}
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_frame.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_frame.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_frame.h	Fri Mar 30 12:19:18 2007
@@ -39,16 +39,15 @@
 #include <switch.h>
 
 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 */
 	const char *source;
 	/*! the raw packet */
 	void *packet;
-	/*! the size of the raw packet when applicable*/
+	/*! the size of the raw packet when applicable */
 	uint32_t packetlen;
 	/*! the frame data */
 	void *data;
@@ -69,9 +68,7 @@
 };
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h	Fri Mar 30 12:19:18 2007
@@ -42,7 +42,6 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /**
  * @defgroup switch_ivr IVR Library
  * @ingroup core1
@@ -50,8 +49,6 @@
  *	building blocks for a higher level IVR interface.
  * @{
  */
-
-
 /*!
   \brief Generate an XML CDR report.
   \param session the session to get the data from.
@@ -59,7 +56,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);
 
 /*!
   \brief Parse command from an event
@@ -88,9 +85,7 @@
   \param timeout a timeout in milliseconds
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
-                                                                   switch_input_args_t *args,
-																   uint32_t timeout);
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout);
 
 /*!
   \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
@@ -106,10 +101,7 @@
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
 																char *buf,
 																uint32_t buflen,
-																uint32_t maxdigits,
-																const char *terminators,
-																char *terminator,
-																uint32_t timeout);
+																uint32_t maxdigits, const char *terminators, char *terminator, uint32_t timeout);
 
 /*!
   \brief Engage background Speech detection on a session
@@ -122,11 +114,7 @@
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
-														 char *mod_name,
-														 char *grammar,
-														 char *path,
-														 char *dest,
-														 switch_asr_handle_t *ah);
+														 char *mod_name, char *grammar, char *path, char *dest, switch_asr_handle_t *ah);
 
 /*!
   \brief Stop background Speech detection on a session
@@ -173,7 +161,7 @@
   \param fh file handle to use (NULL for builtin one)
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file,  switch_file_handle_t *fh);
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh);
 
 /*!
   \brief Stop Recording a session
@@ -197,10 +185,7 @@
   \return SWITCH_STATUS_SUCCESS if all is well
   \note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop playback.
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session,
-                                                     switch_file_handle_t *fh,
-                                                     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, char *file, switch_input_args_t *args);
 
 
 /*!
@@ -216,10 +201,7 @@
   \note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop recording.
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
-                                                       switch_file_handle_t *fh,
-                                                       char *file,
-                                                       switch_input_args_t *args,
-                                                       uint32_t limit);
+													   switch_file_handle_t *fh, char *file, switch_input_args_t *args, uint32_t limit);
 
 
 /*!
@@ -239,23 +221,18 @@
   \note to test for digit capture failure look for \\0 in the first position of the buffer
 */
 SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t *session,
-                                                           uint32_t min_digits,
-                                                           uint32_t max_digits,
-                                                           uint32_t max_tries,
-                                                           uint32_t timeout,
-                                                           char* valid_terminators,
-                                                           char* audio_file,
-                                                           char* bad_input_audio_file,
-                                                           void* digit_buffer,
-                                                           uint32_t digit_buffer_length,
-                                                           char* digits_regex);
+														   uint32_t min_digits,
+														   uint32_t max_digits,
+														   uint32_t max_tries,
+														   uint32_t timeout,
+														   char *valid_terminators,
+														   char *audio_file,
+														   char *bad_input_audio_file, void *digit_buffer, uint32_t digit_buffer_length,
+														   char *digits_regex);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session_t *session,
-                                                             switch_speech_handle_t *sh,
-                                                             switch_codec_t *codec,
-                                                             switch_timer_t *timer,
-                                                             char *text,
-                                                             switch_input_args_t *args);
+															 switch_speech_handle_t *sh,
+															 switch_codec_t *codec, switch_timer_t *timer, char *text, switch_input_args_t *args);
 
 /*!
   \brief Speak given text with given tts engine
@@ -269,12 +246,8 @@
   \param buflen the len of buf
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, 
-													  char *tts_name,
-													  char *voice_name,
-													  uint32_t rate,
-													  char *text,
-                                                      switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
+													  char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args);
 
 /*!
   \brief Make an outgoing call
@@ -295,9 +268,7 @@
 													 char *bridgeto,
 													 uint32_t timelimit_sec,
 													 const switch_state_handler_table_t *table,
-													 char *cid_name_override,
-													 char *cid_num_override,
-													 switch_caller_profile_t *caller_profile_override);
+													 char *cid_name_override, char *cid_num_override, switch_caller_profile_t *caller_profile_override);
 
 /*!
   \brief Bridge Audio from one session to another
@@ -308,10 +279,9 @@
   \param peer_session_data data to pass to the DTMF callback for peer_session
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session, 
+SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
 																 switch_core_session_t *peer_session,
-																 switch_input_callback_function_t dtmf_callback,
-																 void *session_data,
+																 switch_input_callback_function_t dtmf_callback, void *session_data,
 																 void *peer_session_data);
 
 /*!
@@ -436,24 +406,24 @@
 
 /******************************************************************************************************/
 
-struct switch_ivr_digit_stream_parser;
-typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t;
-struct switch_ivr_digit_stream;
-typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t;
+	 struct switch_ivr_digit_stream_parser;
+	 typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t;
+	 struct switch_ivr_digit_stream;
+	 typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t;
 /*!
   \brief Create a digit stream parser object
   \param pool the pool to use for the new hash
   \param parser a pointer to the object pointer
   \return SWITCH_STATUS_SUCCESS if all is well 
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser);
+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser);
 
 /*!
   \brief Destroy a digit stream parser object
   \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
@@ -461,14 +431,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
@@ -477,7 +447,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
@@ -485,7 +455,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
@@ -493,14 +463,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
@@ -508,7 +478,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);
 
 
 /******************************************************************************************************/
@@ -524,28 +494,28 @@
  * @{
  */
 
-typedef enum {
-	SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0),
-	SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1),
-	SWITCH_IVR_MENU_FLAG_STACK = (1 << 2),
-} switch_ivr_menu_flags;
+	 typedef enum {
+		 SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0),
+		 SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1),
+		 SWITCH_IVR_MENU_FLAG_STACK = (1 << 2),
+	 } switch_ivr_menu_flags;
 /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
-typedef enum {
-	SWITCH_IVR_ACTION_DIE, 		/* Exit the menu.                  */
-	SWITCH_IVR_ACTION_EXECMENU,	/* Goto another menu in the stack. */
-	SWITCH_IVR_ACTION_EXECAPP,	/* Execute an application.         */
-	SWITCH_IVR_ACTION_PLAYSOUND,	/* Play a sound.                   */
-	SWITCH_IVR_ACTION_SAYTEXT,	/* say text.                       */
-	SWITCH_IVR_ACTION_SAYPHRASE,	/* say a phrase macro.                       */
-	SWITCH_IVR_ACTION_BACK,		/* Go back 1 menu.                 */
-	SWITCH_IVR_ACTION_TOMAIN,	/* Go back to the top level menu.  */
-	SWITCH_IVR_ACTION_TRANSFER,	/* Transfer caller to another ext. */
-	SWITCH_IVR_ACTION_NOOP,		/* No operation                    */
-} switch_ivr_action_t;
-struct switch_ivr_menu;
-typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
-typedef struct switch_ivr_menu switch_ivr_menu_t;
-typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
+	 typedef enum {
+		 SWITCH_IVR_ACTION_DIE,	/* Exit the menu.                  */
+		 SWITCH_IVR_ACTION_EXECMENU,	/* Goto another menu in the stack. */
+		 SWITCH_IVR_ACTION_EXECAPP,	/* Execute an application.         */
+		 SWITCH_IVR_ACTION_PLAYSOUND,	/* Play a sound.                   */
+		 SWITCH_IVR_ACTION_SAYTEXT,	/* say text.                       */
+		 SWITCH_IVR_ACTION_SAYPHRASE,	/* say a phrase macro.                       */
+		 SWITCH_IVR_ACTION_BACK,	/* Go back 1 menu.                 */
+		 SWITCH_IVR_ACTION_TOMAIN,	/* Go back to the top level menu.  */
+		 SWITCH_IVR_ACTION_TRANSFER,	/* Transfer caller to another ext. */
+		 SWITCH_IVR_ACTION_NOOP,	/* No operation                    */
+	 } switch_ivr_action_t;
+	 struct switch_ivr_menu;
+	 typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
+	 typedef struct switch_ivr_menu switch_ivr_menu_t;
+	 typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
 /******************************************************************************************************/
 
 /*!
@@ -564,19 +534,16 @@
  *\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, 
+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 *exit_sound,
-													 const char *invalid_sound, 
+													 const char *invalid_sound,
 													 const char *tts_engine,
 													 const char *tts_voice,
-													 const char *phrase_lang,
-													 int timeout,
-													 int max_failures, 
-													 switch_memory_pool_t *pool);
+													 const char *phrase_lang, int timeout, int max_failures, switch_memory_pool_t *pool);
 
 /*!
  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
@@ -586,7 +553,7 @@
  *\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);
 
 
 /*!
@@ -600,7 +567,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);
 
 
 /*!
@@ -611,17 +579,17 @@
  *\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;
+	 struct switch_ivr_menu_xml_ctx;
+	 typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
 /*!
  *\brief Build a menu stack from an xml source
  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
@@ -630,10 +598,8 @@
  *\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);
 
 /*!
  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
@@ -641,28 +607,22 @@
  *\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,
-										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,
+																	 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,
-                                                        char *macro_name,
-                                                        char *data,
-                                                        char *lang,
-                                                        switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, char *macro_name, char *data, char *lang,
+														switch_input_args_t *args);
 /** @} */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_loadable_module.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_loadable_module.h	Fri Mar 30 12:19:18 2007
@@ -44,15 +44,13 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /*!
   \defgroup mods Loadable Module Functions
   \ingroup core1
   \{ 
 */
-
 /*! \brief The abstraction of a loadable module */
-struct switch_loadable_module_interface {
+	struct switch_loadable_module_interface {
 	/*! the name of the module */
 	const char *module_name;
 	/*! the table of endpoints the module has implmented */
@@ -76,7 +74,7 @@
 	/*! the table of chat interfaces the module has implmented */
 	const switch_chat_interface_t *chat_interface;
 	/*! the table of say interfaces the module has implmented */
-	const switch_say_interface_t *say_interface;	
+	const switch_say_interface_t *say_interface;
 	/*! the table of asr interfaces the module has implmented */
 	const switch_asr_interface_t *asr_interface;
 	/*! the table of management interfaces the module has implmented */
@@ -125,9 +123,9 @@
   \note only use this function if you are making a module that in turn gateways module loading to another technology
  */
 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_module_load_t switch_module_load,
+																	 switch_module_runtime_t switch_module_runtime,
+																	 switch_module_shutdown_t switch_module_shutdown);
 
 /*!
   \brief Retrieve the timer interface by it's registered name
@@ -206,8 +204,7 @@
   \param arraylen the max size in elements of the array
   \return the number of elements added to the array
  */
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
-													  int arraylen);
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array, int arraylen);
 
 
 /*!
@@ -219,8 +216,7 @@
   \return the number of elements added to the array
   \note this function only considers codecs that are listed in the "prefs" array and ignores the rest.
 */
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array,
-															 int arraylen, char **prefs, int preflen);
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen);
 
 /*!
   \brief Execute a registered API command
@@ -266,9 +262,7 @@
 ///\}
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h	Fri Mar 30 12:19:18 2007
@@ -41,35 +41,32 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 ///\defgroup log Logger Routines
 ///\ingroup core1
 ///\{
-
-
 /*! \brief Log Data
  */
-typedef struct {
+	typedef struct {
 	/*! The complete log message */
 	char *data;
-	/*! The file where the message originated */	
+	/*! The file where the message originated */
 	char *file;
-	/*! The line number where the message originated */	
+	/*! The line number where the message originated */
 	uint32_t line;
-	/*! The function where the message originated */	
+	/*! The function where the message originated */
 	char *func;
-	/*! The log level of the message */	
+	/*! The log level of the message */
 	switch_log_level_t level;
 	/*! The time when the log line was sent */
 	switch_time_t timestamp;
-	/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */	
+	/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
 	char *content;
 
 	/* To maintain abi, only add new elements to the end of this struct and do not delete any elements */
 
 } switch_log_node_t;
 
-typedef switch_status_t (*switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level);
+typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
 
 
 /*! 
@@ -97,7 +94,8 @@
   \param ... variable args
   \note there are channel macros to supply the first 4 parameters
 */
-SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6,7);
+SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line,
+									   switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6, 7);
 
 /*! 
   \brief Shut down  the logging engine
@@ -121,9 +119,7 @@
 
 ///\}
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h	Fri Mar 30 12:19:18 2007
@@ -42,10 +42,9 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 /*! \brief A table of functions to execute at various states 
 */
-struct switch_state_handler_table {
+	struct switch_state_handler_table {
 	/*! executed when the state changes to init */
 	switch_state_handler_t on_init;
 	/*! executed when the state changes to ring */
@@ -54,13 +53,13 @@
 	switch_state_handler_t on_execute;
 	/*! executed when the state changes to hangup */
 	switch_state_handler_t on_hangup;
-	/*! executed when the state changes to loopback*/
+	/*! executed when the state changes to loopback */
 	switch_state_handler_t on_loopback;
-	/*! executed when the state changes to transmit*/
+	/*! executed when the state changes to transmit */
 	switch_state_handler_t on_transmit;
-	/*! executed when the state changes to hold*/
+	/*! executed when the state changes to hold */
 	switch_state_handler_t on_hold;
-	/*! executed when the state changes to hibernate*/
+	/*! executed when the state changes to hibernate */
 	switch_state_handler_t on_hibernate;
 };
 
@@ -75,133 +74,33 @@
 	switch_event_t *event;
 };
 
-/*! \brief Node in which to store custom outgoing channel callback hooks */
-struct switch_io_event_hook_outgoing_channel {
-	/*! the outgoing channel callback hook*/
-	switch_outgoing_channel_hook_t outgoing_channel;
-	struct switch_io_event_hook_outgoing_channel *next;
-};
-
-/*! \brief Node in which to store custom answer channel callback hooks */
-struct switch_io_event_hook_answer_channel {
-	/*! the answer channel callback hook*/
-	switch_answer_channel_hook_t answer_channel;
-	struct switch_io_event_hook_answer_channel *next;
-};
-
-/*! \brief Node in which to store custom receive message callback hooks */
-struct switch_io_event_hook_receive_message {
-	/*! the answer channel callback hook*/
-	switch_receive_message_hook_t receive_message;
-	struct switch_io_event_hook_receive_message *next;
-};
-
-/*! \brief Node in which to store custom receive message callback hooks */
-struct switch_io_event_hook_receive_event {
-	/*! the answer channel callback hook*/
-	switch_receive_event_hook_t receive_event;
-	struct switch_io_event_hook_receive_event *next;
-};
-
-/*! \brief Node in which to store custom read frame channel callback hooks */
-struct switch_io_event_hook_read_frame {
-	/*! the read frame channel callback hook*/
-	switch_read_frame_hook_t read_frame;
-	struct switch_io_event_hook_read_frame *next;
-};
-
-/*! \brief Node in which to store custom write_frame channel callback hooks */
-struct switch_io_event_hook_write_frame {
-	/*! the write_frame channel callback hook*/
-	switch_write_frame_hook_t write_frame;
-	struct switch_io_event_hook_write_frame *next;
-};
-
-/*! \brief Node in which to store custom kill channel callback hooks */
-struct switch_io_event_hook_kill_channel {
-	/*! the kill channel callback hook*/
-	switch_kill_channel_hook_t kill_channel;
-	struct switch_io_event_hook_kill_channel *next;
-};
-
-/*! \brief Node in which to store custom waitfor read channel callback hooks */
-struct switch_io_event_hook_waitfor_read {
-	/*! the waitfor read channel callback hook*/
-	switch_waitfor_read_hook_t waitfor_read;
-	struct switch_io_event_hook_waitfor_read *next;
-};
-
-/*! \brief Node in which to store custom waitfor write channel callback hooks */
-struct switch_io_event_hook_waitfor_write {
-	/*! the waitfor write channel callback hook*/
-	switch_waitfor_write_hook_t waitfor_write;
-	struct switch_io_event_hook_waitfor_write *next;
-};
-
-/*! \brief Node in which to store custom send dtmf channel callback hooks */
-struct switch_io_event_hook_send_dtmf {
-	/*! the send dtmf channel callback hook*/
-	switch_send_dtmf_hook_t send_dtmf;
-	struct switch_io_event_hook_send_dtmf *next;
-};
-
-/*! \brief Node in which to store state change callback hooks */
-struct switch_io_event_hook_state_change {
-	/*! the send dtmf channel callback hook*/
-	switch_state_change_hook_t state_change;
-	struct switch_io_event_hook_state_change *next;
-};
-
-/*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */
-struct switch_io_event_hooks {
-	/*! a list of outgoing channel hooks */
-	switch_io_event_hook_outgoing_channel_t *outgoing_channel;
-	/*! a list of answer channel hooks */
-	switch_io_event_hook_answer_channel_t *answer_channel;
-	/*! a list of receive message hooks */
-	switch_io_event_hook_receive_message_t *receive_message;
-	/*! a list of queue message hooks */
-	switch_io_event_hook_receive_event_t *receive_event;
-	/*! a list of read frame hooks */
-	switch_io_event_hook_read_frame_t *read_frame;
-	/*! a list of write frame hooks */
-	switch_io_event_hook_write_frame_t *write_frame;
-	/*! a list of kill channel hooks */
-	switch_io_event_hook_kill_channel_t *kill_channel;
-	/*! a list of wait for read hooks */
-	switch_io_event_hook_waitfor_read_t *waitfor_read;
-	/*! a list of wait for write hooks */
-	switch_io_event_hook_waitfor_write_t *waitfor_write;
-	/*! a list of send dtmf hooks */
-	switch_io_event_hook_send_dtmf_t *send_dtmf;
-	/*! a list of state change hooks */
-	switch_io_event_hook_state_change_t *state_change;
-};
+struct switch_io_event_hooks;
+
 
 /*! \brief A table of i/o routines that an endpoint interface can implement */
 struct switch_io_routines {
 	/*! creates an outgoing session from given session, caller profile */
-	switch_call_cause_t (*outgoing_channel)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
+	switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
 	/*! answers the given session's channel */
-	switch_status_t (*answer_channel)(switch_core_session_t *);
+	switch_status_t (*answer_channel) (switch_core_session_t *);
 	/*! read a frame from a session */
-	switch_status_t (*read_frame)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
+	switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
 	/*! write a frame to a session */
-	switch_status_t (*write_frame)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
+	switch_status_t (*write_frame) (switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
 	/*! send a kill signal to the session's channel */
-	switch_status_t (*kill_channel)(switch_core_session_t *, int);
+	switch_status_t (*kill_channel) (switch_core_session_t *, int);
 	/*! wait for the session's channel to be ready to read audio */
-	switch_status_t (*waitfor_read)(switch_core_session_t *, int, int);
+	switch_status_t (*waitfor_read) (switch_core_session_t *, int, int);
 	/*! wait for the session's channel to be ready to write audio */
-	switch_status_t (*waitfor_write)(switch_core_session_t *, int, int);
+	switch_status_t (*waitfor_write) (switch_core_session_t *, int, int);
 	/*! send a string of DTMF digits to a session's channel */
-	switch_status_t (*send_dtmf)(switch_core_session_t *, char *);
-	/*! receive a message from another session*/
-	switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
-	/*! queue a message for another session*/
-	switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
+	switch_status_t (*send_dtmf) (switch_core_session_t *, char *);
+	/*! receive a message from another session */
+	switch_status_t (*receive_message) (switch_core_session_t *, switch_core_session_message_t *);
+	/*! queue a message for another session */
+	switch_status_t (*receive_event) (switch_core_session_t *, switch_event_t *);
 	/*! change a sessions channel state */
-	switch_status_t (*state_change)(switch_core_session_t *);
+	switch_status_t (*state_change) (switch_core_session_t *);
 };
 
 /*! \brief Abstraction of an module endpoint interface
@@ -250,15 +149,15 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to allocate the timer */
-	switch_status_t (*timer_init)(switch_timer_t *);
+	switch_status_t (*timer_init) (switch_timer_t *);
 	/*! function to wait for one cycle to pass */
-	switch_status_t (*timer_next)(switch_timer_t *);
+	switch_status_t (*timer_next) (switch_timer_t *);
 	/*! function to step the timer one step */
-	switch_status_t (*timer_step)(switch_timer_t *);
+	switch_status_t (*timer_step) (switch_timer_t *);
 	/*! function to check if the current step has expired */
-	switch_status_t (*timer_check)(switch_timer_t *);
+	switch_status_t (*timer_check) (switch_timer_t *);
 	/*! function to deallocate the timer */
-	switch_status_t (*timer_destroy)(switch_timer_t *);
+	switch_status_t (*timer_destroy) (switch_timer_t *);
 	const struct switch_timer_interface *next;
 };
 
@@ -276,19 +175,19 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the file */
-	switch_status_t (*file_open)(switch_file_handle_t *, char *file_path);
+	switch_status_t (*file_open) (switch_file_handle_t *, char *file_path);
 	/*! function to close the file */
-	switch_status_t (*file_close)(switch_file_handle_t *);
+	switch_status_t (*file_close) (switch_file_handle_t *);
 	/*! function to read from the file */
-	switch_status_t (*file_read)(switch_file_handle_t *, void *data, switch_size_t *len);
+	switch_status_t (*file_read) (switch_file_handle_t *, void *data, switch_size_t *len);
 	/*! function to write from the file */
-	switch_status_t (*file_write)(switch_file_handle_t *, void *data, switch_size_t *len);
+	switch_status_t (*file_write) (switch_file_handle_t *, void *data, switch_size_t *len);
 	/*! function to seek to a certian position in the file */
-	switch_status_t (*file_seek)(switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence);
+	switch_status_t (*file_seek) (switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence);
 	/*! function to set meta data */
-	switch_status_t (*file_set_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
+	switch_status_t (*file_set_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
 	/*! function to get meta data */
-	switch_status_t (*file_get_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
+	switch_status_t (*file_get_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
 	/*! list of supported file extensions */
 	char **extens;
 	const struct switch_file_interface *next;
@@ -316,7 +215,7 @@
 	int seekable;
 	/*! the sample count of the file */
 	unsigned int sample_count;
-	/*! the speed of the file playback*/
+	/*! the speed of the file playback */
 	int speed;
 	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
@@ -325,8 +224,8 @@
 	char *handler;
 	int64_t pos;
 	switch_buffer_t *audio_buffer;
-    uint32_t thresh;
-    uint32_t silence_hits;
+	uint32_t thresh;
+	uint32_t silence_hits;
 };
 
 /*! \brief Abstract interface to an asr module */
@@ -334,27 +233,23 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the asr interface */
-	switch_status_t (*asr_open)(switch_asr_handle_t *ah,
-								char *codec,
-								int rate,
-								char *dest,
-								switch_asr_flag_t *flags);
+	switch_status_t (*asr_open) (switch_asr_handle_t *ah, char *codec, int rate, char *dest, switch_asr_flag_t *flags);
 	/*! function to load a grammar to the asr interface */
-	switch_status_t (*asr_load_grammar)(switch_asr_handle_t *ah, char *grammar, char *path);
+	switch_status_t (*asr_load_grammar) (switch_asr_handle_t *ah, char *grammar, char *path);
 	/*! function to unload a grammar to the asr interface */
-	switch_status_t (*asr_unload_grammar)(switch_asr_handle_t *ah, char *grammar);
+	switch_status_t (*asr_unload_grammar) (switch_asr_handle_t *ah, char *grammar);
 	/*! function to close the asr interface */
-	switch_status_t (*asr_close)(switch_asr_handle_t *ah, switch_asr_flag_t *flags);
-	/*! function to feed audio to the ASR*/
-	switch_status_t (*asr_feed)(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
-	/*! function to resume the ASR*/
-	switch_status_t (*asr_resume)(switch_asr_handle_t *ah);
-	/*! function to pause the ASR*/
-	switch_status_t (*asr_pause)(switch_asr_handle_t *ah);
-	/*! function to read results from the ASR*/
-	switch_status_t (*asr_check_results)(switch_asr_handle_t *ah, switch_asr_flag_t *flags);
-	/*! function to read results from the ASR*/
-	switch_status_t (*asr_get_results)(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
+	switch_status_t (*asr_close) (switch_asr_handle_t *ah, switch_asr_flag_t *flags);
+	/*! function to feed audio to the ASR */
+	switch_status_t (*asr_feed) (switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
+	/*! function to resume the ASR */
+	switch_status_t (*asr_resume) (switch_asr_handle_t *ah);
+	/*! function to pause the ASR */
+	switch_status_t (*asr_pause) (switch_asr_handle_t *ah);
+	/*! function to read results from the ASR */
+	switch_status_t (*asr_check_results) (switch_asr_handle_t *ah, switch_asr_flag_t *flags);
+	/*! function to read results from the ASR */
+	switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
 	const struct switch_asr_interface *next;
 };
 
@@ -364,11 +259,11 @@
 	const switch_asr_interface_t *asr_interface;
 	/*! flags to control behaviour */
 	uint32_t flags;
-	/*! The Name*/
+	/*! The Name */
 	char *name;
-	/*! The Codec*/
+	/*! The Codec */
 	char *codec;
-	/*! The Rate*/
+	/*! The Rate */
 	uint32_t rate;
 	char *grammar;
 	/*! the handle's memory pool */
@@ -382,24 +277,17 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the speech interface */
-	switch_status_t (*speech_open)(switch_speech_handle_t *sh,
-								 char *voice_name, 
-								 int rate,
-								 switch_speech_flag_t *flags);
+	switch_status_t (*speech_open) (switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags);
 	/*! function to close the speech interface */
-	switch_status_t (*speech_close)(switch_speech_handle_t *, switch_speech_flag_t *flags);
-	/*! 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);
-	void (*speech_flush_tts)(switch_speech_handle_t *sh);
-	void (*speech_text_param_tts)(switch_speech_handle_t *sh, char *param, char *val);
-	void (*speech_numeric_param_tts)(switch_speech_handle_t *sh, char *param, int val);
-	void (*speech_float_param_tts)(switch_speech_handle_t *sh, char *param, double val);
+	switch_status_t (*speech_close) (switch_speech_handle_t *, switch_speech_flag_t *flags);
+	/*! 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);
+	void (*speech_flush_tts) (switch_speech_handle_t *sh);
+	void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, char *val);
+	void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
+	void (*speech_float_param_tts) (switch_speech_handle_t *sh, char *param, double val);
 
 	const struct switch_speech_interface *next;
 };
@@ -411,9 +299,9 @@
 	const switch_speech_interface_t *speech_interface;
 	/*! flags to control behaviour */
 	uint32_t flags;
-	/*! The Name*/
+	/*! The Name */
 	char *name;
-	/*! The Rate*/
+	/*! The Rate */
 	uint32_t rate;
 	uint32_t speed;
 	char voice[80];
@@ -429,7 +317,7 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to pass down to the module */
-    switch_say_callback_t say_function;
+	switch_say_callback_t say_function;
 	const struct switch_say_interface *next;
 };
 
@@ -438,7 +326,7 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the directory interface */
-	switch_status_t (*chat_send)(char *proto, char *from, char *to, char *subject, char *body, char *hint);
+	switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint);
 	const struct switch_chat_interface *next;
 };
 
@@ -447,7 +335,7 @@
 	/*! the name of the interface */
 	const char *relative_oid;
 	/*! function to open the directory interface */
-	switch_status_t (*management_function)(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
+	switch_status_t (*management_function) (char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
 	const struct switch_management_interface *next;
 };
 
@@ -456,16 +344,16 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the directory interface */
-	switch_status_t (*directory_open)(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd);
+	switch_status_t (*directory_open) (switch_directory_handle_t *dh, char *source, char *dsn, char *passwd);
 	/*! function to close the directory interface */
-	switch_status_t (*directory_close)(switch_directory_handle_t *dh);
+	switch_status_t (*directory_close) (switch_directory_handle_t *dh);
 	/*! function to query the directory interface */
-	switch_status_t (*directory_query)(switch_directory_handle_t *dh, char *base, char *query);
+	switch_status_t (*directory_query) (switch_directory_handle_t *dh, char *base, char *query);
 	/*! function to advance to the next record */
-	switch_status_t (*directory_next)(switch_directory_handle_t *dh);
+	switch_status_t (*directory_next) (switch_directory_handle_t *dh);
 	/*! function to advance to the next name/value pair in the current record */
-	switch_status_t (*directory_next_pair)(switch_directory_handle_t *dh, char **var, char **val);
-	
+	switch_status_t (*directory_next_pair) (switch_directory_handle_t *dh, char **var, char **val);
+
 	const struct switch_directory_interface *next;
 };
 
@@ -534,7 +422,7 @@
 	switch_codec_settings_t codec_settings;
 	/*! flags to modify behaviour */
 	uint32_t flags;
-	/*! the handle's memory pool*/
+	/*! the handle's memory pool */
 	switch_memory_pool_t *memory_pool;
 	/*! private data for the codec module to store handle specific info */
 	void *private_info;
@@ -569,29 +457,21 @@
 	/*! 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_status_t (*init)(switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
+	switch_status_t (*init) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
 	/*! function to encode raw data into encoded data */
-	switch_status_t (*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_status_t (*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);
 	/*! function to decode encoded data into raw data */
-	switch_status_t (*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_status_t (*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);
 	/*! deinitalize a codec handle using this implementation */
-	switch_status_t (*destroy)(switch_codec_t *);
+	switch_status_t (*destroy) (switch_codec_t *);
 	const struct switch_codec_implementation *next;
 };
 
@@ -635,9 +515,7 @@
 };
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h	Fri Mar 30 12:19:18 2007
@@ -35,23 +35,17 @@
 #define SWITCH_PLATFORM_H
 
 SWITCH_BEGIN_EXTERN_C
-
 #ifdef __ICC
 #pragma warning (disable:810 869 981 279 1469 188)
 #endif
-
 #include <stdio.h>
-
+#define SWITCH_VA_NONE "%s", ""
 #ifdef _MSC_VER
 #define __SWITCH_FUNC__ __FUNCTION__
 #else
 #define __SWITCH_FUNC__ (const char *)__func__
 #endif
-
-
 #ifdef _MSC_VER
-
-
 /* disable the following warnings 
  * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored. 
  * C4200: Non standard extension C zero sized array
@@ -65,7 +59,11 @@
  */
 #pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996)
 
-#if (_MSC_VER >= 1400) // VC8+
+#pragma include_alias(<libteletone.h>,				<../../libs/libteletone/src/libteletone.h>)
+#pragma include_alias(<libteletone_generate.h>,		<../../libs/libteletone/src/libteletone_generate.h>)
+#pragma include_alias(<libteletone_detect.h>,		<../../libs/libteletone/src/libteletone_detect.h>)
+
+#if (_MSC_VER >= 1400)			// VC8+
 #ifndef _CRT_SECURE_NO_DEPRECATE
 #define _CRT_SECURE_NO_DEPRECATE
 #endif
@@ -73,30 +71,27 @@
 #define _CRT_NONSTDC_NO_DEPRECATE
 #endif
 #endif // VC8+
-
 #if  _MSC_VER < 1300
 #ifndef __FUNCTION__
 #define __FUNCTION__ ""
 #endif
 #endif
-
 #undef inline
 #define inline __inline
-
 #ifndef uint32_t
-typedef unsigned __int8		uint8_t;
-typedef unsigned __int16	uint16_t;
-typedef unsigned __int32	uint32_t;
-typedef unsigned __int64    uint64_t;
-typedef __int8		int8_t;
-typedef __int16		int16_t;
-typedef __int32		int32_t;
-typedef __int64		int64_t;
-typedef unsigned long	in_addr_t;
-#endif
-typedef  int         pid_t;
-typedef  int         uid_t;
-typedef  int         gid_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+typedef __int8 int8_t;
+typedef __int16 int16_t;
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned long in_addr_t;
+#endif
+typedef int pid_t;
+typedef int uid_t;
+typedef int gid_t;
 #define PACKED
 #include <io.h>
 #define strcasecmp(s1, s2) stricmp(s1, s2)
@@ -116,7 +111,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #endif // _MSC_VER
-
 #ifndef __LITTLE_ENDIAN
 #define __LITTLE_ENDIAN 1234
 #endif
@@ -130,9 +124,7 @@
 #define __BYTE_ORDER __LITTLE_ENDIAN
 #endif
 #endif
-
 #ifdef WIN32
-
 #if defined(SWITCH_CORE_DECLARE_STATIC)
 #define SWITCH_DECLARE(type)			type __stdcall
 #define SWITCH_DECLARE_NONSTD(type)		type __cdecl
@@ -146,7 +138,6 @@
 #define SWITCH_DECLARE_NONSTD(type)		__declspec(dllimport) type __cdecl
 #define SWITCH_DECLARE_DATA				__declspec(dllimport)
 #endif
-
 #if defined(SWITCH_MOD_DECLARE_STATIC)
 #define SWITCH_MOD_DECLARE(type)		type __cdecl
 #elif defined(MOD_EXPORTS)
@@ -169,35 +160,32 @@
 #define SWITCH_DECLARE_DATA
 #define SWITCH_THREAD_FUNC
 #endif
-
 #ifdef DOXYGEN
 #define DoxyDefine(x) x
 #else
 #define DoxyDefine(x)
 #endif
-
 #if __GNUC__ >= 3
 #define PRINTF_FUNCTION(fmtstr,vars) __attribute__((format(printf,fmtstr,vars)))
 #else
 #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
-typedef  SWITCH_SIZE_T  switch_size_t;
+typedef SWITCH_SIZE_T switch_size_t;
 #else
-typedef  uintptr_t  switch_size_t;
+typedef uintptr_t switch_size_t;
 #endif
 
 #ifdef SWITCH_SSIZE_T
-typedef  SWITCH_SSIZE_T   switch_ssize_t;
+typedef SWITCH_SSIZE_T switch_ssize_t;
 #else
-typedef  intptr_t	switch_ssize_t;
+typedef intptr_t switch_ssize_t;
 #endif
 
 #ifdef WIN32
@@ -213,12 +201,6 @@
 #define SWITCH_INT64_T_FMT          "I64d"
 #define SWITCH_UINT64_T_FMT         "I64u"
 
-#ifdef _USE_32BIT_TIME_T
-#define TIME_T_FMT "d"
-#else
-#define TIME_T_FMT SWITCH_INT64_T_FMT
-#endif
-
 #else
 #ifndef SWITCH_SSIZE_T_FMT
 #define SWITCH_SSIZE_T_FMT          (sizeof (switch_ssize_t) == sizeof (long) ? "ld" : sizeof (switch_ssize_t) == sizeof (int) ? "d" : "lld")
@@ -245,7 +227,6 @@
 #define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT
 
 SWITCH_END_EXTERN_C
-
 /* these includes must be outside the extern "C" block on windows or it will break compatibility with c++ modules*/
 #ifdef WIN32
 /* Has windows.h already been included?  If so, our preferences don't matter,
@@ -257,7 +238,6 @@
 #define WIN32_LEAN_AND_MEAN
 #endif
 #ifndef _WIN32_WINNT
-
 /* Restrict the server to a subset of Windows NT 4.0 header files by default
  */
 #define _WIN32_WINNT 0x0400
@@ -288,19 +268,13 @@
 #endif /* !_WINDOWS_ */
 #include <process.h>
 #endif
-
 #endif
-
-
 #ifndef FALSE
 #define FALSE 0
 #endif
 #ifndef TRUE
 #define TRUE (!FALSE)
 #endif
-
-
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_regex.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_regex.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_regex.h	Fri Mar 30 12:19:18 2007
@@ -35,32 +35,23 @@
 #define SWITCH_REGEX_H
 
 SWITCH_BEGIN_EXTERN_C
-
 /**
  * @defgroup switch_regex
  * @ingroup FREESWITCH
  * @{
  */
+	typedef struct real_pcre switch_regex_t;
 
-typedef struct real_pcre switch_regex_t;
-
-SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
-													  int options,
-													  const char **errorptr,
-													  int *erroroffset,
+SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern, int options, const char **errorptr, int *erroroffset,
 													  const unsigned char *tables);
 
-SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject,
-												int *ovector,
-												int stringcount,
-												int stringnumber,
-												char *buffer,
-												int size);
+SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int size);
 
 SWITCH_DECLARE(void) switch_regex_free(void *data);
 
 SWITCH_DECLARE(int) switch_regex_perform(char *field, char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen);
-SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data, char *substituted, uint32_t len, int *ovector);
+SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data,
+												 char *substituted, uint32_t len, int *ovector);
 
 /*!
  \brief Function to evaluate an expression against a string
@@ -78,9 +69,7 @@
 /** @} */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h	Fri Mar 30 12:19:18 2007
@@ -45,15 +45,13 @@
 
 #include <switch.h>
 SWITCH_BEGIN_EXTERN_C
-
 /*!
   \defgroup resamp Audio Resample Functions
   \ingroup core1
   \{ 
 */
-
 /*! \brief An audio resampling handle */
-typedef struct {
+	typedef struct {
 	/*! a pointer to store the resampler object */
 	void *resampler;
 	/*! the rate to resample from in hz */
@@ -87,11 +85,7 @@
   \return SWITCH_STATUS_SUCCESS if the handle was created
  */
 SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t **new_resampler,
-													 int from_rate,
-													 switch_size_t from_size,
-													 int to_rate,
-													 uint32_t to_size,
-													 switch_memory_pool_t *pool);
+													   int from_rate, switch_size_t from_size, int to_rate, uint32_t to_size, switch_memory_pool_t *pool);
 
 /*!
   \brief Destroy an existing resampler handle
@@ -172,9 +166,7 @@
 ///\}
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_rtp.h	Fri Mar 30 12:19:18 2007
@@ -39,17 +39,12 @@
 #define SWITCH_RTP_H
 
 SWITCH_BEGIN_EXTERN_C
-
 #define SWITCH_RTP_MAX_BUF_LEN 16384
-
 ///\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);
 
 /*! 
   \brief Initilize the RTP System
@@ -77,15 +72,12 @@
   \param pool a memory pool to use for the session
   \return the new RTP session or NULL on failure
 */
-SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session,
-												 switch_payload_t payload,
-												 uint32_t samples_per_interval,
-												 uint32_t ms_per_packet,
-												 switch_rtp_flag_t flags,
-												 char *crypto_key,
-												 char *timer_name,
-												 const char **err,
-												 switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session,
+												  switch_payload_t payload,
+												  uint32_t samples_per_interval,
+												  uint32_t ms_per_packet,
+												  switch_rtp_flag_t flags, char *crypto_key, char *timer_name, const char **err,
+												  switch_memory_pool_t *pool);
 
 
 /*!
@@ -104,18 +96,14 @@
   \param pool a memory pool to use for the session
   \return the new RTP session or NULL on failure
 */
-SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host,
-											 switch_port_t rx_port,
-											 char *tx_host,
-											 switch_port_t tx_port,
-											 switch_payload_t payload,
-											 uint32_t samples_per_interval,
-											 uint32_t ms_per_packet,
-											 switch_rtp_flag_t flags,
-											 char *crypto_key,
-											 char *timer_name,
-											 const char **err,
-											 switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host,
+											  switch_port_t rx_port,
+											  char *tx_host,
+											  switch_port_t tx_port,
+											  switch_payload_t payload,
+											  uint32_t samples_per_interval,
+											  uint32_t ms_per_packet,
+											  switch_rtp_flag_t flags, char *crypto_key, char *timer_name, const char **err, switch_memory_pool_t *pool);
 
 
 /*! 
@@ -189,7 +177,7 @@
   \param rtp_session the RTP session to retrieve the socket from
   \return the socket from the RTP session
 */
-SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session);
+SWITCH_DECLARE(switch_socket_t *) switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session);
 
 /*! 
   \brief Set the default samples per interval for a given RTP session
@@ -237,7 +225,8 @@
   \param flags 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_payload_t *payload_type, switch_frame_flag_t *flags);
+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);
 
 /*! 
   \brief Queue RFC2833 DTMF data into an RTP Session
@@ -281,10 +270,7 @@
   \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);
+														 void **data, uint32_t * datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags);
 
 /*! 
   \brief Read data from a given RTP session without copying
@@ -313,7 +299,8 @@
   \param flags flags for control
   \return SWITCH_STAUTS_SUCCESS on success
 */
-SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags);
+SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session,
+													  switch_codec_t *codec, switch_vad_flag_t flags);
 
 /*!
   \brief Disable VAD on an RTP Session
@@ -347,12 +334,7 @@
 SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
 											void *data,
 											uint16_t datalen,
-											uint8_t m,
-											switch_payload_t payload,
-											uint32_t ts,
-											uint16_t mseq,
-											uint32_t ssrc,
-											switch_frame_flag_t *flags);
+											uint8_t m, switch_payload_t payload, uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags);
 
 /*! 
   \brief Retrieve the SSRC from a given RTP session
@@ -387,16 +369,14 @@
   \param rtp_session the RTP session to retrieve the data from
   \return the pointer to the private data
 */
-SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp_t *rtp_session);
+SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session);
 
 /*!
   \}
 */
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_sqlite.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_sqlite.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_sqlite.h	Fri Mar 30 12:19:18 2007
@@ -36,26 +36,22 @@
 #define SWITCH_SQLITE_H
 
 SWITCH_BEGIN_EXTERN_C
-
 #include <sqlite3.h>
-
 /**
  * @defgroup switch_sqlite_top Brought To You By SQLite
  * @ingroup FREESWITCH
  * @{
  */
-
 /**
  * @defgroup switch_sqlite Database Routines
  * @ingroup switch_sqlite_top 
  * @{
  */
-
 /**
  * Each open sqlite database is represented by an instance of the
  * following opaque structure.
 */
-typedef sqlite3 switch_core_db_t;
+	typedef sqlite3 switch_core_db_t;
 typedef sqlite3_stmt switch_core_db_stmt_t;
 /**
  * Aggregate functions use the following routine to allocate
@@ -67,17 +63,15 @@
  *
  * The buffer allocated is freed automatically by SQLite.
  */
-DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context*, int nBytes);)
+DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context *, int nBytes);)
 #define switch_core_db_aggregate_context sqlite3_aggregate_context
-
 /**
  * /return the number of calls to xStep for a particular
  * aggregate function instance.  The current call to xStep counts so this
  * routine always returns at least 1.
  */
-DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context*);)
+DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context *);)
 #define switch_core_db_aggregate_count sqlite3_aggregate_count
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -106,9 +100,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));)
+DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt *, int, const void *, int n, void (*)(void *));)
 #define switch_core_db_bind_blob sqlite3_bind_blob
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -129,9 +122,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt*, int, double);)
+DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt *, int, double);)
 #define switch_core_db_bind_double sqlite3_bind_double
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -152,9 +144,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt*, int, int);)
+DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt *, int, int);)
 #define switch_core_db_bind_int sqlite3_bind_int
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -175,9 +166,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt*, int, sqlite_int64);)
+DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt *, int, sqlite_int64);)
 #define switch_core_db_bind_int64 sqlite3_bind_int64
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -198,9 +188,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt*, int);)
+DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt *, int);)
 #define switch_core_db_bind_null sqlite3_bind_null
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -229,9 +218,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));)
+DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt *, int, const char *, int n, void (*)(void *));)
 #define switch_core_db_bind_text sqlite3_bind_text
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -260,9 +248,8 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));)
+DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt *, int, const void *, int, void (*)(void *));)
 #define switch_core_db_bind_text16 sqlite3_bind_text16
-
 /**
  * In the SQL strings input to switch_core_db_prepare(),
  * one or more literals can be replace by parameters "?" or ":AAA" or
@@ -283,24 +270,21 @@
  * an switch_core_db_prepare() or sqlite3_reset().  Unbound parameterss are
  * interpreted as NULL.
  */
-DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt*, int, const sqlite3_value*);)
+DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt *, int, const sqlite3_value *);)
 #define switch_core_db_bind_value sqlite3_bind_value
-
 /**
  * @return The number of parameters in a compiled SQL statement.
  * @remark This routine was added to support DBD::SQLite.
  */
-DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt*);)
+DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt *);)
 #define switch_core_db_bind_parameter_count sqlite3_bind_parameter_count
-
 /**
  * @return the index of a parameter with the given name.  If no parameter with the 
  * given name is found, return 0.
  * @remark The name must match exactly.
  */
-DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt*, const char *zName);)
+DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt *, const char *zName);)
 #define switch_core_db_bind_parameter_index sqlite3_bind_parameter_index
-
 /**
  * @return the name of the i-th parameter.  
  * @remark Ordinary parameters "?" are
@@ -308,9 +292,8 @@
  * $VVV the complete text of the parameter name is returned, including
  * the initial ":" or "$".  NULL is returned if the index is out of range.
  */
-DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt*, int);)
+DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt *, int);)
 #define switch_core_db_bind_parameter_name sqlite3_bind_parameter_name
-
 /**
  * This routine identifies a callback function that is invoked
  * whenever an attempt is made to open a database table that is
@@ -333,9 +316,8 @@
  * data structures out from under the executing query and will 
  * probably result in a coredump.
  */
-DoxyDefine(int switch_core_db_busy_handler(switch_core_db*, int(*)(void*,int), void*);)
+DoxyDefine(int switch_core_db_busy_handler(switch_core_db *, int (*)(void *, int), void *);)
 #define switch_core_db_busy_handler sqlite3_busy_handler
-
 /**
  * This routine sets a busy handler that sleeps for a while when a
  * table is locked.  The handler will sleep multiple times until 
@@ -346,9 +328,8 @@
  * Calling this routine with an argument less than or equal to zero
  * turns off all busy handlers.
  */
-DoxyDefine(int switch_core_db_busy_timeout(switch_core_db*, int ms);)
+DoxyDefine(int switch_core_db_busy_timeout(switch_core_db *, int ms);)
 #define switch_core_db_busy_timeout sqlite3_busy_timeout
-
 /**
  * This function returns the number of database rows that were changed
  * (or inserted or deleted) by the most recent called sqlite3_exec().
@@ -369,9 +350,8 @@
  * table. To get an accurate count of the number of rows deleted, use
  * "DELETE FROM table WHERE 1" instead.
  */
-DoxyDefine(int switch_core_db_changes(switch_core_db*);)
+DoxyDefine(int switch_core_db_changes(switch_core_db *);)
 #define switch_core_db_changes sqlite3_changes
-
 /**
  * A function to close the database.
  *
@@ -385,7 +365,6 @@
  */
 DoxyDefine(int switch_core_db_close(switch_core_db *);)
 #define switch_core_db_close sqlite3_close
-
 /**
  * To avoid having to register all collation sequences before a database
  * can be used, a single callback function may be registered with the
@@ -405,13 +384,9 @@
  * The collation sequence is returned to SQLite by a collation-needed
  * callback using the sqlite3_create_collation() API, described above.
  */
-DoxyDefine(int switch_core_db_collation_needed(
-  switch_core_db*, 
-  void*, 
-  void(*)(void*,switch_core_db*,int eTextRep,const char*)
-);)
+DoxyDefine(int switch_core_db_collation_needed(switch_core_db *, void *, void (*)(void *, switch_core_db *, int eTextRep, const char *)
+		   );)
 #define switch_core_db_collation_needed sqlite3_collation_needed
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.
@@ -453,9 +428,8 @@
  *
  * @return the value of a BLOB.
  */
-DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt *stmt, int iCol);)
+DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt * stmt, int iCol);)
 #define switch_core_db_column_blob sqlite3_column_blob
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -497,9 +471,8 @@
  * TEXT value represented as UTF-8.  The "\000" terminator is included in the 
  * byte count for TEXT values.
  */
-DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt*, int iCol);)
+DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_bytes sqlite3_column_bytes
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -541,9 +514,8 @@
  * TEXT value represented as UTF-16.  The "\u0000" terminator is included in 
  * the byte count for TEXT values.
  */
-DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt*, int iCol);)
+DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_bytes16 sqlite3_column_bytes16
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -583,9 +555,8 @@
  *
  *  Return a FLOAT value.
  */
-DoxyDefine(double switch_core_db_column_double(sqlite3_stmt*, int iCol);)
+DoxyDefine(double switch_core_db_column_double(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_double sqlite3_column_double
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -626,9 +597,8 @@
  *  Return an INTEGER value in the host computer's native integer representation.  
  *  This might be either a 32- or 64-bit integer depending on the host.
  */
-DoxyDefine(int switch_core_db_column_int(sqlite3_stmt*, int iCol);)
+DoxyDefine(int switch_core_db_column_int(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_int sqlite3_column_int
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -668,9 +638,8 @@
  *
  * Return an INTEGER value as a 64-bit signed integer.
  */
-DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt*, int iCol);)
+	DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_int64 sqlite3_column_int64
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -710,9 +679,8 @@
  *
  *  Return the value as UTF-8 text.
  */
-DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt*, int iCol);)
+DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_text sqlite3_column_text
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -752,9 +720,8 @@
  *
  * Return the value as UTF-16 text.
  */
-DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt*, int iCol);)
+DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_text16 sqlite3_column_text16
-
 /**
  * The next group of routines returns information about the information
  * in a single column of the current result row of a query.  In every
@@ -795,25 +762,22 @@
  * ReturnS the datatype of the result.  This is one of
  * SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL.
  */
-DoxyDefine(int switch_core_db_column_type(sqlite3_stmt*, int iCol);)
+DoxyDefine(int switch_core_db_column_type(sqlite3_stmt *, int iCol);)
 #define switch_core_db_column_type sqlite3_column_type
-
 /**
  * The first parameter is a compiled SQL statement. This function returns
  * the column heading for the Nth column of that statement, where N is the
  * second function parameter.  The string returned is UTF-8.
  */
-DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt*,int);)
+DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt *, int);)
 #define switch_core_db_column_name sqlite3_column_name
-
 /**
  * Return the number of columns in the result set returned by the compiled
  * SQL statement. This routine returns 0 if pStmt is an SQL statement
  * that does not return data (for example an UPDATE).
  */
-DoxyDefine(int switch_core_db_column_count(sqlite3_stmt *pStmt);)
+DoxyDefine(int switch_core_db_column_count(sqlite3_stmt * pStmt);)
 #define switch_core_db_column_count sqlite3_column_count
-
 /**
  * The first parameter is a compiled SQL statement. If this statement
  * is a SELECT statement, the Nth column of the returned result set 
@@ -834,7 +798,6 @@
  */
 DoxyDefine(const char *switch_core_db_column_decltype(sqlite3_stmt *, int i);)
 #define switch_core_db_column_decltype sqlite3_column_decltype
-
 /**
  * The first parameter is a compiled SQL statement. If this statement
  * is a SELECT statement, the Nth column of the returned result set 
@@ -853,9 +816,8 @@
  * result column (i==1), and a NULL pointer for the first result column
  * (i==0).
  */
-DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt*,int);)
+DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt *, int);)
 #define switch_core_db_column_decltype16 sqlite3_column_decltype16
-
 /**
  * Register a callback function to be invoked whenever a new transaction
  * is committed.  The pArg argument is passed through to the callback.
@@ -869,9 +831,8 @@
  *
  ****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
  */
-DoxyDefine(void *switch_core_db_commit_hook(switch_core_db*, int(*)(void*), void*);)
+DoxyDefine(void *switch_core_db_commit_hook(switch_core_db *, int (*)(void *), void *);)
 #define switch_core_db_commit_hook sqlite3_commit_hook
-
 /**
  * This functions return true if the given input string comprises
  * one or more complete SQL statements. The parameter must be a nul-terminated 
@@ -883,7 +844,6 @@
  */
 DoxyDefine(int switch_core_db_complete(const char *sql);)
 #define switch_core_db_complete sqlite3_complete
-
 /**
  * This function is used to add new collation sequences to the
  * sqlite3 handle specified as the first argument. 
@@ -909,15 +869,10 @@
  * the first string is less than, equal to, or greater than the second
  * string. i.e. (STRING1 - STRING2).
  */
-DoxyDefine(int switch_core_db_create_collation(
-  switch_core_db*, 
-  const char *zName, 
-  int eTextRep, 
-  void*,
-  int(*xCompare)(void*,int,const void*,int,const void*)
-);)
+DoxyDefine(int switch_core_db_create_collation(switch_core_db *,
+											   const char *zName, int eTextRep, void *, int (*xCompare) (void *, int, const void *, int, const void *)
+		   );)
 #define switch_core_db_create_collation sqlite3_create_collation
-
 /**
  * The following function is used to add user functions or aggregates
  * implemented in C to the SQL langauge interpreted by SQLite. The
@@ -951,18 +906,15 @@
  * xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is
  * returned.
  */
-DoxyDefine(int switch_core_db_create_function(
-  switch_core_db *,
-  const char *zFunctionName,
-  int nArg,
-  int eTextRep,
-  void*,
-  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
-  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
-  void (*xFinal)(sqlite3_context*)
-);)
+DoxyDefine(int switch_core_db_create_function(switch_core_db *,
+											  const char *zFunctionName,
+											  int nArg,
+											  int eTextRep,
+											  void *,
+											  void (*xFunc) (sqlite3_context *, int, sqlite3_value **),
+											  void (*xStep) (sqlite3_context *, int, sqlite3_value **), void (*xFinal) (sqlite3_context *)
+		   );)
 #define switch_core_db_create_function sqlite3_create_function
-
 /**
  * Return the number of values in the current row of the result set.
  *
@@ -972,18 +924,16 @@
  * error code, or before switch_core_db_step() has been called on a 
  * compiled SQL statement, this routine returns zero.
  */
-DoxyDefine(int switch_core_db_data_count(sqlite3_stmt *pStmt);)
+DoxyDefine(int switch_core_db_data_count(sqlite3_stmt * pStmt);)
 #define switch_core_db_data_count sqlite3_data_count
-
 /**
  * Return the sqlite3* database handle to which the prepared statement given
  * in the argument belongs.  This is the same database handle that was
  * the first argument to the switch_core_db_prepare() that was used to create
  * the statement in the first place.
  */
-DoxyDefine(switch_core_db *switch_core_db_db_handle(sqlite3_stmt*);)
+	DoxyDefine(switch_core_db * switch_core_db_db_handle(sqlite3_stmt *);)
 #define switch_core_db_db_handle sqlite3_db_handle
-
 /**
 ** Return the error code for the most recent switch_core_db_* API call associated
 ** with switch_core_db handle 'db'. SQLITE_OK is returned if the most recent 
@@ -999,9 +949,8 @@
 ** code returned by this function is associated with the same error as
 ** the strings  returned by sqlite3_errmsg() and sqlite3_errmsg16().
 */
-DoxyDefine(int switch_core_db_errcode(switch_core_db *db);)
+DoxyDefine(int switch_core_db_errcode(switch_core_db * db);)
 #define switch_core_db_errcode sqlite3_errcode
-
 /**
  * Return a pointer to a UTF-8 encoded string describing in english the
  * error condition for the most recent sqlite3_* API call. The returned
@@ -1010,9 +959,8 @@
  * The string "not an error" is returned when the most recent API call was
  * successful.
  */
-DoxyDefine(const char *switch_core_db_errmsg(switch_core_db*);)
+DoxyDefine(const char *switch_core_db_errmsg(switch_core_db *);)
 #define switch_core_db_errmsg sqlite3_errmsg
-
 /**
  * A function to executes one or more statements of SQL.
  *
@@ -1053,15 +1001,13 @@
  * behavior can be modified somewhat using the sswitch_core_db_busy_handler()
  * and switch_core_db_busy_timeout() functions below.)
  */
-DoxyDefine(int switch_core_db_exec(
-  switch_core_db*,                     /* An open database */
-  const char *sql,              /* SQL to be executed */
-  sqlite3_callback,             /* Callback function */
-  void *,                       /* 1st argument to callback function */
-  char **errmsg                 /* Error msg written here */
-);)
+DoxyDefine(int switch_core_db_exec(switch_core_db *,	/* An open database */
+								   const char *sql,	/* SQL to be executed */
+								   sqlite3_callback,	/* Callback function */
+								   void *,	/* 1st argument to callback function */
+								   char **errmsg	/* Error msg written here */
+		   );)
 #define switch_core_db_exec sqlite3_exec
-
 /**
  * Return TRUE (non-zero) if the statement supplied as an argument needs
  * to be recompiled.  A statement needs to be recompiled whenever the
@@ -1071,9 +1017,8 @@
  * added or changed.
  *
  */
-DoxyDefine(int switch_core_db_expired(sqlite3_stmt*);)
+DoxyDefine(int switch_core_db_expired(sqlite3_stmt *);)
 #define switch_core_db_expired sqlite3_expired
-
 /**
  * This function is called to delete a compiled
  * SQL statement obtained by a previous call to switch_core_db_prepare().
@@ -1088,24 +1033,21 @@
  * rolled back and transactions cancelled,  depending on the circumstances,
  * and the result code returned will be SQLITE_ABORT.
  */
-DoxyDefine(int switch_core_db_finalize(sqlite3_stmt *pStmt);)
+DoxyDefine(int switch_core_db_finalize(sqlite3_stmt * pStmt);)
 #define switch_core_db_finalize sqlite3_finalize
-
 /**
  * Call this routine to free the memory that sqlite3_get_table() allocated.
  */
 DoxyDefine(void switch_core_db_free_table(char **result);)
 #define switch_core_db_free_table sqlite3_free_table
-
 /**
  * Test to see whether or not the database connection is in autocommit
  * mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
  * by default.  Autocommit is disabled by a BEGIN statement and reenabled
  * by the next COMMIT or ROLLBACK.
  */
-DoxyDefine(int switch_core_db_get_autocommit(switch_core_db*);)
+DoxyDefine(int switch_core_db_get_autocommit(switch_core_db *);)
 #define switch_core_db_get_autocommit sqlite3_get_autocommit
-
 /**
  * The following function may be used by scalar user functions to
  * associate meta-data with argument values. If the same value is passed to
@@ -1125,9 +1067,8 @@
  * expressions that are constant at compile time. This includes literal
  * values and SQL variables.
  */
-DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context*, int);)
+DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context *, int);)
 #define switch_core_db_get_auxdata sqlite3_get_auxdata
-
 /**
  * The following function may be used by scalar user functions to
  * associate meta-data with argument values. If the same value is passed to
@@ -1149,9 +1090,8 @@
  * expressions that are constant at compile time. This includes literal
  * values and SQL variables.
  */
-DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));)
+DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context *, int, void *, void (*)(void *));)
 #define switch_core_db_set_auxdata sqlite3_set_auxdata
-
 /**
  * This next routine is really just a wrapper around sqlite3_exec().
  * Instead of invoking a user-supplied callback for each row of the
@@ -1193,16 +1133,14 @@
  *
  * The return value of this routine is the same as from switch_core_db_exec().
  */
-DoxyDefine(int switch_core_db_get_table(
-  switch_core_db*,       /* An open database */
-  const char *sql,       /* SQL to be executed */
-  char ***resultp,       /* Result written to a char *[]  that this points to */
-  int *nrow,             /* Number of result rows written here */
-  int *ncolumn,          /* Number of result columns written here */
-  char **errmsg          /* Error msg written here */
-);)
+DoxyDefine(int switch_core_db_get_table(switch_core_db *,	/* An open database */
+										const char *sql,	/* SQL to be executed */
+										char ***resultp,	/* Result written to a char *[]  that this points to */
+										int *nrow,	/* Number of result rows written here */
+										int *ncolumn,	/* Number of result columns written here */
+										char **errmsg	/* Error msg written here */
+		   );)
 #define switch_core_db_get_table sqlite3_get_table
-
 /**
  * This function is called to recover from a malloc() failure that occured
  * within the SQLite library. Normally, after a single malloc() fails the 
@@ -1224,16 +1162,14 @@
  */
 DoxyDefine(int switch_core_db_global_recover();)
 #define switch_core_db_global_recover sqlite3_global_recover
-
 /** This function causes any pending database operation to abort and
  * return at its earliest opportunity.  This routine is typically
  * called in response to a user action such as pressing "Cancel"
  * or Ctrl-C where the user wants a long query operation to halt
  * immediately.
  */
-DoxyDefine(void switch_core_db_interrupt(switch_core_db*);)
+DoxyDefine(void switch_core_db_interrupt(switch_core_db *);)
 #define switch_core_db_interrupt sqlite3_interrupt
-
 /**
  * Each entry in an SQLite table has a unique integer key.  (The key is
  * the value of the INTEGER PRIMARY KEY column if there is such a column,
@@ -1243,9 +1179,8 @@
  *
  * This function is similar to the mysql_insert_id() function from MySQL.
  */
-DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db*);)
+	DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db *);)
 #define switch_core_db_last_insert_rowid sqlite3_last_insert_rowid
-
 /**
  * Open the sqlite database file "filename".  The "filename" is UTF-8
  * encoded.  An sqlite3* handle is returned in *ppDb, even
@@ -1261,12 +1196,10 @@
  * with the switch_core_db* handle should be released by passing it to
  * switch_core_db_close() when it is no longer required.
  */
-DoxyDefine(int switch_core_db_open(
-  const char *filename,   /* Database filename (UTF-8) */
-  switch_core_db **ppDb          /* OUT: SQLite db handle */
-);)
+DoxyDefine(int switch_core_db_open(const char *filename,	/* Database filename (UTF-8) */
+								   switch_core_db ** ppDb	/* OUT: SQLite db handle */
+		   );)
 #define switch_core_db_open sqlite3_open
-
 /**
  * To execute an SQL query, it must first be compiled into a byte-code
  * program using the following routine.
@@ -1289,15 +1222,13 @@
  *
  * On success, SQLITE_OK is returned.  Otherwise an error code is returned.
  */
-DoxyDefine(int switch_core_db_prepare(
-  sqlite3 *db,            /* Database handle */
-  const char *zSql,       /* SQL statement, UTF-8 encoded */
-  int nBytes,             /* Length of zSql in bytes. */
-  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
-  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
-);)
+DoxyDefine(int switch_core_db_prepare(sqlite3 * db,	/* Database handle */
+									  const char *zSql,	/* SQL statement, UTF-8 encoded */
+									  int nBytes,	/* Length of zSql in bytes. */
+									  sqlite3_stmt ** ppStmt,	/* OUT: Statement handle */
+									  const char **pzTail	/* OUT: Pointer to unused portion of zSql */
+		   );)
 #define switch_core_db_prepare sqlite3_prepare
-
 /**
  * Register a function for tracing SQL command evaluation.  The function registered by
  * switch_core_db_profile() runs at the end of each SQL statement and includes
@@ -1306,10 +1237,8 @@
  * The sqlite3_profile() API is currently considered experimental and
  * is subject to change.
  */
-DoxyDefine(void *switch_core_db_profile(switch_core_db*,
-   void(*xProfile)(void*,const char*,sqlite_uint64), void*);)
+DoxyDefine(void *switch_core_db_profile(switch_core_db *, void (*xProfile) (void *, const char *, sqlite_uint64), void *);)
 #define switch_core_db_profile sqlite3_profile
-
 /**
  * This routine configures a callback function - the progress callback - that
  * is invoked periodically during long running calls to switch_core_db_exec(),
@@ -1336,9 +1265,8 @@
  *
  ****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
  */
-DoxyDefine(void switch_core_db_progress_handler(switch_core_db*, int, int(*)(void*), void*);)
+DoxyDefine(void switch_core_db_progress_handler(switch_core_db *, int, int (*)(void *), void *);)
 #define switch_core_db_progress_handler sqlite3_progress_handler
-
 /**
  * The switch_core_db_reset() function is called to reset a compiled SQL
  * statement obtained by a previous call to switch_core_db_prepare()
@@ -1346,93 +1274,80 @@
  * Any SQL statement variables that had values bound to them using
  * the switch_core_db_bind_*() API retain their values.
  */
-DoxyDefine(int switch_core_db_reset(sqlite3_stmt *pStmt);)
+DoxyDefine(int switch_core_db_reset(sqlite3_stmt * pStmt);)
 #define switch_core_db_reset sqlite3_reset
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_blob(sqlite3_context*, const void*, int, void(*)(void*));)
+DoxyDefine(void switch_core_db_result_blob(sqlite3_context *, const void *, int, void (*)(void *));)
 #define switch_core_db_result_blob sqlite3_result_blob
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_double(sqlite3_context*, double);)
+DoxyDefine(void switch_core_db_result_double(sqlite3_context *, double);)
 #define switch_core_db_result_double sqlite3_result_double
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_error(sqlite3_context*, const char*, int);)
+DoxyDefine(void switch_core_db_result_error(sqlite3_context *, const char *, int);)
 #define switch_core_db_result_error sqlite3_result_error
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_error16(sqlite3_context*, const void*, int);)
+DoxyDefine(void switch_core_db_result_error16(sqlite3_context *, const void *, int);)
 #define switch_core_db_result_error16 sqlite3_result_error16
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_int(sqlite3_context*, int);)
+DoxyDefine(void switch_core_db_result_int(sqlite3_context *, int);)
 #define switch_core_db_result_int sqlite3_result_int
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_int64(sqlite3_context*, sqlite_int64);)
+DoxyDefine(void switch_core_db_result_int64(sqlite3_context *, sqlite_int64);)
 #define switch_core_db_result_int64 sqlite3_result_int64
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_null(sqlite3_context*);)
+DoxyDefine(void switch_core_db_result_null(sqlite3_context *);)
 #define switch_core_db_result_null sqlite3_result_null
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_text(sqlite3_context*, const char*, int, void(*)(void*));)
+DoxyDefine(void switch_core_db_result_text(sqlite3_context *, const char *, int, void (*)(void *));)
 #define switch_core_db_result_text sqlite3_result_text
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_text16(sqlite3_context*, const void*, int, void(*)(void*));)
+DoxyDefine(void switch_core_db_result_text16(sqlite3_context *, const void *, int, void (*)(void *));)
 #define switch_core_db_result_text16 sqlite3_result_text16
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));)
+DoxyDefine(void switch_core_db_result_text16le(sqlite3_context *, const void *, int, void (*)(void *));)
 #define switch_core_db_result_text16le sqlite3_result_text16le
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));)
+DoxyDefine(void switch_core_db_result_text16be(sqlite3_context *, const void *, int, void (*)(void *));)
 #define switch_core_db_result_text16be sqlite3_result_text16be
-
 /**
  * User-defined functions invoke this routine in order to
  * set their return value.
  */
-DoxyDefine(void switch_core_db_result_value(sqlite3_context*, sqlite3_value*);)
+DoxyDefine(void switch_core_db_result_value(sqlite3_context *, sqlite3_value *);)
 #define switch_core_db_result_value sqlite3_result_value
-
 /**
  * This routine registers a callback with the SQLite library.  The
  * callback is invoked (at compile-time, not at run-time) for each
@@ -1441,13 +1356,9 @@
  * SQL statement should be aborted with an error and SQLITE_IGNORE
  * if the column should be treated as a NULL value.
  */
-DoxyDefine(int switch_core_db_set_authorizer(
-  switch_core_db*,
-  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
-  void *pUserData
-);)
+DoxyDefine(int switch_core_db_set_authorizer(switch_core_db *,
+											 int (*xAuth) (void *, int, const char *, const char *, const char *, const char *), void *pUserData);)
 #define switch_core_db_set_authorizer sqlite3_set_authorizer
-
 /** 
  * After an SQL query has been compiled with a call to either
  * switch_core_db_prepare(), then this function must be
@@ -1480,9 +1391,8 @@
  * SQLITE_DONE.  Or it could be the case the the same database connection
  * is being used simulataneously by two or more threads.
  */
-DoxyDefine(int switch_core_db_step(sqlite3_stmt*);)
+DoxyDefine(int switch_core_db_step(sqlite3_stmt *);)
 #define switch_core_db_step sqlite3_step
-
 /**
  * If the following global variable is made to point to a
  * string which is the name of a directory, then all temporary files
@@ -1493,9 +1403,8 @@
  * Once switch_core_db_open() has been called, changing this variable will invalidate
  * the current temporary database, if any.
  */
-DoxyDefine(extern char *switch_core_db_temp_directory;)
+	DoxyDefine(extern char *switch_core_db_temp_directory;)
 #define switch_core_db_temp_directory sqlite3_temp_directory
-
 /**
  * This function returns the number of database rows that have been
  * modified by INSERT, UPDATE or DELETE statements since the database handle
@@ -1512,17 +1421,15 @@
  * table. To get an accurate count of the number of rows deleted, use
  * "DELETE FROM table WHERE 1" instead.
  */
-DoxyDefine(int switch_core_db_total_changes(switch_core_db*);)
+DoxyDefine(int switch_core_db_total_changes(switch_core_db *);)
 #define switch_core_db_total_changes sqlite3_total_changes
-
 /**
  * Register a function for tracing SQL command evaluation.  The function
  * registered is invoked at the first switch_core_db_step()
  * for the evaluation of an SQL statement.
  */
-DoxyDefine(void *switch_core_db_trace(switch_core_db*, void(*xTrace)(void*,const char*), void*);)
+DoxyDefine(void *switch_core_db_trace(switch_core_db *, void (*xTrace) (void *, const char *), void *);)
 #define switch_core_db_trace sqlite3_trace
-
 /**
  * Move all bindings from the first prepared statement over to the second.
  * This routine is useful, for example, if the first prepared statement
@@ -1530,17 +1437,15 @@
  * the second prepared statement then all of the bindings transfered over
  * to the second statement before the first statement is finalized.
  */
-DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);)
+DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt *, sqlite3_stmt *);)
 #define switch_core_db_transfer_bindings sqlite3_transfer_bindings
-
 /**
  * The pUserData parameter to the switch_core_db_create_function()
  * routine used to register user functions is available to
  * the implementation of the function using this call.
  */
-DoxyDefine(void *switch_core_db_user_data(sqlite3_context*);)
+DoxyDefine(void *switch_core_db_user_data(sqlite3_context *);)
 #define switch_core_db_user_data sqlite3_user_data
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1549,9 +1454,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value*);)
+DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value *);)
 #define switch_core_db_value_blob sqlite3_value_blob
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1560,9 +1464,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(int switch_core_db_value_bytes(sqlite3_value*);)
+DoxyDefine(int switch_core_db_value_bytes(sqlite3_value *);)
 #define switch_core_db_value_bytes sqlite3_value_bytes
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1571,9 +1474,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value*);)
+DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value *);)
 #define switch_core_db_value_bytes16 sqlite3_value_bytes16
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1582,9 +1484,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(double switch_core_db_value_double(sqlite3_value*);)
+DoxyDefine(double switch_core_db_value_double(sqlite3_value *);)
 #define switch_core_db_value_double sqlite3_value_double
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1593,9 +1494,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(int switch_core_db_value_int(sqlite3_value*);)
+DoxyDefine(int switch_core_db_value_int(sqlite3_value *);)
 #define switch_core_db_value_int sqlite3_value_int
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1604,9 +1504,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value*);)
+	DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value *);)
 #define switch_core_db_value_int64 sqlite3_value_int64
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1615,9 +1514,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value*);)
+DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value *);)
 #define switch_core_db_value_text sqlite3_value_text
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1626,9 +1524,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value*);)
+DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value *);)
 #define switch_core_db_value_text16 sqlite3_value_text16
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1637,9 +1534,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value*);)
+DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value *);)
 #define switch_core_db_value_text16be sqlite3_value_text16be
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1648,9 +1544,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value*);)
+DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value *);)
 #define switch_core_db_value_text16le sqlite3_value_text16le
-
 /**
  * returns information about parameters to
  * a user-defined function.  Function implementations use this routines
@@ -1659,10 +1554,8 @@
  * sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
  * column number.
  */
-DoxyDefine(int switch_core_db_value_type(sqlite3_value*);)
+DoxyDefine(int switch_core_db_value_type(sqlite3_value *);)
 #define switch_core_db_value_type sqlite3_value_type
-
-
 /**
  * This routine is a variant of the "sprintf()" from the
  * standard C library.  The resulting string is written into memory
@@ -1704,10 +1597,9 @@
  * should always use %q instead of %s when inserting text into a string 
  * literal.
  */
-DoxyDefine(char *switch_core_db_mprintf(const char*,...);)
+DoxyDefine(char *switch_core_db_mprintf(const char *, ...);)
 #define switch_core_db_mprintf sqlite3_mprintf
 #define switch_mprintf sqlite3_mprintf
-
 /**
  * This routine is a variant of the "sprintf()" from the
  * standard C library.  The resulting string is written into memory
@@ -1749,9 +1641,8 @@
  * should always use %q instead of %s when inserting text into a string 
  * literal.
  */
-DoxyDefine(char *switch_core_db_vmprintf(const char*, va_list);)
+DoxyDefine(char *switch_core_db_vmprintf(const char *, va_list);)
 #define switch_core_db_vmprintf sqlite3_vmprintf
-
 /**
  * This routine is a variant of the "sprintf()" from the
  * standard C library.  The resulting string is written into memory
@@ -1793,22 +1684,17 @@
  * should always use %q instead of %s when inserting text into a string 
  * literal.
  */
-DoxyDefine(char *switch_core_db_snprintf(int,char*,const char*, ...);)
+DoxyDefine(char *switch_core_db_snprintf(int, char *, const char *, ...);)
 #define switch_core_db_snprintf sqlite3_snprintf
-
 /**
  * call this routine to free memory malloced by a call to switch_core_db_mprintf, switch_core_db_vmprintf, or switch_core_db_snprintf
  */
 DoxyDefine(void switch_core_db_free(char *z);)
 #define switch_core_db_free sqlite3_free
-
 /** @} */
 /** @} */
-
-SWITCH_END_EXTERN_C
-
+	SWITCH_END_EXTERN_C
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_stun.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_stun.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_stun.h	Fri Mar 30 12:19:18 2007
@@ -38,59 +38,57 @@
 #define _SWITCH_STUN_PARSER_H
 
 SWITCH_BEGIN_EXTERN_C
-
 #define SWITCH_STUN_DEFAULT_PORT 3478
 #define SWITCH_STUN_PACKET_MIN_LEN 20
-
-typedef enum {
-	SWITCH_STUN_BINDING_REQUEST					= 0x0001,
-	SWITCH_STUN_BINDING_RESPONSE					= 0x0101,
-	SWITCH_STUN_BINDING_ERROR_RESPONSE				= 0x0111,
-	SWITCH_STUN_SHARED_SECRET_REQUEST				= 0x0002,
-	SWITCH_STUN_SHARED_SECRET_RESPONSE				= 0x0102,
-	SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE 		= 0x0112,
-	SWITCH_STUN_ALLOCATE_REQUEST					= 0x0003,
-	SWITCH_STUN_ALLOCATE_RESPONSE					= 0x0103,
-	SWITCH_STUN_ALLOCATE_ERROR_RESPONSE			= 0x0113,
-	SWITCH_STUN_SEND_REQUEST						= 0x0004,
-	SWITCH_STUN_SEND_RESPONSE						= 0x0104,
-	SWITCH_STUN_SEND_ERROR_RESPONSE				= 0x0114,
-	SWITCH_STUN_DATA_INDICATION					= 0x0115
+	typedef enum {
+	SWITCH_STUN_BINDING_REQUEST = 0x0001,
+	SWITCH_STUN_BINDING_RESPONSE = 0x0101,
+	SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111,
+	SWITCH_STUN_SHARED_SECRET_REQUEST = 0x0002,
+	SWITCH_STUN_SHARED_SECRET_RESPONSE = 0x0102,
+	SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112,
+	SWITCH_STUN_ALLOCATE_REQUEST = 0x0003,
+	SWITCH_STUN_ALLOCATE_RESPONSE = 0x0103,
+	SWITCH_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113,
+	SWITCH_STUN_SEND_REQUEST = 0x0004,
+	SWITCH_STUN_SEND_RESPONSE = 0x0104,
+	SWITCH_STUN_SEND_ERROR_RESPONSE = 0x0114,
+	SWITCH_STUN_DATA_INDICATION = 0x0115
 } switch_stun_message_t;
 
 typedef enum {
-	SWITCH_STUN_ATTR_MAPPED_ADDRESS				= 0x0001, /* Address */
-	SWITCH_STUN_ATTR_RESPONSE_ADDRESS				= 0x0002, /* Address */
-	SWITCH_STUN_ATTR_CHANGE_REQUEST				= 0x0003, /* UInt32 */
-	SWITCH_STUN_ATTR_SOURCE_ADDRESS				= 0x0004, /* Address */
-	SWITCH_STUN_ATTR_CHANGED_ADDRESS				= 0x0005, /* Address */
-	SWITCH_STUN_ATTR_USERNAME						= 0x0006, /* ByteString, multiple of 4 bytes */
-	SWITCH_STUN_ATTR_PASSWORD						= 0x0007, /* ByteString, multiple of 4 bytes */
-	SWITCH_STUN_ATTR_MESSAGE_INTEGRITY				= 0x0008, /* ByteString, 20 bytes */
-	SWITCH_STUN_ATTR_ERROR_CODE					= 0x0009, /* ErrorCode */
-	SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES			= 0x000a, /* UInt16List */
-	SWITCH_STUN_ATTR_REFLECTED_FROM				= 0x000b, /* Address */
-	SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES 		= 0x000c, /* TransportPrefs */
-	SWITCH_STUN_ATTR_LIFETIME						= 0x000d, /* UInt32 */
-	SWITCH_STUN_ATTR_ALTERNATE_SERVER				= 0x000e, /* Address */
-	SWITCH_STUN_ATTR_MAGIC_COOKIE					= 0x000f, /* ByteString, 4 bytes */
-	SWITCH_STUN_ATTR_BANDWIDTH						= 0x0010, /* UInt32 */
-	SWITCH_STUN_ATTR_DESTINATION_ADDRESS			= 0x0011, /* Address */
-	SWITCH_STUN_ATTR_SOURCE_ADDRESS2				= 0x0012, /* Address */
-	SWITCH_STUN_ATTR_DATA							= 0x0013, /* ByteString */
-	SWITCH_STUN_ATTR_OPTIONS						= 0x8001  /* UInt32 */
+	SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001,	/* Address */
+	SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002,	/* Address */
+	SWITCH_STUN_ATTR_CHANGE_REQUEST = 0x0003,	/* UInt32 */
+	SWITCH_STUN_ATTR_SOURCE_ADDRESS = 0x0004,	/* Address */
+	SWITCH_STUN_ATTR_CHANGED_ADDRESS = 0x0005,	/* Address */
+	SWITCH_STUN_ATTR_USERNAME = 0x0006,	/* ByteString, multiple of 4 bytes */
+	SWITCH_STUN_ATTR_PASSWORD = 0x0007,	/* ByteString, multiple of 4 bytes */
+	SWITCH_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008,	/* ByteString, 20 bytes */
+	SWITCH_STUN_ATTR_ERROR_CODE = 0x0009,	/* ErrorCode */
+	SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a,	/* UInt16List */
+	SWITCH_STUN_ATTR_REFLECTED_FROM = 0x000b,	/* Address */
+	SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES = 0x000c,	/* TransportPrefs */
+	SWITCH_STUN_ATTR_LIFETIME = 0x000d,	/* UInt32 */
+	SWITCH_STUN_ATTR_ALTERNATE_SERVER = 0x000e,	/* Address */
+	SWITCH_STUN_ATTR_MAGIC_COOKIE = 0x000f,	/* ByteString, 4 bytes */
+	SWITCH_STUN_ATTR_BANDWIDTH = 0x0010,	/* UInt32 */
+	SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011,	/* Address */
+	SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012,	/* Address */
+	SWITCH_STUN_ATTR_DATA = 0x0013,	/* ByteString */
+	SWITCH_STUN_ATTR_OPTIONS = 0x8001	/* UInt32 */
 } switch_stun_attribute_t;
 
 typedef enum {
-	SWITCH_STUN_ERROR_BAD_REQUEST					= 400,
-	SWITCH_STUN_ERROR_UNAUTHORIZED					= 401,
-	SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE			= 420,
-	SWITCH_STUN_ERROR_STALE_CREDENTIALS			= 430,
-	SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE		= 431,
-	SWITCH_STUN_ERROR_MISSING_USERNAME				= 432,
-	SWITCH_STUN_ERROR_USE_TLS						= 433,
-	SWITCH_STUN_ERROR_SERVER_ERROR					= 500,
-	SWITCH_STUN_ERROR_GLOBAL_FAILURE				= 600
+	SWITCH_STUN_ERROR_BAD_REQUEST = 400,
+	SWITCH_STUN_ERROR_UNAUTHORIZED = 401,
+	SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE = 420,
+	SWITCH_STUN_ERROR_STALE_CREDENTIALS = 430,
+	SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE = 431,
+	SWITCH_STUN_ERROR_MISSING_USERNAME = 432,
+	SWITCH_STUN_ERROR_USE_TLS = 433,
+	SWITCH_STUN_ERROR_SERVER_ERROR = 500,
+	SWITCH_STUN_ERROR_GLOBAL_FAILURE = 600
 } switch_stun_error_t;
 
 typedef enum {
@@ -138,7 +136,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
@@ -146,7 +144,7 @@
   \param value the value to look up
   \return a sring version of value
 */
-SWITCH_DECLARE(const char *)switch_stun_value_to_name(int32_t type, uint32_t value);
+SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t value);
 
 
 /*!
@@ -156,7 +154,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
@@ -165,7 +163,7 @@
   \param len the maximum size of the username buffer
   \return a pointer to the username or NULL
 */
-SWITCH_DECLARE(char *)switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute, char *username, uint16_t len);
+SWITCH_DECLARE(char *) switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute, char *username, uint16_t len);
 
 
 /*!
@@ -175,10 +173,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
@@ -197,7 +192,7 @@
   \param port the port of the mapped address
   \return true or false
 */
-SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr,  uint16_t port);
+SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr, uint16_t port);
 
 /*!
   \brief Perform a stun lookup
@@ -209,12 +204,8 @@
   \param pool the memory pool to use
   \return SUCCESS or FAIL
 */
-SWITCH_DECLARE(switch_status_t) switch_stun_lookup (char **ip, 
-												  switch_port_t *port,
-												  char *stunip,
-												  switch_port_t stunport,
-												  char **err,
-												  switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
+												   switch_port_t *port, char *stunip, switch_port_t stunport, char **err, switch_memory_pool_t *pool);
 
 
 
@@ -241,9 +232,7 @@
 ///\}
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h	Fri Mar 30 12:19:18 2007
@@ -36,9 +36,7 @@
 
 #include <switch.h>
 SWITCH_BEGIN_EXTERN_C
-
 #define SWITCH_SEQ_ESC "\033["
-
 /* Ansi Control character suffixes */
 #define SWITCH_SEQ_HOME_CHAR 'H'
 #define SWITCH_SEQ_HOME_CHAR_STR "H"
@@ -48,11 +46,9 @@
 #define SWITCH_SEQ_CLEARSCR_CHAR0 '2'
 #define SWITCH_SEQ_CLEARSCR_CHAR1 'J'
 #define SWITCH_SEQ_CLEARSCR_CHAR "2J"
-
-#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR /* Reset to Default fg/bg color */
-#define SWITCH_SEQ_AND_COLOR ";" /* To add multiple color definitions */
-#define SWITCH_SEQ_END_COLOR "m" /* To end color definitions */
-
+#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR	/* Reset to Default fg/bg color */
+#define SWITCH_SEQ_AND_COLOR ";"	/* To add multiple color definitions */
+#define SWITCH_SEQ_END_COLOR "m"	/* To end color definitions */
 /* Foreground colors values */
 #define SWITCH_SEQ_F_BLACK "30"
 #define SWITCH_SEQ_F_RED "31"
@@ -62,7 +58,6 @@
 #define SWITCH_SEQ_F_MAGEN "35"
 #define SWITCH_SEQ_F_CYAN "36"
 #define SWITCH_SEQ_F_WHITE "37"
-
 /* Background colors values */
 #define SWITCH_SEQ_B_BLACK "40"
 #define SWITCH_SEQ_B_RED "41"
@@ -72,7 +67,6 @@
 #define SWITCH_SEQ_B_MAGEN "45"
 #define SWITCH_SEQ_B_CYAN "46"
 #define SWITCH_SEQ_B_WHITE "47"
-
 /* Preset escape sequences - Change foreground colors only */
 #define SWITCH_SEQ_FBLACK SWITCH_SEQ_ESC SWITCH_SEQ_F_BLACK SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_FRED SWITCH_SEQ_ESC SWITCH_SEQ_F_RED SWITCH_SEQ_END_COLOR
@@ -82,7 +76,6 @@
 #define SWITCH_SEQ_FMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_F_MAGEN SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_FCYAN SWITCH_SEQ_ESC SWITCH_SEQ_F_CYAN SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_FWHITE SWITCH_SEQ_ESC SWITCH_SEQ_F_WHITE SWITCH_SEQ_END_COLOR
-
 #define SWITCH_SEQ_BBLACK SWITCH_SEQ_ESC SWITCH_SEQ_B_BLACK SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_BRED SWITCH_SEQ_ESC SWITCH_SEQ_B_RED SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_BGREEN SWITCH_SEQ_ESC SWITCH_SEQ_B_GREEN SWITCH_SEQ_END_COLOR
@@ -91,21 +84,17 @@
 #define SWITCH_SEQ_BMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_B_MAGEN SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_BCYAN SWITCH_SEQ_ESC SWITCH_SEQ_B_CYAN SWITCH_SEQ_END_COLOR
 #define SWITCH_SEQ_BWHITE SWITCH_SEQ_ESC SWITCH_SEQ_B_WHITE SWITCH_SEQ_END_COLOR
-
 /* Preset escape sequences */
 #define SWITCH_SEQ_HOME SWITCH_SEQ_ESC SWITCH_SEQ_HOME_CHAR_STR
 #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
-
 #ifdef WIN32
 #define SWITCH_PATH_SEPARATOR "\\"
 #else
 #define SWITCH_PATH_SEPARATOR "/"
 #endif
-
 #define SWITCH_URL_SEPARATOR "://"
-
 #define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
 #define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
 #define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
@@ -122,11 +111,10 @@
 #define SWITCH_REMOTE_MEDIA_PORT_VARIABLE "remote_media_port"
 #define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge"
 #define SWITCH_MAX_FORWARDS_VARIABLE "max_forwards"
-
 #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 enum {
 	SWITCH_FALSE = 0,
@@ -137,7 +125,7 @@
 	SSM_NA,
 	SSM_PRONOUNCED,
 	SSM_ITERATED,
-    SSM_COUNTED
+	SSM_COUNTED
 } switch_say_method_t;
 
 typedef enum {
@@ -170,7 +158,8 @@
 typedef enum {
 	SSHF_NONE = 0,
 	SSHF_OWN_THREAD = (1 << 0),
-	SSHF_FREE_ARG = (1 << 1)
+	SSHF_FREE_ARG = (1 << 1),
+	SSHF_NO_DEL = (1 << 2)
 } switch_scheduler_flag_t;
 
 typedef enum {
@@ -242,12 +231,12 @@
 } switch_caller_profile_flag_t;
 
 typedef enum {
-	SWITCH_AUDIO_COL_STR_TITLE                    = 0x01,
-	SWITCH_AUDIO_COL_STR_COPYRIGHT                = 0x02,
-	SWITCH_AUDIO_COL_STR_SOFTWARE                 = 0x03,
-	SWITCH_AUDIO_COL_STR_ARTIST                   = 0x04,
-	SWITCH_AUDIO_COL_STR_COMMENT                  = 0x05,
-	SWITCH_AUDIO_COL_STR_DATE                     = 0x06
+	SWITCH_AUDIO_COL_STR_TITLE = 0x01,
+	SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02,
+	SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03,
+	SWITCH_AUDIO_COL_STR_ARTIST = 0x04,
+	SWITCH_AUDIO_COL_STR_COMMENT = 0x05,
+	SWITCH_AUDIO_COL_STR_DATE = 0x06
 } switch_audio_col_t;
 
 typedef enum {
@@ -269,10 +258,10 @@
 </pre>
  */
 typedef enum {
-	SWITCH_VAD_FLAG_TALKING = ( 1 << 0 ),
-	SWITCH_VAD_FLAG_EVENTS_TALK = ( 1 << 1 ),
-	SWITCH_VAD_FLAG_EVENTS_NOTALK = ( 1 << 2 ),
-	SWITCH_VAD_FLAG_CNG = ( 1 << 3)
+	SWITCH_VAD_FLAG_TALKING = (1 << 0),
+	SWITCH_VAD_FLAG_EVENTS_TALK = (1 << 1),
+	SWITCH_VAD_FLAG_EVENTS_NOTALK = (1 << 2),
+	SWITCH_VAD_FLAG_CNG = (1 << 3)
 } switch_vad_flag_t;
 
 #define SWITCH_RTP_CNG_PAYLOAD 13
@@ -299,7 +288,7 @@
 </pre>
  */
 typedef enum {
-	SWITCH_RTP_FLAG_NOBLOCK = ( 1 << 0),
+	SWITCH_RTP_FLAG_NOBLOCK = (1 << 0),
 	SWITCH_RTP_FLAG_IO = (1 << 1),
 	SWITCH_RTP_FLAG_USE_TIMER = (1 << 2),
 	SWITCH_RTP_FLAG_TIMER_RECLOCK = (1 << 3),
@@ -308,8 +297,8 @@
 	SWITCH_RTP_FLAG_RAW_WRITE = (1 << 6),
 	SWITCH_RTP_FLAG_GOOGLEHACK = (1 << 7),
 	SWITCH_RTP_FLAG_VAD = (1 << 8),
-	SWITCH_RTP_FLAG_BREAK = ( 1 << 9),
-	SWITCH_RTP_FLAG_MINI = ( 1 << 10),
+	SWITCH_RTP_FLAG_BREAK = (1 << 9),
+	SWITCH_RTP_FLAG_MINI = (1 << 10),
 	SWITCH_RTP_FLAG_DATAWAIT = (1 << 11),
 	SWITCH_RTP_FLAG_BUGGY_2833 = (1 << 12),
 	SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 13),
@@ -453,7 +442,7 @@
 typedef enum {
 	SWITCH_LOG_CONSOLE = 8,
 	SWITCH_LOG_DEBUG = 7,
-	SWITCH_LOG_INFO  = 6,
+	SWITCH_LOG_INFO = 6,
 	SWITCH_LOG_NOTICE = 5,
 	SWITCH_LOG_WARNING = 4,
 	SWITCH_LOG_ERROR = 3,
@@ -512,7 +501,7 @@
 	CS_HOLD,
 	CS_HIBERNATE,
 	CS_HANGUP,
-	CS_DONE 
+	CS_DONE
 } switch_channel_state_t;
 
 
@@ -544,25 +533,25 @@
  */
 
 typedef enum {
-	CF_ANSWERED   	= (1 <<  0),
-	CF_OUTBOUND   	= (1 <<  1),
-	CF_EARLY_MEDIA	= (1 <<  2),
-	CF_ORIGINATOR	= (1 <<  3),
-	CF_TRANSFER		= (1 <<  4),
-	CF_ACCEPT_CNG	= (1 <<  5),
-	CF_LOCK_THREAD	= (1 <<  6),
-	CF_BRIDGED		= (1 <<  7),
-	CF_HOLD			= (1 <<  8),
-	CF_SERVICE		= (1 <<  9),
-	CF_TAGGED		= (1 << 10),
-	CF_WINNER		= (1 << 11),
-	CF_CONTROLLED	= (1 << 12),
-	CF_NOMEDIA		= (1 << 13),
-	CF_SUSPEND		= (1 << 14),
-	CF_EVENT_PARSE	= (1 << 15),
-    CF_REPEAT_STATE = (1 << 16),
-	CF_GEN_RINGBACK	= (1 << 17),
-	CF_RING_READY   = (1 << 18)
+	CF_ANSWERED = (1 << 0),
+	CF_OUTBOUND = (1 << 1),
+	CF_EARLY_MEDIA = (1 << 2),
+	CF_ORIGINATOR = (1 << 3),
+	CF_TRANSFER = (1 << 4),
+	CF_ACCEPT_CNG = (1 << 5),
+	CF_LOCK_THREAD = (1 << 6),
+	CF_BRIDGED = (1 << 7),
+	CF_HOLD = (1 << 8),
+	CF_SERVICE = (1 << 9),
+	CF_TAGGED = (1 << 10),
+	CF_WINNER = (1 << 11),
+	CF_CONTROLLED = (1 << 12),
+	CF_NOMEDIA = (1 << 13),
+	CF_SUSPEND = (1 << 14),
+	CF_EVENT_PARSE = (1 << 15),
+	CF_REPEAT_STATE = (1 << 16),
+	CF_GEN_RINGBACK = (1 << 17),
+	CF_RING_READY = (1 << 18)
 } switch_channel_flag_t;
 
 
@@ -600,7 +589,7 @@
 	SWITCH_SIG_NONE,
 	SWITCH_SIG_KILL,
 	SWITCH_SIG_XFER,
-    SWITCH_SIG_BREAK
+	SWITCH_SIG_BREAK
 } switch_signal_t;
 
 /*!
@@ -618,14 +607,14 @@
 </pre>
 */
 typedef enum {
-	SWITCH_CODEC_FLAG_ENCODE =			(1 <<  0),
-	SWITCH_CODEC_FLAG_DECODE =			(1 <<  1),
-	SWITCH_CODEC_FLAG_SILENCE_START =	(1 <<  2),
-	SWITCH_CODEC_FLAG_SILENCE_STOP =	(1 <<  3),
-	SWITCH_CODEC_FLAG_SILENCE =			(1 <<  4),
-	SWITCH_CODEC_FLAG_FREE_POOL =		(1 <<  5),
-	SWITCH_CODEC_FLAG_AAL2 =			(1 <<  6),
-	SWITCH_CODEC_FLAG_PASSTHROUGH =		(1 <<  7)
+	SWITCH_CODEC_FLAG_ENCODE = (1 << 0),
+	SWITCH_CODEC_FLAG_DECODE = (1 << 1),
+	SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2),
+	SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3),
+	SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
+	SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
+	SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
+	SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7)
 } switch_codec_flag_t;
 
 
@@ -641,12 +630,12 @@
 </pre>
 */
 typedef enum {
-	SWITCH_SPEECH_FLAG_NONE =			0,
-	SWITCH_SPEECH_FLAG_HASTEXT =		(1 <<  0),
-	SWITCH_SPEECH_FLAG_PEEK =			(1 <<  1),
-	SWITCH_SPEECH_FLAG_FREE_POOL =		(1 <<  2),
-	SWITCH_SPEECH_FLAG_BLOCKING =		(1 <<  3),
-	SWITCH_SPEECH_FLAG_PAUSE =			(1 <<  4)
+	SWITCH_SPEECH_FLAG_NONE = 0,
+	SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0),
+	SWITCH_SPEECH_FLAG_PEEK = (1 << 1),
+	SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2),
+	SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3),
+	SWITCH_SPEECH_FLAG_PAUSE = (1 << 4)
 
 } switch_speech_flag_t;
 
@@ -662,12 +651,12 @@
 </pre>
 */
 typedef enum {
-	SWITCH_ASR_FLAG_NONE =			0,
-	SWITCH_ASR_FLAG_DATA =			(1 <<  0),
-	SWITCH_ASR_FLAG_FREE_POOL =		(1 <<  1),
-	SWITCH_ASR_FLAG_CLOSED =		(1 <<  2),
-	SWITCH_ASR_FLAG_FIRE_EVENTS =	(1 <<  3),
-	SWITCH_ASR_FLAG_AUTO_RESUME = 	(1 <<  4)
+	SWITCH_ASR_FLAG_NONE = 0,
+	SWITCH_ASR_FLAG_DATA = (1 << 0),
+	SWITCH_ASR_FLAG_FREE_POOL = (1 << 1),
+	SWITCH_ASR_FLAG_CLOSED = (1 << 2),
+	SWITCH_ASR_FLAG_FIRE_EVENTS = (1 << 3),
+	SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4)
 } switch_asr_flag_t;
 
 /*!
@@ -678,7 +667,7 @@
 </pre>
 */
 typedef enum {
-	SWITCH_DIRECTORY_FLAG_FREE_POOL =		(1 <<  0),
+	SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0),
 
 } switch_directory_flag_t;
 
@@ -708,7 +697,7 @@
 </pre>
 */
 typedef enum {
-		SWITCH_TIMER_FLAG_FREE_POOL =		(1 <<  0),
+	SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0),
 } switch_timer_flag_t;
 
 
@@ -747,18 +736,18 @@
 </pre>
  */
 typedef enum {
-	SWITCH_FILE_FLAG_READ =			(1 <<  0),
-	SWITCH_FILE_FLAG_WRITE =		(1 <<  1),
-	SWITCH_FILE_FLAG_FREE_POOL =	(1 <<  2),
-	SWITCH_FILE_DATA_SHORT =		(1 <<  3),
-	SWITCH_FILE_DATA_INT =			(1 <<  4),
-	SWITCH_FILE_DATA_FLOAT =		(1 <<  5),
-	SWITCH_FILE_DATA_DOUBLE =		(1 <<  6),
-	SWITCH_FILE_DATA_RAW =			(1 <<  7),
-	SWITCH_FILE_PAUSE =				(1 <<  8),
-	SWITCH_FILE_NATIVE = 			(1 <<  9),
-	SWITCH_FILE_SEEK = 				(1 << 10),
-	SWITCH_FILE_OPEN =				(1 << 11)
+	SWITCH_FILE_FLAG_READ = (1 << 0),
+	SWITCH_FILE_FLAG_WRITE = (1 << 1),
+	SWITCH_FILE_FLAG_FREE_POOL = (1 << 2),
+	SWITCH_FILE_DATA_SHORT = (1 << 3),
+	SWITCH_FILE_DATA_INT = (1 << 4),
+	SWITCH_FILE_DATA_FLOAT = (1 << 5),
+	SWITCH_FILE_DATA_DOUBLE = (1 << 6),
+	SWITCH_FILE_DATA_RAW = (1 << 7),
+	SWITCH_FILE_PAUSE = (1 << 8),
+	SWITCH_FILE_NATIVE = (1 << 9),
+	SWITCH_FILE_SEEK = (1 << 10),
+	SWITCH_FILE_OPEN = (1 << 11)
 } switch_file_flag_t;
 
 typedef enum {
@@ -809,6 +798,10 @@
 	SWITCH_EVENT_PRIVATE_COMMAND	- A private command event 
 	SWITCH_EVENT_HEARTBEAT			- Machine is alive
 	SWITCH_EVENT_TRAP				- Error Trap
+	SWITCH_EVENT_ADD_SCHEDULE		- Something has been scheduled
+	SWITCH_EVENT_DEL_SCHEDULE		- Something has been unscheduled
+	SWITCH_EVENT_EXE_SCHEDULE		- Something scheduled has been executed
+	SWITCH_EVENT_RE_SCHEDULE		- Something scheduled has been rescheduled
     SWITCH_EVENT_ALL				- All events at once
 </pre>
 
@@ -851,6 +844,10 @@
 	SWITCH_EVENT_PRIVATE_COMMAND,
 	SWITCH_EVENT_HEARTBEAT,
 	SWITCH_EVENT_TRAP,
+	SWITCH_EVENT_ADD_SCHEDULE,
+	SWITCH_EVENT_DEL_SCHEDULE,
+	SWITCH_EVENT_EXE_SCHEDULE,
+	SWITCH_EVENT_RE_SCHEDULE,
 	SWITCH_EVENT_ALL
 } switch_event_types_t;
 
@@ -951,19 +948,8 @@
 typedef struct switch_buffer switch_buffer_t;
 typedef struct switch_codec_settings switch_codec_settings_t;
 
-typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
-typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
-typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
-typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
-typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
-typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t;
-typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t;
-typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t;
-typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t;
-typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
-typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
+
 typedef struct switch_io_routines switch_io_routines_t;
-typedef struct switch_io_event_hooks switch_io_event_hooks_t;
 typedef struct switch_speech_handle switch_speech_handle_t;
 typedef struct switch_asr_handle switch_asr_handle_t;
 typedef struct switch_directory_handle switch_directory_handle_t;
@@ -982,43 +968,26 @@
 typedef struct switch_management_interface switch_management_interface_t;
 typedef struct switch_core_port_allocator switch_core_port_allocator_t;
 typedef struct switch_media_bug switch_media_bug_t;
-typedef switch_bool_t (*switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t);
-typedef void (*switch_application_function_t)(switch_core_session_t *, char *);
-typedef void (*switch_event_callback_t)(switch_event_t *);
-typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t)(switch_core_session_t *, void *);
-typedef struct switch_core_scheduler_task switch_core_scheduler_task_t;
-typedef void (*switch_core_scheduler_func_t)(switch_core_scheduler_task_t *task);
-typedef switch_status_t (*switch_state_handler_t)(switch_core_session_t *);
-typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
-typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_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 **, int, switch_io_flag_t, int);
-typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
-typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int);
-typedef switch_status_t (*switch_waitfor_read_hook_t)(switch_core_session_t *, int, int);
-typedef switch_status_t (*switch_waitfor_write_hook_t)(switch_core_session_t *, int, int);
-typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char *);
-typedef switch_status_t (*switch_state_change_hook_t)(switch_core_session_t *);
+typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
+typedef void (*switch_application_function_t) (switch_core_session_t *, char *);
+typedef void (*switch_event_callback_t) (switch_event_t *);
+typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *);
+typedef struct switch_scheduler_task switch_scheduler_task_t;
+typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
+typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
 typedef struct switch_stream_handle switch_stream_handle_t;
-typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, const char *fmt, ...);
-typedef switch_status_t (*switch_api_function_t)(char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
-typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
-															void *input,
-															switch_input_type_t input_type,
-															void *buf,
-															unsigned int buflen);
+typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
+typedef switch_status_t (*switch_api_function_t) (char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
+typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
+															 switch_input_type_t input_type, void *buf, unsigned int buflen);
 typedef struct switch_say_interface switch_say_interface_t;
 typedef struct {
-    switch_input_callback_function_t input_callback;
-    void *buf;
-    uint32_t buflen;
+	switch_input_callback_function_t input_callback;
+	void *buf;
+	uint32_t buflen;
 } switch_input_args_t;
-typedef switch_status_t (*switch_say_callback_t)(switch_core_session_t *session,
-                                                 char *tosay,
-                                                 switch_say_type_t type,
-                                                 switch_say_method_t method,
-                                                 switch_input_args_t *args);
+typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session,
+												  char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
 typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *);
 typedef switch_status_t (*switch_module_reload_t) (void);
 typedef switch_status_t (*switch_module_pause_t) (void);
@@ -1028,12 +997,9 @@
 typedef switch_status_t (*switch_module_shutdown_t) (void);
 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,
-													 const char *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, const char *params,
+													 void *user_data);
 
 /* things we don't deserve to know about */
 /*! \brief A channel */
@@ -1046,9 +1012,7 @@
 struct switch_ivr_digit_stream_parser;
 
 SWITCH_END_EXTERN_C
-
 #endif
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h	Fri Mar 30 12:19:18 2007
@@ -41,24 +41,32 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
-
 #define switch_bytes_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
-
 #define SWITCH_SMAX 32767
 #define SWITCH_SMIN -32768
 #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
-
 #define switch_codec2str(codec,buf,len) snprintf(buf, len, "%s@%uk@%ui", \
                                                  codec->implementation->iananame, \
                                                  codec->implementation->samples_per_second, \
                                                  codec->implementation->microseconds_per_frame / 1000)
-
 #ifdef WIN32
 #define switch_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
 #else
 #define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
 #endif
 
+static inline switch_bool_t switch_is_digit_string(char *s) {
+
+	while(s && *s) {
+		if (*s < 48 || *s > 57) {
+			return SWITCH_FALSE;
+		}
+		s++;
+	}
+
+	return SWITCH_TRUE;
+}
+
 /*!
   \brief Evaluate the truthfullness of a string expression
   \param expr a string expression
@@ -69,7 +77,6 @@
 !strcasecmp(expr, "on") ||\
 !strcasecmp(expr, "true") ||\
 atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
-
 /*!
   \brief find local ip of the box
   \param buf the buffer to write the ip adress found into
@@ -233,7 +240,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
@@ -247,10 +254,18 @@
 #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
 SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len);
 SWITCH_DECLARE(char *) switch_url_decode(char *s);
-SWITCH_END_EXTERN_C
 
+/* malloc or DIE macros */
+#ifdef NDEBUG
+#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr )
+#define switch_zmalloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), memset(ptr, 0, len))
+#else
+#define switch_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr)
+#define switch_zmalloc(ptr, len) (void)(assert((ptr = malloc(len))),memset(ptr, 0, len))
 #endif
 
+SWITCH_END_EXTERN_C
+#endif
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_xml.h	Fri Mar 30 12:19:18 2007
@@ -62,40 +62,38 @@
 ///\ingroup core1
 ///\{
 SWITCH_BEGIN_EXTERN_C
-
-#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
-
-typedef enum {
-	SWITCH_XML_ROOT =	   (1 << 0), // root
-	SWITCH_XML_NAMEM =  (1 << 1), // name is malloced
-	SWITCH_XML_TXTM =   (1 << 2), // txt is malloced
-	SWITCH_XML_DUP   =  (1 << 3) // attribute name and value are strduped
+#define SWITCH_XML_BUFSIZE 1024	// size of internal memory buffers
+	typedef enum {
+	SWITCH_XML_ROOT = (1 << 0),	// root
+	SWITCH_XML_NAMEM = (1 << 1),	// name is malloced
+	SWITCH_XML_TXTM = (1 << 2),	// txt is malloced
+	SWITCH_XML_DUP = (1 << 3)	// attribute name and value are strduped
 } switch_xml_flag_t;
 
 /*! \brief A representation of an XML tree */
 struct switch_xml {
 	/*! tag name */
-    char *name;      
+	char *name;
 	/*! tag attributes { name, value, name, value, ... NULL } */
-    char **attr;
+	char **attr;
 	/*! tag character content, empty string if none */
-    char *txt;
-    /*! path to free on destroy*/
-    char *free_path;
+	char *txt;
+	/*! path to free on destroy */
+	char *free_path;
 	/*! tag offset from start of parent tag character content */
-    switch_size_t off;
+	switch_size_t off;
 	/*! next tag with same name in this section at this depth */
-    switch_xml_t next;
-	/*! next tag with different name in same section and depth*/
-    switch_xml_t sibling;
+	switch_xml_t next;
+	/*! next tag with different name in same section and depth */
+	switch_xml_t sibling;
 	/*! next tag, same section and depth, in original order */
-    switch_xml_t ordered;
-	/*! head of sub tag list, NULL if none*/
-    switch_xml_t child;
-	/*! parent tag, NULL if current tag is root tag*/
-    switch_xml_t parent;
+	switch_xml_t ordered;
+	/*! head of sub tag list, NULL if none */
+	switch_xml_t child;
+	/*! parent tag, NULL if current tag is root tag */
+	switch_xml_t parent;
 	/*! flags */
-    uint32_t flags;
+	uint32_t flags;
 };
 
 ///\brief Given a string of xml data and its length, parses it and creates an switch_xml
@@ -118,13 +116,13 @@
 ///\param file a file to parse
 ///\return a formated xml node or NULL
 SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file);
-    
+
 ///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
 ///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file()
 ///\ or switch_xml_parse_fd()
 ///\param fp a FILE pointer to parse
 ///\return an xml node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp);
+SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE * fp);
 
 ///\brief returns the first child tag (one level deeper) with the given name or NULL
 ///\ if not found
@@ -152,7 +150,7 @@
 ///\param xml the xml node
 ///\param idx the index
 ///\return an xml node or NULL
-switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
+	 switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
 
 ///\brief returns the name of the given tag
 ///\param xml the xml node
@@ -184,7 +182,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.
@@ -203,7 +201,7 @@
 ///\param xml the xml node
 ///\note in the case of the root node the readlock will be lifted
 SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml);
-    
+
 ///\brief returns parser error message or empty string if none
 ///\param xml the xml node
 ///\return the error string or nothing
@@ -224,7 +222,7 @@
 ///\param name the name of the tag
 ///\param off the offset
 ///\return an xml node or NULL
-switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
+	 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
@@ -237,7 +235,7 @@
 ///\param xml the xml node
 ///\param txt the text
 ///\return an xml node or NULL
-switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
+	 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
@@ -314,18 +312,15 @@
 ///\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,
 												  const char *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, const char *params);
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t * node, const char *params);
 
 ///\brief bind a search function to an external gateway
 ///\param function the search function to bind
@@ -341,11 +336,8 @@
 SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(const char *str);
 
 SWITCH_END_EXTERN_C
-
 ///\}
-
 #endif // _SWITCH_XML_H
-
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_bridgecall/mod_bridgecall.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_bridgecall/mod_bridgecall.c	Fri Mar 30 12:19:18 2007
@@ -44,11 +44,11 @@
 	char *var;
 	uint8_t no_media_bridge = 0;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
-    uint8_t do_continue = 0;
+	uint8_t do_continue = 0;
 
-    if (switch_strlen_zero(data)) {
-        return;
-    }
+	if (switch_strlen_zero(data)) {
+		return;
+	}
 
 	caller_channel = switch_core_session_get_channel(session);
 	assert(caller_channel != NULL);
@@ -60,9 +60,11 @@
 	if ((var = switch_channel_get_variable(caller_channel, "continue_on_fail"))) {
 		do_continue = switch_true(var);
 	}
-	
-	if ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var)) {
-		if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+
+	if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)
+		|| ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) {
+		if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
+			&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
 			switch_channel_set_flag(caller_channel, CF_NOMEDIA);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
@@ -72,31 +74,33 @@
 
 	if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed.  Cause: %s\n", switch_channel_cause2str(cause));
-        if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) {
-            /* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set.
-               We will pass the fail cause on when we hangup.*/
-            switch_channel_hangup(caller_channel, cause);
-        }
-        /* Otherwise.. nobody answered.  Go back to the dialplan instructions in case there was more to do. */
+		if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) {
+			/* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set.
+			   We will pass the fail cause on when we hangup. */
+			switch_channel_hangup(caller_channel, cause);
+		}
+		/* Otherwise.. nobody answered.  Go back to the dialplan instructions in case there was more to do. */
 		return;
 	} else {
 		if (no_media_bridge) {
-            switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-            switch_frame_t *read_frame;
-            /* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
-            while(switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
-                switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
-                uint8_t bad = 1;
-
-                if (SWITCH_READ_ACCEPTABLE(status) && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
-                    bad = 0;
-                }
-                if (bad) {
-                    switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    return;
-                }
-            }
+			switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
+			switch_frame_t *read_frame;
+			/* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
+			while (switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel)
+				   && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+				switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
+				uint8_t bad = 1;
+
+				if (SWITCH_READ_ACCEPTABLE(status)
+					&& switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
+					bad = 0;
+				}
+				if (bad) {
+					switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					return;
+				}
+			}
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to point-to-point mode.\n");
 			switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c	Fri Mar 30 12:19:18 2007
@@ -76,18 +76,15 @@
 		stream->write_function(stream, "<h1>FreeSWITCH Status</h1>\n<b>");
 	}
 
-	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"
-						   );
+	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");
 
 	stream->write_function(stream, "%d sessions\n", switch_core_session_count());
-	
+
 	if (html) {
 		stream->write_function(stream, "</b>\n");
 	}
@@ -98,7 +95,7 @@
 			int r;
 			refresh++;
 			r = atoi(refresh);
-			if (r > 0) { 
+			if (r > 0) {
 				stream->write_function(stream, "<META HTTP-EQUIV=REFRESH CONTENT=\"%d; URL=/api/status?refresh=%d%s\">\n", r, r, html ? "html=1" : "");
 			}
 		}
@@ -120,7 +117,7 @@
 
 	if ((mydata = strdup(data))) {
 		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-	
+
 		if (!strcmp(argv[0], "hupall")) {
 			arg = 1;
 			switch_core_session_ctl(SCSC_HUPALL, &arg);
@@ -136,17 +133,17 @@
 		} else {
 			stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", argv[0]);
 			goto end;
-		} 
+		}
 
 		stream->write_function(stream, "OK\n");
-	end:
+	  end:
 		free(mydata);
 	} else {
 		stream->write_function(stream, "MEM ERR\n");
 	}
 
-    return SWITCH_STATUS_SUCCESS;
-	
+	return SWITCH_STATUS_SUCCESS;
+
 }
 
 static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
@@ -178,11 +175,11 @@
 	if (session) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if ((xml_root = switch_xml_open_root(1, &err))) {
 		switch_xml_free(xml_root);
 	}
-	
+
 	stream->write_function(stream, "OK [%s]\n", err);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -213,13 +210,13 @@
 static switch_status_t transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 2 || argc > 4) {
@@ -229,11 +226,11 @@
 		char *dest = argv[1];
 		char *dp = argv[2];
 		char *context = argv[3];
-		
+
 		if ((session = switch_core_session_locate(uuid))) {
 
 			if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
-				 stream->write_function(stream, "OK\n");
+				stream->write_function(stream, "OK\n");
 			} else {
 				stream->write_function(stream, "ERROR\n");
 			}
@@ -252,13 +249,13 @@
 static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
-	char *argv[6] = {0};
+	char *argv[6] = { 0 };
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) {
@@ -269,9 +266,9 @@
 		char *dp = argv[3];
 		char *context = argv[4];
 		time_t when;
-		
+
 		if (*argv[0] == '+') {
-			when = time (NULL) + atol(argv[0] + 1);
+			when = time(NULL) + atol(argv[0] + 1);
 		} else {
 			when = atol(argv[0]);
 		}
@@ -291,13 +288,13 @@
 static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 1) {
@@ -309,7 +306,7 @@
 		switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
 
 		if (*argv[0] == '+') {
-			when = time (NULL) + atol(argv[0] + 1);
+			when = time(NULL) + atol(argv[0] + 1);
 		} else {
 			when = atol(argv[0]);
 		}
@@ -333,14 +330,14 @@
 
 static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 	switch_status_t status = SWITCH_STATUS_FALSE;
-	
+
 	if (isession) {
 		return status;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 1) {
@@ -365,14 +362,14 @@
 
 static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (isession) {
 		return status;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 2) {
@@ -391,7 +388,7 @@
 		} else {
 			flags |= SMF_ECHO_ALEG;
 		}
-		
+
 		status = switch_ivr_broadcast(argv[0], argv[1], flags);
 		stream->write_function(stream, "+OK Message Sent\n");
 	}
@@ -402,14 +399,14 @@
 
 static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (isession) {
 		return status;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 3) {
@@ -419,7 +416,7 @@
 		time_t when;
 
 		if (*argv[0] == '+') {
-			when = time (NULL) + atol(argv[0] + 1);
+			when = time(NULL) + atol(argv[0] + 1);
 		} else {
 			when = atol(argv[0]);
 		}
@@ -435,7 +432,7 @@
 		} else {
 			flags |= SMF_ECHO_ALEG;
 		}
-		
+
 		status = switch_ivr_schedule_broadcast(when, argv[1], argv[2], flags);
 		stream->write_function(stream, "+OK Message Scheduled\n");
 	}
@@ -445,14 +442,14 @@
 
 static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 	switch_status_t status = SWITCH_STATUS_FALSE;
-	
+
 	if (isession) {
 		return status;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 1) {
@@ -476,13 +473,13 @@
 
 static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc != 2) {
@@ -498,70 +495,70 @@
 
 static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-    switch_core_session_t *session = NULL;
-	char *argv[4] = {0};
-    char *uuid = NULL, *action = NULL, *path = NULL;
+	switch_core_session_t *session = NULL;
+	char *argv[4] = { 0 };
+	char *uuid = NULL, *action = NULL, *path = NULL;
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	if (switch_strlen_zero(cmd)) {
-        goto usage;
-    }
+		goto usage;
+	}
 
 	if ((argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
-        goto usage;
-    }
+		goto usage;
+	}
+
+	uuid = argv[0];
+	action = argv[1];
+	path = argv[2];
 
-    uuid = argv[0];
-    action = argv[1];
-    path = argv[2];
-    
-    if (!(session = switch_core_session_locate(uuid))) {
+	if (!(session = switch_core_session_locate(uuid))) {
 		stream->write_function(stream, "-Error Cannot locate session!\n");
-        return SWITCH_STATUS_SUCCESS;
-    }
-    
-    if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
-        goto usage;
-    }
-
-    if (!strcasecmp(action, "start")) {
-        switch_ivr_record_session(session, path, NULL);
-    } else if (!strcasecmp(action, "stop")) {
-        switch_ivr_stop_record_session(session, path);
-    } else {
-        goto usage;
-    }
-
-    goto done;
-
- usage:
-
-    stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
-    return SWITCH_STATUS_SUCCESS;
-
- done:
-
-    if (session) {
-        switch_core_session_rwunlock(session);
-    }
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
+		goto usage;
+	}
+
+	if (!strcasecmp(action, "start")) {
+		switch_ivr_record_session(session, path, NULL);
+	} else if (!strcasecmp(action, "stop")) {
+		switch_ivr_stop_record_session(session, path);
+	} else {
+		goto usage;
+	}
+
+	goto done;
+
+  usage:
+
+	stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
+	return SWITCH_STATUS_SUCCESS;
+
+  done:
+
+	if (session) {
+		switch_core_session_rwunlock(session);
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc = 0;
 
 	if (isession) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
 	if (switch_strlen_zero(cmd) || argc < 2) {
@@ -569,7 +566,7 @@
 	} else {
 		char *uuid = argv[0];
 		char *dest = argv[1];
-		
+
 		if ((session = switch_core_session_locate(uuid))) {
 			switch_channel_t *channel = switch_core_session_get_channel(session);
 
@@ -593,7 +590,7 @@
 {
 	switch_channel_t *caller_channel;
 	switch_core_session_t *caller_session;
-	char *argv[7] = {0};
+	char *argv[7] = { 0 };
 	int i = 0, x, argc = 0;
 	char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
 	uint32_t timeout = 60;
@@ -612,12 +609,12 @@
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	for(x = 0; x < argc; x++) {
+	for (x = 0; x < argc; x++) {
 		if (!strcasecmp(argv[x], "undef")) {
 			argv[x] = NULL;
 		}
 	}
-	
+
 	if (!strcasecmp(argv[0], "machine")) {
 		machine = 1;
 		i++;
@@ -629,7 +626,7 @@
 	context = argv[i++];
 	cid_name = argv[i++];
 	cid_num = argv[i++];
-	
+
 	if (!dp) {
 		dp = "XML";
 	}
@@ -649,13 +646,13 @@
 			stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause));
 		}
 		return SWITCH_STATUS_SUCCESS;
-	} 
+	}
 
 	caller_channel = switch_core_session_get_channel(caller_session);
 	assert(caller_channel != NULL);
 	switch_channel_clear_state_handler(caller_channel, NULL);
 
-	if (*exten == '&'  && *(exten + 1)) {
+	if (*exten == '&' && *(exten + 1)) {
 		switch_caller_extension_t *extension = NULL;
 		char *app_name = switch_core_session_strdup(caller_session, (exten + 1));
 		char *arg = NULL, *e;
@@ -689,6 +686,83 @@
 	return SWITCH_STATUS_SUCCESS;;
 }
 
+static void sch_api_callback(switch_scheduler_task_t *task)
+{
+	char *cmd, *arg = NULL;
+	switch_stream_handle_t stream = { 0 };
+
+	assert(task);
+
+	cmd = (char *) task->cmd_arg;
+
+	if ((arg = strchr(cmd, ' '))) {
+		*arg++ = '\0';
+	}
+
+	SWITCH_STANDARD_STREAM(stream);
+	switch_api_execute(cmd, arg, NULL, &stream);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data));
+	switch_safe_free(stream.data);
+}
+
+static switch_status_t sched_del_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+	uint32_t cnt = 0;
+	
+	if (switch_is_digit_string(cmd)) {
+		int64_t tmp;
+		tmp = (uint32_t) atoi(cmd);
+		if (tmp > 0) {
+			cnt = switch_scheduler_del_task_id((uint32_t)tmp);
+		}
+	} else {
+		cnt = switch_scheduler_del_task_group(cmd);
+	}
+
+	stream->write_function(stream, "DELETED: %u\n", cnt);
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sched_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+	char *tm = NULL, *dcmd, *group;
+	time_t when;
+
+	assert(cmd != NULL);
+	tm = strdup(cmd);
+	assert(tm != NULL);
+
+	if ((group = strchr(tm, ' '))) {
+		uint32_t id;
+
+		*group++ = '\0';
+
+		if ((dcmd = strchr(group, ' '))) {
+			*dcmd++ = '\0';
+
+			if (*tm == '+') {
+				when = time(NULL) + atol(tm + 1);
+			} else {
+				when = atol(tm);
+			}
+		
+			id = switch_scheduler_add_task(when, sch_api_callback, (char *) __SWITCH_FUNC__, group, 0, strdup(dcmd), SSHF_FREE_ARG);
+			stream->write_function(stream, "ADDED: %u\n", id);
+			goto good;
+		} 
+	}
+
+	stream->write_function(stream, "Invalid syntax\n");
+
+ good:
+
+	switch_safe_free(tm);
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
 struct holder {
 	switch_stream_handle_t *stream;
 	char *http;
@@ -696,7 +770,8 @@
 	int print_title;
 };
 
-static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
+static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
 	struct holder *holder = (struct holder *) pArg;
 	int x;
 
@@ -706,7 +781,7 @@
 			holder->stream->write_function(holder->stream, "\n<tr>");
 		}
 
-		for(x = 0; x < argc; x++) {
+		for (x = 0; x < argc; x++) {
 			if (holder->http) {
 				holder->stream->write_function(holder->stream, "<td>");
 				holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
@@ -714,13 +789,13 @@
 				holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ",");
 			}
 		}
-	} 
+	}
 
 	if (holder->http) {
 		holder->stream->write_function(holder->stream, "<tr bgcolor=%s>", holder->count % 2 == 0 ? "eeeeee" : "ffffff");
 	}
 
-	for(x = 0; x < argc; x++) {
+	for (x = 0; x < argc; x++) {
 		if (holder->http) {
 			holder->stream->write_function(holder->stream, "<td>");
 			holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
@@ -738,7 +813,7 @@
 	char sql[1024];
 	char *errmsg;
 	switch_core_db_t *db = switch_core_db_handle();
-	struct holder holder = {0};
+	struct holder holder = { 0 };
 	int help = 0;
 
 	if (session) {
@@ -747,7 +822,7 @@
 
 	if (stream->event) {
 		holder.http = switch_event_get_header(stream->event, "http-host");
-	} 
+	}
 
 	holder.print_title = 1;
 
@@ -756,14 +831,16 @@
 	if (!cmd) {
 		stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax);
 		return SWITCH_STATUS_SUCCESS;
-	} else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"dialplan") || !strcmp(cmd,"file") || !strcmp(cmd,"timer")) {
-		sprintf (sql, "select type, name from interfaces where type = '%s'", cmd);
-	} else if (!strcmp(cmd,"application") || !strcmp(cmd,"api")) {
-		sprintf (sql, "select name, description, syntax from interfaces where type = '%s' and description != ''" , cmd);
-	} else if ( !strcmp(cmd,"calls")) {
-		sprintf (sql, "select * from calls");
-	} else if ( !strcmp(cmd,"channels")) {
-		sprintf (sql, "select * from channels");
+	} else if (!strcmp(cmd, "codec") || !strcmp(cmd, "dialplan") || !strcmp(cmd, "file") || !strcmp(cmd, "timer")) {
+		sprintf(sql, "select type, name from interfaces where type = '%s'", cmd);
+	} else if (!strcmp(cmd, "tasks")) {
+		sprintf(sql, "select * from %s", cmd);
+	} else if (!strcmp(cmd, "application") || !strcmp(cmd, "api")) {
+		sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", cmd);
+	} else if (!strcmp(cmd, "calls")) {
+		sprintf(sql, "select * from calls");
+	} else if (!strcmp(cmd, "channels")) {
+		sprintf(sql, "select * from channels");
 	} else if (!strncasecmp(cmd, "help", 4)) {
 		char *cmdname = NULL;
 
@@ -771,15 +848,15 @@
 		holder.print_title = 0;
 		if ((cmdname = strchr(cmd, ' ')) != 0) {
 			*cmdname++ = '\0';
-			snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
+			snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
 		} else {
-			snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'");
+			snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'");
 		}
 	} else {
 		stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax);
 		return SWITCH_STATUS_SUCCESS;
 	}
-    
+
 	holder.stream = stream;
 	holder.count = 0;
 
@@ -794,7 +871,7 @@
 	}
 
 	if (errmsg) {
-		stream->write_function(stream, "SQL ERR [%s]\n",errmsg);
+		stream->write_function(stream, "SQL ERR [%s]\n", errmsg);
 		switch_core_db_free(errmsg);
 		errmsg = NULL;
 	} else if (help) {
@@ -811,7 +888,7 @@
 static switch_status_t version_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	char version_string[1024];
-	snprintf(version_string, sizeof(version_string) - 1,  "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
+	snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
 
 	stream->write_function(stream, version_string);
 	return SWITCH_STATUS_SUCCESS;
@@ -822,10 +899,10 @@
 	char showcmd[1024];
 	int all = 0;
 	if (switch_strlen_zero(cmd)) {
-		sprintf (showcmd, "help");
+		sprintf(showcmd, "help");
 		all = 1;
 	} else {
-		snprintf(showcmd, sizeof(showcmd) -1, "help %s", cmd);
+		snprintf(showcmd, sizeof(showcmd) - 1, "help %s", cmd);
 	}
 
 	if (all) {
@@ -837,12 +914,28 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_api_interface_t sched_del_api_interface = {
+	/*.interface_name */ "sched_del",
+	/*.desc */ "Delete a Scheduled task",
+	/*.function */ sched_del_function,
+	/*.syntax */ "<task_id>|<group_id>",
+	/*.next */ NULL
+};
+
+static switch_api_interface_t sched_api_api_interface = {
+	/*.interface_name */ "sched_api",
+	/*.desc */ "Schedule an api command",
+	/*.function */ sched_api_function,
+	/*.syntax */ "[+]<time> <group_name> <command_string>",
+	/*.next */ &sched_del_api_interface
+};
+
 static switch_api_interface_t sched_transfer_api_interface = {
 	/*.interface_name */ "sched_transfer",
 	/*.desc */ "Schedule a broadcast event to a running call",
 	/*.function */ sched_transfer_function,
 	/*.syntax */ "[+]<time> <uuid> <extension> [<dialplan>] [<context>]",
-	/*.next */ NULL
+	/*.next */ &sched_api_api_interface
 };
 
 static switch_api_interface_t sched_broadcast_api_interface = {
@@ -986,7 +1079,8 @@
 	/*.interface_name */ "originate",
 	/*.desc */ "Originate a Call",
 	/*.function */ originate_function,
-	/*.syntax */ "<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
+	/*.syntax */
+	"<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
 	/*.next */ &kill_api_interface
 };
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c	Fri Mar 30 12:19:18 2007
@@ -39,7 +39,7 @@
 static switch_api_interface_t conf_api_interface;
 
 /* Size to allocate for audio buffers */
-#define CONF_BUFFER_SIZE 1024 * 128 
+#define CONF_BUFFER_SIZE 1024 * 128
 #define CONF_EVENT_MAINT "conference::maintenence"
 #define CONF_DEFAULT_LEADIN 20
 
@@ -53,7 +53,7 @@
 #endif
 
 typedef enum {
-	FILE_STOP_CURRENT, 
+	FILE_STOP_CURRENT,
 	FILE_STOP_ALL
 } file_stop_t;
 
@@ -70,20 +70,20 @@
 } globals;
 
 typedef enum {
-	CALLER_CONTROL_MUTE, 
-	CALLER_CONTROL_DEAF_MUTE, 
-	CALLER_CONTROL_ENERGY_UP, 
-	CALLER_CONTROL_ENERGY_EQU_CONF, 
-	CALLER_CONTROL_ENERGEY_DN, 
-	CALLER_CONTROL_VOL_TALK_UP, 
-	CALLER_CONTROL_VOL_TALK_ZERO, 
-	CALLER_CONTROL_VOL_TALK_DN, 
-	CALLER_CONTROL_VOL_LISTEN_UP, 
-	CALLER_CONTROL_VOL_LISTEN_ZERO, 
-	CALLER_CONTROL_VOL_LISTEN_DN, 
-	CALLER_CONTROL_HANGUP, 
-	CALLER_CONTROL_MENU, 
-	CALLER_CONTROL_DIAL, 
+	CALLER_CONTROL_MUTE,
+	CALLER_CONTROL_DEAF_MUTE,
+	CALLER_CONTROL_ENERGY_UP,
+	CALLER_CONTROL_ENERGY_EQU_CONF,
+	CALLER_CONTROL_ENERGEY_DN,
+	CALLER_CONTROL_VOL_TALK_UP,
+	CALLER_CONTROL_VOL_TALK_ZERO,
+	CALLER_CONTROL_VOL_TALK_DN,
+	CALLER_CONTROL_VOL_LISTEN_UP,
+	CALLER_CONTROL_VOL_LISTEN_ZERO,
+	CALLER_CONTROL_VOL_LISTEN_DN,
+	CALLER_CONTROL_HANGUP,
+	CALLER_CONTROL_MENU,
+	CALLER_CONTROL_DIAL,
 	CALLER_CONTROL_EVENT
 } caller_control_t;
 
@@ -97,7 +97,7 @@
 	char *key;
 	char *digits;
 	caller_control_t action;
-	void (*handler)(conference_member_t *, struct caller_control_actions *);
+	void (*handler) (conference_member_t *, struct caller_control_actions *);
 } caller_control_fn_table_t;
 
 typedef struct caller_control_actions {
@@ -112,33 +112,33 @@
 } caller_control_menu_info_t;
 
 typedef enum {
-	MFLAG_RUNNING = (1 << 0), 
-	MFLAG_CAN_SPEAK = (1 << 1), 
-	MFLAG_CAN_HEAR = (1 << 2), 
-	MFLAG_KICKED = (1 << 3), 
-	MFLAG_ITHREAD = (1 << 4), 
+	MFLAG_RUNNING = (1 << 0),
+	MFLAG_CAN_SPEAK = (1 << 1),
+	MFLAG_CAN_HEAR = (1 << 2),
+	MFLAG_KICKED = (1 << 3),
+	MFLAG_ITHREAD = (1 << 4),
 	MFLAG_NOCHANNEL = (1 << 5),
-    MFLAG_INTREE = (1 << 6),
+	MFLAG_INTREE = (1 << 6),
 	MFLAG_WASTE_BANDWIDTH = (1 << 7),
 	MFLAG_FLUSH_BUFFER = (1 << 8)
 } member_flag_t;
 
 typedef enum {
-	CFLAG_RUNNING = (1 << 0), 
-	CFLAG_DYNAMIC = (1 << 1), 
-	CFLAG_ENFORCE_MIN = (1 << 2), 
-	CFLAG_DESTRUCT = (1 << 3), 
-	CFLAG_LOCKED = (1 << 4), 
+	CFLAG_RUNNING = (1 << 0),
+	CFLAG_DYNAMIC = (1 << 1),
+	CFLAG_ENFORCE_MIN = (1 << 2),
+	CFLAG_DESTRUCT = (1 << 3),
+	CFLAG_LOCKED = (1 << 4),
 	CFLAG_ANSWERED = (1 << 5)
 } conf_flag_t;
 
 typedef enum {
-	RFLAG_CAN_SPEAK = (1 << 0), 
+	RFLAG_CAN_SPEAK = (1 << 0),
 	RFLAG_CAN_HEAR = (1 << 1)
 } relation_flag_t;
 
 typedef enum {
-	NODE_TYPE_FILE, 
+	NODE_TYPE_FILE,
 	NODE_TYPE_SPEECH
 } node_type_t;
 
@@ -178,10 +178,10 @@
 	char *kicked_sound;
 	char *caller_id_name;
 	char *caller_id_number;
-    char *sound_prefix;
-    uint32_t max_members;
-    char *maxmember_sound;
-    uint32_t anounce_count;
+	char *sound_prefix;
+	uint32_t max_members;
+	char *maxmember_sound;
+	uint32_t anounce_count;
 	switch_ivr_digit_stream_parser_t *dtmf_parser;
 	char *pin;
 	char *pin_sound;
@@ -196,7 +196,7 @@
 	uint32_t interval;
 	switch_mutex_t *mutex;
 	conference_member_t *members;
-    switch_mutex_t *member_mutex;
+	switch_mutex_t *member_mutex;
 	conference_file_node_t *fnode;
 	conference_file_node_t *async_fnode;
 	switch_memory_pool_t *pool;
@@ -254,12 +254,12 @@
 } conference_record_t;
 
 typedef enum {
-	CONF_API_SUB_ARGS_SPLIT, 
-	CONF_API_SUB_MEMBER_TARGET, 
+	CONF_API_SUB_ARGS_SPLIT,
+	CONF_API_SUB_MEMBER_TARGET,
 	CONF_API_SUB_ARGS_AS_ONE
 } conference_fntype_t;
 
-typedef void (*void_fn_t)(void);
+typedef void (*void_fn_t) (void);
 
 /* API command parser */
 typedef struct api_command {
@@ -272,69 +272,48 @@
 
 /* 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 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 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 switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t audio_bridge_on_ring(switch_core_session_t *session);
-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, 
+										  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,
 											 char *conference_name,
-                                             switch_core_session_t *session, 
-                                             char *bridgeto, 
-                                             uint32_t timeout, 
-                                             char *flags, 
-                                             char *cid_name, 
-                                             char *cid_num);
+											 switch_core_session_t *session, char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num);
 static void conference_function(switch_core_session_t *session, char *data);
-static void launch_conference_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, char *buf, switch_size_t len);
-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 *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, char *buf, switch_size_t len);
+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);
+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);
 
 /* Return a Distinct ID # */
 static uint32_t next_member_id(void)
@@ -349,7 +328,7 @@
 }
 
 /* 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;
 
@@ -368,7 +347,7 @@
 				/* 0 matches everyone.
 				   (We will still test the others brcause a real match carries more clout) */
 
-				if (rel->id == 0) { 
+				if (rel->id == 0) {
 					global = rel;
 				}
 			}
@@ -386,54 +365,54 @@
 }
 
 /* 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;
 
-    assert(conference != NULL);
-    assert(id != 0);
+	assert(conference != NULL);
+	assert(id != 0);
 
-    switch_mutex_lock(conference->member_mutex);
-    for(member = conference->members; member; member = member->next) {
-        
-        if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-            continue;
-        }
-        
-        if (member->id == id) {
-            break;
-        }
-    }
-
-    if (member && !switch_test_flag(member, MFLAG_INTREE)) {
-        member = NULL;
-    }
+	switch_mutex_lock(conference->member_mutex);
+	for (member = conference->members; member; member = member->next) {
 
-    switch_mutex_unlock(conference->member_mutex);
+		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			continue;
+		}
+
+		if (member->id == id) {
+			break;
+		}
+	}
+
+	if (member && !switch_test_flag(member, MFLAG_INTREE)) {
+		member = NULL;
+	}
+
+	switch_mutex_unlock(conference->member_mutex);
 
 	return member;
 }
 
 /* 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;
 
-	assert (conference != NULL);
-    switch_mutex_lock(conference->member_mutex);
-    for(member = conference->members; member; member = member->next) {
-        if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) {
-            switch_clear_flag_locked(member, MFLAG_RUNNING);
-            count++;
-        }
-    }
-    switch_mutex_unlock(conference->member_mutex);
+	assert(conference != NULL);
+	switch_mutex_lock(conference->member_mutex);
+	for (member = conference->members; member; member = member->next) {
+		if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) {
+			switch_clear_flag_locked(member, MFLAG_RUNNING);
+			count++;
+		}
+	}
+	switch_mutex_unlock(conference->member_mutex);
 	return count;
 }
 
 /* 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;
 
@@ -450,7 +429,7 @@
 }
 
 /* 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;
@@ -477,187 +456,186 @@
 }
 
 /* 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]; // for conference count anouncement
+	switch_event_t *event;
+	char msg[512];				// for conference count anouncement
+
+	assert(conference != NULL);
+	assert(member != NULL);
+
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(member->audio_in_mutex);
+	switch_mutex_lock(member->audio_out_mutex);
+	switch_mutex_lock(member->flag_mutex);
+
+	switch_mutex_lock(conference->member_mutex);
+	member->conference = conference;
+	member->next = conference->members;
+	member->energy_level = conference->energy_level;
+	conference->members = member;
+	switch_set_flag(member, MFLAG_INTREE);
+	switch_mutex_unlock(conference->member_mutex);
+
+	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+		conference->count++;
+		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+			switch_event_fire(&event);
+		}
+
+		if (conference->count > 1 && conference->enter_sound) {
+			conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+		}
+		// anounce the total number of members in the conference
+		if (conference->count >= conference->anounce_count && conference->anounce_count > 1) {
+			snprintf(msg, sizeof(msg), "There are %d callers", conference->count);
+			conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
+		} else if (conference->count == 1) {
+			if (conference->alone_sound) {
+				conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+			} else {
+				snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
+				conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
+			}
+		}
+
+		if (conference->min && conference->count >= conference->min) {
+			switch_set_flag(conference, CFLAG_ENFORCE_MIN);
+		}
+
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
+
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member");
+			switch_event_fire(&event);
+		}
+	}
+	switch_mutex_unlock(member->flag_mutex);
+	switch_mutex_unlock(member->audio_out_mutex);
+	switch_mutex_unlock(member->audio_in_mutex);
 
-    assert(conference != NULL);
-    assert(member != NULL);
+	switch_mutex_unlock(conference->mutex);
+	status = SWITCH_STATUS_SUCCESS;
 
-    switch_mutex_lock(conference->mutex);
-    switch_mutex_lock(member->audio_in_mutex);
-    switch_mutex_lock(member->audio_out_mutex);
-    switch_mutex_lock(member->flag_mutex);
-    
-    switch_mutex_lock(conference->member_mutex);
-    member->conference = conference;
-    member->next = conference->members;
-    member->energy_level = conference->energy_level;
-    conference->members = member;
-    switch_set_flag(member, MFLAG_INTREE);
-    switch_mutex_unlock(conference->member_mutex);
-
-    if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
-        conference->count++;
-        if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-            switch_event_fire(&event);
-        }
-
-        if (conference->count > 1 && conference->enter_sound) {
-            conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
-        }
-
-        // anounce the total number of members in the conference
-        if (conference->count >= conference->anounce_count && conference->anounce_count > 1) {
-            snprintf(msg, sizeof(msg), "There are %d callers", conference->count);
-            conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
-        } else if (conference->count == 1) {
-            if (conference->alone_sound) {
-                conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
-            } else {
-                snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
-                conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
-            }
-        }
-
-        if (conference->min && conference->count >= conference->min) {
-            switch_set_flag(conference, CFLAG_ENFORCE_MIN);	
-        }
-        
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
-
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member");
-            switch_event_fire(&event);
-        }
-    }
-    switch_mutex_unlock(member->flag_mutex);
-    switch_mutex_unlock(member->audio_out_mutex);
-    switch_mutex_unlock(member->audio_in_mutex);
-
-    switch_mutex_unlock(conference->mutex);
-    status = SWITCH_STATUS_SUCCESS;
-	
 
 	return status;
 }
 
 /* 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;
-    switch_event_t *event;
+	conference_member_t *imember, *last = NULL;
+	switch_event_t *event;
+
+	assert(conference != NULL);
+	assert(member != NULL);
+
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->member_mutex);
+	switch_mutex_lock(member->audio_in_mutex);
+	switch_mutex_lock(member->audio_out_mutex);
+	switch_mutex_lock(member->flag_mutex);
+	switch_clear_flag(member, MFLAG_INTREE);
+
+	for (imember = conference->members; imember; imember = imember->next) {
+		if (imember == member) {
+			if (last) {
+				last->next = imember->next;
+			} else {
+				conference->members = imember->next;
+			}
+			break;
+		}
+		last = imember;
+	}
+
+	/* Close Unused Handles */
+	if (member->fnode) {
+		conference_file_node_t *fnode, *cur;
+		switch_memory_pool_t *pool;
+
+		fnode = member->fnode;
+		while (fnode) {
+			cur = fnode;
+			fnode = fnode->next;
+
+			if (cur->type == NODE_TYPE_SPEECH) {
+				switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+				switch_core_speech_close(&cur->sh, &flags);
+			} else {
+				switch_core_file_close(&cur->fh);
+			}
+
+			pool = cur->pool;
+			switch_core_destroy_memory_pool(&pool);
+		}
+	}
+
+	member->conference = NULL;
+
+	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
+		conference->count--;
+		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+			switch_event_fire(&event);
+		}
+
+		if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min)
+			|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0)) {
+			switch_set_flag(conference, CFLAG_DESTRUCT);
+		} else {
+			if (conference->exit_sound) {
+				conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0);
+			}
+			if (conference->count == 1 && conference->alone_sound) {
+				conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session), 0);
+			}
+		}
+
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
+
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member");
+			switch_event_fire(&event);
+		}
+	}
+	switch_mutex_unlock(conference->member_mutex);
+	switch_mutex_unlock(member->flag_mutex);
+	switch_mutex_unlock(member->audio_out_mutex);
+	switch_mutex_unlock(member->audio_in_mutex);
+	switch_mutex_unlock(conference->mutex);
+	status = SWITCH_STATUS_SUCCESS;
 
-    assert(conference != NULL);
-    assert(member != NULL);
-    
-    switch_mutex_lock(conference->mutex);
-    switch_mutex_lock(conference->member_mutex);
-    switch_mutex_lock(member->audio_in_mutex);
-    switch_mutex_lock(member->audio_out_mutex);
-    switch_mutex_lock(member->flag_mutex);
-    switch_clear_flag(member, MFLAG_INTREE);
-    
-    for (imember = conference->members; imember; imember = imember->next) {
-        if (imember == member ) {
-            if (last) {
-                last->next = imember->next;
-            } else {
-                conference->members = imember->next;
-            }
-            break;
-        }
-        last = imember;
-    }
-
-    /* Close Unused Handles */
-    if (member->fnode) {
-        conference_file_node_t *fnode, *cur;
-        switch_memory_pool_t *pool;
-
-        fnode = member->fnode;
-        while(fnode) {
-            cur = fnode;
-            fnode = fnode->next;
-
-            if (cur->type == NODE_TYPE_SPEECH) {
-                switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-                switch_core_speech_close(&cur->sh, &flags);
-            } else {
-                switch_core_file_close(&cur->fh);
-            }
-
-            pool = cur->pool;
-            switch_core_destroy_memory_pool(&pool);
-        }
-    }
-
-    member->conference = NULL;
-
-    if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
-        conference->count--;
-        if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
-            switch_event_fire(&event);
-        }
-
-        if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min) 
-            || (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0) ) {
-            switch_set_flag(conference, CFLAG_DESTRUCT);
-        } else { 
-            if (conference->exit_sound) {
-                conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0);
-            }
-            if (conference->count == 1 && conference->alone_sound) {
-                conference_play_file(conference, conference->alone_sound, 0, switch_core_session_get_channel(member->session), 0);
-            } 
-        }
-
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
-
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member");
-            switch_event_fire(&event);
-        }
-    }
-    switch_mutex_unlock(conference->member_mutex);
-    switch_mutex_unlock(member->flag_mutex);
-    switch_mutex_unlock(member->audio_out_mutex);
-    switch_mutex_unlock(member->audio_in_mutex);
-    switch_mutex_unlock(conference->mutex);
-    status = SWITCH_STATUS_SUCCESS;
-	
 
 	return status;
 }
 
 /* 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;
 	uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval);
 	uint32_t bytes = samples * 2;
 	uint8_t ready = 0;
-	switch_timer_t timer = {0};
+	switch_timer_t timer = { 0 };
 	switch_event_t *event;
 	uint8_t *file_frame;
 	uint8_t *async_file_frame;
@@ -667,9 +645,9 @@
 
 
 	if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, conference->pool) == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u  samples: %u\n", conference->interval, samples);	
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u  samples: %u\n", conference->interval, samples);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");	
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");
 		return NULL;
 	}
 
@@ -677,7 +655,7 @@
 	globals.threads++;
 	switch_mutex_unlock(globals.hash_mutex);
 
-	while(globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
+	while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
 		switch_size_t file_sample_len = samples;
 		switch_size_t file_data_len = samples * 2;
 		int has_file_data = 0;
@@ -703,9 +681,9 @@
 			switch_mutex_lock(imember->audio_in_mutex);
 			/* if there is audio in the resample buffer it takes precedence over the other data */
 			if (imember->mux_resampler && switch_buffer_inuse(imember->resample_buffer) >= bytes) {
-				imember->read = (uint32_t)switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
+				imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
 				ready++;
-			} else if ((imember->read = (uint32_t)switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) {
+			} else if ((imember->read = (uint32_t) switch_buffer_read(imember->audio_buffer, imember->frame, imember->buflen))) {
 				/* If the caller is not at the right sample rate resample him to suit and buffer accordingly */
 				if (imember->mux_resampler) {
 					int16_t *bptr = (int16_t *) imember->frame;
@@ -713,18 +691,18 @@
 					int len = (int) imember->read;
 
 					imember->mux_resampler->from_len = switch_short_to_float(bptr, imember->mux_resampler->from, (int) len / 2);
-					imember->mux_resampler->to_len = switch_resample_process(imember->mux_resampler, imember->mux_resampler->from, 
-                                                                             imember->mux_resampler->from_len, imember->mux_resampler->to, 
-                                                                             imember->mux_resampler->to_size, 0);
+					imember->mux_resampler->to_len =
+						switch_resample_process(imember->mux_resampler, imember->mux_resampler->from,
+												imember->mux_resampler->from_len, imember->mux_resampler->to, imember->mux_resampler->to_size, 0);
 					switch_float_to_short(imember->mux_resampler->to, out, len);
 					len = imember->mux_resampler->to_len * 2;
 					switch_buffer_write(imember->resample_buffer, out, len);
 					if (switch_buffer_inuse(imember->resample_buffer) >= bytes) {
-						imember->read = (uint32_t)switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
+						imember->read = (uint32_t) switch_buffer_read(imember->resample_buffer, imember->frame, bytes);
 						ready++;
 					}
 				} else {
-					ready++; /* Tally of how many channels had data */
+					ready++;	/* Tally of how many channels had data */
 				}
 			}
 			switch_mutex_unlock(imember->audio_in_mutex);
@@ -740,14 +718,10 @@
 					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
 					uint32_t rate = conference->rate;
 
-					if (switch_core_speech_read_tts(&conference->fnode->sh, 
-													file_frame, 
-													&file_data_len, 
-													&rate, 
-													&flags) == SWITCH_STATUS_SUCCESS) {
+					if (switch_core_speech_read_tts(&conference->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
 						file_sample_len = file_data_len / 2;
 					} else {
-						file_sample_len = file_data_len  = 0;
+						file_sample_len = file_data_len = 0;
 					}
 				} else if (conference->fnode->type == NODE_TYPE_FILE) {
 					switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len);
@@ -774,16 +748,16 @@
 					conference->async_fnode->done++;
 				} else {
 					if (has_file_data) {
-						switch_size_t x;			
+						switch_size_t x;
 						for (x = 0; x < file_sample_len; x++) {
 							int32_t z;
 							int16_t *bptr, *muxed;
-							
+
 							muxed = (int16_t *) file_frame;
 							bptr = (int16_t *) async_file_frame;
 							z = muxed[x] + bptr[x];
 							switch_normalize_to_16bit(z);
-							muxed[x] = (int16_t)z;
+							muxed[x] = (int16_t) z;
 						}
 					} else {
 						memcpy(file_frame, async_file_frame, file_sample_len * 2);
@@ -810,7 +784,7 @@
 						continue;
 					}
 
-					if (imember->read) { /* mux the frame with the collective */
+					if (imember->read) {	/* mux the frame with the collective */
 						uint32_t x;
 						int16_t *bptr, *muxed;
 
@@ -819,7 +793,7 @@
 							conference_relationship_t *rel;
 
 							if ((rel = member_get_relationship(omember, imember))) {
-								if (! switch_test_flag(rel, RFLAG_CAN_HEAR)) {
+								if (!switch_test_flag(rel, RFLAG_CAN_HEAR)) {
 									continue;
 								}
 							}
@@ -830,7 +804,7 @@
 							conference_relationship_t *rel;
 
 							if ((rel = member_get_relationship(imember, omember))) {
-								if (! switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
+								if (!switch_test_flag(rel, RFLAG_CAN_SPEAK)) {
 									continue;
 								}
 							}
@@ -839,22 +813,22 @@
 						if (imember->read > imember->len) {
 							imember->len = imember->read;
 						}
-						
+
 						bptr = (int16_t *) imember->frame;
 						muxed = (int16_t *) omember->mux_frame;
 
-						
+
 						for (x = 0; x < imember->read / 2; x++) {
 							int32_t z = muxed[x] + bptr[x];
 							switch_normalize_to_16bit(z);
-							muxed[x] = (int16_t)z;
+							muxed[x] = (int16_t) z;
 						}
-						
+
 						ready++;
 					}
 				}
 			}
-			
+
 			/* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */
 			for (imember = conference->members; imember; imember = imember->next) {
 				if (switch_test_flag(imember, MFLAG_RUNNING)) {
@@ -894,7 +868,7 @@
 		}
 
 		switch_mutex_unlock(conference->mutex);
-	} /* Rinse ... Repeat */
+	}							/* Rinse ... Repeat */
 
 	if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
@@ -908,36 +882,36 @@
 	}
 
 	switch_core_timer_destroy(&timer);
-    
+
 	if (switch_test_flag(conference, CFLAG_DESTRUCT)) {
 
 		switch_mutex_lock(conference->mutex);
 
-		/* Close Unused Handles */ 
+		/* Close Unused Handles */
 		if (conference->fnode) {
-			conference_file_node_t *fnode, *cur; 
-			switch_memory_pool_t *pool; 
+			conference_file_node_t *fnode, *cur;
+			switch_memory_pool_t *pool;
+
+			fnode = conference->fnode;
+			while (fnode) {
+				cur = fnode;
+				fnode = fnode->next;
+
+				if (cur->type == NODE_TYPE_SPEECH) {
+					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+					switch_core_speech_close(&cur->sh, &flags);
+				} else {
+					switch_core_file_close(&cur->fh);
+				}
 
-			fnode = conference->fnode; 
-			while (fnode) { 
-				cur = fnode; 
-				fnode = fnode->next; 
-
-				if (cur->type == NODE_TYPE_SPEECH) { 
-					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; 
-					switch_core_speech_close(&cur->sh, &flags); 
-				} else { 
-					switch_core_file_close(&cur->fh); 
-				} 
-
-				pool = cur->pool; 
-				switch_core_destroy_memory_pool(&pool); 
-			} 
-			conference->fnode = NULL; 
-		} 
+				pool = cur->pool;
+				switch_core_destroy_memory_pool(&pool);
+			}
+			conference->fnode = NULL;
+		}
 
-        switch_mutex_lock(conference->member_mutex);
-		for(imember = conference->members; imember; imember = imember->next) {
+		switch_mutex_lock(conference->member_mutex);
+		for (imember = conference->members; imember; imember = imember->next) {
 			switch_channel_t *channel;
 
 			if (!switch_test_flag(imember, MFLAG_NOCHANNEL)) {
@@ -946,8 +920,8 @@
 				/* add this little bit to preserve the bridge cause code in case of an early media call that */
 				/* never answers */
 				if (switch_test_flag(conference, CFLAG_ANSWERED)) {
-					switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);	
-				} else 	{
+					switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+				} else {
 					/* put actual cause code from outbound channel hangup here */
 					switch_channel_hangup(channel, conference->bridge_hangup_cause);
 				}
@@ -955,11 +929,11 @@
 
 			switch_clear_flag_locked(imember, MFLAG_RUNNING);
 		}
-        switch_mutex_unlock(conference->member_mutex);
+		switch_mutex_unlock(conference->member_mutex);
 
 		switch_mutex_unlock(conference->mutex);
 
-		switch_mutex_lock(globals.hash_mutex);		
+		switch_mutex_lock(globals.hash_mutex);
 		switch_core_hash_delete(globals.conference_hash, conference->name);
 		switch_mutex_unlock(globals.hash_mutex);
 
@@ -979,44 +953,44 @@
 	}
 
 	switch_mutex_lock(globals.hash_mutex);
-	globals.threads--;	
+	globals.threads--;
 	switch_mutex_unlock(globals.hash_mutex);
 
 	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) {
 		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
 			conf_api_sub_mute(member, NULL, NULL);
 		} else {
 			conf_api_sub_unmute(member, NULL, NULL);
-            if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
-                conf_api_sub_undeaf(member, NULL, NULL);
-            }
+			if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
+				conf_api_sub_undeaf(member, NULL, NULL);
+			}
 		}
 	}
 }
 
-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) {
 		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
 			conf_api_sub_mute(member, NULL, NULL);
-            if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
-                conf_api_sub_deaf(member, NULL, NULL);
-            }
+			if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+				conf_api_sub_deaf(member, NULL, NULL);
+			}
 		} else {
 			conf_api_sub_unmute(member, NULL, NULL);
-            if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
-                conf_api_sub_undeaf(member, NULL, NULL);
-            }
+			if (!switch_test_flag(member, MFLAG_CAN_HEAR)) {
+				conf_api_sub_undeaf(member, NULL, NULL);
+			}
 		}
 	}
 }
 
-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)
 {
 	if (member != NULL) {
 		char msg[512];
@@ -1045,9 +1019,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1070,10 +1044,10 @@
 		}
 	}
 }
-					
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1100,9 +1074,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1127,9 +1101,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1153,9 +1127,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1180,9 +1154,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1207,9 +1181,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1233,9 +1207,9 @@
 	}
 }
 
-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)
 {
-	if (member!= NULL) {
+	if (member != NULL) {
 		char msg[512];
 		switch_event_t *event;
 
@@ -1260,7 +1234,7 @@
 	}
 }
 
-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 (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
@@ -1275,25 +1249,20 @@
 	}
 }
 
-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;
 	switch_status_t status;
 	switch_frame_t *read_frame = NULL;
 	switch_codec_t *read_codec;
-	uint32_t hangover = 40, 
-		hangunder = 15, 
-		hangover_hits = 0, 
-		hangunder_hits = 0, 
-		energy_level = 0, 
-		diff_level = 400;
+	uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
 	uint8_t talking = 0;
 
 	assert(member != NULL);
@@ -1307,7 +1276,7 @@
 	/* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it 
 	   and mux it with any audio from other channels. */
 
-	while(switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
+	while (switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
 		/* Read a frame. */
 		status = switch_core_session_read_frame(member->session, &read_frame, -1, 0);
 
@@ -1359,7 +1328,7 @@
 							switch_event_fire(&event);
 						}
 					}
-				} 
+				}
 			} else {
 				if (hangunder_hits) {
 					hangunder_hits--;
@@ -1376,7 +1345,7 @@
 							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
 							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "stop-talking");
 							switch_event_fire(&event);
-						}					
+						}
 					}
 				}
 			}
@@ -1389,9 +1358,9 @@
 				int len = (int) read_frame->datalen;;
 
 				member->read_resampler->from_len = switch_short_to_float(bptr, member->read_resampler->from, (int) len / 2);
-				member->read_resampler->to_len = switch_resample_process(member->read_resampler, member->read_resampler->from, 
-																		 member->read_resampler->from_len, member->read_resampler->to, 
-																		 member->read_resampler->to_size, 0);
+				member->read_resampler->to_len =
+					switch_resample_process(member->read_resampler, member->read_resampler->from,
+											member->read_resampler->from_len, member->read_resampler->to, member->read_resampler->to_size, 0);
 				switch_float_to_short(member->read_resampler->to, read_frame->data, len);
 				len = member->read_resampler->to_len * 2;
 				read_frame->datalen = len;
@@ -1415,7 +1384,7 @@
 }
 
 /* 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)
 {
 	if (member != NULL) {
 		switch_thread_t *thread;
@@ -1430,30 +1399,31 @@
 }
 
 static caller_control_fn_table_t ccfntbl[] = {
-	{"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle}, 
-	{"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle}, 
-	{"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up}, 
-	{"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf}, 
-	{"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn}, 
-	{"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up}, 
-	{"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero}, 
-	{"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn}, 
-	{"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up}, 
-	{"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero}, 
-	{"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn}, 
-	{"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup}, 
+	{"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle},
+	{"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle},
+	{"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up},
+	{"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf},
+	{"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn},
+	{"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up},
+	{"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero},
+	{"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn},
+	{"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up},
+	{"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero},
+	{"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn},
+	{"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup},
 	{"event", NULL, CALLER_CONTROL_EVENT, conference_loop_fn_event}
 };
+
 #define CCFNTBL_QTY (sizeof(ccfntbl)/sizeof(ccfntbl[0]))
 
 /* 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_frame_t write_frame = {0};
+	switch_frame_t write_frame = { 0 };
 	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
-	switch_timer_t timer = {0};
+	switch_timer_t timer = { 0 };
 	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_bytes_per_frame(member->conference->rate, member->conference->interval);
@@ -1465,16 +1435,13 @@
 	assert(channel != NULL);
 	assert(member->conference != NULL);
 
-	if (switch_core_timer_init(&timer, 
-							   member->conference->timer_name, 
-							   interval,
+	if (switch_core_timer_init(&timer, member->conference->timer_name, interval,
 							   //member->conference->interval, 
-							   samples, 
-							   NULL) == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u  samples: %u\n", 
-						  member->conference->timer_name, interval, samples);	
+							   samples, NULL) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u  samples: %u\n",
+						  member->conference->timer_name, interval, samples);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");	
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");
 		return;
 	}
 
@@ -1490,16 +1457,17 @@
 	launch_conference_loop_input(member, switch_core_session_get_pool(member->session));
 
 	/* build a digit stream object */
-	if (member->conference->dtmf_parser != NULL && 
-        switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
+	if (member->conference->dtmf_parser != NULL
+		&& switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning Will Robinson, there is no digit parser stream object\n");
 	}
 
-	/* Fair WARNING, If you expect the caller to hear anything or for digit handling to be proccessed, 		*/
-	/* you better not block this thread loop for more than the duration of member->conference->timer_name!	*/
-	while(switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(member, MFLAG_ITHREAD) && switch_channel_ready(channel)) {
+	/* Fair WARNING, If you expect the caller to hear anything or for digit handling to be proccessed,      */
+	/* you better not block this thread loop for more than the duration of member->conference->timer_name!  */
+	while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(member, MFLAG_ITHREAD)
+		   && switch_channel_ready(channel)) {
 		char dtmf[128] = "";
-		uint8_t file_frame[CONF_BUFFER_SIZE] = {0};
+		uint8_t file_frame[CONF_BUFFER_SIZE] = { 0 };
 		switch_size_t file_data_len = samples * 2;
 		switch_size_t file_sample_len = samples;
 		char *digit;
@@ -1515,8 +1483,7 @@
 			char *body = switch_event_get_body(event);
 			char *p, *freeme = NULL;
 
-			if ((p = strchr(to, '+')) && 
-				strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) {
+			if ((p = strchr(to, '+')) && strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) {
 				freeme = switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
 				to = freeme;
 			}
@@ -1550,32 +1517,26 @@
 						switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, *digit);
 				}
 			}
-            /* otherwise, clock the parser so that it can handle digit timeout detection */
+			/* otherwise, clock the parser so that it can handle digit timeout detection */
 		} else if (member->conference->dtmf_parser != NULL) {
-			caller_action = (caller_control_action_t *)switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, '\0');
+			caller_action = (caller_control_action_t *) switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, '\0');
 		}
 
 		/* if a caller action has been detected, handle it */
 		if (caller_action != NULL && caller_action->fndesc != NULL && caller_action->fndesc->handler != NULL) {
-			//switch_channel_t *channel		 = switch_core_session_get_channel(member->session);
-			//switch_caller_profile_t *profile	 = switch_channel_get_caller_profile(channel);
-            char *param = NULL;
-
-            if (caller_action->fndesc->action != CALLER_CONTROL_MENU) {
-                param = caller_action->data;
-            }
+			//switch_channel_t *channel      = switch_core_session_get_channel(member->session);
+			//switch_caller_profile_t *profile   = switch_channel_get_caller_profile(channel);
+			char *param = NULL;
 
+			if (caller_action->fndesc->action != CALLER_CONTROL_MENU) {
+				param = caller_action->data;
+			}
 #ifdef INTENSE_DEBUG
-			switch_log_printf(SWITCH_CHANNEL_LOG, 
-                              SWITCH_LOG_INFO, 
-                              "executing caller control '%s' param '%s' on call '%u, %s, %s, %s'\n", 
-                              caller_action->fndesc->key, 
-                              param ? param : "none", 
-                              member->id, 
-                              switch_channel_get_name(channel), 
-                              profile->caller_id_name, 
-                              profile->caller_id_number
-                              );
+			switch_log_printf(SWITCH_CHANNEL_LOG,
+							  SWITCH_LOG_INFO,
+							  "executing caller control '%s' param '%s' on call '%u, %s, %s, %s'\n",
+							  caller_action->fndesc->key,
+							  param ? param : "none", member->id, switch_channel_get_name(channel), profile->caller_id_name, profile->caller_id_number);
 #endif
 
 			caller_action->fndesc->handler(member, caller_action);
@@ -1586,7 +1547,7 @@
 
 		/* handle file and TTS frames */
 		if (member->fnode) {
-            switch_mutex_lock(member->flag_mutex);
+			switch_mutex_lock(member->flag_mutex);
 			/* if we are done, clean it up */
 			if (member->fnode->done) {
 				conference_file_node_t *fnode;
@@ -1610,19 +1571,15 @@
 				/* skip this frame until leadin time has expired */
 				if (member->fnode->leadin) {
 					member->fnode->leadin--;
-				} else {	/* send the node frame instead of the conference frame to the call leg */
+				} else {		/* send the node frame instead of the conference frame to the call leg */
 					if (member->fnode->type == NODE_TYPE_SPEECH) {
 						switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
 						uint32_t rate = member->conference->rate;
 
-						if (switch_core_speech_read_tts(&member->fnode->sh, 
-														file_frame, 
-														&file_data_len, 
-														&rate, 
-														&flags) == SWITCH_STATUS_SUCCESS) {
+						if (switch_core_speech_read_tts(&member->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
 							file_sample_len = file_data_len / 2;
 						} else {
-							file_sample_len = file_data_len  = 0;
+							file_sample_len = file_data_len = 0;
 						}
 					} else if (member->fnode->type == NODE_TYPE_FILE) {
 						switch_core_file_read(&member->fnode->fh, file_frame, &file_sample_len);
@@ -1631,10 +1588,10 @@
 
 					if (file_sample_len <= 0) {
 						member->fnode->done++;
-					} else { /* there is file node data to deliver */
+					} else {	/* there is file node data to deliver */
 						write_frame.data = file_frame;
-						write_frame.datalen = (uint32_t)file_data_len;
-						write_frame.samples = (uint32_t)file_sample_len;
+						write_frame.datalen = (uint32_t) file_data_len;
+						write_frame.samples = (uint32_t) file_sample_len;
 						/* Check for output volume adjustments */
 						if (member->volume_out_level) {
 							switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
@@ -1648,22 +1605,22 @@
 					}
 				}
 			}
-            switch_mutex_unlock(member->flag_mutex);
-		} else {	/* send the conferecne frame to the call leg */
+			switch_mutex_unlock(member->flag_mutex);
+		} else {				/* send the conferecne frame to the call leg */
 			switch_buffer_t *use_buffer = NULL;
 			uint32_t mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
 
-			if (mux_used){ 
+			if (mux_used) {
 				if (mux_used < bytes) {
 					if (++low_count >= 5) {
 						/* partial frame sitting around this long is useless and builds delay */
 						switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
 					}
 					mux_used = 0;
-				} else 	if (mux_used > bytes * 2) {
+				} else if (mux_used > bytes * 2) {
 					/* getting behind, clear the buffer */
 					switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
-				} 
+				}
 			}
 
 			if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
@@ -1683,7 +1640,7 @@
 				use_buffer = member->mux_buffer;
 				low_count = 0;
 
-				if ((write_frame.datalen = (uint32_t)switch_buffer_read(use_buffer, write_frame.data, bytes))) {
+				if ((write_frame.datalen = (uint32_t) switch_buffer_read(use_buffer, write_frame.data, bytes))) {
 					if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
 						write_frame.samples = write_frame.datalen / 2;
 
@@ -1699,7 +1656,7 @@
 
 				switch_mutex_unlock(member->audio_out_mutex);
 				switch_core_timer_next(&timer);
-				
+
 			} else {
 				if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
 					switch_generate_sln_silence(write_frame.data, samples, 1400);
@@ -1711,7 +1668,7 @@
 				switch_core_timer_next(&timer);
 			}
 		}
-	} /* Rinse ... Repeat */
+	}							/* Rinse ... Repeat */
 
 	if (member->digit_stream != NULL) {
 		switch_ivr_digit_stream_destroy(member->digit_stream);
@@ -1720,8 +1677,8 @@
 	switch_clear_flag_locked(member, MFLAG_RUNNING);
 	switch_core_timer_destroy(&timer);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel leaving conference, cause: %s\n", 
-                      switch_channel_cause2str(switch_channel_get_cause(channel)));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel leaving conference, cause: %s\n",
+					  switch_channel_cause2str(switch_channel_get_cause(channel)));
 
 	/* if it's an outbound channel, store the release cause in the conference struct, we might need it */
 	if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
@@ -1729,24 +1686,24 @@
 	}
 
 	/* Wait for the input thead to end */
-	while(switch_test_flag(member, MFLAG_ITHREAD)) {
+	while (switch_test_flag(member, MFLAG_ITHREAD)) {
 		switch_yield(1000);
 	}
 }
 
 /* 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};
-	conference_member_t smember = {0}, *member;
+	switch_file_handle_t fh = { 0 };
+	conference_member_t smember = { 0 }, *member;
 	conference_record_t *rec = (conference_record_t *) obj;
 	conference_obj_t *conference = rec->conference;
 	uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval);
 	//uint32_t bytes = samples * 2;
 	uint32_t low_count = 0, mux_used;
 	char *vval;
-	switch_timer_t timer = {0};
+	switch_timer_t timer = { 0 };
 	uint32_t rlen;
 
 	if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
@@ -1791,11 +1748,8 @@
 		goto end;
 	}
 
-	if (switch_core_file_open(&fh, 
-							  rec->path, 
-							  (uint8_t)1,
-							  conference->rate,
-							  SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, 
+	if (switch_core_file_open(&fh,
+							  rec->path, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
 							  rec->pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
 		goto end;
@@ -1803,12 +1757,12 @@
 
 
 	if (switch_core_timer_init(&timer, conference->timer_name, conference->interval, samples, rec->pool) == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u  samples: %u\n", conference->interval, samples);	
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success interval: %u  samples: %u\n", conference->interval, samples);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");	
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed.  Conference Cannot Start\n");
 		goto end;
 	}
-	
+
 	if ((vval = switch_mprintf("Conference %s", conference->name))) {
 		switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
 		switch_safe_free(vval);
@@ -1816,7 +1770,7 @@
 
 	switch_core_file_set_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, "FreeSWITCH mod_conference Software Conference Module");
 
-	while(switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
+	while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
 		mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
 
 		if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
@@ -1833,8 +1787,8 @@
 			/* 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 ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data, sizeof(data)))) {
 				if (!switch_test_flag((&fh), SWITCH_FILE_PAUSE)) {
 					switch_size_t len = (switch_size_t) rlen / sizeof(int16_t);
 					if (switch_core_file_write(&fh, data, &len) != SWITCH_STATUS_SUCCESS) {
@@ -1847,9 +1801,9 @@
 		} else {
 			switch_core_timer_next(&timer);
 		}
-	} /* Rinse ... Repeat */
+	}							/* Rinse ... Repeat */
 
- end:
+  end:
 
 	switch_core_timer_destroy(&timer);
 	conference_del_member(conference, member);
@@ -1876,38 +1830,38 @@
 }
 
 /* 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;
+	conference_file_node_t *nptr;
 
-    assert(conference != NULL);
+	assert(conference != NULL);
 
-    switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->mutex);
 
-    if (stop == FILE_STOP_ALL) {
-        for (nptr = conference->fnode; nptr; nptr = nptr->next) {
-            nptr->done++;
-            count++;
-        }
+	if (stop == FILE_STOP_ALL) {
+		for (nptr = conference->fnode; nptr; nptr = nptr->next) {
+			nptr->done++;
+			count++;
+		}
 		if (conference->async_fnode) {
 			conference->async_fnode->done++;
 			count++;
 		}
-    } else {
-        if (conference->fnode) {
-            conference->fnode->done++;
-            count++;
-        }
-    }
-    
-    switch_mutex_unlock(conference->mutex);	
+	} else {
+		if (conference->fnode) {
+			conference->fnode->done++;
+			count++;
+		}
+	}
+
+	switch_mutex_unlock(conference->mutex);
 
 	return count;
 }
 
 /* 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)
 {
 	uint32_t count = 0;
 
@@ -1935,88 +1889,84 @@
 }
 
 /* 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;
-    switch_memory_pool_t *pool;
-    uint32_t count;
-    char *dfile = NULL, *expanded = NULL;
-
-    assert(conference != NULL);
-
-    switch_mutex_lock(conference->mutex);
-    switch_mutex_lock(conference->member_mutex);
-    count = conference->count;
-    switch_mutex_unlock(conference->member_mutex);
-    switch_mutex_unlock(conference->mutex);	
-
-    if (!count) {
-        status = SWITCH_STATUS_FALSE;
-        goto done;
-    }
-
-    if (channel) {
-        if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
-            file = expanded;
-        } else {
-            expanded = NULL;
-        }
-    }
-
-    if (!async && !strncasecmp(file, "say:", 4)) {
-        status = conference_say(conference, file + 4, leadin);
-        goto done;
-    } 
-
-    if (!switch_is_file_path(file)) {
-        if (conference->sound_prefix) {
-            if (!(dfile = switch_mprintf("%s/%s", conference->sound_prefix, file))) {
-                goto done;
-            }
-            file = dfile;
-        } else if (!async) {
-            status = conference_say(conference, file, leadin);
-            goto done;  
-        } else {
+	conference_file_node_t *fnode, *nptr = NULL;
+	switch_memory_pool_t *pool;
+	uint32_t count;
+	char *dfile = NULL, *expanded = NULL;
+
+	assert(conference != NULL);
+
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->member_mutex);
+	count = conference->count;
+	switch_mutex_unlock(conference->member_mutex);
+	switch_mutex_unlock(conference->mutex);
+
+	if (!count) {
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
+
+	if (channel) {
+		if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
+			file = expanded;
+		} else {
+			expanded = NULL;
+		}
+	}
+
+	if (!async && !strncasecmp(file, "say:", 4)) {
+		status = conference_say(conference, file + 4, leadin);
+		goto done;
+	}
+
+	if (!switch_is_file_path(file)) {
+		if (conference->sound_prefix) {
+			if (!(dfile = switch_mprintf("%s/%s", conference->sound_prefix, file))) {
+				goto done;
+			}
+			file = dfile;
+		} else if (!async) {
+			status = conference_say(conference, file, leadin);
+			goto done;
+		} else {
 			goto done;
 		}
-    }
+	}
+
+	/* Setup a memory pool to use. */
+	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+		status = SWITCH_STATUS_MEMERR;
+		goto done;
+	}
+
+	/* Create a node object */
+	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+		switch_core_destroy_memory_pool(&pool);
+		status = SWITCH_STATUS_MEMERR;
+		goto done;
+	}
 
-    /* Setup a memory pool to use. */
-    if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-        status = SWITCH_STATUS_MEMERR;
-        goto done;
-    }
-
-    /* Create a node object*/
-    if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-        switch_core_destroy_memory_pool(&pool);
-        status = SWITCH_STATUS_MEMERR;
-        goto done;
-    }
-
-    fnode->type = NODE_TYPE_FILE;
-    fnode->leadin = leadin;
-
-    /* Open the file */
-    if (switch_core_file_open(&fnode->fh, 
-                              file, 
-							  (uint8_t)1,
-							  conference->rate,
-                              SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, 
-                              pool) != SWITCH_STATUS_SUCCESS) {
-        switch_core_destroy_memory_pool(&pool);
-        status = SWITCH_STATUS_NOTFOUND;
-        goto done;
-    }
+	fnode->type = NODE_TYPE_FILE;
+	fnode->leadin = leadin;
 
-    fnode->pool = pool;
+	/* Open the file */
+	if (switch_core_file_open(&fnode->fh, file, (uint8_t) 1, conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, pool) !=
+		SWITCH_STATUS_SUCCESS) {
+		switch_core_destroy_memory_pool(&pool);
+		status = SWITCH_STATUS_NOTFOUND;
+		goto done;
+	}
+
+	fnode->pool = pool;
 	fnode->async = async;
-    /* Queue the node */
-    switch_mutex_lock(conference->mutex);
+	/* Queue the node */
+	switch_mutex_lock(conference->mutex);
 
 	if (async) {
 		if (conference->async_fnode) {
@@ -2028,12 +1978,12 @@
 			switch_memory_pool_t *pool;
 			switch_core_file_close(&nptr->fh);
 			pool = nptr->pool;
-            switch_core_destroy_memory_pool(&pool);
+			switch_core_destroy_memory_pool(&pool);
 		}
-		
+
 	} else {
 		for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
-		
+
 		if (nptr) {
 			nptr->next = fnode;
 		} else {
@@ -2041,1027 +1991,1002 @@
 		}
 	}
 
-    switch_mutex_unlock(conference->mutex);
+	switch_mutex_unlock(conference->mutex);
 
- done:
+  done:
 
 
-    switch_safe_free(expanded);
-    switch_safe_free(dfile);
+	switch_safe_free(expanded);
+	switch_safe_free(dfile);
 
-	
 
-    return status;
+
+	return status;
 }
 
 /* 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;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	char *dfile = NULL, *expanded = NULL;
 
-    if (member != NULL && file != NULL) {
-        conference_file_node_t *fnode, *nptr;
-        switch_memory_pool_t *pool;
-
-        if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
-            file = expanded;
-        } else {
-            expanded = NULL;
-        }
-
-        if (!strncasecmp(file, "say:", 4)) {
-            status = conference_say(member->conference, file + 4, leadin);
-            goto done;
-        } 
-
-        if (!switch_is_file_path(file)) {
-            if (member->conference->sound_prefix) {
-                if (!(dfile = switch_mprintf("%s/%s", member->conference->sound_prefix, file))) {
-                    goto done;
-                }
-                file = dfile;
-            } else {
-                status = conference_say(member->conference, file, leadin);
-                goto done;  
-            }
-        }
-
-        /* Setup a memory pool to use. */
-        if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-            status = SWITCH_STATUS_MEMERR;
-            goto done;
-        }
-
-        /* Create a node object*/
-        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-            switch_core_destroy_memory_pool(&pool);
-            status = SWITCH_STATUS_MEMERR;
-            goto done;
-        }
-
-        fnode->type = NODE_TYPE_FILE;
-        fnode->leadin = leadin;
-
-        /* Open the file */
-        if (switch_core_file_open(&fnode->fh, 
-                                  file, 
-								  (uint8_t)1,
-								  member->conference->rate,
-                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, 
-                                  pool) != SWITCH_STATUS_SUCCESS) {
-            switch_core_destroy_memory_pool(&pool);
-            status = SWITCH_STATUS_NOTFOUND;
-            goto done;
-        }
-
-        fnode->pool = pool;
-
-        /* Queue the node */
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file);
-        switch_mutex_lock(member->flag_mutex);
-        for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
-
-        if (nptr) {
-            nptr->next = fnode;
-        } else {
-            member->fnode = fnode;
-        }
-        switch_mutex_unlock(member->flag_mutex);
-
-        status = SWITCH_STATUS_SUCCESS;
-    }
+	if (member != NULL && file != NULL) {
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
 
- done:
+		if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
+			file = expanded;
+		} else {
+			expanded = NULL;
+		}
 
-    switch_safe_free(expanded);
-    switch_safe_free(dfile);
+		if (!strncasecmp(file, "say:", 4)) {
+			status = conference_say(member->conference, file + 4, leadin);
+			goto done;
+		}
 
-    return status;
-}
+		if (!switch_is_file_path(file)) {
+			if (member->conference->sound_prefix) {
+				if (!(dfile = switch_mprintf("%s/%s", member->conference->sound_prefix, file))) {
+					goto done;
+				}
+				file = dfile;
+			} else {
+				status = conference_say(member->conference, file, leadin);
+				goto done;
+			}
+		}
 
-/* 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)
-{
-    switch_status_t status = SWITCH_STATUS_FALSE;
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
+
+		/* Create a node object */
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
 
-    if (member != NULL && !switch_strlen_zero(text)) {
-        conference_obj_t *conference = (member != NULL ? member->conference : NULL);
-        conference_file_node_t *fnode, *nptr;
-        switch_memory_pool_t *pool;
-        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-
-        assert(conference != NULL);
-        
-        if (!(conference->tts_engine && conference->tts_voice)) {
-            return SWITCH_STATUS_SUCCESS;
-        }
-
-        /* Setup a memory pool to use. */
-        if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-            return SWITCH_STATUS_MEMERR;
-        }
-
-        /* Create a node object*/
-        if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-            switch_core_destroy_memory_pool(&pool);
-            return SWITCH_STATUS_MEMERR;
-        }
-
-        fnode->type = NODE_TYPE_SPEECH;
-        fnode->leadin = leadin;
-        fnode->pool = pool;
-
-        memset(&fnode->sh, 0, sizeof(fnode->sh));
-        if (switch_core_speech_open(&fnode->sh, 
-                                    conference->tts_engine, 
-                                    conference->tts_voice, 
-                                    conference->rate, 
-                                    &flags, 
-                                    fnode->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;
-        }
-
-        /* Queue the node */
-        switch_mutex_lock(member->flag_mutex);
-        for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
-
-        if (nptr) {
-            nptr->next = fnode;
-        } else {
-            member->fnode = fnode;
-        }
-
-        /* Begin Generation */
-        switch_sleep(200000);
-        switch_core_speech_feed_tts(&fnode->sh, text, &flags);
-        switch_mutex_unlock(member->flag_mutex);
+		fnode->type = NODE_TYPE_FILE;
+		fnode->leadin = leadin;
 
-        status = SWITCH_STATUS_SUCCESS;
-    }
+		/* Open the file */
+		if (switch_core_file_open(&fnode->fh,
+								  file, (uint8_t) 1, member->conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+								  pool) != SWITCH_STATUS_SUCCESS) {
+			switch_core_destroy_memory_pool(&pool);
+			status = SWITCH_STATUS_NOTFOUND;
+			goto done;
+		}
 
-    return status;
-}
+		fnode->pool = pool;
 
-/* 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)
-{
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    conference_file_node_t *fnode, *nptr;
-    switch_memory_pool_t *pool;
-    switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-    uint32_t count;
-
-    assert(conference != NULL);
-
-    if (switch_strlen_zero(text)) {
-        return SWITCH_STATUS_GENERR;
-    }
-
-    switch_mutex_lock(conference->mutex);
-    switch_mutex_lock(conference->member_mutex);
-    count = conference->count;
-    if (!(conference->tts_engine && conference->tts_voice)) {
-        count = 0;
-    }
-    switch_mutex_unlock(conference->member_mutex);
-    switch_mutex_unlock(conference->mutex);	
-
-    if (!count) {
-        return SWITCH_STATUS_FALSE;
-    }
-
-    /* Setup a memory pool to use. */
-    if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-        return SWITCH_STATUS_MEMERR;
-    }
-
-    /* Create a node object*/
-    if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-        switch_core_destroy_memory_pool(&pool);
-        return SWITCH_STATUS_MEMERR;
-    }
-
-    fnode->type = NODE_TYPE_SPEECH;
-    fnode->leadin = leadin;
-
-    memset(&fnode->sh, 0, sizeof(fnode->sh));
-    if (switch_core_speech_open(&fnode->sh, 
-                                conference->tts_engine, 
-                                conference->tts_voice, 
-                                conference->rate, 
-                                &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;
-    }
-
-    fnode->pool = pool;
-
-    /* Queue the node */
-    switch_mutex_lock(conference->mutex);
-    for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
-
-    if (nptr) {
-        nptr->next = fnode;
-    } else {
-        conference->fnode = fnode;
-    }
-
-    /* Begin Generation */
-    switch_sleep(200000);
-    switch_core_speech_feed_tts(&fnode->sh, (char *)text, &flags);
-    switch_mutex_unlock(conference->mutex);
+		/* Queue the node */
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file);
+		switch_mutex_lock(member->flag_mutex);
+		for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
 
-    status = SWITCH_STATUS_SUCCESS;
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			member->fnode = fnode;
+		}
+		switch_mutex_unlock(member->flag_mutex);
 
-    return status;
-}
+		status = SWITCH_STATUS_SUCCESS;
+	}
 
-/* 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)
-{
-    conference_member_t *member = NULL;
+  done:
 
-    assert(conference != NULL);
-    assert(stream != NULL);
-    assert(pfncallback != NULL);
+	switch_safe_free(expanded);
+	switch_safe_free(dfile);
 
-    switch_mutex_lock(conference->member_mutex);
-    for (member = conference->members; member; member = member->next) {
-        pfncallback(member, stream, data);
-    }
-    switch_mutex_unlock(conference->member_mutex);
-	
+	return status;
 }
 
-static void conference_list_pretty(conference_obj_t *conference, switch_stream_handle_t *stream)
+/* 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)
 {
-    conference_member_t *member = NULL;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
+	if (member != NULL && !switch_strlen_zero(text)) {
+		conference_obj_t *conference = (member != NULL ? member->conference : NULL);
+		conference_file_node_t *fnode, *nptr;
+		switch_memory_pool_t *pool;
+		switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
 
-    switch_mutex_lock(conference->member_mutex);
-    //		stream->write_function(stream, "<pre>Current Callers:\n");
+		assert(conference != NULL);
 
-    for (member = conference->members; member; member = member->next) {
-        switch_channel_t *channel;
-        switch_caller_profile_t *profile;
+		if (!(conference->tts_engine && conference->tts_voice)) {
+			return SWITCH_STATUS_SUCCESS;
+		}
 
-        if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-            continue;
-        }
-        channel = switch_core_session_get_channel(member->session);
-        profile = switch_channel_get_caller_profile(channel);
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			return SWITCH_STATUS_MEMERR;
+		}
 
+		/* Create a node object */
+		if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+			switch_core_destroy_memory_pool(&pool);
+			return SWITCH_STATUS_MEMERR;
+		}
 
-        stream->write_function(stream, "%u) %s (%s)\n", 
-                               member->id, 
-                               profile->caller_id_name, 
-                               profile->caller_id_number
-                               );
+		fnode->type = NODE_TYPE_SPEECH;
+		fnode->leadin = leadin;
+		fnode->pool = pool;
 
-    }
+		memset(&fnode->sh, 0, sizeof(fnode->sh));
+		if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &flags, fnode->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;
+		}
 
-    switch_mutex_unlock(conference->member_mutex);
-	
-}
+		/* Queue the node */
+		switch_mutex_lock(member->flag_mutex);
+		for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
 
-static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim)
-{
-    conference_member_t *member = NULL;
+		if (nptr) {
+			nptr->next = fnode;
+		} else {
+			member->fnode = fnode;
+		}
 
-    assert(conference != NULL);
-    assert(stream != NULL);
-    assert(delim != NULL);
+		/* Begin Generation */
+		switch_sleep(200000);
+		switch_core_speech_feed_tts(&fnode->sh, text, &flags);
+		switch_mutex_unlock(member->flag_mutex);
 
+		status = SWITCH_STATUS_SUCCESS;
+	}
 
-    switch_mutex_lock(conference->member_mutex);
+	return status;
+}
 
-    for (member = conference->members; member; member = member->next) {
-        switch_channel_t *channel;
-        switch_caller_profile_t *profile;
-        char *uuid;
-        char *name;
-        uint32_t count = 0;
+/* 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)
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	conference_file_node_t *fnode, *nptr;
+	switch_memory_pool_t *pool;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+	uint32_t count;
 
-        if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
-            continue;
-        }
+	assert(conference != NULL);
 
-        uuid = switch_core_session_get_uuid(member->session);
-        channel = switch_core_session_get_channel(member->session);
-        profile = switch_channel_get_caller_profile(channel);
-        name = switch_channel_get_name(channel);
+	if (switch_strlen_zero(text)) {
+		return SWITCH_STATUS_GENERR;
+	}
 
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->member_mutex);
+	count = conference->count;
+	if (!(conference->tts_engine && conference->tts_voice)) {
+		count = 0;
+	}
+	switch_mutex_unlock(conference->member_mutex);
+	switch_mutex_unlock(conference->mutex);
 
-        stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s", 
-                               member->id, delim, 
-                               name, delim, 
-                               uuid, delim, 
-                               profile->caller_id_name, delim, 
-                               profile->caller_id_number, delim);
+	if (!count) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-        if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
-            stream->write_function(stream, "hear");
-            count++;
-        }
+	/* Setup a memory pool to use. */
+	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+		return SWITCH_STATUS_MEMERR;
+	}
 
-        if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-            stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
-            count++;
-        }
+	/* Create a node object */
+	if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+		switch_core_destroy_memory_pool(&pool);
+		return SWITCH_STATUS_MEMERR;
+	}
 
-        stream->write_function(stream, "%s%d%s%d%s%d\n", 
-                               delim, 
-                               member->volume_in_level, delim, 
-                               member->volume_out_level, delim, 
-                               member->energy_level);
-    }
+	fnode->type = NODE_TYPE_SPEECH;
+	fnode->leadin = leadin;
 
-    switch_mutex_unlock(conference->member_mutex);
-	
-}
+	memset(&fnode->sh, 0, sizeof(fnode->sh));
+	if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &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;
+	}
 
-static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
-{
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	fnode->pool = pool;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	/* Queue the node */
+	switch_mutex_lock(conference->mutex);
+	for (nptr = conference->fnode; nptr && nptr->next; nptr = nptr->next);
 
-        switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
-        if (member->conference->muted_sound) {
-            conference_member_play_file(member, member->conference->muted_sound, 0);
-        } else {
-            char msg[512];
+	if (nptr) {
+		nptr->next = fnode;
+	} else {
+		conference->fnode = fnode;
+	}
 
-            snprintf(msg, sizeof(msg), "Muted");
-            conference_member_say(member, msg, 0);
-        }
-        if (stream != NULL) {
-            stream->write_function(stream, "OK mute %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+	/* Begin Generation */
+	switch_sleep(200000);
+	switch_core_speech_feed_tts(&fnode->sh, (char *) text, &flags);
+	switch_mutex_unlock(conference->mutex);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	status = SWITCH_STATUS_SUCCESS;
 
-    return ret_status;
+	return status;
 }
 
-static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+/* 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)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-
-    if (member != NULL) {
-        switch_event_t *event;
-
-        switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK unmute %u\n", member->id);
-        }
-        if (member->conference->unmuted_sound) {
-            conference_member_play_file(member, member->conference->unmuted_sound, 0);
-        } else {
-            char msg[512];
+	conference_member_t *member = NULL;
 
-            snprintf(msg, sizeof(msg), "Un-Muted");
-            conference_member_say(member, msg, 0);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+	assert(conference != NULL);
+	assert(stream != NULL);
+	assert(pfncallback != NULL);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	switch_mutex_lock(conference->member_mutex);
+	for (member = conference->members; member; member = member->next) {
+		pfncallback(member, stream, data);
+	}
+	switch_mutex_unlock(conference->member_mutex);
 
-    return ret_status;
 }
 
-static switch_status_t conf_api_sub_deaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static void conference_list_pretty(conference_obj_t * conference, switch_stream_handle_t *stream)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	conference_member_t *member = NULL;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-        switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK deaf %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+	switch_mutex_lock(conference->member_mutex);
+	//      stream->write_function(stream, "<pre>Current Callers:\n");
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	for (member = conference->members; member; member = member->next) {
+		switch_channel_t *channel;
+		switch_caller_profile_t *profile;
 
-    return ret_status;
-}
+		if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			continue;
+		}
+		channel = switch_core_session_get_channel(member->session);
+		profile = switch_channel_get_caller_profile(channel);
 
-static switch_status_t conf_api_sub_undeaf(conference_member_t *member, switch_stream_handle_t *stream, void *data)
-{
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+		stream->write_function(stream, "%u) %s (%s)\n", member->id, profile->caller_id_name, profile->caller_id_number);
 
-        switch_set_flag_locked(member, MFLAG_CAN_HEAR);
-        if (stream != NULL) {
-            stream->write_function(stream, "OK undeaf %u\n", member->id);
-        }
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+	}
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	switch_mutex_unlock(conference->member_mutex);
 
-    return ret_status;
 }
 
-static switch_status_t conf_api_sub_kick(conference_member_t *member, switch_stream_handle_t *stream, void *data)
+static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-
-    if (member != NULL) {
-        switch_event_t *event;
-
-        switch_mutex_lock(member->flag_mutex);
-        switch_clear_flag(member, MFLAG_RUNNING);
-        switch_set_flag(member, MFLAG_KICKED);
-        switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
-        switch_mutex_unlock(member->flag_mutex);
-
-        if (stream != NULL) {
-            stream->write_function(stream, "OK kicked %u\n", member->id);
-        }
+	conference_member_t *member = NULL;
 
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_channel_t *channel = switch_core_session_get_channel(member->session);
-            switch_channel_event_set_data(channel, event);
+	assert(conference != NULL);
+	assert(stream != NULL);
+	assert(delim != NULL);
 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
-            switch_event_fire(&event);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
 
-    return ret_status;
-}
+	switch_mutex_lock(conference->member_mutex);
 
+	for (member = conference->members; member; member = member->next) {
+		switch_channel_t *channel;
+		switch_caller_profile_t *profile;
+		char *uuid;
+		char *name;
+		uint32_t count = 0;
 
-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 (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+			continue;
+		}
 
-    if (member == NULL) {
-        stream->write_function(stream, "Invalid member!\n");
-        return SWITCH_STATUS_GENERR;
-    }
+		uuid = switch_core_session_get_uuid(member->session);
+		channel = switch_core_session_get_channel(member->session);
+		profile = switch_channel_get_caller_profile(channel);
+		name = switch_channel_get_name(channel);
 
-    if (switch_strlen_zero(dtmf)) {
-        stream->write_function(stream, "Invalid input!\n");
-        return SWITCH_STATUS_GENERR;
-    }
 
-    
-    switch_mutex_lock(member->flag_mutex);
-    switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
-    switch_core_session_send_dtmf(member->session, dtmf);
-    switch_mutex_unlock(member->flag_mutex);
+		stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s",
+							   member->id, delim, name, delim, uuid, delim, profile->caller_id_name, delim, profile->caller_id_number, delim);
 
+		if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
+			stream->write_function(stream, "hear");
+			count++;
+		}
 
-    if (stream != NULL) {
-        stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
-    }
+		if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+			stream->write_function(stream, "%s%s", count ? "|" : "", "speak");
+			count++;
+		}
 
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_channel_t *channel = switch_core_session_get_channel(member->session);
-        switch_channel_event_set_data(channel, event);
+		stream->write_function(stream, "%s%d%s%d%s%d\n", delim, member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level);
+	}
 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "dtmf-member");
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Digits", "%s", dtmf);
-        switch_event_fire(&event);
-    }
+	switch_mutex_unlock(conference->member_mutex);
 
-    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_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-
-    if (member != NULL) {
-        switch_event_t *event;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->energy_level = atoi((char *)data);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+	if (member != NULL) {
+		switch_event_t *event;
 
-        if (stream != NULL) {
-            stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
-        }
+		switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
+		if (member->conference->muted_sound) {
+			conference_member_play_file(member, member->conference->muted_sound, 0);
+		} else {
+			char msg[512];
 
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+			snprintf(msg, sizeof(msg), "Muted");
+			conference_member_say(member, msg, 0);
+		}
+		if (stream != NULL) {
+			stream->write_function(stream, "OK mute %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                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_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    return ret_status;
+	if (member != NULL) {
+		switch_event_t *event;
+
+		switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK unmute %u\n", member->id);
+		}
+		if (member->conference->unmuted_sound) {
+			conference_member_play_file(member, member->conference->unmuted_sound, 0);
+		} else {
+			char msg[512];
+
+			snprintf(msg, sizeof(msg), "Un-Muted");
+			conference_member_say(member, msg, 0);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
+
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
 }
 
-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_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    if (member != NULL) {
-        switch_event_t *event;
+	if (member != NULL) {
+		switch_event_t *event;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->volume_in_level = atoi((char *)data);
-            switch_normalize_volume(member->volume_in_level);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+		switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK deaf %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
 
-        if (stream != NULL) {
-            stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
-        }
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                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);
+	return ret_status;
+}
 
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    return ret_status;
+	if (member != NULL) {
+		switch_event_t *event;
+
+		switch_set_flag_locked(member, MFLAG_CAN_HEAR);
+		if (stream != NULL) {
+			stream->write_function(stream, "OK undeaf %u\n", member->id);
+		}
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
+
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
 }
 
-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_kick(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+
+	if (member != NULL) {
+		switch_event_t *event;
+
+		switch_mutex_lock(member->flag_mutex);
+		switch_clear_flag(member, MFLAG_RUNNING);
+		switch_set_flag(member, MFLAG_KICKED);
+		switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+		switch_mutex_unlock(member->flag_mutex);
+
+		if (stream != NULL) {
+			stream->write_function(stream, "OK kicked %u\n", member->id);
+		}
+
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_t *channel = switch_core_session_get_channel(member->session);
+			switch_channel_event_set_data(channel, event);
+
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
+			switch_event_fire(&event);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
+}
 
-    if (member != NULL) {
-        switch_event_t *event;
 
-        if (data) {
-            switch_mutex_lock(member->flag_mutex);
-            member->volume_out_level = atoi((char *)data);
-            switch_normalize_volume(member->volume_out_level);
-            switch_mutex_unlock(member->flag_mutex);
-        }
+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 (stream != NULL) {
-            stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
-        }
+	if (member == NULL) {
+		stream->write_function(stream, "Invalid member!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
-        if (data) {
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_t *channel = switch_core_session_get_channel(member->session);
-                switch_channel_event_set_data(channel, event);
+	if (switch_strlen_zero(dtmf)) {
+		stream->write_function(stream, "Invalid input!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                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);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+	switch_mutex_lock(member->flag_mutex);
+	switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+	switch_core_session_send_dtmf(member->session, dtmf);
+	switch_mutex_unlock(member->flag_mutex);
 
-    return ret_status;
+
+	if (stream != NULL) {
+		stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
+	}
+
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_t *channel = switch_core_session_get_channel(member->session);
+		switch_channel_event_set_data(channel, event);
+
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "dtmf-member");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Digits", "%s", dtmf);
+		switch_event_fire(&event);
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t conf_api_sub_energy(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+
+	if (member != NULL) {
+		switch_event_t *event;
+
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->energy_level = atoi((char *) data);
+			switch_mutex_unlock(member->flag_mutex);
+		}
+
+		if (stream != NULL) {
+			stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
+		}
+
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
+
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				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);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_volume_in(conference_member_t * member, switch_stream_handle_t *stream, void *data)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+
+	if (member != NULL) {
+		switch_event_t *event;
+
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->volume_in_level = atoi((char *) data);
+			switch_normalize_volume(member->volume_in_level);
+			switch_mutex_unlock(member->flag_mutex);
+		}
+
+		if (stream != NULL) {
+			stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
+		}
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
+
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				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);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
 }
 
-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_volume_out(conference_member_t * member, switch_stream_handle_t *stream, void *data)
 {
-    int ret_status = SWITCH_STATUS_GENERR;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+
+	if (member != NULL) {
+		switch_event_t *event;
+
+		if (data) {
+			switch_mutex_lock(member->flag_mutex);
+			member->volume_out_level = atoi((char *) data);
+			switch_normalize_volume(member->volume_out_level);
+			switch_mutex_unlock(member->flag_mutex);
+		}
+
+		if (stream != NULL) {
+			stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
+		}
 
-    switch_hash_index_t *hi;
-    void *val;
-    char *d = ";";
-    int pretty = 0;
-    int argofs = (argc >= 2 && strcasecmp(argv[1], "list") == 0);	// detect being called from chat vs. api
+		if (data) {
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_t *channel = switch_core_session_get_channel(member->session);
+				switch_channel_event_set_data(channel, event);
+
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", member->conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				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);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
+}
+
+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;
 
-    if (argv[1+argofs]) {
-        if (argv[2+argofs] && !strcasecmp(argv[1+argofs], "delim")) {
-            d = argv[2+argofs];
+	switch_hash_index_t *hi;
+	void *val;
+	char *d = ";";
+	int pretty = 0;
+	int argofs = (argc >= 2 && strcasecmp(argv[1], "list") == 0);	// detect being called from chat vs. api
 
-            if (*d == '"') {
-                if (++d) {
-                    char *p;
-                    if ((p = strchr(d, '"'))) {
-                        *p = '\0';
-                    }
-                } else {
-                    d = ";";
-                }
-            }
-        } else if (strcasecmp(argv[1+argofs], "pretty") == 0) {
-            pretty = 1;
-        }
-    }
+	if (argv[1 + argofs]) {
+		if (argv[2 + argofs] && !strcasecmp(argv[1 + argofs], "delim")) {
+			d = argv[2 + argofs];
 
-    if (conference == NULL) {
-        for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
-            switch_hash_this(hi, NULL, NULL, &val);
-            conference = (conference_obj_t *) val;
+			if (*d == '"') {
+				if (++d) {
+					char *p;
+					if ((p = strchr(d, '"'))) {
+						*p = '\0';
+					}
+				} else {
+					d = ";";
+				}
+			}
+		} else if (strcasecmp(argv[1 + argofs], "pretty") == 0) {
+			pretty = 1;
+		}
+	}
 
-            stream->write_function(stream, "Conference %s (%u member%s%s)\n", 
-                                   conference->name, 
-                                   conference->count, 
-                                   conference->count == 1 ? "" : "s",
-                                   switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""
-                                   );
-            if (pretty) {
-                conference_list_pretty(conference, stream);
-            } else {
-                conference_list(conference, stream, d);
-            }
-        }
-    } else {
-        if (pretty) {
-            conference_list_pretty(conference, stream);
-        } else {
-            conference_list(conference, stream, d);
-        }
-    }
+	if (conference == NULL) {
+		for (hi = switch_hash_first(globals.conference_pool, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
+			switch_hash_this(hi, NULL, NULL, &val);
+			conference = (conference_obj_t *) val;
+
+			stream->write_function(stream, "Conference %s (%u member%s%s)\n",
+								   conference->name,
+								   conference->count, conference->count == 1 ? "" : "s", switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
+			if (pretty) {
+				conference_list_pretty(conference, stream);
+			} else {
+				conference_list(conference, stream, d);
+			}
+		}
+	} else {
+		if (pretty) {
+			conference_list_pretty(conference, stream);
+		} else {
+			conference_list(conference, stream, d);
+		}
+	}
 
-    ret_status = SWITCH_STATUS_SUCCESS;
+	ret_status = SWITCH_STATUS_SUCCESS;
 
-    return ret_status;
+	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;
+	int ret_status = SWITCH_STATUS_GENERR;
+	switch_event_t *event;
 	uint8_t async = 0;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if ((argc == 4 && !strcasecmp(argv[3], "async")) || (argc == 5 && !strcasecmp(argv[4], "async"))) {    
+	if ((argc == 4 && !strcasecmp(argv[3], "async")) || (argc == 5 && !strcasecmp(argv[4], "async"))) {
 		argc--;
 		async++;
 	}
-	
-    if (argc == 3) {
-        if (conference_play_file(conference, argv[2], 0, NULL, async) == SWITCH_STATUS_SUCCESS) {
-            stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
-                switch_event_fire(&event);
-            }
-        } else {
-            stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else if (argc == 4) {
-        uint32_t id = atoi(argv[3]);
-        conference_member_t *member;
-
-        if ((member = conference_member_get(conference, id))) {
-            if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
-                stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
-                if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
-                    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
-                    switch_event_fire(&event);
-                }
-            } else {
-                stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
-            }
-            ret_status = SWITCH_STATUS_SUCCESS;
-        } else {
-            stream->write_function(stream, "Member: %u not found.\n", id);
-        }
-    }
-
-    return ret_status;
-}
-
-static switch_status_t conf_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text)
-{
-    int ret_status = SWITCH_STATUS_GENERR;
-
-    if (switch_strlen_zero(text)) {
-        stream->write_function(stream, "(say) Error! No text.");
-        return ret_status;
-    }
-
-    if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
-        switch_event_t *event;
-
-        stream->write_function(stream, "(say) OK\n");
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
-            switch_event_fire(&event);
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else {
-        stream->write_function(stream, "(say) Error!");
-    }
-
-    return ret_status;
-}
-
-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;
-    char *start_text = NULL;
-    char *workspace = NULL;
-    uint32_t id = 0;
-    conference_member_t *member;
-
-    if (switch_strlen_zero(text)) {
-        stream->write_function(stream, "(saymember) No Text!\n");
-        goto done;
-    }
-
-    if (!(workspace = strdup(text))) {
-        stream->write_function(stream, "(saymember) Memory Error!\n");
-        goto done;
-    }
-
-    if ((start_text = strchr(workspace, ' '))) {
-        *start_text++ = '\0';
-        text = start_text;
-    }
-
-    id = atoi(workspace);
-
-    if (!id || switch_strlen_zero(text)) {
-        stream->write_function(stream, "(saymember) No Text!\n");
-        goto done;
-    }
-
-    if (!(member = conference_member_get(conference, id))) {
-        stream->write_function(stream, "(saymember) Unknown Member %u!", id);
-        goto done;
-    }
-
-    if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *)text)) != text) {
-        text = expanded;
-    } else {
-        expanded = NULL;
-    }
-
-    if (text && conference_member_say(member, (char *)text, 0) == SWITCH_STATUS_SUCCESS) {
-        switch_event_t *event;
-
-        stream->write_function(stream, "(saymember) OK\n");
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
-            switch_event_fire(&event);
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-    } else {
-        stream->write_function(stream, "(saymember) Error!");
-    }
-
- 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)
-{
-    int ret_status = SWITCH_STATUS_GENERR;
-    uint8_t current = 0, all = 0;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (argc > 2) {
-        current = strcasecmp(argv[2], "current") ? 0 : 1;
-        all = strcasecmp(argv[2], "all") ? 0 : 1;
-    } else {
-        all = 1;
-    }
-
-    if (current || all) {
-        if (argc == 4) {
-            uint32_t id = atoi(argv[3]);
-            conference_member_t *member;
-
-            if ((member = conference_member_get(conference, id))) {
-                uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-                stream->write_function(stream, "Stopped %u files.\n", stopped);
-            } else {
-                stream->write_function(stream, "Member: %u not found.\n", id);
-            }
-            ret_status = SWITCH_STATUS_SUCCESS;
-        } else {
-            uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
-            stream->write_function(stream, "Stopped %u files.\n", stopped);
-            ret_status = SWITCH_STATUS_SUCCESS;
-        }
-    }
-
-    return ret_status;
-}
-
-static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    int ret_status = SWITCH_STATUS_GENERR;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (argc > 4) {
-        uint8_t nospeak = 0, nohear = 0, clear = 0;
-        nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
-        nohear = strstr(argv[4], "nohear") ? 1 : 0;
-
-        if (!strcasecmp(argv[4], "clear")) {
-            clear = 1;
-        }
-
-        if (!(clear || nospeak || nohear)) { 
-            ret_status = SWITCH_STATUS_GENERR;
-            goto done;
-        }
-        ret_status = SWITCH_STATUS_SUCCESS;
-
-        if (clear) {
-            conference_member_t *member = NULL;
-            uint32_t id = atoi(argv[2]);
-            uint32_t oid = atoi(argv[3]);
-
-            if ((member = conference_member_get(conference, id))) {
-                member_del_relationship(member, oid);
-                stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
-            } else {
-                stream->write_function(stream, "relationship %u->%u not found", id, oid);
-            }
-        } else if (nospeak || nohear) {
-            conference_member_t *member = NULL, *other_member = NULL;
-            uint32_t id = atoi(argv[2]);
-            uint32_t oid = atoi(argv[3]);
-
-            if ((member = conference_member_get(conference, id)) && (other_member = conference_member_get(conference, oid))) {
-                conference_relationship_t *rel = NULL;
-                if ((rel = member_get_relationship(member, other_member))) {
-                    rel->flags = 0;
-                } else {
-                    rel = member_add_relationship(member, oid);
-                }
-
-                if (rel) {
-                    switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
-                    if (nospeak) {
-                        switch_clear_flag(rel, RFLAG_CAN_SPEAK);
-                    }
-                    if (nohear) {
-                        switch_clear_flag(rel, RFLAG_CAN_HEAR);
-                    }
-                    stream->write_function(stream, "ok %u->%u set\n", id, oid);
-                } else {
-                    stream->write_function(stream, "error!\n");
-                }
-            } else {
-                stream->write_function(stream, "relationship %u->%u not found", id, oid);
-            }
-        }
-    }
-
- done:
-    return ret_status;
-}
-
-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;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (conference->is_locked_sound) {
-        conference_play_file(conference, conference->is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
-    }
-
-    switch_set_flag_locked(conference, CFLAG_LOCKED);
-    stream->write_function(stream, "OK %s locked\n", argv[0]);
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
-        switch_event_fire(&event);
-    }
-
-    return 0;
-}
-
-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;
-
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (conference->is_unlocked_sound) {
-        conference_play_file(conference, conference->is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
-    }
-
-    switch_clear_flag_locked(conference, CFLAG_LOCKED);
-    stream->write_function(stream, "OK %s unlocked\n", argv[0]);
-    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
-        switch_event_fire(&event);
-    }
-	
 
-    return 0;
+	if (argc == 3) {
+		if (conference_play_file(conference, argv[2], 0, NULL, async) == SWITCH_STATUS_SUCCESS) {
+			stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
+				switch_event_fire(&event);
+			}
+		} else {
+			stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else if (argc == 4) {
+		uint32_t id = atoi(argv[3]);
+		conference_member_t *member;
+
+		if ((member = conference_member_get(conference, id))) {
+			if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
+				stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
+				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", "%s", argv[2]);
+					switch_event_fire(&event);
+				}
+			} else {
+				stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+			}
+			ret_status = SWITCH_STATUS_SUCCESS;
+		} else {
+			stream->write_function(stream, "Member: %u not found.\n", id);
+		}
+	}
+
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
+{
+	int ret_status = SWITCH_STATUS_GENERR;
+
+	if (switch_strlen_zero(text)) {
+		stream->write_function(stream, "(say) Error! No text.");
+		return ret_status;
+	}
+
+	if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
+		switch_event_t *event;
+
+		stream->write_function(stream, "(say) OK\n");
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
+			switch_event_fire(&event);
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else {
+		stream->write_function(stream, "(say) Error!");
+	}
+
+	return ret_status;
+}
+
+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;
+	char *start_text = NULL;
+	char *workspace = NULL;
+	uint32_t id = 0;
+	conference_member_t *member;
+
+	if (switch_strlen_zero(text)) {
+		stream->write_function(stream, "(saymember) No Text!\n");
+		goto done;
+	}
+
+	if (!(workspace = strdup(text))) {
+		stream->write_function(stream, "(saymember) Memory Error!\n");
+		goto done;
+	}
+
+	if ((start_text = strchr(workspace, ' '))) {
+		*start_text++ = '\0';
+		text = start_text;
+	}
+
+	id = atoi(workspace);
+
+	if (!id || switch_strlen_zero(text)) {
+		stream->write_function(stream, "(saymember) No Text!\n");
+		goto done;
+	}
+
+	if (!(member = conference_member_get(conference, id))) {
+		stream->write_function(stream, "(saymember) Unknown Member %u!", id);
+		goto done;
+	}
+
+	if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), (char *) text)) != text) {
+		text = expanded;
+	} else {
+		expanded = NULL;
+	}
+
+	if (text && conference_member_say(member, (char *) text, 0) == SWITCH_STATUS_SUCCESS) {
+		switch_event_t *event;
+
+		stream->write_function(stream, "(saymember) OK\n");
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "speak-text-member");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
+			switch_event_fire(&event);
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+	} else {
+		stream->write_function(stream, "(saymember) Error!");
+	}
+
+  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)
+{
+	int ret_status = SWITCH_STATUS_GENERR;
+	uint8_t current = 0, all = 0;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (argc > 2) {
+		current = strcasecmp(argv[2], "current") ? 0 : 1;
+		all = strcasecmp(argv[2], "all") ? 0 : 1;
+	} else {
+		all = 1;
+	}
+
+	if (current || all) {
+		if (argc == 4) {
+			uint32_t id = atoi(argv[3]);
+			conference_member_t *member;
+
+			if ((member = conference_member_get(conference, id))) {
+				uint32_t stopped = conference_member_stop_file(member, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+				stream->write_function(stream, "Stopped %u files.\n", stopped);
+			} else {
+				stream->write_function(stream, "Member: %u not found.\n", id);
+			}
+			ret_status = SWITCH_STATUS_SUCCESS;
+		} else {
+			uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
+			stream->write_function(stream, "Stopped %u files.\n", stopped);
+			ret_status = SWITCH_STATUS_SUCCESS;
+		}
+	}
+
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+	int ret_status = SWITCH_STATUS_GENERR;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (argc > 4) {
+		uint8_t nospeak = 0, nohear = 0, clear = 0;
+		nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
+		nohear = strstr(argv[4], "nohear") ? 1 : 0;
+
+		if (!strcasecmp(argv[4], "clear")) {
+			clear = 1;
+		}
+
+		if (!(clear || nospeak || nohear)) {
+			ret_status = SWITCH_STATUS_GENERR;
+			goto done;
+		}
+		ret_status = SWITCH_STATUS_SUCCESS;
+
+		if (clear) {
+			conference_member_t *member = NULL;
+			uint32_t id = atoi(argv[2]);
+			uint32_t oid = atoi(argv[3]);
+
+			if ((member = conference_member_get(conference, id))) {
+				member_del_relationship(member, oid);
+				stream->write_function(stream, "relationship %u->%u cleared.", id, oid);
+			} else {
+				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+			}
+		} else if (nospeak || nohear) {
+			conference_member_t *member = NULL, *other_member = NULL;
+			uint32_t id = atoi(argv[2]);
+			uint32_t oid = atoi(argv[3]);
+
+			if ((member = conference_member_get(conference, id))
+				&& (other_member = conference_member_get(conference, oid))) {
+				conference_relationship_t *rel = NULL;
+				if ((rel = member_get_relationship(member, other_member))) {
+					rel->flags = 0;
+				} else {
+					rel = member_add_relationship(member, oid);
+				}
+
+				if (rel) {
+					switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR);
+					if (nospeak) {
+						switch_clear_flag(rel, RFLAG_CAN_SPEAK);
+					}
+					if (nohear) {
+						switch_clear_flag(rel, RFLAG_CAN_HEAR);
+					}
+					stream->write_function(stream, "ok %u->%u set\n", id, oid);
+				} else {
+					stream->write_function(stream, "error!\n");
+				}
+			} else {
+				stream->write_function(stream, "relationship %u->%u not found", id, oid);
+			}
+		}
+	}
+
+  done:
+	return ret_status;
+}
+
+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;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (conference->is_locked_sound) {
+		conference_play_file(conference, conference->is_locked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+	}
+
+	switch_set_flag_locked(conference, CFLAG_LOCKED);
+	stream->write_function(stream, "OK %s locked\n", argv[0]);
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
+		switch_event_fire(&event);
+	}
+
+	return 0;
+}
+
+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;
+
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (conference->is_unlocked_sound) {
+		conference_play_file(conference, conference->is_unlocked_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+	}
+
+	switch_clear_flag_locked(conference, CFLAG_LOCKED);
+	stream->write_function(stream, "OK %s unlocked\n", argv[0]);
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
+		switch_event_fire(&event);
+	}
+
+
+	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_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    assert(stream != NULL);
+	assert(stream != NULL);
 
 	if (argc > 2) {
-        switch_call_cause_t cause;
+		switch_call_cause_t cause;
 
 		if (conference) {
 			conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
@@ -3069,21 +2994,21 @@
 			conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
 		}
 
-        stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
-    } else {
-        stream->write_function(stream, "Bad Args\n");
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+		stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
+	} else {
+		stream->write_function(stream, "Bad Args\n");
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
 
-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_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    assert(stream != NULL);
+	assert(stream != NULL);
 
 	if (argc > 2) {
 		if (conference) {
@@ -3092,171 +3017,171 @@
 			conference_outcall_bg(NULL, argv[1], NULL, argv[2], 60, NULL, argv[4], argv[3]);
 		}
 		stream->write_function(stream, "OK\n");
-    } else {
-        stream->write_function(stream, "Bad Args\n");
-        ret_status = SWITCH_STATUS_GENERR;
-    }
-
-    return ret_status;
-}
-
-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 *params = NULL;
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    if (argc > 3 && !switch_strlen_zero(argv[2])) {
-        int x;
-
-        for (x = 3; x<argc; x++) {
-            conference_member_t *member = NULL;
-            uint32_t id = atoi(argv[x]);
-            conference_obj_t *new_conference = NULL;
-            switch_channel_t *channel;
-            switch_event_t *event;
-            char *profile_name;
-            switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
-
-            if (!id || !(member = conference_member_get(conference, id))) {								
-                stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
-                continue;
-            }
-
-            channel = switch_core_session_get_channel(member->session);
-
-            /* build a new conference if it doesn't exist */
-            if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
-                switch_memory_pool_t *pool = NULL;
-                char *conf_name;
-                conf_xml_cfg_t xml_cfg = {0};
-
-                /* Setup a memory pool to use. */
-                if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-                    goto done;
-                }
-
-                conf_name = switch_core_strdup(pool, argv[2]);
-
-                if ((profile_name = strchr(conf_name, '@'))) {
-                    *profile_name++ = '\0';
-                } else {
-                    profile_name = "default";
-                }
-                params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
-                /* Open the config from the xml registry  */
-                if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
-                    goto done;
-                }
-
-                if ((profiles = switch_xml_child(cfg, "profiles"))) {
-                    xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
-                }
-
-                if (!xml_cfg.profile) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
-                    switch_xml_free(cxml);
-                    cxml = NULL;
-                    goto done;
-                }
-
-                xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
-
-                /* Release the config registry handle */
-                if (cxml) {
-                    switch_xml_free(cxml);
-                    cxml = NULL;
-                }
-
-                /* Create the conference object. */
-                new_conference = conference_new(conf_name, xml_cfg, pool);
-
-                if (!new_conference) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-                    if (pool != NULL) {
-                        switch_core_destroy_memory_pool(&pool);
-                    }
-                    goto done;
-                }
-
-                /* Set the minimum number of members (once you go above it you cannot go below it) */
-                new_conference->min = 1;
-
-                /* Indicate the conference is dynamic */
-                switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
-
-                switch_mutex_lock(new_conference->mutex);
-
-                /* Start the conference thread for this conference */
-                launch_conference_thread(new_conference);
-            } else {
-                switch_mutex_lock(new_conference->mutex);
-            }
-
-            /* move the member from the old conference to the new one */
-            conference_del_member(conference, member);
-            conference_add_member(new_conference, member);
-            switch_mutex_unlock(new_conference->mutex);
-
-            stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
-
-            /* tell them what happened */
-            if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-                switch_channel_event_set_data(channel, event);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", "%s", conference->name);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", "%s", argv[3]);
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
-                switch_event_fire(&event);
-            }
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
-
- done:
-    switch_safe_free(params);
-    return ret_status;
-}
-
-static switch_status_t conf_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char**argv)
-{
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
-    assert(conference != NULL);
-    assert(stream != NULL);
+	} else {
+		stream->write_function(stream, "Bad Args\n");
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
+}
+
+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 *params = NULL;
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (argc > 3 && !switch_strlen_zero(argv[2])) {
+		int x;
 
-    if (argc > 2) {
+		for (x = 3; x < argc; x++) {
+			conference_member_t *member = NULL;
+			uint32_t id = atoi(argv[x]);
+			conference_obj_t *new_conference = NULL;
+			switch_channel_t *channel;
+			switch_event_t *event;
+			char *profile_name;
+			switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+
+			if (!id || !(member = conference_member_get(conference, id))) {
+				stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
+				continue;
+			}
+
+			channel = switch_core_session_get_channel(member->session);
+
+			/* build a new conference if it doesn't exist */
+			if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
+				switch_memory_pool_t *pool = NULL;
+				char *conf_name;
+				conf_xml_cfg_t xml_cfg = { 0 };
+
+				/* Setup a memory pool to use. */
+				if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+					goto done;
+				}
+
+				conf_name = switch_core_strdup(pool, argv[2]);
+
+				if ((profile_name = strchr(conf_name, '@'))) {
+					*profile_name++ = '\0';
+				} else {
+					profile_name = "default";
+				}
+				params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
+				/* Open the config from the xml registry  */
+				if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+					goto done;
+				}
+
+				if ((profiles = switch_xml_child(cfg, "profiles"))) {
+					xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+				}
+
+				if (!xml_cfg.profile) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
+					switch_xml_free(cxml);
+					cxml = NULL;
+					goto done;
+				}
+
+				xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
+
+				/* Release the config registry handle */
+				if (cxml) {
+					switch_xml_free(cxml);
+					cxml = NULL;
+				}
+
+				/* Create the conference object. */
+				new_conference = conference_new(conf_name, xml_cfg, pool);
+
+				if (!new_conference) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+					if (pool != NULL) {
+						switch_core_destroy_memory_pool(&pool);
+					}
+					goto done;
+				}
+
+				/* Set the minimum number of members (once you go above it you cannot go below it) */
+				new_conference->min = 1;
+
+				/* Indicate the conference is dynamic */
+				switch_set_flag_locked(new_conference, CFLAG_DYNAMIC);
+
+				switch_mutex_lock(new_conference->mutex);
+
+				/* Start the conference thread for this conference */
+				launch_conference_thread(new_conference);
+			} else {
+				switch_mutex_lock(new_conference->mutex);
+			}
+
+			/* move the member from the old conference to the new one */
+			conference_del_member(conference, member);
+			conference_add_member(new_conference, member);
+			switch_mutex_unlock(new_conference->mutex);
+
+			stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
+
+			/* tell them what happened */
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_event_set_data(channel, event);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", "%s", conference->name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", "%s", argv[3]);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
+				switch_event_fire(&event);
+			}
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+  done:
+	switch_safe_free(params);
+	return ret_status;
+}
+
+static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	if (argc > 2) {
 		stream->write_function(stream, "Record file %s\n", argv[2]);
-        launch_conference_record_thread(conference, argv[2]);
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
+		launch_conference_record_thread(conference, argv[2]);
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
 
-    return ret_status;
+	return ret_status;
 }
 
-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)
 {
-    switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
+	switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
 
-    assert(conference != NULL);
-    assert(stream != NULL);
+	assert(conference != NULL);
+	assert(stream != NULL);
 
-    if (argc > 2) {
-        int all = (strcasecmp(argv[2], "all") == 0 );
+	if (argc > 2) {
+		int all = (strcasecmp(argv[2], "all") == 0);
 		stream->write_function(stream, "Stop recording file %s\n", argv[2]);
-		
-        if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
-            stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
-        }
-    } else {
-        ret_status = SWITCH_STATUS_GENERR;
-    }
-	
-    return ret_status;
+
+		if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
+			stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
+		}
+	} else {
+		ret_status = SWITCH_STATUS_GENERR;
+	}
+
+	return ret_status;
 }
 
 typedef enum {
@@ -3287,198 +3212,211 @@
 /* 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, "<confname> energy <member_id|all|last> [<newval>]"}, 
-	{"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, "<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, "<confname> saymember <member_id> <text>"}, 
-	{"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, "<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, "<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, "<confname> undeaf <[member_id|all]|last>"}, 
-	{"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, "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"}, 
-	{"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, "<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]>"}, 
+	{"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,
+	 "<confname> volume_in <member_id|all|last> [<newval>]"},
+	{"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,
+	 "<confname> saymember <member_id> <text>"},
+	{"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,
+	 "<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,
+	 "<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,
+	 "<confname> undeaf <[member_id|all]|last>"},
+	{"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,
+	 "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
+	{"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,
+	 "<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]>"},
 };
 
 #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 status = SWITCH_STATUS_FALSE;
-    uint32_t i, found = 0;
-    assert(conference != NULL);
-    assert(stream != NULL);
-
-    /* loop through the command table to find a match */
-    for (i = 0; i<CONFFUNCAPISIZE && !found; i++) {
-        if (strcasecmp(argv[argn], conf_api_sub_commands[i].pname) == 0) {
-            found = 1;
-            switch(conf_api_sub_commands[i].fntype) {
-
-                /* commands that we've broken the command line into arguments for */
-            case CONF_API_SUB_ARGS_SPLIT:
-                {	conf_api_args_cmd_t pfn = (conf_api_args_cmd_t)conf_api_sub_commands[i].pfnapicmd;
-
-                    if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
-                        /* command returned error, so show syntax usage */
-                        stream->write_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
-
-                /* member specific command that can be itteratted */
-            case CONF_API_SUB_MEMBER_TARGET:
-                {
-                    uint32_t id = 0;
-                    uint8_t all = 0;
-                    uint8_t last = 0;
-
-                    if (argv[argn+1]) {
-                        if (!(id = atoi(argv[argn+1]))) {
-                            all = strcasecmp(argv[argn+1], "all") ? 0 : 1;
-                            last = strcasecmp(argv[argn+1], "last") ? 0 : 1;
-                        }                        
-                    }
-
-                    if (all) {
-                        conference_member_itterator(conference, stream, (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd, argv[argn+2]);
-                    } else if (last) {
-                        conference_member_t *member = NULL;
-                        conference_member_t *last_member = NULL;
-
-                        switch_mutex_lock(conference->member_mutex);
-
-                        /* find last (oldest) member */
-                        member = conference->members;
-                        while (member != NULL) {
-                            if (last_member == NULL || member->id > last_member->id) {
-                                last_member = member;
-                            }
-                            member = member->next;
-                        }
-
-                        /* exec functio on last (oldest) member */
-                        if (last_member != NULL) {
-                            conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
-                            pfn(last_member, stream, argv[argn+2]);
-                        }
-
-                        switch_mutex_unlock(conference->member_mutex);
-                    } else if (id) {
-                        conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
-                        conference_member_t *member = conference_member_get(conference, id);
-                        
-                        if (member != NULL) {
-                            pfn(conference_member_get(conference, id), stream, argv[argn+2]);
-                        } else {
-                            stream->write_function(stream, "Non-Existant ID %u\n", id);
-                        }
-                    } else {
-                        stream->write_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
-
-                /* commands that deals with all text after command */
-            case CONF_API_SUB_ARGS_AS_ONE:
-                {	
-                    conf_api_text_cmd_t pfn = (conf_api_text_cmd_t) conf_api_sub_commands[i].pfnapicmd;
-                    char *start_text;
-                    const char *modified_cmdline = cmdline;
-                    const char *cmd = conf_api_sub_commands[i].pname;
-
-                    if ((start_text = strstr(modified_cmdline, cmd))) {
-                        modified_cmdline = start_text + strlen(cmd);
-                        while(modified_cmdline && *modified_cmdline && (*modified_cmdline  == ' ' || *modified_cmdline == '\t')) {
-                            modified_cmdline++;
-                        }
-                    }
-                            
-                    /* call the command handler */
-                    if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) {
-                        /* command returned error, so show syntax usage */
-                        stream->write_function(stream, conf_api_sub_commands[i].psyntax);
-                    }
-                }
-                break;
-            }
-        }
-    }
-
-    if (!found) {
-        stream->write_function(stream, "Confernece command '%s' not found.\n", argv[argn]);
-    } else {
-        status = SWITCH_STATUS_SUCCESS;
-    }
+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;
+	assert(conference != NULL);
+	assert(stream != NULL);
+
+	/* loop through the command table to find a match */
+	for (i = 0; i < CONFFUNCAPISIZE && !found; i++) {
+		if (strcasecmp(argv[argn], conf_api_sub_commands[i].pname) == 0) {
+			found = 1;
+			switch (conf_api_sub_commands[i].fntype) {
+
+				/* commands that we've broken the command line into arguments for */
+			case CONF_API_SUB_ARGS_SPLIT:
+				{
+					conf_api_args_cmd_t pfn = (conf_api_args_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+
+					if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+						/* command returned error, so show syntax usage */
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
+
+				/* member specific command that can be itteratted */
+			case CONF_API_SUB_MEMBER_TARGET:
+				{
+					uint32_t id = 0;
+					uint8_t all = 0;
+					uint8_t last = 0;
+
+					if (argv[argn + 1]) {
+						if (!(id = atoi(argv[argn + 1]))) {
+							all = strcasecmp(argv[argn + 1], "all") ? 0 : 1;
+							last = strcasecmp(argv[argn + 1], "last") ? 0 : 1;
+						}
+					}
+
+					if (all) {
+						conference_member_itterator(conference, stream, (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd, argv[argn + 2]);
+					} else if (last) {
+						conference_member_t *member = NULL;
+						conference_member_t *last_member = NULL;
+
+						switch_mutex_lock(conference->member_mutex);
+
+						/* find last (oldest) member */
+						member = conference->members;
+						while (member != NULL) {
+							if (last_member == NULL || member->id > last_member->id) {
+								last_member = member;
+							}
+							member = member->next;
+						}
+
+						/* exec functio on last (oldest) member */
+						if (last_member != NULL) {
+							conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+							pfn(last_member, stream, argv[argn + 2]);
+						}
+
+						switch_mutex_unlock(conference->member_mutex);
+					} else if (id) {
+						conf_api_member_cmd_t pfn = (conf_api_member_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+						conference_member_t *member = conference_member_get(conference, id);
+
+						if (member != NULL) {
+							pfn(conference_member_get(conference, id), stream, argv[argn + 2]);
+						} else {
+							stream->write_function(stream, "Non-Existant ID %u\n", id);
+						}
+					} else {
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
+
+				/* commands that deals with all text after command */
+			case CONF_API_SUB_ARGS_AS_ONE:
+				{
+					conf_api_text_cmd_t pfn = (conf_api_text_cmd_t) conf_api_sub_commands[i].pfnapicmd;
+					char *start_text;
+					const char *modified_cmdline = cmdline;
+					const char *cmd = conf_api_sub_commands[i].pname;
+
+					if ((start_text = strstr(modified_cmdline, cmd))) {
+						modified_cmdline = start_text + strlen(cmd);
+						while (modified_cmdline && *modified_cmdline && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
+							modified_cmdline++;
+						}
+					}
+
+					/* call the command handler */
+					if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) {
+						/* command returned error, so show syntax usage */
+						stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+					}
+				}
+				break;
+			}
+		}
+	}
+
+	if (!found) {
+		stream->write_function(stream, "Confernece command '%s' not found.\n", argv[argn]);
+	} else {
+		status = SWITCH_STATUS_SUCCESS;
+	}
 
-    return status;
+	return status;
 }
 
 /* API Interface Function */
 static switch_status_t conf_api_main(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-    char *lbuf = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    char *http = NULL;
-    int argc;
-    char *argv[25] = {0};
-
-    if (!buf) {
-        buf = "help";
-    }
-
-    if (session) {
-        return SWITCH_STATUS_FALSE;
-    }
-
-    if (stream->event) {
-        http = switch_event_get_header(stream->event, "http-host");
-    }
-
-    if (http) {
-        /* Output must be to a web browser */
-        stream->write_function(stream, "<pre>\n");
-    }
-
-    if (!(lbuf = strdup(buf))) {
-        return status;
-    }
-
-    argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-
-    /* try to find a command to execute */
-    if (argc) {
-        conference_obj_t *conference = NULL;
-
-        if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
-            if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-                goto done;
-            }
-            if (argc >= 2) {
-                conf_api_dispatch(conference, stream, argc, argv, (const char *)buf, 1);
-            } else {
-                stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
-            }
-            switch_thread_rwlock_unlock(conference->rwlock);
-
-        } else {
-            /* special case the list command, because it doesn't require a conference argument */
-            if (strcasecmp(argv[0], "list") == 0) {
-                conf_api_sub_list(NULL, stream, argc, argv);
-            } else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-                stream->write_function(stream, "%s\n", conf_api_interface.syntax);
+	char *lbuf = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	char *http = NULL;
+	int argc;
+	char *argv[25] = { 0 };
+
+	if (!buf) {
+		buf = "help";
+	}
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (stream->event) {
+		http = switch_event_get_header(stream->event, "http-host");
+	}
+
+	if (http) {
+		/* Output must be to a web browser */
+		stream->write_function(stream, "<pre>\n");
+	}
+
+	if (!(lbuf = strdup(buf))) {
+		return status;
+	}
+
+	argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+	/* try to find a command to execute */
+	if (argc) {
+		conference_obj_t *conference = NULL;
+
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
+			if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+				goto done;
+			}
+			if (argc >= 2) {
+				conf_api_dispatch(conference, stream, argc, argv, (const char *) buf, 1);
+			} else {
+				stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
+			}
+			switch_thread_rwlock_unlock(conference->rwlock);
+
+		} else {
+			/* special case the list command, because it doesn't require a conference argument */
+			if (strcasecmp(argv[0], "list") == 0) {
+				conf_api_sub_list(NULL, stream, argc, argv);
+			} else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
+				stream->write_function(stream, "%s\n", conf_api_interface.syntax);
 			} else if (argv[1] && strcasecmp(argv[1], "dial") == 0) {
 				if (conf_api_sub_dial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
 					/* command returned error, so show syntax usage */
@@ -3489,68 +3427,63 @@
 					/* command returned error, so show syntax usage */
 					stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax);
 				}
-            } else {
-                stream->write_function(stream, "Conference %s not found\n", argv[0]);
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
-            }
-        }
-
-    } else {
-        stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n");
-    }
+			} else {
+				stream->write_function(stream, "Conference %s not found\n", argv[0]);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
+			}
+		}
 
- done:
-    switch_safe_free(lbuf);
+	} else {
+		stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n");
+	}
 
-    return status;
+  done:
+	switch_safe_free(lbuf);
+
+	return status;
 
 }
 
 /* outbound call bridge progress call state callback handler */
 static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
 {
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
 
-    /* put the channel in a passive state so we can loop audio to it */
-    switch_channel_set_state(channel, CS_TRANSMIT);
-    return SWITCH_STATUS_FALSE;
+	/* put the channel in a passive state so we can loop audio to it */
+	switch_channel_set_state(channel, CS_TRANSMIT);
+	return SWITCH_STATUS_FALSE;
 }
 
 static const switch_state_handler_table_t audio_bridge_peer_state_handlers = {
-    /*.on_init */ NULL, 
-    /*.on_ring */ audio_bridge_on_ring, 
-    /*.on_execute */ NULL, 
-    /*.on_hangup */ NULL, 
-    /*.on_loopback */ NULL, 
-    /*.on_transmit */ NULL, 
-    /*.on_hold */ NULL, 
+	/*.on_init */ NULL,
+	/*.on_ring */ audio_bridge_on_ring,
+	/*.on_execute */ NULL,
+	/*.on_hangup */ NULL,
+	/*.on_loopback */ NULL,
+	/*.on_transmit */ NULL,
+	/*.on_hold */ NULL,
 };
 
 
 /* generate an outbound call from the 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)
-{
-    switch_core_session_t *peer_session;
-    switch_channel_t *peer_channel;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    switch_channel_t *caller_channel = NULL;
-    char appdata[512];
+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)
+{
+	switch_core_session_t *peer_session;
+	switch_channel_t *peer_channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *caller_channel = NULL;
+	char appdata[512];
 
 
-    *cause = SWITCH_CAUSE_NORMAL_CLEARING;
+	*cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 
 	if (conference == NULL) {
@@ -3565,630 +3498,608 @@
 
 		peer_channel = switch_core_session_get_channel(peer_session);
 		assert(peer_channel != NULL);
-		
+
 		goto callup;
 	}
 
 
 	conference_name = conference->name;
 
-    if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-        return SWITCH_STATUS_FALSE;
-    }
-
-    if (session != NULL) {
-        caller_channel = switch_core_session_get_channel(session);
-	
-    }
-
-    if (switch_strlen_zero(cid_name)) {
-        cid_name = conference->caller_id_name;
-    }
-
-    if (switch_strlen_zero(cid_num)) {
-        cid_num = conference->caller_id_number;
-    }
-
-    /* establish an outbound call leg */
-    if (switch_ivr_originate(session, 
-                             &peer_session, 
-                             cause, 
-                             bridgeto, 
-                             timeout, 
-                             &audio_bridge_peer_state_handlers, 
-                             cid_name, 
-                             cid_num, 
-                             NULL) != 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;
-    } 
-
-
-    peer_channel = switch_core_session_get_channel(peer_session);
-    assert(peer_channel != NULL);
-
-    /* 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");
-        if (caller_channel) {
-            switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
-        }
-        switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
-        goto done;
-    }
-
-    if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
-        switch_channel_answer(caller_channel);
-    }
-
- 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)) {
-        switch_caller_extension_t *extension = NULL;
-
-        /* build an extension name object */
-        if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-            status = SWITCH_STATUS_MEMERR;
-            goto done;
-        }
-        /* add them to the conference */
-        if (flags && strcasecmp(flags, "none")) {
-            snprintf(appdata, sizeof(appdata), "%s +flags{%s}", conference_name, flags);
-            switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
-        } else {
-            switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
-        }
-
-        switch_channel_set_caller_extension(peer_channel, extension);
-        switch_channel_set_state(peer_channel, CS_EXECUTE);
-
-    } else {
-        switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
-        status = SWITCH_STATUS_FALSE;
-        goto done;
-    }
+	if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (session != NULL) {
+		caller_channel = switch_core_session_get_channel(session);
+
+	}
+
+	if (switch_strlen_zero(cid_name)) {
+		cid_name = conference->caller_id_name;
+	}
+
+	if (switch_strlen_zero(cid_num)) {
+		cid_num = conference->caller_id_number;
+	}
+
+	/* establish an outbound call leg */
+	if (switch_ivr_originate(session,
+							 &peer_session, cause, bridgeto, timeout, &audio_bridge_peer_state_handlers, cid_name, cid_num,
+							 NULL) != 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;
+	}
+
+
+	peer_channel = switch_core_session_get_channel(peer_session);
+	assert(peer_channel != NULL);
+
+	/* 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");
+		if (caller_channel) {
+			switch_channel_hangup(caller_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+		}
+		switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
+		goto done;
+	}
+
+	if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+		switch_channel_answer(caller_channel);
+	}
+
+  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)) {
+		switch_caller_extension_t *extension = NULL;
+
+		/* build an extension name object */
+		if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+			status = SWITCH_STATUS_MEMERR;
+			goto done;
+		}
+		/* add them to the conference */
+		if (flags && strcasecmp(flags, "none")) {
+			snprintf(appdata, sizeof(appdata), "%s +flags{%s}", conference_name, flags);
+			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
+		} else {
+			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
+		}
+
+		switch_channel_set_caller_extension(peer_channel, extension);
+		switch_channel_set_state(peer_channel, CS_EXECUTE);
+
+	} else {
+		switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
+
+  done:
+	if (conference) {
+		switch_thread_rwlock_unlock(conference->rwlock);
+	}
+	return status;
+}
+
+struct bg_call {
+	conference_obj_t *conference;
+	switch_core_session_t *session;
+	char *bridgeto;
+	uint32_t timeout;
+	char *flags;
+	char *cid_name;
+	char *cid_num;
+	char *conference_name;
+};
+
+static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t * thread, void *obj)
+{
+	struct bg_call *call = (struct bg_call *) obj;
+
+	if (call) {
+		switch_call_cause_t cause;
+		switch_event_t *event;
+
+		conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
+
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", call->conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "bgdial-result");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Result", "%s", switch_channel_cause2str(cause));
+			switch_event_fire(&event);
+		}
+		switch_safe_free(call->bridgeto);
+		switch_safe_free(call->flags);
+		switch_safe_free(call->cid_name);
+		switch_safe_free(call->cid_num);
+		switch_safe_free(call->conference_name);
+		switch_safe_free(call);
+	}
+
+	return NULL;
+}
+
+static switch_status_t conference_outcall_bg(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)
+{
+	struct bg_call *call = NULL;
+
+	if ((call = malloc(sizeof(*call)))) {
+		switch_thread_t *thread;
+		switch_threadattr_t *thd_attr = NULL;
+
+		memset(call, 0, sizeof(*call));
+		call->conference = conference;
+		call->session = session;
+		call->timeout = timeout;
+
+		if (bridgeto) {
+			call->bridgeto = strdup(bridgeto);
+		}
+		if (flags) {
+			call->flags = strdup(flags);
+		}
+		if (cid_name) {
+			call->cid_name = strdup(cid_name);
+		}
+		if (cid_num) {
+			call->cid_num = strdup(cid_num);
+		}
+
+		if (conference_name) {
+			call->conference_name = strdup(conference_name);
+		}
+
+
+		switch_threadattr_create(&thd_attr, conference->pool);
+		switch_threadattr_detach_set(thd_attr, 1);
+		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+		switch_thread_create(&thread, thd_attr, conference_outcall_run, call, conference->pool);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n");
+
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_MEMERR;
+}
+
+/* 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, char *buf, switch_size_t len)
+{
+	uint32_t x = 0;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+	/* generate some space infront of the file to be played */
+	for (x = 0; x < leadin; x++) {
+		switch_frame_t *read_frame;
+		switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
+			break;
+		}
+	}
+
+	/* if all is well, really play the file */
+	if (status == SWITCH_STATUS_SUCCESS) {
+		char *dpath = NULL;
+
+		if (conference->sound_prefix) {
+			if (!(dpath = switch_mprintf("%s/%s", conference->sound_prefix, path))) {
+				return SWITCH_STATUS_MEMERR;
+			}
+			path = dpath;
+		}
+
+		status = switch_ivr_play_file(session, NULL, path, NULL);
+		switch_safe_free(dpath);
+	}
+
+	return status;
+}
+
+static void set_mflags(char *flags, member_flag_t * f)
+{
+	if (flags) {
+		if (strstr(flags, "mute")) {
+			*f &= ~MFLAG_CAN_SPEAK;
+		} else if (strstr(flags, "deaf")) {
+			*f &= ~MFLAG_CAN_HEAR;
+		} else if (strstr(flags, "waste")) {
+			*f |= MFLAG_WASTE_BANDWIDTH;
+		}
+	}
+
+}
+
+
+/* Application interface function that is called from the dialplan to join the channel to a conference */
+static void conference_function(switch_core_session_t *session, char *data)
+{
+	switch_codec_t *read_codec = NULL;
+	uint32_t flags = 0;
+	conference_member_t member = { 0 };
+	conference_obj_t *conference = NULL;
+	switch_channel_t *channel = NULL;
+	char *mydata = switch_core_session_strdup(session, data);
+	char *conf_name = NULL;
+	char *bridge_prefix = "bridge:";
+	char *flags_prefix = "+flags{";
+	char *bridgeto = NULL;
+	char *profile_name = NULL;
+	switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
+	char *flags_str;
+	member_flag_t mflags = 0;
+	switch_core_session_message_t msg = { 0 };
+	uint8_t rl = 0, isbr = 0;
+	char *dpin = NULL;
+	conf_xml_cfg_t xml_cfg = { 0 };
+	char *params = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if (!mydata) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+		return;
+	}
+
+
+	/* is this a bridging conference ? */
+	if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
+		isbr = 1;
+		mydata += strlen(bridge_prefix);
+		if ((bridgeto = strchr(mydata, ':'))) {
+			*bridgeto++ = '\0';
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
+			goto done;
+		}
+	}
+
+	conf_name = mydata;
+
+	/* is there a conference pin ? */
+	if ((dpin = strchr(conf_name, '+'))) {
+		*dpin++ = '\0';
+	}
+
+	/* is there profile specification ? */
+	if ((profile_name = strchr(conf_name, '@'))) {
+		*profile_name++ = '\0';
+	} else {
+		profile_name = "default";
+	}
+
+	params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
+
+	/* Open the config from the xml registry */
+	if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+		goto done;
+	}
+
+	if ((profiles = switch_xml_child(cfg, "profiles"))) {
+		xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+	}
+
+	if (!xml_cfg.profile) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
+		switch_xml_free(cxml);
+		cxml = NULL;
+		goto done;
+	}
+
+	xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
+
+	/* if this is a bridging call, and it's not a duplicate, build a */
+	/* conference object, and skip pin handling, and locked checking */
+	if (isbr) {
+		char *uuid = switch_core_session_get_uuid(session);
+
+		if (!strcmp(conf_name, "_uuid_")) {
+			conf_name = uuid;
+		}
+
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s already exists!\n", conf_name);
+			goto done;
+		}
+
+		/* Create the conference object. */
+		conference = conference_new(conf_name, xml_cfg, NULL);
+
+		if (!conference) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+			goto done;
+		}
+
+		/* Set the minimum number of members (once you go above it you cannot go below it) */
+		conference->min = 2;
+
+		/* if the dialplan specified a pin, override the profile's value */
+		if (dpin) {
+			conference->pin = switch_core_strdup(conference->pool, dpin);
+		}
+
+		/* Indicate the conference is dynamic */
+		switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+		/* Start the conference thread for this conference */
+		launch_conference_thread(conference);
+
+	} else {
+		/* if the conference exists, get the pointer to it */
+		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;
+			}
+
+			/* if the dialplan specified a pin, override the profile's value */
+			if (dpin) {
+				conference->pin = switch_core_strdup(conference->pool, dpin);
+			}
+
+			/* Set the minimum number of members (once you go above it you cannot go below it) */
+			conference->min = 1;
+
+			/* Indicate the conference is dynamic */
+			switch_set_flag_locked(conference, CFLAG_DYNAMIC);
+
+			/* Start the conference thread for this conference */
+			launch_conference_thread(conference);
+		}
+
+		/* acquire a read lock on the thread so it can't leave without us */
+		if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
+			goto done;
+		}
+		rl++;
+
+		/* if this is not an outbound call, deal with conference pins */
+		if (!switch_channel_test_flag(channel, CF_OUTBOUND) && conference->pin) {
+			char pin_buf[80] = "";
+			int pin_retries = 3;	/* XXX - this should be configurable - i'm too lazy to do it right now... */
+			int pin_valid = 0;
+			switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+			/* Answer the channel */
+			switch_channel_answer(channel);
+
+			while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
+
+				/* be friendly */
+				if (conference->pin_sound) {
+					conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
+				}
+				/* wait for them if neccessary */
+				if (strlen(pin_buf) < strlen(conference->pin)) {
+					char *buf = pin_buf + strlen(pin_buf);
+					char term = '\0';
+
+					status = switch_ivr_collect_digits_count(session,
+															 buf,
+															 sizeof(pin_buf) - (unsigned int) strlen(pin_buf),
+															 (unsigned int) strlen(conference->pin) - (unsigned int) strlen(pin_buf), "#", &term, 10000);
+				}
+
+				pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, conference->pin) == 0);
+				if (!pin_valid) {
+					/* zero the collected pin */
+					memset(pin_buf, 0, sizeof(pin_buf));
+
+					/* more friendliness */
+					if (conference->bad_pin_sound) {
+						conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
+					}
+				}
+				pin_retries--;
+			}
+
+			if (!pin_valid) {
+				goto done;
+			}
+		}
+
+		/* don't allow more callers if the conference is locked, unless we invited them */
+		if (switch_test_flag(conference, CFLAG_LOCKED) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is locked.\n", conf_name);
+			if (conference->locked_sound) {
+				/* Answer the channel */
+				switch_channel_answer(channel);
+				conference_local_play_file(conference, session, conference->locked_sound, 20, NULL, 0);
+			}
+			goto done;
+		}
+
+		/* dont allow more callers than the max_members allows for -- I explicitly didnt allow outbound calls
+		 * someone else can add that (see above) if they feel that outbound calls should be able to violate the
+		 * max_members limit -- TRX
+		 */
+		if ((conference->max_members > 0) && (conference->count >= conference->max_members)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is full.\n", conf_name);
+			if (conference->maxmember_sound) {
+				/* Answer the channel */
+				switch_channel_answer(channel);
+				conference_local_play_file(conference, session, conference->maxmember_sound, 20, NULL, 0);
+			}
+			goto done;
+		}
 
- done:
-	if (conference) {
-		switch_thread_rwlock_unlock(conference->rwlock);
 	}
-    return status;
-}
-
-struct bg_call {
-    conference_obj_t *conference;
-    switch_core_session_t *session;
-    char *bridgeto;
-    uint32_t timeout;
-    char *flags;
-    char *cid_name;
-    char *cid_num;
-	char *conference_name;
-};
 
-static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, void *obj)
-{
-    struct bg_call *call = (struct bg_call *) obj;
-    
-    if (call) {
-        switch_call_cause_t cause;
-        switch_event_t *event;
-
-        conference_outcall(call->conference, NULL, call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
-
-        if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", call->conference->name);
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "bgdial-result");
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Result", "%s", switch_channel_cause2str(cause));
-            switch_event_fire(&event);
-        }
-        switch_safe_free(call->bridgeto);
-        switch_safe_free(call->flags);
-        switch_safe_free(call->cid_name);
-        switch_safe_free(call->cid_num);
-        switch_safe_free(call->conference_name);
-        switch_safe_free(call);
-    }
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+		cxml = NULL;
+	}
 
-    return NULL;
-}
+	/* if we're using "bridge:" make an outbound call and bridge it in */
+	if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
+		switch_call_cause_t cause;
+		if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) {
+			goto done;
+		}
+	} else {
+		/* if we're not using "bridge:" set the conference answered flag */
+		/* and this isn't an outbound channel, answer the call */
+		if (!switch_channel_test_flag(channel, CF_OUTBOUND))
+			switch_set_flag(conference, CFLAG_ANSWERED);
+	}
+
+	/* Save the original read codec. */
+	read_codec = switch_core_session_get_read_codec(session);
+	member.native_rate = read_codec->implementation->samples_per_second;
+	member.pool = switch_core_session_get_pool(session);
+
+	/* Setup a Signed Linear codec for reading audio. */
+	if (switch_core_codec_init(&member.read_codec,
+							   "L16",
+							   NULL,
+							   read_codec->implementation->samples_per_second,
+							   read_codec->implementation->microseconds_per_frame / 1000,
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+		flags = 0;
+		goto done;
+	}
 
-static switch_status_t conference_outcall_bg(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)
-{
-    struct bg_call *call = NULL;
-    
-    if ((call = malloc(sizeof(*call)))) {
-        switch_thread_t *thread;
-        switch_threadattr_t *thd_attr = NULL;
-
-        memset(call, 0, sizeof(*call));
-        call->conference = conference;
-        call->session = session;
-        call->timeout = timeout;
-
-        if (bridgeto) {
-            call->bridgeto = strdup(bridgeto);
-        }
-        if (flags) {
-            call->flags = strdup(flags);
-        }
-        if (cid_name) {
-            call->cid_name = strdup(cid_name);
-        }
-        if (cid_num) {
-            call->cid_num = strdup(cid_num);
-        }
-		
-		if (conference_name) {
-			call->conference_name = strdup(conference_name);
+	if (read_codec->implementation->samples_per_second != conference->rate) {
+		switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
+			&member.read_resampler : &member.mux_resampler;
+
+		if (switch_resample_create(resampler,
+								   read_codec->implementation->samples_per_second,
+								   read_codec->implementation->samples_per_second * 20,
+								   conference->rate, conference->rate * 20, member.pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
+			goto done;
 		}
 
-        
-        switch_threadattr_create(&thd_attr, conference->pool);
-        switch_threadattr_detach_set(thd_attr, 1);
-        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-        switch_thread_create(&thread, thd_attr, conference_outcall_run, call, conference->pool);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n");
+		/* 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) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+			goto done;
+		}
+	}
+	/* Setup a Signed Linear codec for writing audio. */
+	if (switch_core_codec_init(&member.write_codec,
+							   "L16",
+							   NULL,
+							   read_codec->implementation->samples_per_second,
+							   read_codec->implementation->microseconds_per_frame / 1000,
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+		flags = 0;
+		goto codec_done2;
+	}
 
-		return SWITCH_STATUS_SUCCESS;
-    }
+	/* Setup an audio buffer for the incoming audio */
+	if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+		goto codec_done1;
+	}
 
-	return SWITCH_STATUS_MEMERR;
-}
+	/* Setup an audio buffer for the outgoing audio */
+	if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
+		goto codec_done1;
+	}
 
-/* 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, char *buf, switch_size_t len)
-{
-    uint32_t x = 0;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	/* Prepare MUTEXS */
+	member.id = next_member_id();
+	member.session = session;
+	switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
+	switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
+	switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
+
+	/* Install our Signed Linear codec so we get the audio in that format */
+	switch_core_session_set_read_codec(member.session, &member.read_codec);
+
+	if ((flags_str = strstr(mydata, flags_prefix))) {
+		char *p;
+
+		*flags_str = '\0';
+		flags_str += strlen(flags_prefix);
+		if ((p = strchr(flags_str, '}'))) {
+			*p = '\0';
+		}
+	}
 
-    /* generate some space infront of the file to be played */
-    for (x = 0; x < leadin; x++) {
-        switch_frame_t *read_frame;
-        switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+	mflags = conference->mflags;
+	set_mflags(flags_str, &mflags);
+	switch_set_flag_locked((&member), MFLAG_RUNNING | mflags);
 
-        if (!SWITCH_READ_ACCEPTABLE(status)) {
-            break;
-        }
-    }
+	/* Add the caller to the conference */
+	if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
+		goto codec_done1;
+	}
 
-    /* if all is well, really play the file */
-    if (status == SWITCH_STATUS_SUCCESS) {
-        char *dpath = NULL;
+	msg.from = __FILE__;
 
-        if (conference->sound_prefix) {
-            if (!(dpath = switch_mprintf("%s/%s", conference->sound_prefix, path))) {
-                return SWITCH_STATUS_MEMERR;
-            }
-            path = dpath;
-        }
+	/* Tell the channel we are going to be in a bridge */
+	msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
+	switch_core_session_receive_message(session, &msg);
 
-        status = switch_ivr_play_file(session, NULL, path, NULL);
-        switch_safe_free(dpath);
-    }
+	/* Run the confernece loop */
+	conference_loop_output(&member);
 
-    return status;
-}
+	/* 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);
 
-static void set_mflags(char *flags, member_flag_t *f)
-{
-	if (flags) {
-		if (strstr(flags, "mute")) {
-			*f &= ~MFLAG_CAN_SPEAK;
-		} else if (strstr(flags, "deaf")) {
-			*f &= ~MFLAG_CAN_HEAR;
-		} else if (strstr(flags, "waste")) {
-			*f |= MFLAG_WASTE_BANDWIDTH;
-		}
-	}
+	/* Remove the caller from the conference */
+	conference_del_member(member.conference, &member);
 
-}
+	/* Put the original codec back */
+	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:
+	switch_core_codec_destroy(&member.read_codec);
+  codec_done2:
+	switch_core_codec_destroy(&member.write_codec);
+  done:
+	switch_safe_free(params);
+	switch_buffer_destroy(&member.resample_buffer);
+	switch_buffer_destroy(&member.audio_buffer);
+	switch_buffer_destroy(&member.mux_buffer);
 
-/* Application interface function that is called from the dialplan to join the channel to a conference */
-static void conference_function(switch_core_session_t *session, char *data)
-{
-    switch_codec_t *read_codec = NULL;
-    uint32_t flags = 0;
-    conference_member_t member = {0};
-    conference_obj_t *conference = NULL;
-    switch_channel_t *channel = NULL;
-    char *mydata = switch_core_session_strdup(session, data);
-    char *conf_name = NULL;
-    char *bridge_prefix = "bridge:";
-    char *flags_prefix = "+flags{";
-    char *bridgeto = NULL;
-    char *profile_name = NULL;
-    switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
-    char *flags_str;
-    member_flag_t mflags = 0;
-    switch_core_session_message_t msg = {0};
-    uint8_t rl = 0, isbr = 0;
-    char *dpin = NULL;
-    conf_xml_cfg_t xml_cfg = {0};
-    char *params = NULL;
-
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
-
-    if (!mydata) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-        return;
-    }
-
-
-    /* is this a bridging conference ? */
-    if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
-        isbr = 1;
-        mydata += strlen(bridge_prefix);
-        if ((bridgeto = strchr(mydata, ':'))) {
-            *bridgeto++ = '\0';
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
-            goto done;
-        }
-    }
-
-    conf_name = mydata;
-
-    /* is there a conference pin ? */
-    if ((dpin = strchr(conf_name, '+'))) {
-        *dpin++ = '\0';
-    }
-
-    /* is there profile specification ? */
-    if ((profile_name = strchr(conf_name, '@'))) {
-        *profile_name++ = '\0';
-    } else {
-        profile_name = "default";
-    }
-
-    params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
-
-    /* Open the config from the xml registry */
-    if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
-        goto done;
-    }
-
-    if ((profiles = switch_xml_child(cfg, "profiles"))) {
-        xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
-    }
-
-    if (!xml_cfg.profile) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile: %s\n", profile_name);
-        switch_xml_free(cxml);
-        cxml = NULL;
-        goto done;
-    }
-
-    xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
-
-    /* if this is a bridging call, and it's not a duplicate, build a */
-    /* conference object, and skip pin handling, and locked checking */
-    if (isbr) {
-        char *uuid = switch_core_session_get_uuid(session);
-
-        if (!strcmp(conf_name, "_uuid_")) {
-            conf_name = uuid;
-        }
-
-        if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s already exists!\n", conf_name);
-            goto done;
-        }
-
-        /* Create the conference object. */
-        conference = conference_new(conf_name, xml_cfg, NULL);
-
-        if (!conference) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-            goto done;
-        }
-
-        /* Set the minimum number of members (once you go above it you cannot go below it) */
-        conference->min = 2;
-
-        /* if the dialplan specified a pin, override the profile's value */
-        if (dpin) {
-            conference->pin = switch_core_strdup(conference->pool, dpin);
-        }
-
-        /* Indicate the conference is dynamic */
-        switch_set_flag_locked(conference, CFLAG_DYNAMIC);	
-
-        /* Start the conference thread for this conference */
-        launch_conference_thread(conference);
-
-    } else {
-        /* if the conference exists, get the pointer to it */
-        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;
-            }
-
-            /* if the dialplan specified a pin, override the profile's value */
-            if (dpin) {
-                conference->pin = switch_core_strdup(conference->pool, dpin);
-            }
-
-            /* Set the minimum number of members (once you go above it you cannot go below it) */
-            conference->min = 1;
-
-            /* Indicate the conference is dynamic */
-            switch_set_flag_locked(conference, CFLAG_DYNAMIC);
-
-            /* Start the conference thread for this conference */
-            launch_conference_thread(conference);
-        }
-
-        /* acquire a read lock on the thread so it can't leave without us */
-        if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
-            goto done;
-        }
-        rl++;
-        
-        /* if this is not an outbound call, deal with conference pins */
-        if (!switch_channel_test_flag(channel, CF_OUTBOUND) && conference->pin) {
-            char pin_buf[80] = "";
-            int  pin_retries = 3;	/* XXX - this should be configurable - i'm too lazy to do it right now... */
-            int  pin_valid = 0;
-            switch_status_t status = SWITCH_STATUS_SUCCESS;
-
-            /* Answer the channel */
-            switch_channel_answer(channel);
-
-            while(!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
-
-                /* be friendly */
-                if (conference->pin_sound) {
-                    conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
-                } 
-                /* wait for them if neccessary */
-                if (strlen(pin_buf) < strlen(conference->pin)) {
-                    char *buf = pin_buf + strlen(pin_buf);
-                    char term = '\0';
-
-                    status = switch_ivr_collect_digits_count(session, 
-                                                             buf, 
-                                                             sizeof(pin_buf) - (unsigned int)strlen(pin_buf), 
-                                                             (unsigned int)strlen(conference->pin) - (unsigned int)strlen(pin_buf), 
-                                                             "#", &term, 10000);
-                }
-
-                pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, conference->pin) == 0);
-                if (!pin_valid) {
-                    /* zero the collected pin */
-                    memset(pin_buf, 0, sizeof(pin_buf));
-
-                    /* more friendliness */
-                    if (conference->bad_pin_sound) {
-                        conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
-                    }
-                }
-                pin_retries --;
-            }
-
-            if (!pin_valid) {
-                goto done;
-            }
-        }
-
-        /* don't allow more callers if the conference is locked, unless we invited them */
-        if (switch_test_flag(conference, CFLAG_LOCKED) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is locked.\n", conf_name);
-            if (conference->locked_sound) {
-                /* Answer the channel */
-                switch_channel_answer(channel);
-                conference_local_play_file(conference, session, conference->locked_sound, 20, NULL, 0);
-            }
-            goto done;
-        }
-
-        /* dont allow more callers than the max_members allows for -- I explicitly didnt allow outbound calls
-         * someone else can add that (see above) if they feel that outbound calls should be able to violate the
-         * max_members limit -- TRX
-         */
-        if((conference->max_members > 0) && (conference->count >= conference->max_members)) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Conference %s is full.\n",conf_name);
-            if(conference->maxmember_sound) {
-                /* Answer the channel */
-                switch_channel_answer(channel);
-                conference_local_play_file(conference, session, conference->maxmember_sound, 20, NULL, 0);
-            }
-            goto done;
-        }
-
-    }
-
-    /* Release the config registry handle */
-    if (cxml) {
-        switch_xml_free(cxml);
-        cxml = NULL;
-    }
-
-    /* if we're using "bridge:" make an outbound call and bridge it in */
-    if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
-        switch_call_cause_t cause;
-        if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) {
-            goto done;
-        }
-    } else {	
-        /* if we're not using "bridge:" set the conference answered flag */
-        /* and this isn't an outbound channel, answer the call */
-        if (!switch_channel_test_flag(channel, CF_OUTBOUND)) 
-            switch_set_flag(conference, CFLAG_ANSWERED);
-    }
-
-    /* Save the original read codec. */
-    read_codec = switch_core_session_get_read_codec(session);
-    member.native_rate = read_codec->implementation->samples_per_second;
-    member.pool = switch_core_session_get_pool(session);
-
-    /* Setup a Signed Linear codec for reading audio. */
-    if (switch_core_codec_init(&member.read_codec, 
-                               "L16", 
-                               NULL, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->microseconds_per_frame / 1000, 
-                               1, 
-                               SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
-                               NULL, 
-                               member.pool) == SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", 
-                          read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", 
-						  read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-        flags = 0;
-        goto done;
-    }
-
-    if (read_codec->implementation->samples_per_second != conference->rate) {
-        switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ? 
-            &member.read_resampler : &member.mux_resampler;
-
-        if (switch_resample_create(resampler, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->samples_per_second * 20, 
-                               conference->rate, 
-                               conference->rate * 20, 
-							   member.pool) != SWITCH_STATUS_SUCCESS){
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
-            goto done;
-		}
-
-        /* 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) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-            goto done;
-        }
-    }
-    /* Setup a Signed Linear codec for writing audio. */
-    if (switch_core_codec_init(&member.write_codec, 
-                               "L16", 
-                               NULL, 
-                               read_codec->implementation->samples_per_second, 
-                               read_codec->implementation->microseconds_per_frame / 1000, 
-                               1, 
-                               SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
-                               NULL, 
-                               member.pool) == SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", 
-						  read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", 
-						  read_codec->implementation->samples_per_second,
-						  read_codec->implementation->microseconds_per_frame / 1000);
-        flags = 0;
-        goto codec_done2;
-    }
-
-    /* Setup an audio buffer for the incoming audio */
-    if (switch_buffer_create_dynamic(&member.audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-        goto codec_done1;
-    }
-
-    /* Setup an audio buffer for the outgoing audio */
-    if (switch_buffer_create_dynamic(&member.mux_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error Creating Audio Buffer!\n");
-        goto codec_done1;
-    }
-
-    /* Prepare MUTEXS */
-    member.id = next_member_id();
-    member.session = session;
-    switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
-    switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
-    switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
-
-    /* Install our Signed Linear codec so we get the audio in that format */
-    switch_core_session_set_read_codec(member.session, &member.read_codec);
-
-    if ((flags_str = strstr(mydata, flags_prefix))) {
-        char *p;
-
-        *flags_str = '\0';
-        flags_str += strlen(flags_prefix);
-        if ((p = strchr(flags_str, '}'))) {
-            *p = '\0';
-        }
-    }
-	
-	mflags = conference->mflags;
-	set_mflags(flags_str, &mflags);
-    switch_set_flag_locked((&member), MFLAG_RUNNING | mflags);
-	
-    /* Add the caller to the conference */
-    if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
-        goto codec_done1;
-    }
-
-    msg.from = __FILE__;
-
-    /* Tell the channel we are going to be in a bridge */
-    msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
-    switch_core_session_receive_message(session, &msg);
-
-    /* Run the confernece loop */
-    conference_loop_output(&member);
-
-    /* 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);
-
-    /* Remove the caller from the conference */
-    conference_del_member(member.conference, &member);
-
-    /* Put the original codec back */
-    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:
-    switch_core_codec_destroy(&member.read_codec);
- codec_done2:
-    switch_core_codec_destroy(&member.write_codec);
- done:
-    switch_safe_free(params);
-    switch_buffer_destroy(&member.resample_buffer);
-    switch_buffer_destroy(&member.audio_buffer);
-    switch_buffer_destroy(&member.mux_buffer);
-
-    /* Release the config registry handle */
-    if (cxml) {
-        switch_xml_free(cxml);
-    }
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+	}
 
-    if (switch_test_flag(&member, MFLAG_KICKED) && conference->kicked_sound) {
+	if (switch_test_flag(&member, MFLAG_KICKED) && conference->kicked_sound) {
 		char *toplay = NULL;
 		char *dfile = NULL;
 
-        if (conference->sound_prefix) {
-            assert((dfile = switch_mprintf("%s/%s", conference->sound_prefix, conference->kicked_sound)));
+		if (conference->sound_prefix) {
+			assert((dfile = switch_mprintf("%s/%s", conference->sound_prefix, conference->kicked_sound)));
 			toplay = dfile;
 		} else {
 			toplay = conference->kicked_sound;
@@ -4196,720 +4107,719 @@
 
 		switch_ivr_play_file(session, NULL, toplay, NULL);
 		switch_safe_free(dfile);
-    }
+	}
 
-    switch_core_session_reset(session);
+	switch_core_session_reset(session);
 
-    /* release the readlock */
-    if (rl) {
-        switch_thread_rwlock_unlock(conference->rwlock);
-    }
+	/* release the readlock */
+	if (rl) {
+		switch_thread_rwlock_unlock(conference->rwlock);
+	}
 }
 
 /* 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;
+
+	switch_set_flag_locked(conference, CFLAG_RUNNING);
+	switch_threadattr_create(&thd_attr, conference->pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_mutex_lock(globals.hash_mutex);
+	switch_core_hash_insert(globals.conference_hash, conference->name, conference);
+	switch_mutex_unlock(globals.hash_mutex);
+	switch_thread_create(&thread, thd_attr, conference_thread_run, conference, conference->pool);
+}
+
+static void launch_conference_record_thread(conference_obj_t * conference, char *path)
 {
-    switch_thread_t *thread;
-    switch_threadattr_t *thd_attr = NULL;
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
+	switch_memory_pool_t *pool;
+	conference_record_t *rec;
+
+	/* Setup a memory pool to use. */
+	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+	}
+
+	/* Create a node object */
+	if (!(rec = switch_core_alloc(pool, sizeof(*rec)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
+		switch_core_destroy_memory_pool(&pool);
+	}
 
-    switch_set_flag_locked(conference, CFLAG_RUNNING);
-    switch_threadattr_create(&thd_attr, conference->pool);
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_mutex_lock(globals.hash_mutex);
-    switch_core_hash_insert(globals.conference_hash, conference->name, conference);
-    switch_mutex_unlock(globals.hash_mutex);
-    switch_thread_create(&thread, thd_attr, conference_thread_run, conference, conference->pool);
-}
-
-static void launch_conference_record_thread(conference_obj_t *conference, char *path)
-{
-    switch_thread_t *thread;
-    switch_threadattr_t *thd_attr = NULL;
-    switch_memory_pool_t *pool;
-    conference_record_t *rec;
-
-    /* Setup a memory pool to use. */
-    if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-    }
-
-    /* Create a node object*/
-    if (!(rec = switch_core_alloc(pool, sizeof(*rec)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
-        switch_core_destroy_memory_pool(&pool);
-    }
-
-    rec->conference = conference;
-    rec->path = switch_core_strdup(pool, path);
-    rec->pool = pool;
-
-    switch_threadattr_create(&thd_attr, rec->pool);
-    switch_threadattr_detach_set(thd_attr, 1);
-    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-    switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
+	rec->conference = conference;
+	rec->path = switch_core_strdup(pool, path);
+	rec->pool = pool;
+
+	switch_threadattr_create(&thd_attr, rec->pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
 }
 
 static const switch_application_interface_t conference_application_interface = {
-    /*.interface_name */ global_app_name, 
-    /*.application_function */ conference_function, 
-    NULL, NULL, NULL, 
+	/*.interface_name */ global_app_name,
+	/*.application_function */ conference_function,
+	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-    /*.next*/ NULL
+	/*.next */ NULL
 };
 
 static switch_api_interface_t conf_api_interface = {
-    /*.interface_name */	"conference", 
-    /*.desc */				"Conference module commands", 
-    /*.function */			conf_api_main, 
-    /*.syntax */		/* see switch_module_load, this is built on the fly */
-    /*.next */ 
+	/*.interface_name */ "conference",
+	/*.desc */ "Conference module commands",
+	/*.function */ conf_api_main,
+	/*.syntax *//* see switch_module_load, this is built on the fly */
+	/*.next */
 };
 
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
 {
-    char name[512] = "", *p, *lbuf = NULL;
-    switch_chat_interface_t *ci;
-    conference_obj_t *conference = NULL;
-    switch_stream_handle_t stream = {0};
-
-    if ((p = strchr(to, '+'))) {
-        to = ++p;
-    }
-
-    if (!body) {
-        return SWITCH_STATUS_SUCCESS;
-    }
-
-    if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
-    }
-
-
-    if ((p = strchr(to, '@'))) {
-        switch_copy_string(name, to, ++p-to);
-    } 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);
-        return SWITCH_STATUS_FALSE;
-    }
-
-    SWITCH_STANDARD_STREAM(stream);
-
-    if (body != NULL && (lbuf = strdup(body))) {
-        int argc;
-        char *argv[25];
-
-        memset(argv, 0, sizeof(argv));
-        argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-
-        /* try to find a command to execute */
-        if (argc) {
-            /* special case list */
-            if (strcasecmp(argv[0], "list") == 0) {
-                conference_list_pretty(conference, &stream);
-                /* provide help */
-            } 
+	char name[512] = "", *p, *lbuf = NULL;
+	switch_chat_interface_t *ci;
+	conference_obj_t *conference = NULL;
+	switch_stream_handle_t stream = { 0 };
+
+	if ((p = strchr(to, '+'))) {
+		to = ++p;
+	}
+
+	if (!body) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
+	}
+
+
+	if ((p = strchr(to, '@'))) {
+		switch_copy_string(name, to, ++p - to);
+	} 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);
+		return SWITCH_STATUS_FALSE;
+	}
+
+	SWITCH_STANDARD_STREAM(stream);
+
+	if (body != NULL && (lbuf = strdup(body))) {
+		int argc;
+		char *argv[25];
+
+		memset(argv, 0, sizeof(argv));
+		argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+		/* try to find a command to execute */
+		if (argc) {
+			/* special case list */
+			if (strcasecmp(argv[0], "list") == 0) {
+				conference_list_pretty(conference, &stream);
+				/* provide help */
+			}
 #if 0
-            else {
-                if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-                    stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
-                    /* find a normal command */
-                } else {
-                    conf_api_dispatch(conference, &stream, argc, argv, (const char *)body, 0);
-                }
-            }
+			else {
+				if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
+					stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
+					/* find a normal command */
+				} else {
+					conf_api_dispatch(conference, &stream, argc, argv, (const char *) body, 0);
+				}
+			}
 #endif
-        } else {
-            stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
-        }
-    }
-    switch_safe_free(lbuf);
+		} else {
+			stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
+		}
+	}
+	switch_safe_free(lbuf);
 
-    ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL);
-    switch_safe_free(stream.data);
+	ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL);
+	switch_safe_free(stream.data);
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static const switch_chat_interface_t conference_chat_interface = {
-    /*.name */ CONF_CHAT_PROTO, 
-    /*.chat_send */ chat_send, 
+	/*.name */ CONF_CHAT_PROTO,
+	/*.chat_send */ chat_send,
 
 };
 
 static switch_loadable_module_interface_t conference_module_interface = {
-    /*.module_name */ modname, 
-    /*.endpoint_interface */ NULL, 
-    /*.timer_interface */ NULL, 
-    /*.dialplan_interface */ NULL, 
-    /*.codec_interface */ NULL, 
-    /*.application_interface */ &conference_application_interface, 
-    /*.api_interface */ &conf_api_interface, 
-    /*.file_interface */ NULL, 
-    /*.speech_interface */ NULL, 
-    /*.directory_interface */ NULL, 
-    /*.chat_interface */ &conference_chat_interface
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ NULL,
+	/*.application_interface */ &conference_application_interface,
+	/*.api_interface */ &conf_api_interface,
+	/*.file_interface */ NULL,
+	/*.speech_interface */ NULL,
+	/*.directory_interface */ NULL,
+	/*.chat_interface */ &conference_chat_interface
 };
 
-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;
+	caller_control_action_t *action;
+
+	assert(conference != NULL);
+
+	for (i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i < CCFNTBL_QTY; i++) {
+		if (!switch_strlen_zero(ccfntbl[i].digits)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+							  "Installing default caller control action '%s' bound to '%s'.\n", ccfntbl[i].key, ccfntbl[i].digits);
+			action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
+			if (action != NULL) {
+				action->fndesc = &ccfntbl[i];
+				action->data = NULL;
+				status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, ccfntbl[i].digits, action);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
+				status = SWITCH_STATUS_MEMERR;
+			}
+		}
+	}
+
+
+	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)
 {
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    uint32_t i;
-    caller_control_action_t *action;
-
-    assert(conference != NULL);
-
-    for(i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<CCFNTBL_QTY; i++) {
-        if (!switch_strlen_zero(ccfntbl[i].digits)) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing default caller control action '%s' bound to '%s'.\n", 
-                              ccfntbl[i].key, 
-                              ccfntbl[i].digits);
-            action = (caller_control_action_t *)switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
-            if (action != NULL) {
-                action->fndesc = &ccfntbl[i];
-                action->data = NULL;
-                status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, ccfntbl[i].digits, action);
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n", 
-                                  ccfntbl[i].key, ccfntbl[i].digits);
-                status = SWITCH_STATUS_MEMERR;
-            }
-        }
-    }
-	
-
-    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)
-{
-    switch_status_t status = SWITCH_STATUS_FALSE;
-    switch_xml_t xml_kvp;
-
-    assert(conference != NULL);
-    assert(xml_controls != NULL);
-
-    /* parse the controls tree for caller control digit strings */
-    for (xml_kvp = switch_xml_child(xml_controls, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
-        char *key = (char *) switch_xml_attr(xml_kvp, "action");
-        char *val = (char *) switch_xml_attr(xml_kvp, "digits");
-        char *data = (char *)switch_xml_attr_soft(xml_kvp, "data");
-
-        if (!switch_strlen_zero(key) && !switch_strlen_zero(val)) {
-            uint32_t i;
-
-            /* scan through all of the valid actions, and if found, */
-            /* set the new caller control action digit string, then */
-            /* stop scanning the table, and go to the next xml kvp. */
-            for(i = 0, status = SWITCH_STATUS_NOOP; i<CCFNTBL_QTY && status == SWITCH_STATUS_NOOP; i++) {
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	switch_xml_t xml_kvp;
+
+	assert(conference != NULL);
+	assert(xml_controls != NULL);
+
+	/* parse the controls tree for caller control digit strings */
+	for (xml_kvp = switch_xml_child(xml_controls, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
+		char *key = (char *) switch_xml_attr(xml_kvp, "action");
+		char *val = (char *) switch_xml_attr(xml_kvp, "digits");
+		char *data = (char *) switch_xml_attr_soft(xml_kvp, "data");
+
+		if (!switch_strlen_zero(key) && !switch_strlen_zero(val)) {
+			uint32_t i;
+
+			/* scan through all of the valid actions, and if found, */
+			/* set the new caller control action digit string, then */
+			/* stop scanning the table, and go to the next xml kvp. */
+			for (i = 0, status = SWITCH_STATUS_NOOP; i < CCFNTBL_QTY && status == SWITCH_STATUS_NOOP; i++) {
+
+				if (strcasecmp(ccfntbl[i].key, key) == 0) {
 
-                if (strcasecmp(ccfntbl[i].key, key) == 0) {
-					
 					caller_control_action_t *action;
 
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing caller control action '%s' bound to '%s'.\n", key, val);
-					action = (caller_control_action_t *)switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
+					action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t));
 					if (action != NULL) {
 						action->fndesc = &ccfntbl[i];
-						action->data = (void *)switch_core_strdup(conference->pool, data);
+						action->data = (void *) switch_core_strdup(conference->pool, data);
 						action->binded_dtmf = switch_core_strdup(conference->pool, val);
 						status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser, val, action);
 					} else {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+										  "unable to alloc memory for caller control binding '%s' to '%s'\n", ccfntbl[i].key, ccfntbl[i].digits);
 						status = SWITCH_STATUS_MEMERR;
 					}
 				}
 			}
-            if (status == SWITCH_STATUS_NOOP) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n", key);
-            }
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
-        }
-    }
+			if (status == SWITCH_STATUS_NOOP) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n", key);
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control config entry pair action = '%s' digits = '%s'\n", key, val);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 /* create a new conferene with a specific profile */
 static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool)
 {
-    conference_obj_t *conference;
-    switch_xml_t xml_kvp;
-    char *rate_name = NULL;
-    char *interval_name = NULL;
-    char *timer_name = NULL;
-    char *domain = NULL;
-    char *tts_engine = NULL;
-    char *tts_voice = NULL;
-    char *enter_sound = NULL;
-    char *sound_prefix = NULL;
-    char *exit_sound = NULL;
-    char *alone_sound = NULL;
-    char *ack_sound = NULL;
-    char *nack_sound = NULL;
-    char *muted_sound = NULL;
-    char *unmuted_sound = NULL;
-    char *locked_sound = NULL;
-    char *is_locked_sound = NULL;
-    char *is_unlocked_sound = NULL;
-    char *kicked_sound = NULL;
-    char *pin = NULL;
-    char *pin_sound = NULL; 
-    char *bad_pin_sound = NULL;
-    char *energy_level = NULL;
-    char *caller_id_name = NULL;
-    char *caller_id_number = NULL;
-    char *caller_controls = NULL;
+	conference_obj_t *conference;
+	switch_xml_t xml_kvp;
+	char *rate_name = NULL;
+	char *interval_name = NULL;
+	char *timer_name = NULL;
+	char *domain = NULL;
+	char *tts_engine = NULL;
+	char *tts_voice = NULL;
+	char *enter_sound = NULL;
+	char *sound_prefix = NULL;
+	char *exit_sound = NULL;
+	char *alone_sound = NULL;
+	char *ack_sound = NULL;
+	char *nack_sound = NULL;
+	char *muted_sound = NULL;
+	char *unmuted_sound = NULL;
+	char *locked_sound = NULL;
+	char *is_locked_sound = NULL;
+	char *is_unlocked_sound = NULL;
+	char *kicked_sound = NULL;
+	char *pin = NULL;
+	char *pin_sound = NULL;
+	char *bad_pin_sound = NULL;
+	char *energy_level = NULL;
+	char *caller_id_name = NULL;
+	char *caller_id_number = NULL;
+	char *caller_controls = NULL;
 	char *member_flags = NULL;
-    uint32_t max_members = 0;
-    uint32_t anounce_count = 0;
-    char *maxmember_sound = NULL;
-    uint32_t rate = 8000, interval = 20;
-    switch_status_t status;
-
-    /* Validate the conference name */
-    if (switch_strlen_zero(name)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Record! no name.\n");
-        return NULL;
-    }
-
-    /* parse the profile tree for param values */
-    for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) {
-        char *var = (char *) switch_xml_attr_soft(xml_kvp, "name");
-        char *val = (char *) switch_xml_attr_soft(xml_kvp, "value");
-        char buf[128] = "";
-        char *p;
-
-        if ((p = strchr(var, '_'))) {
-            switch_copy_string(buf, var, sizeof(buf));
-            for(p = buf; *p; p++) {
-                if (*p == '_') {
-                    *p = '-';
-                }
-            }
-            var = buf;
-        }
-
-        if (!strcasecmp(var, "rate")) {
-            rate_name = val;
-        } else if (!strcasecmp(var, "domain")) {
-            domain = val;
-        } else if (!strcasecmp(var, "interval")) {
-            interval_name = val;
-        } else if (!strcasecmp(var, "timer-name")) {
-            timer_name = val;
-        } else if (!strcasecmp(var, "tts-engine")) {
-            tts_engine = val;
-        } else if (!strcasecmp(var, "tts-voice")) {
-            tts_voice = val;
-        } else if (!strcasecmp(var, "enter-sound")) {
-            enter_sound = val;
-        } else if (!strcasecmp(var, "exit-sound")) {
-            exit_sound = val;
-        } else if (!strcasecmp(var, "alone-sound")) {
-            alone_sound = val;
-        } else if (!strcasecmp(var, "ack-sound")) {
-            ack_sound = val;
-        } else if (!strcasecmp(var, "nack-sound")) {
-            nack_sound = val;
-        } else if (!strcasecmp(var, "muted-sound")) {
-            muted_sound = val;
-        } else if (!strcasecmp(var, "unmuted-sound")) {
-            unmuted_sound = val;
-        } else if (!strcasecmp(var, "locked-sound")) {
-            locked_sound = val;
-        } else if (!strcasecmp(var, "is-locked-sound")) {
-            is_locked_sound = val;
-        } else if (!strcasecmp(var, "is-unlocked-sound")) {
-            is_unlocked_sound = val;
-        } else if (!strcasecmp(var, "member-flags")) {
+	uint32_t max_members = 0;
+	uint32_t anounce_count = 0;
+	char *maxmember_sound = NULL;
+	uint32_t rate = 8000, interval = 20;
+	switch_status_t status;
+
+	/* Validate the conference name */
+	if (switch_strlen_zero(name)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Record! no name.\n");
+		return NULL;
+	}
+
+	/* parse the profile tree for param values */
+	for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) {
+		char *var = (char *) switch_xml_attr_soft(xml_kvp, "name");
+		char *val = (char *) switch_xml_attr_soft(xml_kvp, "value");
+		char buf[128] = "";
+		char *p;
+
+		if ((p = strchr(var, '_'))) {
+			switch_copy_string(buf, var, sizeof(buf));
+			for (p = buf; *p; p++) {
+				if (*p == '_') {
+					*p = '-';
+				}
+			}
+			var = buf;
+		}
+
+		if (!strcasecmp(var, "rate")) {
+			rate_name = val;
+		} else if (!strcasecmp(var, "domain")) {
+			domain = val;
+		} else if (!strcasecmp(var, "interval")) {
+			interval_name = val;
+		} else if (!strcasecmp(var, "timer-name")) {
+			timer_name = val;
+		} else if (!strcasecmp(var, "tts-engine")) {
+			tts_engine = val;
+		} else if (!strcasecmp(var, "tts-voice")) {
+			tts_voice = val;
+		} else if (!strcasecmp(var, "enter-sound")) {
+			enter_sound = val;
+		} else if (!strcasecmp(var, "exit-sound")) {
+			exit_sound = val;
+		} else if (!strcasecmp(var, "alone-sound")) {
+			alone_sound = val;
+		} else if (!strcasecmp(var, "ack-sound")) {
+			ack_sound = val;
+		} else if (!strcasecmp(var, "nack-sound")) {
+			nack_sound = val;
+		} else if (!strcasecmp(var, "muted-sound")) {
+			muted_sound = val;
+		} else if (!strcasecmp(var, "unmuted-sound")) {
+			unmuted_sound = val;
+		} else if (!strcasecmp(var, "locked-sound")) {
+			locked_sound = val;
+		} else if (!strcasecmp(var, "is-locked-sound")) {
+			is_locked_sound = val;
+		} else if (!strcasecmp(var, "is-unlocked-sound")) {
+			is_unlocked_sound = val;
+		} else if (!strcasecmp(var, "member-flags")) {
 			member_flags = val;
-        } else if (!strcasecmp(var, "kicked-sound")) {
-            kicked_sound = val;
-        } else if (!strcasecmp(var, "pin")) {
-            pin = val;
-        } else if (!strcasecmp(var, "pin-sound")) {
-            pin_sound = val;
-        } else if (!strcasecmp(var, "bad-pin-sound")) {
-            bad_pin_sound = val;
-        } else if (!strcasecmp(var, "energy-level")) {
-            energy_level = val;
-        } else if (!strcasecmp(var, "caller-id-name")) {
-            caller_id_name = val;
-        } else if (!strcasecmp(var, "caller-id-number")) {
-            caller_id_number = val;
-        } else if (!strcasecmp(var, "caller-controls")) {
-            caller_controls = val;
-        } else if (!strcasecmp(var, "sound-prefix")) {
-            sound_prefix = val;
-        } else if (!strcasecmp(var, "max-members")) {
-            errno = 0; // sanity first
-            max_members = strtol(val,NULL,0); // base 0 lets 0x... for hex 0... for octal and base 10 otherwise through
-            if(errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
-                // a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound 
-                // stuff is added, see comments above
-                max_members = 0; // set to 0 to disable max counts
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n",val);
-            }
-        } else if(!strcasecmp(var, "max-members-sound")) {
-            maxmember_sound = val;
-        } else if(!strcasecmp(var, "anounce-count")) {
-            errno = 0; // safety first
-            anounce_count = strtol(val,NULL,0);
-            if(errno == ERANGE || errno == EINVAL) {
-                anounce_count = 0;
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "anounce-count is invalid, not anouncing member counts\n");
-            }
-        }
-    }
-
-    /* Set defaults and various paramaters */
-
-    /* Speed in hertz */
-    if (!switch_strlen_zero(rate_name)) {
-        uint32_t r = atoi(rate_name);
-        if (r) {
-            rate = r;
-        }
-    }
-
-    /* Packet Interval in milliseconds */
-    if (!switch_strlen_zero(interval_name)) {
-        uint32_t i = atoi(interval_name);
-        if (i) {
-            interval = i;
-        }
-    }
-
-    /* Timer module to use */
-    if (switch_strlen_zero(timer_name)) {
-        timer_name = "soft";
-    }
-
-    /* Caller ID Name */
-    if (switch_strlen_zero(caller_id_name)) {
-        caller_id_name = (char *) global_app_name;
-    }
-
-    /* Caller ID Number */
-    if (switch_strlen_zero(caller_id_number)) {
-        caller_id_number = "0000000000";
-    }
-
-    if (!pool) {
-        /* Setup a memory pool to use. */
-        if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
-            status = SWITCH_STATUS_TERM;
-            return NULL;
-        }
-    }
-
-    /* Create the conference object. */
-    if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-        status = SWITCH_STATUS_TERM;
-        return NULL;
-    }
-
-    /* initialize the conference object with settings from the specified profile */
-    conference->pool = pool;
-    conference->timer_name = switch_core_strdup(conference->pool, timer_name);
-    conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
-    conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
+		} else if (!strcasecmp(var, "kicked-sound")) {
+			kicked_sound = val;
+		} else if (!strcasecmp(var, "pin")) {
+			pin = val;
+		} else if (!strcasecmp(var, "pin-sound")) {
+			pin_sound = val;
+		} else if (!strcasecmp(var, "bad-pin-sound")) {
+			bad_pin_sound = val;
+		} else if (!strcasecmp(var, "energy-level")) {
+			energy_level = val;
+		} else if (!strcasecmp(var, "caller-id-name")) {
+			caller_id_name = val;
+		} else if (!strcasecmp(var, "caller-id-number")) {
+			caller_id_number = val;
+		} else if (!strcasecmp(var, "caller-controls")) {
+			caller_controls = val;
+		} else if (!strcasecmp(var, "sound-prefix")) {
+			sound_prefix = val;
+		} else if (!strcasecmp(var, "max-members")) {
+			errno = 0;			// sanity first
+			max_members = strtol(val, NULL, 0);	// base 0 lets 0x... for hex 0... for octal and base 10 otherwise through
+			if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
+				// a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound 
+				// stuff is added, see comments above
+				max_members = 0;	// set to 0 to disable max counts
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val);
+			}
+		} else if (!strcasecmp(var, "max-members-sound")) {
+			maxmember_sound = val;
+		} else if (!strcasecmp(var, "anounce-count")) {
+			errno = 0;			// safety first
+			anounce_count = strtol(val, NULL, 0);
+			if (errno == ERANGE || errno == EINVAL) {
+				anounce_count = 0;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "anounce-count is invalid, not anouncing member counts\n");
+			}
+		}
+	}
+
+	/* Set defaults and various paramaters */
+
+	/* Speed in hertz */
+	if (!switch_strlen_zero(rate_name)) {
+		uint32_t r = atoi(rate_name);
+		if (r) {
+			rate = r;
+		}
+	}
+
+	/* Packet Interval in milliseconds */
+	if (!switch_strlen_zero(interval_name)) {
+		uint32_t i = atoi(interval_name);
+		if (i) {
+			interval = i;
+		}
+	}
+
+	/* Timer module to use */
+	if (switch_strlen_zero(timer_name)) {
+		timer_name = "soft";
+	}
+
+	/* Caller ID Name */
+	if (switch_strlen_zero(caller_id_name)) {
+		caller_id_name = (char *) global_app_name;
+	}
+
+	/* Caller ID Number */
+	if (switch_strlen_zero(caller_id_number)) {
+		caller_id_number = "0000000000";
+	}
+
+	if (!pool) {
+		/* Setup a memory pool to use. */
+		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+			status = SWITCH_STATUS_TERM;
+			return NULL;
+		}
+	}
+
+	/* Create the conference object. */
+	if (!(conference = switch_core_alloc(pool, sizeof(*conference)))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+		status = SWITCH_STATUS_TERM;
+		return NULL;
+	}
+
+	/* initialize the conference object with settings from the specified profile */
+	conference->pool = pool;
+	conference->timer_name = switch_core_strdup(conference->pool, timer_name);
+	conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
+	conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
 
-    conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
-    conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
+	conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
+	conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
 
 	conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
 
 	if (member_flags) {
 		set_mflags(member_flags, &conference->mflags);
-	} 
+	}
+
+	if (sound_prefix) {
+		conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix);
+	}
+
+	if (!switch_strlen_zero(enter_sound)) {
+		conference->enter_sound = switch_core_strdup(conference->pool, enter_sound);
+	}
+
+	if (!switch_strlen_zero(exit_sound)) {
+		conference->exit_sound = switch_core_strdup(conference->pool, exit_sound);
+	}
+
+	if (!switch_strlen_zero(ack_sound)) {
+		conference->ack_sound = switch_core_strdup(conference->pool, ack_sound);
+	}
+
+	if (!switch_strlen_zero(nack_sound)) {
+		conference->nack_sound = switch_core_strdup(conference->pool, nack_sound);
+	}
+
+	if (!switch_strlen_zero(muted_sound)) {
+		conference->muted_sound = switch_core_strdup(conference->pool, muted_sound);
+	}
+
+	if (!switch_strlen_zero(unmuted_sound)) {
+		conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound);
+	}
+
+	if (!switch_strlen_zero(kicked_sound)) {
+		conference->kicked_sound = switch_core_strdup(conference->pool, kicked_sound);
+	}
+
+	if (!switch_strlen_zero(pin_sound)) {
+		conference->pin_sound = switch_core_strdup(conference->pool, pin_sound);
+	}
+
+	if (!switch_strlen_zero(bad_pin_sound)) {
+		conference->bad_pin_sound = switch_core_strdup(conference->pool, bad_pin_sound);
+	}
+
+	if (!switch_strlen_zero(pin)) {
+		conference->pin = switch_core_strdup(conference->pool, pin);
+	}
+
+	if (!switch_strlen_zero(alone_sound)) {
+		conference->alone_sound = switch_core_strdup(conference->pool, alone_sound);
+	}
+
+	if (!switch_strlen_zero(locked_sound)) {
+		conference->locked_sound = switch_core_strdup(conference->pool, locked_sound);
+	}
+
+	if (!switch_strlen_zero(is_locked_sound)) {
+		conference->is_locked_sound = switch_core_strdup(conference->pool, is_locked_sound);
+	}
+
+	if (!switch_strlen_zero(is_unlocked_sound)) {
+		conference->is_unlocked_sound = switch_core_strdup(conference->pool, is_unlocked_sound);
+	}
+
+	if (!switch_strlen_zero(energy_level)) {
+		conference->energy_level = atoi(energy_level);
+	}
+
+	if (!switch_strlen_zero(maxmember_sound)) {
+		conference->maxmember_sound = switch_core_strdup(conference->pool, maxmember_sound);
+	}
+	// its going to be 0 by default, set to a value otherwise so this should be safe
+	conference->max_members = max_members;
+	conference->anounce_count = anounce_count;
+
+	conference->name = switch_core_strdup(conference->pool, name);
+	if (domain) {
+		conference->domain = switch_core_strdup(conference->pool, domain);
+	} else {
+		conference->domain = "cluecon.com";
+	}
+	conference->rate = rate;
+	conference->interval = interval;
+	conference->dtmf_parser = NULL;
+
+	/* caller control configuration chores */
+	if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
+
+		/* if no controls, or default controls specified, install default */
+		if (caller_controls == NULL || *caller_controls == '\0' || strcasecmp(caller_controls, "default") == 0) {
+			status = conf_default_controls(conference);
+		} else if (strcasecmp(caller_controls, "none") != 0) {
+			/* try to build caller control if the group has been specified and != "none" */
+			switch_xml_t xml_controls = switch_xml_find_child(cfg.controls, "group", "name", caller_controls);
+			status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
 
-    if (sound_prefix) {
-        conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix);
-    }
-
-    if (!switch_strlen_zero(enter_sound)) {
-        conference->enter_sound = switch_core_strdup(conference->pool, enter_sound);
-    }
-
-    if (!switch_strlen_zero(exit_sound)) {
-        conference->exit_sound = switch_core_strdup(conference->pool, exit_sound);
-    }
-
-    if (!switch_strlen_zero(ack_sound)) {
-        conference->ack_sound = switch_core_strdup(conference->pool, ack_sound);
-    }
-
-    if (!switch_strlen_zero(nack_sound)) {
-        conference->nack_sound = switch_core_strdup(conference->pool, nack_sound);
-    }
-
-    if (!switch_strlen_zero(muted_sound)) {
-        conference->muted_sound = switch_core_strdup(conference->pool, muted_sound);
-    }
-
-    if (!switch_strlen_zero(unmuted_sound)) {
-        conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound);
-    }
-
-    if (!switch_strlen_zero(kicked_sound)) {
-        conference->kicked_sound = switch_core_strdup(conference->pool, kicked_sound);
-    }
-
-    if (!switch_strlen_zero(pin_sound)) {
-        conference->pin_sound = switch_core_strdup(conference->pool, pin_sound);
-    }
-
-    if (!switch_strlen_zero(bad_pin_sound)) {
-        conference->bad_pin_sound = switch_core_strdup(conference->pool, bad_pin_sound);
-    }
-
-    if (!switch_strlen_zero(pin)) {
-        conference->pin = switch_core_strdup(conference->pool, pin);
-    }
-
-    if (!switch_strlen_zero(alone_sound)) {
-        conference->alone_sound = switch_core_strdup(conference->pool, alone_sound);
-    } 
-
-    if (!switch_strlen_zero(locked_sound)) {
-        conference->locked_sound = switch_core_strdup(conference->pool, locked_sound);
-    }
-
-    if (!switch_strlen_zero(is_locked_sound)) {
-        conference->is_locked_sound = switch_core_strdup(conference->pool, is_locked_sound);
-    }
-
-    if (!switch_strlen_zero(is_unlocked_sound)) {
-        conference->is_unlocked_sound = switch_core_strdup(conference->pool, is_unlocked_sound);
-    }
-
-    if (!switch_strlen_zero(energy_level)) {
-        conference->energy_level = atoi(energy_level);
-    }
-
-    if (!switch_strlen_zero(maxmember_sound)) {
-        conference->maxmember_sound = switch_core_strdup(conference->pool, maxmember_sound);
-    }
-
-    // its going to be 0 by default, set to a value otherwise so this should be safe
-    conference->max_members = max_members;
-    conference->anounce_count = anounce_count;
-
-    conference->name = switch_core_strdup(conference->pool, name);
-    if (domain) {
-        conference->domain = switch_core_strdup(conference->pool, domain);
-    } else {
-        conference->domain = "cluecon.com";
-    }
-    conference->rate = rate;
-    conference->interval = interval;
-    conference->dtmf_parser = NULL;
-
-    /* caller control configuration chores */
-    if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
-
-        /* if no controls, or default controls specified, install default */
-        if (caller_controls == NULL || *caller_controls == '\0' || strcasecmp(caller_controls, "default") == 0) {
-            status = conf_default_controls(conference);
-        } else if (strcasecmp(caller_controls, "none") != 0) {
-            /* try to build caller control if the group has been specified and != "none" */
-            switch_xml_t xml_controls = switch_xml_find_child(cfg.controls, "group", "name", caller_controls);
-            status = conference_new_install_caller_controls_custom(conference, xml_controls, NULL);
-
-            if (status != SWITCH_STATUS_SUCCESS) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to install caller controls group '%s'\n", caller_controls);
-            }
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "no caller controls intalled.\n");
-        }
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate caller control digit parser.\n");
-    }
-
-    /* Activate the conference mutex for exclusivity */
-    switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool);
-    switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool);
-    switch_thread_rwlock_create(&conference->rwlock, conference->pool);
+			if (status != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to install caller controls group '%s'\n", caller_controls);
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "no caller controls intalled.\n");
+		}
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate caller control digit parser.\n");
+	}
+
+	/* Activate the conference mutex for exclusivity */
+	switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool);
+	switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool);
+	switch_thread_rwlock_create(&conference->rwlock, conference->pool);
 	switch_mutex_init(&conference->member_mutex, SWITCH_MUTEX_NESTED, conference->pool);
 
-    return conference;
+	return conference;
+}
+
+static void pres_event_handler(switch_event_t *event)
+{
+	char *to = switch_event_get_header(event, "to");
+	char *dup_to = NULL, *conf_name, *e;
+	conference_obj_t *conference;
+
+	if (!to || strncasecmp(to, "conf+", 5)) {
+		return;
+	}
+
+	if (!(dup_to = strdup(to))) {
+		return;
+	}
+
+	conf_name = dup_to + 5;
+
+	if ((e = strchr(conf_name, '@'))) {
+		*e = '\0';
+	}
+
+	if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+		switch_event_t *event;
+
+		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+			switch_event_fire(&event);
+		}
+	} else if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conf_name);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+		switch_event_fire(&event);
+	}
+
+	switch_safe_free(dup_to);
 }
 
-static void pres_event_handler(switch_event_t *event) 
-{ 
-    char *to = switch_event_get_header(event, "to"); 
-    char *dup_to = NULL, *conf_name, *e; 
-    conference_obj_t *conference; 
-
-    if (!to || strncasecmp(to, "conf+", 5)) { 
-        return; 
-    } 
-
-    if (!(dup_to = strdup(to))) { 
-        return; 
-    } 
-
-    conf_name = dup_to + 5; 
-
-    if ((e = strchr(conf_name, '@'))) { 
-        *e = '\0'; 
-    } 
-
-    if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) { 
-        switch_event_t *event; 
-
-        if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conference->name); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s"); 
-            switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-            switch_event_fire(&event); 
-        } 
-    } else if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", conf_name); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Idle"); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle"); 
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-        switch_event_fire(&event); 
-    } 
-
-    switch_safe_free(dup_to); 
-} 
- 
-static void send_presence(switch_event_types_t id) 
-{ 
-    switch_xml_t cxml, cfg, advertise, room; 
-
-    /* Open the config from the xml registry */ 
-    if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, "presence"))) { 
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name); 
-        goto done; 
-    } 
-
-    if ((advertise = switch_xml_child(cfg, "advertise"))) { 
-        for (room = switch_xml_child(advertise, "room"); room; room = room->next) { 
-            char *name = (char *) switch_xml_attr_soft(room, "name"); 
-            char *status = (char *) switch_xml_attr_soft(room, "status"); 
-            switch_event_t *event; 
-
-            if (name && switch_event_create(&event, id) == SWITCH_STATUS_SUCCESS) { 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", name); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", name); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status ? status : "Available"); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle"); 
-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); 
-                switch_event_fire(&event); 
-            } 
-        } 
-    } 
-
- done: 
-    /* Release the config registry handle */ 
-    if (cxml) { 
-        switch_xml_free(cxml); 
-        cxml = NULL; 
-    } 
-} 
+static void send_presence(switch_event_types_t id)
+{
+	switch_xml_t cxml, cfg, advertise, room;
+
+	/* Open the config from the xml registry */
+	if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, "presence"))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+		goto done;
+	}
+
+	if ((advertise = switch_xml_child(cfg, "advertise"))) {
+		for (room = switch_xml_child(advertise, "room"); room; room = room->next) {
+			char *name = (char *) switch_xml_attr_soft(room, "name");
+			char *status = (char *) switch_xml_attr_soft(room, "status");
+			switch_event_t *event;
+
+			if (name && switch_event_create(&event, id) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", name);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", status ? status : "Available");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+				switch_event_fire(&event);
+			}
+		}
+	}
+
+  done:
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+		cxml = NULL;
+	}
+}
 
 /* Called by FreeSWITCH when the module loads */
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-    uint32_t i;
-    size_t nl, ol = 0;
-    char *p = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-
-    memset(&globals, 0, sizeof(globals));
-
-    /* build api interface help ".syntax" field string */
-    p = strdup("");
-    for (i = 0; i<CONFFUNCAPISIZE; i++) {
-        nl = strlen(conf_api_sub_commands[i].psyntax) + 4;
-        if (p != NULL) {
-            ol = strlen(p);
-        }
-        p = realloc(p, ol+nl);
-        if (p != NULL) {
-            strcat(p, "\t\t");
-            strcat(p, conf_api_sub_commands[i].psyntax);
-            if (i < CONFFUNCAPISIZE-1) {
-                strcat(p, "\n");
-            }
-        }
-		
-    }
-    /* install api interface help ".syntax" field string */
-    if (p != NULL) {
-        conf_api_interface.syntax = p;
-    }
-
-    /* Connect my internal structure to the blank pointer passed to me */
-    *module_interface = &conference_module_interface;
-
-    /* create/register custom event message type */
-    if (switch_event_reserve_subclass(CONF_EVENT_MAINT) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", CONF_EVENT_MAINT);
-        return SWITCH_STATUS_TERM;
-    }
-
-    /* Setup the pool */
-    if (switch_core_new_memory_pool(&globals.conference_pool) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no conference pool\n");
-        return SWITCH_STATUS_TERM;
-    }
-
-    /* Setup a hash to store conferences by name */
-    switch_core_hash_init(&globals.conference_hash, globals.conference_pool);
-    switch_mutex_init(&globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
-    switch_mutex_init(&globals.id_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
-    switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
-
-    /* Subscribe to presence request events */
-    if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
-        return SWITCH_STATUS_GENERR;
-    }
-
-    send_presence(SWITCH_EVENT_PRESENCE_IN);
-
-    globals.running = 1;
-    /* indicate that the module should continue to be loaded */
-    return status;
+	uint32_t i;
+	size_t nl, ol = 0;
+	char *p = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+	memset(&globals, 0, sizeof(globals));
+
+	/* build api interface help ".syntax" field string */
+	p = strdup("");
+	for (i = 0; i < CONFFUNCAPISIZE; i++) {
+		nl = strlen(conf_api_sub_commands[i].psyntax) + 4;
+		if (p != NULL) {
+			ol = strlen(p);
+		}
+		p = realloc(p, ol + nl);
+		if (p != NULL) {
+			strcat(p, "\t\t");
+			strcat(p, conf_api_sub_commands[i].psyntax);
+			if (i < CONFFUNCAPISIZE - 1) {
+				strcat(p, "\n");
+			}
+		}
+
+	}
+	/* install api interface help ".syntax" field string */
+	if (p != NULL) {
+		conf_api_interface.syntax = p;
+	}
+
+	/* Connect my internal structure to the blank pointer passed to me */
+	*module_interface = &conference_module_interface;
+
+	/* create/register custom event message type */
+	if (switch_event_reserve_subclass(CONF_EVENT_MAINT) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", CONF_EVENT_MAINT);
+		return SWITCH_STATUS_TERM;
+	}
+
+	/* Setup the pool */
+	if (switch_core_new_memory_pool(&globals.conference_pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no conference pool\n");
+		return SWITCH_STATUS_TERM;
+	}
+
+	/* Setup a hash to store conferences by name */
+	switch_core_hash_init(&globals.conference_hash, globals.conference_pool);
+	switch_mutex_init(&globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+	switch_mutex_init(&globals.id_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+	switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
+
+	/* Subscribe to presence request events */
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
+	send_presence(SWITCH_EVENT_PRESENCE_IN);
+
+	globals.running = 1;
+	/* indicate that the module should continue to be loaded */
+	return status;
 }
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
-    if (globals.running) {
+	if (globals.running) {
 
-        /* signal all threads to shutdown */
-        globals.running = 0;
+		/* signal all threads to shutdown */
+		globals.running = 0;
 
-        /* wait for all threads */
-        while (globals.threads) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for %d threads\n", globals.threads);
-            switch_yield(100000);
-        }
-
-        /* free api interface help ".syntax" field string */
-        if (conf_api_interface.syntax != NULL) {
-            free((char *)conf_api_interface.syntax);
-        }
-    }
+		/* wait for all threads */
+		while (globals.threads) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for %d threads\n", globals.threads);
+			switch_yield(100000);
+		}
+
+		/* free api interface help ".syntax" field string */
+		if (conf_api_interface.syntax != NULL) {
+			free((char *) conf_api_interface.syntax);
+		}
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 /* For Emacs:

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c	Fri Mar 30 12:19:18 2007
@@ -43,7 +43,8 @@
 	int argc;
 	char *lbuf = NULL;
 
-	if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+	if (data && (lbuf = switch_core_session_strdup(session, data))
+		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		if (!strcasecmp(argv[0], "grammar") && argc >= 1) {
 			switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
 		} else if (!strcasecmp(argv[0], "nogrammar")) {
@@ -60,14 +61,14 @@
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", detect_speech_application_interface.syntax);
 	}
-	
+
 }
 
 static void ring_ready_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_ring_ready(channel);
 }
 
@@ -84,7 +85,7 @@
 static void transfer_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
@@ -99,15 +100,15 @@
 static void sched_transfer_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata;
-	
+
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
 			time_t when;
 
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
@@ -122,7 +123,7 @@
 static void sched_hangup_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[5] = {0};
+	char *argv[5] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
@@ -132,11 +133,11 @@
 			switch_bool_t bleg = SWITCH_FALSE;
 
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
-			
+
 			if (argv[1]) {
 				cause = switch_channel_str2cause(argv[1]);
 			}
@@ -156,20 +157,20 @@
 static void sched_broadcast_function(switch_core_session_t *session, char *data)
 {
 	int argc;
-	char *argv[6] = {0};
+	char *argv[6] = { 0 };
 	char *mydata;
 
 	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
 			time_t when;
 			switch_media_flag_t flags = SMF_NONE;
-			
+
 			if (*argv[0] == '+') {
-				when = time (NULL) + atol(argv[0] + 1);
+				when = time(NULL) + atol(argv[0] + 1);
 			} else {
 				when = atol(argv[0]);
 			}
-			
+
 			if (argv[2]) {
 				if (!strcmp(argv[2], "both")) {
 					flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
@@ -207,26 +208,26 @@
 
 static void phrase_function(switch_core_session_t *session, char *data)
 {
-    switch_channel_t *channel;
-    char *mydata = NULL;
+	switch_channel_t *channel;
+	char *mydata = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if ((mydata = switch_core_session_strdup(session, data))) {
+		char *lang;
+		char *macro = mydata;
+		char *mdata = NULL;
+
+		if ((mdata = strchr(macro, ','))) {
+			*mdata++ = '\0';
+		}
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
-    
-    if ((mydata = switch_core_session_strdup(session, data))) {
-        char *lang;
-        char *macro = mydata;
-        char *mdata = NULL;
-
-        if ((mdata = strchr(macro, ','))) {
-            *mdata++ = '\0';
-        }
-
-        lang = switch_channel_get_variable(channel, "language");
-        
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
-        switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
-    }
+		lang = switch_channel_get_variable(channel, "language");
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
+		switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
+	}
 
 }
 
@@ -234,14 +235,14 @@
 static void hangup_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    if (!switch_strlen_zero((char *) data)) {
-        cause = switch_channel_str2cause((char *) data);
-    }
+	if (!switch_strlen_zero((char *) data)) {
+		cause = switch_channel_str2cause((char *) data);
+	}
 
 	switch_channel_hangup(channel, cause);
 }
@@ -251,7 +252,7 @@
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_answer(channel);
 }
 
@@ -260,18 +261,18 @@
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 	switch_channel_pre_answer(channel);
 }
 
 static void redirect_function(switch_core_session_t *session, char *data)
 {
-    switch_core_session_message_t msg = {0};
+	switch_core_session_message_t msg = { 0 };
 
-    /* Tell the channel to redirect */
+	/* Tell the channel to redirect */
 	msg.from = __FILE__;
 	msg.string_arg = data;
-    msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
+	msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
 	switch_core_session_receive_message(session, &msg);
 
 }
@@ -283,7 +284,7 @@
 	char *var, *val = NULL;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -293,11 +294,11 @@
 
 		if (val) {
 			*val++ = '\0';
-            if (switch_strlen_zero(val)) {
-                val = NULL;
-            }
+			if (switch_strlen_zero(val)) {
+				val = NULL;
+			}
 		}
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
 		switch_channel_set_variable(channel, var, val);
 	}
@@ -309,7 +310,7 @@
 	char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -320,11 +321,11 @@
 
 		if (val) {
 			*val++ = '\0';
-            if (switch_strlen_zero(val)) {
-                val = NULL;
-            }
+			if (switch_strlen_zero(val)) {
+				val = NULL;
+			}
 		}
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
 		switch_channel_set_variable(channel, var, val);
 
@@ -346,7 +347,7 @@
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -359,43 +360,43 @@
 static void log_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    char *level, *log_str;
+	char *level, *log_str;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
+
+	if (data && (level = strdup(data))) {
+		switch_event_types_t etype = SWITCH_LOG_DEBUG;
+
+		if ((log_str = strchr(level, ' '))) {
+			*log_str++ = '\0';
+			switch_name_event(level, &etype);
+		} else {
+			log_str = level;
+		}
 
-    if (data && (level = strdup(data))) {
-        switch_event_types_t etype = SWITCH_LOG_DEBUG;
-        
-        if ((log_str = strchr(level, ' '))) {
-            *log_str++ = '\0';
-            switch_name_event(level, &etype);
-        } else {
-            log_str = level;
-        }
-
-        switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
-        switch_safe_free(level);
-    }
+		switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
+		switch_safe_free(level);
+	}
 }
 
 
 static void info_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
-    switch_event_t *event;
-    char *buf;
+	switch_event_t *event;
+	char *buf;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
+
+	if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		switch_event_serialize(event, &buf);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
+		switch_event_destroy(&event);
+	}
 
-    if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-        switch_channel_event_set_data(channel, event);
-        switch_event_serialize(event, &buf);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
-        switch_event_destroy(&event);
-    }
-    
 }
 
 static void privacy_function(switch_core_session_t *session, char *data)
@@ -405,8 +406,8 @@
 	char *arg;
 
 	channel = switch_core_session_get_channel(session);
-    	assert(channel != NULL);		
-	
+	assert(channel != NULL);
+
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	if (switch_strlen_zero(data)) {
@@ -416,7 +417,7 @@
 
 		switch_set_flag(caller_profile, SWITCH_CPF_SCREEN);
 
-		if(!strcasecmp(arg, "no")) {
+		if (!strcasecmp(arg, "no")) {
 			switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
 			switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
 		} else if (!strcasecmp(arg, "yes")) {
@@ -440,7 +441,8 @@
 	int argc;
 	char *lbuf;
 
-	if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
+	if (data && (lbuf = switch_core_session_strdup(session, data))
+		&& (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
 		switch_size_t retsize;
 		switch_time_exp_t tm;
 		char date[80] = "";
@@ -459,26 +461,26 @@
 
 static switch_status_t strepoch_api_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-    switch_time_t out;
-    
-    if (switch_strlen_zero(data)) {
-        out = switch_time_now();
-    } else {
-        out = switch_str_time(data);
-    }
+	switch_time_t out;
 
-    stream->write_function(stream, "%d", (uint32_t)((out) / (int64_t)(1000000)) );
+	if (switch_strlen_zero(data)) {
+		out = switch_time_now();
+	} else {
+		out = switch_str_time(data);
+	}
+
+	stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000)));
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	
+
 	switch_size_t retsize;
 	switch_time_exp_t tm;
 	char date[80] = "";
-	
+
 	switch_time_exp_lt(&tm, switch_time_now());
 	switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
 	stream->write_function(stream, "%s", date);
@@ -493,14 +495,15 @@
 	int argc = 0;
 	switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
 
-	if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
+	if (fmt && (lbuf = strdup(fmt))
+		&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
 		if (!strcasecmp(argv[0], "out")) {
 			type = SWITCH_EVENT_PRESENCE_OUT;
 		} else if (argc != 4) {
 			stream->write_function(stream, "Invalid");
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "dp");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
@@ -527,9 +530,10 @@
 	char *lbuf, *argv[4];
 	int argc = 0;
 
-	if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
+	if (fmt && (lbuf = strdup(fmt))
+		&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
 		switch_chat_interface_t *ci;
-		
+
 		if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
 			ci->chat_send("dp", argv[1], argv[2], "", argv[3], "");
 			stream->write_function(stream, "Sent");
@@ -539,19 +543,19 @@
 	} else {
 		stream->write_function(stream, "Invalid");
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
 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;
 
 	if (param != NULL) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n",param);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n", param);
 	}
 
 	return action;
@@ -563,7 +567,7 @@
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char *params;
 
-	if (channel && data && (params = switch_core_session_strdup(session,data))) {
+	if (channel && data && (params = switch_core_session_strdup(session, data))) {
 		switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
 
 		// Open the config from the xml registry
@@ -577,16 +581,15 @@
 					switch_ivr_menu_t *menu_stack = NULL;
 
 					// build a menu tree and execute it
-					if (switch_ivr_menu_stack_xml_init(&xml_ctx,NULL) == SWITCH_STATUS_SUCCESS
+					if (switch_ivr_menu_stack_xml_init(&xml_ctx, NULL) == SWITCH_STATUS_SUCCESS
 #ifdef _TEST_CALLBACK_
 						&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS
 #endif
-						&& switch_ivr_menu_stack_xml_build(xml_ctx,&menu_stack,xml_menus,xml_menu) == SWITCH_STATUS_SUCCESS)
-					{
+						&& switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) {
 						switch_xml_free(cxml);
 						cxml = NULL;
 						switch_channel_pre_answer(channel);
-						switch_ivr_menu_execute(session,menu_stack,params,NULL);
+						switch_ivr_menu_execute(session, menu_stack, params, NULL);
 						switch_ivr_menu_stack_free(menu_stack);
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
@@ -670,7 +673,7 @@
 
 static const switch_application_interface_t queuedtmf_application_interface = {
 	/*.interface_name */ "queue_dtmf",
-	/*.application_function */ queue_dtmf_function,	
+	/*.application_function */ queue_dtmf_function,
 	/* long_desc */ "Queue dtmf to be sent from a session",
 	/* short_desc */ "Queue dtmf to be sent",
 	/* syntax */ "<dtmf_data>",
@@ -680,7 +683,7 @@
 
 static const switch_application_interface_t redirect_application_interface = {
 	/*.interface_name */ "redirect",
-	/*.application_function */ redirect_function,	
+	/*.application_function */ redirect_function,
 	/* long_desc */ "Send a redirect message to a session.",
 	/* short_desc */ "Send session redirect",
 	/* syntax */ "<redirect_data>",
@@ -690,7 +693,7 @@
 
 static const switch_application_interface_t ivr_application_interface = {
 	/*.interface_name */ "ivr",
-	/*.application_function */ ivr_application_function,	
+	/*.application_function */ ivr_application_function,
 	/* long_desc */ "Run an ivr menu.",
 	/* short_desc */ "Run an ivr menu",
 	/* syntax */ "<menu_name>",
@@ -700,7 +703,7 @@
 
 static const switch_application_interface_t detect_speech_application_interface = {
 	/*.interface_name */ "detect_speech",
-	/*.application_function */ detect_speech_function,	
+	/*.application_function */ detect_speech_function,
 	/* long_desc */ "Detect speech on a channel.",
 	/* short_desc */ "Detect speech",
 	/* syntax */ "<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR pause OR resume",
@@ -777,7 +780,6 @@
 	/* syntax */ "[<cause>]",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &log_application_interface
-
 };
 
 static const switch_application_interface_t answer_application_interface = {
@@ -788,7 +790,6 @@
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &hangup_application_interface
-
 };
 
 static const switch_application_interface_t pre_answer_application_interface = {
@@ -799,7 +800,6 @@
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &answer_application_interface
-
 };
 
 static const switch_application_interface_t eval_application_interface = {
@@ -810,7 +810,6 @@
 	/* syntax */ "",
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &pre_answer_application_interface
-
 };
 
 static const switch_application_interface_t phrase_application_interface = {
@@ -821,7 +820,6 @@
 	/* syntax */ "<macro_name>,<data>",
 	/* flags */ SAF_NONE,
 	/*.next */ &eval_application_interface
-
 };
 
 static const switch_application_interface_t strftime_application_interface = {
@@ -832,13 +830,13 @@
 	/* syntax */ NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
 	/*.next */ &phrase_application_interface
-
 };
 
 static const switch_application_interface_t sleep_application_interface = {
 	/*.interface_name */ "sleep",
 	/*.application_function */ sleep_function,
-	/* long_desc */ "Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
+	/* long_desc */
+	"Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
 	/* short_desc */ "Pause a channel",
 	/* syntax */ "<pausemilliseconds>",
 	/* flags */ SAF_NONE,

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_echo/mod_echo.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_echo/mod_echo.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_echo/mod_echo.c	Fri Mar 30 12:19:18 2007
@@ -38,7 +38,7 @@
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-	assert(channel != NULL);	
+	assert(channel != NULL);
 
 	switch_channel_answer(channel);
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/mod_enum.c	Fri Mar 30 12:19:18 2007
@@ -48,10 +48,10 @@
 typedef struct enum_record enum_record_t;
 
 struct query {
-	const char *name;		/* original query string */
+	const char *name;			/* original query string */
 	char *number;
 	unsigned char dn[DNS_MAXDN];
-	enum dns_type qtyp;		/* type of the query */
+	enum dns_type qtyp;			/* type of the query */
 	enum_record_t *results;
 };
 typedef struct query enum_query_t;
@@ -77,7 +77,7 @@
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root)
 
 
-static void add_route(char *service, char *regex, char *replace)
+	 static void add_route(char *service, char *regex, char *replace)
 {
 	enum_route_t *route, *rp;
 
@@ -86,11 +86,11 @@
 	}
 
 	memset(route, 0, sizeof(*route));
-	
+
 	route->service = strdup(service);
 	route->regex = strdup(regex);
 	route->replace = strdup(replace);
-	
+
 	if (!globals.route_order) {
 		globals.route_order = route;
 	} else {
@@ -107,8 +107,8 @@
 static switch_status_t load_config(void)
 {
 	char *cf = "enum.conf";
-    switch_xml_t cfg, xml = NULL, param, settings, route, routes;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_xml_t cfg, xml = NULL, param, settings, route, routes;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	memset(&globals, 0, sizeof(globals));
 	if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) {
@@ -119,39 +119,39 @@
 
 	switch_core_hash_init(&globals.routes, globals.pool);
 
-    if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-        status = SWITCH_STATUS_FALSE;
-        goto done;
-    }
-
-    if ((settings = switch_xml_child(cfg, "settings"))) {
-        for (param = switch_xml_child(settings, "param"); param; param = param->next) {
-            char *var = (char *) switch_xml_attr_soft(param, "name");
-            char *val = (char *) switch_xml_attr_soft(param, "value");
-            if (!strcasecmp(var, "default-root")) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
+
+	if ((settings = switch_xml_child(cfg, "settings"))) {
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+			if (!strcasecmp(var, "default-root")) {
 				set_global_root(val);
-            } else if (!strcasecmp(var, "log-level-trace")) {
-				
-            }
-        }
-    }
-
-    if ((routes = switch_xml_child(cfg, "routes"))) {
-        for (route = switch_xml_child(routes, "route"); route; route = route->next) {
-            char *service = (char *) switch_xml_attr_soft(route, "service");
-            char *regex = (char *) switch_xml_attr_soft(route, "regex");
-            char *replace = (char *) switch_xml_attr_soft(route, "replace");
+			} else if (!strcasecmp(var, "log-level-trace")) {
+
+			}
+		}
+	}
+
+	if ((routes = switch_xml_child(cfg, "routes"))) {
+		for (route = switch_xml_child(routes, "route"); route; route = route->next) {
+			char *service = (char *) switch_xml_attr_soft(route, "service");
+			char *regex = (char *) switch_xml_attr_soft(route, "regex");
+			char *replace = (char *) switch_xml_attr_soft(route, "replace");
 
 			if (service && regex && replace) {
 				add_route(service, regex, replace);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Route!\n");
 			}
-        }
-    }
-	
- done:
+		}
+	}
+
+  done:
 
 	if (xml) {
 		switch_xml_free(xml);
@@ -168,20 +168,20 @@
 
 static char *reverse_number(char *in, char *root)
 {
-    switch_size_t len;
-    char *out = NULL;
-    char *y,*z;
-
-    if (!(in && root)) {
-        return NULL;
-    }
-
-    len = (strlen(in) * 2) + strlen(root) + 1;
-    if ((out = malloc(len))) {
-        memset(out, 0, len);
+	switch_size_t len;
+	char *out = NULL;
+	char *y, *z;
+
+	if (!(in && root)) {
+		return NULL;
+	}
 
-        z = out;
-        for(y = in + (strlen(in) - 1); y; y--) {
+	len = (strlen(in) * 2) + strlen(root) + 1;
+	if ((out = malloc(len))) {
+		memset(out, 0, len);
+
+		z = out;
+		for (y = in + (strlen(in) - 1); y; y--) {
 			if (*y > 47 && *y < 58) {
 				*z++ = *y;
 				*z++ = '.';
@@ -189,21 +189,22 @@
 			if (y == in) {
 				break;
 			}
-        }
-        strcat(z, root);
-    }
+		}
+		strcat(z, root);
+	}
 
 	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",
+	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));
 }
 
 
-static void add_result(enum_query_t *q, int order, int preference, char *service, char *route)
+static void add_result(enum_query_t * q, int order, int preference, char *service, char *route)
 {
 	enum_record_t *new_result, *rp, *prev = NULL;
 
@@ -213,12 +214,12 @@
 	}
 
 	memset(new_result, 0, sizeof(*new_result));
-	
+
 	new_result->order = order;
 	new_result->preference = preference;
 	new_result->service = strdup(service);
 	new_result->route = strdup(route);
-	
+
 
 	if (!q->results) {
 		q->results = new_result;
@@ -227,12 +228,12 @@
 
 	rp = q->results;
 
-	while(rp && strcmp(rp->service, new_result->service)) {
+	while (rp && strcmp(rp->service, new_result->service)) {
 		prev = rp;
 		rp = rp->next;
 	}
 
-	while(rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
+	while (rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
 		prev = rp;
 		rp = rp->next;
 	}
@@ -241,7 +242,7 @@
 		prev = rp;
 		rp = rp->next;
 	}
-	
+
 	if (prev) {
 		new_result->next = rp;
 		prev->next = new_result;
@@ -252,11 +253,11 @@
 }
 
 
-static void free_results(enum_record_t **results) 
+static void free_results(enum_record_t ** results)
 {
 	enum_record_t *fp, *rp;
 
-	for(rp = *results; rp;) {
+	for (rp = *results; rp;) {
 		fp = rp;
 		rp = rp->next;
 		switch_safe_free(fp->service);
@@ -266,7 +267,8 @@
 	*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;
 	const unsigned char *dptr = rr->dnsrr_dptr;
@@ -282,25 +284,26 @@
 	char *regex = NULL;
 	char *replace = NULL;
 	int argc = 0;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int leap;
 
-	switch(rr->dnsrr_typ) {
+	switch (rr->dnsrr_typ) {
 
-	case DNS_T_NAPTR:	/* prio weight port targetDN */
+	case DNS_T_NAPTR:			/* prio weight port targetDN */
 		c = dptr;
 		c += 2 + 2 + 2;
-		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
+		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend)
+			goto xperr;
 		c = dptr;
-		
+
 		leap = *dn;
-		nme = (char *)dn+1;
+		nme = (char *) dn + 1;
 
-		order = dns_get16(c+0);
-		preference = dns_get16(c+2);
-		flags = (char) dns_get16(c+4);		
+		order = dns_get16(c + 0);
+		preference = dns_get16(c + 2);
+		flags = (char) dns_get16(c + 4);
 
-		if ((ptr = nme+leap)) {
+		if ((ptr = nme + leap)) {
 			service = nme;
 			*ptr++ = '\0';
 			argc = switch_separate_string(ptr, '!', argv, (sizeof(argv) / sizeof(argv[0])));
@@ -308,7 +311,7 @@
 			replace = argv[2];
 		}
 
-		for(ptr = replace; ptr && *ptr; ptr++) {
+		for (ptr = replace; ptr && *ptr; ptr++) {
 			if (*ptr == '\\') {
 				*ptr = '$';
 			}
@@ -332,7 +335,7 @@
 					uri = replace;
 				}
 
-				if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))){
+				if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))) {
 					switch_regex_safe_free(re);
 					if ((proceed = switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 						if (strchr(route->regex, '(')) {
@@ -343,7 +346,7 @@
 						}
 					}
 				}
-				
+
 				add_result(q, order, preference, service, uri);
 			}
 
@@ -358,12 +361,13 @@
 
 	return;
 
- xperr:
+  xperr:
 	//printf("<parse error>\n");
 	return;
 }
 
-static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
+static void dnscb(struct dns_ctx *ctx, void *result, void *data)
+{
 	int r = dns_status(ctx);
 	enum_query_t *q = data;
 	struct dns_parse p;
@@ -375,25 +379,24 @@
 		dnserror(q, r);
 		return;
 	}
-	pkt = result; end = pkt + r; cur = dns_payload(pkt);
+	pkt = result;
+	end = pkt + r;
+	cur = dns_payload(pkt);
 	dns_getdn(pkt, &cur, end, dn, sizeof(dn));
 	dns_initparse(&p, NULL, pkt, cur, end);
 	p.dnsp_qcls = p.dnsp_qtyp = 0;
 	qdn = dn;
 	nrr = 0;
-	while((r = dns_nextrr(&p, &rr)) > 0) {
-		if (!dns_dnequal(qdn, rr.dnsrr_dn)) continue;
-		if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) &&
-			(q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
+	while ((r = dns_nextrr(&p, &rr)) > 0) {
+		if (!dns_dnequal(qdn, rr.dnsrr_dn))
+			continue;
+		if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) && (q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
 			++nrr;
 		else if (rr.dnsrr_typ == DNS_T_CNAME && !nrr) {
-			if (dns_getdn(pkt, &rr.dnsrr_dptr, end,
-						  p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 ||
-				rr.dnsrr_dptr != rr.dnsrr_dend) {
+			if (dns_getdn(pkt, &rr.dnsrr_dptr, end, p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 || rr.dnsrr_dptr != rr.dnsrr_dend) {
 				r = DNS_E_PROTOCOL;
 				break;
-			}
-			else {
+			} else {
 				qdn = p.dnsp_dnbuf;
 			}
 		}
@@ -409,28 +412,28 @@
 	dns_rewind(&p, NULL);
 	p.dnsp_qtyp = q->qtyp;
 	p.dnsp_qcls = qcls;
-	while(dns_nextrr(&p, &rr)) {
+	while (dns_nextrr(&p, &rr)) {
 		parse_rr(&p, q, &rr);
 	}
-  
+
 	free(result);
 }
 
 
-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;
+	switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
 	char *name = NULL;
-	enum_query_t query = {0};
+	enum_query_t query = { 0 };
 	enum dns_type l_qtyp = DNS_T_NAPTR;
 	int i = 0, abs = 0;
-	dns_socket fd = (dns_socket)-1;
+	dns_socket fd = (dns_socket) - 1;
 	fd_set fds;
-	struct timeval tv = {0};
+	struct timeval tv = { 0 };
 	time_t now = 0;
 	struct dns_ctx *nctx = NULL;
 	char *num, *mnum = NULL;
-	
+
 	if (*in != '+') {
 		mnum = switch_mprintf("+%s", in);
 		num = mnum;
@@ -458,7 +461,7 @@
 		goto done;
 	}
 
-	dns_ptodn(name, (unsigned int)strlen(name), query.dn, sizeof(query.dn), &abs);
+	dns_ptodn(name, (unsigned int) strlen(name), query.dn, sizeof(query.dn), &abs);
 	query.name = name;
 	query.number = num;
 	query.qtyp = l_qtyp;
@@ -466,7 +469,7 @@
 	if (abs) {
 		abs = DNS_NOSRCH;
 	}
-	
+
 	if (!dns_submit_dn(nctx, query.dn, qcls, l_qtyp, abs, 0, dnscb, &query)) {
 		dnserror(&query, dns_status(nctx));
 	}
@@ -474,7 +477,7 @@
 	FD_ZERO(&fds);
 	now = 0;
 
-	while((i = dns_timeouts(nctx, -1, now)) > 0) {
+	while ((i = dns_timeouts(nctx, -1, now)) > 0) {
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable: 4389 4127)
@@ -485,9 +488,10 @@
 #endif
 		tv.tv_sec = i;
 		tv.tv_usec = 0;
-		i = select((int)(fd+1), &fds, 0, 0, &tv);
+		i = select((int) (fd + 1), &fds, 0, 0, &tv);
 		now = time(NULL);
-		if (i > 0) dns_ioevent(nctx, now);
+		if (i > 0)
+			dns_ioevent(nctx, now);
 	}
 
 	if (!query.results) {
@@ -497,17 +501,17 @@
 	*results = query.results;
 	query.results = NULL;
 
- done:
+  done:
 
 	if (fd > -1) {
 		closesocket(fd);
-		fd = (dns_socket)-1;
+		fd = (dns_socket) - 1;
 	}
 
 	if (nctx) {
 		dns_free(nctx);
 	}
-	
+
 	switch_safe_free(name);
 	switch_safe_free(mnum);
 
@@ -524,34 +528,34 @@
 	enum_route_t *rtp;
 	char *dp = (char *) arg;
 
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ENUM Lookup on %s\n", caller_profile->destination_number);
 
 	if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) == SWITCH_STATUS_SUCCESS) {
 		if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-			free_results(&results);	
+			free_results(&results);
 			return NULL;
 		}
 		switch_channel_set_variable(channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
-		
-		for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-			for(rp = results; rp; rp = rp->next) {
+
+		for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+			for (rp = results; rp; rp = rp->next) {
 				if (!strcmp(rtp->service, rp->service)) {
-					switch_caller_extension_add_application(session, extension, "bridge", rp->route);					
+					switch_caller_extension_add_application(session, extension, "bridge", rp->route);
 				}
 			}
 		}
 
-		free_results(&results);	
+		free_results(&results);
 	}
 
 	if (extension) {
-        switch_channel_set_state(channel, CS_EXECUTE);
-    }
+		switch_channel_set_state(channel, CS_EXECUTE);
+	}
 
 	return extension;
 
@@ -560,7 +564,7 @@
 static void enum_app_function(switch_core_session_t *session, char *data)
 {
 	int argc = 0;
-    char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	char *mydata = NULL;
 	char *dest = NULL, *root = NULL;
 	enum_record_t *results, *rp;
@@ -575,12 +579,12 @@
 	assert(channel != NULL);
 
 	if (!(mydata = switch_core_session_strdup(session, data))) {
-        return;
-    }
+		return;
+	}
 
-    if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		dest = argv[0];
-        root = argv[1] ? argv[1] : globals.root;
+		root = argv[1] ? argv[1] : globals.root;
 		if (enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
 			switch_hash_index_t *hi;
 			void *vval;
@@ -593,8 +597,8 @@
 				}
 			}
 
-			for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-				for(rp = results; rp; rp = rp->next) {
+			for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+				for (rp = results; rp; rp = rp->next) {
 					if (!strcmp(rtp->service, rp->service)) {
 						snprintf(vbuf, sizeof(vbuf), "enum_route_%d", cnt++);
 						switch_channel_set_variable(channel, vbuf, rp->route);
@@ -608,19 +612,19 @@
 			}
 			snprintf(vbuf, sizeof(vbuf), "%d", cnt);
 			switch_channel_set_variable(channel, "enum_route_count", vbuf);
-			*(rbuf+strlen(rbuf)-1) = '\0';
+			*(rbuf + strlen(rbuf) - 1) = '\0';
 			switch_channel_set_variable(channel, "enum_auto_route", rbuf);
-			free_results(&results);	
+			free_results(&results);
 		}
 	}
-	
+
 }
 
 static switch_status_t enum_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 
 	int argc = 0;
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	enum_record_t *results, *rp;
 	char *mydata = NULL;
 	char *dest = NULL, *root = NULL;
@@ -639,35 +643,33 @@
 	if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		dest = argv[0];
 		root = argv[1] ? argv[1] : globals.root;
-		
+
 		if (!enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
 			stream->write_function(stream, "No Match!\n");
 			return SWITCH_STATUS_SUCCESS;
 		}
-		
+
 		stream->write_function(stream,
 							   "\nOffered Routes:\n"
-							   "Order\tPref\tService   \tRoute\n"
-							   "==============================================================================\n");
+							   "Order\tPref\tService   \tRoute\n" "==============================================================================\n");
 
-		for(rp = results; rp; rp = rp->next) {
+		for (rp = results; rp; rp = rp->next) {
 			stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
 		}
-	
+
 
 		stream->write_function(stream,
 							   "\nSupported Routes:\n"
-							   "Order\tPref\tService   \tRoute\n"
-							   "==============================================================================\n");
+							   "Order\tPref\tService   \tRoute\n" "==============================================================================\n");
 
-		for(rtp = globals.route_order; rtp; rtp = rtp->next) {
-			for(rp = results; rp; rp = rp->next) {
+		for (rtp = globals.route_order; rtp; rtp = rtp->next) {
+			for (rp = results; rp; rp = rp->next) {
 				if (!strcmp(rtp->service, rp->service)) {
 					stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
 				}
 			}
 		}
-		
+
 		free_results(&results);
 	} else {
 		stream->write_function(stream, "Invalid Input!\n");
@@ -678,14 +680,14 @@
 
 
 static const switch_dialplan_interface_t enum_dialplan_interface = {
-    /*.interface_name = */ "enum",
-    /*.hunt_function = */ enum_dialplan_hunt
-    /*.next = NULL */
+	/*.interface_name = */ "enum",
+	/*.hunt_function = */ enum_dialplan_hunt
+		/*.next = NULL */
 };
 
 static const switch_application_interface_t enum_application_interface = {
 	/*.interface_name */ "enum",
-	/*.application_function */ enum_app_function,	
+	/*.application_function */ enum_app_function,
 	/* long_desc */ "Perform an ENUM lookup",
 	/* short_desc */ "Perform an ENUM lookup",
 	/* syntax */ "<number> [<root>]",
@@ -729,5 +731,3 @@
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
-
-

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c	Fri Mar 30 12:19:18 2007
@@ -42,13 +42,13 @@
 static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-	
-		switch_copy_string((char *)buf, dtmf, buflen);
-		return SWITCH_STATUS_BREAK;
-	}
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+			switch_copy_string((char *) buf, dtmf, buflen);
+			return SWITCH_STATUS_BREAK;
+		}
 		break;
 	default:
 		break;
@@ -72,9 +72,8 @@
 	for (team = switch_xml_child(f1, "team"); team; team = team->next) {
 		teamname = switch_xml_attr_soft(team, "name");
 		for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
-							  "%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
-							  switch_xml_child(driver, "points")->txt);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+							  "%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname, switch_xml_child(driver, "points")->txt);
 		}
 	}
 	switch_xml_free(f1);
@@ -84,7 +83,7 @@
 static void ivr_application_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	char *params = switch_core_session_strdup(session,data);
+	char *params = switch_core_session_strdup(session, data);
 
 	if (channel != NULL && params != NULL) {
 		switch_ivr_menu_t *menu = NULL, *sub_menu = NULL;
@@ -97,26 +96,11 @@
 									  NULL,
 									  "main",
 									  "please enter some numbers so i can figure out if I have any bugs or not",
-									  "enter some numbers",
-									  NULL,
-									  "I have no idea what that is",
-									  "cepstral",
-									  "david",
-									  NULL,
-									  15000, 10, NULL);
+									  "enter some numbers", NULL, "I have no idea what that is", "cepstral", "david", NULL, 15000, 10, NULL);
 
 
 		status = switch_ivr_menu_init(&sub_menu,
-									  menu,
-									  "sub",
-									  "/ram/congrats.wav",
-									  "/ram/extension.wav",
-									  NULL,
-									  "/ram/invalid.wav",
-									  NULL,
-									  NULL,
-									  NULL,
-									  15000, 10, NULL);
+									  menu, "sub", "/ram/congrats.wav", "/ram/extension.wav", NULL, "/ram/invalid.wav", NULL, NULL, NULL, 15000, 10, NULL);
 
 		if (status == SWITCH_STATUS_SUCCESS) {
 			// build the menu
@@ -125,10 +109,10 @@
 			switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_EXECMENU, "sub", "3");
 			//switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/usr/local/freeswitch/sounds/3.wav", "3");
 
-			
+
 			switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/swimp.raw", "1");
 			switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_BACK, NULL, "2");
-			
+
 
 			// start the menu
 			status = switch_ivr_menu_execute(session, menu, "main", NULL);
@@ -136,11 +120,11 @@
 			// cleaup the menu
 			switch_ivr_menu_stack_free(menu);
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n",params);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n", params);
 		}
-			
 
-		switch_ivr_play_file(session, NULL,"/ram/goodbye.wav",NULL);
+
+		switch_ivr_play_file(session, NULL, "/ram/goodbye.wav", NULL);
 	}
 }
 
@@ -151,15 +135,10 @@
 	switch_directory_handle_t dh;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 
-	if (switch_core_directory_open(&dh, 
-								   "ldap",
-								   "ldap.freeswitch.org",
-								   "cn=Manager,dc=freeswitch,dc=org",
-								   "test",
-								   NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_directory_open(&dh, "ldap", "ldap.freeswitch.org", "cn=Manager,dc=freeswitch,dc=org", "test", NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
 		return;
 	}
@@ -181,12 +160,12 @@
 {
 
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
 
-		switch_copy_string((char *)buf, dtmf, buflen);
-	}
+			switch_copy_string((char *) buf, dtmf, buflen);
+		}
 		break;
 	default:
 		break;
@@ -203,9 +182,9 @@
 	char buf[10] = "";
 	char *argv[3];
 	int argc;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
-	if(!(mydata = switch_core_session_strdup(session, (char *) data))) {
+	if (!(mydata = switch_core_session_strdup(session, (char *) data))) {
 		return;
 	}
 
@@ -221,14 +200,14 @@
 	}
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
-	
-    switch_channel_answer(channel);
+	assert(channel != NULL);
+
+	switch_channel_answer(channel);
 
 	codec = switch_core_session_get_read_codec(session);
-    args.input_callback = show_dtmf;
-    args.buf = buf;
-    args.buflen = sizeof(buf);
+	args.input_callback = show_dtmf;
+	args.buf = buf;
+	args.buflen = sizeof(buf);
 	switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
 }
@@ -236,17 +215,17 @@
 #ifdef BUGTEST
 static switch_bool_t bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
 {
-    switch_frame_t *frame;
+	switch_frame_t *frame;
 
-    switch(type) {
+	switch (type) {
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
-        frame = switch_core_media_bug_get_replace_frame(bug);
-        switch_core_media_bug_set_replace_frame(bug, frame);
-        printf("W00t\n");
-        break;
-    default:
-        break;
-    }
+		frame = switch_core_media_bug_get_replace_frame(bug);
+		switch_core_media_bug_set_replace_frame(bug, frame);
+		printf("W00t\n");
+		break;
+	default:
+		break;
+	}
 
 	return SWITCH_TRUE;
 }
@@ -257,55 +236,43 @@
 #ifdef BUGTEST
 	switch_media_bug_t *bug;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-    switch_status_t status;
+	switch_status_t status;
 
-	if ((status = switch_core_media_bug_add(session,
-											bug_callback,
-											NULL,
-											SMBF_WRITE_REPLACE,
-											&bug)) != SWITCH_STATUS_SUCCESS) {
+	if ((status = switch_core_media_bug_add(session, bug_callback, NULL, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-        return;
+		return;
 	}
 #endif
 	//switch_ivr_schedule_broadcast(time(NULL) + 10, switch_core_session_get_uuid(session), "/Users/anthm/sr8k.wav", SMF_ECHO_ALEG);
 	//switch_ivr_schedule_transfer(time(NULL) + 10, switch_core_session_get_uuid(session), "2000", NULL, NULL);
 	//switch_ivr_schedule_hangup(time(NULL) + 10, switch_core_session_get_uuid(session), SWITCH_CAUSE_ALLOTTED_TIMEOUT);
 
-    switch_ivr_play_file(session, NULL, data, NULL);
+	switch_ivr_play_file(session, NULL, data, NULL);
 }
 
 #if 1
 static void asrtest_function(switch_core_session_t *session, char *data)
 {
-	switch_ivr_detect_speech(session,
-							 "lumenvox",
-							 "demo",
-							 data,
-							 "127.0.0.1",
-							 NULL);
+	switch_ivr_detect_speech(session, "lumenvox", "demo", data, "127.0.0.1", NULL);
 }
 
-#else 
+#else
 static void asrtest_function(switch_core_session_t *session, char *data)
 {
-	switch_asr_handle_t ah = {0};
+	switch_asr_handle_t ah = { 0 };
 	switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char *codec_name = "L16";
-	switch_codec_t codec = {0}, *read_codec;
-	switch_frame_t write_frame = {0}, *write_frame_p = NULL;
+	switch_codec_t codec = { 0 }, *read_codec;
+	switch_frame_t write_frame = { 0 }, *write_frame_p = NULL;
 	char xdata[1024] = "";
 
 	read_codec = switch_core_session_get_read_codec(session);
 	assert(read_codec != NULL);
-	
+
 
 	if (switch_core_asr_open(&ah, "lumenvox",
-							 read_codec->implementation->iananame,
-							 8000,
-							 "127.0.0.1",
-							 &flags,
+							 read_codec->implementation->iananame, 8000, "127.0.0.1", &flags,
 							 switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		if (strcmp(ah.codec, read_codec->implementation->iananame)) {
 			if (switch_core_codec_init(&codec,
@@ -317,36 +284,37 @@
 									   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 									   NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
-				switch_core_session_set_read_codec(session, &codec);		
+				switch_core_session_set_read_codec(session, &codec);
 				write_frame.data = xdata;
 				write_frame.buflen = sizeof(xdata);
 				write_frame.codec = &codec;
 				write_frame_p = &write_frame;
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Failed %s@%uhz %u channels %dms\n",
-								  codec_name, read_codec->implementation->samples_per_second, read_codec->implementation->number_of_channels,
-								  read_codec->implementation->microseconds_per_frame / 1000);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+								  "Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
+								  read_codec->implementation->samples_per_second,
+								  read_codec->implementation->number_of_channels, read_codec->implementation->microseconds_per_frame / 1000);
 				switch_core_session_reset(session);
 				return;
 			}
 		}
-		
-		
+
+
 		if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
 			goto end;
 		}
-		
-		while(switch_channel_ready(channel)) {
+
+		while (switch_channel_ready(channel)) {
 			switch_frame_t *read_frame;
 			switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
 			char *xmlstr = NULL;
 			switch_xml_t xml = NULL, result;
- 
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-			
+
 			if (switch_test_flag(read_frame, SFF_CNG)) {
 				continue;
 			}
@@ -355,7 +323,7 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error Feeding Data\n");
 				break;
 			}
-			
+
 			if (switch_core_asr_check_results(&ah, &flags) == SWITCH_STATUS_SUCCESS) {
 				if (switch_core_asr_get_results(&ah, &xmlstr, &flags) != SWITCH_STATUS_SUCCESS) {
 					break;
@@ -368,7 +336,7 @@
 				}
 				switch_safe_free(xmlstr);
 			}
-			
+
 			if (write_frame_p) {
 				write_frame.datalen = read_frame->datalen;
 				switch_core_session_write_frame(session, write_frame_p, -1, 0);
@@ -378,7 +346,7 @@
 			}
 		}
 
-	end:
+	  end:
 		if (write_frame_p) {
 			switch_core_session_set_read_codec(session, read_codec);
 			switch_core_codec_destroy(&codec);
@@ -400,9 +368,9 @@
 	char buf[10] = "";
 	char term;
 	char say[128] = "";
-	
+
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	switch_channel_answer(channel);
 
@@ -413,15 +381,15 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enter up to 10 digits, press # to terminate, * to hangup\n");
 
 		if (data) {
-            switch_input_args_t args = {0};
+			switch_input_args_t args = { 0 };
 			/* you could have passed NULL instead of on_dtmf to get this exact behaviour (copy the digits to buf and stop playing)
 			   but you may want to pass the function if you have something cooler to do...
-			*/
-            args.input_callback = on_dtmf;
-            args.buf = buf;
-            args.buflen = sizeof(buf);
+			 */
+			args.input_callback = on_dtmf;
+			args.buf = buf;
+			args.buflen = sizeof(buf);
 			status = switch_ivr_play_file(session, NULL, data, &args);
-			
+
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 				break;
@@ -440,7 +408,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say);
 		switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL);
 	}
-	
+
 }
 
 
@@ -449,7 +417,7 @@
 	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n", switch_channel_get_name(channel));
 	return SWITCH_STATUS_SUCCESS;
@@ -472,7 +440,7 @@
 	/*.application_function */ bugtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ NULL
+	/*.next */ NULL
 };
 
 static const switch_application_interface_t ivr_application_interface = {
@@ -480,7 +448,7 @@
 	/*.application_function */ ivr_application_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &bug_application_interface
+	/*.next */ &bug_application_interface
 };
 
 static const switch_application_interface_t xml_application_interface = {
@@ -488,7 +456,7 @@
 	/*.application_function */ xml_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &ivr_application_interface
+	/*.next */ &ivr_application_interface
 };
 
 static const switch_application_interface_t disast_application_interface = {
@@ -496,7 +464,7 @@
 	/*.application_function */ disast_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
-	/*.next*/ &xml_application_interface
+	/*.next */ &xml_application_interface
 };
 
 static const switch_application_interface_t tts_application_interface = {
@@ -504,7 +472,7 @@
 	/*.application_function */ tts_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &disast_application_interface
+	/*.next */ &disast_application_interface
 };
 
 static const switch_application_interface_t dirtest_application_interface = {
@@ -512,7 +480,7 @@
 	/*.application_function */ dirtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_SUPPORT_NOMEDIA,
-	/*.next*/ &tts_application_interface
+	/*.next */ &tts_application_interface
 };
 
 static const switch_application_interface_t ivrtest_application_interface = {
@@ -520,7 +488,7 @@
 	/*.application_function */ ivrtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &dirtest_application_interface
+	/*.next */ &dirtest_application_interface
 };
 
 static const switch_application_interface_t asrtest_application_interface = {
@@ -528,7 +496,7 @@
 	/*.application_function */ asrtest_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ &ivrtest_application_interface
+	/*.next */ &ivrtest_application_interface
 };
 
 static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_park/mod_park.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_park/mod_park.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_park/mod_park.c	Fri Mar 30 12:19:18 2007
@@ -35,13 +35,13 @@
 static void park_function(switch_core_session_t *session, char *data)
 {
 	switch_ivr_park(session, NULL);
-	
+
 }
 
 static const switch_application_interface_t park_application_interface = {
 	/*.interface_name */ "park",
 	/*.application_function */ park_function,
-	NULL,NULL,NULL,
+	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
 	NULL
 };

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_playback/mod_playback.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_playback/mod_playback.c	Fri Mar 30 12:19:18 2007
@@ -41,21 +41,21 @@
 static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
 
-	
+
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-		
-		if (*dtmf == '*') {
-			return SWITCH_STATUS_BREAK;
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+			if (*dtmf == '*') {
+				return SWITCH_STATUS_BREAK;
+			}
 		}
-	}
 		break;
 	default:
 		break;
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -64,28 +64,28 @@
 {
 	switch_channel_t *channel;
 	char buf[10];
-	char *argv[4] = {0};
+	char *argv[4] = { 0 };
 	int argc;
 	char *engine = NULL;
 	char *voice = NULL;
 	char *text = NULL;
 	char *mydata = NULL;
 	switch_codec_t *codec;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	codec = switch_core_session_get_read_codec(session);
 	assert(codec != NULL);
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	mydata = switch_core_session_strdup(session, data);
-	argc = switch_separate_string(mydata, '|', argv, sizeof(argv)/sizeof(argv[0]));
+	argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
 
 	engine = argv[0];
 	voice = argv[1];
 	text = argv[2];
-	
+
 	if (!(engine && voice && text)) {
 		if (!engine) {
 			engine = "NULL";
@@ -102,27 +102,27 @@
 
 	switch_channel_pre_answer(channel);
 
-    args.input_callback = on_dtmf;
-    args.buf = buf;
-    args.buflen = sizeof(buf);
+	args.input_callback = on_dtmf;
+	args.buf = buf;
+	args.buflen = sizeof(buf);
 	switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args);
-	
+
 }
 
 static void playback_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
 	char *file_name = NULL;
-    switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	file_name = switch_core_session_strdup(session, data);
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 	switch_channel_pre_answer(channel);
 
-    args.input_callback = on_dtmf;
+	args.input_callback = on_dtmf;
 	switch_ivr_play_file(session, NULL, file_name, &args);
 
 }
@@ -132,21 +132,21 @@
 {
 	switch_channel_t *channel;
 	switch_status_t status;
-    uint32_t limit = 0;
-    char *path;
-    char *p;
-    switch_input_args_t args = {0};
+	uint32_t limit = 0;
+	char *path;
+	char *p;
+	switch_input_args_t args = { 0 };
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-    path = switch_core_session_strdup(session, data);
-    if ((p = strchr(path, '+'))) {
-        *p++ = '\0';
-        limit = atoi(p);
-    }
+	path = switch_core_session_strdup(session, data);
+	if ((p = strchr(path, '+'))) {
+		*p++ = '\0';
+		limit = atoi(p);
+	}
 
-    args.input_callback = on_dtmf;
+	args.input_callback = on_dtmf;
 	status = switch_ivr_record_file(session, NULL, path, &args, limit);
 
 	if (!switch_channel_ready(channel) || (status != SWITCH_STATUS_SUCCESS && !SWITCH_STATUS_IS_BREAK(status))) {
@@ -159,9 +159,9 @@
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-	switch_ivr_record_session(session, data, NULL);	
+	switch_ivr_record_session(session, data, NULL);
 }
 
 
@@ -169,9 +169,9 @@
 {
 	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
-	switch_ivr_stop_record_session(session, data);	
+	switch_ivr_stop_record_session(session, data);
 }
 
 
@@ -223,7 +223,7 @@
 	/* short_desc */ "Playback File",
 	/* syntax */ "<path>",
 	/* flags */ SAF_NONE,
-	/*.next*/	&stop_record_session_application_interface
+	/*.next */ &stop_record_session_application_interface
 };
 
 static const switch_loadable_module_interface_t mod_playback_module_interface = {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_rss/mod_rss.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_rss/mod_rss.c	Fri Mar 30 12:19:18 2007
@@ -68,9 +68,9 @@
 {
 	char tstr[80] = "";
 	uint32_t matches = 0, x = 0;
-	uint32_t len = (uint32_t)strlen(str);
+	uint32_t len = (uint32_t) strlen(str);
 
-	for (x = 0; x < max ; x++) {
+	for (x = 0; x < max; x++) {
 		snprintf(tstr, sizeof(tstr), "%u", x);
 		if (!strncasecmp(str, tstr, len)) {
 			matches++;
@@ -86,67 +86,66 @@
   if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
 static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
-
 {
 	switch (itype) {
-	case SWITCH_INPUT_TYPE_DTMF: {
-		char *dtmf = (char *) input;
-		struct dtmf_buffer *dtb;
-		dtb = (struct dtmf_buffer *) buf;
-	
-		switch(*dtmf) {
-		case '#':
-			switch_set_flag(dtb, SFLAG_MAIN);
-			return SWITCH_STATUS_BREAK;
-		case '6':
-			dtb->index++;
-			return SWITCH_STATUS_BREAK;
-		case '4':
-			dtb->index--;
-			return SWITCH_STATUS_BREAK;
-		case '*':
-			if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
-				switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
-			} else {
-				switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
-			}
-			break;
-		case '5':
-			switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-			break;
-		case '9':
-			switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-			break;
-		case '2':
-			if (dtb->speed < 260) {
-				dtb->speed += 30;
-				switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+	case SWITCH_INPUT_TYPE_DTMF:{
+			char *dtmf = (char *) input;
+			struct dtmf_buffer *dtb;
+			dtb = (struct dtmf_buffer *) buf;
+
+			switch (*dtmf) {
+			case '#':
+				switch_set_flag(dtb, SFLAG_MAIN);
+				return SWITCH_STATUS_BREAK;
+			case '6':
+				dtb->index++;
+				return SWITCH_STATUS_BREAK;
+			case '4':
+				dtb->index--;
+				return SWITCH_STATUS_BREAK;
+			case '*':
+				if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
+					switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+				} else {
+					switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+				}
+				break;
+			case '5':
+				switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
 				switch_set_flag(dtb, SFLAG_INFO);
 				return SWITCH_STATUS_BREAK;
-			}
-			break;
-		case '7':
-			dtb->speed = TTS_MEAN_SPEED;
-			switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
-			switch_set_flag(dtb, SFLAG_INFO);
-			return SWITCH_STATUS_BREAK;
-		case '8':
-			if (dtb->speed > 80) {
-				dtb->speed -= 30;
+				break;
+			case '9':
+				switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
+				switch_set_flag(dtb, SFLAG_INFO);
+				return SWITCH_STATUS_BREAK;
+				break;
+			case '2':
+				if (dtb->speed < 260) {
+					dtb->speed += 30;
+					switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+					switch_set_flag(dtb, SFLAG_INFO);
+					return SWITCH_STATUS_BREAK;
+				}
+				break;
+			case '7':
+				dtb->speed = TTS_MEAN_SPEED;
 				switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
 				switch_set_flag(dtb, SFLAG_INFO);
 				return SWITCH_STATUS_BREAK;
+			case '8':
+				if (dtb->speed > 80) {
+					dtb->speed -= 30;
+					switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+					switch_set_flag(dtb, SFLAG_INFO);
+					return SWITCH_STATUS_BREAK;
+				}
+				break;
+			case '0':
+				switch_set_flag(dtb, SFLAG_INSTRUCT);
+				return SWITCH_STATUS_BREAK;
 			}
-			break;
-		case '0':
-			switch_set_flag(dtb, SFLAG_INSTRUCT);
-			return SWITCH_STATUS_BREAK;
 		}
-	}
 		break;
 	default:
 		break;
@@ -159,9 +158,9 @@
 	switch_channel_t *channel;
 	switch_status_t status;
 	const char *err = NULL;
-	struct dtmf_buffer dtb = {0};
+	struct dtmf_buffer dtb = { 0 };
 	switch_xml_t xml = NULL, item, xchannel = NULL;
-	struct rss_entry entries[TTS_MAX_ENTRIES] = {{0}};
+	struct rss_entry entries[TTS_MAX_ENTRIES] = { {0} };
 	uint32_t i = 0;
 	char *title_txt = "", *description_txt = "", *rights_txt = "";
 	switch_codec_t speech_codec, *codec = switch_core_session_get_read_codec(session);
@@ -169,31 +168,32 @@
 	char *voice = TTS_DEFAULT_VOICE;
 	char *timer_name = NULL;
 	switch_speech_handle_t sh;
-    switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
 	switch_core_thread_session_t thread_session;
 	uint32_t rate, interval = 20;
 	int stream_id = 0;
-	switch_timer_t timer = {0}, *timerp = NULL;
+	switch_timer_t timer = { 0 }, *timerp = NULL;
 	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;
 	char *cf = "rss.conf";
-    switch_xml_t cfg, cxml, feeds, feed;
+	switch_xml_t cfg, cxml, feeds, feed;
 	char buf[1024];
 	int32_t jumpto = -1;
 	uint32_t matches = 0;
-	switch_input_args_t args = {0};
+	switch_input_args_t args = { 0 };
 
 	channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	assert(channel != NULL);
 
 
 	if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-        return;
-    }
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+		return;
+	}
 
 	if ((feeds = switch_xml_child(cfg, "feeds"))) {
 		for (feed = switch_xml_child(feeds, "feed"); feed; feed = feed->next) {
@@ -210,14 +210,14 @@
 	}
 
 	switch_xml_free(cxml);
-	
+
 	switch_channel_answer(channel);
 
 
 
 	if (!switch_strlen_zero(data)) {
 		if ((mydata = switch_core_session_strdup(session, data))) {
-			argc = switch_separate_string(mydata, ' ', argv, sizeof(argv)/sizeof(argv[0]));
+			argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]));
 
 			if (argv[0]) {
 				engine = argv[0];
@@ -244,24 +244,17 @@
 	}
 
 	memset(&sh, 0, sizeof(sh));
-	if (switch_core_speech_open(&sh,
-								engine,
-								voice,
-								rate,
-								&flags,
-								switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_speech_open(&sh, engine, voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
 		return;
 	}
-	
+
 	if (switch_core_codec_init(&speech_codec,
 							   "L16",
 							   NULL,
-							   (int)rate,
+							   (int) rate,
 							   interval,
-							   1,
-							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-							   NULL,
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
 							   switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
 	} else {
@@ -270,16 +263,16 @@
 		switch_core_speech_close(&sh, &flags);
 		return;
 	}
-	
+
 	if (timer_name) {
-		if (switch_core_timer_init(&timer, timer_name, interval, (int)(rate / 50), switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		if (switch_core_timer_init(&timer, timer_name, interval, (int) (rate / 50), switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
 			switch_core_codec_destroy(&speech_codec);
 			flags = 0;
 			switch_core_speech_close(&sh, &flags);
 			return;
 		}
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", (rate / 50)*2, interval);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", (rate / 50) * 2, interval);
 
 		/* start a thread to absorb incoming audio */
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
@@ -292,7 +285,7 @@
 	while (switch_channel_ready(channel)) {
 		int32_t len = 0, idx = 0;
 		char cmd[3];
-	main_menu:
+	  main_menu:
 		filename = NULL;
 		len = idx = 0;
 		*cmd = '\0';
@@ -304,36 +297,29 @@
 		} else {
 			switch_core_speech_flush_tts(&sh);
 #ifdef MATCH_COUNT
-			snprintf(buf + len, sizeof(buf) - len, 
+			snprintf(buf + len, sizeof(buf) - len,
 					 ",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
-					 "Select one of the following news sources, or press 0 to exit. "
-					 ",<break time=\"600ms\"/>");
+					 "Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
 #else
-			snprintf(buf + len, sizeof(buf) - len, 
+			snprintf(buf + len, sizeof(buf) - len,
 					 ",<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\"/>");
+					 "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);
+			len = (int32_t) strlen(buf);
 
 			for (idx = 0; idx < feed_index; idx++) {
 				snprintf(buf + len, sizeof(buf) - len, "%d: %s. <break time=\"600ms\"/>", idx + 1, feed_names[idx]);
-				len = (int32_t)strlen(buf);
+				len = (int32_t) strlen(buf);
 			}
 
 
 			snprintf(buf + len, sizeof(buf) - len, "<break time=\"2000ms\"/>");
-			len = (int32_t)strlen(buf);
+			len = (int32_t) strlen(buf);
 
 			args.input_callback = NULL;
 			args.buf = cmd;
 			args.buflen = sizeof(cmd);
-			status = switch_ivr_speak_text_handle(session,
-												  &sh,
-												  &speech_codec,
-												  timerp,
-												  buf,
-												  &args);
+			status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				goto finished;
 			}
@@ -346,51 +332,46 @@
 				break;
 			}
 
-			if ((p=strchr(cmd, '#'))) {
+			if ((p = strchr(cmd, '#'))) {
 				*p = '\0';
 #ifdef MATCH_COUNT
 				/* Hmmm... I know there are no more matches so I don't *need* them to press pound but 
 				   I already told them to press it.  Will this confuse people or not?  Let's make em press 
 				   pound unless this define is enabled for now.
-				*/
+				 */
 			} else if (match_count(cmd, feed_index) > 1) {
 #else
 			} else {
 #endif
 				char term;
 				char *cp;
-				int blen = sizeof(cmd) - (int)strlen(cmd);
+				int blen = sizeof(cmd) - (int) strlen(cmd);
 
 				cp = cmd + blen;
 				switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
 			}
-			
+
 			i = atoi(cmd) - 1;
 
 			if (i > -1 && i < feed_index) {
 				filename = feed_list[i];
 			} else if (matches > 1) {
-				
+
 			} else {
 				args.input_callback = NULL;
 				args.buf = NULL;
 				args.buflen = 0;
-				status = switch_ivr_speak_text_handle(session,
-													  &sh,
-													  &speech_codec,
-													  timerp,
-													  "I'm sorry. That is an Invalid Selection. ",
-													  &args);
+				status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, "I'm sorry. That is an Invalid Selection. ", &args);
 				if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 					goto finished;
 				}
 			}
 		}
-	
+
 		if (!filename) {
 			continue;
 		}
-		
+
 
 
 		if (!(xml = switch_xml_parse_file(filename))) {
@@ -411,7 +392,7 @@
 			if ((title = switch_xml_child(xchannel, "title"))) {
 				title_txt = title->txt;
 			}
-			
+
 			if ((description = switch_xml_child(xchannel, "description"))) {
 				description_txt = description->txt;
 			}
@@ -444,19 +425,19 @@
 			if ((title = switch_xml_child(item, "title"))) {
 				entries[i].title_txt = title->txt;
 			}
-		
+
 			if ((description = switch_xml_child(item, "description"))) {
 				char *t, *e;
 				entries[i].description_txt = description->txt;
-				for(;;) {
+				for (;;) {
 					if (!(t = strchr(entries[i].description_txt, '<'))) {
 						break;
 					}
 					if (!(e = strchr(t, '>'))) {
 						break;
 					}
-				
-					memset(t, 32, ++e-t);
+
+					memset(t, 32, ++e - t);
 				}
 			}
 
@@ -471,9 +452,8 @@
 			if (entries[i].description_txt && (p = strchr(entries[i].description_txt, '<'))) {
 				*p = '\0';
 			}
-
 #ifdef _STRIP_SOME_CHARS_
-			for(p = entries[i].description_txt; *p; p++) {
+			for (p = entries[i].description_txt; *p; p++) {
 				if (*p == '\'' || *p == '"' || *p == ':') {
 					*p = ' ';
 				}
@@ -493,17 +473,13 @@
 			switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
 
 
-			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. ", 
+			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);
 			args.input_callback = NULL;
 			args.buf = cmd;
 			args.buflen = sizeof(cmd);
-			status = switch_ivr_speak_text_handle(session,
-												  &sh,
-												  &speech_codec,
-												  timerp,
-												  buf,
-												  &args);
+			status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 				goto finished;
 			}
@@ -519,7 +495,7 @@
 			}
 		}
 
-		for(last = 0; last < TTS_MAX_ENTRIES; last++) {
+		for (last = 0; last < TTS_MAX_ENTRIES; last++) {
 			if (!entries[last].inuse) {
 				last--;
 				break;
@@ -531,8 +507,8 @@
 		dtb.speed = TTS_MEAN_SPEED;
 		switch_set_flag(&dtb, SFLAG_INFO);
 		switch_copy_string(dtb.voice, voice, sizeof(dtb.voice));
-		while(entries[0].inuse && switch_channel_ready(channel)) {
-			while(switch_channel_ready(channel)) {
+		while (entries[0].inuse && switch_channel_ready(channel)) {
+			while (switch_channel_ready(channel)) {
 				uint8_t cont = 0;
 
 				if (dtb.index >= TTS_MAX_ENTRIES) {
@@ -556,13 +532,8 @@
 					}
 					if (switch_test_flag(&dtb, SFLAG_INFO)) {
 						switch_clear_flag(&dtb, SFLAG_INFO);
-						snprintf(buf + len, sizeof(buf) - len,
-								 "%s %s. I am speaking at %u words per minute. ",
-								 sh.engine,
-								 sh.voice,
-								 dtb.speed
-								 );
-						len = (uint32_t)strlen(buf);
+						snprintf(buf + len, sizeof(buf) - len, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
+						len = (uint32_t) strlen(buf);
 					}
 
 					if (switch_test_flag(&dtb, SFLAG_INSTRUCT)) {
@@ -577,33 +548,28 @@
 								 "To hear these options again, press zero or press pound to return to the main menu. ");
 					} else {
 						snprintf(buf + len, sizeof(buf) - len, "Story %d. ", dtb.index + 1);
-						len = (uint32_t)strlen(buf);
+						len = (uint32_t) strlen(buf);
 
 						if (entries[dtb.index].subject_txt) {
 							snprintf(buf + len, sizeof(buf) - len, "Subject: %s. ", entries[dtb.index].subject_txt);
-							len = (uint32_t)strlen(buf);
+							len = (uint32_t) strlen(buf);
 						}
-				
+
 						if (entries[dtb.index].dept_txt) {
 							snprintf(buf + len, sizeof(buf) - len, "From the %s department. ", entries[dtb.index].dept_txt);
-							len = (uint32_t)strlen(buf);
+							len = (uint32_t) strlen(buf);
 						}
 
 						if (entries[dtb.index].title_txt) {
 							snprintf(buf + len, sizeof(buf) - len, "%s", entries[dtb.index].title_txt);
-							len = (uint32_t)strlen(buf);
+							len = (uint32_t) strlen(buf);
 						}
 					}
 					switch_core_speech_flush_tts(&sh);
 					args.input_callback = on_dtmf;
 					args.buf = &dtb;
 					args.buflen = sizeof(dtb);
-					status = switch_ivr_speak_text_handle(session,
-														  &sh,
-														  &speech_codec,
-														  timerp,
-														  buf,
-														  &args);
+					status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
 					if (status == SWITCH_STATUS_BREAK) {
 						continue;
 					} else if (status != SWITCH_STATUS_SUCCESS) {
@@ -614,17 +580,12 @@
 						cont = 0;
 						continue;
 					}
-					
+
 					if (entries[dtb.index].description_txt) {
 						args.input_callback = on_dtmf;
 						args.buf = &dtb;
 						args.buflen = sizeof(dtb);
-						status = switch_ivr_speak_text_handle(session,
-															  &sh,
-															  &speech_codec,
-															  timerp,
-															  entries[dtb.index].description_txt,
-															  &args);
+						status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, entries[dtb.index].description_txt, &args);
 					}
 					if (status == SWITCH_STATUS_BREAK) {
 						continue;
@@ -638,7 +599,7 @@
 		}
 	}
 
- finished:
+  finished:
 	switch_core_speech_close(&sh, &flags);
 	switch_core_codec_destroy(&speech_codec);
 
@@ -659,7 +620,7 @@
 	/*.application_function */ rss_function,
 	NULL, NULL, NULL,
 	/* flags */ SAF_NONE,
-	/*.next*/ NULL
+	/*.next */ NULL
 };
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	Fri Mar 30 12:19:18 2007
@@ -69,23 +69,23 @@
 
 
 /* This callback caches the audio in the buffer */
-static swift_result_t write_audio(swift_event *event, swift_event_t type, void *udata)
+static swift_result_t write_audio(swift_event * event, swift_event_t type, void *udata)
 {
 	cepstral_t *cepstral;
-    swift_event_t rv = SWIFT_SUCCESS;
-    void *buf = NULL;
-    int len = 0, i = 0;
-	
+	swift_event_t rv = SWIFT_SUCCESS;
+	void *buf = NULL;
+	int len = 0, i = 0;
+
 	cepstral = udata;
 	assert(cepstral != NULL);
-	
+
 	if (!cepstral->port || cepstral->done || cepstral->done_gen) {
-		return  SWIFT_UNKNOWN_ERROR;
+		return SWIFT_UNKNOWN_ERROR;
 	}
 
 	/* Only proceed when we have success */
-    if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
-		while(!cepstral->done) {
+	if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
+		while (!cepstral->done) {
 			switch_mutex_lock(cepstral->audio_lock);
 			if (switch_buffer_write(cepstral->audio_buffer, buf, len) > 0) {
 				switch_mutex_unlock(cepstral->audio_lock);
@@ -100,7 +100,7 @@
 					}
 				}
 			}
-			
+
 		}
 	} else {
 		cepstral->done = 1;
@@ -109,8 +109,8 @@
 	if (cepstral->done) {
 		rv = SWIFT_UNKNOWN_ERROR;
 	}
-	
-    return rv;
+
+	return rv;
 }
 
 static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags)
@@ -143,7 +143,7 @@
 		goto all_done;
 	}
 
-		
+
 	if (voice_name && SWIFT_FAILED(swift_port_set_voice_by_name(cepstral->port, voice_name))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid voice %s!\n", voice_name);
 		voice_name = NULL;
@@ -157,7 +157,7 @@
 		}
 
 		/* Set the voice found by find_first_voice() as the port's current voice */
-		if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+		if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
 			goto all_done;
 		}
@@ -173,8 +173,8 @@
 
 	sh->private_info = cepstral;
 	return SWITCH_STATUS_SUCCESS;
-	
- all_done:
+
+  all_done:
 	return SWITCH_STATUS_FALSE;
 }
 
@@ -185,18 +185,19 @@
 	assert(sh != NULL);
 	cepstral = sh->private_info;
 	assert(cepstral != NULL);
-	
+
 
 	cepstral->done = 1;
 	cepstral->done_gen = 1;
 	swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
 	/* Close the Swift Port and Engine */
-	if (NULL != cepstral->port) swift_port_close(cepstral->port);
+	if (NULL != cepstral->port)
+		swift_port_close(cepstral->port);
 	//if (NULL != cepstral->engine) swift_engine_close(cepstral->engine);
 
 	cepstral->port = NULL;
 	//cepstral->engine = NULL;
-	
+
 	switch_buffer_destroy(&cepstral->audio_buffer);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -206,7 +207,7 @@
 {
 	cepstral_t *cepstral;
 	const char *fp = "file:";
-	int len = (int)strlen(fp);
+	int len = (int) strlen(fp);
 
 	assert(sh != NULL);
 	cepstral = sh->private_info;
@@ -214,7 +215,7 @@
 
 	cepstral->done_gen = 0;
 	cepstral->done = 0;
-	
+
 	cepstral->tts_stream = NULL;
 
 	if (!strncasecmp(text, fp, len)) {
@@ -222,17 +223,17 @@
 		if (switch_strlen_zero(text)) {
 			return SWITCH_STATUS_FALSE;
 		}
-		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); 
+		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL);
 	} else {
-        char *to_say;
+		char *to_say;
 		if (switch_strlen_zero(text)) {
 			return SWITCH_STATUS_FALSE;
 		}
 
-        if ((to_say = switch_mprintf("<break time=\"500ms\"/> %s <break time=\"500ms\"/>", text))) {
-            swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL); 
-            switch_safe_free(to_say);
-        }
+		if ((to_say = switch_mprintf("<break time=\"500ms\"/> %s <break time=\"500ms\"/>", text))) {
+			swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL);
+			switch_safe_free(to_say);
+		}
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -243,10 +244,10 @@
 	cepstral_t *cepstral;
 
 	cepstral = sh->private_info;
-    assert(cepstral != NULL);
+	assert(cepstral != NULL);
 
 	cepstral->done_gen = 1;
-    cepstral->done = 1;
+	cepstral->done = 1;
 	if (cepstral->audio_buffer) {
 		switch_mutex_lock(cepstral->audio_lock);
 		switch_buffer_zero(cepstral->audio_buffer);
@@ -255,11 +256,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;
@@ -270,7 +267,7 @@
 	cepstral = sh->private_info;
 	assert(cepstral != NULL);
 
-	while(!cepstral->done) {
+	while (!cepstral->done) {
 		if (!cepstral->done_gen) {
 			int check = swift_port_status(cepstral->port, cepstral->tts_stream);
 
@@ -282,8 +279,8 @@
 		switch_mutex_lock(cepstral->audio_lock);
 		used = switch_buffer_inuse(cepstral->audio_buffer);
 		switch_mutex_unlock(cepstral->audio_lock);
-		
-		
+
+
 		if (!used && cepstral->done_gen) {
 
 			status = SWITCH_STATUS_BREAK;
@@ -304,15 +301,15 @@
 			switch_yield(1000);
 			continue;
 		}
-		
+
 		/* There is enough, read it and return */
 		switch_mutex_lock(cepstral->audio_lock);
 		*datalen = switch_buffer_read(cepstral->audio_buffer, data, desired);
 		if (padding) {
 			size_t x = 0;
 			unsigned char *p = data;
-			
-			for(x = 0; x < padding; x++) {
+
+			for (x = 0; x < padding; x++) {
 				*(p + x) = 0;
 				(*datalen)++;
 			}
@@ -323,7 +320,7 @@
 
 		break;
 	}
-	
+
 	return status;
 }
 
@@ -338,7 +335,7 @@
 		char *voice_name = val;
 		if (!strcasecmp(voice_name, "next")) {
 			if ((cepstral->voice = swift_port_find_next_voice(cepstral->port))) {
-				if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+				if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
 					cepstral->done = cepstral->done_gen = 1;
 					return;
 				}
@@ -354,22 +351,22 @@
 		}
 
 		if (!voice_name) {
-            /* Find the first voice on the system */
-            if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
+			/* Find the first voice on the system */
+			if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
 				cepstral->done = cepstral->done_gen = 1;
 				return;
-            }
+			}
 
-            /* Set the voice found by find_first_voice() as the port's current voice */
-            if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
+			/* Set the voice found by find_first_voice() as the port's current voice */
+			if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
 				cepstral->done = cepstral->done_gen = 1;
 				return;
-            }
+			}
 
 			voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
-        } 
+		}
 
 		if (voice_name) {
 			switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
@@ -405,15 +402,15 @@
 }
 
 static const switch_speech_interface_t cepstral_speech_interface = {
-	/*.interface_name*/			"cepstral",
-	/*.speech_open*/			cepstral_speech_open,
-	/*.speech_close*/			cepstral_speech_close,
-	/*.speech_feed_tts*/		cepstral_speech_feed_tts,
-	/*.speech_read_tts*/		cepstral_speech_read_tts,
-	/*.speech_flush_tts*/		cepstral_speech_flush_tts,
-	/*.speech_text_param_tts*/  cepstral_text_param_tts,
-	/*.speech_numeric_param_tts*/  cepstral_numeric_param_tts,
-	/*.speech_numeric_param_tts*/  cepstral_float_param_tts
+	/*.interface_name */ "cepstral",
+	/*.speech_open */ cepstral_speech_open,
+	/*.speech_close */ cepstral_speech_close,
+	/*.speech_feed_tts */ cepstral_speech_feed_tts,
+	/*.speech_read_tts */ cepstral_speech_read_tts,
+	/*.speech_flush_tts */ cepstral_speech_flush_tts,
+	/*.speech_text_param_tts */ cepstral_text_param_tts,
+	/*.speech_numeric_param_tts */ cepstral_numeric_param_tts,
+	/*.speech_numeric_param_tts */ cepstral_float_param_tts
 };
 
 static const switch_loadable_module_interface_t cepstral_module_interface = {
@@ -433,11 +430,11 @@
 {
 
 	/* Open the Swift TTS Engine */
-	if ( SWIFT_FAILED(engine = swift_engine_open(NULL)) ) {
+	if (SWIFT_FAILED(engine = swift_engine_open(NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open Swift Engine.");
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &cepstral_module_interface;
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_amr/mod_amr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_amr/mod_amr.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_amr/mod_amr.c	Fri Mar 30 12:19:18 2007
@@ -30,7 +30,7 @@
  *
  * mod_amr.c -- GSM-AMR Codec Module
  *
- */  
+ */
 #include "switch.h"
 static const char modname[] = "mod_amr";
 
@@ -113,15 +113,14 @@
 
 #endif
 
-static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 
 #ifdef AMR_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-    if (codec->fmtp_in) {
-        codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-    }
+	if (codec->fmtp_in) {
+		codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+	}
 	return SWITCH_STATUS_SUCCESS;
 #else
 	struct amr_context *context = NULL;
@@ -139,10 +138,10 @@
 
 		if (codec->fmtp_in) {
 			argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
-			for(x = 0; x < argc; x++) {
+			for (x = 0; x < argc; x++) {
 				char *data = argv[x];
 				char *arg;
-				while(*data && *data == ' ') {
+				while (*data && *data == ' ') {
 					data++;
 				}
 				if ((arg = strchr(data, '='))) {
@@ -171,16 +170,16 @@
 					} else if (!strcasecmp(data, "mode-change-period")) {
 						context->change_period = atoi(arg);
 					} else if (!strcasecmp(data, "ptime")) {
-						context->ptime = (switch_byte_t)atoi(arg);
+						context->ptime = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "channels")) {
-						context->channels = (switch_byte_t)atoi(arg);
+						context->channels = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "maxptime")) {
-						context->max_ptime = (switch_byte_t)atoi(arg);
+						context->max_ptime = (switch_byte_t) atoi(arg);
 					} else if (!strcasecmp(data, "mode-set")) {
 						int y, m_argc;
 						char *m_argv[7];
 						m_argc = switch_separate_string(arg, ',', m_argv, (sizeof(m_argv) / sizeof(m_argv[0])));
-						for(y = 0; y < m_argc; y++) {
+						for (y = 0; y < m_argc; y++) {
 							context->enc_modes |= (1 << atoi(m_argv[y]));
 						}
 					}
@@ -192,7 +191,7 @@
 		if (context->enc_modes) {
 			for (i = 7; i > -1; i++) {
 				if (context->enc_modes & (1 << i)) {
-					context->enc_mode = (switch_byte_t)i;
+					context->enc_mode = (switch_byte_t) i;
 					break;
 				}
 			}
@@ -201,10 +200,10 @@
 		if (!context->enc_mode) {
 			context->enc_mode = globals.default_bitrate;
 		}
-		
+
 		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;
 		context->encoder_state = NULL;
 		context->decoder_state = NULL;
@@ -224,7 +223,7 @@
 #endif
 }
 
-static switch_status_t switch_amr_destroy(switch_codec_t *codec) 
+static switch_status_t switch_amr_destroy(switch_codec_t *codec)
 {
 #ifndef AMR_PASSTHROUGH
 	struct amr_context *context = codec->private_info;
@@ -240,45 +239,35 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_amr_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) 
+static switch_status_t switch_amr_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)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
 	return SWITCH_STATUS_FALSE;
 #else
 	struct amr_context *context = codec->private_info;
-	
+
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
-	*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (switch_byte_t *) encoded_data, 0);
+
+	*encoded_data_len = Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data, (switch_byte_t *) encoded_data, 0);
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-static switch_status_t switch_amr_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) 
+static switch_status_t switch_amr_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)
 {
 #ifdef AMR_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -290,51 +279,50 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	Decoder_Interface_Decode(context->decoder_state, (unsigned char *)encoded_data, (int16_t *)decoded_data, 0);
+	Decoder_Interface_Decode(context->decoder_state, (unsigned char *) encoded_data, (int16_t *) decoded_data, 0);
 	*decoded_data_len = codec->implementation->bytes_per_frame;
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t amr_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 96, 
-	/*.iananame */ "AMR", 
+static const switch_codec_implementation_t amr_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 96,
+	/*.iananame */ "AMR",
 	/*.fmtp */ "octet-align=0",
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 0, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 0,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
 	/*.bytes_per_frame */ 320,
-	/*.encoded_bytes_per_frame */ 0, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_amr_init, 
-	/*.encode */ switch_amr_encode, 
-	/*.decode */ switch_amr_decode, 
-	/*.destroy */ switch_amr_destroy, 
+	/*.encoded_bytes_per_frame */ 0,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_amr_init,
+	/*.encode */ switch_amr_encode,
+	/*.decode */ switch_amr_decode,
+	/*.destroy */ switch_amr_destroy,
 };
 
-static const switch_codec_interface_t amr_codec_interface = { 
-	/*.interface_name */ "GSM-AMR", 
-	/*.implementations */ &amr_implementation, 
+static const switch_codec_interface_t amr_codec_interface = {
+	/*.interface_name */ "GSM-AMR",
+	/*.implementations */ &amr_implementation,
 };
 
-static switch_loadable_module_interface_t amr_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &amr_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t amr_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &amr_codec_interface,
+	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 #ifndef AMR_PASSTHROUGH
 	char *cf = "amr.conf";
@@ -349,17 +337,16 @@
 				char *var = (char *) switch_xml_attr_soft(param, "name");
 				char *val = (char *) switch_xml_attr_soft(param, "value");
 				if (!strcasecmp(var, "default-bitrate")) {
-					globals.default_bitrate = (switch_byte_t)atoi(val);
+					globals.default_bitrate = (switch_byte_t) atoi(val);
 				}
 			}
 		}
 	}
-
 #endif
 
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &amr_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g711/mod_g711.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g711/mod_g711.c	Fri Mar 30 12:19:18 2007
@@ -36,8 +36,7 @@
 static const char modname[] = "mod_g711";
 
 
-static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -53,12 +52,11 @@
 
 
 static switch_status_t switch_g711u_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)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -77,12 +75,11 @@
 }
 
 static switch_status_t switch_g711u_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)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -111,8 +108,7 @@
 }
 
 
-static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -128,12 +124,11 @@
 
 
 static switch_status_t switch_g711a_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)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -152,12 +147,11 @@
 }
 
 static switch_status_t switch_g711a_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)
 {
 	short *dbuf;
 	unsigned char *ebuf;
@@ -226,7 +220,7 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_120ms_implementation
+	/*.next */ &g711u_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
@@ -247,7 +241,7 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_60ms_implementation
+	/*.next */ &g711u_8k_60ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
@@ -268,7 +262,7 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_30ms_implementation
+	/*.next */ &g711u_8k_30ms_implementation
 };
 
 static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
@@ -289,7 +283,7 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next*/ &g711u_8k_20ms_implementation
+	/*.next */ &g711u_8k_20ms_implementation
 };
 
 
@@ -332,7 +326,7 @@
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_120ms_implementation
+	/*.next */ &g711a_8k_120ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
@@ -353,7 +347,7 @@
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_60ms_implementation
+	/*.next */ &g711a_8k_60ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
@@ -374,7 +368,7 @@
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_30ms_implementation
+	/*.next */ &g711a_8k_30ms_implementation
 };
 
 static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
@@ -395,7 +389,7 @@
 	/*.encode */ switch_g711a_encode,
 	/*.decode */ switch_g711a_decode,
 	/*.destroy */ switch_g711a_destroy,
-    /*.next*/ &g711a_8k_20ms_implementation
+	/*.next */ &g711a_8k_20ms_implementation
 };
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g722/mod_g722.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g722/mod_g722.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g722/mod_g722.c	Fri Mar 30 12:19:18 2007
@@ -40,8 +40,7 @@
 	g722_encode_state_t encoder_object;
 };
 
-static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 	struct g722_context *context = NULL;
@@ -50,18 +49,18 @@
 	encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
 	decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
 
-	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) { 
+	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
 		return SWITCH_STATUS_FALSE;
 	} else {
 		if (encoding) {
-			if(codec->implementation->samples_per_second == 16000){
+			if (codec->implementation->samples_per_second == 16000) {
 				g722_encode_init(&context->encoder_object, 64000, G722_PACKED);
 			} else {
 				g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000);
 			}
 		}
 		if (decoding) {
-			if(codec->implementation->samples_per_second == 16000){
+			if (codec->implementation->samples_per_second == 16000) {
 				g722_decode_init(&context->decoder_object, 64000, G722_PACKED);
 			} else {
 				g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000);
@@ -70,44 +69,42 @@
 	}
 
 	codec->private_info = context;
-	return SWITCH_STATUS_SUCCESS;	
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_g722_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)
 {
 	struct g722_context *context = codec->private_info;
 
 	if (!context) {
-		return SWITCH_STATUS_FALSE; 
+		return SWITCH_STATUS_FALSE;
 	}
 
 	*encoded_data_len = g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_g722_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)
 {
 	struct g722_context *context = codec->private_info;
 
 	if (!context) {
-		return SWITCH_STATUS_FALSE; 
+		return SWITCH_STATUS_FALSE;
 	}
 
 	*decoded_data_len = (2 * g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/mod_g723_1.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/mod_g723_1.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/mod_g723_1.c	Fri Mar 30 12:19:18 2007
@@ -30,7 +30,7 @@
  *
  * mod_g723.c -- G723.1 Codec Module
  *
- */  
+ */
 #include "switch.h"
 
 #ifndef G723_PASSTHROUGH
@@ -60,12 +60,11 @@
 };
 #endif
 
-static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 #ifdef G723_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-	return  SWITCH_STATUS_FALSE;
+	return SWITCH_STATUS_FALSE;
 #else
 	struct g723_context *context = NULL;
 	int encoding, decoding;
@@ -79,10 +78,10 @@
 
 		if (encoding) {
 			Init_Coder(&context->encoder_object);
-			if( UseVx ) {
+			if (UseVx) {
 				Init_Vad(&context->encoder_object);
 				Init_Cod_Cng(&context->encoder_object);
-			}		   
+			}
 		}
 
 		if (decoding) {
@@ -98,7 +97,7 @@
 }
 
 
-static switch_status_t switch_g723_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g723_destroy(switch_codec_t *codec)
 {
 #ifndef G723_PASSTHROUGH
 	codec->private_info = NULL;
@@ -106,17 +105,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_g723_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) 
+static switch_status_t switch_g723_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)
 {
 #ifdef G723_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -131,28 +125,23 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	for(x = 0; x < Frame; x++) {
+	for (x = 0; x < Frame; x++) {
 		context->cod_float_buf[x] = decoded_slin_buf[x];
 	}
 
-	Coder(&context->encoder_object, (FLOAT *)context->cod_float_buf, ebuf);
+	Coder(&context->encoder_object, (FLOAT *) context->cod_float_buf, ebuf);
 	*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
 
 	return SWITCH_STATUS_SUCCESS;
 #endif
 }
 
-static switch_status_t switch_g723_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) 
+static switch_status_t switch_g723_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)
 {
 #ifdef G723_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -165,10 +154,10 @@
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	Decod(&context->decoder_object, (FLOAT *) context->dec_float_buf, (char *) decoded_data, 0);
 
-	for (x=0;x<Frame;x++) {
+	for (x = 0; x < Frame; x++) {
 		to_slin_buf[x] = context->dec_float_buf[x];
 	}
 	*decoded_data_len = codec->implementation->bytes_per_frame;
@@ -177,49 +166,48 @@
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g723_1_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 4, 
-	/*.iananame */ "G723", 
+static const switch_codec_implementation_t g723_1_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 4,
+	/*.iananame */ "G723",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 6300, 
-	/*.microseconds_per_frame */ 30000, 
-	/*.samples_per_frame */ 240, 
-	/*.bytes_per_frame */ 480, 
-	/*.encoded_bytes_per_frame */ 24, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 4, 
-	/*.init */ switch_g723_init, 
-	/*.encode */ switch_g723_encode, 
-	/*.decode */ switch_g723_decode, 
-	/*.destroy */ switch_g723_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 6300,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ 24,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 4,
+	/*.init */ switch_g723_init,
+	/*.encode */ switch_g723_encode,
+	/*.decode */ switch_g723_decode,
+	/*.destroy */ switch_g723_destroy,
 };
 
-static const switch_codec_interface_t g723_1_codec_interface = { 
-	/*.interface_name */ "g723.1 6.3k", 
-	/*.implementations */ &g723_1_implementation, 
+static const switch_codec_interface_t g723_1_codec_interface = {
+	/*.interface_name */ "g723.1 6.3k",
+	/*.implementations */ &g723_1_implementation,
 };
 
-static switch_loadable_module_interface_t g723_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &g723_1_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t g723_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &g723_1_codec_interface,
+	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g723_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g726/mod_g726.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g726/mod_g726.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g726/mod_g726.c	Fri Mar 30 12:19:18 2007
@@ -28,15 +28,15 @@
  *
  * mod_g726.c -- G726 Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "g72x.h"
 #include "switch_bitpack.h"
 
 static const char modname[] = "mod_g726";
 
-typedef int (*encoder_t)(int, int, g726_state *);
-typedef int (*decoder_t)(int, int, g726_state *);
+typedef int (*encoder_t) (int, int, g726_state *);
+typedef int (*decoder_t) (int, int, g726_state *);
 
 
 typedef struct {
@@ -52,8 +52,7 @@
 	switch_byte_t buf[160];
 } g726_handle_t;
 
-static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+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;
 	g726_handle_t *handle;
@@ -65,8 +64,8 @@
 		return SWITCH_STATUS_FALSE;
 	} else {
 		handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
-		
-		switch(handle->bytes) {
+
+		switch (handle->bytes) {
 		case 100:
 			handle->encoder = g726_40_encoder;
 			handle->decoder = g726_40_decoder;
@@ -96,14 +95,14 @@
 		g726_init_state(&handle->context);
 		codec->private_info = handle;
 		handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
-		handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2")) 
+		handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
 			? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
 		return SWITCH_STATUS_SUCCESS;
 	}
 }
 
 
-static switch_status_t switch_g726_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g726_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
@@ -111,17 +110,12 @@
 
 
 
-static switch_status_t switch_g726_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) 
+static switch_status_t switch_g726_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)
 {
 
 	g726_handle_t *handle = codec->private_info;
@@ -163,17 +157,12 @@
 
 
 
-static switch_status_t switch_g726_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) 
+static switch_status_t switch_g726_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)
 {
 
 	g726_handle_t *handle = codec->private_info;
@@ -192,13 +181,13 @@
 		for (y = 0; y < handle->loops; y++) {
 			switch_bitpack_out(&handle->unpack, in[z++]);
 		}
-		for(y = 0; y < handle->bytes; y++) {
+		for (y = 0; y < handle->bytes; y++) {
 			*ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
-            new_len += 2;
+			new_len += 2;
 		}
 		switch_bitpack_done(&handle->unpack);
 	}
-	
+
 	if (new_len <= *decoded_data_len) {
 		*decoded_data_len = new_len;
 	} else {
@@ -213,239 +202,238 @@
 
 
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g726_16k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 127, 
-	/*.iananame */ "G726-16", 
+static const switch_codec_implementation_t g726_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 127,
+	/*.iananame */ "G726-16",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 16000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 40, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 16000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 40,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
 
-static const switch_codec_implementation_t g726_24k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 126, 
-	/*.iananame */ "G726-24", 
+static const switch_codec_implementation_t g726_24k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 126,
+	/*.iananame */ "G726-24",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 24000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 60, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t g726_32k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 2, 
-	/*.iananame */ "G726-32", 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 24000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 60,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t g726_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 2,
+	/*.iananame */ "G726-32",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 80, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t g726_40k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 125, 
-	/*.iananame */ "G726-40", 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 80,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t g726_40k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 125,
+	/*.iananame */ "G726-40",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 40000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 100, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
+	/*.bits_per_second */ 40000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 100,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
 
 
-static const switch_codec_implementation_t aal2_g726_16k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 124, 
-	/*.iananame */ "AAL2-G726-16", 
+static const switch_codec_implementation_t aal2_g726_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 124,
+	/*.iananame */ "AAL2-G726-16",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 16000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 40, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 16000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 40,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
 };
 
 
-static const switch_codec_implementation_t aal2_g726_24k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 123, 
-	/*.iananame */ "AAL2-G726-24", 
+static const switch_codec_implementation_t aal2_g726_24k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 123,
+	/*.iananame */ "AAL2-G726-24",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 24000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 60, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t aal2_g726_32k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 2, 
-	/*.iananame */ "AAL2-G726-32", 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 24000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 60,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t aal2_g726_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 2,
+	/*.iananame */ "AAL2-G726-32",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 80, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-static const switch_codec_implementation_t aal2_g726_40k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 122, 
-	/*.iananame */ "AAL2-G726-40", 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 80,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+static const switch_codec_implementation_t aal2_g726_40k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 122,
+	/*.iananame */ "AAL2-G726-40",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 40000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 100, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g726_init, 
-	/*.encode */ switch_g726_encode, 
-	/*.decode */ switch_g726_decode, 
-	/*.destroy */ switch_g726_destroy, 
-};
-
-const switch_codec_interface_t g726_16k_codec_interface = { 
-	/*.interface_name */ "G.726 16k", 
-	/*.implementations */ &g726_16k_implementation, 
-};
-
-const switch_codec_interface_t g726_24k_codec_interface = { 
-	/*.interface_name */ "G.726 24k", 
-	/*.implementations */ &g726_24k_implementation, 
+	/*.bits_per_second */ 40000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 100,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g726_init,
+	/*.encode */ switch_g726_encode,
+	/*.decode */ switch_g726_decode,
+	/*.destroy */ switch_g726_destroy,
+};
+
+const switch_codec_interface_t g726_16k_codec_interface = {
+	/*.interface_name */ "G.726 16k",
+	/*.implementations */ &g726_16k_implementation,
+};
+
+const switch_codec_interface_t g726_24k_codec_interface = {
+	/*.interface_name */ "G.726 24k",
+	/*.implementations */ &g726_24k_implementation,
 	/*.next */ &g726_16k_codec_interface
 };
 
-const switch_codec_interface_t g726_32k_codec_interface = { 
-	/*.interface_name */ "G.726 32k", 
-	/*.implementations */ &g726_32k_implementation, 
+const switch_codec_interface_t g726_32k_codec_interface = {
+	/*.interface_name */ "G.726 32k",
+	/*.implementations */ &g726_32k_implementation,
 	/*.next */ &g726_24k_codec_interface
 };
 
-const switch_codec_interface_t g726_40k_codec_interface = { 
-	/*.interface_name */ "G.726 40k", 
-	/*.implementations */ &g726_40k_implementation, 
+const switch_codec_interface_t g726_40k_codec_interface = {
+	/*.interface_name */ "G.726 40k",
+	/*.implementations */ &g726_40k_implementation,
 	/*.next */ &g726_32k_codec_interface
 };
 
 
 
-const switch_codec_interface_t aal2_g726_16k_codec_interface = { 
-	/*.interface_name */ "G.726 16k (aal2)", 
-	/*.implementations */ &aal2_g726_16k_implementation, 
+const switch_codec_interface_t aal2_g726_16k_codec_interface = {
+	/*.interface_name */ "G.726 16k (aal2)",
+	/*.implementations */ &aal2_g726_16k_implementation,
 	/*.next */ &g726_40k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_24k_codec_interface = { 
-	/*.interface_name */ "G.726 24k (aal2)", 
-	/*.implementations */ &aal2_g726_24k_implementation, 
+const switch_codec_interface_t aal2_g726_24k_codec_interface = {
+	/*.interface_name */ "G.726 24k (aal2)",
+	/*.implementations */ &aal2_g726_24k_implementation,
 	/*.next */ &aal2_g726_16k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_32k_codec_interface = { 
-	/*.interface_name */ "G.726 32k (aal2)", 
-	/*.implementations */ &aal2_g726_32k_implementation, 
+const switch_codec_interface_t aal2_g726_32k_codec_interface = {
+	/*.interface_name */ "G.726 32k (aal2)",
+	/*.implementations */ &aal2_g726_32k_implementation,
 	/*.next */ &aal2_g726_24k_codec_interface
 };
 
-const switch_codec_interface_t aal2_g726_40k_codec_interface = { 
-	/*.interface_name */ "G.726 40k (aal2)", 
-	/*.implementations */ &aal2_g726_40k_implementation, 
+const switch_codec_interface_t aal2_g726_40k_codec_interface = {
+	/*.interface_name */ "G.726 40k (aal2)",
+	/*.implementations */ &aal2_g726_40k_implementation,
 	/*.next */ &aal2_g726_32k_codec_interface
 };
 
 
 
-static switch_loadable_module_interface_t g726_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &aal2_g726_40k_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t g726_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &aal2_g726_40k_codec_interface,
+	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g726_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/mod_g729.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/mod_g729.c	Fri Mar 30 12:19:18 2007
@@ -30,7 +30,7 @@
  *
  * mod_g729.c -- G729 Codec Module
  *
- */  
+ */
 
 static const char modname[] = "mod_g729";
 
@@ -45,16 +45,15 @@
 };
 #endif
 
-static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 #ifdef G729_PASSTHROUGH
 	codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
-    if (codec->fmtp_in) {
-        codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-    }
+	if (codec->fmtp_in) {
+		codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+	}
 	return SWITCH_STATUS_SUCCESS;
-#else 
+#else
 	struct g729_context *context = NULL;
 	int encoding, decoding;
 
@@ -64,9 +63,9 @@
 	if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
 		return SWITCH_STATUS_FALSE;
 	} else {
-        if (codec->fmtp_in) {
-            codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
-        }
+		if (codec->fmtp_in) {
+			codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
+		}
 
 		if (encoding) {
 			g729_init_coder(&context->encoder_object, 0);
@@ -84,7 +83,7 @@
 #endif
 }
 
-static switch_status_t switch_g729_destroy(switch_codec_t *codec) 
+static switch_status_t switch_g729_destroy(switch_codec_t *codec)
 {
 #ifndef G729_PASSTHROUGH
 	codec->private_info = NULL;
@@ -92,17 +91,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_g729_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) 
+static switch_status_t switch_g729_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)
 {
 #ifdef G729_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -117,7 +111,7 @@
 
 	if (decoded_data_len % 160 == 0) {
 		uint32_t new_len = 0;
-		INT16 * ddp = decoded_data;
+		INT16 *ddp = decoded_data;
 		char *edp = encoded_data;
 		int x;
 		int loops = (int) decoded_data_len / 160;
@@ -140,17 +134,12 @@
 #endif
 }
 
-static switch_status_t switch_g729_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) 
+static switch_status_t switch_g729_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)
 {
 #ifdef G729_PASSTHROUGH
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -189,7 +178,7 @@
 			uint32_t new_len = 0;
 
 			test = (uint8_t *) encoded_data;
-			if (*test == 0 && *(test+1) == 0) {
+			if (*test == 0 && *(test + 1) == 0) {
 				*decoded_data_len = (encoded_data_len / divisor) * 160;
 				memset(decoded_data, 0, *decoded_data_len);
 				return SWITCH_STATUS_SUCCESS;
@@ -213,7 +202,7 @@
 				return SWITCH_STATUS_FALSE;
 
 			}
-		} 
+		}
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
 		return SWITCH_STATUS_FALSE;
@@ -222,46 +211,46 @@
 #endif
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t g729_10ms_8k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 18, 
-	/*.iananame */ "G729", 
+static const switch_codec_implementation_t g729_10ms_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 18,
+	/*.iananame */ "G729",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 32000, 
-	/*.microseconds_per_frame */ 10000, 
-	/*.samples_per_frame */ 80, 
-	/*.bytes_per_frame */ 160, 
-	/*.encoded_bytes_per_frame */ 10, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g729_init, 
-	/*.encode */ switch_g729_encode, 
-	/*.decode */ switch_g729_decode, 
-	/*.destroy */ switch_g729_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 32000,
+	/*.microseconds_per_frame */ 10000,
+	/*.samples_per_frame */ 80,
+	/*.bytes_per_frame */ 160,
+	/*.encoded_bytes_per_frame */ 10,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g729_init,
+	/*.encode */ switch_g729_encode,
+	/*.decode */ switch_g729_decode,
+	/*.destroy */ switch_g729_destroy,
 };
 
-static const switch_codec_implementation_t g729_8k_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 18, 
-	/*.iananame */ "G729", 
+static const switch_codec_implementation_t g729_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 18,
+	/*.iananame */ "G729",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000, 
-	/*.bits_per_second */ 64000, 
-	/*.microseconds_per_frame */ 20000, 
-	/*.samples_per_frame */ 160, 
-	/*.bytes_per_frame */ 320, 
-	/*.encoded_bytes_per_frame */ 20, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_g729_init, 
-	/*.encode */ switch_g729_encode, 
-	/*.decode */ switch_g729_decode, 
-	/*.destroy */ switch_g729_destroy, 
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 64000,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 20,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_g729_init,
+	/*.encode */ switch_g729_encode,
+	/*.decode */ switch_g729_decode,
+	/*.destroy */ switch_g729_destroy,
 	&g729_10ms_8k_implementation
 };
 
@@ -271,22 +260,21 @@
 	/*.next */ NULL
 };
 
-static switch_loadable_module_interface_t g729_module_interface = { 
+static switch_loadable_module_interface_t g729_module_interface = {
 	/*.module_name */ "g729",
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &g729_codec_interface, 
-	/*.application_interface */ NULL 
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &g729_codec_interface,
+	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &g729_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_gsm/mod_gsm.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_gsm/mod_gsm.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_gsm/mod_gsm.c	Fri Mar 30 12:19:18 2007
@@ -28,7 +28,7 @@
  *
  * mod_codec_gsm.c -- gsm Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "gsm.h"
 static const char modname[] = "mod_gsm";
@@ -36,8 +36,7 @@
 	gsm encoder;
 	gsm decoder;
 };
-static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	struct gsm_context *context;
 	int encoding, decoding;
@@ -55,7 +54,7 @@
 	codec->private_info = context;
 	return SWITCH_STATUS_SUCCESS;
 }
-static switch_status_t switch_gsm_destroy(switch_codec_t *codec) 
+static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
 {
 	struct gsm_context *context = codec->private_info;
 	int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
@@ -68,8 +67,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 static switch_status_t switch_gsm_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) 
+										 uint32_t decoded_data_len, 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;
 	if (!context) {
@@ -77,8 +76,8 @@
 	}
 	if (decoded_data_len % 320 == 0) {
 		uint32_t new_len = 0;
-		gsm_signal * ddp = decoded_data;
-		gsm_byte * edp = encoded_data;
+		gsm_signal *ddp = decoded_data;
+		gsm_byte *edp = encoded_data;
 		int x;
 		int loops = (int) decoded_data_len / 320;
 		for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
@@ -97,8 +96,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 static switch_status_t switch_gsm_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) 
+										 uint32_t encoded_data_len, 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;
 	if (!context) {
@@ -107,8 +106,8 @@
 
 	if (encoded_data_len % 33 == 0) {
 		int loops = (int) encoded_data_len / 33;
-		gsm_byte * edp = encoded_data;
-		gsm_signal * ddp = decoded_data;
+		gsm_byte *edp = encoded_data;
+		gsm_signal *ddp = decoded_data;
 		int x;
 		uint32_t new_len = 0;
 
@@ -131,47 +130,46 @@
 }
 
 
-/* Registration */ 
-static const switch_codec_implementation_t gsm_8k_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 3, 
-		/*.iananame */ "GSM", 
-		/*.fmtp */ NULL,
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ 13200, 
-		/*.microseconds_per_frame */ 20000, 
-		/*.samples_per_frame */ 160, 
-		/*.bytes_per_frame */ 320, 
-		/*.encoded_bytes_per_frame */ 33, 
-		/*.number_of_channels */ 1, 
-		/*.pref_frames_per_packet */ 1, 
-		/*.max_frames_per_packet */ 1, 
-		/*.init */ switch_gsm_init, 
-		/*.encode */ switch_gsm_encode, 
-		/*.decode */ switch_gsm_decode, 
-		/*.destroy */ switch_gsm_destroy, 
+/* Registration */
+static const switch_codec_implementation_t gsm_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 3,
+	/*.iananame */ "GSM",
+	/*.fmtp */ NULL,
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 13200,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 33,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_gsm_init,
+	/*.encode */ switch_gsm_encode,
+	/*.decode */ switch_gsm_decode,
+	/*.destroy */ switch_gsm_destroy,
 };
-static const switch_codec_interface_t gsm_codec_interface = { 
-		/*.interface_name */ "gsm", 
-		/*.implementations */ &gsm_8k_implementation, 
+static const switch_codec_interface_t gsm_codec_interface = {
+	/*.interface_name */ "gsm",
+	/*.implementations */ &gsm_8k_implementation,
 };
-static switch_loadable_module_interface_t gsm_module_interface = { 
-		/*.module_name */ modname, 
-		/*.endpoint_interface */ NULL, 
-		/*.timer_interface */ NULL, 
-		/*.dialplan_interface */ NULL, 
-		/*.codec_interface */ &gsm_codec_interface, 
-		/*.application_interface */ NULL 
+static switch_loadable_module_interface_t gsm_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &gsm_codec_interface,
+	/*.application_interface */ NULL
 };
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-														char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	
-		/* connect my internal structure to the blank pointer passed to me */ 
-		*module_interface = &gsm_module_interface;
-	
-		/* indicate that the module should continue to be loaded */ 
-		return SWITCH_STATUS_SUCCESS;
+
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &gsm_module_interface;
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
 }
 
 /* For Emacs:

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_ilbc/mod_ilbc.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_ilbc/mod_ilbc.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_ilbc/mod_ilbc.c	Fri Mar 30 12:19:18 2007
@@ -28,7 +28,7 @@
  *
  * mod_ilbc.c -- ilbc Codec Module
  *
- */  
+ */
 #include "switch.h"
 #include "iLBC_encode.h"
 #include "iLBC_decode.h"
@@ -44,12 +44,11 @@
 	uint16_t dbytes;
 };
 
-static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	struct ilbc_context *context;
 	int encoding, decoding;
-	uint8_t ms = (uint8_t)(codec->implementation->microseconds_per_frame / 1000);
+	uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_frame / 1000);
 
 
 	if (ms != 20 && ms != 30) {
@@ -82,13 +81,13 @@
 	}
 
 	codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->implementation->fmtp);
-	
+
 	codec->private_info = context;
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status_t switch_ilbc_destroy(switch_codec_t *codec) 
+static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
@@ -96,14 +95,11 @@
 
 
 static switch_status_t switch_ilbc_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)
 {
 	struct ilbc_context *context = codec->private_info;
 
@@ -120,7 +116,7 @@
 		float buf[240];
 
 		for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
-			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
+			for (y = 0; y < context->dbytes / sizeof(short); y++) {
 				buf[y] = ddp[y];
 			}
 			iLBC_encode(edp, buf, &context->encoder);
@@ -139,14 +135,11 @@
 }
 
 static switch_status_t switch_ilbc_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)
 {
 	struct ilbc_context *context = codec->private_info;
 
@@ -165,8 +158,8 @@
 
 		for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
 			iLBC_decode(buf, edp, &context->decoder, 1);
-			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
-				ddp[y] = (short)buf[y];
+			for (y = 0; y < context->dbytes / sizeof(short); y++) {
+				ddp[y] = (short) buf[y];
 			}
 			ddp += context->dbytes / sizeof(short);
 			edp += context->bytes;
@@ -186,153 +179,152 @@
 }
 
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t ilbc_8k_30ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=30",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
-		/*.microseconds_per_frame */ 30000,
-		/*.samples_per_frame */ 240,
-		/*.bytes_per_frame */ 480,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=30",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
-static const switch_codec_implementation_t ilbc_8k_20ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy,
-		/*.next */ &ilbc_8k_30ms_implementation
+static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy,
+	/*.next */ &ilbc_8k_30ms_implementation
 };
 
 
 
-static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 102, 
-		/*.iananame */ "iLBC", 
-		/*.fmtp */ "mode=30",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
-		/*.microseconds_per_frame */ 30000,
-		/*.samples_per_frame */ 240,
-		/*.bytes_per_frame */ 480,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 102,
+	/*.iananame */ "iLBC",
+	/*.fmtp */ "mode=30",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
+	/*.microseconds_per_frame */ 30000,
+	/*.samples_per_frame */ 240,
+	/*.bytes_per_frame */ 480,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
-static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 102, 
-		/*.iananame */ "iLBC102", 
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy,
-		/*.next */ &ilbc_102_8k_30ms_implementation
+static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 102,
+	/*.iananame */ "iLBC102",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy,
+	/*.next */ &ilbc_102_8k_30ms_implementation
 };
 
 
-static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = { 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 97, 
-		/*.iananame */ "iLBC20ms",
-		/*.fmtp */ "mode=20",
-		/*.samples_per_second */ 8000, 
-		/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS, 
-		/*.microseconds_per_frame */ 20000,
-		/*.samples_per_frame */ 160,
-		/*.bytes_per_frame */ 320,
-		/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS, 
-		/*.number_of_channels */ 1,
-		/*.pref_frames_per_packet */ 1,
-		/*.max_frames_per_packet */ 1,
-		/*.init */ switch_ilbc_init,
-		/*.encode */ switch_ilbc_encode,
-		/*.decode */ switch_ilbc_decode,
-		/*.destroy */ switch_ilbc_destroy
+static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 97,
+	/*.iananame */ "iLBC20ms",
+	/*.fmtp */ "mode=20",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
+	/*.microseconds_per_frame */ 20000,
+	/*.samples_per_frame */ 160,
+	/*.bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_ilbc_init,
+	/*.encode */ switch_ilbc_encode,
+	/*.decode */ switch_ilbc_decode,
+	/*.destroy */ switch_ilbc_destroy
 };
 
 
-static const switch_codec_interface_t ilbc_20ms_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_8k_20ms_nonext_implementation
+static const switch_codec_interface_t ilbc_20ms_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_8k_20ms_nonext_implementation
 };
 
-static const switch_codec_interface_t ilbc_102_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_102_8k_20ms_implementation, 
-		/*.next*/ &ilbc_20ms_codec_interface
+static const switch_codec_interface_t ilbc_102_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_102_8k_20ms_implementation,
+	/*.next */ &ilbc_20ms_codec_interface
 };
 
-static const switch_codec_interface_t ilbc_codec_interface = { 
-		/*.interface_name */ "ilbc", 
-		/*.implementations */ &ilbc_8k_20ms_implementation, 
-		/*.next*/ &ilbc_102_codec_interface
+static const switch_codec_interface_t ilbc_codec_interface = {
+	/*.interface_name */ "ilbc",
+	/*.implementations */ &ilbc_8k_20ms_implementation,
+	/*.next */ &ilbc_102_codec_interface
 };
 
 
-static switch_loadable_module_interface_t ilbc_module_interface = { 
-		/*.module_name */ modname, 
-		/*.endpoint_interface */ NULL, 
-		/*.timer_interface */ NULL, 
-		/*.dialplan_interface */ NULL, 
-		/*.codec_interface */ &ilbc_codec_interface, 
-		/*.application_interface */ NULL 
+static switch_loadable_module_interface_t ilbc_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &ilbc_codec_interface,
+	/*.application_interface */ NULL
 };
 
 
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-														char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	
-		/* connect my internal structure to the blank pointer passed to me */ 
-		*module_interface = &ilbc_module_interface;
-	
 
-		/* indicate that the module should continue to be loaded */ 
-		return SWITCH_STATUS_SUCCESS;
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &ilbc_module_interface;
+
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
 
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_l16/mod_l16.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_l16/mod_l16.c	Fri Mar 30 12:19:18 2007
@@ -34,8 +34,7 @@
 static const char modname[] = "mod_l16";
 
 
-static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									 const switch_codec_settings_t *codec_settings)
+static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	int encoding, decoding;
 
@@ -50,12 +49,11 @@
 }
 
 static switch_status_t switch_raw_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)
 {
 	/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
 	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
@@ -67,12 +65,11 @@
 }
 
 static switch_status_t switch_raw_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)
 {
 	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
 		memcpy(decoded_data, encoded_data, encoded_data_len);
@@ -107,7 +104,7 @@
 	/*.encode = */ switch_raw_encode,
 	/*.decode = */ switch_raw_decode,
 	/*.destroy = */ switch_raw_destroy
-	/*.next = */ 
+		/*.next = */
 };
 
 static const switch_codec_implementation_t raw_32k_30ms_implementation = {
@@ -298,6 +295,7 @@
 	/*.destroy = */ switch_raw_destroy,
 	/*.next = */ &raw_16k_20ms_implementation
 };
+
 ///////////////////////////////
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_lpc10/mod_lpc10.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_lpc10/mod_lpc10.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_lpc10/mod_lpc10.c	Fri Mar 30 12:19:18 2007
@@ -28,16 +28,16 @@
  *
  * mod_lpc10.c -- LPC10 Codec Module
  *
- */  
+ */
 
 #include "switch.h"
 #include "lpc10.h"
 
 enum {
 	SamplesPerFrame = 180,
-	BitsPerFrame    = 54,
-	BytesPerFrame   = (BitsPerFrame+7)/8,
-	BitsPerSecond   = 2400
+	BitsPerFrame = 54,
+	BytesPerFrame = (BitsPerFrame + 7) / 8,
+	BitsPerSecond = 2400
 };
 
 #define   SampleValueScale 32768.0
@@ -51,8 +51,7 @@
 	struct lpc10_decoder_state decoder_object;
 };
 
-static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									  const switch_codec_settings_t *codec_settings) 
+static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	uint32_t encoding, decoding;
 	struct lpc10_context *context = NULL;
@@ -78,44 +77,39 @@
 	}
 }
 
-static switch_status_t switch_lpc10_destroy(switch_codec_t *codec) 
+static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_lpc10_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) 
+static switch_status_t switch_lpc10_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)
 {
 	struct lpc10_context *context = codec->private_info;
 	uint8_t i;
 	int32_t bits[BitsPerFrame];
 	real speech[SamplesPerFrame];
-	const short *sampleBuffer = (const short *)decoded_data;
-	unsigned char *buffer = (unsigned char *)encoded_data;
+	const short *sampleBuffer = (const short *) decoded_data;
+	unsigned char *buffer = (unsigned char *) encoded_data;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
 
 	for (i = 0; i < SamplesPerFrame; i++)
-		speech[i] = (real)(sampleBuffer[i]/SampleValueScale);
+		speech[i] = (real) (sampleBuffer[i] / SampleValueScale);
 
 	lpc10_encode(speech, bits, &context->encoder_object);
 
 	memset(encoded_data, 0, BytesPerFrame);
 	for (i = 0; i < BitsPerFrame; i++) {
 		if (bits[i])
-			buffer[i>>3] |= 1 << (i&7);
+			buffer[i >> 3] |= 1 << (i & 7);
 	}
 
 	*encoded_data_len = BytesPerFrame;
@@ -123,91 +117,85 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t switch_lpc10_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) 
+static switch_status_t switch_lpc10_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)
 {
 	struct lpc10_context *context = codec->private_info;
 	int i;
 	INT32 bits[BitsPerFrame];
 	real speech[SamplesPerFrame];
-	short *sampleBuffer = (short *)decoded_data;
-	const unsigned char *buffer = (const unsigned char *)encoded_data;
+	short *sampleBuffer = (short *) decoded_data;
+	const unsigned char *buffer = (const unsigned char *) encoded_data;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
 
 	for (i = 0; i < BitsPerFrame; i++)
-		bits[i] = (buffer[i>>3]&(1<<(i&7))) != 0;
+		bits[i] = (buffer[i >> 3] & (1 << (i & 7))) != 0;
 
 	lpc10_decode(bits, speech, &context->decoder_object);
 
 	for (i = 0; i < SamplesPerFrame; i++) {
-		real sample = (real)(speech[i]*SampleValueScale);
+		real sample = (real) (speech[i] * SampleValueScale);
 		if (sample < MinSampleValue)
 			sample = MinSampleValue;
 		else if (sample > MaxSampleValue)
 			sample = MaxSampleValue;
-		sampleBuffer[i] = (short)sample;
+		sampleBuffer[i] = (short) sample;
 	}
 
-	*decoded_data_len = SamplesPerFrame*2;
+	*decoded_data_len = SamplesPerFrame * 2;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-/* Registration */ 
+/* Registration */
 
-static const switch_codec_implementation_t lpc10_implementation = { 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 7, 
-	/*.iananame */ "LPC", 
+static const switch_codec_implementation_t lpc10_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 7,
+	/*.iananame */ "LPC",
 	/*.fmtp */ NULL,
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 240, 
-	/*.microseconds_per_frame */ 22500, 
-	/*.samples_per_frame */ 180, 
-	/*.bytes_per_frame */ 360, 
-	/*.encoded_bytes_per_frame */ 7, 
-	/*.number_of_channels */ 1, 
-	/*.pref_frames_per_packet */ 1, 
-	/*.max_frames_per_packet */ 1, 
-	/*.init */ switch_lpc10_init, 
-	/*.encode */ switch_lpc10_encode, 
-	/*.decode */ switch_lpc10_decode, 
-	/*.destroy */ switch_lpc10_destroy, 
+	/*.bits_per_second */ 240,
+	/*.microseconds_per_frame */ 22500,
+	/*.samples_per_frame */ 180,
+	/*.bytes_per_frame */ 360,
+	/*.encoded_bytes_per_frame */ 7,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_lpc10_init,
+	/*.encode */ switch_lpc10_encode,
+	/*.decode */ switch_lpc10_decode,
+	/*.destroy */ switch_lpc10_destroy,
 };
 
-const switch_codec_interface_t lpc10_codec_interface = { 
-	/*.interface_name */ "LPC-10 2.4kbps", 
-	/*.implementations */ &lpc10_implementation, 
+const switch_codec_interface_t lpc10_codec_interface = {
+	/*.interface_name */ "LPC-10 2.4kbps",
+	/*.implementations */ &lpc10_implementation,
 };
 
-static switch_loadable_module_interface_t lpc10_module_interface = { 
-	/*.module_name */ modname, 
-	/*.endpoint_interface */ NULL, 
-	/*.timer_interface */ NULL, 
-	/*.dialplan_interface */ NULL, 
-	/*.codec_interface */ &lpc10_codec_interface, 
-	/*.application_interface */ NULL 
+static switch_loadable_module_interface_t lpc10_module_interface = {
+	/*.module_name */ modname,
+	/*.endpoint_interface */ NULL,
+	/*.timer_interface */ NULL,
+	/*.dialplan_interface */ NULL,
+	/*.codec_interface */ &lpc10_codec_interface,
+	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
-													 char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	/* connect my internal structure to the blank pointer passed to me */ 
+	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &lpc10_module_interface;
 
-	/* indicate that the module should continue to be loaded */ 
+	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_speex/mod_speex.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_speex/mod_speex.c	Fri Mar 30 12:19:18 2007
@@ -72,8 +72,7 @@
 	int decoder_mode;
 };
 
-static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags,
-									   const switch_codec_settings_t *codec_settings)
+static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
 {
 	struct speex_context *context = NULL;
 	int encoding, decoding;
@@ -111,17 +110,14 @@
 			speex_encoder_ctl(context->encoder_state, SPEEX_GET_FRAME_SIZE, &context->encoder_frame_size);
 			speex_encoder_ctl(context->encoder_state, SPEEX_SET_COMPLEXITY, &codec->codec_settings.complexity);
 			if (codec->codec_settings.preproc) {
-				context->pp =
-					speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
+				context->pp = speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
 				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_VAD, &codec->codec_settings.pp_vad);
 				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC, &codec->codec_settings.pp_agc);
 				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &codec->codec_settings.pp_agc_level);
 				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DENOISE, &codec->codec_settings.pp_denoise);
 				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB, &codec->codec_settings.pp_dereverb);
-				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY,
-									 &codec->codec_settings.pp_dereverb_decay);
-				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL,
-									 &codec->codec_settings.pp_dereverb_level);
+				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &codec->codec_settings.pp_dereverb_decay);
+				speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &codec->codec_settings.pp_dereverb_level);
 			}
 
 			if (!codec->codec_settings.abr && !codec->codec_settings.vbr) {
@@ -158,12 +154,11 @@
 }
 
 static switch_status_t switch_speex_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)
 {
 	struct speex_context *context = codec->private_info;
 	short *buf;
@@ -211,12 +206,11 @@
 }
 
 static switch_status_t switch_speex_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)
 {
 	struct speex_context *context = codec->private_info;
 	short *buf;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	Fri Mar 30 12:19:18 2007
@@ -46,12 +46,12 @@
 } globals;
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_directory_name, globals.directory_name)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
 
-static void load_config(void)
+	 static void load_config(void)
 {
 	char *cf = "dialplan_directory.conf";
 	switch_xml_t cfg, xml, settings, param;
@@ -100,19 +100,14 @@
 	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);
-	
-	
-	if (! (globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
+					  caller_profile->destination_number);
+
+
+	if (!(globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
 		return NULL;
 	}
 
-	if (switch_core_directory_open(&dh, 
-								   globals.directory_name,
-								   globals.host,
-								   globals.dn,
-								   globals.pass,
-								   NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_directory_open(&dh, globals.directory_name, globals.host, globals.dn, globals.pass, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
 		return NULL;
 	}
@@ -127,10 +122,9 @@
 	while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {
 		while (switch_core_directory_next_pair(&dh, &var, &val) == SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DIRECTORY VALUE [%s]=[%s]\n", var, val);
-			if(!strcasecmp(var, "callflow")) {
+			if (!strcasecmp(var, "callflow")) {
 				if (!extension) {
-					if ((extension = switch_caller_extension_new(session, caller_profile->destination_number,
-																  caller_profile->destination_number)) == 0) {
+					if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
 						goto out;
 					}
@@ -143,11 +137,11 @@
 			}
 		}
 	}
- out:
-	
+  out:
+
 	switch_core_directory_close(&dh);
 
-	
+
 	if (extension) {
 		switch_channel_set_state(channel, CS_EXECUTE);
 	}
@@ -159,7 +153,7 @@
 static const switch_dialplan_interface_t directory_dialplan_interface = {
 	/*.interface_name = */ "directory",
 	/*.hunt_function = */ directory_dialplan_hunt
-	/*.next = NULL */
+		/*.next = NULL */
 };
 
 static const switch_loadable_module_interface_t directory_dialplan_module_interface = {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Fri Mar 30 12:19:18 2007
@@ -50,7 +50,7 @@
 	switch_channel_t *channel;
 	char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
 	int proceed = 0;
-    switch_stream_handle_t stream = {0};
+	switch_stream_handle_t stream = { 0 };
 
 	channel = switch_core_session_get_channel(session);
 	caller_profile = switch_channel_get_caller_profile(channel);
@@ -63,7 +63,7 @@
 		switch_regex_t *re = NULL;
 		int ovector[30];
 		break_t do_break_i = BREAK_ON_FALSE;
-		
+
 		field = (char *) switch_xml_attr(xcond, "field");
 
 		expression = (char *) switch_xml_attr_soft(xcond, "expression");
@@ -83,32 +83,32 @@
 		if (field) {
 			if (*field == '$') {
 				char *cmd = switch_core_session_strdup(session, field + 1);
-				char *e, *arg;                
-                field = cmd;
-                field_data = "";
-
-                if (*field == '{') {
-                    field++;
-                    if ((e = strchr(field, '}'))) {
-                        *e = '\0';
-                        field_data = switch_channel_get_variable(channel, field);
-                    }
-                } else {
-                    switch_safe_free(stream.data);
-                    memset(&stream, 0, sizeof(stream));
-                    SWITCH_STANDARD_STREAM(stream);
-
-                    if ((arg = strchr(cmd, '('))) {
-                        *arg++ = '\0';
-                        if ((e = strchr(arg, ')'))) {
-                            *e = '\0';
-                            if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
-                                field_data = stream.data;
-                            }
-                        }
-                    }
-                }
-            } else {
+				char *e, *arg;
+				field = cmd;
+				field_data = "";
+
+				if (*field == '{') {
+					field++;
+					if ((e = strchr(field, '}'))) {
+						*e = '\0';
+						field_data = switch_channel_get_variable(channel, field);
+					}
+				} else {
+					switch_safe_free(stream.data);
+					memset(&stream, 0, sizeof(stream));
+					SWITCH_STANDARD_STREAM(stream);
+
+					if ((arg = strchr(cmd, '('))) {
+						*arg++ = '\0';
+						if ((e = strchr(arg, ')'))) {
+							*e = '\0';
+							if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
+								field_data = stream.data;
+							}
+						}
+					}
+				}
+			} else {
 				field_data = switch_caller_get_field_by_name(caller_profile, field);
 			}
 			if (!field_data) {
@@ -119,18 +119,17 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
 
 				for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
-					char *application = (char*) switch_xml_attr_soft(xaction, "application");
+					char *application = (char *) switch_xml_attr_soft(xaction, "application");
 					char *data = (char *) switch_xml_attr_soft(xaction, "data");
 
 					if (!*extension) {
-						if ((*extension =
-							 switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
+						if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                            proceed = 0;
-                            goto done;
+							proceed = 0;
+							goto done;
 						}
 					}
-					
+
 					switch_caller_extension_add_application(session, *extension, application, data);
 				}
 
@@ -145,20 +144,20 @@
 
 
 		for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
-			char *application = (char*) switch_xml_attr_soft(xaction, "application");
+			char *application = (char *) switch_xml_attr_soft(xaction, "application");
 			char *data = (char *) switch_xml_attr_soft(xaction, "data");
 			char *substituted = NULL;
-            uint32_t len = 0;
+			uint32_t len = 0;
 			char *app_data = NULL;
 
 			if (field && strchr(expression, '(')) {
-                len = (uint32_t)(strlen(data) + strlen(field_data) + 10);
-                if (!(substituted = malloc(len))) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                    proceed = 0;
-                    goto done;
-                }
-                memset(substituted, 0, len);
+				len = (uint32_t) (strlen(data) + strlen(field_data) + 10);
+				if (!(substituted = malloc(len))) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+					proceed = 0;
+					goto done;
+				}
+				memset(substituted, 0, len);
 				switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
 				app_data = substituted;
 			} else {
@@ -166,18 +165,17 @@
 			}
 
 			if (!*extension) {
-				if ((*extension =
-					 switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
+				if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
-                    proceed = 0;
-                    goto done;
+					proceed = 0;
+					goto done;
 				}
 			}
 
 			switch_caller_extension_add_application(session, *extension, application, app_data);
-            switch_safe_free(substituted);
+			switch_safe_free(substituted);
 		}
-        
+
 		switch_regex_safe_free(re);
 
 		if (do_break_i == BREAK_ON_TRUE || do_break_i == BREAK_ALWAYS) {
@@ -185,110 +183,109 @@
 		}
 	}
 
- done:
-    switch_safe_free(stream.data);
+  done:
+	switch_safe_free(stream.data);
 	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_status_t status = SWITCH_STATUS_GENERR;
 	switch_channel_t *channel;
-    switch_stream_handle_t stream = {0};
-    switch_size_t encode_len = 1024, new_len = 0;
-    char *encode_buf = NULL;
-    char *prof[12] = {0}, *prof_names[12] = {0}, *e = NULL;
-    switch_hash_index_t *hi;
-    uint32_t x = 0;
+	switch_stream_handle_t stream = { 0 };
+	switch_size_t encode_len = 1024, new_len = 0;
+	char *encode_buf = NULL;
+	char *prof[12] = { 0 }, *prof_names[12] = {
+	0}, *e = NULL;
+	switch_hash_index_t *hi;
+	uint32_t x = 0;
 
 	channel = switch_core_session_get_channel(session);
 
-    SWITCH_STANDARD_STREAM(stream);
-    
-    if (!(encode_buf = malloc(encode_len))) {
-        goto done;
-    }
-    
-    prof[0] = caller_profile->context;
-    prof[1] = caller_profile->destination_number;
-    prof[2] = caller_profile->caller_id_name;
-    prof[3] = caller_profile->caller_id_number;
-    prof[4] = caller_profile->network_addr;
-    prof[5] = caller_profile->ani;
-    prof[6] = caller_profile->aniii;
-    prof[7] = caller_profile->rdnis;
-    prof[8] = caller_profile->source;
-    prof[9] = caller_profile->chan_name;
-    prof[10] = caller_profile->uuid;
-
-    prof_names[0] = "context";
-    prof_names[1] = "destination_number";
-    prof_names[2] = "caller_id_name";
-    prof_names[3] = "caller_id_number";
-    prof_names[4] = "network_addr";
-    prof_names[5] = "ani";
-    prof_names[6] = "aniii";
-    prof_names[7] = "rdnis";
-    prof_names[8] = "source";
-    prof_names[9] = "chan_name";
-    prof_names[10] = "uuid";
+	SWITCH_STANDARD_STREAM(stream);
+
+	if (!(encode_buf = malloc(encode_len))) {
+		goto done;
+	}
+
+	prof[0] = caller_profile->context;
+	prof[1] = caller_profile->destination_number;
+	prof[2] = caller_profile->caller_id_name;
+	prof[3] = caller_profile->caller_id_number;
+	prof[4] = caller_profile->network_addr;
+	prof[5] = caller_profile->ani;
+	prof[6] = caller_profile->aniii;
+	prof[7] = caller_profile->rdnis;
+	prof[8] = caller_profile->source;
+	prof[9] = caller_profile->chan_name;
+	prof[10] = caller_profile->uuid;
+
+	prof_names[0] = "context";
+	prof_names[1] = "destination_number";
+	prof_names[2] = "caller_id_name";
+	prof_names[3] = "caller_id_number";
+	prof_names[4] = "network_addr";
+	prof_names[5] = "ani";
+	prof_names[6] = "aniii";
+	prof_names[7] = "rdnis";
+	prof_names[8] = "source";
+	prof_names[9] = "chan_name";
+	prof_names[10] = "uuid";
 
-    for (x = 0; prof[x]; x++) {
+	for (x = 0; prof[x]; x++) {
 		if (switch_strlen_zero(prof[x])) {
 			continue;
 		}
-        new_len = (strlen(prof[x]) * 3) + 1;
-        if (encode_len < new_len) {
-            char *tmp;
-            
-            encode_len = new_len;
-
-            if (!(tmp = realloc(encode_buf, encode_len))) {
-                goto done;
-            }
-
-            encode_buf = tmp;
-        }
-        switch_url_encode(prof[x], encode_buf, encode_len - 1);
-        stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
-    }
+		new_len = (strlen(prof[x]) * 3) + 1;
+		if (encode_len < new_len) {
+			char *tmp;
+
+			encode_len = new_len;
+
+			if (!(tmp = realloc(encode_buf, encode_len))) {
+				goto done;
+			}
+
+			encode_buf = tmp;
+		}
+		switch_url_encode(prof[x], encode_buf, encode_len - 1);
+		stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
+	}
 
 
 	for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
-        void *val;
-        const void *var;
+		void *val;
+		const void *var;
 		switch_hash_this(hi, &var, NULL, &val);
-        
-        new_len = (strlen((char *) var) * 3) + 1;
-        if (encode_len < new_len) {
-            char *tmp;
-            
-            encode_len = new_len;
-
-            if (!(tmp = realloc(encode_buf, encode_len))) {
-                goto done;
-            }
-
-            encode_buf = tmp;
-        }
-
-        switch_url_encode((char *) val, encode_buf, encode_len - 1);
-        stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
-        
-	}
-    
-    e = (char *)stream.data + (strlen((char *)stream.data) - 1);
-
-    if (e && *e == '&') {
-        *e = '\0';
-    }
+
+		new_len = (strlen((char *) var) * 3) + 1;
+		if (encode_len < new_len) {
+			char *tmp;
+
+			encode_len = new_len;
+
+			if (!(tmp = realloc(encode_buf, encode_len))) {
+				goto done;
+			}
+
+			encode_buf = tmp;
+		}
+
+		switch_url_encode((char *) val, encode_buf, encode_len - 1);
+		stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
+
+	}
+
+	e = (char *) stream.data + (strlen((char *) stream.data) - 1);
+
+	if (e && *e == '&') {
+		*e = '\0';
+	}
 
 	status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, stream.data);
 
-done:
+  done:
 	switch_safe_free(stream.data);
 	switch_safe_free(encode_buf);
 	return status;
@@ -300,7 +297,7 @@
 	switch_caller_extension_t *extension = NULL;
 	switch_channel_t *channel;
 	switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
-    char *alt_path = (char *) arg;
+	char *alt_path = (char *) arg;
 
 	channel = switch_core_session_get_channel(session);
 
@@ -313,47 +310,45 @@
 		goto done;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
-					  caller_profile->destination_number);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name, caller_profile->destination_number);
 
 	/* get our handle to the "dialplan" section of the config */
 
 	if (!switch_strlen_zero(alt_path)) {
-        switch_xml_t conf = NULL, tag = NULL;
-        if (!(alt_root = switch_xml_parse_file(alt_path))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
-            goto done;
-        }
-        
-		if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) && 
-			(tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n", alt_path);
-            xml = alt_root;
-            cfg = tag;
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
-            goto done;
-        }
+		switch_xml_t conf = NULL, tag = NULL;
+		if (!(alt_root = switch_xml_parse_file(alt_path))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
+			goto done;
+		}
+
+		if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) && (tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n", alt_path);
+			xml = alt_root;
+			cfg = tag;
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
+			goto done;
+		}
 	} else {
 		if (dialplan_xml_locate(session, caller_profile, &xml, &cfg) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
 			goto done;
 		}
-    }
-    
-    /* get a handle to the context tag */
+	}
+
+	/* get a handle to the context tag */
 	if (!(xcontext = switch_xml_find_child(cfg, "context", "name", caller_profile->context))) {
 		if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", caller_profile->context);
 			goto done;
 		}
 	}
-	
+
 	if (!(xexten = switch_xml_find_child(xcontext, "extension", "name", caller_profile->destination_number))) {
 		xexten = switch_xml_child(xcontext, "extension");
 	}
-	
-	while(xexten) {
+
+	while (xexten) {
 		int proceed = 0;
 		char *cont = (char *) switch_xml_attr_soft(xexten, "continue");
 
@@ -374,7 +369,7 @@
 		switch_channel_set_state(channel, CS_EXECUTE);
 	}
 
-done:
+  done:
 	switch_xml_free(xml);
 	return extension;
 }
@@ -383,7 +378,7 @@
 static const switch_dialplan_interface_t dialplan_interface = {
 	/*.interface_name = */ "XML",
 	/*.hunt_function = */ dialplan_hunt
-	/*.next = NULL */
+		/*.next = NULL */
 };
 
 static const switch_loadable_module_interface_t dialplan_module_interface = {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/directories/mod_ldap/mod_ldap.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/directories/mod_ldap/mod_ldap.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/directories/mod_ldap/mod_ldap.c	Fri Mar 30 12:19:18 2007
@@ -44,10 +44,10 @@
 
 struct ldap_context {
 	LDAP *ld;
-	LDAPMessage* msg;
-	LDAPMessage* entry;
-	BerElement* ber;
-	char* attr;
+	LDAPMessage *msg;
+	LDAPMessage *entry;
+	BerElement *ber;
+	char *attr;
 	char *var;
 	char *val;
 	char **vals;
@@ -60,14 +60,14 @@
 static switch_status_t mod_ldap_open(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd)
 {
 	struct ldap_context *context;
-	int  auth_method = LDAP_AUTH_SIMPLE;
+	int auth_method = LDAP_AUTH_SIMPLE;
 	int desired_version = LDAP_VERSION3;
 
 	if ((context = switch_core_alloc(dh->memory_pool, sizeof(*context))) == 0) {
 		return SWITCH_STATUS_MEMERR;
 	}
-	
-	if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL ) {
+
+	if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -76,11 +76,11 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS ) {
+	if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	
+
 	dh->private_info = context;
 
 	return SWITCH_STATUS_SUCCESS;
@@ -112,7 +112,7 @@
 	if (ldap_count_entries(context->ld, context->msg) <= 0) {
 		return SWITCH_STATUS_FALSE;
 	}
-	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -161,7 +161,7 @@
 		*val = context->val;
 		return SWITCH_STATUS_SUCCESS;
 	} else {
-	itter:
+	  itter:
 		if (context->attr && context->vals) {
 			if ((*val = context->vals[context->vi++])) {
 				*var = context->attr;
@@ -177,7 +177,7 @@
 			ldap_memfree(context->val);
 			context->val = NULL;
 			if (context->ber) {
-				ber_free(context->ber,0);
+				ber_free(context->ber, 0);
 				context->ber = NULL;
 			}
 			context->attr = ldap_first_attribute(context->ld, context->entry, &context->ber);
@@ -192,18 +192,18 @@
 			goto itter;
 		}
 	}
-	
+
 	return SWITCH_STATUS_FALSE;
 }
 
 
 static const switch_directory_interface_t ldap_directory_interface = {
-    /*.interface_name */ "ldap",
-	/*.directory_open*/ mod_ldap_open,
-	/*.directory_close*/ mod_ldap_close,
-	/*.directory_query*/ mod_ldap_query,
-	/*.directory_next*/ mod_ldap_next,
-	/*.directory_next_pair*/ mod_ldap_next_pair
+	/*.interface_name */ "ldap",
+	/*.directory_open */ mod_ldap_open,
+	/*.directory_close */ mod_ldap_close,
+	/*.directory_query */ mod_ldap_query,
+	/*.directory_next */ mod_ldap_next,
+	/*.directory_next_pair */ mod_ldap_next_pair
 };
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Fri Mar 30 12:19:18 2007
@@ -45,12 +45,9 @@
 static switch_memory_pool_t *module_pool = NULL;
 
 static char sub_sql[] =
-"CREATE TABLE subscriptions (\n"
-"   sub_from            VARCHAR(255),\n"
-"   sub_to          VARCHAR(255),\n"
-"   show          VARCHAR(255),\n"
-"   status          VARCHAR(255)\n"
-");\n";
+	"CREATE TABLE subscriptions (\n"
+	"   sub_from            VARCHAR(255),\n" "   sub_to          VARCHAR(255),\n" "   show          VARCHAR(255),\n" "   status          VARCHAR(255)\n"
+	");\n";
 
 
 typedef enum {
@@ -65,16 +62,16 @@
 	TFLAG_CODEC_READY = (1 << 8),
 	TFLAG_TRANSPORT = (1 << 9),
 	TFLAG_ANSWER = (1 << 10),
-	TFLAG_VAD_IN = ( 1 << 11),
-	TFLAG_VAD_OUT = ( 1 << 12),
-	TFLAG_VAD = ( 1 << 13),
-	TFLAG_DO_CAND = ( 1 << 14),
+	TFLAG_VAD_IN = (1 << 11),
+	TFLAG_VAD_OUT = (1 << 12),
+	TFLAG_VAD = (1 << 13),
+	TFLAG_DO_CAND = (1 << 14),
 	TFLAG_DO_DESC = (1 << 15),
 	TFLAG_LANADDR = (1 << 16),
 	TFLAG_AUTO = (1 << 17),
 	TFLAG_DTMF = (1 << 18),
-	TFLAG_TIMER = ( 1 << 19),
-	TFLAG_TERM = ( 1 << 20),
+	TFLAG_TIMER = (1 << 19),
+	TFLAG_TERM = (1 << 20),
 	TFLAG_TRANSPORT_ACCEPT = (1 << 21),
 	TFLAG_READY = (1 << 22),
 } TFLAGS;
@@ -97,28 +94,28 @@
 	switch_hash_t *profile_hash;
 	int running;
 	int handles;
-    char guess_ip[80];
+	char guess_ip[80];
 } globals;
 
 struct mdl_profile {
-    char *name;
-    char *login;
-    char *password;
-    char *message;
+	char *name;
+	char *login;
+	char *password;
+	char *message;
 	char *auto_reply;
-    char *dialplan;
-    char *ip;
-    char *extip;
-    char *lanaddr;
+	char *dialplan;
+	char *ip;
+	char *extip;
+	char *lanaddr;
 	char *server;
-    char *exten;
-    char *context;
+	char *exten;
+	char *context;
 	char *timer_name;
 	char *dbname;
 	switch_mutex_t *mutex;
-    ldl_handle_t *handle;
-    uint32_t flags;
-    uint32_t user_flags;
+	ldl_handle_t *handle;
+	uint32_t flags;
+	uint32_t user_flags;
 };
 
 struct private_object {
@@ -170,32 +167,32 @@
 
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
 
-static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
-static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
-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_ring(switch_core_session_t *session);
-static switch_status_t channel_on_loopback(switch_core_session_t *session);
-static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
-													switch_core_session_t **new_session, switch_memory_pool_t **pool);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										  switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										   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, char *to, char *from, char *subject, char *msg);
-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);
+	 static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 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_ring(switch_core_session_t *session);
+	 static switch_status_t channel_on_loopback(switch_core_session_t *session);
+	 static switch_status_t channel_on_transmit(switch_core_session_t *session);
+	 static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+														 switch_caller_profile_t *outbound_profile,
+														 switch_core_session_t **new_session, switch_memory_pool_t **pool);
+	 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, 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,
+										 char *to, char *from, char *subject, char *msg);
+	 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);
 
 #define is_special(s) (s && (strstr(s, "ext+") || strstr(s, "user+")))
 
-static char *translate_rpid(char *in, char *ext)
+	 static char *translate_rpid(char *in, char *ext)
 {
 	char *r = NULL;
 
@@ -210,7 +207,7 @@
 	if (!in) {
 		return NULL;
 	}
-	
+
 	if (!strcasecmp(in, "busy")) {
 		r = "dnd";
 	}
@@ -228,7 +225,7 @@
 	} else if (ext && !strcasecmp(ext, "away")) {
 		r = "away";
 	}
-	
+
 	return r;
 }
 
@@ -242,7 +239,7 @@
 	char *rpid = argv[3];
 	char *status = argv[4];
 	//char *proto = argv[5];
-	
+
 	if (switch_strlen_zero(type)) {
 		type = NULL;
 	} else if (!strcasecmp(type, "unavailable")) {
@@ -283,10 +280,10 @@
 {
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *proto = switch_event_get_header(event, "proto");
 	char *from = switch_event_get_header(event, "from");
-	char *status= switch_event_get_header(event, "status");
+	char *status = switch_event_get_header(event, "status");
 	char *rpid = switch_event_get_header(event, "rpid");
 	char *type = switch_event_get_header(event, "event_subtype");
 	char *sql;
@@ -306,35 +303,35 @@
 		status = NULL;
 	}
 
-	switch(event->event_id) {
-	case SWITCH_EVENT_PRESENCE_PROBE: 
-        if (proto) {
-        	char *sql;
-            switch_core_db_t *db;
-            char *errmsg;
-            char *to = switch_event_get_header(event, "to");
-            char *f_host = NULL;
-            if (to) {
-                if ((f_host = strchr(to, '@'))) {
-                    f_host++;
-                }
-            }
-
-            if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
-                if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
-                    if (!(db = switch_core_db_open_file(profile->dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                        return;
-                    }
-                    switch_mutex_lock(profile->mutex);
-                    switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
-                    switch_mutex_unlock(profile->mutex);
-                    switch_core_db_close(db);
-                    switch_safe_free(sql);
-                }
-            }
-        }
-        return;
+	switch (event->event_id) {
+	case SWITCH_EVENT_PRESENCE_PROBE:
+		if (proto) {
+			char *sql;
+			switch_core_db_t *db;
+			char *errmsg;
+			char *to = switch_event_get_header(event, "to");
+			char *f_host = NULL;
+			if (to) {
+				if ((f_host = strchr(to, '@'))) {
+					f_host++;
+				}
+			}
+
+			if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
+				if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
+					if (!(db = switch_core_db_open_file(profile->dbname))) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+						return;
+					}
+					switch_mutex_lock(profile->mutex);
+					switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
+					switch_mutex_unlock(profile->mutex);
+					switch_core_db_close(db);
+					switch_safe_free(sql);
+				}
+			}
+		}
+		return;
 	case SWITCH_EVENT_PRESENCE_IN:
 		if (!status) {
 			status = "Available";
@@ -346,7 +343,7 @@
 	default:
 		break;
 	}
-	
+
 
 	if (!type) {
 		type = "";
@@ -357,20 +354,19 @@
 	if (!status) {
 		status = "Away";
 	}
-	
 
-	sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'", 
-						 type, rpid, status, proto, from);
-	
-	
+
+	sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
+
+
 	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -383,7 +379,7 @@
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 
 	}
 
@@ -400,9 +396,9 @@
 	if (from && (f_user = strdup(from))) {
 		if ((f_host = strchr(f_user, '@'))) {
 			*f_host++ = '\0';
-            if ((f_resource = strchr(f_host, '/'))) {
-                *f_resource++ = '\0';
-            }
+			if ((f_resource = strchr(f_host, '/'))) {
+				*f_resource++ = '\0';
+			}
 		}
 	}
 
@@ -412,7 +408,7 @@
 		}
 
 		if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
-			
+
 			if (!strcmp(proto, MDL_CHAT_PROTO)) {
 				from = hint;
 			} else {
@@ -439,12 +435,12 @@
 
 static void roster_event_handler(switch_event_t *event)
 {
-	char *status= switch_event_get_header(event, "status");
-	char *from= switch_event_get_header(event, "from");
+	char *status = switch_event_get_header(event, "status");
+	char *from = switch_event_get_header(event, "from");
 	char *event_type = switch_event_get_header(event, "event_type");
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *sql;
 	switch_core_db_t *db;
 
@@ -453,7 +449,7 @@
 	}
 
 	if (switch_strlen_zero(event_type)) {
-		event_type="presence";
+		event_type = "presence";
 	}
 
 	if (from) {
@@ -464,12 +460,12 @@
 
 	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -482,7 +478,7 @@
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 	}
 
 	switch_safe_free(sql);
@@ -498,7 +494,7 @@
 
 
 	ldl_handle_send_presence(profile->handle, sub_to, sub_from, "unavailable", "dnd", "Bub-Bye");
-	
+
 	return 0;
 }
 
@@ -510,12 +506,12 @@
 
 	//char *sub_from = argv[0];
 	char *sub_to = argv[1];
-	
+
 	if (is_special(sub_to)) {
 		if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  sub_to);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", sub_to);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "available");
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Online");
 			switch_event_fire(&event);
@@ -529,22 +525,22 @@
 {
 	struct mdl_profile *profile = NULL;
 	switch_hash_index_t *hi;
-    void *val;
+	void *val;
 	char *sql;
 	switch_core_db_t *db;
 
 
 	sql = switch_mprintf("select * from subscriptions");
-	
+
 
 	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 		char *errmsg;
-        switch_hash_this(hi, NULL, NULL, &val);
-        profile = (struct mdl_profile *) val;
+		switch_hash_this(hi, NULL, NULL, &val);
+		profile = (struct mdl_profile *) val;
 
-        if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
+		if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
 			continue;
-        }
+		}
 
 
 		if (sql) {
@@ -557,9 +553,9 @@
 			switch_mutex_unlock(profile->mutex);
 			switch_core_db_close(db);
 		}
-		
+
 	}
-	
+
 	switch_yield(1000000);
 	switch_safe_free(sql);
 
@@ -590,9 +586,9 @@
 		switch_channel_t *channel = switch_core_session_get_channel(*session);
 		switch_channel_state_t state = switch_channel_get_state(channel);
 		struct private_object *tech_pvt = NULL;
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line, switch_channel_state_name(state));
- 
+
 		tech_pvt = switch_core_session_get_private(*session);
 
 		if (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY)) {
@@ -601,14 +597,14 @@
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_TERM)) {
-			/*once is enough*/
+			/*once is enough */
 			return;
 		}
 
 		if (state < CS_HANGUP) {
 			switch_channel_hangup(channel, cause);
 		}
-		
+
 		switch_mutex_lock(tech_pvt->flag_mutex);
 		switch_set_flag(tech_pvt, TFLAG_TERM);
 		switch_set_flag(tech_pvt, TFLAG_BYE);
@@ -626,7 +622,7 @@
 	char data[1024];
 
 	va_start(ap, fmt);
-	
+
 	vsnprintf(data, sizeof(data), fmt, ap);
 	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s", data);
 
@@ -641,9 +637,7 @@
 	if (!tech_pvt->num_codecs) {
 		if (globals.codec_string) {
 			if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
-																				 SWITCH_MAX_CODECS,
-																				 globals.codec_order,
-																				 globals.codec_order_last)) <= 0) {
+																				 SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 				return 0;
 			}
@@ -659,7 +653,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;
 	struct mdl_profile *profile = NULL;
@@ -674,15 +668,15 @@
 	globals.handles--;
 	ldl_handle_destroy(&handle);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name, profile->login);
-	
+
 	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;
-	
+
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -702,10 +696,10 @@
 		return 1;
 	}
 
-    if (!(tech_pvt->remote_ip && tech_pvt->remote_port)) {
+	if (!(tech_pvt->remote_ip && tech_pvt->remote_port)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No valid candidates received!\n");
-        return 0;
-    }
+		return 0;
+	}
 
 	if (switch_core_codec_init(&tech_pvt->read_codec,
 							   tech_pvt->codec_name,
@@ -722,9 +716,9 @@
 	tech_pvt->read_frame.rate = tech_pvt->read_codec.implementation->samples_per_second;
 	tech_pvt->read_frame.codec = &tech_pvt->read_codec;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n", 
-					  tech_pvt->codec_name, (int)tech_pvt->read_codec.implementation->samples_per_second);
-	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Read Codec to %s@%d\n",
+					  tech_pvt->codec_name, (int) tech_pvt->read_codec.implementation->samples_per_second);
+
 	if (switch_core_codec_init(&tech_pvt->write_codec,
 							   tech_pvt->codec_name,
 							   NULL,
@@ -737,20 +731,21 @@
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return 0;
 	}
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",  
-					  tech_pvt->codec_name,(int)tech_pvt->write_codec.implementation->samples_per_second);
-							
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",
+					  tech_pvt->codec_name, (int) tech_pvt->write_codec.implementation->samples_per_second);
+
 	switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
 	switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
-	
 
-	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);
-	
+
+	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_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ;
 	//flags = SWITCH_RTP_FLAG_AUTOADJ;
 
 	if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
-	  flags |= SWITCH_RTP_FLAG_USE_TIMER;
+		flags |= SWITCH_RTP_FLAG_USE_TIMER;
 	}
 
 	flags |= SWITCH_RTP_FLAG_AUTO_CNG;
@@ -760,12 +755,9 @@
 												 tech_pvt->remote_ip,
 												 tech_pvt->remote_port,
 												 tech_pvt->codec_num,
-                                                 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+												 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
 												 tech_pvt->read_codec.implementation->microseconds_per_frame,
-												 flags,
-												 NULL,
-												 tech_pvt->profile->timer_name,
-												 &err, switch_core_session_get_pool(tech_pvt->session)))) {
+												 flags, NULL, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return 0;
@@ -818,10 +810,10 @@
 
 		cand[0].port = tech_pvt->local_port;
 		cand[0].address = advip;
-				
+
 		if (!strncasecmp(advip, "stun:", 5)) {
 			char *stun_ip = advip + 5;
-					
+
 			if (tech_pvt->stun_ip) {
 				cand[0].address = tech_pvt->stun_ip;
 				cand[0].port = tech_pvt->stun_port;
@@ -834,12 +826,9 @@
 
 				cand[0].address = tech_pvt->profile->ip;
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address, cand[0].port);
-				if (switch_stun_lookup(&cand[0].address,
-									   &cand[0].port,
-									   stun_ip,
-									   SWITCH_STUN_DEFAULT_PORT,
-									   &err,
-									   switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+				if (switch_stun_lookup
+					(&cand[0].address, &cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err,
+					 switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return 0;
@@ -912,12 +901,12 @@
 			tech_pvt->codec_rate = tech_pvt->codecs[0]->samples_per_second;
 			tech_pvt->r_codec_num = tech_pvt->codecs[0]->ianacode;
 			tech_pvt->codec_index = 0;
-					
+
 			payloads[0].name = lame(tech_pvt->codecs[0]->iananame);
 			payloads[0].id = tech_pvt->codecs[0]->ianacode;
 			payloads[0].rate = tech_pvt->codecs[0]->samples_per_second;
 			payloads[0].bps = tech_pvt->codecs[0]->bits_per_second;
-			
+
 		} else {
 			payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
 			payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
@@ -925,12 +914,13 @@
 			payloads[0].bps = tech_pvt->codecs[tech_pvt->codec_index]->bits_per_second;
 		}
 
-				
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s@%d]\n", payloads[0].name, payloads[0].rate);
-		tech_pvt->desc_id = ldl_session_describe(tech_pvt->dlsession, payloads, 1,
-												 switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
+		tech_pvt->desc_id =
+			ldl_session_describe(tech_pvt->dlsession, payloads, 1,
+								 switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT);
 		switch_set_flag_locked(tech_pvt, TFLAG_CODEC_READY);
-	} 
+	}
 	switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
 	return 1;
 }
@@ -957,7 +947,7 @@
 	/* jingle has no ringing indication so we will just pretend that we got one */
 	switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 	switch_channel_mark_ring_ready(channel);
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 		tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT;
 		tech_pvt->next_desc = switch_time_now();
@@ -966,63 +956,62 @@
 		tech_pvt->next_desc = switch_time_now() + DL_CAND_WAIT;
 	}
 
-	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) &&
-			 switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
+	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)
+			 && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
 		now = switch_time_now();
-		elapsed = (unsigned int)((now - started) / 1000);
+		elapsed = (unsigned int) ((now - started) / 1000);
 
 		if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
 			goto out;
 		}
 
-		
+
 		if (now >= tech_pvt->next_desc) {
 			if (!do_describe(tech_pvt, 0)) {
 				goto out;
 			}
 		}
-		
+
 		if (tech_pvt->next_cand && now >= tech_pvt->next_cand) {
 			if (!do_candidates(tech_pvt, 0)) {
 				goto out;
 			}
 		}
 		if (elapsed > 60000) {
-			terminate_session(&tech_pvt->session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+			terminate_session(&tech_pvt->session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 			switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 			goto done;
 		}
-		if (switch_test_flag(tech_pvt, TFLAG_BYE) || ! switch_test_flag(tech_pvt, TFLAG_IO)) {
+		if (switch_test_flag(tech_pvt, TFLAG_BYE) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
 			goto done;
 		}
 		switch_yield(1000);
 	}
-	
+
 	if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
 		goto out;
-	}	
+	}
 
 	if (!activate_rtp(tech_pvt)) {
 		goto out;
 	}
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 		if (!do_candidates(tech_pvt, 0)) {
 			goto out;
 		}
 		switch_channel_answer(channel);
-	} 
+	}
 	ret = SWITCH_STATUS_SUCCESS;
 
 	goto done;
-	
- out:
-	terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- done:
+
+  out:
+	terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+  done:
 
 	return ret;
 }
@@ -1065,7 +1054,7 @@
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
-	
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1093,7 +1082,7 @@
 {
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1105,12 +1094,11 @@
 	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
 	/* 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");
+	   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");
 	}
 	if (tech_pvt->dlsession) {
 		if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
@@ -1144,42 +1132,42 @@
 	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
-    if (!(channel = switch_core_session_get_channel(session))) {
-        return SWITCH_STATUS_SUCCESS;
-    }
-
-    if (!(tech_pvt = switch_core_session_get_private(session))) {
-        return SWITCH_STATUS_SUCCESS;
-    }
-    
-
-    switch (sig) {
-    case SWITCH_SIG_KILL:
-        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-        switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-
-        if (tech_pvt->dlsession) {
-            if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
-                ldl_session_terminate(tech_pvt->dlsession);
-                switch_set_flag_locked(tech_pvt, TFLAG_TERM);
-            }
-            ldl_session_destroy(&tech_pvt->dlsession);
-            
-        }
-
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
-            switch_rtp_kill_socket(tech_pvt->rtp_session);
-        }
-        break;
+	if (!(channel = switch_core_session_get_channel(session))) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (!(tech_pvt = switch_core_session_get_private(session))) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+
+		if (tech_pvt->dlsession) {
+			if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
+				ldl_session_terminate(tech_pvt->dlsession);
+				switch_set_flag_locked(tech_pvt, TFLAG_TERM);
+			}
+			ldl_session_destroy(&tech_pvt->dlsession);
+
+		}
+
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
+			switch_rtp_kill_socket(tech_pvt->rtp_session);
+		}
+		break;
 	case SWITCH_SIG_BREAK:
-        if (switch_rtp_ready(tech_pvt->rtp_session)) {
+		if (switch_rtp_ready(tech_pvt->rtp_session)) {
 			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
 		}
 		break;
-    }
+	}
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1227,14 +1215,11 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%s]\n", dtmf);
 
-	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
-									dtmf,
-									100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
+	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session, dtmf, 100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
 
 }
 
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										  switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 	uint32_t bytes = 0;
@@ -1268,11 +1253,12 @@
 	ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
 	tech_pvt->read_frame.datalen = 0;
 
-	
-	while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
+
+	while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO)
+		   && tech_pvt->read_frame.datalen == 0) {
 		tech_pvt->read_frame.flags = 0;
 		status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
-		
+
 		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
 			return SWITCH_STATUS_FALSE;
 		}
@@ -1295,19 +1281,19 @@
 		}
 
 		if (tech_pvt->read_frame.datalen > 0) {
-            if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
-                if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame && bytes) {
-                    bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-                    frames = (tech_pvt->read_frame.datalen / bytes);
-                } else {
-                    frames = 1;
-                }
-                samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
-                ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
-                tech_pvt->timestamp_recv += (int32_t) samples;
-                tech_pvt->read_frame.samples = (int) samples;
-                tech_pvt->last_read = tech_pvt->read_frame.datalen;
-            }
+			if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+				if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame && bytes) {
+					bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+					frames = (tech_pvt->read_frame.datalen / bytes);
+				} else {
+					frames = 1;
+				}
+				samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+				ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
+				tech_pvt->timestamp_recv += (int32_t) samples;
+				tech_pvt->read_frame.samples = (int) samples;
+				tech_pvt->last_read = tech_pvt->read_frame.datalen;
+			}
 			break;
 		}
 
@@ -1322,8 +1308,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										   switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	struct private_object *tech_pvt;
 	switch_channel_t *channel = NULL;
@@ -1362,7 +1347,7 @@
 	samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 	tech_pvt->timestamp_send += samples;
 	if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, 0) < 0) {
-		terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+		terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -1391,16 +1376,16 @@
 {
 	switch_channel_t *channel;
 	struct private_object *tech_pvt;
-			
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
-	  if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+		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);
@@ -1423,14 +1408,14 @@
 static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
 {
 	switch_channel_t *channel;
-    struct private_object *tech_pvt;
+	struct private_object *tech_pvt;
 	char *subject, *body;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    tech_pvt = switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 
 	if (!(body = switch_event_get_body(event))) {
@@ -1464,8 +1449,8 @@
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
 	/*.send_dtmf */ channel_send_dtmf,
-	/*.receive_message*/ channel_receive_message,
-	/*.receive_event*/ channel_receive_event
+	/*.receive_message */ channel_receive_message,
+	/*.receive_event */ channel_receive_event
 };
 
 static const switch_endpoint_interface_t channel_endpoint_interface = {
@@ -1508,17 +1493,17 @@
 	/*.application_interface */ NULL,
 	/*.api_interface */ &login_api_interface,
 	/*.file_interface */ NULL,
-    /*.speech_interface */ NULL,
-    /*.directory_interface */ NULL,
-    /*.chat_interface */ &channel_chat_interface
-
+	/*.speech_interface */ NULL,
+	/*.directory_interface */ NULL,
+	/*.chat_interface */ &channel_chat_interface
 };
 
 
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
@@ -1544,7 +1529,7 @@
 			*callto++ = '\0';
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid URL!\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
 		}
 
@@ -1552,9 +1537,9 @@
 			*dnis++ = '\0';
 		}
 
-        for (p = callto; p && *p; p++) {
-            *p = (char) tolower(*p);
-        }
+		for (p = callto; p && *p; p++) {
+			*p = (char) tolower(*p);
+		}
 
 		if ((p = strchr(profile_name, '@'))) {
 			*p++ = '\0';
@@ -1574,28 +1559,28 @@
 						user = ubuf;
 					} else {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid User!\n");
-						terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					}
 				}
 			}
 
 			if (!ldl_handle_ready(mdl_profile->handle)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! we are not logged in yet!\n");
-				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 			}
 			if (!(full_id = ldl_handle_probe(mdl_profile->handle, callto, user, idbuf, sizeof(idbuf)))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Recipient!\n");
-				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_NO_USER_RESPONSE);
+				terminate_session(new_session, __LINE__, SWITCH_CAUSE_NO_USER_RESPONSE);
 				return SWITCH_CAUSE_NO_USER_RESPONSE;
 			}
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Profile!\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
-		
-		
+
+
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
 			memset(tech_pvt, 0, sizeof(*tech_pvt));
@@ -1611,13 +1596,13 @@
 			tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
 
 		if (outbound_profile) {
 			char name[128];
-			
+
 			snprintf(name, sizeof(name), "DingaLing/%s", outbound_profile->destination_number);
 			switch_channel_set_name(channel, name);
 
@@ -1626,7 +1611,7 @@
 			tech_pvt->caller_profile = caller_profile;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! no caller profile\n");
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		}
 
@@ -1637,7 +1622,7 @@
 		tech_pvt->us = switch_core_session_strdup(*new_session, user);
 		tech_pvt->them = switch_core_session_strdup(*new_session, full_id);
 		ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, user, LDL_FLAG_OUTBOUND);
-		
+
 		if (session) {
 			switch_channel_t *calling_channel = switch_core_session_get_channel(session);
 			cid_msg = switch_channel_get_variable(calling_channel, "dl_cid_msg");
@@ -1669,8 +1654,8 @@
 		ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
 		tech_pvt->dlsession = dlsession;
 		if (!get_codecs(tech_pvt)) {
-			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
-            return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+			terminate_session(new_session, __LINE__, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
+			return SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL;
 		}
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_CAUSE_SUCCESS;
@@ -1705,7 +1690,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_CONNECTED);
 		return SWITCH_STATUS_GENERR;
 	}
-	
+
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
@@ -1721,7 +1706,8 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, roster_event_handler, NULL)
+		!= SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -1733,7 +1719,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;
@@ -1743,18 +1729,11 @@
 
 static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
 {
-	if (profile &&
-		profile->login &&
-		profile->password &&
-		profile->dialplan &&
-		profile->message &&
-		profile->ip &&
-		profile->name &&
-		profile->exten) {
+	if (profile && profile->login && profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten) {
 		ldl_handle_t *handle;
 
 		if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
-			profile->timer_name = switch_core_strdup(module_pool, "soft");			
+			profile->timer_name = switch_core_strdup(module_pool, "soft");
 		}
 
 		if (login) {
@@ -1762,12 +1741,7 @@
 								profile->login,
 								profile->password,
 								profile->server,
-								profile->user_flags,
-								profile->message,
-								handle_loop,
-								handle_signalling,
-								handle_response,
-								profile) == LDL_STATUS_SUCCESS) {
+								profile->user_flags, profile->message, handle_loop, handle_signalling, handle_response, profile) == LDL_STATUS_SUCCESS) {
 				profile->handle = handle;
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Started Thread for %s@%s\n", profile->login, profile->dialplan);
 				switch_core_hash_insert(globals.profile_hash, profile->name, profile);
@@ -1778,7 +1752,7 @@
 			switch_core_hash_insert(globals.profile_hash, profile->name, profile);
 		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 						  "Invalid Profile\n"
 						  "login[%s]\n"
 						  "pass[%s]\n"
@@ -1786,13 +1760,7 @@
 						  "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,
+						  "exten[%s]\n", profile->login, profile->password, profile->dialplan, profile->message, profile->ip, profile->name,
 						  profile->exten);
 
 		return SWITCH_STATUS_FALSE;
@@ -1812,7 +1780,7 @@
 		while (globals.handles > 0) {
 			switch_yield(100000);
 			x++;
-			if(x > 10) {
+			if (x > 10) {
 				break;
 			}
 		}
@@ -1826,13 +1794,13 @@
 
 static void set_profile_val(struct mdl_profile *profile, char *var, char *val)
 {
-	
+
 	if (!strcasecmp(var, "login")) {
 		profile->login = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "password")) {
 		profile->password = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
-	  	switch_set_flag(profile, TFLAG_TIMER);
+		switch_set_flag(profile, TFLAG_TIMER);
 	} else if (!strcasecmp(var, "dialplan")) {
 		profile->dialplan = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "auto-reply")) {
@@ -1908,7 +1876,7 @@
 
 static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	char *argv[10] = {0};
+	char *argv[10] = { 0 };
 	int argc = 0;
 	char *var, *val, *myarg;
 	struct mdl_profile *profile = NULL;
@@ -1918,10 +1886,10 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-    if (switch_strlen_zero(arg)) {
-        stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
-        return SWITCH_STATUS_SUCCESS;
-    }
+	if (switch_strlen_zero(arg)) {
+		stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax);
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	myarg = strdup(arg);
 
@@ -1947,7 +1915,7 @@
 	} else {
 		profile = switch_core_alloc(module_pool, sizeof(*profile));
 
-		for(x = 0; x < argc; x++) {
+		for (x = 0; x < argc; x++) {
 			var = argv[x];
 			if ((val = strchr(var, '='))) {
 				*val++ = '\0';
@@ -1955,7 +1923,7 @@
 			}
 		}
 	}
-	
+
 
 	if (profile && init_profile(profile, 1) == SWITCH_STATUS_SUCCESS) {
 		stream->write_function(stream, "OK\n");
@@ -1975,10 +1943,10 @@
 
 	memset(&globals, 0, sizeof(globals));
 	globals.running = 1;
-    
-    switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
 
-	switch_core_hash_init(&globals.profile_hash, module_pool);	
+	switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
+
+	switch_core_hash_init(&globals.profile_hash, module_pool);
 
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -1994,16 +1962,14 @@
 				globals.debug = atoi(val);
 			} else if (!strcasecmp(var, "codec-prefs")) {
 				set_global_codec_string(val);
-				globals.codec_order_last =
-					switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
+				globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
 			} else if (!strcasecmp(var, "codec-rates")) {
 				set_global_codec_rates_string(val);
-				globals.codec_rates_last =
-					switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
+				globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
 			}
 		}
 	}
-	
+
 	if (!(xmlint = switch_xml_child(cfg, "profile"))) {
 		if ((xmlint = switch_xml_child(cfg, "interface"))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "!!!!!!! DEPRICATION WARNING 'interface' is now 'profile' !!!!!!!\n");
@@ -2022,7 +1988,7 @@
 				globals.init = 1;
 			}
 
-			if(!profile) {
+			if (!profile) {
 				profile = switch_core_alloc(module_pool, sizeof(*profile));
 			}
 			set_profile_val(profile, var, val);
@@ -2081,7 +2047,7 @@
 }
 
 
-static void execute_sql(char *dbname, char *sql, switch_mutex_t *mutex)
+static void execute_sql(char *dbname, char *sql, switch_mutex_t * mutex)
 {
 	switch_core_db_t *db;
 
@@ -2093,17 +2059,17 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", dbname);
 		goto end;
 	}
-	
+
 	switch_core_db_persistant_execute(db, sql, 25);
 	switch_core_db_close(db);
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
 }
 
-static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
+static void do_vcard(ldl_handle_t * handle, char *to, char *from, char *id)
 {
 	char *params = NULL, *real_to, *to_user, *xmlstr = NULL, *to_host = NULL;
 	switch_xml_t domain, xml = NULL, user, vcard;
@@ -2123,22 +2089,18 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		goto end;
 	}
-	
+
 	if (!to_host) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Missing Host!\n");
 		goto end;
 	}
 
-	if (!(params = switch_mprintf("to=%s@%s&from=%s&object=vcard",
-								  to_user,
-								  to_host,
-								  from
-								  ))) {
+	if (!(params = switch_mprintf("to=%s@%s&from=%s&object=vcard", to_user, to_host, from))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		goto end;
 	}
 
-	
+
 	if (switch_xml_locate("directory", "domain", "name", to_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", to_user, to_host);
 		goto end;
@@ -2162,19 +2124,21 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 	}
 
- end:
-	if (xml) switch_xml_free(xml);
+  end:
+	if (xml)
+		switch_xml_free(xml);
 	switch_safe_free(to_user);
 	switch_safe_free(params);
 	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)
 {
 	struct mdl_profile *profile = NULL;
 	switch_core_session_t *session = NULL;
 	switch_channel_t *channel = NULL;
-    struct private_object *tech_pvt = NULL;
+	struct private_object *tech_pvt = NULL;
 	switch_event_t *event;
 	ldl_status status = LDL_STATUS_SUCCESS;
 	char *sql;
@@ -2189,7 +2153,7 @@
 
 	if (!dlsession) {
 		if (profile->user_flags & LDL_FLAG_COMPONENT) {
-			switch(dl_signal) {
+			switch (dl_signal) {
 			case LDL_SIGNAL_VCARD:
 				do_vcard(handle, to, from, subject);
 				break;
@@ -2203,7 +2167,7 @@
 				break;
 
 			case LDL_SIGNAL_SUBSCRIBE:
-				
+
 				if ((sql = switch_mprintf("delete from subscriptions where sub_from='%q' and sub_to='%q';\n"
 										  "insert into subscriptions values('%q','%q','%q','%q');\n", from, to, from, to, msg, subject))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
@@ -2213,13 +2177,12 @@
 				if (is_special(to)) {
 					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
 				}
-
 #if 0
 				if (is_special(to)) {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
 						//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
 						switch_event_fire(&event);
@@ -2236,34 +2199,34 @@
 				break;
 			case LDL_SIGNAL_PRESENCE_PROBE:
 				if (is_special(to)) {
-                    ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
-                } else {
+					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
+				} else {
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", from);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s", to);
 						switch_event_fire(&event);
 					}
-                }
-                break;
+				}
+				break;
 			case LDL_SIGNAL_PRESENCE_IN:
-				
+
 				if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
 				}
-				
+
 				if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  from);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", from);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "%s", msg);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "%s", subject);
 					switch_event_fire(&event);
 				}
 
-				
+
 				if (is_special(to)) {
 					ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call");
 				}
@@ -2272,7 +2235,7 @@
 					if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
-						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s",  to);
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s", to);
 						//switch_event_add_header(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
 						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Click To Call");
 						switch_event_fire(&event);
@@ -2282,7 +2245,7 @@
 				break;
 
 			case LDL_SIGNAL_PRESENCE_OUT:
-				
+
 				if ((sql = switch_mprintf("update subscriptions set show='%q', status='%q' where sub_from='%q'", msg, subject, from))) {
 					execute_sql(profile->dbname, sql, profile->mutex);
 					switch_core_db_free(sql);
@@ -2297,48 +2260,48 @@
 			default:
 				break;
 			}
-		} 
+		}
 
-		switch(dl_signal) {
-		case LDL_SIGNAL_MSG: {
-			switch_chat_interface_t *ci;
-			char *proto = MDL_CHAT_PROTO;
-			char *pproto = NULL, *ffrom = NULL;
-			char *hint;
-
-			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 (strchr(to, '+')) {
-				pproto = strdup(to);
-				if ((to = strchr(pproto, '+'))) {
-					*to++ = '\0';
+		switch (dl_signal) {
+		case LDL_SIGNAL_MSG:{
+				switch_chat_interface_t *ci;
+				char *proto = MDL_CHAT_PROTO;
+				char *pproto = NULL, *ffrom = NULL;
+				char *hint;
+
+				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 (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) {
@@ -2364,12 +2327,12 @@
 			break;
 		default:
 			break;
-			
+
 		}
 		status = LDL_STATUS_SUCCESS;
 		goto done;
 	}
-	
+
 
 	if ((session = ldl_session_get_private(dlsession))) {
 		tech_pvt = switch_core_session_get_private(session);
@@ -2377,7 +2340,7 @@
 
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
-		
+
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n", ldl_session_get_id(dlsession));
 
 		if (switch_channel_get_state(channel) >= CS_HANGUP) {
@@ -2394,7 +2357,7 @@
 		}
 		if ((session = switch_core_session_request(&channel_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) {
 				memset(tech_pvt, 0, sizeof(*tech_pvt));
 				switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
@@ -2411,7 +2374,7 @@
 				switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hey where is my memory pool?\n");
-				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				status = LDL_STATUS_FALSE;
 				goto done;
 			}
@@ -2428,9 +2391,9 @@
 
 	}
 
-	switch(dl_signal) {
+	switch (dl_signal) {
 	case LDL_SIGNAL_MSG:
-		if (msg) { 
+		if (msg) {
 			if (*msg == '+') {
 				switch_channel_queue_dtmf(channel, msg + 1);
 				switch_set_flag_locked(tech_pvt, TFLAG_DTMF);
@@ -2444,12 +2407,12 @@
 		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
 			char *hint = NULL, *p, *freeme = NULL;
 
-			hint = from;			
+			hint = from;
 			if (strchr(from, '/')) {
 				freeme = strdup(from);
 				p = strchr(freeme, '/');
 				*p = '\0';
-				from = freeme;				
+				from = freeme;
 			}
 
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
@@ -2482,7 +2445,7 @@
 				if (!strcasecmp(msg, "accept")) {
 					switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
 					if (!do_candidates(tech_pvt, 0)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
@@ -2496,42 +2459,43 @@
 
 
 			if (!get_codecs(tech_pvt)) {
-				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				status = LDL_STATUS_FALSE;
 				goto done;
 			}
 
-			
+
 			if (ldl_session_get_payloads(dlsession, &payloads, &len) == LDL_STATUS_SUCCESS) {
-                unsigned int x, y;
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u payloads\n", len);
-				for(x = 0; x < len; x++) {
+				unsigned int x, y;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u payloads\n", len);
+				for (x = 0; x < len; x++) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
-					for(y = 0; y < tech_pvt->num_codecs; y++) {
+					for (y = 0; y < tech_pvt->num_codecs; y++) {
 						char *name = tech_pvt->codecs[y]->iananame;
 
 						if (!strncasecmp(name, "ilbc", 4)) {
 							name = "ilbc";
 						}
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n", 
-                                          payloads[x].name, payloads[x].id, payloads[x].rate,
-                                          name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "compare %s %d/%d to %s %d/%d\n",
+										  payloads[x].name, payloads[x].id, payloads[x].rate,
+										  name, tech_pvt->codecs[y]->ianacode, tech_pvt->codecs[y]->samples_per_second);
 						if (tech_pvt->codecs[y]->ianacode > 95) {
 							match = strcasecmp(name, payloads[x].name) ? 0 : 1;
 						} else {
 							match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0;
 						}
-						
+
 						if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) {
 							tech_pvt->codec_index = y;
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name, payloads[x].id);
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name,
+											  payloads[x].id);
 							tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
 							tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
-							tech_pvt->r_codec_num = (switch_payload_t)(payloads[x].id);
+							tech_pvt->r_codec_num = (switch_payload_t) (payloads[x].id);
 							tech_pvt->codec_rate = payloads[x].rate;
 							if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 								if (!do_describe(tech_pvt, 0)) {
-									terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+									terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 									status = LDL_STATUS_FALSE;
 									goto done;
 								}
@@ -2543,14 +2507,14 @@
 				}
 				if (!match && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 					if (!do_describe(tech_pvt, 0)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
 				}
 			}
 		}
-		
+
 		break;
 	case LDL_SIGNAL_CANDIDATES:
 		if (dl_signal) {
@@ -2566,41 +2530,30 @@
 				goto done;
 			}
 
-				
+
 			if (tech_pvt->remote_ip) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already picked an IP [%s]\n", tech_pvt->remote_ip);
 				break;
 			}
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
-			for(x = 0; x < len; x++) {
+			for (x = 0; x < len; x++) {
 				uint8_t lanaddr = 0;
 
 				if (profile->lanaddr) {
 					lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
-				} 
+				}
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
-					
-				if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && 
-					((profile->lanaddr && lanaddr) ||
-					 (strncasecmp(candidates[x].address, "10.", 3) && 
-					  strncasecmp(candidates[x].address, "192.168.", 8) &&
-					  strncasecmp(candidates[x].address, "127.", 4) &&
-					  strncasecmp(candidates[x].address, "255.", 4) &&
-					  strncasecmp(candidates[x].address, "0.", 2) &&
-					  strncasecmp(candidates[x].address, "1.", 2) &&
-					  strncasecmp(candidates[x].address, "2.", 2) &&
-					  strncasecmp(candidates[x].address, "172.16.", 7) &&
-					  strncasecmp(candidates[x].address, "172.17.", 7) &&
-					  strncasecmp(candidates[x].address, "172.18.", 7) &&
-					  strncasecmp(candidates[x].address, "172.19.", 7) &&
-					  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)  && // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
-					  strncasecmp(candidates[x].address, "169.254.", 8)
-					  ))) {
+
+				if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && ((profile->lanaddr && lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && strncasecmp(candidates[x].address, "192.168.", 8) && strncasecmp(candidates[x].address, "127.", 4) && strncasecmp(candidates[x].address, "255.", 4) && strncasecmp(candidates[x].address, "0.", 2) && strncasecmp(candidates[x].address, "1.", 2) && strncasecmp(candidates[x].address, "2.", 2) && strncasecmp(candidates[x].address, "172.16.", 7) && strncasecmp(candidates[x].address, "172.17.", 7) && strncasecmp(candidates[x].address, "172.18.", 7) && strncasecmp(candidates[x].address, "172.19.", 7) && 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) &&	// 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
+																																															  strncasecmp
+																																															  (candidates
+																																															   [x].
+																																															   address,
+																																															   "169.254.",
+																																															   8)
+																																							))) {
 					ldl_payload_t payloads[5];
 					char *exten;
 					char *context;
@@ -2638,7 +2591,7 @@
 							}
 						}
 					}
-						
+
 					if (!(context = ldl_session_get_value(dlsession, "context"))) {
 						context = profile->context;
 					}
@@ -2655,7 +2608,7 @@
 					if (profile->context && !strcmp(profile->context, "_auto_")) {
 						context = profile->name;
 					}
-			
+
 					tech_pvt->them = switch_core_session_strdup(session, ldl_session_get_callee(dlsession));
 					tech_pvt->us = switch_core_session_strdup(session, ldl_session_get_caller(dlsession));
 
@@ -2673,22 +2626,23 @@
 
 						switch_safe_free(tmp);
 					}
-						
+
 					if (!tech_pvt->caller_profile) {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating an identity for %s %s <%s> %s\n", 
-										  ldl_session_get_id(dlsession), cid_name, cid_num, exten);
-			
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+										  "Creating an identity for %s %s <%s> %s\n", ldl_session_get_id(dlsession), cid_name, cid_num, exten);
+
 						if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																				  ldl_handle_get_login(profile->handle),
 																				  profile->dialplan,
 																				  cid_name,
 																				  cid_num,
 																				  ldl_session_get_ip(dlsession),
-																				  ldl_session_get_value(dlsession, "ani"),
-																				  ldl_session_get_value(dlsession, "aniii"),
-																				  ldl_session_get_value(dlsession, "rdnis"),
-																				  (char *)modname,
-																				  context,
+																				  ldl_session_get_value(dlsession,
+																										"ani"),
+																				  ldl_session_get_value(dlsession,
+																										"aniii"),
+																				  ldl_session_get_value(dlsession,
+																										"rdnis"), (char *) modname, context,
 																				  exten)) != 0) {
 							char name[128];
 							snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
@@ -2698,32 +2652,32 @@
 					}
 
 					switch_safe_free(them);
-						
+
 					if (lanaddr) {
 						switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
 					}
 
 					if (!get_codecs(tech_pvt)) {
-						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 						status = LDL_STATUS_FALSE;
 						goto done;
 					}
 
-						
+
 					tech_pvt->remote_ip = switch_core_session_strdup(session, candidates[x].address);
 					ldl_session_set_ip(dlsession, tech_pvt->remote_ip);
 					tech_pvt->remote_port = candidates[x].port;
 					tech_pvt->remote_user = switch_core_session_strdup(session, candidates[x].username);
 
-						
+
 					if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 						if (!do_candidates(tech_pvt, 0)) {
-							terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+							terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 							status = LDL_STATUS_FALSE;
 							goto done;
 						}
 					}
-						
+
 					status = LDL_STATUS_SUCCESS;
 					goto done;
 				}
@@ -2731,18 +2685,18 @@
 		}
 		break;
 	case LDL_SIGNAL_REJECT:
-        if (channel) {
+		if (channel) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "reject %s\n", switch_channel_get_name(channel));
-			terminate_session(&session,  __LINE__, SWITCH_CAUSE_CALL_REJECTED);
+			terminate_session(&session, __LINE__, SWITCH_CAUSE_CALL_REJECTED);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call (Rejected)\n");
 			goto done;
 		}
-        break;
+		break;
 	case LDL_SIGNAL_ERROR:
 	case LDL_SIGNAL_TERMINATE:
 		if (channel) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hungup %s\n", switch_channel_get_name(channel));
-			terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+			terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call\n");
 			goto done;
 		}
@@ -2753,12 +2707,12 @@
 		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/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c	Fri Mar 30 12:19:18 2007
@@ -98,13 +98,12 @@
 
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
 
 
-	 static char *IAXNAMES[] =
-		 { "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
+	 static char *IAXNAMES[] = { "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
 		 "IAX_EVENT_DTMF", "IAX_EVENT_TIMEOUT", "IAX_EVENT_LAGRQ", "IAX_EVENT_LAGRP", "IAX_EVENT_RINGA",
 		 "IAX_EVENT_PING", "IAX_EVENT_PONG", "IAX_EVENT_BUSY", "IAX_EVENT_ANSWER", "IAX_EVENT_IMAGE",
 		 "IAX_EVENT_AUTHRQ", "IAX_EVENT_AUTHRP", "IAX_EVENT_REGREQ", "IAX_EVENT_REGACK",
@@ -209,9 +208,8 @@
 	IAX_QUERY = 2
 } iax_io_t;
 
-static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *iax_session,
-								   unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
-								   iax_io_t io)
+static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *iax_session,
+									 unsigned int *format, unsigned int *cababilities, unsigned short *samprate, iax_io_t io)
 {
 	char *dname = NULL;
 	//int rate = 8000;
@@ -224,16 +222,11 @@
 	uint32_t interval = 0;
 
 	if (globals.codec_string) {
-		if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
-																	SWITCH_MAX_CODECS,
-																	globals.codec_order,
-																	globals.codec_order_last)) <= 0) {
+		if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 			return SWITCH_STATUS_GENERR;
 		}
-	} else
-		if (((num_codecs =
-			 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) {
+	} else if (((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -244,7 +237,7 @@
 			unsigned int codec = iana2ast(imp->ianacode);
 			if (io == IAX_QUERY && !(codec & local_cap)) {
 				iax_pref_codec_add(iax_session, codec);
-			}	
+			}
 			local_cap |= codec;
 		}
 	}
@@ -422,12 +415,11 @@
 static switch_status_t channel_on_ring(switch_core_session_t *session);
 static switch_status_t channel_on_loopback(switch_core_session_t *session);
 static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id);
+static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
+static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
 
 
@@ -443,14 +435,14 @@
 	}
 }
 
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
+static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
 {
 	tech_pvt->read_frame.data = tech_pvt->databuf;
 	tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
 	switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-    switch_core_session_set_private(session, tech_pvt);
-    tech_pvt->session = session;
+	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+	switch_core_session_set_private(session, tech_pvt);
+	tech_pvt->session = session;
 }
 
 /* 
@@ -559,7 +551,7 @@
 		globals.calls = 0;
 	}
 	switch_mutex_unlock(globals.mutex);
-		
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -574,20 +566,20 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    switch(sig) {
-    case SWITCH_SIG_KILL:
-        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
-        switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-        //switch_thread_cond_signal(tech_pvt->cond);
-        break;
-    case SWITCH_SIG_BREAK:
-        switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
-        break;
-    default:
-        break;
-    }
-	
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		//switch_thread_cond_signal(tech_pvt->cond);
+		break;
+	case SWITCH_SIG_BREAK:
+		switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+		break;
+	default:
+		break;
+	}
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -640,34 +632,33 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
 	switch_time_t started = switch_time_now();
 	unsigned int elapsed;
 	switch_byte_t *data;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
-    tech_pvt->read_frame.flags = SFF_NONE;
-    *frame = NULL;
+	tech_pvt->read_frame.flags = SFF_NONE;
+	*frame = NULL;
 
 	while (switch_test_flag(tech_pvt, TFLAG_IO)) {
-        
-        if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
-            switch_yield(1000);
-            continue;
-        }
+
+		if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
+			switch_yield(1000);
+			continue;
+		}
 		//switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
 		if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
-            switch_clear_flag(tech_pvt, TFLAG_BREAK);
-            goto cng;
-        }
+			switch_clear_flag(tech_pvt, TFLAG_BREAK);
+			goto cng;
+		}
 
 		if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
 			return SWITCH_STATUS_FALSE;
@@ -688,12 +679,12 @@
 		}
 
 		if (timeout > -1) {
-			elapsed = (unsigned int)((switch_time_now() - started) / 1000);
-			if (elapsed >= (unsigned int)timeout) {
+			elapsed = (unsigned int) ((switch_time_now() - started) / 1000);
+			if (elapsed >= (unsigned int) timeout) {
 				return SWITCH_STATUS_SUCCESS;
 			}
 		}
-		
+
 
 		switch_yield(1000);
 	}
@@ -701,19 +692,18 @@
 
 	return SWITCH_STATUS_FALSE;
 
- cng:
+  cng:
 	data = (switch_byte_t *) tech_pvt->read_frame.data;
 	data[0] = 65;
 	data[1] = 0;
-    tech_pvt->read_frame.datalen = 2;
-    tech_pvt->read_frame.flags = SFF_CNG; 
-    *frame = &tech_pvt->read_frame;
-    return SWITCH_STATUS_SUCCESS;
-	
+	tech_pvt->read_frame.datalen = 2;
+	tech_pvt->read_frame.flags = SFF_CNG;
+	*frame = &tech_pvt->read_frame;
+	return SWITCH_STATUS_SUCCESS;
+
 }
 
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -734,8 +724,7 @@
 	}
 #endif
 	//printf("Send %ld %d\n", time(NULL), (int) frame->datalen);
-	iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen,
-				   tech_pvt->write_codec.implementation->samples_per_frame);
+	iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -799,7 +788,8 @@
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
 that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
@@ -812,7 +802,7 @@
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
 			channel = switch_core_session_get_channel(*new_session);
-            tech_init(tech_pvt, *new_session);
+			tech_init(tech_pvt, *new_session);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(new_session);
@@ -850,8 +840,7 @@
 		}
 
 		iax_call(tech_pvt->iax_session,
-				 caller_profile->caller_id_number,
-				 caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
+				 caller_profile->caller_id_number, caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
 		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
@@ -871,7 +860,7 @@
 		return SWITCH_STATUS_TERM;
 	}
 
-	
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &channel_module_interface;
 
@@ -920,12 +909,10 @@
 				set_global_dialplan(val);
 			} else if (!strcmp(var, "codec-prefs")) {
 				set_global_codec_string(val);
-				globals.codec_order_last =
-					switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
+				globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
 			} else if (!strcmp(var, "codec-rates")) {
 				set_global_codec_rates_string(val);
-				globals.codec_rates_last =
-					switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
+				globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
 			}
 		}
 	}
@@ -943,18 +930,18 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t tech_media(private_t *tech_pvt, struct iax_event *iaxevent)
+static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxevent)
 {
-    unsigned int cap = iax_session_get_capability(iaxevent->session);
-    unsigned int format = iaxevent->ies.format;
+	unsigned int cap = iax_session_get_capability(iaxevent->session);
+	unsigned int format = iaxevent->ies.format;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-    
-    if (!switch_test_flag(tech_pvt, TFLAG_CODEC) && 
-        (status = iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET)) != SWITCH_STATUS_SUCCESS) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format, iaxevent->ies.capability);
-    }
-    
-    return status;
+
+	if (!switch_test_flag(tech_pvt, TFLAG_CODEC) &&
+		(status = iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET)) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format, iaxevent->ies.capability);
+	}
+
+	return status;
 }
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
@@ -994,7 +981,7 @@
 		/* Wait for an event. */
 		if ((iaxevent = iax_get_event(0)) == NULL) {
 			int waitlen = 0;
-			
+
 			if (globals.calls == 0) {
 				waitlen = 10000;
 			} else if (globals.calls < 10) {
@@ -1007,15 +994,14 @@
 			continue;
 		} else {
 			private_t *tech_pvt = NULL;
-            switch_channel_t *channel = NULL;
+			switch_channel_t *channel = NULL;
+
+			if ((tech_pvt = iax_get_private(iaxevent->session))) {
+				channel = switch_core_session_get_channel(tech_pvt->session);
+			}
 
-            if ((tech_pvt = iax_get_private(iaxevent->session))) {
-                channel = switch_core_session_get_channel(tech_pvt->session);
-            }
-            
 			if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n",
-								  iaxevent->etype, IAXNAMES[iaxevent->etype]);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n", iaxevent->etype, IAXNAMES[iaxevent->etype]);
 			}
 
 			switch (iaxevent->etype) {
@@ -1031,11 +1017,11 @@
 				break;
 			case IAX_EVENT_ACCEPT:
 				if (channel && !switch_channel_test_flag(channel, CF_ANSWERED)) {
-                    if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
-                        switch_channel_mark_pre_answered(channel);
-                    } else {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    }
+					if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
+						switch_channel_mark_pre_answered(channel);
+					} else {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					}
 				}
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call accepted.\n");
 				break;
@@ -1052,32 +1038,30 @@
 			case IAX_EVENT_ANSWER:
 				// the other side answered our call
 				if (channel) {
-                    if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
-                        if (switch_channel_test_flag(channel, CF_ANSWERED)) {
-                            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
-						
-                        } else {
-                            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel));
-                            switch_channel_mark_answered(channel);
-                        }
-                    } else {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                    }
-                }
+					if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
+						if (switch_channel_test_flag(channel, CF_ANSWERED)) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
+
+						} else {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel));
+							switch_channel_mark_answered(channel);
+						}
+					} else {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					}
+				}
 				break;
 			case IAX_EVENT_CONNECT:
 				// incoming call detected
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-									  "Incoming call connected %s, %s, %s %u/%u\n",
-									  iaxevent->ies.called_number,
-									  iaxevent->ies.calling_number,
-									  iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
+								  "Incoming call connected %s, %s, %s %u/%u\n",
+								  iaxevent->ies.called_number,
+								  iaxevent->ies.calling_number, iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
 
 				if (iaxevent) {
 					switch_core_session_t *session;
 
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n",
-										  iaxevent->ies.calling_name);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
 					if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 						private_t *tech_pvt;
 						switch_channel_t *channel;
@@ -1085,7 +1069,7 @@
 						switch_core_session_add_stream(session, NULL);
 						if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
 							channel = switch_core_session_get_channel(session);
-                            tech_init(tech_pvt, session);
+							tech_init(tech_pvt, session);
 						} else {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 							switch_core_session_destroy(&session);
@@ -1100,23 +1084,19 @@
 																				  iaxevent->ies.calling_number,
 																				  iax_get_peer_ip(iaxevent->session),
 																				  iaxevent->ies.calling_ani,
-																				  NULL, 
 																				  NULL,
-																				  (char *)modname,
-																				  iaxevent->ies.called_context,
-																				  iaxevent->ies.called_number)) != 0) {
+																				  NULL,
+																				  (char *) modname,
+																				  iaxevent->ies.called_context, iaxevent->ies.called_number)) != 0) {
 							char name[128];
-							snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number,
-									 rand() & 0xffff);
+							snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
 							switch_channel_set_name(channel, name);
 							switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 
 						}
 
 						if (iax_set_codec(tech_pvt, iaxevent->session,
-										  &iaxevent->ies.format,
-										  &iaxevent->ies.capability,
-										  &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
+										  &iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
 							iax_reject(iaxevent->session, "Codec Error!");
 							switch_core_session_destroy(&session);
 						} else {
@@ -1141,11 +1121,11 @@
 					switch_mutex_unlock(tech_pvt->flag_mutex);
 
 
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
-                    switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
-                    switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
-                    //switch_thread_cond_signal(tech_pvt->cond);
-                    iaxevent->session = NULL;
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
+					switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+					switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
+					//switch_thread_cond_signal(tech_pvt->cond);
+					iaxevent->session = NULL;
 				}
 				break;
 			case IAX_EVENT_CNG:
@@ -1156,7 +1136,7 @@
 				if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen) != 0) {
 					if (channel && switch_channel_get_state(channel) <= CS_HANGUP) {
 						int bytes, frames;
-						
+
 						if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
 							//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
 							break;
@@ -1183,18 +1163,16 @@
 				break;
 			case IAX_EVENT_DTMF:
 				if (channel) {
-                    char str[2] = { (char)iaxevent->subclass };
-                    if (globals.debug) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
-                                          switch_channel_get_name(channel));
-                    }
-                    switch_channel_queue_dtmf(channel, str);
+					char str[2] = { (char) iaxevent->subclass };
+					if (globals.debug) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str, switch_channel_get_name(channel));
+					}
+					switch_channel_queue_dtmf(channel, str);
 				}
 
 				break;
 			default:
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n",
-									  iaxevent->etype);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
 				break;
 			}
 
@@ -1216,7 +1194,7 @@
 	running = -1;
 
 	if (globals.fd) {
-		/* Die Mutha $%#$@% Die Mutha $#%#$^ Die*/
+		/* Die Mutha $%#$@% Die Mutha $#%#$^ Die */
 		shutdown(globals.fd, 2);
 	}
 	iax_shutdown();

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Fri Mar 30 12:19:18 2007
@@ -48,13 +48,13 @@
 //#define SAMPLE_TYPE  paFloat32
 typedef short SAMPLE;
 
-typedef switch_status_t (*pa_command_t)(char **argv, int argc, switch_stream_handle_t *stream);
+typedef switch_status_t (*pa_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
 
 typedef enum {
-    GFLAG_NONE = 0,
-    GFLAG_EAR = (1 << 0),
-    GFLAG_MOUTH = (1 << 1),
-    GFLAG_RING = (1 << 2)
+	GFLAG_NONE = 0,
+	GFLAG_EAR = (1 << 0),
+	GFLAG_MOUTH = (1 << 1),
+	GFLAG_RING = (1 << 2)
 } GFLAGS;
 
 typedef enum {
@@ -75,17 +75,17 @@
 	switch_core_session_t *session;
 	switch_caller_profile_t *caller_profile;
 	char call_id[50];
-    int sample_rate;
-    int codec_ms;
+	int sample_rate;
+	int codec_ms;
 	switch_mutex_t *flag_mutex;
-    char *hold_file;
-    switch_file_handle_t fh;
-    switch_file_handle_t *hfh;
+	char *hold_file;
+	switch_file_handle_t fh;
+	switch_file_handle_t *hfh;
 	switch_frame_t hold_frame;
-    unsigned char holdbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+	unsigned char holdbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	switch_codec_t write_codec;
-    switch_timer_t timer;
-    struct private_object *next;
+	switch_timer_t timer;
+	struct private_object *next;
 };
 
 typedef struct private_object private_t;
@@ -96,9 +96,9 @@
 	char *cid_name;
 	char *cid_num;
 	char *dialplan;
-    char *ring_file;
-    char *hold_file;
-    char *timer_name;
+	char *ring_file;
+	char *hold_file;
+	char *timer_name;
 	int ringdev;
 	int indev;
 	int outdev;
@@ -114,13 +114,13 @@
 	switch_codec_t read_codec;
 	switch_codec_t write_codec;
 	switch_frame_t read_frame;
-    switch_frame_t cng_frame;
+	switch_frame_t cng_frame;
 	unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
 	unsigned char cngbuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
-    private_t *call_list;
-    int ring_interval;
-    GFLAGS flags;
-    switch_timer_t timer;
+	private_t *call_list;
+	int ring_interval;
+	GFLAGS flags;
+	switch_timer_t timer;
 } globals;
 
 
@@ -129,37 +129,34 @@
 
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ring_file, globals.ring_file)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_hold_file, globals.hold_file)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_name)
-
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ring_file, globals.ring_file)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_hold_file, globals.hold_file)
+	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_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 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_ring(switch_core_session_t *session);
-static switch_status_t channel_on_loopback(switch_core_session_t *session);
-static switch_status_t channel_on_transmit(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
-													switch_caller_profile_t *outbound_profile,
-													switch_core_session_t **new_session, switch_memory_pool_t **pool);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-                                          switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-                                           switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
-static switch_status_t engage_device(int samplerate, int codec_ms);
-static switch_status_t engage_ring_device(int sample_rate, int channels);
-static void deactivate_ring_device(void);
-static int dump_info(void);
-static switch_status_t load_config(void);
-static int get_dev_by_name(char *name, int in);
-static int get_dev_by_number(int number, int in);
-static switch_status_t pa_cmd(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
-static switch_status_t padep(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 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_ring(switch_core_session_t *session);
+	 static switch_status_t channel_on_loopback(switch_core_session_t *session);
+	 static switch_status_t channel_on_transmit(switch_core_session_t *session);
+	 static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+														 switch_caller_profile_t *outbound_profile,
+														 switch_core_session_t **new_session, switch_memory_pool_t **pool);
+	 static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
+	 static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
+	 static switch_status_t engage_device(int samplerate, int codec_ms);
+	 static switch_status_t engage_ring_device(int sample_rate, int channels);
+	 static void deactivate_ring_device(void);
+	 static int dump_info(void);
+	 static switch_status_t load_config(void);
+	 static int get_dev_by_name(char *name, int in);
+	 static int get_dev_by_number(int number, int in);
+	 static switch_status_t pa_cmd(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t padep(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
 
 
 /* 
@@ -167,91 +164,90 @@
    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
    so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
 */
-static switch_status_t channel_on_init(switch_core_session_t *session)
+	 static switch_status_t channel_on_init(switch_core_session_t *session)
 {
 	switch_channel_t *channel;
 	private_t *tech_pvt = NULL;
 	switch_time_t last;
 	int waitsec = globals.ring_interval * 1000000;
-    switch_file_handle_t fh = {0};
-    char *val, *ring_file = NULL, *hold_file = NULL;
-    int16_t abuf[2048];
+	switch_file_handle_t fh = { 0 };
+	char *val, *ring_file = NULL, *hold_file = NULL;
+	int16_t abuf[2048];
 
-    tech_pvt = switch_core_session_get_private(session);
+	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-    
+
 	last = switch_time_now() - waitsec;
 
 
 
-    if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
-        hold_file = val;
-    } else {
-        hold_file = globals.hold_file;
-    }
-
-    if (hold_file) {
-        tech_pvt->hold_file = switch_core_session_strdup(session, hold_file);
-    }
+	if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
+		hold_file = val;
+	} else {
+		hold_file = globals.hold_file;
+	}
+
+	if (hold_file) {
+		tech_pvt->hold_file = switch_core_session_strdup(session, hold_file);
+	}
 
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 
-        
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n", switch_channel_get_name(channel),
-                          switch_channel_get_state(channel), switch_test_flag(tech_pvt, TFLAG_ANSWER));
-        
-
-
-        if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-            return SWITCH_STATUS_FALSE;
-        }
-
-        if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-            add_pvt(tech_pvt, PA_SLAVE);
-
-            ring_file = globals.ring_file;
-            if ((val = switch_channel_get_variable(channel, "pa_ring_file"))) {
-                ring_file = val;
-            }
-
-            if (switch_test_flag((&globals), GFLAG_RING)) {
-                ring_file = NULL;
-            }
-            switch_set_flag_locked((&globals), GFLAG_RING);
-            if (ring_file) {
-                if (switch_core_file_open(&fh,
-                                          ring_file,
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n",
+						  switch_channel_get_name(channel), switch_channel_get_state(channel), switch_test_flag(tech_pvt, TFLAG_ANSWER));
+
+
+
+		if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			return SWITCH_STATUS_FALSE;
+		}
+
+		if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+			add_pvt(tech_pvt, PA_SLAVE);
+
+			ring_file = globals.ring_file;
+			if ((val = switch_channel_get_variable(channel, "pa_ring_file"))) {
+				ring_file = val;
+			}
+
+			if (switch_test_flag((&globals), GFLAG_RING)) {
+				ring_file = NULL;
+			}
+			switch_set_flag_locked((&globals), GFLAG_RING);
+			if (ring_file) {
+				if (switch_core_file_open(&fh,
+										  ring_file,
 										  globals.read_codec.implementation->number_of_channels,
 										  globals.read_codec.implementation->samples_per_second,
-                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-                                          NULL) == SWITCH_STATUS_SUCCESS) {
-            
-                    if (engage_ring_device(fh.samplerate, fh.channels) != SWITCH_STATUS_SUCCESS) {
-                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ring Error!\n");
-                        switch_core_file_close(&fh);
-                        return SWITCH_STATUS_GENERR;
-                    }
-                } else {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n", ring_file);
-                    ring_file = NULL;
-                }
-            }
-        }
+										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
+
+					if (engage_ring_device(fh.samplerate, fh.channels) != SWITCH_STATUS_SUCCESS) {
+						switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ring Error!\n");
+						switch_core_file_close(&fh);
+						return SWITCH_STATUS_GENERR;
+					}
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open %s, disabling ring file!\n", ring_file);
+					ring_file = NULL;
+				}
+			}
+		}
 
 		switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 		switch_channel_mark_ring_ready(channel);
-		
+
 		while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
 			if (switch_time_now() - last >= waitsec) {
 				char buf[512];
 				switch_event_t *event;
-                
+
 				snprintf(buf, sizeof(buf), "BRRRRING! BRRRRING! call %s\n", tech_pvt->call_id);
 
 				if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_RINGING) == SWITCH_STATUS_SUCCESS) {
@@ -263,46 +259,46 @@
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
 				last = switch_time_now();
-                if (ring_file) {
-                    unsigned int pos = 0;
-                    switch_core_file_seek(&fh, &pos, 0, SEEK_SET);				 
-                    for (;;) {
-                        switch_size_t olen = 1024;
-                        switch_core_file_read(&fh, abuf, &olen);
-                        if (olen == 0) {
-                            break;
-                        }
-                        WriteAudioStream(globals.ring_stream, abuf, (long)olen);
-                    }
-                }
-            }
-
-            switch_yield(globals.read_codec.implementation->microseconds_per_frame);
-
-        }
-        switch_clear_flag_locked((&globals), GFLAG_RING);
-    }
-
-    if (ring_file) {
-        deactivate_ring_device();
-        switch_core_file_close(&fh);
-        switch_core_codec_destroy(&tech_pvt->write_codec);
+				if (ring_file) {
+					unsigned int pos = 0;
+					switch_core_file_seek(&fh, &pos, 0, SEEK_SET);
+					for (;;) {
+						switch_size_t olen = 1024;
+						switch_core_file_read(&fh, abuf, &olen);
+						if (olen == 0) {
+							break;
+						}
+						WriteAudioStream(globals.ring_stream, abuf, (long) olen);
+					}
+				}
+			}
+
+			switch_yield(globals.read_codec.implementation->microseconds_per_frame);
+
+		}
+		switch_clear_flag_locked((&globals), GFLAG_RING);
+	}
+
+	if (ring_file) {
+		deactivate_ring_device();
+		switch_core_file_close(&fh);
+		switch_core_codec_destroy(&tech_pvt->write_codec);
 		switch_core_timer_destroy(&tech_pvt->timer);
-    }
+	}
 
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-        if (!switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
-            return SWITCH_STATUS_SUCCESS;
-        }
+		if (!switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
+			switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
+			return SWITCH_STATUS_SUCCESS;
+		}
 	}
 
-    switch_set_flag_locked(tech_pvt, TFLAG_IO);
-
-    /* Move Channel's State Machine to RING */
-    switch_channel_set_state(channel, CS_RING);
-	
-    return SWITCH_STATUS_SUCCESS;
+	switch_set_flag_locked(tech_pvt, TFLAG_IO);
+
+	/* Move Channel's State Machine to RING */
+	switch_channel_set_state(channel, CS_RING);
+
+	return SWITCH_STATUS_SUCCESS;
 
 }
 
@@ -363,72 +359,72 @@
 
 
 
-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;
+	private_t *tp;
+	uint8_t in_list = 0;
+
+	switch_mutex_lock(globals.pvt_lock);
 
-    switch_mutex_lock(globals.pvt_lock);
+	if (switch_strlen_zero(tech_pvt->call_id)) {
+		snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id);
+		switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt);
+		switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec);
+		switch_core_session_set_write_codec(tech_pvt->session, &globals.write_codec);
+	}
 
-    if (switch_strlen_zero(tech_pvt->call_id)) {
-        snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id);
-        switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt);
-        switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec);
-        switch_core_session_set_write_codec(tech_pvt->session, &globals.write_codec);
-    }
-
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        if (tp == tech_pvt) {
-            in_list = 1;
-        }
-        if (master) {
-            switch_clear_flag_locked(tp, TFLAG_MASTER);
-        }
-    }
-
-
-    if (master) {
-        if (!in_list) {
-            tech_pvt->next = globals.call_list;
-            globals.call_list = tech_pvt;
-        }
-        switch_set_flag_locked(tech_pvt, TFLAG_MASTER);
-
-    } else if (!in_list) {
-        for (tp = globals.call_list; tp && tp->next; tp = tp->next);
-        if (tp) {
-            tp->next = tech_pvt;
-        } else {
-            globals.call_list = tech_pvt;
-        }
-    }
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		if (tp == tech_pvt) {
+			in_list = 1;
+		}
+		if (master) {
+			switch_clear_flag_locked(tp, TFLAG_MASTER);
+		}
+	}
+
+
+	if (master) {
+		if (!in_list) {
+			tech_pvt->next = globals.call_list;
+			globals.call_list = tech_pvt;
+		}
+		switch_set_flag_locked(tech_pvt, TFLAG_MASTER);
+
+	} else if (!in_list) {
+		for (tp = globals.call_list; tp && tp->next; tp = tp->next);
+		if (tp) {
+			tp->next = tech_pvt;
+		} else {
+			globals.call_list = tech_pvt;
+		}
+	}
 
 	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;
+	private_t *tp, *last = NULL;
 
 	switch_mutex_lock(globals.pvt_lock);
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        switch_clear_flag_locked(tp, TFLAG_MASTER);
-        if (tp == tech_pvt) {
-            if (last) {
-                last->next = tp->next;
-            } else {
-                globals.call_list = tp->next;
-            }
-        }
-        last = tp;
-    }
-
-    if (globals.call_list) {
-        switch_set_flag_locked(globals.call_list, TFLAG_MASTER);
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No more channels, deactivating audio\n");
-        deactivate_audio_device();
-    }
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		switch_clear_flag_locked(tp, TFLAG_MASTER);
+		if (tp == tech_pvt) {
+			if (last) {
+				last->next = tp->next;
+			} else {
+				globals.call_list = tp->next;
+			}
+		}
+		last = tp;
+	}
+
+	if (globals.call_list) {
+		switch_set_flag_locked(globals.call_list, TFLAG_MASTER);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No more channels, deactivating audio\n");
+		deactivate_audio_device();
+	}
 
 	switch_mutex_unlock(globals.pvt_lock);
 }
@@ -444,17 +440,17 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    remove_pvt(tech_pvt);
+	remove_pvt(tech_pvt);
 
 	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 	switch_set_flag_locked(tech_pvt, TFLAG_HUP);
 
 	switch_core_hash_delete(globals.call_hash, tech_pvt->call_id);
 
-    if (tech_pvt->hfh) {
-        tech_pvt->hfh = NULL;
-        switch_core_file_close(&tech_pvt->fh);
-    }
+	if (tech_pvt->hfh) {
+		tech_pvt->hfh = NULL;
+		switch_core_file_close(&tech_pvt->fh);
+	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
 
@@ -472,14 +468,14 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-    switch (sig) {
-    case SWITCH_SIG_KILL:
-        switch_set_flag_locked(tech_pvt, TFLAG_HUP);
-        switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-        break;
-    default:
-        break;
-    }
+	switch (sig) {
+	case SWITCH_SIG_KILL:
+		switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		break;
+	default:
+		break;
+	}
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 
 
@@ -542,8 +538,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-                                          switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -557,94 +552,93 @@
 	assert(tech_pvt != NULL);
 
 	if (!globals.audio_stream) {
-        return SWITCH_STATUS_FALSE;
-    }
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
-        return SWITCH_STATUS_FALSE;
-    }
-    
-    if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
-        goto cng;
-    }
-
-    if (!is_master(tech_pvt)) {
-        if (tech_pvt->hold_file) {
-            if (!tech_pvt->hfh) {
-                int codec_ms = tech_pvt->codec_ms ? tech_pvt->codec_ms : globals.codec_ms;
-                int sample_rate = tech_pvt->sample_rate ? tech_pvt->sample_rate : globals.sample_rate;
-
-                if (switch_core_codec_init(&tech_pvt->write_codec,
-                                           "L16",
-                                           NULL,
-                                           sample_rate,
-                                           codec_ms,
-                                           1,
-                                           SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                           NULL,
-                                           switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
-                    switch_core_codec_destroy(&globals.read_codec);
-                    tech_pvt->hold_file = NULL;
-                    goto cng;
-                }
+	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+		goto cng;
+	}
+
+	if (!is_master(tech_pvt)) {
+		if (tech_pvt->hold_file) {
+			if (!tech_pvt->hfh) {
+				int codec_ms = tech_pvt->codec_ms ? tech_pvt->codec_ms : globals.codec_ms;
+				int sample_rate = tech_pvt->sample_rate ? tech_pvt->sample_rate : globals.sample_rate;
+
+				if (switch_core_codec_init(&tech_pvt->write_codec,
+										   "L16",
+										   NULL,
+										   sample_rate,
+										   codec_ms,
+										   1,
+										   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+										   NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+					switch_core_codec_destroy(&globals.read_codec);
+					tech_pvt->hold_file = NULL;
+					goto cng;
+				}
 
-                if (switch_core_file_open(&tech_pvt->fh,
-                                          tech_pvt->hold_file,
+				if (switch_core_file_open(&tech_pvt->fh,
+										  tech_pvt->hold_file,
 										  globals.read_codec.implementation->number_of_channels,
-                                          globals.read_codec.implementation->samples_per_second,
-                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
-                                          switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-                    switch_core_codec_destroy(&tech_pvt->write_codec);
-                    tech_pvt->hold_file = NULL;
-                    goto cng;
-                }
-
-                tech_pvt->hfh = &tech_pvt->fh;
-                tech_pvt->hold_frame.data = tech_pvt->holdbuf;
-                tech_pvt->hold_frame.buflen = sizeof(tech_pvt->holdbuf);
-                tech_pvt->hold_frame.rate = sample_rate;
-                tech_pvt->hold_frame.codec = &tech_pvt->write_codec;
-            }
-            
-            goto hold;
-        }
-    cng:
-        switch_yield(globals.read_codec.implementation->microseconds_per_frame);
-        *frame = &globals.cng_frame;
+										  globals.read_codec.implementation->samples_per_second,
+										  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+										  switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+					switch_core_codec_destroy(&tech_pvt->write_codec);
+					tech_pvt->hold_file = NULL;
+					goto cng;
+				}
+
+				tech_pvt->hfh = &tech_pvt->fh;
+				tech_pvt->hold_frame.data = tech_pvt->holdbuf;
+				tech_pvt->hold_frame.buflen = sizeof(tech_pvt->holdbuf);
+				tech_pvt->hold_frame.rate = sample_rate;
+				tech_pvt->hold_frame.codec = &tech_pvt->write_codec;
+			}
+
+			goto hold;
+		}
+	  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;
+		{
+			switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
 			if (switch_core_timer_next(&tech_pvt->timer) != SWITCH_STATUS_SUCCESS) {
-                switch_core_file_close(&tech_pvt->fh);
-                switch_core_codec_destroy(&tech_pvt->write_codec);
-                goto cng;
+				switch_core_file_close(&tech_pvt->fh);
+				switch_core_codec_destroy(&tech_pvt->write_codec);
+				goto cng;
+			}
+			switch_core_file_read(tech_pvt->hfh, tech_pvt->hold_frame.data, &olen);
+
+			if (olen == 0) {
+				unsigned int pos = 0;
+				switch_core_file_seek(tech_pvt->hfh, &pos, 0, SEEK_SET);
+				goto cng;
 			}
-            switch_core_file_read(tech_pvt->hfh, tech_pvt->hold_frame.data, &olen);
-            
-            if (olen == 0) {
-                unsigned int pos = 0;
-                switch_core_file_seek(tech_pvt->hfh, &pos, 0, SEEK_SET);				 
-                goto cng;
-            }
-            
-            
-            tech_pvt->hold_frame.datalen = (uint32_t)(olen * sizeof(int16_t));
-            tech_pvt->hold_frame.samples = (uint32_t)olen;
+
+
+			tech_pvt->hold_frame.datalen = (uint32_t) (olen * sizeof(int16_t));
+			tech_pvt->hold_frame.samples = (uint32_t) olen;
 			tech_pvt->hold_frame.timestamp = tech_pvt->timer.samplecount;
-            *frame = &tech_pvt->hold_frame;
-            
-        }
+			*frame = &tech_pvt->hold_frame;
 
-		return SWITCH_STATUS_SUCCESS;        
-    }
+		}
+
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	switch_mutex_lock(globals.device_lock);
 
-    if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) != 0) {
+	if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) != 0) {
 		globals.read_frame.datalen = samples * 2;
 		globals.read_frame.samples = samples;
 
@@ -652,9 +646,9 @@
 		globals.read_frame.timestamp = globals.timer.samplecount;
 		*frame = &globals.read_frame;
 
-        if (!switch_test_flag((&globals), GFLAG_MOUTH)) {
-            memset(globals.read_frame.data, 255, globals.read_frame.datalen);
-        }
+		if (!switch_test_flag((&globals), GFLAG_MOUTH)) {
+			memset(globals.read_frame.data, 255, globals.read_frame.datalen);
+		}
 
 		status = SWITCH_STATUS_SUCCESS;
 	}
@@ -663,8 +657,7 @@
 	return status;
 }
 
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-                                           switch_io_flag_t flags, int stream_id)
+static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
 	switch_channel_t *channel = NULL;
 	private_t *tech_pvt = NULL;
@@ -676,21 +669,21 @@
 	assert(tech_pvt != NULL);
 
 	if (!globals.audio_stream) {
-        return SWITCH_STATUS_FALSE;
-    }
+		return SWITCH_STATUS_FALSE;
+	}
 
-    if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
-        return SWITCH_STATUS_FALSE;
-    }
-
-    if (!is_master(tech_pvt) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
-		return SWITCH_STATUS_SUCCESS;        
-    }
+	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!is_master(tech_pvt) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
+		return SWITCH_STATUS_SUCCESS;
+	}
 
 	if (globals.audio_stream) {
-        if (switch_test_flag((&globals), GFLAG_EAR)) {
-            WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)));
-        }
+		if (switch_test_flag((&globals), GFLAG_EAR)) {
+			WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)));
+		}
 		status = SWITCH_STATUS_SUCCESS;
 	}
 
@@ -716,16 +709,16 @@
 {
 	switch_channel_t *channel;
 	private_t *tech_pvt;
-			
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-			
+
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 
 	switch (msg->message_id) {
-	case SWITCH_MESSAGE_INDICATE_PROGRESS: 
+	case SWITCH_MESSAGE_INDICATE_PROGRESS:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
 			switch_set_flag_locked(tech_pvt, TFLAG_IO);
@@ -737,43 +730,43 @@
 }
 
 static switch_api_interface_t send_dtmf_interface = {
-    /*.interface_name */ "padtmf",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ NULL
+	/*.interface_name */ "padtmf",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ NULL
 };
 
 static switch_api_interface_t answer_call_interface = {
-    /*.interface_name */ "paoffhook",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &send_dtmf_interface
+	/*.interface_name */ "paoffhook",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &send_dtmf_interface
 };
 
 static switch_api_interface_t channel_info_interface = {
-    /*.interface_name */ "painfo",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &answer_call_interface
+	/*.interface_name */ "painfo",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &answer_call_interface
 };
 
 static switch_api_interface_t channel_hup_interface = {
-    /*.interface_name */ "pahup",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &channel_info_interface
+	/*.interface_name */ "pahup",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &channel_info_interface
 };
 
 static switch_api_interface_t channel_call_interface = {
-    /*.interface_name */ "pacall",
-    /*.desc */ "DEPRICATED (see 'pa')",
-    /*.function */ padep,
-    /*.syntax */ "DEPRICATED (see 'pa')",
-    /*.next */ &channel_hup_interface
+	/*.interface_name */ "pacall",
+	/*.desc */ "DEPRICATED (see 'pa')",
+	/*.function */ padep,
+	/*.syntax */ "DEPRICATED (see 'pa')",
+	/*.next */ &channel_hup_interface
 };
 
 static switch_api_interface_t channel_api_interface = {
@@ -802,7 +795,7 @@
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
 	/*.send_dtmf */ channel_send_dtmf,
-	/*.receive_message*/ channel_receive_message
+	/*.receive_message */ channel_receive_message
 };
 
 static const switch_endpoint_interface_t channel_endpoint_interface = {
@@ -826,7 +819,8 @@
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
+													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool)
 {
 
@@ -837,12 +831,12 @@
 
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
-			memset(tech_pvt, 0, sizeof(*tech_pvt));            
+			memset(tech_pvt, 0, sizeof(*tech_pvt));
 			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
 			tech_pvt->session = *new_session;
-            globals.flags = GFLAG_EAR | GFLAG_MOUTH;
+			globals.flags = GFLAG_EAR | GFLAG_MOUTH;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(new_session);
@@ -851,9 +845,9 @@
 
 		if (outbound_profile) {
 			char name[128];
-            char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
+			char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na";
 			snprintf(name, sizeof(name), "PortAudio/%s", id);
-					 
+
 			switch_channel_set_name(channel, name);
 
 			caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
@@ -879,7 +873,7 @@
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
-    switch_status_t status;
+	switch_status_t status;
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
@@ -889,17 +883,18 @@
 	Pa_Initialize();
 
 	if (dump_info()) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't find any audio devices!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't find any audio devices!\n");
 		return SWITCH_STATUS_TERM;
-    }
+	}
 
 	if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
-        return status;
-    }
+		return status;
+	}
 
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", 
-                      globals.indev, globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+					  "Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", globals.indev,
+					  globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
 
 
 	switch_core_hash_init(&globals.call_hash, module_pool);
@@ -919,7 +914,7 @@
 	globals.cng_frame.data = globals.cngbuf;
 	globals.cng_frame.buflen = sizeof(globals.cngbuf);
 	globals.cng_frame.datalen = sizeof(globals.cngbuf);
-    switch_set_flag((&globals.cng_frame), SFF_CNG);
+	switch_set_flag((&globals.cng_frame), SFF_CNG);
 
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &channel_module_interface;
@@ -933,7 +928,7 @@
 {
 	char *cf = "portaudio.conf";
 	switch_xml_t cfg, xml, settings, param;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -941,7 +936,7 @@
 	}
 
 	memset(&globals, 0, sizeof(globals));
-    globals.indev = globals.outdev = globals.ringdev = -1;
+	globals.indev = globals.outdev = globals.ringdev = -1;
 
 	if ((settings = switch_xml_child(cfg, "settings"))) {
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
@@ -951,7 +946,7 @@
 			if (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
 			} else if (!strcmp(var, "ring-interval")) {
-                globals.ring_interval = atoi(val);
+				globals.ring_interval = atoi(val);
 			} else if (!strcmp(var, "ring-file")) {
 				set_global_ring_file(val);
 			} else if (!strcmp(var, "hold-file")) {
@@ -986,7 +981,7 @@
 				} else {
 					globals.ringdev = get_dev_by_name(val, 0);
 				}
-            }
+			}
 		}
 	}
 
@@ -1005,37 +1000,37 @@
 	if (!globals.ring_interval) {
 		globals.ring_interval = 5;
 	}
-    
-    if (!globals.timer_name) {
-        set_global_timer_name("soft");
-    }
-
-    if (globals.indev < 0) {
-        globals.indev = get_dev_by_name(NULL, 1);
-        if (globals.indev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default input device!\n");
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
-            status = SWITCH_STATUS_GENERR;            
-        }
-    }
-
-    if (globals.outdev < 0) {
-        globals.outdev = get_dev_by_name(NULL, 0);
-        if (globals.outdev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default output device!\n");
-        } else {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
-            status = SWITCH_STATUS_GENERR;            
-        }
-    }
-
-    if (globals.ringdev < 0) {
-        if (globals.outdev > -1) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ring device configured using output device!\n");
-            globals.ringdev = globals.outdev;
-        } 
-    }
+
+	if (!globals.timer_name) {
+		set_global_timer_name("soft");
+	}
+
+	if (globals.indev < 0) {
+		globals.indev = get_dev_by_name(NULL, 1);
+		if (globals.indev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default input device!\n");
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
+			status = SWITCH_STATUS_GENERR;
+		}
+	}
+
+	if (globals.outdev < 0) {
+		globals.outdev = get_dev_by_name(NULL, 0);
+		if (globals.outdev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Switching to default output device!\n");
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find an input device!\n");
+			status = SWITCH_STATUS_GENERR;
+		}
+	}
+
+	if (globals.ringdev < 0) {
+		if (globals.outdev > -1) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ring device configured using output device!\n");
+			globals.ringdev = globals.outdev;
+		}
+	}
 
 	switch_xml_free(xml);
 
@@ -1060,18 +1055,18 @@
 
 static int get_dev_by_number(int number, int in)
 {
-    int numDevices = Pa_GetDeviceCount();
+	int numDevices = Pa_GetDeviceCount();
 	const PaDeviceInfo *pdi;
 
-    if (number > -1 && number < numDevices && (pdi = Pa_GetDeviceInfo(number))) {
-        if (in && pdi->maxInputChannels) {
-            return number;
-        } else if (!in && pdi->maxOutputChannels) {
-            return number;
-        }
-    }
-    
-    return -1;
+	if (number > -1 && number < numDevices && (pdi = Pa_GetDeviceInfo(number))) {
+		if (in && pdi->maxInputChannels) {
+			return number;
+		} else if (!in && pdi->maxOutputChannels) {
+			return number;
+		}
+	}
+
+	return -1;
 }
 
 static int get_dev_by_name(char *name, int in)
@@ -1087,15 +1082,15 @@
 	}
 
 	for (i = 0; i < numDevices; i++) {
-        int match = 0;
+		int match = 0;
 		pdi = Pa_GetDeviceInfo(i);
-        
+
 		if (switch_strlen_zero(name)) {
-            match = 1;
-        } else if (strstr(pdi->name, name)) {
-            match = 1;
-        }
-        
+			match = 1;
+		} else if (strstr(pdi->name, name)) {
+			match = 1;
+		}
+
 		if (match) {
 			if (in && pdi->maxInputChannels) {
 				return i;
@@ -1105,263 +1100,252 @@
 		}
 	}
 
-    if (switch_strlen_zero(name)) {
-        return -1;
-    }
+	if (switch_strlen_zero(name)) {
+		return -1;
+	}
 
 	return get_dev_by_name(NULL, in);
 }
 
 
 /*******************************************************************/
-static void PrintSupportedStandardSampleRates(const PaStreamParameters *inputParameters,
-                                              const PaStreamParameters *outputParameters)
+static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters)
 {
-    int i, printCount, cr = 7;
-    PaError err;
-    static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
-                                            44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1};
-
-    printCount = cr;
-    for(i=0; standardSampleRates[i] > 0; i++) {
-        err = Pa_IsFormatSupported(inputParameters, outputParameters, standardSampleRates[i]);
-        if (err == paFormatIsSupported) {
-            if (printCount == cr) {
-                printCount = 0;
-                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "\n\t%0.2f", standardSampleRates[i]);
-            } else {
-                switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  ", %0.2f", standardSampleRates[i]);
-            }
-            printCount++;
-        }
-    }
-    if (!printCount) {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  " None\n");
-    } else {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "\n");
-    }
+	int i, printCount, cr = 7;
+	PaError err;
+	static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
+		44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1
+	};
+
+	printCount = cr;
+	for (i = 0; standardSampleRates[i] > 0; i++) {
+		err = Pa_IsFormatSupported(inputParameters, outputParameters, standardSampleRates[i]);
+		if (err == paFormatIsSupported) {
+			if (printCount == cr) {
+				printCount = 0;
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "\n\t%0.2f", standardSampleRates[i]);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, ", %0.2f", standardSampleRates[i]);
+			}
+			printCount++;
+		}
+	}
+	if (!printCount) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, " None\n");
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "\n");
+	}
 }
+
 /*******************************************************************/
 
 static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *stream)
 {
-	int     i, numDevices;
-    const   PaDeviceInfo *deviceInfo;
-            
-    numDevices = Pa_GetDeviceCount();
-    if (numDevices < 0) {
+	int i, numDevices;
+	const PaDeviceInfo *deviceInfo;
+
+	numDevices = Pa_GetDeviceCount();
+	if (numDevices < 0) {
 		return SWITCH_STATUS_SUCCESS;
-    }
-	for(i=0; i<numDevices; i++) {
-        deviceInfo = Pa_GetDeviceInfo(i);
-        stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
+	}
+	for (i = 0; i < numDevices; i++) {
+		deviceInfo = Pa_GetDeviceInfo(i);
+		stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
 	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static int dump_info(void)
 {
-    int     i, numDevices, defaultDisplayed;
-    const   PaDeviceInfo *deviceInfo;
-    PaStreamParameters inputParameters, outputParameters;
-    PaError err;
-    const char *line = "--------------------------------------------------------------------------------\n";
-    
+	int i, numDevices, defaultDisplayed;
+	const PaDeviceInfo *deviceInfo;
+	PaStreamParameters inputParameters, outputParameters;
+	PaError err;
+	const char *line = "--------------------------------------------------------------------------------\n";
 
 
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "PortAudio version number = %d\nPortAudio version text = '%s'\n",
-                      Pa_GetVersion(), Pa_GetVersionText());
+
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
+					  "PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText());
 	if (globals.audio_stream) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "ERROR: Cannot use this command this while a call is in progress\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
 		return 0;
 	}
-            
-    numDevices = Pa_GetDeviceCount();
-    if (numDevices < 0) {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
-        err = numDevices;
-        goto error;
-    }
-    
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Number of devices = %d\n", numDevices);
-    for(i=0; i<numDevices; i++) {
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
-        deviceInfo = Pa_GetDeviceInfo(i);
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Device #%d ", i);
-                
-        /* Mark global and API specific default devices */
-        defaultDisplayed = 0;
-        if (i == Pa_GetDefaultInputDevice()) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default Input");
-            defaultDisplayed = 1;
-            
-        } else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultInputDevice) {
-            
-            const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default %s Input", hostInfo->name);
-            defaultDisplayed = 1;
-        }
-        
-        if (i == Pa_GetDefaultOutputDevice()) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default Output");
-            defaultDisplayed = 1;
-
-        } else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultOutputDevice) {
-
-            const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "**Default %s Output", hostInfo->name);
-            defaultDisplayed = 1;
-        }
-
-        if (defaultDisplayed) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "** | ");
-        }
-        /* print device info fields */
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Name: %s\n", deviceInfo->name);
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Host: %s | ",  Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "inputs: %d | ", deviceInfo->maxInputChannels );
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "outputs: %d | ", deviceInfo->maxOutputChannels );
-
-        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,  "Default rate: %8.2f\n", deviceInfo->defaultSampleRate);
-
-        /* poll for standard sample rates */
-        inputParameters.device = i;
-        inputParameters.channelCount = deviceInfo->maxInputChannels;
-        inputParameters.sampleFormat = paInt16;
-        inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
-        inputParameters.hostApiSpecificStreamInfo = NULL;
-        
-        outputParameters.device = i;
-        outputParameters.channelCount = deviceInfo->maxOutputChannels;
-        outputParameters.sampleFormat = paInt16;
-        outputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
-        outputParameters.hostApiSpecificStreamInfo = NULL;
-
-        if (inputParameters.channelCount > 0) {
-
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:",
-                              inputParameters.channelCount);
-            PrintSupportedStandardSampleRates(&inputParameters, NULL);
-        }
-
-        if (outputParameters.channelCount > 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:",
-                              outputParameters.channelCount);
-            PrintSupportedStandardSampleRates(NULL, &outputParameters);
-        }
-
-        if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
-
-            switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "full-duplex 16 bit %d channel input, %d channel output rates:",
-                              inputParameters.channelCount, outputParameters.channelCount);
-            PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
-        }
-    }
-
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
-    
-    return 0;
-
- error:
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "An error occured while using the portaudio stream\n");
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "Error number: %d\n", err);
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,  "Error message: %s\n", Pa_GetErrorText(err));
-    return err;
+
+	numDevices = Pa_GetDeviceCount();
+	if (numDevices < 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
+		err = numDevices;
+		goto error;
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Number of devices = %d\n", numDevices);
+	for (i = 0; i < numDevices; i++) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
+		deviceInfo = Pa_GetDeviceInfo(i);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Device #%d ", i);
+
+		/* Mark global and API specific default devices */
+		defaultDisplayed = 0;
+		if (i == Pa_GetDefaultInputDevice()) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default Input");
+			defaultDisplayed = 1;
+
+		} else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultInputDevice) {
+
+			const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default %s Input", hostInfo->name);
+			defaultDisplayed = 1;
+		}
+
+		if (i == Pa_GetDefaultOutputDevice()) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default Output");
+			defaultDisplayed = 1;
+
+		} else if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultOutputDevice) {
+
+			const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "**Default %s Output", hostInfo->name);
+			defaultDisplayed = 1;
+		}
+
+		if (defaultDisplayed) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "** | ");
+		}
+		/* print device info fields */
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Name: %s\n", deviceInfo->name);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Host: %s | ", Pa_GetHostApiInfo(deviceInfo->hostApi)->name);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "inputs: %d | ", deviceInfo->maxInputChannels);
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "outputs: %d | ", deviceInfo->maxOutputChannels);
+
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "Default rate: %8.2f\n", deviceInfo->defaultSampleRate);
+
+		/* poll for standard sample rates */
+		inputParameters.device = i;
+		inputParameters.channelCount = deviceInfo->maxInputChannels;
+		inputParameters.sampleFormat = paInt16;
+		inputParameters.suggestedLatency = 0;	/* ignored by Pa_IsFormatSupported() */
+		inputParameters.hostApiSpecificStreamInfo = NULL;
+
+		outputParameters.device = i;
+		outputParameters.channelCount = deviceInfo->maxOutputChannels;
+		outputParameters.sampleFormat = paInt16;
+		outputParameters.suggestedLatency = 0;	/* ignored by Pa_IsFormatSupported() */
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+
+		if (inputParameters.channelCount > 0) {
+
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel input rates:", inputParameters.channelCount);
+			PrintSupportedStandardSampleRates(&inputParameters, NULL);
+		}
+
+		if (outputParameters.channelCount > 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "half-duplex 16 bit %d channel output rates:", outputParameters.channelCount);
+			PrintSupportedStandardSampleRates(NULL, &outputParameters);
+		}
+
+		if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
+
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
+							  "full-duplex 16 bit %d channel input, %d channel output rates:", inputParameters.channelCount,
+							  outputParameters.channelCount);
+			PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
+		}
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "%s", line);
+
+	return 0;
+
+  error:
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "An error occured while using the portaudio stream\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error number: %d\n", err);
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error message: %s\n", Pa_GetErrorText(err));
+	return err;
 }
 
 
 
 static switch_status_t engage_device(int sample_rate, int codec_ms)
 {
-    PaStreamParameters inputParameters, outputParameters;
+	PaStreamParameters inputParameters, outputParameters;
 	PaError err;
 
-    if (!globals.audio_stream) {
-        if (!sample_rate) {
-            sample_rate = globals.sample_rate;
-        }
-        if (!codec_ms) {
-            codec_ms = globals.codec_ms;
-        }
-
-        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) {
-            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) {
-                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 (!globals.audio_stream) {
+		if (!sample_rate) {
+			sample_rate = globals.sample_rate;
+		}
+		if (!codec_ms) {
+			codec_ms = globals.codec_ms;
+		}
+
+		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) {
+			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) {
+				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,
+								   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;
 
+		globals.read_frame.rate = sample_rate;
+		globals.read_frame.codec = &globals.read_codec;
 
 
-        switch_mutex_lock(globals.device_lock);
-        /* LOCKED ***************************************************************************************************/
-        inputParameters.device = globals.indev;
-        inputParameters.channelCount = 1;
-        inputParameters.sampleFormat = SAMPLE_TYPE;
-        inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
-        inputParameters.hostApiSpecificStreamInfo = NULL;
 
-        outputParameters.device = globals.outdev;
-        outputParameters.channelCount = 1;
-        outputParameters.sampleFormat =  SAMPLE_TYPE;
-        outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
-        outputParameters.hostApiSpecificStreamInfo = NULL;
-        err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff);
-        /* UNLOCKED **************************************************************************************************/
-        switch_mutex_unlock(globals.device_lock);
+		switch_mutex_lock(globals.device_lock);
+		/* LOCKED ************************************************************************************************** */
+		inputParameters.device = globals.indev;
+		inputParameters.channelCount = 1;
+		inputParameters.sampleFormat = SAMPLE_TYPE;
+		inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
+		inputParameters.hostApiSpecificStreamInfo = NULL;
+
+		outputParameters.device = globals.outdev;
+		outputParameters.channelCount = 1;
+		outputParameters.sampleFormat = SAMPLE_TYPE;
+		outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+		err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff);
+		/* UNLOCKED ************************************************************************************************* */
+		switch_mutex_unlock(globals.device_lock);
 
 
-        if (err != paNoError) {
-            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);
+		if (err != paNoError) {
+			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;
+		}
+	}
 
 
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 
 
 }
@@ -1370,34 +1354,34 @@
 static switch_status_t engage_ring_device(int sample_rate, int channels)
 {
 	//int codec_ms = 20;
-    PaStreamParameters outputParameters;
+	PaStreamParameters outputParameters;
 	PaError err;
 
-    if (!globals.ring_stream) {
-        if (!sample_rate) {
-            sample_rate = globals.sample_rate;
-        }
-
-        switch_mutex_lock(globals.device_lock);
-        /* LOCKED ***************************************************************************************************/
-        outputParameters.device = globals.ringdev;
-        outputParameters.channelCount = channels;
-        outputParameters.sampleFormat =  SAMPLE_TYPE;
-        outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
-        outputParameters.hostApiSpecificStreamInfo = NULL;
-        err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff);
-        /* UNLOCKED **************************************************************************************************/
-        switch_mutex_unlock(globals.device_lock);
-
-
-        if (err != paNoError) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
-            return SWITCH_STATUS_FALSE;
-        }
-    }
+	if (!globals.ring_stream) {
+		if (!sample_rate) {
+			sample_rate = globals.sample_rate;
+		}
 
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels);
-    return SWITCH_STATUS_SUCCESS;
+		switch_mutex_lock(globals.device_lock);
+		/* LOCKED ************************************************************************************************** */
+		outputParameters.device = globals.ringdev;
+		outputParameters.channelCount = channels;
+		outputParameters.sampleFormat = SAMPLE_TYPE;
+		outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
+		outputParameters.hostApiSpecificStreamInfo = NULL;
+		err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff);
+		/* UNLOCKED ************************************************************************************************* */
+		switch_mutex_unlock(globals.device_lock);
+
+
+		if (err != paNoError) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
+			return SWITCH_STATUS_FALSE;
+		}
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Engage ring device! rate: %d channels %d\n", sample_rate, channels);
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
@@ -1405,64 +1389,64 @@
 
 static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    char *dtmf = argv[0];
+	char *dtmf = argv[0];
 
-    if (switch_strlen_zero(dtmf)) {
-        stream->write_function(stream, "No DTMF Supplied!\n");
-    } else {
-        switch_mutex_lock(globals.pvt_lock);
-        if (globals.call_list) {
-            switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
-            switch_channel_queue_dtmf(channel, dtmf);
-        }
-        switch_mutex_unlock(globals.pvt_lock);
-    }
+	if (switch_strlen_zero(dtmf)) {
+		stream->write_function(stream, "No DTMF Supplied!\n");
+	} else {
+		switch_mutex_lock(globals.pvt_lock);
+		if (globals.call_list) {
+			switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
+			switch_channel_queue_dtmf(channel, dtmf);
+		}
+		switch_mutex_unlock(globals.pvt_lock);
+	}
 
-    return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp,*tech_pvt = NULL;
-    char *callid = argv[0];
-    uint8_t one_call = 0;
-
-    switch_mutex_lock(globals.pvt_lock);
-    if (switch_strlen_zero(callid)) {
-        if (globals.call_list) {
-            if (globals.call_list->next) {
-                tech_pvt = globals.call_list->next;
-            } else {
-                tech_pvt = globals.call_list;
-                one_call = 1;
-            }
-        }
-    } else if (!strcasecmp(callid, "none")) {
-        for (tp = globals.call_list; tp; tp = tp->next) {
-            switch_clear_flag_locked(tp, TFLAG_MASTER);
-        }
-        stream->write_function(stream, "OK\n");
-        goto done;
-    } else {
-        tech_pvt = switch_core_hash_find(globals.call_hash, callid);
-    }
+	private_t *tp, *tech_pvt = NULL;
+	char *callid = argv[0];
+	uint8_t one_call = 0;
+
+	switch_mutex_lock(globals.pvt_lock);
+	if (switch_strlen_zero(callid)) {
+		if (globals.call_list) {
+			if (globals.call_list->next) {
+				tech_pvt = globals.call_list->next;
+			} else {
+				tech_pvt = globals.call_list;
+				one_call = 1;
+			}
+		}
+	} else if (!strcasecmp(callid, "none")) {
+		for (tp = globals.call_list; tp; tp = tp->next) {
+			switch_clear_flag_locked(tp, TFLAG_MASTER);
+		}
+		stream->write_function(stream, "OK\n");
+		goto done;
+	} else {
+		tech_pvt = switch_core_hash_find(globals.call_hash, callid);
+	}
 
 	if (tech_pvt) {
-        if (tech_pvt == globals.call_list && !tech_pvt->next) {
-            one_call = 1;
-        }
-
-        if (!one_call) {
-            remove_pvt(tech_pvt);
-        }
-        add_pvt(tech_pvt, PA_MASTER);
-        stream->write_function(stream, "OK\n");
+		if (tech_pvt == globals.call_list && !tech_pvt->next) {
+			one_call = 1;
+		}
+
+		if (!one_call) {
+			remove_pvt(tech_pvt);
+		}
+		add_pvt(tech_pvt, PA_MASTER);
+		stream->write_function(stream, "OK\n");
 	} else {
 		stream->write_function(stream, "NO SUCH CALL\n");
 	}
 
- done:
-    switch_mutex_unlock(globals.pvt_lock);
+  done:
+	switch_mutex_unlock(globals.pvt_lock);
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -1470,24 +1454,24 @@
 
 static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tech_pvt;
-    char *callid = argv[0];
-    
-    switch_mutex_lock(globals.pvt_lock);
-    if (switch_strlen_zero(callid)) {
-        tech_pvt = globals.call_list;
-    } else {
-        tech_pvt = switch_core_hash_find(globals.call_hash, callid);
-    }
+	private_t *tech_pvt;
+	char *callid = argv[0];
+
+	switch_mutex_lock(globals.pvt_lock);
+	if (switch_strlen_zero(callid)) {
+		tech_pvt = globals.call_list;
+	} else {
+		tech_pvt = switch_core_hash_find(globals.call_hash, callid);
+	}
 
 	if (tech_pvt) {
 		switch_channel_hangup(switch_core_session_get_channel(tech_pvt->session), SWITCH_CAUSE_NORMAL_CLEARING);
-        //switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		//switch_set_flag_locked(tech_pvt, TFLAG_HUP);
 		stream->write_function(stream, "OK\n");
 	} else {
 		stream->write_function(stream, "NO SUCH CALL\n");
 	}
-    switch_mutex_unlock(globals.pvt_lock);
+	switch_mutex_unlock(globals.pvt_lock);
 
 	return SWITCH_STATUS_SUCCESS;
 
@@ -1495,43 +1479,43 @@
 
 static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp;
-    int x = 0;
-    char *callid = argv[0];
-    
-    switch_mutex_lock(globals.pvt_lock);
-
-    if (!switch_strlen_zero(callid)) {
-        if ((tp = switch_core_hash_find(globals.call_hash, callid))) {
-            if (switch_test_flag(tp, TFLAG_ANSWER)) {
-                stream->write_function(stream, "CALL ALREADY ANSWERED\n");
-            } else {
-                switch_channel_t *channel = switch_core_session_get_channel(tp->session);
-                switch_set_flag_locked(tp, TFLAG_ANSWER);
-                switch_channel_answer(channel);
-                add_pvt(tp, PA_MASTER);
-            }
-        } else {
-            stream->write_function(stream, "NO SUCH CALL\n");
-        }
-
-        goto done;
-    }
-
-    for (tp = globals.call_list; tp; tp = tp->next) {
-        if (!switch_test_flag(tp, TFLAG_ANSWER)) {
-            switch_channel_t *channel = switch_core_session_get_channel(tp->session);
-            switch_set_flag_locked(tp, TFLAG_ANSWER);
-            switch_channel_answer(channel);
-            add_pvt(tp, PA_MASTER);
-            x++;
-            break;
-        }
-	} 
- done:
-    switch_mutex_unlock(globals.pvt_lock);
+	private_t *tp;
+	int x = 0;
+	char *callid = argv[0];
 
-    stream->write_function(stream, "Answered %d channels.\n", x);    
+	switch_mutex_lock(globals.pvt_lock);
+
+	if (!switch_strlen_zero(callid)) {
+		if ((tp = switch_core_hash_find(globals.call_hash, callid))) {
+			if (switch_test_flag(tp, TFLAG_ANSWER)) {
+				stream->write_function(stream, "CALL ALREADY ANSWERED\n");
+			} else {
+				switch_channel_t *channel = switch_core_session_get_channel(tp->session);
+				switch_set_flag_locked(tp, TFLAG_ANSWER);
+				switch_channel_answer(channel);
+				add_pvt(tp, PA_MASTER);
+			}
+		} else {
+			stream->write_function(stream, "NO SUCH CALL\n");
+		}
+
+		goto done;
+	}
+
+	for (tp = globals.call_list; tp; tp = tp->next) {
+		if (!switch_test_flag(tp, TFLAG_ANSWER)) {
+			switch_channel_t *channel = switch_core_session_get_channel(tp->session);
+			switch_set_flag_locked(tp, TFLAG_ANSWER);
+			switch_channel_answer(channel);
+			add_pvt(tp, PA_MASTER);
+			x++;
+			break;
+		}
+	}
+  done:
+	switch_mutex_unlock(globals.pvt_lock);
+
+	stream->write_function(stream, "Answered %d channels.\n", x);
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1540,113 +1524,110 @@
 
 static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    char *action = argv[0];
-    char *flag_str = argv[1];
-    GFLAGS flags = GFLAG_NONE;
-    char *p;
-    int x = 0;
-
-    if (argc < 2) {
-        goto desc;
-    }
-
-    for (x = 1; x < argc; x++) {
-        flag_str = argv[x];
-        for(p = flag_str; *p; p++) {
-            *p = (char)tolower(*p);
-        }
-    
-        if (strstr(flag_str, "ear")) {
-            flags |= GFLAG_EAR;
-        } 
-        if (strstr(flag_str, "mouth")) {
-            flags |= GFLAG_MOUTH;
-        }
-    }
-
-    if (!strcasecmp(action, "on")) {
-        if (flags & GFLAG_EAR) {
-            switch_set_flag((&globals), GFLAG_EAR);
-        }
-        if (flags & GFLAG_MOUTH) {
-            switch_set_flag((&globals), GFLAG_MOUTH);
-        }
-    } else if (!strcasecmp(action, "off")) {
-        if (flags & GFLAG_EAR) {
-            switch_clear_flag((&globals), GFLAG_EAR);
-        }
-        if (flags & GFLAG_MOUTH) {
-            switch_clear_flag((&globals), GFLAG_MOUTH);
-        }
-    } else {
-        goto bad;
-    }
-
- desc:
-    x = 0;
-    stream->write_function(stream, "FLAGS: ");
-    if (switch_test_flag((&globals), GFLAG_EAR)) {
-        stream->write_function(stream, "ear");
-        x++;
-    }
-    if (switch_test_flag((&globals), GFLAG_MOUTH)) {
-        stream->write_function(stream, "%smouth", x ? "|" : "");
-        x++;
-    }
-    if (!x) {
-        stream->write_function(stream, "none");
-    }
-
-    goto done;
-
- bad:
-    stream->write_function(stream, "Usage: flags [on|off] <flags>\n");    
- done:
-    return SWITCH_STATUS_SUCCESS;
+	char *action = argv[0];
+	char *flag_str = argv[1];
+	GFLAGS flags = GFLAG_NONE;
+	char *p;
+	int x = 0;
+
+	if (argc < 2) {
+		goto desc;
+	}
+
+	for (x = 1; x < argc; x++) {
+		flag_str = argv[x];
+		for (p = flag_str; *p; p++) {
+			*p = (char) tolower(*p);
+		}
+
+		if (strstr(flag_str, "ear")) {
+			flags |= GFLAG_EAR;
+		}
+		if (strstr(flag_str, "mouth")) {
+			flags |= GFLAG_MOUTH;
+		}
+	}
+
+	if (!strcasecmp(action, "on")) {
+		if (flags & GFLAG_EAR) {
+			switch_set_flag((&globals), GFLAG_EAR);
+		}
+		if (flags & GFLAG_MOUTH) {
+			switch_set_flag((&globals), GFLAG_MOUTH);
+		}
+	} else if (!strcasecmp(action, "off")) {
+		if (flags & GFLAG_EAR) {
+			switch_clear_flag((&globals), GFLAG_EAR);
+		}
+		if (flags & GFLAG_MOUTH) {
+			switch_clear_flag((&globals), GFLAG_MOUTH);
+		}
+	} else {
+		goto bad;
+	}
+
+  desc:
+	x = 0;
+	stream->write_function(stream, "FLAGS: ");
+	if (switch_test_flag((&globals), GFLAG_EAR)) {
+		stream->write_function(stream, "ear");
+		x++;
+	}
+	if (switch_test_flag((&globals), GFLAG_MOUTH)) {
+		stream->write_function(stream, "%smouth", x ? "|" : "");
+		x++;
+	}
+	if (!x) {
+		stream->write_function(stream, "none");
+	}
+
+	goto done;
+
+  bad:
+	stream->write_function(stream, "Usage: flags [on|off] <flags>\n");
+  done:
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t list_calls(char **argv, int argc, switch_stream_handle_t *stream)
 {
-    private_t *tp;
-    int x = 0;
-    char *cid_name = "n/a";
-    char *cid_num = "n/a";
-    
-    switch_mutex_lock(globals.pvt_lock);
-    for (tp = globals.call_list; tp; tp = tp->next) {
+	private_t *tp;
+	int x = 0;
+	char *cid_name = "n/a";
+	char *cid_num = "n/a";
+
+	switch_mutex_lock(globals.pvt_lock);
+	for (tp = globals.call_list; tp; tp = tp->next) {
 		switch_channel_t *channel;
-        switch_caller_profile_t *profile;
-        x++;
-        channel = switch_core_session_get_channel(tp->session);        
-        
-        if ((profile = switch_channel_get_caller_profile(channel))) {
-            if (profile->originatee_caller_profile) {
-                cid_name = "Outbound Call";
-                cid_num = profile->originatee_caller_profile->destination_number;
-            } else {
-                cid_name = profile->caller_id_name;
-                cid_num = profile->caller_id_number;
-            }
-        }
-
-        stream->write_function(stream, "%s %s [%s (%s)] %s\n", tp->call_id, switch_channel_get_name(channel),
-                               cid_name,
-                               cid_num,
-                               switch_test_flag(tp, TFLAG_MASTER) ? "active" : "hold"
-                               );
-    }
-    switch_mutex_unlock(globals.pvt_lock);
+		switch_caller_profile_t *profile;
+		x++;
+		channel = switch_core_session_get_channel(tp->session);
+
+		if ((profile = switch_channel_get_caller_profile(channel))) {
+			if (profile->originatee_caller_profile) {
+				cid_name = "Outbound Call";
+				cid_num = profile->originatee_caller_profile->destination_number;
+			} else {
+				cid_name = profile->caller_id_name;
+				cid_num = profile->caller_id_number;
+			}
+		}
 
-    stream->write_function(stream, "\n%d call%s\n", x, x == 1 ? "" : "s");
+		stream->write_function(stream, "%s %s [%s (%s)] %s\n", tp->call_id, switch_channel_get_name(channel),
+							   cid_name, cid_num, switch_test_flag(tp, TFLAG_MASTER) ? "active" : "hold");
+	}
+	switch_mutex_unlock(globals.pvt_lock);
 
-    return SWITCH_STATUS_SUCCESS;
+	stream->write_function(stream, "\n%d call%s\n", x, x == 1 ? "" : "s");
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-    char *dest = NULL;
+	char *dest = NULL;
 
 	if (!argv[0]) {
 		stream->write_function(stream, "FAIL:Usage: call <dest>\n");
@@ -1657,9 +1638,9 @@
 	if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
-        char *dialplan = globals.dialplan;
-        char *cid_name = globals.cid_name;
-        char *cid_num = globals.cid_num;        
+		char *dialplan = globals.dialplan;
+		char *cid_name = globals.cid_name;
+		char *cid_num = globals.cid_num;
 
 		switch_core_session_add_stream(session, NULL);
 		if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
@@ -1668,7 +1649,7 @@
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
 			tech_pvt->session = session;
-            globals.flags = GFLAG_EAR | GFLAG_MOUTH;
+			globals.flags = GFLAG_EAR | GFLAG_MOUTH;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(&session);
@@ -1676,31 +1657,29 @@
 		}
 
 		if (!switch_strlen_zero(argv[1])) {
-            dialplan = argv[1];
-        }
+			dialplan = argv[1];
+		}
+
+		if (!switch_strlen_zero(argv[2])) {
+			cid_num = argv[2];
+		}
+
+		if (!switch_strlen_zero(argv[3])) {
+			cid_name = argv[3];
+		}
+
+		if (!switch_strlen_zero(argv[4])) {
+			tech_pvt->sample_rate = atoi(argv[4]);
+		}
 
-        if (!switch_strlen_zero(argv[2])) {
-            cid_num = argv[2];
-        }
-
-        if (!switch_strlen_zero(argv[3])) {
-            cid_name = argv[3];
-        }
-
-        if (!switch_strlen_zero(argv[4])) {
-            tech_pvt->sample_rate = atoi(argv[4]);
-        }
-
-        if (!switch_strlen_zero(argv[4])) {
-            tech_pvt->codec_ms = atoi(argv[5]);
-        }
+		if (!switch_strlen_zero(argv[4])) {
+			tech_pvt->codec_ms = atoi(argv[5]);
+		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																  NULL,
-																  dialplan,
-                                                                  cid_name,
-																  cid_num,
-                                                                  NULL, NULL, NULL, NULL, (char *)modname, NULL, dest)) != 0) {
+																  dialplan, cid_name, cid_num, NULL, NULL, NULL, NULL, (char *) modname, NULL,
+																  dest)) != 0) {
 			char name[128];
 			snprintf(name, sizeof(name), "PortAudio/%s",
 					 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
@@ -1710,14 +1689,14 @@
 		}
 		tech_pvt->session = session;
 		if ((status = engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms)) == SWITCH_STATUS_SUCCESS) {
-            switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
-            switch_channel_mark_answered(channel);
+			switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
+			switch_channel_mark_answered(channel);
 			switch_channel_set_state(channel, CS_INIT);
 			switch_core_session_thread_launch(tech_pvt->session);
-            add_pvt(tech_pvt, PA_MASTER);
+			add_pvt(tech_pvt, PA_MASTER);
 			stream->write_function(stream, "SUCCESS:%s:%s\n", tech_pvt->call_id, switch_core_session_get_uuid(tech_pvt->session));
 		} else {
-            switch_core_session_destroy(&session);
+			switch_core_session_destroy(&session);
 			stream->write_function(stream, "FAIL:Device Error!\n");
 		}
 	}
@@ -1727,72 +1706,71 @@
 
 static switch_status_t padep(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-    stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
-    return SWITCH_STATUS_SUCCESS;
+	stream->write_function(stream, "This command no longer exists (try 'pa help')\n");
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-    char *argv[1024] = {0};
-    int argc = 0;
-    char *mycmd = NULL, *devname = NULL;
-    switch_status_t status = SWITCH_STATUS_SUCCESS;
-    pa_command_t func = NULL;
-    int lead = 1, devval = 0;
-    const char *usage_string = "USAGE:\n"
-        "--------------------------------------------------------------------------------\n"
-        "pa help\n"
-        "pa dump\n"
-        "pa call <dest> [<dialplan> <cid_name> <cid_num> <rate>]\n"
-        "pa answer [<call_id>]\n"
-        "pa hangup [<call_id>]\n"
-        "pa list\n"
-        "pa switch [<call_id>|none]\n"
-        "pa dtmf <digit string>\n"
-        "pa flags [on|off] [ear] [mouth]\n"
+	char *argv[1024] = { 0 };
+	int argc = 0;
+	char *mycmd = NULL, *devname = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	pa_command_t func = NULL;
+	int lead = 1, devval = 0;
+	const char *usage_string = "USAGE:\n"
+		"--------------------------------------------------------------------------------\n"
+		"pa help\n"
+		"pa dump\n"
+		"pa call <dest> [<dialplan> <cid_name> <cid_num> <rate>]\n"
+		"pa answer [<call_id>]\n"
+		"pa hangup [<call_id>]\n"
+		"pa list\n"
+		"pa switch [<call_id>|none]\n"
+		"pa dtmf <digit string>\n"
+		"pa flags [on|off] [ear] [mouth]\n"
 		"pa devlist\n"
 		"pa indev [#<num>|<partial name>\n"
 		"pa outdev [#<num>|<partial name>\n"
-		"pa ringdev [#<num>|<partial name>\n"
-        "--------------------------------------------------------------------------------\n";
+		"pa ringdev [#<num>|<partial name>\n" "--------------------------------------------------------------------------------\n";
+
+	if (switch_strlen_zero(cmd)) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	}
+
+	if (!(mycmd = strdup(cmd))) {
+		status = SWITCH_STATUS_MEMERR;
+		goto done;
+	}
 
-    if (switch_strlen_zero(cmd)) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    }
-
-    if (!(mycmd = strdup(cmd))) {
-        status = SWITCH_STATUS_MEMERR;
-        goto done;
-    }
-    
-    if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    }
-    
-    if (!strcasecmp(argv[0], "call")) {
-        func = place_call;
-    } else if (!strcasecmp(argv[0], "help")) {
-        stream->write_function(stream, "%s", usage_string);
-        goto done;
-    } else if (!strcasecmp(argv[0], "devlist")) {
+	if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	}
+
+	if (!strcasecmp(argv[0], "call")) {
+		func = place_call;
+	} else if (!strcasecmp(argv[0], "help")) {
+		stream->write_function(stream, "%s", usage_string);
+		goto done;
+	} else if (!strcasecmp(argv[0], "devlist")) {
 		func = devlist;
-    } else if (!strcasecmp(argv[0], "dump")) {
-        dump_info();
-        goto done;
-    } else if (!strcasecmp(argv[0], "list")) {
-        func = list_calls;
-    } else if (!strcasecmp(argv[0], "flags")) {
-        func = do_flags;
-    } else if (!strcasecmp(argv[0], "hangup")) {
-        func = hangup_call;
-    } else if (!strcasecmp(argv[0], "answer")) {
-        func = answer_call;
-    } else if (!strcasecmp(argv[0], "switch")) {
-        func = switch_call;
-    } else if (!strcasecmp(argv[0], "dtmf")) {
-        func = dtmf_call;
+	} else if (!strcasecmp(argv[0], "dump")) {
+		dump_info();
+		goto done;
+	} else if (!strcasecmp(argv[0], "list")) {
+		func = list_calls;
+	} else if (!strcasecmp(argv[0], "flags")) {
+		func = do_flags;
+	} else if (!strcasecmp(argv[0], "hangup")) {
+		func = hangup_call;
+	} else if (!strcasecmp(argv[0], "answer")) {
+		func = answer_call;
+	} else if (!strcasecmp(argv[0], "switch")) {
+		func = switch_call;
+	} else if (!strcasecmp(argv[0], "dtmf")) {
+		func = dtmf_call;
 	} else if (argv[1] && !strcmp(argv[0], "indev")) {
 		if (*argv[1] == '#') {
 			devval = get_dev_by_number(atoi(argv[1] + 1), 1);
@@ -1810,7 +1788,7 @@
 			devval = get_dev_by_name(argv[1], 0);
 		}
 		devname = "outdev";
-		if (devval > 0)  {
+		if (devval > 0) {
 			globals.outdev = devval;
 		}
 	} else if (argv[1] && !strcmp(argv[0], "ringdev")) {
@@ -1823,11 +1801,11 @@
 		if (devval > 0) {
 			globals.ringdev = devval;
 		}
-    }
-    
-    if (func) {
-        status = func(&argv[lead], argc - lead, stream);
-    } else {
+	}
+
+	if (func) {
+		status = func(&argv[lead], argc - lead, stream);
+	} else {
 		if (devname) {
 			if (devval > 0) {
 				stream->write_function(stream, "%s set to %d\n", devname, devval);
@@ -1837,13 +1815,13 @@
 		} else {
 			stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
 		}
-    }
+	}
 
- done:
+  done:
 
-    switch_safe_free(mycmd);
+	switch_safe_free(mycmd);
 
-    return status;
+	return status;
 }
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.c	Fri Mar 30 12:19:18 2007
@@ -81,17 +81,17 @@
 #   define PaUtil_WriteMemoryBarrier()
 #else
 
-#if defined(__APPLE__) //|| defined(__FreeBSD__)
+#if defined(__APPLE__)			//|| defined(__FreeBSD__)
 #   include <libkern/OSAtomic.h>
-    /* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
-       full memory barriers, so the three types of barriers are the same. */
+	/* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
+	   full memory barriers, so the three types of barriers are the same. */
 #   define PaUtil_FullMemoryBarrier()  OSMemoryBarrier()
 #   define PaUtil_ReadMemoryBarrier()  OSMemoryBarrier()
 #   define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
 #elif defined(__GNUC__)
 
-    /* GCC understands volatile asm and "memory" to mean it
-     * should not reorder memory read/writes */
+	/* GCC understands volatile asm and "memory" to mean it
+	 * should not reorder memory read/writes */
 #   if defined( __PPC__ )
 #      define PaUtil_FullMemoryBarrier()  __asm__ volatile("sync":::"memory")
 #      define PaUtil_ReadMemoryBarrier()  __asm__ volatile("sync":::"memory")
@@ -123,37 +123,39 @@
  * Initialize FIFO.
  * numBytes must be power of 2, returns -1 if not.
  */
-long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr )
+long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr)
 {
-    if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */
-    rbuf->bufferSize = numBytes;
-    rbuf->buffer = (char *)dataPtr;
-    PaUtil_FlushRingBuffer( rbuf );
-    rbuf->bigMask = (numBytes*2)-1;
-    rbuf->smallMask = (numBytes)-1;
-    return 0;
+	if (((numBytes - 1) & numBytes) != 0)
+		return -1;				/* Not Power of two. */
+	rbuf->bufferSize = numBytes;
+	rbuf->buffer = (char *) dataPtr;
+	PaUtil_FlushRingBuffer(rbuf);
+	rbuf->bigMask = (numBytes * 2) - 1;
+	rbuf->smallMask = (numBytes) - 1;
+	return 0;
 }
 
 /***************************************************************************
 ** Return number of bytes available for reading. */
-long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf )
+long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf)
 {
-    PaUtil_ReadMemoryBarrier();
-    return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask );
+	PaUtil_ReadMemoryBarrier();
+	return ((rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask);
 }
+
 /***************************************************************************
 ** Return number of bytes available for writing. */
-long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf )
+long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf)
 {
-    /* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
-    return ( rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
+	/* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
+	return (rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
 }
 
 /***************************************************************************
 ** Clear buffer. Should only be called when buffer is NOT being read. */
-void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
+void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf)
 {
-    rbuf->writeIndex = rbuf->readIndex = 0;
+	rbuf->writeIndex = rbuf->readIndex = 0;
 }
 
 /***************************************************************************
@@ -162,42 +164,38 @@
 ** If non-contiguous, size2 will be the size of second region.
 ** Returns room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                       void **dataPtr1, long *sizePtr1,
-                                       void **dataPtr2, long *sizePtr2 )
-{
-    long   index;
-    long   available = PaUtil_GetRingBufferWriteAvailable( rbuf );
-    if( numBytes > available ) numBytes = available;
-    /* Check to see if write is not contiguous. */
-    index = rbuf->writeIndex & rbuf->smallMask;
-    if( (index + numBytes) > rbuf->bufferSize )
-    {
-        /* Write data in two blocks that wrap the buffer. */
-        long   firstHalf = rbuf->bufferSize - index;
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = firstHalf;
-        *dataPtr2 = &rbuf->buffer[0];
-        *sizePtr2 = numBytes - firstHalf;
-    }
-    else
-    {
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = numBytes;
-        *dataPtr2 = NULL;
-        *sizePtr2 = 0;
-    }
-    return numBytes;
+long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
+{
+	long index;
+	long available = PaUtil_GetRingBufferWriteAvailable(rbuf);
+	if (numBytes > available)
+		numBytes = available;
+	/* Check to see if write is not contiguous. */
+	index = rbuf->writeIndex & rbuf->smallMask;
+	if ((index + numBytes) > rbuf->bufferSize) {
+		/* Write data in two blocks that wrap the buffer. */
+		long firstHalf = rbuf->bufferSize - index;
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = firstHalf;
+		*dataPtr2 = &rbuf->buffer[0];
+		*sizePtr2 = numBytes - firstHalf;
+	} else {
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = numBytes;
+		*dataPtr2 = NULL;
+		*sizePtr2 = 0;
+	}
+	return numBytes;
 }
 
 
 /***************************************************************************
 */
-long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
+long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes)
 {
-    /* we need to ensure that previous writes are seen before we update the write index */
-    PaUtil_WriteMemoryBarrier();
-    return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
+	/* we need to ensure that previous writes are seen before we update the write index */
+	PaUtil_WriteMemoryBarrier();
+	return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
 }
 
 /***************************************************************************
@@ -206,81 +204,72 @@
 ** If non-contiguous, size2 will be the size of second region.
 ** Returns room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                void **dataPtr1, long *sizePtr1,
-                                void **dataPtr2, long *sizePtr2 )
-{
-    long   index;
-    long   available = PaUtil_GetRingBufferReadAvailable( rbuf );
-    if( numBytes > available ) numBytes = available;
-    /* Check to see if read is not contiguous. */
-    index = rbuf->readIndex & rbuf->smallMask;
-    if( (index + numBytes) > rbuf->bufferSize )
-    {
-        /* Write data in two blocks that wrap the buffer. */
-        long firstHalf = rbuf->bufferSize - index;
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = firstHalf;
-        *dataPtr2 = &rbuf->buffer[0];
-        *sizePtr2 = numBytes - firstHalf;
-    }
-    else
-    {
-        *dataPtr1 = &rbuf->buffer[index];
-        *sizePtr1 = numBytes;
-        *dataPtr2 = NULL;
-        *sizePtr2 = 0;
-    }
-    return numBytes;
+long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
+{
+	long index;
+	long available = PaUtil_GetRingBufferReadAvailable(rbuf);
+	if (numBytes > available)
+		numBytes = available;
+	/* Check to see if read is not contiguous. */
+	index = rbuf->readIndex & rbuf->smallMask;
+	if ((index + numBytes) > rbuf->bufferSize) {
+		/* Write data in two blocks that wrap the buffer. */
+		long firstHalf = rbuf->bufferSize - index;
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = firstHalf;
+		*dataPtr2 = &rbuf->buffer[0];
+		*sizePtr2 = numBytes - firstHalf;
+	} else {
+		*dataPtr1 = &rbuf->buffer[index];
+		*sizePtr1 = numBytes;
+		*dataPtr2 = NULL;
+		*sizePtr2 = 0;
+	}
+	return numBytes;
 }
+
 /***************************************************************************
 */
-long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes )
+long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes)
 {
-    /* we need to ensure that previous writes are always seen before updating the index. */
-    PaUtil_WriteMemoryBarrier();
-    return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
+	/* we need to ensure that previous writes are always seen before updating the index. */
+	PaUtil_WriteMemoryBarrier();
+	return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
 }
 
 /***************************************************************************
 ** Return bytes written. */
-long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes )
+long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes)
 {
-    long size1, size2, numWritten;
-    void *data1, *data2;
-    numWritten = PaUtil_GetRingBufferWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
-    if( size2 > 0 )
-    {
-
-        memcpy( data1, data, size1 );
-        data = ((char *)data) + size1;
-        memcpy( data2, data, size2 );
-    }
-    else
-    {
-        memcpy( data1, data, size1 );
-    }
-    PaUtil_AdvanceRingBufferWriteIndex( rbuf, numWritten );
-    return numWritten;
+	long size1, size2, numWritten;
+	void *data1, *data2;
+	numWritten = PaUtil_GetRingBufferWriteRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
+	if (size2 > 0) {
+
+		memcpy(data1, data, size1);
+		data = ((char *) data) + size1;
+		memcpy(data2, data, size2);
+	} else {
+		memcpy(data1, data, size1);
+	}
+	PaUtil_AdvanceRingBufferWriteIndex(rbuf, numWritten);
+	return numWritten;
 }
 
 /***************************************************************************
 ** Return bytes read. */
-long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes )
+long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes)
 {
-    long size1, size2, numRead;
-    void *data1, *data2;
-    numRead = PaUtil_GetRingBufferReadRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
-    if( size2 > 0 )
-    {
-        memcpy( data, data1, size1 );
-        data = ((char *)data) + size1;
-        memcpy( data, data2, size2 );
-    }
-    else
-    {
-        memcpy( data, data1, size1 );
-    }
-    PaUtil_AdvanceRingBufferReadIndex( rbuf, numRead );
-    return numRead;
+	long size1, size2, numRead;
+	void *data1, *data2;
+	numRead = PaUtil_GetRingBufferReadRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
+	if (size2 > 0) {
+		memcpy(data, data1, size1);
+		data = ((char *) data) + size1;
+		memcpy(data, data2, size2);
+	} else {
+		memcpy(data, data1, size1);
+	}
+	PaUtil_AdvanceRingBufferReadIndex(rbuf, numRead);
+	return numRead;
 }

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pa_ringbuffer.h	Fri Mar 30 12:19:18 2007
@@ -51,19 +51,17 @@
 */
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-typedef struct PaUtilRingBuffer
-{
-    long   bufferSize; /* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
-    long   writeIndex; /* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
-    long   readIndex;  /* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
-    long   bigMask;    /* Used for wrapping indices with extra bit to distinguish full/empty. */
-    long   smallMask;  /* Used for fitting indices to buffer. */
-    char  *buffer;
-}PaUtilRingBuffer;
+extern "C" {
+#endif							/* __cplusplus */
+
+	typedef struct PaUtilRingBuffer {
+		long bufferSize;		/* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
+		long writeIndex;		/* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
+		long readIndex;			/* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
+		long bigMask;			/* Used for wrapping indices with extra bit to distinguish full/empty. */
+		long smallMask;			/* Used for fitting indices to buffer. */
+		char *buffer;
+	} PaUtilRingBuffer;
 
 /** Initialize Ring Buffer.
 
@@ -76,13 +74,13 @@
 
  @return -1 if numBytes is not a power of 2, otherwise 0.
 */
-long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr );
+	long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr);
 
 /** Clear buffer. Should only be called when buffer is NOT being read.
 
  @param rbuf The ring buffer.
 */
-void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
+	void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf);
 
 /** Retrieve the number of bytes available in the ring buffer for writing.
 
@@ -90,7 +88,7 @@
 
  @return The number of bytes available for writing.
 */
-long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
+	long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf);
 
 /** Retrieve the number of bytes available in the ring buffer for reading.
 
@@ -98,7 +96,7 @@
 
  @return The number of bytes available for reading.
 */
-long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
+	long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf);
 
 /** Write data to the ring buffer.
 
@@ -110,7 +108,7 @@
 
  @return The number of bytes written.
 */
-long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes );
+	long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes);
 
 /** Read data from the ring buffer.
 
@@ -122,7 +120,7 @@
 
  @return The number of bytes read.
 */
-long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes );
+	long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes);
 
 /** Get address of region(s) to which we can write data.
 
@@ -144,9 +142,7 @@
 
  @return The room available to be written or numBytes, whichever is smaller.
 */
-long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                       void **dataPtr1, long *sizePtr1,
-                                       void **dataPtr2, long *sizePtr2 );
+	long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
 
 /** Advance the write index to the next location to be written.
 
@@ -156,7 +152,7 @@
 
  @return The new position.
 */
-long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes );
+	long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes);
 
 /** Get address of region(s) from which we can write data.
 
@@ -178,9 +174,7 @@
 
  @return The number of bytes available for reading.
 */
-long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
-                                      void **dataPtr1, long *sizePtr1,
-                                      void **dataPtr2, long *sizePtr2 );
+	long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes, void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
 
 /** Advance the read index to the next location to be read.
 
@@ -190,9 +184,9 @@
 
  @return The new position.
 */
-long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes );
+	long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes);
 
 #ifdef __cplusplus
 }
-#endif /* __cplusplus */
-#endif /* PA_RINGBUFFER_H */
+#endif							/* __cplusplus */
+#endif							/* PA_RINGBUFFER_H */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.c	Fri Mar 30 12:19:18 2007
@@ -59,13 +59,10 @@
 /******** Prototypes ****************************************************/
 /************************************************************************/
 
-static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
-                               unsigned long framesPerBuffer,
-							   const PaStreamCallbackTimeInfo* timeInfo,
-							   PaStreamCallbackFlags statusFlags,
-							   void *userData );
-static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame );
-static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf );
+static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+							  unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
+static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
+static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
 
 /************************************************************************/
 /******** Functions *****************************************************/
@@ -74,122 +71,118 @@
 /* Called from PortAudio.
  * Read and write data only if there is room in FIFOs.
  */
-static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
-                               unsigned long framesPerBuffer,
-                               const PaStreamCallbackTimeInfo* timeInfo,
-							   PaStreamCallbackFlags statusFlags,
-							   void *userData )
-{
-    PABLIO_Stream *data = (PABLIO_Stream*)userData;
-    long numBytes = data->bytesPerFrame * framesPerBuffer;
-
-    /* This may get called with NULL inputBuffer during initial setup. */
-    if( inputBuffer != NULL )
-    {
-        PaUtil_WriteRingBuffer( &data->inFIFO, inputBuffer, numBytes );
-    }
-    if( outputBuffer != NULL )
-    {
-        int i;
-        int numRead = PaUtil_ReadRingBuffer( &data->outFIFO, outputBuffer, numBytes );
-        /* Zero out remainder of buffer if we run out of data. */
-        for( i=numRead; i<numBytes; i++ )
-        {
-            ((char *)outputBuffer)[i] = 0;
-        }
-    }
+static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+							  unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
+{
+	PABLIO_Stream *data = (PABLIO_Stream *) userData;
+	long numBytes = data->bytesPerFrame * framesPerBuffer;
+
+	/* This may get called with NULL inputBuffer during initial setup. */
+	if (inputBuffer != NULL) {
+		PaUtil_WriteRingBuffer(&data->inFIFO, inputBuffer, numBytes);
+	}
+	if (outputBuffer != NULL) {
+		int i;
+		int numRead = PaUtil_ReadRingBuffer(&data->outFIFO, outputBuffer, numBytes);
+		/* Zero out remainder of buffer if we run out of data. */
+		for (i = numRead; i < numBytes; i++) {
+			((char *) outputBuffer)[i] = 0;
+		}
+	}
 
-    return 0;
+	return 0;
 }
 
 /* Allocate buffer. */
-static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame )
+static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame)
 {
-    long numBytes = numFrames * bytesPerFrame;
-    char *buffer = (char *) malloc( numBytes );
-    if( buffer == NULL ) return paInsufficientMemory;
-    memset( buffer, 0, numBytes );
-    return (PaError) PaUtil_InitializeRingBuffer( rbuf, numBytes, buffer );
+	long numBytes = numFrames * bytesPerFrame;
+	char *buffer = (char *) malloc(numBytes);
+	if (buffer == NULL)
+		return paInsufficientMemory;
+	memset(buffer, 0, numBytes);
+	return (PaError) PaUtil_InitializeRingBuffer(rbuf, numBytes, buffer);
 }
 
 /* Free buffer. */
-static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf )
+static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf)
 {
-    if( rbuf->buffer ) free( rbuf->buffer );
-    rbuf->buffer = NULL;
-    return paNoError;
+	if (rbuf->buffer)
+		free(rbuf->buffer);
+	rbuf->buffer = NULL;
+	return paNoError;
 }
 
 /************************************************************
  * Write data to ring buffer.
  * Will not return until all the data has been written.
  */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
+long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
 {
-    long bytesWritten;
-    char *p = (char *) data;
-    long numBytes = aStream->bytesPerFrame * numFrames;
-    while( numBytes > 0)
-    {
-        bytesWritten = PaUtil_WriteRingBuffer( &aStream->outFIFO, p, numBytes );
-        numBytes -= bytesWritten;
-        p += bytesWritten;
-        if( numBytes > 0) Pa_Sleep(10);
-    }
-    return numFrames;
+	long bytesWritten;
+	char *p = (char *) data;
+	long numBytes = aStream->bytesPerFrame * numFrames;
+	while (numBytes > 0) {
+		bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes);
+		numBytes -= bytesWritten;
+		p += bytesWritten;
+		if (numBytes > 0)
+			Pa_Sleep(10);
+	}
+	return numFrames;
 }
 
 /************************************************************
  * Read data from ring buffer.
  * Will not return until all the data has been read.
  */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
+long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
 {
-    long bytesRead;
-    char *p = (char *) data;
-    long numBytes = aStream->bytesPerFrame * numFrames;
-
-    while( numBytes > 0)
-    {
-        bytesRead = PaUtil_ReadRingBuffer( &aStream->inFIFO, p, numBytes );
-        numBytes -= bytesRead;
-        p += bytesRead;
-        if( numBytes > 0) Pa_Sleep(10);
-    }
-    return numFrames;
+	long bytesRead;
+	char *p = (char *) data;
+	long numBytes = aStream->bytesPerFrame * numFrames;
+
+	while (numBytes > 0) {
+		bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
+		numBytes -= bytesRead;
+		p += bytesRead;
+		if (numBytes > 0)
+			Pa_Sleep(10);
+	}
+	return numFrames;
 }
 
 /************************************************************
  * Return the number of frames that could be written to the stream without
  * having to wait.
  */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream )
+long GetAudioStreamWriteable(PABLIO_Stream * aStream)
 {
-    int bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-    return bytesEmpty / aStream->bytesPerFrame;
+	int bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+	return bytesEmpty / aStream->bytesPerFrame;
 }
 
 /************************************************************
  * Return the number of frames that are available to be read from the
  * stream without having to wait.
  */
-long GetAudioStreamReadable( PABLIO_Stream *aStream )
+long GetAudioStreamReadable(PABLIO_Stream * aStream)
 {
-    int bytesFull = PaUtil_GetRingBufferReadAvailable( &aStream->inFIFO );
-    return bytesFull / aStream->bytesPerFrame;
+	int bytesFull = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
+	return bytesFull / aStream->bytesPerFrame;
 }
 
 /************************************************************/
-static unsigned long RoundUpToNextPowerOf2( unsigned long n )
+static unsigned long RoundUpToNextPowerOf2(unsigned long n)
 {
-    long numBits = 0;
-    if( ((n-1) & n) == 0) return n; /* Already Power of two. */
-    while( n > 0 )
-    {
-        n= n>>1;
-        numBits++;
-    }
-    return (1<<numBits);
+	long numBits = 0;
+	if (((n - 1) & n) == 0)
+		return n;				/* Already Power of two. */
+	while (n > 0) {
+		n = n >> 1;
+		numBits++;
+	}
+	return (1 << numBits);
 }
 
 /************************************************************
@@ -197,27 +190,27 @@
  * Allocates PABLIO_Stream structure.
  *
  */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, 
-						 const PaStreamParameters *inputParameters,
-						 const PaStreamParameters *outputParameters,
-						 double sampleRate,
-						 PaStreamFlags streamFlags)
-{
-    long   bytesPerSample;
-    PaError err;
-    PABLIO_Stream *aStream;
-    long   numFrames;
+PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
+						const PaStreamParameters * inputParameters, const PaStreamParameters * outputParameters, double sampleRate,
+						PaStreamFlags streamFlags)
+{
+	long bytesPerSample;
+	PaError err;
+	PABLIO_Stream *aStream;
+	long numFrames;
 	long numBytes;
 	int channels = 1;
 
-    /* Allocate PABLIO_Stream structure for caller. */
-    aStream = (PABLIO_Stream *) malloc( sizeof(PABLIO_Stream) );
-    if( aStream == NULL ) return paInsufficientMemory;
-    memset( aStream, 0, sizeof(PABLIO_Stream) );
-
-    /* Initialize PortAudio  */
-    err = Pa_Initialize();
-    if( err != paNoError ) goto error;
+	/* Allocate PABLIO_Stream structure for caller. */
+	aStream = (PABLIO_Stream *) malloc(sizeof(PABLIO_Stream));
+	if (aStream == NULL)
+		return paInsufficientMemory;
+	memset(aStream, 0, sizeof(PABLIO_Stream));
+
+	/* Initialize PortAudio  */
+	err = Pa_Initialize();
+	if (err != paNoError)
+		goto error;
 
 	if (inputParameters) {
 		channels = inputParameters->channelCount;
@@ -225,81 +218,77 @@
 		channels = outputParameters->channelCount;
 	}
 
-    numFrames = 4 * FRAMES_PER_BUFFER;
-    numFrames = RoundUpToNextPowerOf2( numFrames );
+	numFrames = 4 * FRAMES_PER_BUFFER;
+	numFrames = RoundUpToNextPowerOf2(numFrames);
 
 	bytesPerSample = 2;
 	aStream->samplesPerFrame = channels;
-    aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
+	aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
 
-    /* Initialize Ring Buffers */
+	/* Initialize Ring Buffers */
 
 	if (inputParameters) {
-		err = PABLIO_InitFIFO( &aStream->inFIFO, numFrames, aStream->bytesPerFrame );
-		if( err != paNoError ) goto error;
+		err = PABLIO_InitFIFO(&aStream->inFIFO, numFrames, aStream->bytesPerFrame);
+		if (err != paNoError)
+			goto error;
 	}
 
 	if (outputParameters) {
-		err = PABLIO_InitFIFO( &aStream->outFIFO, numFrames, aStream->bytesPerFrame );
-		if( err != paNoError ) goto error;
+		err = PABLIO_InitFIFO(&aStream->outFIFO, numFrames, aStream->bytesPerFrame);
+		if (err != paNoError)
+			goto error;
 	}
 
 	/* Make Write FIFO appear full initially. */
-	numBytes = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-	PaUtil_AdvanceRingBufferWriteIndex( &aStream->outFIFO, numBytes );
-	
-
-    /* Open a PortAudio stream that we will use to communicate with the underlying
-     * audio drivers. */
-    err = Pa_OpenStream(
-              &aStream->stream,
-			  inputParameters,
-              outputParameters,
-			  sampleRate,
-              FRAMES_PER_BUFFER,
-			  streamFlags,
-              blockingIOCallback,
-              aStream );
-    if( err != paNoError ) goto error;
-
-    err = Pa_StartStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    *rwblPtr = aStream;
-    return paNoError;
-
-error:
-    CloseAudioStream( aStream );
-    *rwblPtr = NULL;
-    return err;
+	numBytes = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+	PaUtil_AdvanceRingBufferWriteIndex(&aStream->outFIFO, numBytes);
+
+
+	/* Open a PortAudio stream that we will use to communicate with the underlying
+	 * audio drivers. */
+	err = Pa_OpenStream(&aStream->stream, inputParameters, outputParameters, sampleRate, FRAMES_PER_BUFFER, streamFlags, blockingIOCallback, aStream);
+	if (err != paNoError)
+		goto error;
+
+	err = Pa_StartStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	*rwblPtr = aStream;
+	return paNoError;
+
+  error:
+	CloseAudioStream(aStream);
+	*rwblPtr = NULL;
+	return err;
 }
 
 /************************************************************/
-PaError CloseAudioStream( PABLIO_Stream *aStream )
+PaError CloseAudioStream(PABLIO_Stream * aStream)
 {
-    PaError err;
-    int bytesEmpty;
-    int byteSize = aStream->outFIFO.bufferSize;
-
-    /* If we are writing data, make sure we play everything written. */
-    if( byteSize > 0 )
-    {
-        bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-        while( bytesEmpty < byteSize )
-        {
-            Pa_Sleep( 10 );
-            bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
-        }
-    }
-
-    err = Pa_StopStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    err = Pa_CloseStream( aStream->stream );
-    if( err != paNoError ) goto error;
-    Pa_Terminate();
-
-error:
-    PABLIO_TermFIFO( &aStream->inFIFO );
-    PABLIO_TermFIFO( &aStream->outFIFO );
-    free( aStream );
-    return err;
+	PaError err;
+	int bytesEmpty;
+	int byteSize = aStream->outFIFO.bufferSize;
+
+	/* If we are writing data, make sure we play everything written. */
+	if (byteSize > 0) {
+		bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+		while (bytesEmpty < byteSize) {
+			Pa_Sleep(10);
+			bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
+		}
+	}
+
+	err = Pa_StopStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	err = Pa_CloseStream(aStream->stream);
+	if (err != paNoError)
+		goto error;
+	Pa_Terminate();
+
+  error:
+	PABLIO_TermFIFO(&aStream->inFIFO);
+	PABLIO_TermFIFO(&aStream->outFIFO);
+	free(aStream);
+	return err;
 }

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_portaudio/pablio.h	Fri Mar 30 12:19:18 2007
@@ -2,9 +2,8 @@
 #define _PABLIO_H
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
+extern "C" {
+#endif							/* __cplusplus */
 
 /*
  * $Id: pablio.h 1083 2006-08-23 07:30:49Z rossb $
@@ -57,15 +56,13 @@
 
 #include <string.h>
 
-typedef struct
-{
-    PaUtilRingBuffer   inFIFO;
-    PaUtilRingBuffer   outFIFO;
-    PaStream *stream;
-    int          bytesPerFrame;
-    int          samplesPerFrame;
-}
-PABLIO_Stream;
+	typedef struct {
+		PaUtilRingBuffer inFIFO;
+		PaUtilRingBuffer outFIFO;
+		PaStream *stream;
+		int bytesPerFrame;
+		int samplesPerFrame;
+	} PABLIO_Stream;
 
 /* Values for flags for OpenAudioStream(). */
 #define PABLIO_READ     (1<<0)
@@ -78,25 +75,25 @@
  * Write data to ring buffer.
  * Will not return until all the data has been written.
  */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
+	long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
 
 /************************************************************
  * Read data from ring buffer.
  * Will not return until all the data has been read.
  */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
+	long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
 
 /************************************************************
  * Return the number of frames that could be written to the stream without
  * having to wait.
  */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream );
+	long GetAudioStreamWriteable(PABLIO_Stream * aStream);
 
 /************************************************************
  * Return the number of frames that are available to be read from the
  * stream without having to wait.
  */
-long GetAudioStreamReadable( PABLIO_Stream *aStream );
+	long GetAudioStreamReadable(PABLIO_Stream * aStream);
 
 /************************************************************
  * Opens a PortAudio stream with default characteristics.
@@ -106,15 +103,13 @@
  *    PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
  *    and either PABLIO_MONO or PABLIO_STEREO
  */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, 
-						 const PaStreamParameters *inputParameters,
-						 const PaStreamParameters *outputParameters,
-						 double sampleRate,
-						 PaStreamCallbackFlags statusFlags);
+	PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
+							const PaStreamParameters * inputParameters,
+							const PaStreamParameters * outputParameters, double sampleRate, PaStreamCallbackFlags statusFlags);
 
-PaError CloseAudioStream( PABLIO_Stream *aStream );
+	PaError CloseAudioStream(PABLIO_Stream * aStream);
 
 #ifdef __cplusplus
 }
-#endif /* __cplusplus */
-#endif /* _PABLIO_H */
+#endif							/* __cplusplus */
+#endif							/* _PABLIO_H */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Mar 30 12:19:18 2007
@@ -41,7 +41,7 @@
 /*************************************************************************************************************************************************************/
 #define HAVE_APR
 #include <switch.h>
-static const switch_state_handler_table_t noop_state_handler = {0};
+static const switch_state_handler_table_t noop_state_handler = { 0 };
 struct outbound_reg;
 typedef struct outbound_reg outbound_reg_t;
 
@@ -50,7 +50,7 @@
 #define NUA_MAGIC_T sofia_profile_t
 
 struct sofia_private {
-    char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
+	char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
 	outbound_reg_t *gateway;
 };
 
@@ -87,40 +87,29 @@
 
 
 static char reg_sql[] =
-"CREATE TABLE sip_registrations (\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   contact         VARCHAR(1024),\n"
-"   status          VARCHAR(255),\n"
-"   rpid            VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_registrations (\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n"
+	"   contact         VARCHAR(1024),\n" "   status          VARCHAR(255),\n" "   rpid            VARCHAR(255),\n" "   expires         INTEGER(8)" ");\n";
 
 
 static char sub_sql[] =
-"CREATE TABLE sip_subscriptions (\n"
-"   proto           VARCHAR(255),\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   sub_to_user     VARCHAR(255),\n"
-"   sub_to_host     VARCHAR(255),\n"
-"   event           VARCHAR(255),\n"
-"   contact         VARCHAR(1024),\n"
-"   call_id         VARCHAR(255),\n"
-"   full_from       VARCHAR(255),\n"
-"   full_via        VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_subscriptions (\n"
+	"   proto           VARCHAR(255),\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n"
+	"   sub_to_user     VARCHAR(255),\n"
+	"   sub_to_host     VARCHAR(255),\n"
+	"   event           VARCHAR(255),\n"
+	"   contact         VARCHAR(1024),\n"
+	"   call_id         VARCHAR(255),\n" "   full_from       VARCHAR(255),\n" "   full_via        VARCHAR(255),\n" "   expires         INTEGER(8)" ");\n";
 
 
 static char auth_sql[] =
-"CREATE TABLE sip_authentication (\n"
-"   user            VARCHAR(255),\n"
-"   host            VARCHAR(255),\n"
-"   passwd            VARCHAR(255),\n"
-"   nonce           VARCHAR(255),\n"
-"   expires         INTEGER(8)"
-");\n";
+	"CREATE TABLE sip_authentication (\n"
+	"   user            VARCHAR(255),\n"
+	"   host            VARCHAR(255),\n" "   passwd            VARCHAR(255),\n" "   nonce           VARCHAR(255),\n" "   expires         INTEGER(8)"
+	");\n";
 
 static const char modname[] = "mod_sofia";
 #define STRLEN 15
@@ -148,7 +137,7 @@
 	PFLAG_FULL_ID = (1 << 3),
 	PFLAG_PRESENCE = (1 << 4),
 	PFLAG_PASS_RFC2833 = (1 << 5),
-    PFLAG_DISABLE_TRANSCODING = (1 << 6)
+	PFLAG_DISABLE_TRANSCODING = (1 << 6)
 } PFLAGS;
 
 typedef enum {
@@ -163,9 +152,9 @@
 	TFLAG_ANS = (1 << 8),
 	TFLAG_EARLY_MEDIA = (1 << 9),
 	TFLAG_SECURE = (1 << 10),
-	TFLAG_VAD_IN = ( 1 << 11),
-	TFLAG_VAD_OUT = ( 1 << 12),
-	TFLAG_VAD = ( 1 << 13),
+	TFLAG_VAD_IN = (1 << 11),
+	TFLAG_VAD_OUT = (1 << 12),
+	TFLAG_VAD = (1 << 13),
 	TFLAG_TIMER = (1 << 14),
 	TFLAG_READY = (1 << 15),
 	TFLAG_REINVITE = (1 << 16),
@@ -186,7 +175,7 @@
 	uint32_t callid;
 	int32_t running;
 	switch_mutex_t *mutex;
-    char guess_ip[80];
+	char guess_ip[80];
 } globals;
 
 typedef enum {
@@ -250,7 +239,7 @@
 	unsigned int flags;
 	unsigned int pflags;
 	uint32_t max_calls;
-    uint32_t nonce_ttl;
+	uint32_t nonce_ttl;
 	nua_t *nua;
 	switch_memory_pool_t *pool;
 	su_root_t *s_root;
@@ -318,7 +307,7 @@
 	char *chat_from;
 	char *chat_to;
 	char *e_dest;
-    char *call_id;
+	char *call_id;
 	unsigned long rm_rate;
 	switch_payload_t pt;
 	switch_mutex_t *flag_mutex;
@@ -342,96 +331,62 @@
 
 static switch_status_t sofia_on_transmit(switch_core_session_t *session);
 
-static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
-												  switch_core_session_t **new_session, switch_memory_pool_t **pool);
+static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session,
+												  switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session,
+												  switch_memory_pool_t **pool);
 
-static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
-										switch_io_flag_t flags, int stream_id);
+static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id);
 
-static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
-										 switch_io_flag_t flags, int stream_id);
+static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
 
 static switch_status_t config_sofia(int reload);
 
 static switch_status_t sofia_kill_channel(switch_core_session_t *session, int sig);
 
-static switch_status_t activate_rtp(private_object_t *tech_pvt);
+static switch_status_t activate_rtp(private_object_t * tech_pvt);
 
-static void deactivate_rtp(private_object_t *tech_pvt);
+static void deactivate_rtp(private_object_t * tech_pvt);
 
-static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force);
+static void set_local_sdp(private_object_t * tech_pvt, char *ip, uint32_t port, char *sr, int force);
 
-static void tech_set_codecs(private_object_t *tech_pvt);
+static void tech_set_codecs(private_object_t * tech_pvt);
 
-static void attach_private(switch_core_session_t *session,
-                           sofia_profile_t *profile,
-                           private_object_t *tech_pvt,
-                           const char *channame);
+static void attach_private(switch_core_session_t *session, sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame);
 
 static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line);
 
-static switch_status_t tech_choose_port(private_object_t *tech_pvt);
+static switch_status_t tech_choose_port(private_object_t * tech_pvt);
 
 static switch_status_t do_invite(switch_core_session_t *session);
 
-static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
+static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t * sdp);
 
-static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t len, switch_mutex_t *mutex);
+static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t len, switch_mutex_t * mutex);
 
-static void establish_presence(sofia_profile_t *profile);
+static void establish_presence(sofia_profile_t * profile);
 
 static void sip_i_state(int status,
-                        char const *phrase,
-                        nua_t *nua,
-                        sofia_profile_t *profile,
-                        nua_handle_t *nh,
-						sofia_private_t *sofia_private,
-                        sip_t const *sip,
-                        tagi_t tags[]);
-
-
-static void sip_i_refer(nua_t *nua,
-						sofia_profile_t *profile,
-						nua_handle_t *nh,
-                        switch_core_session_t *session,
-						sip_t const *sip,
-						tagi_t tags[]);
-
-static void sip_i_info(nua_t *nua,
-                       sofia_profile_t *profile,
-                       nua_handle_t *nh,
-                       switch_core_session_t *session,
-                       sip_t const *sip,
-                       tagi_t tags[]);
-
-static void sip_i_invite(nua_t *nua,
-                         sofia_profile_t *profile,
-                         nua_handle_t *nh,
-						 sofia_private_t *sofia_private,
-                         sip_t const *sip,
-                         tagi_t tags[]);
-
-static void sip_i_register(nua_t *nua,
-						   sofia_profile_t *profile,
-						   nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-						   sip_t const *sip,
-						   tagi_t tags[]);
-
-static void event_callback(nua_event_t   event,
-                           int           status,
-                           char const   *phrase,
-                           nua_t        *nua,
-                           sofia_profile_t  *profile,
-                           nua_handle_t *nh,
-						   sofia_private_t *sofia_private,
-                           sip_t const  *sip,
-                           tagi_t        tags[]);
+						char const *phrase,
+						nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
 
 
-static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void *obj);
+static void sip_i_refer(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 
-static void launch_profile_thread(sofia_profile_t *profile);
+static void sip_i_info(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
+
+static void sip_i_invite(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+
+static void sip_i_register(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+
+static void event_callback(nua_event_t event,
+						   int status,
+						   char const *phrase,
+						   nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+
+
+static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t * thread, void *obj);
+
+static void launch_profile_thread(sofia_profile_t * profile);
 
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
 
@@ -456,10 +411,10 @@
 	return profile;
 }
 
-static void add_profile(char *key, sofia_profile_t *profile)
+static void add_profile(char *key, sofia_profile_t * profile)
 {
 	switch_mutex_lock(globals.hash_mutex);
-	switch_core_hash_insert(globals.profile_hash, key, profile);	
+	switch_core_hash_insert(globals.profile_hash, key, profile);
 	switch_mutex_unlock(globals.hash_mutex);
 }
 
@@ -474,7 +429,7 @@
 	return gateway;
 }
 
-static void add_gateway(char *key, outbound_reg_t *gateway)
+static void add_gateway(char *key, outbound_reg_t * gateway)
 {
 	switch_mutex_lock(globals.hash_mutex);
 	switch_core_hash_insert(globals.gateway_hash, key, gateway);
@@ -494,12 +449,12 @@
 
 		*e = '\0';
 	}
-	
+
 	return url;
 }
 
 
-static auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen)
+static auth_res_t parse_auth(sofia_profile_t * profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen)
 {
 	int indexnum;
 	const char *cur;
@@ -513,14 +468,14 @@
 	nonce = uri = qop = cnonce = nc = response = NULL;
 
 	if (authorization->au_params) {
-		for(indexnum = 0; (cur=authorization->au_params[indexnum]); indexnum++) {
-			char *var, *val, *p, *work; 
+		for (indexnum = 0; (cur = authorization->au_params[indexnum]); indexnum++) {
+			char *var, *val, *p, *work;
 			var = val = work = NULL;
 			if ((work = strdup(cur))) {
 				var = work;
 				if ((val = strchr(var, '='))) {
 					*val++ = '\0';
-					while(*val == '"') {
+					while (*val == '"') {
 						*val++ = '\0';
 					}
 					if ((p = strchr(val, '"'))) {
@@ -547,7 +502,7 @@
 						cnt++;
 					}
 				}
-				
+
 				free(work);
 			}
 		}
@@ -562,7 +517,7 @@
 		if (!get_auth_data(profile->dbname, nonce, np, nplen, profile->ireg_mutex)) {
 			ret = AUTH_STALE;
 			goto end;
-		} 
+		}
 	}
 
 	npassword = np;
@@ -588,9 +543,9 @@
 		}
 	}
 
- end:
-    switch_safe_free(input);
-    switch_safe_free(input2);
+  end:
+	switch_safe_free(input);
+	switch_safe_free(input2);
 	switch_safe_free(nonce);
 	switch_safe_free(uri);
 	switch_safe_free(qop);
@@ -603,7 +558,7 @@
 }
 
 
-static void execute_sql(char *dbname, char *sql, switch_mutex_t *mutex)
+static void execute_sql(char *dbname, char *sql, switch_mutex_t * mutex)
 {
 	switch_core_db_t *db;
 
@@ -618,7 +573,7 @@
 	switch_core_db_persistant_execute(db, sql, 25);
 	switch_core_db_close(db);
 
- end:
+  end:
 	if (mutex) {
 		switch_mutex_unlock(mutex);
 	}
@@ -631,7 +586,8 @@
 	int matches;
 };
 
-static int find_callback(void *pArg, int argc, char **argv, char **columnNames){
+static int find_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
 	struct callback_t *cbt = (struct callback_t *) pArg;
 
 	switch_copy_string(cbt->val, argv[0], cbt->len);
@@ -639,10 +595,11 @@
 	return 0;
 }
 
-static int del_callback(void *pArg, int argc, char **argv, char **columnNames){
+static int del_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
 	switch_event_t *s_event;
 
-	if (argc >=3 ) {
+	if (argc >= 3) {
 		if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_EXPIRE) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile-name", "%s", argv[0]);
 			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "user", "%s", argv[1]);
@@ -655,7 +612,7 @@
 	return 0;
 }
 
-static void check_expire(switch_core_db_t *db, sofia_profile_t *profile, time_t now)
+static void check_expire(switch_core_db_t *db, sofia_profile_t * profile, time_t now)
 {
 	char sql[1024];
 	char *errmsg;
@@ -666,7 +623,7 @@
 	}
 
 	switch_mutex_lock(profile->ireg_mutex);
-	snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires < %ld", profile->name, (long) now);	
+	snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires < %ld", profile->name, (long) now);
 	switch_core_db_exec(db, sql, del_callback, NULL, &errmsg);
 
 	if (errmsg) {
@@ -674,7 +631,7 @@
 		switch_safe_free(errmsg);
 		errmsg = NULL;
 	}
-	
+
 	snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires < %ld", (long) now);
 	switch_core_db_persistant_execute(db, sql, 1000);
 	snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires < %ld", (long) now);
@@ -686,15 +643,15 @@
 
 }
 
-static char *find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len)
+static char *find_reg_url(sofia_profile_t * profile, const char *user, const char *host, char *val, switch_size_t len)
 {
 	char *errmsg;
-	struct callback_t cbt = {0};
+	struct callback_t cbt = { 0 };
 	switch_core_db_t *db;
 
 	if (!user) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Called with null user!\n");
-        return NULL;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Called with null user!\n");
+		return NULL;
 	}
 
 	if (!(db = switch_core_db_open_file(profile->dbname))) {
@@ -706,9 +663,9 @@
 	cbt.len = len;
 	switch_mutex_lock(profile->ireg_mutex);
 	if (host) {
-		snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);	
+		snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);
 	} else {
-		snprintf(val, len, "select contact from sip_registrations where user='%s'", user);	
+		snprintf(val, len, "select contact from sip_registrations where user='%s'", user);
 	}
 
 	switch_core_db_exec(db, val, find_callback, &cbt, &errmsg);
@@ -722,19 +679,19 @@
 	switch_mutex_unlock(profile->ireg_mutex);
 
 	switch_core_db_close(db);
-    if (cbt.matches) {
-        return val;
-    } else {
-        return NULL;
-    }
+	if (cbt.matches) {
+		return val;
+	} else {
+		return NULL;
+	}
 }
 
 
-static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force)
+static void set_local_sdp(private_object_t * tech_pvt, char *ip, uint32_t port, char *sr, int force)
 {
 	char buf[2048];
 	switch_time_t now = switch_time_now();
-    int ptime = 0;
+	int ptime = 0;
 	int rate = 0;
 
 	if (!force && !ip && !sr && switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
@@ -755,23 +712,10 @@
 		sr = "sendrecv";
 	}
 
-	snprintf(buf, sizeof(buf), 
+	snprintf(buf, sizeof(buf),
 			 "v=0\n"
-			 "o=FreeSWITCH %d%"SWITCH_TIME_T_FMT" %d%"SWITCH_TIME_T_FMT" IN IP4 %s\n"
-			 "s=FreeSWITCH\n"
-			 "c=IN IP4 %s\n"
-			 "t=0 0\n"
-			 "a=%s\n"
-			 "m=audio %d RTP/AVP",
-			 port,
-			 now,
-			 port,
-			 now,
-			 ip,
-			 ip,
-			 sr,
-			 port
-			 );
+			 "o=FreeSWITCH %d%" SWITCH_TIME_T_FMT " %d%" SWITCH_TIME_T_FMT " IN IP4 %s\n"
+			 "s=FreeSWITCH\n" "c=IN IP4 %s\n" "t=0 0\n" "a=%s\n" "m=audio %d RTP/AVP", port, now, port, now, ip, ip, sr, port);
 
 	if (tech_pvt->rm_encoding) {
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
@@ -781,9 +725,9 @@
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
-            if (!ptime) {
-                ptime = imp->microseconds_per_frame / 1000;
-            }
+			if (!ptime) {
+				ptime = imp->microseconds_per_frame / 1000;
+			}
 		}
 	}
 
@@ -803,8 +747,8 @@
 		if (tech_pvt->fmtp_out) {
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
 		}
-		if (tech_pvt->read_codec.implementation && ! ptime) {
-            ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
+		if (tech_pvt->read_codec.implementation && !ptime) {
+			ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
 		}
 
 	} else if (tech_pvt->num_codecs) {
@@ -812,14 +756,14 @@
 		for (i = 0; i < tech_pvt->num_codecs; i++) {
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 			uint32_t rfc_3551_sucks = imp->samples_per_second;
-			
+
 			if (!rate) {
 				rate = imp->samples_per_second;
 			}
-            if (ptime && ptime != imp->microseconds_per_frame / 1000) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
-            }
-			
+			if (ptime && ptime != imp->microseconds_per_frame / 1000) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
+			}
+
 			if (rfc_3551_sucks && imp->ianacode == 9) {
 				rfc_3551_sucks = 8000;
 			}
@@ -830,7 +774,7 @@
 			}
 		}
 	}
-	
+
 	if (tech_pvt->te > 95) {
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te);
 	}
@@ -840,18 +784,18 @@
 			tech_pvt->cng_pt = 0;
 		}
 	}
-    if (ptime) {
-        snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
-    }
+	if (ptime) {
+		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
+	}
 
 	tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
 }
 
-static void tech_set_codecs(private_object_t *tech_pvt)
+static void tech_set_codecs(private_object_t * tech_pvt)
 {
-    switch_channel_t *channel;
-    char *abs, *codec_string = NULL;
-    char *ocodec = NULL;
+	switch_channel_t *channel;
+	char *abs, *codec_string = NULL;
+	char *ocodec = NULL;
 
 	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
 		return;
@@ -861,53 +805,49 @@
 		return;
 	}
 
-    assert(tech_pvt->session != NULL);
+	assert(tech_pvt->session != NULL);
 
-    channel = switch_core_session_get_channel(tech_pvt->session);
-    assert (channel != NULL);
+	channel = switch_core_session_get_channel(tech_pvt->session);
+	assert(channel != NULL);
 
 
-    if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
-        codec_string = abs;
-    } else {
-        if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
+	if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
+		codec_string = abs;
+	} else {
+		if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
 			if (tech_pvt->profile->codec_string) {
 				codec_string = tech_pvt->profile->codec_string;
 			}
-        }
-        
-        if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
-            if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
-                codec_string = ocodec;
-            } else {
+		}
+
+		if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
+			if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
+				codec_string = ocodec;
+			} else {
 				if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
 					codec_string = ocodec;
 				}
-            }
-        }
-    }
+			}
+		}
+	}
 
 	if (codec_string) {
 		char *tmp_codec_string;
 		if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
 			tech_pvt->codec_order_last = switch_separate_string(tmp_codec_string, ',', tech_pvt->codec_order, SWITCH_MAX_CODECS);
-			tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
-																			SWITCH_MAX_CODECS,
-																			tech_pvt->codec_order,
-																			tech_pvt->codec_order_last);
+			tech_pvt->num_codecs =
+				switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, SWITCH_MAX_CODECS, tech_pvt->codec_order, tech_pvt->codec_order_last);
 		}
 	} else {
-		tech_pvt->num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
-																 sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
+		tech_pvt->num_codecs =
+			switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs,
+											  sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
 	}
 
 }
 
 
-static void attach_private(switch_core_session_t *session,
-						   sofia_profile_t *profile,
-						   private_object_t *tech_pvt,
-						   const char *channame)
+static void attach_private(switch_core_session_t *session, sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame)
 {
 	switch_channel_t *channel;
 	char name[256];
@@ -918,9 +858,9 @@
 
 	switch_core_session_add_stream(session, NULL);
 	channel = switch_core_session_get_channel(session);
-	
+
 	//switch_channel_set_flag(channel, CF_ACCEPT_CNG);
-	
+
 	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 	switch_mutex_lock(tech_pvt->flag_mutex);
 	tech_pvt->flags = profile->flags;
@@ -940,47 +880,44 @@
 
 	tech_pvt->session = session;
 	tech_pvt->home = su_home_new(sizeof(*tech_pvt->home));
-	
+
 	switch_core_session_set_private(session, tech_pvt);
 
 
 	snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
-    switch_channel_set_name(channel, name);
+	switch_channel_set_name(channel, name);
 	//tech_set_codecs(tech_pvt);
 
 }
 
 static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line)
 {
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
-    if (*session) {
-        switch_channel_t *channel = switch_core_session_get_channel(*session);
-        struct private_object *tech_pvt = NULL;
-        unsigned running = switch_core_session_running(*session);
-        tech_pvt = switch_core_session_get_private(*session);
-
-        if (running) {
-            switch_channel_hangup(channel, cause);
-        } else {
-            if (tech_pvt) {
-                sofia_on_hangup(*session);
-            }
-            if (session && *session) {
-                switch_core_session_destroy(session);
-            }
-        }
-    }
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
+	if (*session) {
+		switch_channel_t *channel = switch_core_session_get_channel(*session);
+		struct private_object *tech_pvt = NULL;
+		unsigned running = switch_core_session_running(*session);
+		tech_pvt = switch_core_session_get_private(*session);
+
+		if (running) {
+			switch_channel_hangup(channel, cause);
+		} else {
+			if (tech_pvt) {
+				sofia_on_hangup(*session);
+			}
+			if (session && *session) {
+				switch_core_session_destroy(session);
+			}
+		}
+	}
 }
 
 
 
-static switch_status_t sofia_ext_address_lookup(char **ip, 
-												  switch_port_t *port,
-												  char *sourceip,
-												  switch_memory_pool_t *pool)
+static switch_status_t sofia_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool)
 {
 	char *error;
-	
+
 	if (!sourceip) {
 		return SWITCH_STATUS_FALSE;
 	}
@@ -991,12 +928,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
 			return SWITCH_STATUS_FALSE;
 		}
-		if (switch_stun_lookup(ip,
-							   port,
-							   stun_ip,
-							   SWITCH_STUN_DEFAULT_PORT,
-							   &error,
-							   pool) != SWITCH_STATUS_SUCCESS) {
+		if (switch_stun_lookup(ip, port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &error, pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, error);
 			return SWITCH_STATUS_FALSE;
 		}
@@ -1008,7 +940,7 @@
 }
 
 
-static switch_status_t tech_choose_port(private_object_t *tech_pvt)
+static switch_status_t tech_choose_port(private_object_t * tech_pvt)
 {
 	char *ip = tech_pvt->profile->rtpip;
 	switch_channel_t *channel;
@@ -1016,22 +948,20 @@
 	char tmp[50];
 
 	channel = switch_core_session_get_channel(tech_pvt->session);
-	
+
 	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_audio_port) {
 		return SWITCH_STATUS_SUCCESS;
 	}
-	
+
 	tech_pvt->local_sdp_audio_ip = ip;
 	tech_pvt->local_sdp_audio_port = switch_rtp_request_port();
 	sdp_port = tech_pvt->local_sdp_audio_port;
 
 	if (tech_pvt->profile->extrtpip) {
-		if (sofia_ext_address_lookup(&ip,
-									&sdp_port,
-									tech_pvt->profile->extrtpip,
-									switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
-				terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
-				return SWITCH_STATUS_FALSE;
+		if (sofia_ext_address_lookup(&ip, &sdp_port, tech_pvt->profile->extrtpip, switch_core_session_get_pool(tech_pvt->session)) !=
+			SWITCH_STATUS_SUCCESS) {
+			terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
+			return SWITCH_STATUS_FALSE;
 		}
 	}
 
@@ -1041,7 +971,7 @@
 	snprintf(tmp, sizeof(tmp), "%d", sdp_port);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
-	
+
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1055,12 +985,12 @@
 	char *forwardbuf;
 	int forwardval;
 	private_object_t *tech_pvt;
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
 	char *cid_name, *cid_num;
 	char *e_dest = NULL;
 	const char *holdstr = "";
-	switch_stream_handle_t stream = {0};
+	switch_stream_handle_t stream = { 0 };
 	switch_hash_index_t *hi;
 	void *vval;
 	char *extra_headers = NULL;
@@ -1068,26 +998,25 @@
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	char *rep;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
 	rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
 
-    tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	cid_name = (char *) caller_profile->caller_id_name;
 	cid_num = (char *) caller_profile->caller_id_number;
-    tech_set_codecs(tech_pvt);
+	tech_set_codecs(tech_pvt);
 
 	if (!tech_pvt->from_str) {
-		tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" <sip:%s@%s>", 
+		tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" <sip:%s@%s>",
 														 cid_name,
-														 cid_num,
-														 tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip);
-		
+														 cid_num, tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip);
+
 	}
 
 	if (!tech_pvt->from_str) {
@@ -1110,7 +1039,7 @@
 	if (tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
-        
+
 	set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 
 	switch_set_flag_locked(tech_pvt, TFLAG_READY);
@@ -1132,16 +1061,14 @@
 		}
 
 		snprintf(rpid, sizeof(rpid) - 1, "Remote-Party-ID: %s;party=calling;screen=%s;privacy=%s", tech_pvt->from_str, screen, priv);
-								
+
 	}
 
 	if (!tech_pvt->nh) {
-		char *url =  get_url_from_contact(tech_pvt->dest, 1);
+		char *url = get_url_from_contact(tech_pvt->dest, 1);
 		tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
 								  NUTAG_URL(url),
-								  SIPTAG_TO_STR(tech_pvt->dest_to),
-								  SIPTAG_FROM_STR(tech_pvt->from_str),
-								  SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+								  SIPTAG_TO_STR(tech_pvt->dest_to), SIPTAG_FROM_STR(tech_pvt->from_str), SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 								  TAG_END());
 		switch_safe_free(url);
 
@@ -1168,7 +1095,7 @@
 		tech_pvt->chat_to = tech_pvt->dest;
 		tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key);
 		switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt);
-		free(e_dest);			
+		free(e_dest);
 	}
 
 	holdstr = switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) ? "*" : "";
@@ -1187,7 +1114,7 @@
 			}
 		}
 	}
-		
+
 	if (stream.data) {
 		extra_headers = stream.data;
 	}
@@ -1196,19 +1123,16 @@
 			   TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)),
 			   TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
 			   TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-			   TAG_IF(!switch_strlen_zero(max_forwards),SIPTAG_MAX_FORWARDS_STR(max_forwards)),
+			   TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
 			   //SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 			   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 			   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
-			   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
-			   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-			   SOATAG_HOLD(holdstr),
-			   TAG_END());
-		
+			   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
+
 	switch_safe_free(stream.data);
 
 	return SWITCH_STATUS_SUCCESS;
-	
+
 }
 
 
@@ -1217,67 +1141,61 @@
 {
 	char rpid[1024];
 	private_object_t *tech_pvt;
-    switch_channel_t *channel = NULL;
+	switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
 
-    channel = switch_core_session_get_channel(session);
-    assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-    tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-    assert(tech_pvt != NULL);
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
 
-	
 
-	if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" <sip:%s@%s>", 
-														 (char *) caller_profile->caller_id_name, 
-														 (char *) caller_profile->caller_id_number,
-														 tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip
-														 ))) {
+
+	if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" <sip:%s@%s>",
+														  (char *) caller_profile->caller_id_name,
+														  (char *) caller_profile->caller_id_number,
+														  tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip))) {
 
 		char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
 
 		tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
-								  SIPTAG_TO_STR(tech_pvt->dest),
-								  SIPTAG_FROM_STR(tech_pvt->from_str),
-								  SIPTAG_CONTACT_STR(tech_pvt->profile->url),
-								  TAG_END());
-			
-        
+								   SIPTAG_TO_STR(tech_pvt->dest), SIPTAG_FROM_STR(tech_pvt->from_str), SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+								   TAG_END());
+
+
 		nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
 
 		nua_invite(tech_pvt->nh2,
 				   TAG_IF(rpid, SIPTAG_HEADER_STR(rpid)),
 				   SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 				   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
-				   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
-				   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
-				   TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-				   TAG_END());
+				   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE), SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), TAG_END());
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
 	}
-	
+
 }
 
-static void tech_absorb_sdp(private_object_t *tech_pvt)
+static void tech_absorb_sdp(private_object_t * tech_pvt)
 {
 	switch_channel_t *channel;
 	char *sdp_str;
 
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
-	
+
 	if ((sdp_str = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
 		sdp_parser_t *parser;
 		sdp_session_t *sdp;
 		sdp_media_t *m;
 		sdp_connection_t *connection;
 
-		if ((parser = sdp_parse(tech_pvt->home, sdp_str, (int)strlen(sdp_str), 0))) {
+		if ((parser = sdp_parse(tech_pvt->home, sdp_str, (int) strlen(sdp_str), 0))) {
 			if ((sdp = sdp_session(parser))) {
-				for (m = sdp->sdp_media; m ; m = m->m_next) {
+				for (m = sdp->sdp_media; m; m = m->m_next) {
 					if (m->m_type != sdp_media_audio) {
 						continue;
 					}
@@ -1290,14 +1208,14 @@
 					if (connection) {
 						tech_pvt->proxy_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, connection->c_address);
 					}
-					tech_pvt->proxy_sdp_audio_port = (switch_port_t)m->m_port;
+					tech_pvt->proxy_sdp_audio_port = (switch_port_t) m->m_port;
 					if (tech_pvt->proxy_sdp_audio_ip && tech_pvt->proxy_sdp_audio_port) {
 						break;
 					}
 				}
 			}
 			sdp_parser_free(parser);
-		}	
+		}
 		tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, sdp_str);
 	}
 }
@@ -1311,7 +1229,7 @@
 {
 	private_object_t *tech_pvt;
 	switch_channel_t *channel = NULL;
-	
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1331,7 +1249,7 @@
 			return SWITCH_STATUS_FALSE;
 		}
 	}
-	
+
 	/* Move Channel's State Machine to RING */
 	switch_channel_set_state(channel, CS_RING);
 	return SWITCH_STATUS_SUCCESS;
@@ -1371,7 +1289,8 @@
 }
 
 // map QSIG cause codes to SIP from RFC4497 section 8.4.1
-static int hangup_cause_to_sip(switch_call_cause_t cause) {
+static int hangup_cause_to_sip(switch_call_cause_t cause)
+{
 	switch (cause) {
 	case SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET:
 	case SWITCH_CAUSE_NO_ROUTE_DESTINATION:
@@ -1405,7 +1324,7 @@
 		return 503;
 	case SWITCH_CAUSE_OUTGOING_CALL_BARRED:
 	case SWITCH_CAUSE_INCOMING_CALL_BARRED:
-	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH: 
+	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH:
 		return 403;
 	case SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL:
 		return 503;
@@ -1445,7 +1364,7 @@
 
 	deactivate_rtp(tech_pvt);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n", 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n",
 					  switch_channel_get_name(channel), switch_channel_cause2str(cause));
 
 	if (tech_pvt->hash_key) {
@@ -1483,9 +1402