[Freeswitch-svn] [commit] r2782 - in freeswitch/branches/voctel: . build build/config conf docs libs libs/codec/g726 libs/codec/g726/src libs/codec/g7xx libs/codec/g7xx/src libs/codec/g7xx/src/include libs/codec/g7xx/src/include/g7xx libs/codec/gsm libs/codec/ilbc libs/codec/lpc10 libs/iax libs/iax/src libs/jitterbuffer libs/libdingaling libs/libdingaling/src libs/libspeakup libs/libspeakup/src libs/libteletone libs/libteletone/src libs/srtp libs/srtp/crypto libs/srtp/crypto/include libs/srtp/crypto/test libs/srtp/test libs/win32 libs/win32/apr libs/win32/apr-iconv libs/win32/apr-util libs/win32/curl libs/win32/exosip libs/win32/howl libs/win32/iksemel libs/win32/js libs/win32/libresample libs/win32/libsndfile libs/win32/pcre libs/win32/portaudio libs/win32/pthread libs/win32/sofia libs/win32/speex libs/win32/sqlite libs/win32/xmlrpc mac/xcode mac/xcode/FreeSWITCH.xcodeproj mac/xcode/libs scripts scripts/rss scripts/socket scripts/socket/FreeSWITCH src src/dotnet src/dotnet/Marshaling src/dotnet/Marshaling/Types src/dotnet/Modules src/dotnet/Properties src/dotnet/Switch src/dotnet/Types src/include src/mod src/mod/applications 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_ivrtest src/mod/applications/mod_park src/mod/applications/mod_playback src/mod/applications/mod_rss src/mod/applications/mod_skel src/mod/asr_tts src/mod/asr_tts/mod_cepstral src/mod/codecs 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 src/mod/dialplans/mod_dialplan_demo src/mod/dialplans/mod_dialplan_directory src/mod/dialplans/mod_dialplan_xml src/mod/dialplans/mod_pcre src/mod/directories src/mod/directories/mod_ldap src/mod/dotnet src/mod/endpoints src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_exosip src/mod/endpoints/mod_iax src/mod/endpoints/mod_opal src/mod/endpoints/mod_portaudio src/mod/endpoints/mod_sofia src/mod/endpoints/mod_wanpipe src/mod/endpoints/mod_woomera src/mod/event_handlers 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 src/mod/formats/mod_sndfile src/mod/languages src/mod/languages/mod_mono src/mod/languages/mod_perl src/mod/languages/mod_php src/mod/languages/mod_python src/mod/languages/mod_ruby src/mod/languages/mod_spidermonkey src/mod/loggers src/mod/loggers/mod_console src/mod/loggers/mod_syslog src/mod/timers src/mod/timers/mod_softtimer src/mod/xml_int src/mod/xml_int/mod_xml_rpc support w32 w32/Console w32/Library w32/Setup w32/vsnet

Freeswitch SVN voctel at freeswitch.org
Fri Sep 22 14:22:38 EDT 2006


Author: voctel
Date: Fri Sep 22 14:22:15 2006
New Revision: 2782

Added:
   freeswitch/branches/voctel/Freeswitch.sln
      - copied unchanged from r2781, /freeswitch/trunk/Freeswitch.sln
   freeswitch/branches/voctel/build/config/ac_cflags_gcc_option.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_cflags_gcc_option.m4
   freeswitch/branches/voctel/build/config/ac_cflags_sun_option.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_cflags_sun_option.m4
   freeswitch/branches/voctel/build/config/ac_gcc_archflag.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_gcc_archflag.m4
   freeswitch/branches/voctel/build/config/ac_gcc_x86_cpuid.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_gcc_x86_cpuid.m4
   freeswitch/branches/voctel/build/config/ac_prog_gzip.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_prog_gzip.m4
   freeswitch/branches/voctel/build/config/ac_prog_wget.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ac_prog_wget.m4
   freeswitch/branches/voctel/build/config/ax_cc_maxopt.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ax_cc_maxopt.m4
   freeswitch/branches/voctel/build/config/ax_cflags_warn_all_ansi.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ax_cflags_warn_all_ansi.m4
   freeswitch/branches/voctel/build/config/ax_check_compiler_flags.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ax_check_compiler_flags.m4
   freeswitch/branches/voctel/build/config/ax_compiler_vendor.m4
      - copied unchanged from r2781, /freeswitch/trunk/build/config/ax_compiler_vendor.m4
   freeswitch/branches/voctel/conf/freeswitch.xml
      - copied unchanged from r2781, /freeswitch/trunk/conf/freeswitch.xml
   freeswitch/branches/voctel/libs/codec/g726/src/g711.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g726/src/g711.c
   freeswitch/branches/voctel/libs/codec/g726/src/g711.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g726/src/g711.h
   freeswitch/branches/voctel/libs/codec/g7xx/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/codec/g7xx/
   freeswitch/branches/voctel/libs/codec/g7xx/AUTHORS
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/AUTHORS
   freeswitch/branches/voctel/libs/codec/g7xx/COPYING
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/COPYING
   freeswitch/branches/voctel/libs/codec/g7xx/ChangeLog
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/ChangeLog
   freeswitch/branches/voctel/libs/codec/g7xx/INSTALL
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/INSTALL
   freeswitch/branches/voctel/libs/codec/g7xx/Makefile.am
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/Makefile.am
   freeswitch/branches/voctel/libs/codec/g7xx/Makefile.in
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/Makefile.in
   freeswitch/branches/voctel/libs/codec/g7xx/NEWS
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/NEWS
   freeswitch/branches/voctel/libs/codec/g7xx/README
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/README
   freeswitch/branches/voctel/libs/codec/g7xx/aclocal.m4
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/aclocal.m4
   freeswitch/branches/voctel/libs/codec/g7xx/compile
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/compile
   freeswitch/branches/voctel/libs/codec/g7xx/config.guess
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/config.guess
   freeswitch/branches/voctel/libs/codec/g7xx/config.sub
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/config.sub
   freeswitch/branches/voctel/libs/codec/g7xx/configure
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/configure
   freeswitch/branches/voctel/libs/codec/g7xx/configure.in
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/configure.in
   freeswitch/branches/voctel/libs/codec/g7xx/configure.scan
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/configure.scan
   freeswitch/branches/voctel/libs/codec/g7xx/depcomp
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/depcomp
   freeswitch/branches/voctel/libs/codec/g7xx/install-sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/install-sh
   freeswitch/branches/voctel/libs/codec/g7xx/libg7xx.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/libg7xx.vcproj
   freeswitch/branches/voctel/libs/codec/g7xx/ltmain.sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/ltmain.sh
   freeswitch/branches/voctel/libs/codec/g7xx/missing
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/missing
   freeswitch/branches/voctel/libs/codec/g7xx/src/
      - copied from r2781, /freeswitch/trunk/libs/codec/g7xx/src/
   freeswitch/branches/voctel/libs/codec/g7xx/src/g711.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/g711.c
   freeswitch/branches/voctel/libs/codec/g7xx/src/g722_decode.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/g722_decode.c
   freeswitch/branches/voctel/libs/codec/g7xx/src/g722_encode.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/g722_encode.c
   freeswitch/branches/voctel/libs/codec/g7xx/src/g726.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/g726.c
   freeswitch/branches/voctel/libs/codec/g7xx/src/include/
      - copied from r2781, /freeswitch/trunk/libs/codec/g7xx/src/include/
   freeswitch/branches/voctel/libs/codec/g7xx/src/include/g7xx/
      - copied from r2781, /freeswitch/trunk/libs/codec/g7xx/src/include/g7xx/
   freeswitch/branches/voctel/libs/codec/g7xx/src/include/g7xx/g711.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/include/g7xx/g711.h
   freeswitch/branches/voctel/libs/codec/g7xx/src/include/g7xx/g722.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/include/g7xx/g722.h
   freeswitch/branches/voctel/libs/codec/g7xx/src/include/g7xx/g726.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/g7xx/src/include/g7xx/g726.h
   freeswitch/branches/voctel/libs/codec/lpc10/AUTHORS
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/AUTHORS
   freeswitch/branches/voctel/libs/codec/lpc10/COPYING
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/COPYING
   freeswitch/branches/voctel/libs/codec/lpc10/ChangeLog
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/ChangeLog
   freeswitch/branches/voctel/libs/codec/lpc10/INSTALL
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/INSTALL
   freeswitch/branches/voctel/libs/codec/lpc10/Makefile.am
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/Makefile.am
   freeswitch/branches/voctel/libs/codec/lpc10/Makefile.in
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/Makefile.in
   freeswitch/branches/voctel/libs/codec/lpc10/NEWS
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/NEWS
   freeswitch/branches/voctel/libs/codec/lpc10/aclocal.m4
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/aclocal.m4
   freeswitch/branches/voctel/libs/codec/lpc10/compile
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/compile
   freeswitch/branches/voctel/libs/codec/lpc10/config.guess
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/config.guess
   freeswitch/branches/voctel/libs/codec/lpc10/config.sub
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/config.sub
   freeswitch/branches/voctel/libs/codec/lpc10/configure
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/configure
   freeswitch/branches/voctel/libs/codec/lpc10/configure.ac
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/configure.ac
   freeswitch/branches/voctel/libs/codec/lpc10/depcomp
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/depcomp
   freeswitch/branches/voctel/libs/codec/lpc10/install-sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/install-sh
   freeswitch/branches/voctel/libs/codec/lpc10/ltmain.sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/ltmain.sh
   freeswitch/branches/voctel/libs/codec/lpc10/missing
      - copied unchanged from r2781, /freeswitch/trunk/libs/codec/lpc10/missing
   freeswitch/branches/voctel/libs/libspeakup/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/libspeakup/
   freeswitch/branches/voctel/libs/libspeakup/AUTHORS
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/AUTHORS
   freeswitch/branches/voctel/libs/libspeakup/COPYING
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/COPYING
   freeswitch/branches/voctel/libs/libspeakup/ChangeLog
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/ChangeLog
   freeswitch/branches/voctel/libs/libspeakup/INSTALL
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/INSTALL
   freeswitch/branches/voctel/libs/libspeakup/Makefile.am
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/Makefile.am
   freeswitch/branches/voctel/libs/libspeakup/Makefile.in
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/Makefile.in
   freeswitch/branches/voctel/libs/libspeakup/NEWS
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/NEWS
   freeswitch/branches/voctel/libs/libspeakup/README
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/README
   freeswitch/branches/voctel/libs/libspeakup/aclocal.m4
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/aclocal.m4
   freeswitch/branches/voctel/libs/libspeakup/compile
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/compile
   freeswitch/branches/voctel/libs/libspeakup/config.guess
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/config.guess
   freeswitch/branches/voctel/libs/libspeakup/config.sub
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/config.sub
   freeswitch/branches/voctel/libs/libspeakup/configure
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/configure
   freeswitch/branches/voctel/libs/libspeakup/configure.in
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/configure.in
   freeswitch/branches/voctel/libs/libspeakup/depcomp
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/depcomp
   freeswitch/branches/voctel/libs/libspeakup/doc
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/doc
   freeswitch/branches/voctel/libs/libspeakup/install-sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/install-sh
   freeswitch/branches/voctel/libs/libspeakup/jitterbuffer.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/jitterbuffer.vcproj
   freeswitch/branches/voctel/libs/libspeakup/ltmain.sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/ltmain.sh
   freeswitch/branches/voctel/libs/libspeakup/missing
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/missing
   freeswitch/branches/voctel/libs/libspeakup/mkinstalldirs
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/mkinstalldirs
   freeswitch/branches/voctel/libs/libspeakup/src/
      - copied from r2781, /freeswitch/trunk/libs/libspeakup/src/
   freeswitch/branches/voctel/libs/libspeakup/src/jb_speakup.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/src/jb_speakup.c
   freeswitch/branches/voctel/libs/libspeakup/src/jb_speakup.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/libspeakup/src/jb_speakup.h
   freeswitch/branches/voctel/libs/portaudio.build.sh
      - copied unchanged from r2781, /freeswitch/trunk/libs/portaudio.build.sh
   freeswitch/branches/voctel/libs/srtp/libsrtp.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/srtp/libsrtp.vcproj
   freeswitch/branches/voctel/libs/win32/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/
   freeswitch/branches/voctel/libs/win32/Download APR-Iconv.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download APR-Iconv.vcproj
   freeswitch/branches/voctel/libs/win32/Download APR-Util.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download APR-Util.vcproj
   freeswitch/branches/voctel/libs/win32/Download APR.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download APR.vcproj
   freeswitch/branches/voctel/libs/win32/Download CURL.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download CURL.vcproj
   freeswitch/branches/voctel/libs/win32/Download EXOSIP.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download EXOSIP.vcproj
   freeswitch/branches/voctel/libs/win32/Download HOWL.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download HOWL.vcproj
   freeswitch/branches/voctel/libs/win32/Download IKSEMEL.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download IKSEMEL.vcproj
   freeswitch/branches/voctel/libs/win32/Download LIBRESAMPLE.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download LIBRESAMPLE.vcproj
   freeswitch/branches/voctel/libs/win32/Download LIBSNDFILE.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download LIBSNDFILE.vcproj
   freeswitch/branches/voctel/libs/win32/Download PCRE.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download PCRE.vcproj
   freeswitch/branches/voctel/libs/win32/Download PORTAUDIO.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download PORTAUDIO.vcproj
   freeswitch/branches/voctel/libs/win32/Download PTHREAD.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download PTHREAD.vcproj
   freeswitch/branches/voctel/libs/win32/Download SOFIA.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download SOFIA.vcproj
   freeswitch/branches/voctel/libs/win32/Download SPEEX.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download SPEEX.vcproj
   freeswitch/branches/voctel/libs/win32/Download SPIDERMONKEY.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download SPIDERMONKEY.vcproj
   freeswitch/branches/voctel/libs/win32/Download SQLITE.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download SQLITE.vcproj
   freeswitch/branches/voctel/libs/win32/Download XMLRPC.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/Download XMLRPC.vcproj
   freeswitch/branches/voctel/libs/win32/apr/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/apr/
   freeswitch/branches/voctel/libs/win32/apr-iconv/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/apr-iconv/
   freeswitch/branches/voctel/libs/win32/apr-iconv/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr-iconv/cleancount
   freeswitch/branches/voctel/libs/win32/apr-iconv/libapriconv.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr-iconv/libapriconv.vcproj
   freeswitch/branches/voctel/libs/win32/apr-util/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/apr-util/
   freeswitch/branches/voctel/libs/win32/apr-util/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr-util/cleancount
   freeswitch/branches/voctel/libs/win32/apr-util/libaprutil.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr-util/libaprutil.vcproj
   freeswitch/branches/voctel/libs/win32/apr-util/xml.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr-util/xml.vcproj
   freeswitch/branches/voctel/libs/win32/apr/apr.hw
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr/apr.hw
   freeswitch/branches/voctel/libs/win32/apr/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr/cleancount
   freeswitch/branches/voctel/libs/win32/apr/libapr.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/apr/libapr.vcproj
   freeswitch/branches/voctel/libs/win32/curl/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/curl/
   freeswitch/branches/voctel/libs/win32/curl/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/curl/cleancount
   freeswitch/branches/voctel/libs/win32/curl/curllib.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/curl/curllib.vcproj
   freeswitch/branches/voctel/libs/win32/exosip/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/exosip/
   freeswitch/branches/voctel/libs/win32/exosip/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/exosip/cleancount
   freeswitch/branches/voctel/libs/win32/exosip/eXosip.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/exosip/eXosip.vcproj
   freeswitch/branches/voctel/libs/win32/exosip/osip2.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/exosip/osip2.vcproj
   freeswitch/branches/voctel/libs/win32/exosip/osipparser2.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/exosip/osipparser2.vcproj
   freeswitch/branches/voctel/libs/win32/howl/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/howl/
   freeswitch/branches/voctel/libs/win32/howl/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/howl/cleancount
   freeswitch/branches/voctel/libs/win32/howl/libhowl.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/howl/libhowl.vcproj
   freeswitch/branches/voctel/libs/win32/howl/libmDNSResponder.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/howl/libmDNSResponder.vcproj
   freeswitch/branches/voctel/libs/win32/iksemel/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/iksemel/
   freeswitch/branches/voctel/libs/win32/iksemel/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/iksemel/cleancount
   freeswitch/branches/voctel/libs/win32/iksemel/config.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/iksemel/config.h
   freeswitch/branches/voctel/libs/win32/iksemel/iksemel.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/iksemel/iksemel.vcproj
   freeswitch/branches/voctel/libs/win32/js/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/js/
   freeswitch/branches/voctel/libs/win32/js/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/js/cleancount
   freeswitch/branches/voctel/libs/win32/js/fdlibm.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/js/fdlibm.vcproj
   freeswitch/branches/voctel/libs/win32/js/js.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/js/js.vcproj
   freeswitch/branches/voctel/libs/win32/libresample/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/libresample/
   freeswitch/branches/voctel/libs/win32/libresample/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libresample/cleancount
   freeswitch/branches/voctel/libs/win32/libresample/libresample.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libresample/libresample.vcproj
   freeswitch/branches/voctel/libs/win32/libsndfile/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/libsndfile/
   freeswitch/branches/voctel/libs/win32/libsndfile/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libsndfile/cleancount
   freeswitch/branches/voctel/libs/win32/libsndfile/common.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libsndfile/common.c
   freeswitch/branches/voctel/libs/win32/libsndfile/config.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libsndfile/config.h
   freeswitch/branches/voctel/libs/win32/libsndfile/libsndfile.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libsndfile/libsndfile.vcproj
   freeswitch/branches/voctel/libs/win32/libsndfile/sndfile.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/libsndfile/sndfile.h
   freeswitch/branches/voctel/libs/win32/pcre/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/pcre/
   freeswitch/branches/voctel/libs/win32/pcre/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/cleancount
   freeswitch/branches/voctel/libs/win32/pcre/config.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/config.h
   freeswitch/branches/voctel/libs/win32/pcre/dftables.c
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/dftables.c
   freeswitch/branches/voctel/libs/win32/pcre/libpcre.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/libpcre.vcproj
   freeswitch/branches/voctel/libs/win32/pcre/pcre.h
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/pcre.h
   freeswitch/branches/voctel/libs/win32/pcre/pcre_chartables.c.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pcre/pcre_chartables.c.vcproj
   freeswitch/branches/voctel/libs/win32/portaudio/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/portaudio/
   freeswitch/branches/voctel/libs/win32/portaudio/PAStaticWMME.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/portaudio/PAStaticWMME.vcproj
   freeswitch/branches/voctel/libs/win32/portaudio/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/portaudio/cleancount
   freeswitch/branches/voctel/libs/win32/pthread/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/pthread/
   freeswitch/branches/voctel/libs/win32/pthread/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pthread/cleancount
   freeswitch/branches/voctel/libs/win32/pthread/pthread.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/pthread/pthread.vcproj
   freeswitch/branches/voctel/libs/win32/sofia/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/sofia/
   freeswitch/branches/voctel/libs/win32/sofia/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/sofia/cleancount
   freeswitch/branches/voctel/libs/win32/sofia/libsofia_sip_ua_static.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj
   freeswitch/branches/voctel/libs/win32/speex/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/speex/
   freeswitch/branches/voctel/libs/win32/speex/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/speex/cleancount
   freeswitch/branches/voctel/libs/win32/speex/libspeex.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/speex/libspeex.vcproj
   freeswitch/branches/voctel/libs/win32/sqlite/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/sqlite/
   freeswitch/branches/voctel/libs/win32/sqlite/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/sqlite/cleancount
   freeswitch/branches/voctel/libs/win32/sqlite/sqlite.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/sqlite/sqlite.vcproj
   freeswitch/branches/voctel/libs/win32/util.vbs
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/util.vbs
   freeswitch/branches/voctel/libs/win32/xmlrpc/   (props changed)
      - copied from r2781, /freeswitch/trunk/libs/win32/xmlrpc/
   freeswitch/branches/voctel/libs/win32/xmlrpc/Abyss.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/xmlrpc/Abyss.vcproj
   freeswitch/branches/voctel/libs/win32/xmlrpc/cleancount
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/xmlrpc/cleancount
   freeswitch/branches/voctel/libs/win32/xmlrpc/xmlrpc.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/libs/win32/xmlrpc/xmlrpc.vcproj
   freeswitch/branches/voctel/mac/xcode/FreeSWITCH.xcodeproj/
      - copied from r2781, /freeswitch/trunk/mac/xcode/FreeSWITCH.xcodeproj/
   freeswitch/branches/voctel/mac/xcode/FreeSWITCH.xcodeproj/project.pbxproj
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/FreeSWITCH.xcodeproj/project.pbxproj
   freeswitch/branches/voctel/mac/xcode/Loadable Bundle.trgttmpl
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/Loadable Bundle.trgttmpl
   freeswitch/branches/voctel/mac/xcode/apr.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/apr.plist
   freeswitch/branches/voctel/mac/xcode/aprutil.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/aprutil.plist
   freeswitch/branches/voctel/mac/xcode/dingaling.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/dingaling.plist
   freeswitch/branches/voctel/mac/xcode/exosip2.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/exosip2.plist
   freeswitch/branches/voctel/mac/xcode/gsm.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/gsm.plist
   freeswitch/branches/voctel/mac/xcode/iax.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/iax.plist
   freeswitch/branches/voctel/mac/xcode/iksemel.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/iksemel.plist
   freeswitch/branches/voctel/mac/xcode/ilbc.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/ilbc.plist
   freeswitch/branches/voctel/mac/xcode/libfreeswitch.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/libfreeswitch.plist
   freeswitch/branches/voctel/mac/xcode/osip2.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/osip2.plist
   freeswitch/branches/voctel/mac/xcode/osipparser2.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/osipparser2.plist
   freeswitch/branches/voctel/mac/xcode/pcre.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/pcre.plist
   freeswitch/branches/voctel/mac/xcode/portaudio.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/portaudio.plist
   freeswitch/branches/voctel/mac/xcode/resample.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/resample.plist
   freeswitch/branches/voctel/mac/xcode/sndfile.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/sndfile.plist
   freeswitch/branches/voctel/mac/xcode/speakup.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/speakup.plist
   freeswitch/branches/voctel/mac/xcode/speex.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/speex.plist
   freeswitch/branches/voctel/mac/xcode/sqlite.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/sqlite.plist
   freeswitch/branches/voctel/mac/xcode/srtp.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/srtp.plist
   freeswitch/branches/voctel/mac/xcode/teletone.plist
      - copied unchanged from r2781, /freeswitch/trunk/mac/xcode/teletone.plist
   freeswitch/branches/voctel/scripts/fsxs.in
      - copied unchanged from r2781, /freeswitch/trunk/scripts/fsxs.in
   freeswitch/branches/voctel/scripts/rss/
      - copied from r2781, /freeswitch/trunk/scripts/rss/
   freeswitch/branches/voctel/scripts/rss/rss2ivr.pl
      - copied unchanged from r2781, /freeswitch/trunk/scripts/rss/rss2ivr.pl
   freeswitch/branches/voctel/scripts/rss/syncrss.pl
      - copied unchanged from r2781, /freeswitch/trunk/scripts/rss/syncrss.pl
   freeswitch/branches/voctel/scripts/socket/
      - copied from r2781, /freeswitch/trunk/scripts/socket/
   freeswitch/branches/voctel/scripts/socket/FreeSWITCH/
      - copied from r2781, /freeswitch/trunk/scripts/socket/FreeSWITCH/
   freeswitch/branches/voctel/scripts/socket/FreeSWITCH/Client.pm
      - copied unchanged from r2781, /freeswitch/trunk/scripts/socket/FreeSWITCH/Client.pm
   freeswitch/branches/voctel/scripts/socket/fs.pl
      - copied unchanged from r2781, /freeswitch/trunk/scripts/socket/fs.pl
   freeswitch/branches/voctel/src/dotnet/
      - copied from r2781, /freeswitch/trunk/src/dotnet/
   freeswitch/branches/voctel/src/dotnet/Common.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Common.cs
   freeswitch/branches/voctel/src/dotnet/FreeSwitch.NET.csproj
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj
   freeswitch/branches/voctel/src/dotnet/Ivr.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Ivr.cs
   freeswitch/branches/voctel/src/dotnet/Log.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Log.cs
   freeswitch/branches/voctel/src/dotnet/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Makefile
   freeswitch/branches/voctel/src/dotnet/Marshaling/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Marshaling/
   freeswitch/branches/voctel/src/dotnet/Marshaling/BufferMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/BufferMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/CallerExtensionMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/CallerExtensionMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/CallerProfileMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/CallerProfileMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/ChannelMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/ChannelMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/ChannelTimetableMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/ChannelTimetableMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/CodecMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/CoreSessionMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/EventMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/EventMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/FileHandleMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/FileHandleMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/MemoryPoolMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/MemoryPoolMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/StreamHandleMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/StreamHandleMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/TimerMarshaler.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/BufferMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/BufferMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ChannelFlagMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ChannelFlagMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ChannelMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ChannelMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ChannelStateMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ChannelStateMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/ChannelTimetableMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/ChannelTimetableMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CodecImplementationMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CodecImplementationMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CodecMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CodecTypeMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CodecTypeMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/EventMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/EventMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/FileHandleMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/FileHandleMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/FrameMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/FrameMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/TimerMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Marshaling/Types/TypesMarshal.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Marshaling/Types/TypesMarshal.cs
   freeswitch/branches/voctel/src/dotnet/Module.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Module.cs
   freeswitch/branches/voctel/src/dotnet/Modules/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Modules/
   freeswitch/branches/voctel/src/dotnet/Modules/Api.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Modules/Api.cs
   freeswitch/branches/voctel/src/dotnet/Modules/Application.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Modules/Application.cs
   freeswitch/branches/voctel/src/dotnet/Properties/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Properties/
   freeswitch/branches/voctel/src/dotnet/Properties/AssemblyInfo.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Properties/AssemblyInfo.cs
   freeswitch/branches/voctel/src/dotnet/Switch/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Switch/
   freeswitch/branches/voctel/src/dotnet/Switch/CallerProfile.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/CallerProfile.cs
   freeswitch/branches/voctel/src/dotnet/Switch/Channel.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/Channel.cs
   freeswitch/branches/voctel/src/dotnet/Switch/Console.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/Console.cs
   freeswitch/branches/voctel/src/dotnet/Switch/CoreSession.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/CoreSession.cs
   freeswitch/branches/voctel/src/dotnet/Switch/Event.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/Event.cs
   freeswitch/branches/voctel/src/dotnet/Switch/Ivr.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/Ivr.cs
   freeswitch/branches/voctel/src/dotnet/Switch/LoadableModule.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/LoadableModule.cs
   freeswitch/branches/voctel/src/dotnet/Switch/Log.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/Log.cs
   freeswitch/branches/voctel/src/dotnet/Switch/StreamHandle.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Switch/StreamHandle.cs
   freeswitch/branches/voctel/src/dotnet/Types/
      - copied from r2781, /freeswitch/trunk/src/dotnet/Types/
   freeswitch/branches/voctel/src/dotnet/Types/ApiFunction.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ApiFunction.cs
   freeswitch/branches/voctel/src/dotnet/Types/ApplicationFunction.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ApplicationFunction.cs
   freeswitch/branches/voctel/src/dotnet/Types/ApplicationInterface.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ApplicationInterface.cs
   freeswitch/branches/voctel/src/dotnet/Types/Buffer.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Buffer.cs
   freeswitch/branches/voctel/src/dotnet/Types/CallCause.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/CallCause.cs
   freeswitch/branches/voctel/src/dotnet/Types/CallerExtension.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/CallerExtension.cs
   freeswitch/branches/voctel/src/dotnet/Types/CallerProfile.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/CallerProfile.cs
   freeswitch/branches/voctel/src/dotnet/Types/Channel.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Channel.cs
   freeswitch/branches/voctel/src/dotnet/Types/ChannelFlag.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ChannelFlag.cs
   freeswitch/branches/voctel/src/dotnet/Types/ChannelState.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ChannelState.cs
   freeswitch/branches/voctel/src/dotnet/Types/ChannelTimetable.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ChannelTimetable.cs
   freeswitch/branches/voctel/src/dotnet/Types/Codec.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Codec.cs
   freeswitch/branches/voctel/src/dotnet/Types/CoreSession.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/CoreSession.cs
   freeswitch/branches/voctel/src/dotnet/Types/DtmfCallbackFunction.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/DtmfCallbackFunction.cs
   freeswitch/branches/voctel/src/dotnet/Types/Event.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Event.cs
   freeswitch/branches/voctel/src/dotnet/Types/EventCallback.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/EventCallback.cs
   freeswitch/branches/voctel/src/dotnet/Types/EventType.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/EventType.cs
   freeswitch/branches/voctel/src/dotnet/Types/FileHandle.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/FileHandle.cs
   freeswitch/branches/voctel/src/dotnet/Types/InputCallbackFunction.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs
   freeswitch/branches/voctel/src/dotnet/Types/InputType.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/InputType.cs
   freeswitch/branches/voctel/src/dotnet/Types/LoadableModule.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/LoadableModule.cs
   freeswitch/branches/voctel/src/dotnet/Types/LoadableModuleInterface.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs
   freeswitch/branches/voctel/src/dotnet/Types/LogLevel.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/LogLevel.cs
   freeswitch/branches/voctel/src/dotnet/Types/MemoryPool.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/MemoryPool.cs
   freeswitch/branches/voctel/src/dotnet/Types/Module.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Module.cs
   freeswitch/branches/voctel/src/dotnet/Types/ModuleInterfaces.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/ModuleInterfaces.cs
   freeswitch/branches/voctel/src/dotnet/Types/SpeechHandle.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs
   freeswitch/branches/voctel/src/dotnet/Types/StateHandlerTable.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs
   freeswitch/branches/voctel/src/dotnet/Types/Status.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Status.cs
   freeswitch/branches/voctel/src/dotnet/Types/StreamHandle.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/StreamHandle.cs
   freeswitch/branches/voctel/src/dotnet/Types/TextChannel.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/TextChannel.cs
   freeswitch/branches/voctel/src/dotnet/Types/Timer.cs
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/Types/Timer.cs
   freeswitch/branches/voctel/src/dotnet/public.snk
      - copied unchanged from r2781, /freeswitch/trunk/src/dotnet/public.snk
   freeswitch/branches/voctel/src/include/switch_bitpack.h
      - copied unchanged from r2781, /freeswitch/trunk/src/include/switch_bitpack.h
   freeswitch/branches/voctel/src/include/switch_xml.h
      - copied unchanged from r2781, /freeswitch/trunk/src/include/switch_xml.h
   freeswitch/branches/voctel/src/mod/applications/mod_conference/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/applications/mod_conference/
   freeswitch/branches/voctel/src/mod/applications/mod_conference/mod_conference.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/voctel/src/mod/applications/mod_conference/mod_conference.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_dptools/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/applications/mod_dptools/
   freeswitch/branches/voctel/src/mod/applications/mod_dptools/mod_dptools.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/voctel/src/mod/applications/mod_dptools/mod_dptools.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_park/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/applications/mod_park/
   freeswitch/branches/voctel/src/mod/applications/mod_park/mod_park.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_park/mod_park.c
   freeswitch/branches/voctel/src/mod/applications/mod_park/mod_park.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_park/mod_park.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_rss/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/applications/mod_rss/
   freeswitch/branches/voctel/src/mod/applications/mod_rss/mod_rss.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
   freeswitch/branches/voctel/src/mod/applications/mod_rss/mod_rss.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_amr/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/codecs/mod_amr/
   freeswitch/branches/voctel/src/mod/codecs/mod_amr/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_amr/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_amr/mod_amr.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g722/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/codecs/mod_g722/
   freeswitch/branches/voctel/src/mod/codecs/mod_g722/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g722/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_g722/mod_g722.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g722/mod_g722.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_g723_1/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/codecs/mod_g723_1/
   freeswitch/branches/voctel/src/mod/codecs/mod_g723_1/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g723_1/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_g723_1/mod_g723_1.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g723_1/mod_g723_1.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_g726/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/codecs/mod_g726/
   freeswitch/branches/voctel/src/mod/codecs/mod_g726/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g726/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_g726/mod_g726.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g726/mod_g726.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_g726/mod_g726.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_lpc10/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/codecs/mod_lpc10/
   freeswitch/branches/voctel/src/mod/codecs/mod_lpc10/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_lpc10/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_lpc10/mod_lpc10.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/codecs/mod_lpc10/mod_lpc10.c
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_xml/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_xml/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/Makefile
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.vcproj
   freeswitch/branches/voctel/src/mod/dotnet/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/dotnet/
   freeswitch/branches/voctel/src/mod/endpoints/mod_sofia/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/endpoints/mod_sofia/
   freeswitch/branches/voctel/src/mod/endpoints/mod_sofia/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/endpoints/mod_sofia/Makefile
   freeswitch/branches/voctel/src/mod/endpoints/mod_sofia/mod_sofia.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_sofia/mod_sofia.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/Makefile
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/README
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/README
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/basecdr.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/basecdr.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/basecdr.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/baseregistry.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/baseregistry.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/baseregistry.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/baseregistry.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/cdrcontainer.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/cdrcontainer.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/csvcdr.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/csvcdr.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/csvcdr.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/csvcdr.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/mod_cdr.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/mysqlcdr.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/mysqlcdr.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/pddcdr.cpp
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/pddcdr.cpp
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/pddcdr.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/pddcdr.h
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/schema-update.mysql
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/schema-update.mysql
   freeswitch/branches/voctel/src/mod/event_handlers/mod_cdr/schema.sql
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/schema.sql
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_socket/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_event_socket/
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_socket/mod_event_socket.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.vcproj
   freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfile.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.vcproj
   freeswitch/branches/voctel/src/mod/languages/mod_mono/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/languages/mod_mono/
   freeswitch/branches/voctel/src/mod/languages/mod_mono/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_mono/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_mono/mod_mono.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_mono/mod_mono.c
   freeswitch/branches/voctel/src/mod/languages/mod_php/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/languages/mod_php/
   freeswitch/branches/voctel/src/mod/languages/mod_php/CHANGES
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/CHANGES
   freeswitch/branches/voctel/src/mod/languages/mod_php/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_php/apptest.php
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/apptest.php
   freeswitch/branches/voctel/src/mod/languages/mod_php/classFreeswitch.php
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/classFreeswitch.php
   freeswitch/branches/voctel/src/mod/languages/mod_php/fix.diff
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/fix.diff
   freeswitch/branches/voctel/src/mod/languages/mod_php/freeswitch.php
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/freeswitch.php
   freeswitch/branches/voctel/src/mod/languages/mod_php/mod_php.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/mod_php.c
   freeswitch/branches/voctel/src/mod/languages/mod_php/php.ini
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/php.ini
   freeswitch/branches/voctel/src/mod/languages/mod_php/php_freeswitch.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/php_freeswitch.h
   freeswitch/branches/voctel/src/mod/languages/mod_php/switch_swig_wrap.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/switch_swig_wrap.c
   freeswitch/branches/voctel/src/mod/languages/mod_php/test.php
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_php/test.php
   freeswitch/branches/voctel/src/mod/languages/mod_python/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/languages/mod_python/
   freeswitch/branches/voctel/src/mod/languages/mod_python/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_python/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_python/freeswitch.py
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
   freeswitch/branches/voctel/src/mod/languages/mod_python/mod_python.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_python/mod_python.c
   freeswitch/branches/voctel/src/mod/languages/mod_python/python.py
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_python/python.py
   freeswitch/branches/voctel/src/mod/languages/mod_python/switch_swig_wrap.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_python/switch_swig_wrap.c
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/README
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/README
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/config.h
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/config.h
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/mod_ruby.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/mod_ruby.c
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/switch_swig.i
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/switch_swig.i
   freeswitch/branches/voctel/src/mod/languages/mod_ruby/switch_swig_wrap.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/languages/mod_ruby/switch_swig_wrap.c
   freeswitch/branches/voctel/src/mod/xml_int/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/xml_int/
   freeswitch/branches/voctel/src/mod/xml_int/mod_xml_rpc/   (props changed)
      - copied from r2781, /freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/
   freeswitch/branches/voctel/src/mod/xml_int/mod_xml_rpc/Makefile
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/Makefile
   freeswitch/branches/voctel/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
   freeswitch/branches/voctel/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.vcproj
   freeswitch/branches/voctel/src/switch_swig.c
      - copied unchanged from r2781, /freeswitch/trunk/src/switch_swig.c
   freeswitch/branches/voctel/src/switch_swig.i
      - copied unchanged from r2781, /freeswitch/trunk/src/switch_swig.i
   freeswitch/branches/voctel/src/switch_xml.c
      - copied unchanged from r2781, /freeswitch/trunk/src/switch_xml.c
   freeswitch/branches/voctel/support/
      - copied from r2781, /freeswitch/trunk/support/
   freeswitch/branches/voctel/support/freeswitch.pub
      - copied unchanged from r2781, /freeswitch/trunk/support/freeswitch.pub
   freeswitch/branches/voctel/w32/Console/   (props changed)
      - copied from r2781, /freeswitch/trunk/w32/Console/
   freeswitch/branches/voctel/w32/Console/FreeSwitchConsole.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/w32/Console/FreeSwitchConsole.vcproj
   freeswitch/branches/voctel/w32/Console/FreeSwitchConsole.vcproj.user
      - copied unchanged from r2781, /freeswitch/trunk/w32/Console/FreeSwitchConsole.vcproj.user
   freeswitch/branches/voctel/w32/Library/   (props changed)
      - copied from r2781, /freeswitch/trunk/w32/Library/
   freeswitch/branches/voctel/w32/Library/FreeSwitchCore.vcproj
      - copied unchanged from r2781, /freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
Removed:
   freeswitch/branches/voctel/conf/freeswitch.conf
   freeswitch/branches/voctel/libs/MD5
   freeswitch/branches/voctel/libs/codec/lpc10/Makefile
   freeswitch/branches/voctel/libs/jitterbuffer/
   freeswitch/branches/voctel/libs/srtp/crypto/Makefile
   freeswitch/branches/voctel/mac/xcode/libs/
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/g711.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/g711.h
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_demo/
   freeswitch/branches/voctel/src/mod/dialplans/mod_pcre/
   freeswitch/branches/voctel/src/mod/endpoints/mod_opal/
   freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfilel.vcproj
   freeswitch/branches/voctel/src/mod/languages/mod_perl/switch_swig.c
   freeswitch/branches/voctel/w32/vsnet/
Modified:
   freeswitch/branches/voctel/   (props changed)
   freeswitch/branches/voctel/AUTHORS
   freeswitch/branches/voctel/INSTALL
   freeswitch/branches/voctel/Makefile.am
   freeswitch/branches/voctel/Makefile.in
   freeswitch/branches/voctel/aclocal.m4
   freeswitch/branches/voctel/build/   (props changed)
   freeswitch/branches/voctel/build/buildlib.sh
   freeswitch/branches/voctel/build/checkversion.sh
   freeswitch/branches/voctel/build/modmake.sh
   freeswitch/branches/voctel/conf/   (props changed)
   freeswitch/branches/voctel/configure
   freeswitch/branches/voctel/configure.in
   freeswitch/branches/voctel/docs/   (props changed)
   freeswitch/branches/voctel/docs/Doxygen.conf
   freeswitch/branches/voctel/libs/   (props changed)
   freeswitch/branches/voctel/libs/codec/g726/   (props changed)
   freeswitch/branches/voctel/libs/codec/g726/Makefile.am
   freeswitch/branches/voctel/libs/codec/g726/Makefile.in
   freeswitch/branches/voctel/libs/codec/g726/aclocal.m4
   freeswitch/branches/voctel/libs/codec/g726/configure
   freeswitch/branches/voctel/libs/codec/g726/libg726.vcproj
   freeswitch/branches/voctel/libs/codec/g726/src/g72x.c
   freeswitch/branches/voctel/libs/codec/gsm/   (props changed)
   freeswitch/branches/voctel/libs/codec/gsm/libgsm.vcproj
   freeswitch/branches/voctel/libs/codec/ilbc/   (props changed)
   freeswitch/branches/voctel/libs/codec/ilbc/libilbc.vcproj
   freeswitch/branches/voctel/libs/codec/lpc10/   (props changed)
   freeswitch/branches/voctel/libs/iax/   (props changed)
   freeswitch/branches/voctel/libs/iax/libiax2.vcproj
   freeswitch/branches/voctel/libs/iax/src/   (props changed)
   freeswitch/branches/voctel/libs/iax/src/iax.c
   freeswitch/branches/voctel/libs/libdingaling/   (props changed)
   freeswitch/branches/voctel/libs/libdingaling/aclocal.m4
   freeswitch/branches/voctel/libs/libdingaling/configure
   freeswitch/branches/voctel/libs/libdingaling/configure.in
   freeswitch/branches/voctel/libs/libdingaling/libdingaling.vcproj
   freeswitch/branches/voctel/libs/libdingaling/src/dingaling.def
   freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.c
   freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.h
   freeswitch/branches/voctel/libs/libteletone/   (props changed)
   freeswitch/branches/voctel/libs/libteletone/libteletone.vcproj
   freeswitch/branches/voctel/libs/libteletone/src/libteletone_generate.c
   freeswitch/branches/voctel/libs/mozilla.build.sh
   freeswitch/branches/voctel/libs/srtp/   (props changed)
   freeswitch/branches/voctel/libs/srtp.build.sh
   freeswitch/branches/voctel/libs/srtp/crypto/   (props changed)
   freeswitch/branches/voctel/libs/srtp/crypto/include/   (props changed)
   freeswitch/branches/voctel/libs/srtp/crypto/include/datatypes.h
   freeswitch/branches/voctel/libs/srtp/crypto/test/   (props changed)
   freeswitch/branches/voctel/libs/srtp/test/   (props changed)
   freeswitch/branches/voctel/modules.conf.in
   freeswitch/branches/voctel/scripts/   (props changed)
   freeswitch/branches/voctel/src/include/   (props changed)
   freeswitch/branches/voctel/src/include/switch.h
   freeswitch/branches/voctel/src/include/switch_am_config.h.in
   freeswitch/branches/voctel/src/include/switch_apr.h
   freeswitch/branches/voctel/src/include/switch_buffer.h
   freeswitch/branches/voctel/src/include/switch_caller.h
   freeswitch/branches/voctel/src/include/switch_channel.h
   freeswitch/branches/voctel/src/include/switch_config.h
   freeswitch/branches/voctel/src/include/switch_console.h
   freeswitch/branches/voctel/src/include/switch_core.h
   freeswitch/branches/voctel/src/include/switch_event.h
   freeswitch/branches/voctel/src/include/switch_frame.h
   freeswitch/branches/voctel/src/include/switch_ivr.h
   freeswitch/branches/voctel/src/include/switch_loadable_module.h
   freeswitch/branches/voctel/src/include/switch_log.h
   freeswitch/branches/voctel/src/include/switch_module_interfaces.h
   freeswitch/branches/voctel/src/include/switch_platform.h
   freeswitch/branches/voctel/src/include/switch_resample.h
   freeswitch/branches/voctel/src/include/switch_rtp.h
   freeswitch/branches/voctel/src/include/switch_sqlite.h
   freeswitch/branches/voctel/src/include/switch_stun.h
   freeswitch/branches/voctel/src/include/switch_types.h
   freeswitch/branches/voctel/src/include/switch_utils.h
   freeswitch/branches/voctel/src/mod/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.c
   freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_commands/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_echo/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.c
   freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.c
   freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_playback/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.c
   freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.vcproj
   freeswitch/branches/voctel/src/mod/applications/mod_skel/   (props changed)
   freeswitch/branches/voctel/src/mod/applications/mod_skel/mod_skel.c
   freeswitch/branches/voctel/src/mod/asr_tts/   (props changed)
   freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/   (props changed)
   freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
   freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.vcproj
   freeswitch/branches/voctel/src/mod/codecs/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_g729/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.c
   freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_gsm/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.c
   freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.c
   freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_l16/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.c
   freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.vcproj
   freeswitch/branches/voctel/src/mod/codecs/mod_speex/   (props changed)
   freeswitch/branches/voctel/src/mod/codecs/mod_speex/Makefile
   freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.c
   freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.vcproj
   freeswitch/branches/voctel/src/mod/dialplans/   (props changed)
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/   (props changed)
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
   freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.vcproj
   freeswitch/branches/voctel/src/mod/directories/   (props changed)
   freeswitch/branches/voctel/src/mod/directories/mod_ldap/   (props changed)
   freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.c
   freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.vcproj
   freeswitch/branches/voctel/src/mod/endpoints/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.vcproj
   freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/Makefile
   freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.vcproj
   freeswitch/branches/voctel/src/mod/endpoints/mod_iax/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.vcproj
   freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_PortAudio.vcproj
   freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_wanpipe/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/   (props changed)
   freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.c
   freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/   (props changed)
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/   (props changed)
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/   (props changed)
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.c
   freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/   (props changed)
   freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
   freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.vcproj
   freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/   (props changed)
   freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
   freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj
   freeswitch/branches/voctel/src/mod/formats/   (props changed)
   freeswitch/branches/voctel/src/mod/formats/mod_sndfile/   (props changed)
   freeswitch/branches/voctel/src/mod/formats/mod_sndfile/Makefile
   freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfile.c
   freeswitch/branches/voctel/src/mod/languages/   (props changed)
   freeswitch/branches/voctel/src/mod/languages/mod_perl/   (props changed)
   freeswitch/branches/voctel/src/mod/languages/mod_perl/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.pm
   freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.vcproj
   freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.c
   freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.vcproj
   freeswitch/branches/voctel/src/mod/languages/mod_perl/switch_swig_wrap.c
   freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/   (props changed)
   freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/Makefile
   freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj
   freeswitch/branches/voctel/src/mod/loggers/   (props changed)
   freeswitch/branches/voctel/src/mod/loggers/mod_console/   (props changed)
   freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.c
   freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.vcproj
   freeswitch/branches/voctel/src/mod/loggers/mod_syslog/   (props changed)
   freeswitch/branches/voctel/src/mod/loggers/mod_syslog/mod_syslog.c
   freeswitch/branches/voctel/src/mod/timers/   (props changed)
   freeswitch/branches/voctel/src/mod/timers/mod_softtimer/   (props changed)
   freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.c
   freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.vcproj
   freeswitch/branches/voctel/src/switch.c
   freeswitch/branches/voctel/src/switch_buffer.c
   freeswitch/branches/voctel/src/switch_caller.c
   freeswitch/branches/voctel/src/switch_channel.c
   freeswitch/branches/voctel/src/switch_config.c
   freeswitch/branches/voctel/src/switch_console.c
   freeswitch/branches/voctel/src/switch_core.c
   freeswitch/branches/voctel/src/switch_event.c
   freeswitch/branches/voctel/src/switch_ivr.c
   freeswitch/branches/voctel/src/switch_loadable_module.c
   freeswitch/branches/voctel/src/switch_log.c
   freeswitch/branches/voctel/src/switch_resample.c
   freeswitch/branches/voctel/src/switch_rtp.c
   freeswitch/branches/voctel/src/switch_stun.c
   freeswitch/branches/voctel/src/switch_utils.c
   freeswitch/branches/voctel/w32/   (props changed)
   freeswitch/branches/voctel/w32/Setup/   (props changed)
   freeswitch/branches/voctel/w32/Setup/Setup.vdproj

Log:
update to trunk

Modified: freeswitch/branches/voctel/AUTHORS
==============================================================================
--- freeswitch/branches/voctel/AUTHORS	(original)
+++ freeswitch/branches/voctel/AUTHORS	Fri Sep 22 14:22:15 2006
@@ -16,13 +16,19 @@
 people who have submitted patches, reported bugs, and generally made Freeswitch
 that much better:
 
- Joshua Colp - For his help making mod_exosip possible, and for just being a swell guy!
  Brian K. West - For countless hours of work on BSD and Mac support, finding countless bugs, 
-  and moral support.
+  and moral support.  Xcode project files.
+ Joshua Colp - For his help making mod_exosip possible (which we are now getting rid of but oh well), 
+               and for just being a swell guy! (until he backstabbed us, c'est la vie)
  Michal "cypromis" Bielicki (michal.bielicki  AT halo2.pl) - Solaris porting, and autotools enhancements.
  James Martelletti <james at nerdc0re.com> - All around cool guy (mod_syslog)
- 
+ Johny Kadarisman <jkr888 at gmail.com>
+ Yossi Neiman of Cartis Solutions, Inc. <freeswitch AT cartissolutions.com>  -  implementation of mod_cdr (perldd, mysql, csv)
+ Stefan Knoblich - Various patches and support.  Thanks.
+ Justin Unger - <justinunger at gmail dot com> Lots of help with patches and SIP testing. Thanks! 
+ Paul D. Tinsley - Various patches and support. <pdt at jackhammer.org>
+
 A big THANK YOU goes to:
 
 Justin Cassidy - Build related cleanups and automatic build setup.
-
+Bret McDanel - Javascript Documentation, constant feedback and input, many other things I am sure I am forgetting.

Modified: freeswitch/branches/voctel/INSTALL
==============================================================================
--- freeswitch/branches/voctel/INSTALL	(original)
+++ freeswitch/branches/voctel/INSTALL	Fri Sep 22 14:22:15 2006
@@ -22,6 +22,8 @@
 	*) Rebuild all the dependancies
 	   make megaclean 
 
+  *) Build freeswitch without automatically installing the support libraries (you will need to manually build them all):
+     make nodepends
 
 Windows 32:
 

Modified: freeswitch/branches/voctel/Makefile.am
==============================================================================
--- freeswitch/branches/voctel/Makefile.am	(original)
+++ freeswitch/branches/voctel/Makefile.am	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,9 @@
+
+
 EXTRA_DIST =
 SUBDIRS = 
 AUTOMAKE_OPTS = gnu foreign
-AM_MAKE=`which gmake 2>/dev/null || which make 2>/dev/null || make`
+AM_MAKE=`which gmake 2>/dev/null || which make 2>/dev/null || echo make`
 MAKE=$(AM_MAKE)
 NAME=freeswitch
 PREFIX=$(prefix)
@@ -18,8 +20,14 @@
 AM_LDFLAGS += -Wl,-E
 endif
 
+if CRASHPROT
+AM_CFLAGS += -DCRASH_PROT
+endif
+
+AM_CFGARGS =
 if IS64BITLINUX
-AM_CFLAGS += -m64 -march=k8 -fPIC
+AM_CFLAGS += -m64 -march=k8 -fPIC -D_64BIT_MACHINE_
+AM_CFGARGS += --enable-64bit
 endif
 
 #put elsif win here
@@ -40,6 +48,7 @@
 AM_CFLAGS	+= -DSWITCH_DB_DIR=\"$(PREFIX)/db\"
 AM_CFLAGS	+= -DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
 AM_CFLAGS	+= -DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
+AM_CFLAGS	+= -DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
 
 
 libfreeswitch_la_SOURCES	= \
@@ -66,6 +75,7 @@
 src/include/switch_rtp.h\
 src/include/switch_stun.h\
 src/include/switch_log.h\
+src/include/switch_xml.h\
 src/switch_rtp.c\
 src/switch_buffer.c \
 src/switch_caller.c \
@@ -79,7 +89,8 @@
 src/switch_resample.c \
 src/switch_ivr.c \
 src/switch_stun.c\
-src/switch_log.c
+src/switch_log.c\
+src/switch_xml.c
 
 
 
@@ -109,19 +120,21 @@
 src/include/switch_rtp.h\
 src/include/switch_version.h\
 src/include/switch_stun.h\
-src/include/switch_log.h
+src/include/switch_log.h\
+src/include/switch_xml.h
 
 BUILT_SOURCES = version depends
-CLEANFILES = src/include/switch_version.h
+CLEANFILES = src/include/switch_version.h scripts/fsxs
 
 
 lib_LTLIBRARIES		= libfreeswitch.la
-libfreeswitch_la_CFLAGS	= $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g  
+libfreeswitch_la_CFLAGS	= $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -std=c99 
 libfreeswitch_la_LDFLAGS	= -version-info 1:0:0
-libfreeswitch_la_LIBADD  = -lteletone -lresample -lsrtp -lsqlite3 
+libfreeswitch_la_LIBADD  = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup -lpcre
 nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
 
 bin_PROGRAMS =	freeswitch
+bin_SCRIPTS = scripts/fsxs
 freeswitch_SOURCES = 	src/switch.c\
 			src/include/switch_version.h
 freeswitch_CFLAGS = $(AM_CFLAGS)
@@ -150,13 +163,15 @@
 	@rm -f build/freeswitch.env
 	@./build/addenv.sh build/freeswitch.env PREFIX $(PREFIX)
 	@./build/addenv.sh build/freeswitch.env MAKE $(MAKE)
-	./build/buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
-	./build/buildlib.sh . install apr-1.2.6.tar.gz --prefix=$(PREFIX)
-	./build/buildlib.sh . install apr-util-1.2.6.tar.gz --with-apr=../apr-1.2.6 --prefix=$(PREFIX)
+	mkdir -p $(PREFIX)
+	./build/buildlib.sh . install sqlite-3.3.6.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
+	./build/buildlib.sh . install apr-1.2.7.tar.gz --prefix=$(PREFIX)
+	./build/buildlib.sh . install apr-util-1.2.7.tar.gz --with-apr=../apr-1.2.7 --prefix=$(PREFIX)
 	./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
 	./build/buildlib.sh . install libteletone --prefix=$(PREFIX)
 	./build/buildlib.sh . install srtp --prefix=$(PREFIX)
-	./build/buildlib.sh . install jitterbuffer --prefix=$(PREFIX)
+	./build/buildlib.sh . install libspeakup --prefix=$(PREFIX)
+	./build/buildlib.sh . install pcre-6.4.tar.gz --prefix=$(PREFIX)
 	rm build/freeswitch.env
 
 
@@ -175,6 +190,7 @@
 	@./build/addenv.sh build/freeswitch.env LDFLAGS "$(AM_LDFLAGS) -lfreeswitch"
 	@./build/addenv.sh build/freeswitch.env CFLAGS "-Werror $(AM_CFLAGS)"
 	@./build/addenv.sh build/freeswitch.env CC "$(CC)"
+	@./build/addenv.sh build/freeswitch.env CFGARGS "$(AM_CFGARGS)"
 	@cd src/mod && for i in `cat ../../modules.conf | grep -v \#` ; do echo making $$i ; $(PWD)/build/modmake.sh $(PWD) $$i || exit 1; done
 	@rm -f build/freeswitch.env
 
@@ -190,6 +206,8 @@
 
 installall: install install_mod
 
+sure: clean modclean modwipe uninstall installall
+
 wayclean: clean modclean
 
 modwipe:
@@ -197,8 +215,8 @@
 
 install_mod: modules
 	@echo Installing $(NAME)
-	@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
-	@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
+	@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
+	@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
 	@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
 	@echo Installing Modules
 	@rm -f build/freeswitch.env
@@ -219,6 +237,27 @@
 
 dox:
 	cd docs && doxygen $(PWD)/docs/Doxygen.conf
+
+scripts/fsxs: scripts/fsxs.in
+	@echo creating fsxs
+	@sed -e "s, at MODULES_DIR\@,$(PREFIX)/mod," \
+	    -e "s, at LIB_DIR\@,$(PREFIX)/lib," \
+	    -e "s, at BIN_DIR\@,$(PREFIX)/bin," \
+	    -e "s, at INC_DIR\@,$(PREFIX)/include," \
+	    -e "s, at CFG_DIR\@,$(PREFIX)/conf," \
+	    -e "s, at DB_DIR\@,$(PREFIX)/db," \
+	    -e "s, at PREFIX\@,$(PREFIX)," \
+	    -e "s, at CC\@,$(CC)," \
+	    -e "s, at LD\@,$(CC)," \
+	    -e "s, at INSTALL\@,$(INSTALL)," \
+	    -e "s, at MKINSTALLDIRS\@,$(mkdir_p)," \
+	    \
+	    -e "s|@CFLAGS\@|$(CFLAGS) -fPIC $(shell $(APR_CONFIG) --cflags --cppflags)|" \
+	    -e "s|@INCLUDES\@|-I$(PREFIX)/include $(shell $(APR_CONFIG) --includes) $(shell $(APU_CONFIG) --includes)|" \
+	    -e "s|@SOLINK\@|$(SOLINK)|" \
+	    -e "s|@LDFLAGS\@|-L$(PREFIX)/lib|" \
+	    -e "s|@LIBS\@|-lfreeswitch|" \
+	    scripts/fsxs.in > scripts/fsxs
 
 eclean: clean
 	rm -f `find . -type f -name \*~`

Modified: freeswitch/branches/voctel/Makefile.in
==============================================================================
--- freeswitch/branches/voctel/Makefile.in	(original)
+++ freeswitch/branches/voctel/Makefile.in	Fri Sep 22 14:22:15 2006
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.2 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -16,6 +16,9 @@
 
 
 
+
+SOURCES = $(libfreeswitch_la_SOURCES) $(nodist_libfreeswitch_la_SOURCES) $(freeswitch_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -39,8 +42,10 @@
 build_triplet = @build@
 host_triplet = @host@
 @ISLINUX_TRUE at am__append_1 = -Wl,-E
- at IS64BITLINUX_TRUE@am__append_2 = -m64 -march=k8 -fPIC
- at ISMAC_TRUE@am__append_3 = -DMACOSX
+ at CRASHPROT_TRUE@am__append_2 = -DCRASH_PROT
+ at IS64BITLINUX_TRUE@am__append_3 = -m64 -march=k8 -fPIC -D_64BIT_MACHINE_
+ at IS64BITLINUX_TRUE@am__append_4 = --enable-64bit
+ at ISMAC_TRUE@am__append_5 = -DMACOSX
 bin_PROGRAMS = freeswitch$(EXEEXT)
 DIST_COMMON = README $(am__configure_deps) $(library_include_HEADERS) \
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@@ -68,7 +73,7 @@
   esac;
 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
-	"$(DESTDIR)$(library_includedir)"
+	"$(DESTDIR)$(bindir)" "$(DESTDIR)$(library_includedir)"
 libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libfreeswitch_la_DEPENDENCIES =
@@ -84,7 +89,7 @@
 	libfreeswitch_la-switch_event.lo \
 	libfreeswitch_la-switch_resample.lo \
 	libfreeswitch_la-switch_ivr.lo libfreeswitch_la-switch_stun.lo \
-	libfreeswitch_la-switch_log.lo
+	libfreeswitch_la-switch_log.lo libfreeswitch_la-switch_xml.lo
 nodist_libfreeswitch_la_OBJECTS =
 libfreeswitch_la_OBJECTS = $(am_libfreeswitch_la_OBJECTS) \
 	$(nodist_libfreeswitch_la_OBJECTS)
@@ -93,16 +98,18 @@
 am_freeswitch_OBJECTS = freeswitch-switch.$(OBJEXT)
 freeswitch_OBJECTS = $(am_freeswitch_OBJECTS)
 freeswitch_DEPENDENCIES = ${top_builddir}/libfreeswitch.la
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src/include
 depcomp = $(SHELL) $(top_srcdir)/build/config/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
 	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
 	$(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(libfreeswitch_la_SOURCES) \
 	$(nodist_libfreeswitch_la_SOURCES) $(freeswitch_SOURCES)
@@ -143,6 +150,8 @@
 CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CRASHPROT_FALSE = @CRASHPROT_FALSE@
+CRASHPROT_TRUE = @CRASHPROT_TRUE@
 CXX = @CXX@
 CXXCPP = @CXXCPP@
 CXXDEPMODE = @CXXDEPMODE@
@@ -234,7 +243,7 @@
 EXTRA_DIST = 
 SUBDIRS = 
 AUTOMAKE_OPTS = gnu foreign
-AM_MAKE = `which gmake 2>/dev/null || which make 2>/dev/null || make`
+AM_MAKE = `which gmake 2>/dev/null || which make 2>/dev/null || echo make`
 MAKE = $(AM_MAKE)
 NAME = freeswitch
 PREFIX = $(prefix)
@@ -243,17 +252,20 @@
 AM_CFLAGS = -I$(PREFIX)/include $(shell $(APR_CONFIG) --cflags \
 	--cppflags --includes) -I${prefix}/include/srtp $(shell \
 	$(APU_CONFIG) --includes) $(am__append_2) $(am__append_3) \
-	-fPIC -Wall -I$(PWD)/src/sqlite -I$(PWD) -I$(PWD)/src/include \
-	-I$(PREFIX)/include -DSWITCH_MOD_DIR=\"$(PREFIX)/mod\" \
+	$(am__append_5) -fPIC -Wall -I$(PWD)/src/sqlite -I$(PWD) \
+	-I$(PWD)/src/include -I$(PREFIX)/include \
+	-DSWITCH_MOD_DIR=\"$(PREFIX)/mod\" \
 	-DSWITCH_PREFIX_DIR=\"$(PREFIX)\" \
 	-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
 	-DSWITCH_DB_DIR=\"$(PREFIX)/db\" \
 	-DSWITCH_LOG_DIR=\"$(PREFIX)/log\" \
-	-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
+	-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\" \
+	-DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
 AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
 	$(shell $(APU_CONFIG) --link-ld --libs ) -lm \
 	-L/usr/local/lib/db42 -L/usr/local/lib $(am__append_1)
 OSARCH = $(shell uname -s)
+AM_CFGARGS = $(am__append_4)
 @ISMAC_FALSE at SOLINK = -shared -Xlinker -x
 
 #put elsif win here
@@ -284,6 +296,7 @@
 src/include/switch_rtp.h\
 src/include/switch_stun.h\
 src/include/switch_log.h\
+src/include/switch_xml.h\
 src/switch_rtp.c\
 src/switch_buffer.c \
 src/switch_caller.c \
@@ -297,7 +310,8 @@
 src/switch_resample.c \
 src/switch_ivr.c \
 src/switch_stun.c\
-src/switch_log.c
+src/switch_log.c\
+src/switch_xml.c
 
 
 #bindir = $(PREFIX)/bin
@@ -326,15 +340,17 @@
 src/include/switch_rtp.h\
 src/include/switch_version.h\
 src/include/switch_stun.h\
-src/include/switch_log.h
+src/include/switch_log.h\
+src/include/switch_xml.h
 
 BUILT_SOURCES = version depends
-CLEANFILES = src/include/switch_version.h
+CLEANFILES = src/include/switch_version.h scripts/fsxs
 lib_LTLIBRARIES = libfreeswitch.la
-libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g  
+libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -std=c99 
 libfreeswitch_la_LDFLAGS = -version-info 1:0:0
-libfreeswitch_la_LIBADD = -lteletone -lresample -lsrtp -lsqlite3 
+libfreeswitch_la_LIBADD = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup -lpcre
 nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
+bin_SCRIPTS = scripts/fsxs
 freeswitch_SOURCES = src/switch.c\
 			src/include/switch_version.h
 
@@ -457,7 +473,26 @@
 freeswitch$(EXEEXT): $(freeswitch_OBJECTS) $(freeswitch_DEPENDENCIES) 
 	@rm -f freeswitch$(EXEEXT)
 	$(LINK) $(freeswitch_LDFLAGS) $(freeswitch_OBJECTS) $(freeswitch_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	    $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+	  else :; fi; \
+	done
 
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 
@@ -479,6 +514,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libfreeswitch_la-switch_rtp.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libfreeswitch_la-switch_stun.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libfreeswitch_la-switch_utils.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libfreeswitch_la-switch_xml.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@@ -502,103 +538,110 @@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
 libfreeswitch_la-switch_rtp.lo: src/switch_rtp.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_rtp.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_rtp.Tpo" -c -o libfreeswitch_la-switch_rtp.lo `test -f 'src/switch_rtp.c' || echo '$(srcdir)/'`src/switch_rtp.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_rtp.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_rtp.Tpo" -c -o libfreeswitch_la-switch_rtp.lo `test -f 'src/switch_rtp.c' || echo '$(srcdir)/'`src/switch_rtp.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_rtp.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_rtp.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_rtp.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_rtp.c' object='libfreeswitch_la-switch_rtp.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_rtp.lo `test -f 'src/switch_rtp.c' || echo '$(srcdir)/'`src/switch_rtp.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_rtp.lo `test -f 'src/switch_rtp.c' || echo '$(srcdir)/'`src/switch_rtp.c
 
 libfreeswitch_la-switch_buffer.lo: src/switch_buffer.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_buffer.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_buffer.Tpo" -c -o libfreeswitch_la-switch_buffer.lo `test -f 'src/switch_buffer.c' || echo '$(srcdir)/'`src/switch_buffer.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_buffer.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_buffer.Tpo" -c -o libfreeswitch_la-switch_buffer.lo `test -f 'src/switch_buffer.c' || echo '$(srcdir)/'`src/switch_buffer.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_buffer.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_buffer.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_buffer.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_buffer.c' object='libfreeswitch_la-switch_buffer.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_buffer.lo `test -f 'src/switch_buffer.c' || echo '$(srcdir)/'`src/switch_buffer.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_buffer.lo `test -f 'src/switch_buffer.c' || echo '$(srcdir)/'`src/switch_buffer.c
 
 libfreeswitch_la-switch_caller.lo: src/switch_caller.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_caller.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_caller.Tpo" -c -o libfreeswitch_la-switch_caller.lo `test -f 'src/switch_caller.c' || echo '$(srcdir)/'`src/switch_caller.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_caller.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_caller.Tpo" -c -o libfreeswitch_la-switch_caller.lo `test -f 'src/switch_caller.c' || echo '$(srcdir)/'`src/switch_caller.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_caller.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_caller.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_caller.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_caller.c' object='libfreeswitch_la-switch_caller.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_caller.lo `test -f 'src/switch_caller.c' || echo '$(srcdir)/'`src/switch_caller.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_caller.lo `test -f 'src/switch_caller.c' || echo '$(srcdir)/'`src/switch_caller.c
 
 libfreeswitch_la-switch_channel.lo: src/switch_channel.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_channel.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_channel.Tpo" -c -o libfreeswitch_la-switch_channel.lo `test -f 'src/switch_channel.c' || echo '$(srcdir)/'`src/switch_channel.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_channel.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_channel.Tpo" -c -o libfreeswitch_la-switch_channel.lo `test -f 'src/switch_channel.c' || echo '$(srcdir)/'`src/switch_channel.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_channel.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_channel.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_channel.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_channel.c' object='libfreeswitch_la-switch_channel.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_channel.lo `test -f 'src/switch_channel.c' || echo '$(srcdir)/'`src/switch_channel.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_channel.lo `test -f 'src/switch_channel.c' || echo '$(srcdir)/'`src/switch_channel.c
 
 libfreeswitch_la-switch_config.lo: src/switch_config.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_config.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_config.Tpo" -c -o libfreeswitch_la-switch_config.lo `test -f 'src/switch_config.c' || echo '$(srcdir)/'`src/switch_config.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_config.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_config.Tpo" -c -o libfreeswitch_la-switch_config.lo `test -f 'src/switch_config.c' || echo '$(srcdir)/'`src/switch_config.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_config.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_config.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_config.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_config.c' object='libfreeswitch_la-switch_config.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_config.lo `test -f 'src/switch_config.c' || echo '$(srcdir)/'`src/switch_config.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_config.lo `test -f 'src/switch_config.c' || echo '$(srcdir)/'`src/switch_config.c
 
 libfreeswitch_la-switch_console.lo: src/switch_console.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_console.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_console.Tpo" -c -o libfreeswitch_la-switch_console.lo `test -f 'src/switch_console.c' || echo '$(srcdir)/'`src/switch_console.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_console.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_console.Tpo" -c -o libfreeswitch_la-switch_console.lo `test -f 'src/switch_console.c' || echo '$(srcdir)/'`src/switch_console.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_console.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_console.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_console.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_console.c' object='libfreeswitch_la-switch_console.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_console.lo `test -f 'src/switch_console.c' || echo '$(srcdir)/'`src/switch_console.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_console.lo `test -f 'src/switch_console.c' || echo '$(srcdir)/'`src/switch_console.c
 
 libfreeswitch_la-switch_core.lo: src/switch_core.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_core.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_core.Tpo" -c -o libfreeswitch_la-switch_core.lo `test -f 'src/switch_core.c' || echo '$(srcdir)/'`src/switch_core.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_core.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_core.Tpo" -c -o libfreeswitch_la-switch_core.lo `test -f 'src/switch_core.c' || echo '$(srcdir)/'`src/switch_core.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_core.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_core.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_core.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_core.c' object='libfreeswitch_la-switch_core.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_core.lo `test -f 'src/switch_core.c' || echo '$(srcdir)/'`src/switch_core.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_core.lo `test -f 'src/switch_core.c' || echo '$(srcdir)/'`src/switch_core.c
 
 libfreeswitch_la-switch_loadable_module.lo: src/switch_loadable_module.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_loadable_module.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Tpo" -c -o libfreeswitch_la-switch_loadable_module.lo `test -f 'src/switch_loadable_module.c' || echo '$(srcdir)/'`src/switch_loadable_module.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_loadable_module.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Tpo" -c -o libfreeswitch_la-switch_loadable_module.lo `test -f 'src/switch_loadable_module.c' || echo '$(srcdir)/'`src/switch_loadable_module.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_loadable_module.c' object='libfreeswitch_la-switch_loadable_module.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_loadable_module.lo `test -f 'src/switch_loadable_module.c' || echo '$(srcdir)/'`src/switch_loadable_module.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_loadable_module.lo `test -f 'src/switch_loadable_module.c' || echo '$(srcdir)/'`src/switch_loadable_module.c
 
 libfreeswitch_la-switch_utils.lo: src/switch_utils.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_utils.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_utils.Tpo" -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_utils.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_utils.Tpo" -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_utils.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_utils.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_utils.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_utils.c' object='libfreeswitch_la-switch_utils.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c
 
 libfreeswitch_la-switch_event.lo: src/switch_event.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_event.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_event.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_event.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_event.c' object='libfreeswitch_la-switch_event.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c
 
 libfreeswitch_la-switch_resample.lo: src/switch_resample.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_resample.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_resample.Tpo" -c -o libfreeswitch_la-switch_resample.lo `test -f 'src/switch_resample.c' || echo '$(srcdir)/'`src/switch_resample.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_resample.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_resample.Tpo" -c -o libfreeswitch_la-switch_resample.lo `test -f 'src/switch_resample.c' || echo '$(srcdir)/'`src/switch_resample.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_resample.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_resample.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_resample.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_resample.c' object='libfreeswitch_la-switch_resample.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_resample.lo `test -f 'src/switch_resample.c' || echo '$(srcdir)/'`src/switch_resample.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_resample.lo `test -f 'src/switch_resample.c' || echo '$(srcdir)/'`src/switch_resample.c
 
 libfreeswitch_la-switch_ivr.lo: src/switch_ivr.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_ivr.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_ivr.Tpo" -c -o libfreeswitch_la-switch_ivr.lo `test -f 'src/switch_ivr.c' || echo '$(srcdir)/'`src/switch_ivr.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_ivr.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_ivr.Tpo" -c -o libfreeswitch_la-switch_ivr.lo `test -f 'src/switch_ivr.c' || echo '$(srcdir)/'`src/switch_ivr.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_ivr.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_ivr.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_ivr.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_ivr.c' object='libfreeswitch_la-switch_ivr.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_ivr.lo `test -f 'src/switch_ivr.c' || echo '$(srcdir)/'`src/switch_ivr.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_ivr.lo `test -f 'src/switch_ivr.c' || echo '$(srcdir)/'`src/switch_ivr.c
 
 libfreeswitch_la-switch_stun.lo: src/switch_stun.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_stun.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_stun.Tpo" -c -o libfreeswitch_la-switch_stun.lo `test -f 'src/switch_stun.c' || echo '$(srcdir)/'`src/switch_stun.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_stun.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_stun.Tpo" -c -o libfreeswitch_la-switch_stun.lo `test -f 'src/switch_stun.c' || echo '$(srcdir)/'`src/switch_stun.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_stun.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_stun.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_stun.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_stun.c' object='libfreeswitch_la-switch_stun.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_stun.lo `test -f 'src/switch_stun.c' || echo '$(srcdir)/'`src/switch_stun.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_stun.lo `test -f 'src/switch_stun.c' || echo '$(srcdir)/'`src/switch_stun.c
 
 libfreeswitch_la-switch_log.lo: src/switch_log.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_log.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_log.Tpo" -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c; \
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_log.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_log.Tpo" -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_log.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_log.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_log.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_log.c' object='libfreeswitch_la-switch_log.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c
 
+libfreeswitch_la-switch_xml.lo: src/switch_xml.c
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_xml.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo" -c -o libfreeswitch_la-switch_xml.lo `test -f 'src/switch_xml.c' || echo '$(srcdir)/'`src/switch_xml.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_xml.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo"; exit 1; fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/switch_xml.c' object='libfreeswitch_la-switch_xml.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_xml.lo `test -f 'src/switch_xml.c' || echo '$(srcdir)/'`src/switch_xml.c
+
 freeswitch-switch.o: src/switch.c
 @am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(freeswitch_CFLAGS) $(CFLAGS) -MT freeswitch-switch.o -MD -MP -MF "$(DEPDIR)/freeswitch-switch.Tpo" -c -o freeswitch-switch.o `test -f 'src/switch.c' || echo '$(srcdir)/'`src/switch.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/freeswitch-switch.Tpo" "$(DEPDIR)/freeswitch-switch.Po"; else rm -f "$(DEPDIR)/freeswitch-switch.Tpo"; exit 1; fi
@@ -647,13 +690,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -665,7 +702,7 @@
 	    local_target="$$target"; \
 	  fi; \
 	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
@@ -673,13 +710,7 @@
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	case "$@" in \
 	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
@@ -700,7 +731,7 @@
 	    local_target="$$target"; \
 	  fi; \
 	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -917,12 +948,12 @@
 check-am: all-am
 check: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) check-recursive
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(HEADERS)
 install-binPROGRAMS: install-libLTLIBRARIES
 
 installdirs: installdirs-recursive
 installdirs-am:
-	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(library_includedir)"; do \
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(library_includedir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
 	done
 install: $(BUILT_SOURCES)
@@ -976,7 +1007,8 @@
 
 install-data-am: install-library_includeHEADERS
 
-install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+	install-libLTLIBRARIES
 
 install-info: install-info-recursive
 
@@ -1004,8 +1036,9 @@
 
 ps-am:
 
-uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
-	uninstall-libLTLIBRARIES uninstall-library_includeHEADERS
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+	uninstall-info-am uninstall-libLTLIBRARIES \
+	uninstall-library_includeHEADERS
 
 uninstall-info: uninstall-info-recursive
 
@@ -1017,16 +1050,16 @@
 	distclean-generic distclean-hdr distclean-libtool \
 	distclean-recursive distclean-tags distcleancheck distdir \
 	distuninstallcheck dvi dvi-am html html-am info info-am \
-	install install-am install-binPROGRAMS install-data \
-	install-data-am install-exec install-exec-am install-info \
-	install-info-am install-libLTLIBRARIES \
+	install install-am install-binPROGRAMS install-binSCRIPTS \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-libLTLIBRARIES \
 	install-library_includeHEADERS install-man install-strip \
 	installcheck installcheck-am installdirs installdirs-am \
 	maintainer-clean maintainer-clean-generic \
 	maintainer-clean-recursive mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
 	pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
-	uninstall-binPROGRAMS uninstall-info-am \
+	uninstall-binPROGRAMS uninstall-binSCRIPTS uninstall-info-am \
 	uninstall-libLTLIBRARIES uninstall-library_includeHEADERS
 
 
@@ -1050,13 +1083,15 @@
 	@rm -f build/freeswitch.env
 	@./build/addenv.sh build/freeswitch.env PREFIX $(PREFIX)
 	@./build/addenv.sh build/freeswitch.env MAKE $(MAKE)
-	./build/buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
-	./build/buildlib.sh . install apr-1.2.6.tar.gz --prefix=$(PREFIX)
-	./build/buildlib.sh . install apr-util-1.2.6.tar.gz --with-apr=../apr-1.2.6 --prefix=$(PREFIX)
+	mkdir -p $(PREFIX)
+	./build/buildlib.sh . install sqlite-3.3.6.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
+	./build/buildlib.sh . install apr-1.2.7.tar.gz --prefix=$(PREFIX)
+	./build/buildlib.sh . install apr-util-1.2.7.tar.gz --with-apr=../apr-1.2.7 --prefix=$(PREFIX)
 	./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
 	./build/buildlib.sh . install libteletone --prefix=$(PREFIX)
 	./build/buildlib.sh . install srtp --prefix=$(PREFIX)
-	./build/buildlib.sh . install jitterbuffer --prefix=$(PREFIX)
+	./build/buildlib.sh . install libspeakup --prefix=$(PREFIX)
+	./build/buildlib.sh . install pcre-6.4.tar.gz --prefix=$(PREFIX)
 	rm build/freeswitch.env
 
 modules: $(NAME)
@@ -1074,6 +1109,7 @@
 	@./build/addenv.sh build/freeswitch.env LDFLAGS "$(AM_LDFLAGS) -lfreeswitch"
 	@./build/addenv.sh build/freeswitch.env CFLAGS "-Werror $(AM_CFLAGS)"
 	@./build/addenv.sh build/freeswitch.env CC "$(CC)"
+	@./build/addenv.sh build/freeswitch.env CFGARGS "$(AM_CFGARGS)"
 	@cd src/mod && for i in `cat ../../modules.conf | grep -v \#` ; do echo making $$i ; $(PWD)/build/modmake.sh $(PWD) $$i || exit 1; done
 	@rm -f build/freeswitch.env
 
@@ -1089,6 +1125,8 @@
 
 installall: install install_mod
 
+sure: clean modclean modwipe uninstall installall
+
 wayclean: clean modclean
 
 modwipe:
@@ -1096,8 +1134,8 @@
 
 install_mod: modules
 	@echo Installing $(NAME)
-	@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
-	@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
+	@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
+	@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
 	@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
 	@echo Installing Modules
 	@rm -f build/freeswitch.env
@@ -1118,6 +1156,27 @@
 
 dox:
 	cd docs && doxygen $(PWD)/docs/Doxygen.conf
+
+scripts/fsxs: scripts/fsxs.in
+	@echo creating fsxs
+	@sed -e "s, at MODULES_DIR\@,$(PREFIX)/mod," \
+	    -e "s, at LIB_DIR\@,$(PREFIX)/lib," \
+	    -e "s, at BIN_DIR\@,$(PREFIX)/bin," \
+	    -e "s, at INC_DIR\@,$(PREFIX)/include," \
+	    -e "s, at CFG_DIR\@,$(PREFIX)/conf," \
+	    -e "s, at DB_DIR\@,$(PREFIX)/db," \
+	    -e "s, at PREFIX\@,$(PREFIX)," \
+	    -e "s, at CC\@,$(CC)," \
+	    -e "s, at LD\@,$(CC)," \
+	    -e "s, at INSTALL\@,$(INSTALL)," \
+	    -e "s, at MKINSTALLDIRS\@,$(mkdir_p)," \
+	    \
+	    -e "s|@CFLAGS\@|$(CFLAGS) -fPIC $(shell $(APR_CONFIG) --cflags --cppflags)|" \
+	    -e "s|@INCLUDES\@|-I$(PREFIX)/include $(shell $(APR_CONFIG) --includes) $(shell $(APU_CONFIG) --includes)|" \
+	    -e "s|@SOLINK\@|$(SOLINK)|" \
+	    -e "s|@LDFLAGS\@|-L$(PREFIX)/lib|" \
+	    -e "s|@LIBS\@|-lfreeswitch|" \
+	    scripts/fsxs.in > scripts/fsxs
 
 eclean: clean
 	rm -f `find . -type f -name \*~`

Modified: freeswitch/branches/voctel/aclocal.m4
==============================================================================
--- freeswitch/branches/voctel/aclocal.m4	(original)
+++ freeswitch/branches/voctel/aclocal.m4	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.2 -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005  Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -123,7 +123,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 [sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
 
 # Same as above, but do not quote variable references.
@@ -191,8 +191,6 @@
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-_LT_CC_BASENAME([$compiler])
-
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
 file_magic*)
@@ -238,48 +236,6 @@
 ])# _LT_AC_SYS_COMPILER
 
 
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
 # Links a minimal program and checks the executable
@@ -352,7 +308,7 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 if test -z "$ECHO"; then
 if test "X${echo_test_string+set}" != Xset; then
@@ -621,10 +577,8 @@
    echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        $2=yes
      fi
    fi
@@ -655,11 +609,6 @@
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
      else
        $2=yes
      fi
@@ -718,38 +667,11 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    # 
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  *)
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+    while (test "X"`$CONFIG_SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
 	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
 	    lt_cv_sys_max_cmd_len=$new_result &&
@@ -1015,9 +937,7 @@
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
@@ -1085,8 +1005,8 @@
 [AC_MSG_CHECKING([how to hardcode library paths into programs])
 _LT_AC_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
-   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
-   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
@@ -1253,7 +1173,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[[45]]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -1311,7 +1231,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -1369,9 +1289,7 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
+freebsd*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -1390,7 +1308,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+  freebsd3.[01]* | freebsdelf3.[01]*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -1514,10 +1432,27 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+    if AC_TRY_EVAL(ac_compile); then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -1579,11 +1514,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -1749,9 +1680,7 @@
 
       case $tagname in
       CXX)
-	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-	    (test "X$CXX" != "Xg++"))) ; then
+	if test -n "$CXX" && test "X$CXX" != "Xno"; then
 	  AC_LIBTOOL_LANG_CXX_CONFIG
 	else
 	  tagname=""
@@ -2156,15 +2085,6 @@
 *) reload_flag=" $reload_flag" ;;
 esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
 ])# AC_PROG_LD_RELOAD_FLAG
 
 
@@ -2198,7 +2118,7 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-bsdi[[45]]*)
+bsdi4*)
   lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
   lt_cv_file_magic_cmd='/usr/bin/file -L'
   lt_cv_file_magic_test_file=/shlib/libc.so
@@ -2221,13 +2141,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -2271,6 +2191,15 @@
 
 # This must be Linux ELF.
 linux*)
+  case $host_cpu in
+  alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2293,10 +2222,12 @@
   ;;
 
 openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
   if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object'
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
   fi
   ;;
 
@@ -2486,21 +2417,10 @@
 # ---------------
 AC_DEFUN([_LT_AC_LANG_CXX],
 [AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+AC_REQUIRE([AC_PROG_CXXCPP])
 _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
 ])# _LT_AC_LANG_CXX
 
-# _LT_AC_PROG_CXXCPP
-# ---------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
 
 # AC_LIBTOOL_F77
 # --------------
@@ -2573,10 +2493,6 @@
 
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 #
 # Check for any special shared library compilation flags.
 #
@@ -2640,6 +2556,43 @@
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
+  ;;
+  darwin* | rhapsody*)
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case "$host_os" in
+    rhapsody* | darwin1.[[012]])
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+      ;;
+    esac
+    output_verbose_link_cmd='echo'
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+    _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag  -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+  else
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+  fi
     ;;
 esac
 AC_MSG_RESULT([$enable_shared])
@@ -2665,7 +2618,7 @@
 AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
 [AC_LANG_PUSH(C++)
 AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+AC_REQUIRE([AC_PROG_CXXCPP])
 
 _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
 _LT_AC_TAGVAR(allow_undefined_flag, $1)=
@@ -2709,10 +2662,6 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -2734,7 +2683,7 @@
 CC=${CXX-"c++"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
@@ -2841,7 +2790,7 @@
     _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      case $host_os in aix4.[012]|aix4.[012].*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -2862,9 +2811,6 @@
 	fi
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -2924,7 +2870,6 @@
     esac
     ;;
 
-
   cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
     # as there is no search path for DLLs.
@@ -2948,76 +2893,65 @@
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
   ;;
-      darwin* | rhapsody*)
-        case "$host_os" in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+  darwin* | rhapsody*)
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case "$host_os" in
+    rhapsody* | darwin1.[[012]])
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
       else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
       fi
-        ;;
+      ;;
+    esac
+    lt_int_apple_cc_single_mod=no
+    output_verbose_link_cmd='echo'
+    if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+      lt_int_apple_cc_single_mod=yes
+    fi
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    else
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    fi
+    _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
 
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+  else
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+  fi
+    ;;
+
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3028,14 +2962,14 @@
 	;;
     esac
     ;;
-  freebsd[[12]]*)
+  freebsd[12]*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
   freebsd-elf*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     _LT_AC_TAGVAR(ld_shlibs, $1)=yes
@@ -3052,11 +2986,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
       ;;
-    aCC*)
+    aCC)
       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -3066,7 +3000,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -3117,11 +3051,11 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      aCC*)
+      aCC)
 	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
@@ -3161,9 +3095,9 @@
     ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -3174,7 +3108,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -3187,7 +3121,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3212,41 +3146,17 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
-	# version 8.0 and above of icpc choke on multiply defined symbols
-	# if we add $predep_objects and $postdep_objects, however 7.1 and
-	# earlier do not add the objects themselves.
-	case `$CC -V 2>&1` in
-	*"Version 7."*)
-  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-  	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	esac
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -3277,7 +3187,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
@@ -3298,25 +3208,9 @@
     # Workaround some broken pre-1.5 toolchains
     output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
     ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  openbsd*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3332,14 +3226,14 @@
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3357,7 +3251,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3376,7 +3270,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3391,17 +3285,17 @@
 	# the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -3420,7 +3314,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3444,7 +3338,7 @@
   sco*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
@@ -3456,12 +3350,12 @@
     ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3474,7 +3368,7 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -3484,17 +3378,13 @@
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	case $host_os in
-	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
@@ -3515,7 +3405,7 @@
 	# in the archive.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -3558,7 +3448,7 @@
     ;;
   tandem*)
     case $cc_basename in
-      NCC*)
+      NCC)
 	# NonStop-UX NCC 3.20
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3790,16 +3680,12 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${F77-"f77"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
@@ -3818,9 +3704,7 @@
   fi
   ;;
 aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
+  test "$enable_shared" = yes && enable_static=no
   ;;
 esac
 AC_MSG_RESULT([$enable_shared])
@@ -3871,27 +3755,20 @@
 lt_simple_compile_test_code="class foo {}\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
 _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
 
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
 AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
 AC_LIBTOOL_PROG_COMPILER_PIC($1)
 AC_LIBTOOL_PROG_CC_C_O($1)
@@ -3934,16 +3811,11 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
 
 AC_LIBTOOL_CONFIG($1)
@@ -4079,7 +3951,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -4090,11 +3962,11 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 # The names of the tagged configurations supported by this script.
 available_tags=
@@ -4125,13 +3997,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -4207,7 +4073,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -4481,6 +4347,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -4502,13 +4371,6 @@
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDGIRSTW]]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
 irix* | nonstopux*)
   symcode='[[BCDEGRST]]'
   ;;
@@ -4540,11 +4402,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -4733,28 +4592,18 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
 	esac
 	;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           ;;
-         esac
-       ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -4762,19 +4611,19 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    case "$host_cpu" in
@@ -4792,7 +4641,7 @@
 	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -4803,24 +4652,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -4837,7 +4680,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
 	    ;;
 	  *)
@@ -4848,14 +4691,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -4871,7 +4714,7 @@
 	;;
       sco*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  *)
@@ -4880,13 +4723,13 @@
 	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	    ;;
@@ -4896,12 +4739,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -4911,7 +4754,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
@@ -5008,16 +4851,6 @@
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -5053,19 +4886,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-        ;;
       ccc*)
         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         # All Alpha code is PIC.
@@ -5086,14 +4912,9 @@
       ;;
 
     solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
-      *)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -5115,11 +4936,6 @@
       fi
       ;;
 
-    unicos*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-
     uts4*)
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -5180,7 +4996,7 @@
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -5223,8 +5039,7 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  _LT_CC_BASENAME([$compiler])
+
   case $host_os in
   cygwin* | mingw* | pw32*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
@@ -5243,28 +5058,7 @@
   if test "$with_gnu_ld" = yes; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
-    
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-    
+
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -5315,7 +5109,7 @@
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -5329,41 +5123,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -5402,6 +5165,31 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds"
+      fi
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -5412,11 +5200,16 @@
       ;;
     esac
 
-    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
-      runpath_var=
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then
+      runpath_var=LD_RUN_PATH
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -5480,7 +5273,7 @@
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -5501,9 +5294,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -5562,7 +5352,7 @@
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
       ;;
 
-    bsdi[[45]]*)
+    bsdi4*)
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
       ;;
 
@@ -5583,57 +5373,57 @@
       _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
       _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       case "$host_os" in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
+      rhapsody* | darwin1.[[012]])
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
       esac
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
       ;;
 
@@ -5667,7 +5457,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -5778,7 +5568,6 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
       else
@@ -5824,7 +5613,7 @@
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5843,12 +5632,10 @@
     solaris*)
       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -5857,18 +5644,8 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       case $host_os in
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
       esac
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
       ;;
@@ -6129,7 +5906,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -6154,17 +5931,29 @@
     fi
   done
 done
-])
 SED=$lt_cv_path_SED
+])
 AC_MSG_RESULT([$SED])
 ])
 
-# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#                                                        -*- Autoconf -*-
+# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
+# Generated from amversion.in; do not edit by hand.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
@@ -6176,16 +5965,27 @@
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.9.6])])
+	 [AM_AUTOMAKE_VERSION([1.9.2])])
 
-# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+# AM_AUX_DIR_EXPAND
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
@@ -6231,17 +6031,27 @@
 am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
-# AM_CONDITIONAL                                            -*- Autoconf -*-
+# AM_CONDITIONAL                                              -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
 
-# serial 7
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 6
+
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
@@ -6264,16 +6074,27 @@
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
+# serial 7						-*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
 # Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 8
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
 # will think it sees a *use*, and therefore will trigger all it's
@@ -6281,6 +6102,7 @@
 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 
 
+
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
@@ -6420,17 +6242,28 @@
 AC_SUBST([AMDEPBACKSLASH])
 ])
 
-# Generate code to set up dependency tracking.              -*- Autoconf -*-
+# Generate code to set up dependency tracking.   -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+#   Free Software Foundation, Inc.
 
-#serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@@ -6488,20 +6321,31 @@
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Do all the work for Automake.                             -*- Autoconf -*-
+# Do all the work for Automake.                            -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# This macro actually does too much some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 # Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
-# This macro actually does too much.  Some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 11
+
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
 # -----------------------------------------------
@@ -6602,28 +6446,52 @@
 done
 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
+
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 install_sh=${install_sh-"$am_aux_dir/install-sh"}
 AC_SUBST(install_sh)])
 
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#                                                          -*- Autoconf -*-
+# Copyright (C) 2003  Free Software Foundation, Inc.
 
-# serial 2
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
 # Check whether the underlying file-system supports filenames
 # with a leading dot.  For instance MS-DOS doesn't.
 AC_DEFUN([AM_SET_LEADING_DOT],
@@ -6637,16 +6505,27 @@
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
-# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+# Check to see how 'make' treats includes.	-*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
-# serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
 # AM_MAKE_INCLUDE()
 # -----------------
 # Check to see how make treats includes.
@@ -6689,17 +6568,28 @@
 rm -f confinc confmf
 ])
 
-# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+#  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
 AC_DEFUN([AM_MISSING_PROG],
@@ -6724,16 +6614,27 @@
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_MKDIR_P
 # ---------------
 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-#
+
+# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
 # created by `make install' are always world readable, even if the
 # installer happens to have an overly restrictive umask (e.g. 077).
@@ -6787,16 +6688,27 @@
 fi
 AC_SUBST([mkdir_p])])
 
-# Helper functions for option handling.                     -*- Autoconf -*-
+# Helper functions for option handling.                    -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
 
-# serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
 AC_DEFUN([_AM_MANGLE_OPTION],
@@ -6820,17 +6732,29 @@
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Check to make sure that the build environment is sane.
+#
 
-# serial 4
+# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
@@ -6872,14 +6796,25 @@
 fi
 AC_MSG_RESULT(yes)])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_INSTALL_STRIP
-# ---------------------
+
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # One issue with vendor `install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
@@ -6902,13 +6837,25 @@
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2004  Free Software Foundation, Inc.
 
-# serial 2
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
 
 # _AM_PROG_TAR(FORMAT)
 # --------------------

Modified: freeswitch/branches/voctel/build/buildlib.sh
==============================================================================
--- freeswitch/branches/voctel/build/buildlib.sh	(original)
+++ freeswitch/branches/voctel/build/buildlib.sh	Fri Sep 22 14:22:15 2006
@@ -67,7 +67,7 @@
     MAKE=$MAKE ../$uncompressed.build.sh $@
 else
     $MAKE clean 2>&1
-    sh ./configure $@
+    CFLAGS="$MOD_CFLAGS" ; export CFLAGS; sh ./configure $@
 
     if [ $? = 0 ] ; then
 	$MAKE

Modified: freeswitch/branches/voctel/build/checkversion.sh
==============================================================================
--- freeswitch/branches/voctel/build/checkversion.sh	(original)
+++ freeswitch/branches/voctel/build/checkversion.sh	Fri Sep 22 14:22:15 2006
@@ -1,9 +1,11 @@
 #!/bin/sh
 
-if [ ! -z $1 ] ; then
-    if [ $1 = force ] ; then
+if [ -f .noversion ] ; then
+    exit
+fi
+
+if eval test x${1} = xforce ; then
 	rm -f .version
-    fi
 fi
 
 force=0
@@ -16,6 +18,3 @@
     echo $version > .version
     make modclean
 fi
-
-
-

Modified: freeswitch/branches/voctel/build/modmake.sh
==============================================================================
--- freeswitch/branches/voctel/build/modmake.sh	(original)
+++ freeswitch/branches/voctel/build/modmake.sh	Fri Sep 22 14:22:15 2006
@@ -20,8 +20,8 @@
 fi
 
 if [ -f $mod/Makefile ] ; then
-    MODNAME=$end $make -C $mod $@
+    CFLAGS="$MOD_CFLAGS $CFLAGS " MODNAME=$end $make -C $mod $@
 else 
-    MODNAME=$end $make -f $pwd/generic_mod.mk -C $mod $@
+    CFLAGS="$MOD_CFLAGS $CFLAGS" MODNAME=$end $make -f $pwd/generic_mod.mk -C $mod $@
 fi
 

Modified: freeswitch/branches/voctel/configure
==============================================================================
--- freeswitch/branches/voctel/configure	(original)
+++ freeswitch/branches/voctel/configure	Fri Sep 22 14:22:15 2006
@@ -280,7 +280,7 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 if test -z "$ECHO"; then
 if test "X${echo_test_string+set}" != Xset; then
@@ -466,7 +466,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS ISLINUX_TRUE ISLINUX_FALSE ISMAC_TRUE ISMAC_FALSE IS64BITLINUX_TRUE IS64BITLINUX_FALSE LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBOBJS CRASHPROT_TRUE CRASHPROT_FALSE ISLINUX_TRUE ISLINUX_FALSE ISMAC_TRUE ISMAC_FALSE IS64BITLINUX_TRUE IS64BITLINUX_FALSE LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -1037,6 +1037,7 @@
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-crash-protection         Compile with CRASH Protection
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -3357,7 +3358,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -3382,10 +3383,10 @@
     fi
   done
 done
+SED=$lt_cv_path_SED
 
 fi
 
-SED=$lt_cv_path_SED
 echo "$as_me:$LINENO: result: $SED" >&5
 echo "${ECHO_T}$SED" >&6
 
@@ -3526,15 +3527,6 @@
 *) reload_flag=" $reload_flag" ;;
 esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
 
 echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
@@ -3621,7 +3613,7 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-bsdi[45]*)
+bsdi4*)
   lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
   lt_cv_file_magic_cmd='/usr/bin/file -L'
   lt_cv_file_magic_test_file=/shlib/libc.so
@@ -3644,13 +3636,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -3694,6 +3686,15 @@
 
 # This must be Linux ELF.
 linux*)
+  case $host_cpu in
+  alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -3716,10 +3717,12 @@
   ;;
 
 openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
   if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
   fi
   ;;
 
@@ -3812,7 +3815,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 3815 "configure"' > conftest.$ac_ext
+  echo '#line 3818 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -5061,12 +5064,7 @@
 fi
 
 
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  ac_ext=cc
+ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -5296,9 +5294,7 @@
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-fi
 
-
 ac_ext=f
 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -5391,7 +5387,7 @@
 
 
 # Provide some information about the compiler.
-echo "$as_me:5394:" \
+echo "$as_me:5390:" \
      "checking for Fortran 77 compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -5581,38 +5577,11 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  *)
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+    while (test "X"`$CONFIG_SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
 	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
 	    lt_cv_sys_max_cmd_len=$new_result &&
@@ -5658,6 +5627,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -5679,13 +5651,6 @@
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDGIRSTW]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
 irix* | nonstopux*)
   symcode='[BCDEGRST]'
   ;;
@@ -5717,11 +5682,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -5883,7 +5845,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
 
 # Same as above, but do not quote variable references.
@@ -6188,17 +6150,6 @@
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
 file_magic*)
@@ -6385,20 +6336,6 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 #
 # Check for any special shared library compilation flags.
 #
@@ -6440,11 +6377,6 @@
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
-       fi
      else
        lt_prog_compiler_static_works=yes
      fi
@@ -6489,17 +6421,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6492: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6424: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6496: \$? = $ac_status" >&5
+   echo "$as_me:6428: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -6602,16 +6532,6 @@
 	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic='-qnocommon'
-         lt_prog_compiler_wl='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -6647,19 +6567,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
 	lt_prog_compiler_static='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-static'
-        ;;
       ccc*)
         lt_prog_compiler_wl='-Wl,'
         # All Alpha code is PIC.
@@ -6680,14 +6593,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_pic='-KPIC'
       lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -6709,11 +6617,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic='-pic'
       lt_prog_compiler_static='-Bstatic'
@@ -6751,17 +6654,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6754: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6657: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6758: \$? = $ac_status" >&5
+   echo "$as_me:6661: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works=yes
      fi
    fi
@@ -6813,18 +6714,16 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6816: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6717: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:6820: \$? = $ac_status" >&5
+   echo "$as_me:6721: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o=yes
      fi
    fi
@@ -6904,16 +6803,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -6934,27 +6823,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -7005,7 +6873,7 @@
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -7023,37 +6891,6 @@
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -7092,6 +6929,31 @@
       hardcode_shlibpath_var=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -7102,11 +6964,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
+    if test "$ld_shlibs" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -7170,7 +7037,7 @@
       link_all_deplibs=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -7191,9 +7058,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -7354,7 +7218,7 @@
       ld_shlibs=no
       ;;
 
-    bsdi[45]*)
+    bsdi4*)
       export_dynamic_flag_spec=-rdynamic
       ;;
 
@@ -7380,52 +7244,52 @@
       ;;
 
     darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
+      archive_cmds_need_lc=no
       case "$host_os" in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
       esac
-      archive_cmds_need_lc=no
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       hardcode_direct=no
       hardcode_automatic=yes
       hardcode_shlibpath_var=unsupported
-      whole_archive_flag_spec=''
+      whole_archive_flag_spec='-all_load $convenience'
       link_all_deplibs=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs=no
-          ;;
-      esac
+      ld_shlibs=no
     fi
       ;;
 
@@ -7459,7 +7323,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -7570,7 +7434,6 @@
       hardcode_shlibpath_var=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec='${wl}-E'
       else
@@ -7616,7 +7479,7 @@
 	allow_undefined_flag=' -expect_unresolved \*'
 	archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -7635,12 +7498,10 @@
     solaris*)
       no_undefined_flag=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -7649,18 +7510,8 @@
       hardcode_shlibpath_var=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs=yes
       ;;
@@ -7934,7 +7785,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -7992,7 +7843,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -8050,9 +7901,7 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
+freebsd*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -8071,7 +7920,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -8195,10 +8044,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 8051 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -8260,11 +8130,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -8386,8 +8252,8 @@
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" || \
-   test -n "$runpath_var" || \
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test -n "$runpath_var " || \
+   test "X$hardcode_automatic"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct" != no &&
@@ -9053,7 +8919,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9056 "configure"
+#line 8922 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9151,7 +9017,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9154 "configure"
+#line 9020 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9280,6 +9146,43 @@
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
+  ;;
+  darwin* | rhapsody*)
+  if test "$GCC" = yes; then
+    archive_cmds_need_lc=no
+    case "$host_os" in
+    rhapsody* | darwin1.[012])
+      allow_undefined_flag='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+      ;;
+    esac
+    output_verbose_link_cmd='echo'
+    archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+    module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag  -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    hardcode_direct=no
+    hardcode_automatic=yes
+    hardcode_shlibpath_var=unsupported
+    whole_archive_flag_spec='-all_load $convenience'
+    link_all_deplibs=yes
+  else
+    ld_shlibs=no
+  fi
     ;;
 esac
 echo "$as_me:$LINENO: result: $enable_shared" >&5
@@ -9409,7 +9312,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -9420,11 +9323,11 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 # The names of the tagged configurations supported by this script.
 available_tags=
@@ -9454,13 +9357,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -9536,7 +9433,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -9831,9 +9728,7 @@
 
       case $tagname in
       CXX)
-	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-	    (test "X$CXX" != "Xg++"))) ; then
+	if test -n "$CXX" && test "X$CXX" != "Xno"; then
 	  ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -9891,20 +9786,6 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -9926,17 +9807,8 @@
 CC=${CXX-"c++"}
 compiler=$CC
 compiler_CXX=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
 if test "$GXX" = yes; then
@@ -10149,7 +10021,7 @@
     link_all_deplibs_CXX=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[012]|aix4.[012].*)
+      case $host_os in aix4.012|aix4.012.*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -10170,9 +10042,6 @@
 	fi
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -10334,7 +10203,6 @@
     esac
     ;;
 
-
   cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
     # as there is no search path for DLLs.
@@ -10358,76 +10226,65 @@
       ld_shlibs_CXX=no
     fi
   ;;
-      darwin* | rhapsody*)
-        case "$host_os" in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      archive_cmds_need_lc_CXX=no
-      hardcode_direct_CXX=no
-      hardcode_automatic_CXX=yes
-      hardcode_shlibpath_var_CXX=unsupported
-      whole_archive_flag_spec_CXX=''
-      link_all_deplibs_CXX=yes
 
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+  darwin* | rhapsody*)
+  if test "$GXX" = yes; then
+    archive_cmds_need_lc_CXX=no
+    case "$host_os" in
+    rhapsody* | darwin1.[012])
+      allow_undefined_flag_CXX='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
       else
-          archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_CXX=no
-          ;;
-      esac
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_CXX='-undefined dynamic_lookup'
+            ;;
+        esac
       fi
-        ;;
+      ;;
+    esac
+    lt_int_apple_cc_single_mod=no
+    output_verbose_link_cmd='echo'
+    if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+      lt_int_apple_cc_single_mod=yes
+    fi
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    else
+      archive_cmds_CXX='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    fi
+    module_cmds_CXX='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
 
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    hardcode_direct_CXX=no
+    hardcode_automatic_CXX=yes
+    hardcode_shlibpath_var_CXX=unsupported
+    whole_archive_flag_spec_CXX='-all_load $convenience'
+    link_all_deplibs_CXX=yes
+  else
+    ld_shlibs_CXX=no
+  fi
+    ;;
+
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -10438,14 +10295,14 @@
 	;;
     esac
     ;;
-  freebsd[12]*)
+  freebsd12*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     ld_shlibs_CXX=no
     ;;
   freebsd-elf*)
     archive_cmds_need_lc_CXX=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     ld_shlibs_CXX=yes
@@ -10462,11 +10319,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       ld_shlibs_CXX=no
       ;;
-    aCC*)
+    aCC)
       archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -10476,7 +10333,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -10527,11 +10384,11 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      aCC*)
+      aCC)
 	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
@@ -10571,9 +10428,9 @@
     ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -10584,7 +10441,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -10597,7 +10454,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10622,41 +10479,17 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
-	# version 8.0 and above of icpc choke on multiply defined symbols
-	# if we add $predep_objects and $postdep_objects, however 7.1 and
-	# earlier do not add the objects themselves.
-	case `$CC -V 2>&1` in
-	*"Version 7."*)
-  	  archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-  	  archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	esac
 	archive_cmds_need_lc_CXX=no
+	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -10687,7 +10520,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
@@ -10708,25 +10541,9 @@
     # Workaround some broken pre-1.5 toolchains
     output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
     ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    ld_shlibs_CXX=no
-    ;;
-  openbsd*)
-    hardcode_direct_CXX=yes
-    hardcode_shlibpath_var_CXX=no
-    archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      export_dynamic_flag_spec_CXX='${wl}-E'
-      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10742,14 +10559,14 @@
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	hardcode_libdir_separator_CXX=:
@@ -10767,7 +10584,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -10786,7 +10603,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10801,17 +10618,17 @@
 	# the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' -expect_unresolved \*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -10830,7 +10647,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -10854,7 +10671,7 @@
   sco*)
     archive_cmds_need_lc_CXX=no
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
@@ -10866,12 +10683,12 @@
     ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -10884,7 +10701,7 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
 	no_undefined_flag_CXX=' -zdefs'
 	archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -10894,17 +10711,13 @@
 	hardcode_libdir_flag_spec_CXX='-R$libdir'
 	hardcode_shlibpath_var_CXX=no
 	case $host_os in
-	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  solaris2.0-5 | solaris2.0-5.*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	link_all_deplibs_CXX=yes
@@ -10925,7 +10738,7 @@
 	# in the archive.
 	old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -10968,7 +10781,7 @@
     ;;
   tandem*)
     case $cc_basename in
-      NCC*)
+      NCC)
 	# NonStop-UX NCC 3.20
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -11177,28 +10990,18 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
 	esac
 	;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           lt_prog_compiler_pic_CXX='-qnocommon'
-           lt_prog_compiler_wl_CXX='-Wl,'
-           ;;
-         esac
-       ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -11206,19 +11009,19 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    case "$host_cpu" in
@@ -11236,7 +11039,7 @@
 	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -11247,24 +11050,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-static'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -11281,7 +11078,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    lt_prog_compiler_pic_CXX='-W c,exportall'
 	    ;;
 	  *)
@@ -11292,14 +11089,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -11315,7 +11112,7 @@
 	;;
       sco*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  *)
@@ -11324,13 +11121,13 @@
 	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    lt_prog_compiler_wl_CXX='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-PIC'
 	    ;;
@@ -11340,12 +11137,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    lt_prog_compiler_pic_CXX='-pic'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -11355,7 +11152,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
@@ -11399,17 +11196,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11402: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11199: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11406: \$? = $ac_status" >&5
+   echo "$as_me:11203: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_CXX=yes
      fi
    fi
@@ -11461,18 +11256,16 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11464: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11259: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11468: \$? = $ac_status" >&5
+   echo "$as_me:11263: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_CXX=yes
      fi
    fi
@@ -11531,7 +11324,7 @@
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -11711,7 +11504,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -11769,7 +11562,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -11827,9 +11620,7 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
+freebsd*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -11848,7 +11639,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -11972,10 +11763,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 11770 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -12037,11 +11849,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -12163,8 +11971,8 @@
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" || \
-   test -n "$runpath_var_CXX" || \
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test -n "$runpath_var CXX" || \
+   test "X$hardcode_automatic_CXX"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct_CXX" != no &&
@@ -12830,7 +12638,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12833 "configure"
+#line 12641 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12928,7 +12736,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12931 "configure"
+#line 12739 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13146,13 +12954,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -13228,7 +13030,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -13509,36 +13311,13 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${F77-"f77"}
 compiler=$CC
 compiler_F77=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-
 echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
 echo "$as_me:$LINENO: result: $can_build_shared" >&5
@@ -13559,9 +13338,7 @@
   fi
   ;;
 aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
+  test "$enable_shared" = yes && enable_static=no
   ;;
 esac
 echo "$as_me:$LINENO: result: $enable_shared" >&5
@@ -13664,16 +13441,6 @@
 	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_F77='-qnocommon'
-         lt_prog_compiler_wl_F77='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -13709,19 +13476,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl_F77='-Wl,'
 	lt_prog_compiler_pic_F77='-KPIC'
 	lt_prog_compiler_static_F77='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-static'
-        ;;
       ccc*)
         lt_prog_compiler_wl_F77='-Wl,'
         # All Alpha code is PIC.
@@ -13742,14 +13502,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl_F77='-Wl,'
       lt_prog_compiler_pic_F77='-KPIC'
       lt_prog_compiler_static_F77='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_F77='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_F77='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -13771,11 +13526,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic_F77='-pic'
       lt_prog_compiler_static_F77='-Bstatic'
@@ -13813,17 +13563,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13816: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13566: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13820: \$? = $ac_status" >&5
+   echo "$as_me:13570: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_F77=yes
      fi
    fi
@@ -13875,18 +13623,16 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13878: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13626: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13882: \$? = $ac_status" >&5
+   echo "$as_me:13630: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_F77=yes
      fi
    fi
@@ -13966,16 +13712,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -13996,27 +13732,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_F77=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -14067,7 +13782,7 @@
       allow_undefined_flag_F77=unsupported
       always_export_symbols_F77=no
       enable_shared_with_static_runtimes_F77=yes
-      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -14081,41 +13796,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	ld_shlibs_F77=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -14154,6 +13838,31 @@
       hardcode_shlibpath_var_F77=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_F77="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds_F77="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs_F77=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -14164,11 +13873,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs_F77" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_F77=
-      export_dynamic_flag_spec_F77=
-      whole_archive_flag_spec_F77=
+    if test "$ld_shlibs_F77" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_F77=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -14232,7 +13946,7 @@
       link_all_deplibs_F77=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -14253,9 +13967,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -14396,7 +14107,7 @@
       ld_shlibs_F77=no
       ;;
 
-    bsdi[45]*)
+    bsdi4*)
       export_dynamic_flag_spec_F77=-rdynamic
       ;;
 
@@ -14417,57 +14128,57 @@
       old_archive_From_new_cmds_F77='true'
       # FIXME: Should let the user specify the lib program.
       old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       enable_shared_with_static_runtimes_F77=yes
       ;;
 
     darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
+      archive_cmds_need_lc_F77=no
       case "$host_os" in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag_F77='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_F77='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
       esac
-      archive_cmds_need_lc_F77=no
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds_F77='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds_F77='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds_F77='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       hardcode_direct_F77=no
       hardcode_automatic_F77=yes
       hardcode_shlibpath_var_F77=unsupported
-      whole_archive_flag_spec_F77=''
+      whole_archive_flag_spec_F77='-all_load $convenience'
       link_all_deplibs_F77=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-      archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-         archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_F77=no
-          ;;
-      esac
+      ld_shlibs_F77=no
     fi
       ;;
 
@@ -14501,7 +14212,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_F77='-R$libdir'
       hardcode_direct_F77=yes
@@ -14612,7 +14323,6 @@
       hardcode_shlibpath_var_F77=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec_F77='${wl}-E'
       else
@@ -14658,7 +14368,7 @@
 	allow_undefined_flag_F77=' -expect_unresolved \*'
 	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec_F77='-rpath $libdir'
@@ -14677,12 +14387,10 @@
     solaris*)
       no_undefined_flag_F77=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -14691,18 +14399,8 @@
       hardcode_shlibpath_var_F77=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs_F77=yes
       ;;
@@ -14976,7 +14674,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -15034,7 +14732,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -15092,9 +14790,7 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
+freebsd*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -15113,7 +14809,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -15237,10 +14933,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 14940 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -15302,11 +15019,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -15428,8 +15141,8 @@
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action_F77=
 if test -n "$hardcode_libdir_flag_spec_F77" || \
-   test -n "$runpath_var_F77" || \
-   test "X$hardcode_automatic_F77" = "Xyes" ; then
+   test -n "$runpath_var F77" || \
+   test "X$hardcode_automatic_F77"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct_F77" != no &&
@@ -15606,13 +15319,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -15688,7 +15395,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -15926,7 +15633,7 @@
 lt_simple_compile_test_code="class foo {}\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
@@ -15937,42 +15644,16 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
 compiler=$CC
 compiler_GCJ=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
-
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
 archive_cmds_need_lc_GCJ=no
 
-old_archive_cmds_GCJ=$old_archive_cmds
 
-
 lt_prog_compiler_no_builtin_flag_GCJ=
 
 if test "$GCC" = yes; then
@@ -15997,17 +15678,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16000: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15681: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16004: \$? = $ac_status" >&5
+   echo "$as_me:15685: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -16110,16 +15789,6 @@
 	lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_GCJ='-qnocommon'
-         lt_prog_compiler_wl_GCJ='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -16155,19 +15824,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl_GCJ='-Wl,'
 	lt_prog_compiler_pic_GCJ='-KPIC'
 	lt_prog_compiler_static_GCJ='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-fpic'
-	lt_prog_compiler_static_GCJ='-static'
-        ;;
       ccc*)
         lt_prog_compiler_wl_GCJ='-Wl,'
         # All Alpha code is PIC.
@@ -16188,14 +15850,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
       lt_prog_compiler_pic_GCJ='-KPIC'
       lt_prog_compiler_static_GCJ='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_GCJ='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_GCJ='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -16217,11 +15874,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic_GCJ='-pic'
       lt_prog_compiler_static_GCJ='-Bstatic'
@@ -16259,17 +15911,15 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16262: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15914: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16266: \$? = $ac_status" >&5
+   echo "$as_me:15918: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_GCJ=yes
      fi
    fi
@@ -16321,18 +15971,16 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16324: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15974: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16328: \$? = $ac_status" >&5
+   echo "$as_me:15978: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_GCJ=yes
      fi
    fi
@@ -16412,16 +16060,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -16442,27 +16080,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_GCJ=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -16513,7 +16130,7 @@
       allow_undefined_flag_GCJ=unsupported
       always_export_symbols_GCJ=no
       enable_shared_with_static_runtimes_GCJ=yes
-      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -16527,41 +16144,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	ld_shlibs_GCJ=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -16600,6 +16186,31 @@
       hardcode_shlibpath_var_GCJ=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_GCJ="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds_GCJ="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs_GCJ=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -16610,11 +16221,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs_GCJ" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_GCJ=
-      export_dynamic_flag_spec_GCJ=
-      whole_archive_flag_spec_GCJ=
+    if test "$ld_shlibs_GCJ" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_GCJ=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -16678,7 +16294,7 @@
       link_all_deplibs_GCJ=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -16699,9 +16315,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -16862,7 +16475,7 @@
       ld_shlibs_GCJ=no
       ;;
 
-    bsdi[45]*)
+    bsdi4*)
       export_dynamic_flag_spec_GCJ=-rdynamic
       ;;
 
@@ -16883,57 +16496,57 @@
       old_archive_From_new_cmds_GCJ='true'
       # FIXME: Should let the user specify the lib program.
       old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       enable_shared_with_static_runtimes_GCJ=yes
       ;;
 
     darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
+      archive_cmds_need_lc_GCJ=no
       case "$host_os" in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag_GCJ='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_GCJ='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
       esac
-      archive_cmds_need_lc_GCJ=no
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds_GCJ='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds_GCJ='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds_GCJ='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       hardcode_direct_GCJ=no
       hardcode_automatic_GCJ=yes
       hardcode_shlibpath_var_GCJ=unsupported
-      whole_archive_flag_spec_GCJ=''
+      whole_archive_flag_spec_GCJ='-all_load $convenience'
       link_all_deplibs_GCJ=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
-         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_GCJ=no
-          ;;
-      esac
+      ld_shlibs_GCJ=no
     fi
       ;;
 
@@ -16967,7 +16580,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_GCJ='-R$libdir'
       hardcode_direct_GCJ=yes
@@ -17078,7 +16691,6 @@
       hardcode_shlibpath_var_GCJ=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec_GCJ='${wl}-E'
       else
@@ -17124,7 +16736,7 @@
 	allow_undefined_flag_GCJ=' -expect_unresolved \*'
 	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
@@ -17143,12 +16755,10 @@
     solaris*)
       no_undefined_flag_GCJ=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -17157,18 +16767,8 @@
       hardcode_shlibpath_var_GCJ=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs_GCJ=yes
       ;;
@@ -17442,7 +17042,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -17500,7 +17100,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -17558,9 +17158,7 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
+freebsd*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -17579,7 +17177,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -17703,10 +17301,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 17308 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -17768,11 +17387,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -17894,8 +17509,8 @@
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action_GCJ=
 if test -n "$hardcode_libdir_flag_spec_GCJ" || \
-   test -n "$runpath_var_GCJ" || \
-   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
+   test -n "$runpath_var GCJ" || \
+   test "X$hardcode_automatic_GCJ"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct_GCJ" != no &&
@@ -18561,7 +18176,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18564 "configure"
+#line 18179 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18659,7 +18274,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18662 "configure"
+#line 18277 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18877,13 +18492,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -18959,7 +18568,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -19207,35 +18816,11 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 compiler_RC=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
 lt_cv_prog_compiler_c_o_RC=yes
 
 # The else clause should only fire when bootstrapping the
@@ -19352,13 +18937,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -19434,7 +19013,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -21261,7 +20840,11 @@
 
 
 
-for ac_func in gethostname vasprintf
+
+
+
+
+for ac_func in gethostname vasprintf mmap mlock mlockall usleep
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -21608,8 +21191,25 @@
 _ACEOF
 
 
+# Check whether --enable-crash-protection or --disable-crash-protection was given.
+if test "${enable_crash_protection+set}" = set; then
+  enableval="$enable_crash_protection"
 
+else
+  enable_crash_prot="no"
+fi;
 
+
+
+if test "x$enable_crash_prot" != "xno"; then
+  CRASHPROT_TRUE=
+  CRASHPROT_FALSE='#'
+else
+  CRASHPROT_TRUE='#'
+  CRASHPROT_FALSE=
+fi
+
+
           ac_config_files="$ac_config_files Makefile"
 
 
@@ -21761,6 +21361,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${CRASHPROT_TRUE}" && test -z "${CRASHPROT_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CRASHPROT\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CRASHPROT\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${ISLINUX_TRUE}" && test -z "${ISLINUX_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"ISLINUX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -22381,6 +21988,8 @@
 s, at ac_ct_F77@,$ac_ct_F77,;t t
 s, at LIBTOOL@,$LIBTOOL,;t t
 s, at LIBOBJS@,$LIBOBJS,;t t
+s, at CRASHPROT_TRUE@,$CRASHPROT_TRUE,;t t
+s, at CRASHPROT_FALSE@,$CRASHPROT_FALSE,;t t
 s, at ISLINUX_TRUE@,$ISLINUX_TRUE,;t t
 s, at ISLINUX_FALSE@,$ISLINUX_FALSE,;t t
 s, at ISMAC_TRUE@,$ISMAC_TRUE,;t t

Modified: freeswitch/branches/voctel/configure.in
==============================================================================
--- freeswitch/branches/voctel/configure.in	(original)
+++ freeswitch/branches/voctel/configure.in	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,7 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.59)
+
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 AC_CONFIG_AUX_DIR(build/config)
 AM_INIT_AUTOMAKE(libfreeswitch,0.1)
@@ -34,13 +34,16 @@
 AC_FUNC_MALLOC
 AC_TYPE_SIGNAL
 AC_FUNC_STRFTIME
-AC_CHECK_FUNCS([gethostname vasprintf])
+AC_CHECK_FUNCS([gethostname vasprintf mmap mlock mlockall usleep])
 
 AC_C_BIGENDIAN(AC_DEFINE([__BYTE_ORDER],__BIG_ENDIAN,[Big Endian]),AC_DEFINE([__BYTE_ORDER],__LITTLE_ENDIAN,[Little Endian]))
 AC_DEFINE([__LITTLE_ENDIAN],1234,[for the places where it is not defined])
 AC_DEFINE([__BIG_ENDIAN],4321,[for the places where it is not defined])
 
+AC_ARG_ENABLE(crash-protection,     
+	[  --enable-crash-protection         Compile with CRASH Protection],,[enable_crash_prot="no"])
 
+AM_CONDITIONAL([CRASHPROT],[test "x$enable_crash_prot" != "xno"])
 
 AC_CONFIG_FILES([Makefile])
 

Modified: freeswitch/branches/voctel/docs/Doxygen.conf
==============================================================================
--- freeswitch/branches/voctel/docs/Doxygen.conf	(original)
+++ freeswitch/branches/voctel/docs/Doxygen.conf	Fri Sep 22 14:22:15 2006
@@ -186,14 +186,14 @@
 #---------------------------------------------------------------------------
 # configuration options related to the man page output
 #---------------------------------------------------------------------------
-GENERATE_MAN           = YES
+GENERATE_MAN           = NO
 MAN_OUTPUT             = man
 MAN_EXTENSION          = .3
 MAN_LINKS              = NO
 #---------------------------------------------------------------------------
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
-GENERATE_XML           = YES
+GENERATE_XML           = NO
 XML_OUTPUT             = xml
 XML_SCHEMA             = 
 XML_DTD                = 
@@ -205,7 +205,7 @@
 #---------------------------------------------------------------------------
 # configuration options related to the Perl module output
 #---------------------------------------------------------------------------
-GENERATE_PERLMOD       = YES
+GENERATE_PERLMOD       = NO
 PERLMOD_LATEX          = NO
 PERLMOD_PRETTY         = YES
 PERLMOD_MAKEVAR_PREFIX = 

Modified: freeswitch/branches/voctel/libs/codec/g726/Makefile.am
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/Makefile.am	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/Makefile.am	Fri Sep 22 14:22:15 2006
@@ -13,13 +13,14 @@
 src/g726_24.c  \
 src/g726_32.c  \
 src/g726_40.c  \
-src/g72x.c
+src/g72x.c \
+src/g711.c
 
 libg726_la_CFLAGS	= $(AM_CFLAGS)
 libg726_la_LDFLAGS	= 
 
 library_includedir	= $(prefix)/include
-library_include_HEADERS =  src/g72x.h src/private.h
+library_include_HEADERS =  src/g72x.h src/private.h src/g711.h
 
 
 

Modified: freeswitch/branches/voctel/libs/codec/g726/Makefile.in
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/Makefile.in	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/Makefile.in	Fri Sep 22 14:22:15 2006
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,6 +15,8 @@
 @SET_MAKE@
 
 
+SOURCES = $(libg726_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -63,7 +65,8 @@
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libg726_la_LIBADD =
 am_libg726_la_OBJECTS = libg726_la-g726_16.lo libg726_la-g726_24.lo \
-	libg726_la-g726_32.lo libg726_la-g726_40.lo libg726_la-g72x.lo
+	libg726_la-g726_32.lo libg726_la-g726_40.lo libg726_la-g72x.lo \
+	libg726_la-g711.lo
 libg726_la_OBJECTS = $(am_libg726_la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -209,12 +212,13 @@
 src/g726_24.c  \
 src/g726_32.c  \
 src/g726_40.c  \
-src/g72x.c
+src/g72x.c \
+src/g711.c
 
 libg726_la_CFLAGS = $(AM_CFLAGS)
 libg726_la_LDFLAGS = 
 library_includedir = $(prefix)/include
-library_include_HEADERS = src/g72x.h src/private.h
+library_include_HEADERS = src/g72x.h src/private.h src/g711.h
 all: all-recursive
 
 .SUFFIXES:
@@ -288,6 +292,7 @@
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libg726_la-g711.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libg726_la-g726_16.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libg726_la-g726_24.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libg726_la-g726_32.Plo at am__quote@
@@ -350,6 +355,13 @@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libg726_la_CFLAGS) $(CFLAGS) -c -o libg726_la-g72x.lo `test -f 'src/g72x.c' || echo '$(srcdir)/'`src/g72x.c
 
+libg726_la-g711.lo: src/g711.c
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libg726_la_CFLAGS) $(CFLAGS) -MT libg726_la-g711.lo -MD -MP -MF "$(DEPDIR)/libg726_la-g711.Tpo" -c -o libg726_la-g711.lo `test -f 'src/g711.c' || echo '$(srcdir)/'`src/g711.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libg726_la-g711.Tpo" "$(DEPDIR)/libg726_la-g711.Plo"; else rm -f "$(DEPDIR)/libg726_la-g711.Tpo"; exit 1; fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='src/g711.c' object='libg726_la-g711.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libg726_la_CFLAGS) $(CFLAGS) -c -o libg726_la-g711.lo `test -f 'src/g711.c' || echo '$(srcdir)/'`src/g711.c
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -384,13 +396,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -402,7 +408,7 @@
 	    local_target="$$target"; \
 	  fi; \
 	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
@@ -410,13 +416,7 @@
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	case "$@" in \
 	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
@@ -437,7 +437,7 @@
 	    local_target="$$target"; \
 	  fi; \
 	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \

Modified: freeswitch/branches/voctel/libs/codec/g726/aclocal.m4
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/aclocal.m4	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/aclocal.m4	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.3 -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005  Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -123,7 +123,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 [sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
 
 # Same as above, but do not quote variable references.
@@ -143,7 +143,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a `.a' archive for static linking (except M$VC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -191,7 +191,7 @@
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
@@ -238,48 +238,6 @@
 ])# _LT_AC_SYS_COMPILER
 
 
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
 # Links a minimal program and checks the executable
@@ -359,8 +317,8 @@
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -529,7 +487,7 @@
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
+    case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -611,7 +569,7 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -621,10 +579,8 @@
    echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        $2=yes
      fi
    fi
@@ -650,16 +606,11 @@
    LDFLAGS="$LDFLAGS $3"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
+     # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
      else
        $2=yes
      fi
@@ -718,33 +669,20 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  netbsd* | freebsd* | openbsd* | darwin* )
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     ;;
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  *)
+
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
@@ -854,7 +792,7 @@
 }]
 EOF
   if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) $1 ;;
@@ -1003,7 +941,7 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -1015,13 +953,11 @@
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
-   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -1281,8 +1217,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -1312,7 +1247,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -1335,7 +1270,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -1370,17 +1305,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[[123]]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -1398,7 +1324,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+  freebsd3.[01]* | freebsdelf3.[01]*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -1425,7 +1351,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -1524,7 +1450,7 @@
 
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
@@ -1587,11 +1513,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -1758,7 +1680,7 @@
       case $tagname in
       CXX)
 	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || 
 	    (test "X$CXX" != "Xg++"))) ; then
 	  AC_LIBTOOL_LANG_CXX_CONFIG
 	else
@@ -1821,7 +1743,7 @@
 
 # AC_LIBTOOL_WIN32_DLL
 # --------------------
-# declare package support for building win32 DLLs
+# declare package support for building win32 dll's
 AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
 [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
 ])# AC_LIBTOOL_WIN32_DLL
@@ -1995,7 +1917,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -2105,7 +2027,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -2137,7 +2059,7 @@
 AC_DEFUN([AC_PROG_LD_GNU],
 [AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -2229,13 +2151,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -2251,7 +2173,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -2425,13 +2347,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl convenience library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!).  If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
+# --enable-ltdl-convenience to the configure arguments.  Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
+# DIRECTORY is not provided, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
   case $enable_ltdl_convenience in
@@ -2450,13 +2372,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl installable library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!).  If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
+# --enable-ltdl-install to the configure arguments.  Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
+# DIRECTORY is not provided and an installed libltdl is not found, it is
+# assumed to be `libltdl'.  LIBLTDL will be prefixed with '${top_builddir}/'
+# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
+# quotes!).  If your package is not flat and you're not using automake,
+# define top_builddir and top_srcdir appropriately in the Makefiles.
 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
 AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
@@ -2504,7 +2426,7 @@
 [
 AC_REQUIRE([AC_PROG_CXX])
 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || 
     (test "X$CXX" != "Xg++"))) ; then
   AC_PROG_CXXCPP
 fi
@@ -2581,10 +2503,6 @@
 
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 #
 # Check for any special shared library compilation flags.
 #
@@ -2635,7 +2553,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -2702,7 +2620,7 @@
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
 
 # Source file extension for C++ test sources.
-ac_ext=cpp
+ac_ext=cc
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -2717,10 +2635,6 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -2742,7 +2656,7 @@
 CC=${CXX-"c++"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
@@ -2849,7 +2763,7 @@
     _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      case $host_os in aix4.[012]|aix4.[012].*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -2870,9 +2784,6 @@
 	fi
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -2918,7 +2829,7 @@
 	# Exported symbols can be pulled into shared objects from archives
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	# This is similar to how AIX traditionally builds its shared libraries.
+	# This is similar to how AIX traditionally builds it's shared libraries.
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
@@ -2957,7 +2868,7 @@
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
+        case "$host_os" in
         rhapsody* | darwin1.[[012]])
          _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
          ;;
@@ -2995,7 +2906,7 @@
           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
         fi
         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
           if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
             _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           else
@@ -3003,12 +2914,12 @@
           fi
             _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
           _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -3021,11 +2932,11 @@
 
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3036,14 +2947,14 @@
 	;;
     esac
     ;;
-  freebsd[[12]]*)
+  freebsd[12]*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
   freebsd-elf*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     _LT_AC_TAGVAR(ld_shlibs, $1)=yes
@@ -3060,11 +2971,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
       ;;
-    aCC*)
+    aCC)
       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -3074,7 +2985,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -3088,7 +2999,7 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*)
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
@@ -3104,7 +3015,7 @@
         ;;
       esac
     fi
-    case $host_cpu in
+    case "$host_cpu" in
     hppa*64*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -3125,12 +3036,12 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      aCC*)
-	case $host_cpu in
+      aCC)
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
@@ -3151,7 +3062,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case $host_cpu in
+	    case "$host_cpu" in
 	    ia64*|hppa*64*)
 	      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
@@ -3169,9 +3080,9 @@
     ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -3182,7 +3093,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -3195,7 +3106,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3220,7 +3131,7 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
 	# version 8.0 and above of icpc choke on multiply defined symbols
@@ -3232,12 +3143,8 @@
   	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	  ;;
 	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	  ;;
 	esac
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
@@ -3245,16 +3152,7 @@
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -3285,7 +3183,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
@@ -3324,7 +3222,7 @@
     ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3340,14 +3238,14 @@
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3365,7 +3263,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3384,7 +3282,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3399,17 +3297,17 @@
 	# the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -3428,7 +3326,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3452,7 +3350,7 @@
   sco*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
@@ -3464,12 +3362,12 @@
     ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3482,33 +3380,36 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
-        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	case $host_os in
-	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
-	output_verbose_link_cmd='echo'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -3516,7 +3417,7 @@
 	# in the archive.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -3559,7 +3460,7 @@
     ;;
   tandem*)
     case $cc_basename in
-      NCC*)
+      NCC)
 	# NonStop-UX NCC 3.20
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3665,7 +3566,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -3741,21 +3642,6 @@
 
 $rm -f confest.$objext
 
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
-    ;;
-  esac
-esac
-])
-
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
@@ -3806,16 +3692,12 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${F77-"f77"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
@@ -3825,7 +3707,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -3834,9 +3716,7 @@
   fi
   ;;
 aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
+  test "$enable_shared" = yes && enable_static=no
   ;;
 esac
 AC_MSG_RESULT([$enable_shared])
@@ -3887,27 +3767,20 @@
 lt_simple_compile_test_code="class foo {}\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
 _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
 
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
 AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
 AC_LIBTOOL_PROG_COMPILER_PIC($1)
 AC_LIBTOOL_PROG_CC_C_O($1)
@@ -3950,16 +3823,11 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
 
 AC_LIBTOOL_CONFIG($1)
@@ -4095,7 +3963,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -4106,7 +3974,7 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
@@ -4141,13 +4009,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -4223,7 +4085,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -4497,6 +4359,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -4556,11 +4421,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -4724,7 +4586,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	;;
       *)
@@ -4749,7 +4611,7 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
@@ -4758,7 +4620,7 @@
        darwin*)
          # PIC is the default on this platform
          # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
+         case "$cc_basename" in
            xlc*)
            _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
            _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
@@ -4767,10 +4629,10 @@
        ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -4778,22 +4640,22 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
-	    case $host_cpu in
+	    case "$host_cpu" in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -4808,7 +4670,7 @@
 	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -4819,24 +4681,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -4853,7 +4709,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
 	    ;;
 	  *)
@@ -4864,14 +4720,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -4887,7 +4743,7 @@
 	;;
       sco*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  *)
@@ -4896,13 +4752,13 @@
 	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	    ;;
@@ -4912,12 +4768,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -4927,7 +4783,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
@@ -4998,7 +4854,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5027,7 +4883,7 @@
       darwin*)
         # PIC is the default on this platform
         # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
+       case "$cc_basename" in
          xlc*)
          _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
          _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
@@ -5045,7 +4901,7 @@
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5069,19 +4925,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-        ;;
       ccc*)
         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         # All Alpha code is PIC.
@@ -5102,14 +4951,9 @@
       ;;
 
     solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
-      *)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -5131,11 +4975,6 @@
       fi
       ;;
 
-    unicos*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-
     uts4*)
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -5163,7 +5002,7 @@
     [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
@@ -5196,7 +5035,7 @@
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -5239,8 +5078,7 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  _LT_CC_BASENAME([$compiler])
+
   case $host_os in
   cygwin* | mingw* | pw32*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
@@ -5260,27 +5098,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -5331,7 +5148,7 @@
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -5345,41 +5162,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -5418,6 +5204,31 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds"
+      fi
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -5428,11 +5239,16 @@
       ;;
     esac
 
-    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
-      runpath_var=
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then
+      runpath_var=LD_RUN_PATH
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -5496,7 +5312,7 @@
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -5517,9 +5333,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -5564,7 +5377,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
+	  # This is similar to how AIX traditionally builds it's shared libraries.
 	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -5599,12 +5412,12 @@
       _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
       _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
+      case "$host_os" in
         rhapsody* | darwin1.[[012]])
          _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
          ;;
@@ -5633,16 +5446,16 @@
     	output_verbose_link_cmd='echo'
         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -5683,7 +5496,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -5708,7 +5521,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -5717,7 +5530,7 @@
 	  ;;
 	esac
       else
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -5727,7 +5540,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*)
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
@@ -5840,7 +5653,7 @@
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5859,12 +5672,10 @@
     solaris*)
       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -5873,18 +5684,8 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       case $host_os in
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
       esac
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
       ;;
@@ -6145,7 +5946,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -6175,12 +5976,24 @@
 AC_MSG_RESULT([$SED])
 ])
 
-# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#                                                        -*- Autoconf -*-
+# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
+# Generated from amversion.in; do not edit by hand.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
@@ -6192,16 +6005,27 @@
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.9.6])])
+	 [AM_AUTOMAKE_VERSION([1.9.3])])
 
-# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+# AM_AUX_DIR_EXPAND
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
@@ -6247,17 +6071,27 @@
 am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
-# AM_CONDITIONAL                                            -*- Autoconf -*-
+# AM_CONDITIONAL                                              -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
 
-# serial 7
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 6
+
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
@@ -6280,16 +6114,27 @@
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
+# serial 7						-*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
 # Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 8
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
 # will think it sees a *use*, and therefore will trigger all it's
@@ -6297,6 +6142,7 @@
 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 
 
+
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
@@ -6436,17 +6282,28 @@
 AC_SUBST([AMDEPBACKSLASH])
 ])
 
-# Generate code to set up dependency tracking.              -*- Autoconf -*-
+# Generate code to set up dependency tracking.   -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+#   Free Software Foundation, Inc.
 
-#serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@@ -6504,20 +6361,31 @@
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Do all the work for Automake.                             -*- Autoconf -*-
+# Do all the work for Automake.                            -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# This macro actually does too much some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 # Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
-# This macro actually does too much.  Some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 11
+
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
 # -----------------------------------------------
@@ -6618,28 +6486,52 @@
 done
 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
+
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 install_sh=${install_sh-"$am_aux_dir/install-sh"}
 AC_SUBST(install_sh)])
 
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+#                                                          -*- Autoconf -*-
+# Copyright (C) 2003  Free Software Foundation, Inc.
 
-# serial 2
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
 # Check whether the underlying file-system supports filenames
 # with a leading dot.  For instance MS-DOS doesn't.
 AC_DEFUN([AM_SET_LEADING_DOT],
@@ -6653,16 +6545,27 @@
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
-# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+# Check to see how 'make' treats includes.	-*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
-# serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
 # AM_MAKE_INCLUDE()
 # -----------------
 # Check to see how make treats includes.
@@ -6705,17 +6608,28 @@
 rm -f confinc confmf
 ])
 
-# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+#  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
 AC_DEFUN([AM_MISSING_PROG],
@@ -6740,16 +6654,27 @@
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_MKDIR_P
 # ---------------
 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-#
+
+# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
 # created by `make install' are always world readable, even if the
 # installer happens to have an overly restrictive umask (e.g. 077).
@@ -6803,16 +6728,27 @@
 fi
 AC_SUBST([mkdir_p])])
 
-# Helper functions for option handling.                     -*- Autoconf -*-
+# Helper functions for option handling.                    -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
 
-# serial 3
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
 AC_DEFUN([_AM_MANGLE_OPTION],
@@ -6836,17 +6772,29 @@
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
 #
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Check to make sure that the build environment is sane.
+#
 
-# serial 4
+# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
@@ -6888,14 +6836,25 @@
 fi
 AC_MSG_RESULT(yes)])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
 # AM_PROG_INSTALL_STRIP
-# ---------------------
+
+# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
 # One issue with vendor `install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
@@ -6918,13 +6877,25 @@
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2004  Free Software Foundation, Inc.
 
-# serial 2
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
 
 # _AM_PROG_TAR(FORMAT)
 # --------------------

Modified: freeswitch/branches/voctel/libs/codec/g726/configure
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/configure	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/configure	Fri Sep 22 14:22:15 2006
@@ -287,8 +287,8 @@
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -3233,7 +3233,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -3338,7 +3338,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -3372,7 +3372,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -3520,13 +3520,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -3542,7 +3542,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -3731,7 +3731,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-    case `/usr/bin/file conftest.o` in
+    case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -5457,33 +5457,20 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  netbsd* | freebsd* | openbsd* | darwin* )
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     ;;
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  *)
+
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
@@ -5534,6 +5521,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -5593,11 +5583,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -5759,7 +5746,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
 
 # Same as above, but do not quote variable references.
@@ -5779,7 +5766,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a `.a' archive for static linking (except M$VC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -6064,17 +6051,8 @@
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
 file_magic*)
@@ -6100,7 +6078,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -6162,7 +6140,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -6261,20 +6239,6 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 #
 # Check for any special shared library compilation flags.
 #
@@ -6311,16 +6275,11 @@
    LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
+     # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
-       $SED '/^$/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
-       fi
      else
        lt_prog_compiler_static_works=yes
      fi
@@ -6362,20 +6321,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6368: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6327: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6372: \$? = $ac_status" >&5
+   echo "$as_me:6331: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -6452,7 +6409,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -6481,7 +6438,7 @@
       darwin*)
         # PIC is the default on this platform
         # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
+       case "$cc_basename" in
          xlc*)
          lt_prog_compiler_pic='-qnocommon'
          lt_prog_compiler_wl='-Wl,'
@@ -6499,7 +6456,7 @@
       lt_prog_compiler_wl='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -6523,19 +6480,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
 	lt_prog_compiler_static='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-Bstatic'
-        ;;
       ccc*)
         lt_prog_compiler_wl='-Wl,'
         # All Alpha code is PIC.
@@ -6556,14 +6506,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_pic='-KPIC'
       lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -6585,11 +6530,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic='-pic'
       lt_prog_compiler_static='-Bstatic'
@@ -6624,20 +6564,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6630: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6570: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6634: \$? = $ac_status" >&5
+   echo "$as_me:6574: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works=yes
      fi
    fi
@@ -6658,7 +6596,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
@@ -6686,25 +6624,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6692: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6630: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:6696: \$? = $ac_status" >&5
+   echo "$as_me:6634: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -6780,16 +6716,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -6810,27 +6736,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -6881,7 +6786,7 @@
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -6899,37 +6804,6 @@
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -6968,6 +6842,31 @@
       hardcode_shlibpath_var=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -6978,11 +6877,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
+    if test "$ld_shlibs" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -7046,7 +6950,7 @@
       link_all_deplibs=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -7067,9 +6971,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -7216,7 +7117,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec=' '
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
+	  # This is similar to how AIX traditionally builds it's shared libraries.
 	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -7256,7 +7157,7 @@
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
+      case "$host_os" in
         rhapsody* | darwin1.[012])
          allow_undefined_flag='${wl}-undefined ${wl}suppress'
          ;;
@@ -7285,16 +7186,16 @@
     	output_verbose_link_cmd='echo'
         archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
       archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
          archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -7335,7 +7236,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -7360,7 +7261,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -7369,7 +7270,7 @@
 	  ;;
 	esac
       else
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -7379,7 +7280,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*)
 	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld='+b $libdir'
@@ -7492,7 +7393,7 @@
 	allow_undefined_flag=' -expect_unresolved \*'
 	archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -7511,12 +7412,10 @@
     solaris*)
       no_undefined_flag=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -7525,18 +7424,8 @@
       hardcode_shlibpath_var=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs=yes
       ;;
@@ -7838,8 +7727,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -7869,7 +7757,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -7892,7 +7780,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -7927,17 +7815,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -7955,7 +7834,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -7982,7 +7861,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -8081,7 +7960,7 @@
 
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
@@ -8144,11 +8023,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -8937,7 +8812,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 8940 "configure"
+#line 8815 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9003,7 +8878,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -9035,7 +8910,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9038 "configure"
+#line 8913 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9101,7 +8976,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
@@ -9151,7 +9026,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -9293,7 +9168,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -9304,7 +9179,7 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
@@ -9338,13 +9213,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -9420,7 +9289,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -9754,7 +9623,7 @@
 compiler_lib_search_path_CXX=
 
 # Source file extension for C++ test sources.
-ac_ext=cpp
+ac_ext=cc
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -9775,20 +9644,6 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -9810,17 +9665,8 @@
 CC=${CXX-"c++"}
 compiler=$CC
 compiler_CXX=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
 if test "$GXX" = yes; then
@@ -9890,7 +9736,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -9924,7 +9770,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -10033,7 +9879,7 @@
     link_all_deplibs_CXX=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[012]|aix4.[012].*)
+      case $host_os in aix4.012|aix4.012.*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -10054,9 +9900,6 @@
 	fi
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -10204,7 +10047,7 @@
 	# Exported symbols can be pulled into shared objects from archives
 	whole_archive_flag_spec_CXX=' '
 	archive_cmds_need_lc_CXX=yes
-	# This is similar to how AIX traditionally builds its shared libraries.
+	# This is similar to how AIX traditionally builds it's shared libraries.
 	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
@@ -10243,7 +10086,7 @@
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
+        case "$host_os" in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
          ;;
@@ -10281,7 +10124,7 @@
           archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
         fi
         module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
           if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
             archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           else
@@ -10289,12 +10132,12 @@
           fi
             module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
           archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
           module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
           archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -10307,11 +10150,11 @@
 
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -10322,14 +10165,14 @@
 	;;
     esac
     ;;
-  freebsd[12]*)
+  freebsd12*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     ld_shlibs_CXX=no
     ;;
   freebsd-elf*)
     archive_cmds_need_lc_CXX=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     ld_shlibs_CXX=yes
@@ -10346,11 +10189,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       ld_shlibs_CXX=no
       ;;
-    aCC*)
+    aCC)
       archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -10360,7 +10203,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -10374,7 +10217,7 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*)
 	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
 	hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
@@ -10390,7 +10233,7 @@
         ;;
       esac
     fi
-    case $host_cpu in
+    case "$host_cpu" in
     hppa*64*)
       hardcode_direct_CXX=no
       hardcode_shlibpath_var_CXX=no
@@ -10411,12 +10254,12 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      aCC*)
-	case $host_cpu in
+      aCC)
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
@@ -10437,7 +10280,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case $host_cpu in
+	    case "$host_cpu" in
 	    ia64*|hppa*64*)
 	      archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
@@ -10455,9 +10298,9 @@
     ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -10468,7 +10311,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -10481,7 +10324,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10506,7 +10349,7 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
 	# version 8.0 and above of icpc choke on multiply defined symbols
@@ -10518,12 +10361,8 @@
   	  archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	  ;;
 	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+  	  archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+  	archive_expsym_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	  ;;
 	esac
 	archive_cmds_need_lc_CXX=no
@@ -10531,16 +10370,7 @@
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -10571,7 +10401,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
@@ -10610,7 +10440,7 @@
     ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10626,14 +10456,14 @@
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	hardcode_libdir_separator_CXX=:
@@ -10651,7 +10481,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -10670,7 +10500,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -10685,17 +10515,17 @@
 	# the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' -expect_unresolved \*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -10714,7 +10544,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -10738,7 +10568,7 @@
   sco*)
     archive_cmds_need_lc_CXX=no
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
@@ -10750,12 +10580,12 @@
     ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -10768,33 +10598,36 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
-        archive_cmds_need_lc_CXX=yes
 	no_undefined_flag_CXX=' -zdefs'
-	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-R$libdir'
 	hardcode_shlibpath_var_CXX=no
 	case $host_os in
-	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  solaris2.0-5 | solaris2.0-5.*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	link_all_deplibs_CXX=yes
 
-	output_verbose_link_cmd='echo'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -10802,7 +10635,7 @@
 	# in the archive.
 	old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -10845,7 +10678,7 @@
     ;;
   tandem*)
     case $cc_basename in
-      NCC*)
+      NCC)
 	# NonStop-UX NCC 3.20
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -10898,7 +10731,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -10974,20 +10807,6 @@
 
 $rm -f confest.$objext
 
-# PORTME: override above test on systems where it is broken
-case $host_os in
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    postdeps_CXX='-lCstd -lCrun'
-    ;;
-  esac
-esac
-
-
 case " $postdeps_CXX " in
 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
 esac
@@ -11043,7 +10862,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	;;
       *)
@@ -11068,7 +10887,7 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
@@ -11077,7 +10896,7 @@
        darwin*)
          # PIC is the default on this platform
          # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
+         case "$cc_basename" in
            xlc*)
            lt_prog_compiler_pic_CXX='-qnocommon'
            lt_prog_compiler_wl_CXX='-Wl,'
@@ -11086,10 +10905,10 @@
        ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -11097,22 +10916,22 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
-	    case $host_cpu in
+	    case "$host_cpu" in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -11127,7 +10946,7 @@
 	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -11138,24 +10957,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -11172,7 +10985,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    lt_prog_compiler_pic_CXX='-W c,exportall'
 	    ;;
 	  *)
@@ -11183,14 +10996,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -11206,7 +11019,7 @@
 	;;
       sco*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  *)
@@ -11215,13 +11028,13 @@
 	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    lt_prog_compiler_wl_CXX='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-PIC'
 	    ;;
@@ -11231,12 +11044,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    lt_prog_compiler_pic_CXX='-pic'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -11246,7 +11059,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
@@ -11287,20 +11100,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11293: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11106: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11297: \$? = $ac_status" >&5
+   echo "$as_me:11110: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_CXX=yes
      fi
    fi
@@ -11321,7 +11132,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
@@ -11349,25 +11160,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11355: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11166: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11359: \$? = $ac_status" >&5
+   echo "$as_me:11170: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_CXX=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -11422,7 +11231,7 @@
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -11630,8 +11439,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -11661,7 +11469,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -11684,7 +11492,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -11719,17 +11527,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -11747,7 +11546,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -11774,7 +11573,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -11873,7 +11672,7 @@
 
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
@@ -11936,11 +11735,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -12729,7 +12524,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12732 "configure"
+#line 12527 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12795,7 +12590,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -12827,7 +12622,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12830 "configure"
+#line 12625 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12893,7 +12688,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
@@ -13045,13 +12840,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -13127,7 +12916,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -13408,36 +13197,13 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${F77-"f77"}
 compiler=$CC
 compiler_F77=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-
 echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
 echo "$as_me:$LINENO: result: $can_build_shared" >&5
@@ -13449,7 +13215,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -13458,9 +13224,7 @@
   fi
   ;;
 aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
+  test "$enable_shared" = yes && enable_static=no
   ;;
 esac
 echo "$as_me:$LINENO: result: $enable_shared" >&5
@@ -13537,7 +13301,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -13566,7 +13330,7 @@
       darwin*)
         # PIC is the default on this platform
         # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
+       case "$cc_basename" in
          xlc*)
          lt_prog_compiler_pic_F77='-qnocommon'
          lt_prog_compiler_wl_F77='-Wl,'
@@ -13584,7 +13348,7 @@
       lt_prog_compiler_wl_F77='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -13608,19 +13372,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl_F77='-Wl,'
 	lt_prog_compiler_pic_F77='-KPIC'
 	lt_prog_compiler_static_F77='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-Bstatic'
-        ;;
       ccc*)
         lt_prog_compiler_wl_F77='-Wl,'
         # All Alpha code is PIC.
@@ -13641,14 +13398,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl_F77='-Wl,'
       lt_prog_compiler_pic_F77='-KPIC'
       lt_prog_compiler_static_F77='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_F77='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_F77='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -13670,11 +13422,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic_F77='-pic'
       lt_prog_compiler_static_F77='-Bstatic'
@@ -13709,20 +13456,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13715: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13462: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13719: \$? = $ac_status" >&5
+   echo "$as_me:13466: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_F77=yes
      fi
    fi
@@ -13743,7 +13488,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_F77=
@@ -13771,25 +13516,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13777: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13522: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13781: \$? = $ac_status" >&5
+   echo "$as_me:13526: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_F77=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -13865,16 +13608,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -13895,27 +13628,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_F77=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -13966,7 +13678,7 @@
       allow_undefined_flag_F77=unsupported
       always_export_symbols_F77=no
       enable_shared_with_static_runtimes_F77=yes
-      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -13980,41 +13692,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	ld_shlibs_F77=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -14053,6 +13734,31 @@
       hardcode_shlibpath_var_F77=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_F77="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds_F77="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs_F77=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -14063,11 +13769,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs_F77" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_F77=
-      export_dynamic_flag_spec_F77=
-      whole_archive_flag_spec_F77=
+    if test "$ld_shlibs_F77" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_F77=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -14131,7 +13842,7 @@
       link_all_deplibs_F77=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -14152,9 +13863,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -14281,7 +13989,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec_F77=' '
 	  archive_cmds_need_lc_F77=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
+	  # This is similar to how AIX traditionally builds it's shared libraries.
 	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -14316,12 +14024,12 @@
       old_archive_From_new_cmds_F77='true'
       # FIXME: Should let the user specify the lib program.
       old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       enable_shared_with_static_runtimes_F77=yes
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
+      case "$host_os" in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
          ;;
@@ -14350,16 +14058,16 @@
     	output_verbose_link_cmd='echo'
         archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
       archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
          archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -14400,7 +14108,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_F77='-R$libdir'
       hardcode_direct_F77=yes
@@ -14425,7 +14133,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -14434,7 +14142,7 @@
 	  ;;
 	esac
       else
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -14444,7 +14152,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*)
 	  hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
@@ -14557,7 +14265,7 @@
 	allow_undefined_flag_F77=' -expect_unresolved \*'
 	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec_F77='-rpath $libdir'
@@ -14576,12 +14284,10 @@
     solaris*)
       no_undefined_flag_F77=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -14590,18 +14296,8 @@
       hardcode_shlibpath_var_F77=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs_F77=yes
       ;;
@@ -14903,8 +14599,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -14934,7 +14629,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -14957,7 +14652,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -14992,17 +14687,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -15020,7 +14706,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -15047,7 +14733,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -15146,7 +14832,7 @@
 
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
@@ -15209,11 +14895,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -15513,13 +15195,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -15595,7 +15271,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -15833,7 +15509,7 @@
 lt_simple_compile_test_code="class foo {}\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
@@ -15844,42 +15520,16 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
 compiler=$CC
 compiler_GCJ=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
-
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
 archive_cmds_need_lc_GCJ=no
 
-old_archive_cmds_GCJ=$old_archive_cmds
 
-
 lt_prog_compiler_no_builtin_flag_GCJ=
 
 if test "$GCC" = yes; then
@@ -15901,20 +15551,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15907: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15557: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15911: \$? = $ac_status" >&5
+   echo "$as_me:15561: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -15991,7 +15639,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -16020,7 +15668,7 @@
       darwin*)
         # PIC is the default on this platform
         # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
+       case "$cc_basename" in
          xlc*)
          lt_prog_compiler_pic_GCJ='-qnocommon'
          lt_prog_compiler_wl_GCJ='-Wl,'
@@ -16038,7 +15686,7 @@
       lt_prog_compiler_wl_GCJ='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -16062,19 +15710,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl_GCJ='-Wl,'
 	lt_prog_compiler_pic_GCJ='-KPIC'
 	lt_prog_compiler_static_GCJ='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-fpic'
-	lt_prog_compiler_static_GCJ='-Bstatic'
-        ;;
       ccc*)
         lt_prog_compiler_wl_GCJ='-Wl,'
         # All Alpha code is PIC.
@@ -16095,14 +15736,9 @@
       ;;
 
     solaris*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
       lt_prog_compiler_pic_GCJ='-KPIC'
       lt_prog_compiler_static_GCJ='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_GCJ='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_GCJ='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -16124,11 +15760,6 @@
       fi
       ;;
 
-    unicos*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic_GCJ='-pic'
       lt_prog_compiler_static_GCJ='-Bstatic'
@@ -16163,20 +15794,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16169: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15800: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16173: \$? = $ac_status" >&5
+   echo "$as_me:15804: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
-     $SED '/^$/d' conftest.err >conftest.er2
-     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_GCJ=yes
      fi
    fi
@@ -16197,7 +15826,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_GCJ=
@@ -16225,25 +15854,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16231: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15860: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16235: \$? = $ac_status" >&5
+   echo "$as_me:15864: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
-     $SED '/^$/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_GCJ=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -16319,16 +15946,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -16349,27 +15966,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_GCJ=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -16420,7 +16016,7 @@
       allow_undefined_flag_GCJ=unsupported
       always_export_symbols_GCJ=no
       enable_shared_with_static_runtimes_GCJ=yes
-      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
         archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -16434,41 +16030,10 @@
 	fi~
 	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	ld_shlibs_GCJ=no
+	ld_shlibs=no
       fi
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
     netbsd*)
       if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
 	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -16507,6 +16072,31 @@
       hardcode_shlibpath_var_GCJ=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_GCJ="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds_GCJ="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs_GCJ=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -16517,11 +16107,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs_GCJ" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_GCJ=
-      export_dynamic_flag_spec_GCJ=
-      whole_archive_flag_spec_GCJ=
+    if test "$ld_shlibs_GCJ" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_GCJ=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -16585,7 +16180,7 @@
       link_all_deplibs_GCJ=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -16606,9 +16201,6 @@
 	  fi
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -16755,7 +16347,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec_GCJ=' '
 	  archive_cmds_need_lc_GCJ=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
+	  # This is similar to how AIX traditionally builds it's shared libraries.
 	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -16790,12 +16382,12 @@
       old_archive_From_new_cmds_GCJ='true'
       # FIXME: Should let the user specify the lib program.
       old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       enable_shared_with_static_runtimes_GCJ=yes
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
+      case "$host_os" in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
          ;;
@@ -16824,16 +16416,16 @@
     	output_verbose_link_cmd='echo'
         archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
       archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
+      case "$cc_basename" in
         xlc*)
          output_verbose_link_cmd='echo'
          archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -16874,7 +16466,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_GCJ='-R$libdir'
       hardcode_direct_GCJ=yes
@@ -16899,7 +16491,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -16908,7 +16500,7 @@
 	  ;;
 	esac
       else
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*|ia64*)
 	  archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -16918,7 +16510,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case $host_cpu in
+	case "$host_cpu" in
 	hppa*64*)
 	  hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
@@ -17031,7 +16623,7 @@
 	allow_undefined_flag_GCJ=' -expect_unresolved \*'
 	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
@@ -17050,12 +16642,10 @@
     solaris*)
       no_undefined_flag_GCJ=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -17064,18 +16654,8 @@
       hardcode_shlibpath_var_GCJ=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs_GCJ=yes
       ;;
@@ -17377,8 +16957,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -17408,7 +16987,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -17431,7 +17010,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -17466,17 +17045,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -17494,7 +17064,7 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
@@ -17521,7 +17091,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -17620,7 +17190,7 @@
 
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
 
@@ -17683,11 +17253,7 @@
 openbsd*)
   version_type=sunos
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -18476,7 +18042,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18479 "configure"
+#line 18045 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18542,7 +18108,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -18574,7 +18140,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18577 "configure"
+#line 18143 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18640,7 +18206,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
@@ -18792,13 +18358,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -18874,7 +18434,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -19122,35 +18682,11 @@
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 compiler_RC=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
 lt_cv_prog_compiler_c_o_RC=yes
 
 # The else clause should only fire when bootstrapping the
@@ -19267,13 +18803,7 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
 
@@ -19349,7 +18879,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?

Modified: freeswitch/branches/voctel/libs/codec/g726/libg726.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/libg726.vcproj	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/libg726.vcproj	Fri Sep 22 14:22:15 2006
@@ -3,7 +3,7 @@
 	ProjectType="Visual C++"
 	Version="8.00"
 	Name="libg726"
-	ProjectGUID="{989BB874-7AF1-44CB-8E5C-CC8113D267E8}"
+	ProjectGUID="{5A6A281A-AA50-470A-8305-202BDA1CD1BF}"
 	RootNamespace="libg726"
 	Keyword="Win32Proj"
 	>
@@ -47,7 +47,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="4"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -146,6 +146,10 @@
 			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
 			>
+			<File
+				RelativePath=".\src\g711.c"
+				>
+			</File>
 			<File
 				RelativePath=".\src\g726_16.c"
 				>

Modified: freeswitch/branches/voctel/libs/codec/g726/src/g72x.c
==============================================================================
--- freeswitch/branches/voctel/libs/codec/g726/src/g72x.c	(original)
+++ freeswitch/branches/voctel/libs/codec/g726/src/g72x.c	Fri Sep 22 14:22:15 2006
@@ -47,9 +47,9 @@
 static int power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
 			0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};
 
-#ifndef abs
-#define abs(n) ((n)<0 ? -(n) : (n))
-#endif
+#ifndef abs
+#define abs(n) ((n)<0 ? -(n) : (n))
+#endif
 
 /*
  * quan()

Modified: freeswitch/branches/voctel/libs/codec/gsm/libgsm.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/codec/gsm/libgsm.vcproj	(original)
+++ freeswitch/branches/voctel/libs/codec/gsm/libgsm.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,7 +17,7 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
@@ -48,7 +48,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -80,7 +80,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"

Modified: freeswitch/branches/voctel/libs/codec/ilbc/libilbc.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/codec/ilbc/libilbc.vcproj	(original)
+++ freeswitch/branches/voctel/libs/codec/ilbc/libilbc.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,7 +17,7 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
@@ -47,7 +47,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -79,7 +79,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"

Modified: freeswitch/branches/voctel/libs/iax/libiax2.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/iax/libiax2.vcproj	(original)
+++ freeswitch/branches/voctel/libs/iax/libiax2.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,7 +17,7 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
@@ -48,7 +48,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -80,7 +80,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"

Modified: freeswitch/branches/voctel/libs/iax/src/iax.c
==============================================================================
--- freeswitch/branches/voctel/libs/iax/src/iax.c	(original)
+++ freeswitch/branches/voctel/libs/iax/src/iax.c	Fri Sep 22 14:22:15 2006
@@ -904,6 +904,7 @@
 	}
 	
 	if (netfd > -1) {
+		shutdown(netfd, 2);
 		close(netfd);
 	}
 
@@ -1785,7 +1786,7 @@
 		convert_reply(realreply, (unsigned char *) reply);
 		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) realreply);
 	} else {
-		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) password);
+		iax_ie_append_str(&ied, IAX_IE_PASSWORD, (unsigned char *) password);
 	}
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_AUTHREP, 0, ied.buf, ied.pos, -1);
 }
@@ -1808,7 +1809,7 @@
 		convert_reply(realreply, (unsigned char *) reply);
 		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) realreply);
 	} else {
-		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) password);
+		iax_ie_append_str(&ied, IAX_IE_PASSWORD, (unsigned char *) password);
 	}
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREQ, 0, ied.buf, ied.pos, -1);
 }
@@ -2244,7 +2245,7 @@
 	
 	/* How many ms from now should this packet be delivered? (remember
 	   this can be a negative number, too */
-	ms = calc_rxstamp(e->session) - ts;
+	ms = (int)(calc_rxstamp(e->session) - ts);
 
 	/*  
 	   Drop voice frame if timestamp is way off 

Modified: freeswitch/branches/voctel/libs/libdingaling/aclocal.m4
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/aclocal.m4	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/aclocal.m4	Fri Sep 22 14:22:15 2006
@@ -143,7 +143,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except M$VC,
+# All known linkers require a `.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -359,8 +359,8 @@
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
-       echo_test_string="`eval $cmd`" &&
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -529,7 +529,7 @@
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    case "`/usr/bin/file conftest.o`" in
+    case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -611,7 +611,7 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -650,7 +650,7 @@
    LDFLAGS="$LDFLAGS $3"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The compiler can only warn and ignore the option if not recognized
+     # The linker can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
@@ -725,7 +725,7 @@
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
@@ -737,7 +737,7 @@
     # nice to cause kernel panics so lets avoid the loop below.
     # First set a reasonable default.
     lt_cv_sys_max_cmd_len=16384
-    # 
+    #
     if test -x /sbin/sysconfig; then
       case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
         *1*) lt_cv_sys_max_cmd_len=-1 ;;
@@ -854,7 +854,7 @@
 }]
 EOF
   if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) $1 ;;
@@ -1003,7 +1003,7 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -1021,7 +1021,7 @@
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
-   chmod u+w .
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -1281,7 +1281,8 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -1334,7 +1335,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -1372,7 +1373,14 @@
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -1417,7 +1425,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -1813,7 +1821,7 @@
 
 # AC_LIBTOOL_WIN32_DLL
 # --------------------
-# declare package support for building win32 dll's
+# declare package support for building win32 DLLs
 AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
 [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
 ])# AC_LIBTOOL_WIN32_DLL
@@ -1987,7 +1995,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -2097,7 +2105,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some GNU ld's only accept -v.
+      # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -2129,7 +2137,7 @@
 AC_DEFUN([AC_PROG_LD_GNU],
 [AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -2243,7 +2251,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -2417,13 +2425,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl convenience library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments.  Note that LIBLTDL
-# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
-# DIRECTORY is not provided, it is assumed to be `libltdl'.  LIBLTDL will
-# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
-# '${top_srcdir}/' (note the single quotes!).  If your package is not
-# flat and you're not using automake, define top_builddir and
-# top_srcdir appropriately in the Makefiles.
+# --enable-ltdl-convenience to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
+# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+# (note the single quotes!).  If your package is not flat and you're not
+# using automake, define top_builddir and top_srcdir appropriately in
+# the Makefiles.
 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
   case $enable_ltdl_convenience in
@@ -2442,13 +2450,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl installable library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments.  Note that LIBLTDL
-# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
-# DIRECTORY is not provided and an installed libltdl is not found, it is
-# assumed to be `libltdl'.  LIBLTDL will be prefixed with '${top_builddir}/'
-# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
-# quotes!).  If your package is not flat and you're not using automake,
-# define top_builddir and top_srcdir appropriately in the Makefiles.
+# --enable-ltdl-install to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# and an installed libltdl is not found, it is assumed to be `libltdl'.
+# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and top_srcdir
+# appropriately in the Makefiles.
 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
 AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
@@ -2627,7 +2635,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case "$host_os" in
+case $host_os in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -2694,7 +2702,7 @@
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
 
 # Source file extension for C++ test sources.
-ac_ext=cc
+ac_ext=cpp
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -2910,7 +2918,7 @@
 	# Exported symbols can be pulled into shared objects from archives
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	# This is similar to how AIX traditionally builds it's shared libraries.
+	# This is similar to how AIX traditionally builds its shared libraries.
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
@@ -2949,7 +2957,7 @@
     fi
   ;;
       darwin* | rhapsody*)
-        case "$host_os" in
+        case $host_os in
         rhapsody* | darwin1.[[012]])
          _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
          ;;
@@ -2987,7 +2995,7 @@
           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
         fi
         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
           if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
             _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           else
@@ -3000,7 +3008,7 @@
          output_verbose_link_cmd='echo'
           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
           _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -3080,7 +3088,7 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*)
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
@@ -3096,7 +3104,7 @@
         ;;
       esac
     fi
-    case "$host_cpu" in
+    case $host_cpu in
     hppa*64*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -3122,7 +3130,7 @@
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
       aCC*)
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
@@ -3143,7 +3151,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case "$host_cpu" in
+	    case $host_cpu in
 	    ia64*|hppa*64*)
 	      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
@@ -3244,7 +3252,7 @@
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
         ;;
       cxx*)
 	# Compaq C++
@@ -3476,10 +3484,11 @@
     case $cc_basename in
       CC*)
 	# Sun C++ 4.2, 5.x and Centerline C++
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -3499,15 +3508,7 @@
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	output_verbose_link_cmd='echo'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -3664,7 +3665,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -3740,6 +3741,21 @@
 
 $rm -f confest.$objext
 
+# PORTME: override above test on systems where it is broken
+ifelse([$1],[CXX],
+[case $host_os in
+solaris*)
+  case $cc_basename in
+  CC*)
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+    ;;
+  esac
+esac
+])
+
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
@@ -3809,7 +3825,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case "$host_os" in
+case $host_os in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -4708,7 +4724,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	;;
       *)
@@ -4777,7 +4793,7 @@
 	  aCC*)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
-	    case "$host_cpu" in
+	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -4818,7 +4834,7 @@
 	    # Portland Group C++ compiler.
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    ;;
 	  cxx*)
 	    # Compaq C++
@@ -4982,7 +4998,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5029,7 +5045,7 @@
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5059,12 +5075,12 @@
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
+      pgcc* | pgf77* | pgf90* | pgf95*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
 	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         ;;
       ccc*)
         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
@@ -5147,7 +5163,7 @@
     [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
 fi
-case "$host_os" in
+case $host_os in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
@@ -5243,7 +5259,7 @@
   if test "$with_gnu_ld" = yes; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
-    
+
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
@@ -5264,7 +5280,7 @@
       *\ 2.11.*) ;; # other 2.11 versions
       *) supports_anon_versioning=yes ;;
     esac
-    
+
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -5338,11 +5354,11 @@
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
 	pgcc*)				# Portland Group C compiler
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -5548,7 +5564,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  # This is similar to how AIX traditionally builds its shared libraries.
 	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -5588,7 +5604,7 @@
       ;;
 
     darwin* | rhapsody*)
-      case "$host_os" in
+      case $host_os in
         rhapsody* | darwin1.[[012]])
          _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
          ;;
@@ -5617,7 +5633,7 @@
     	output_verbose_link_cmd='echo'
         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
@@ -5626,7 +5642,7 @@
          output_verbose_link_cmd='echo'
          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -5692,7 +5708,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -5701,7 +5717,7 @@
 	  ;;
 	esac
       else
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -5711,7 +5727,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*)
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'

Modified: freeswitch/branches/voctel/libs/libdingaling/configure
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/configure	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/configure	Fri Sep 22 14:22:15 2006
@@ -287,8 +287,8 @@
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
-       echo_test_string="`eval $cmd`" &&
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -3339,7 +3339,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some GNU ld's only accept -v.
+      # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -3373,7 +3373,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -3543,7 +3543,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -3732,7 +3732,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-    case "`/usr/bin/file conftest.o`" in
+    case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -5465,7 +5465,7 @@
     elif test -x /usr/sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
     else
-      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
     fi
     # And add a safety zone
     lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
@@ -5780,7 +5780,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except M$VC,
+# All known linkers require a `.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -6101,7 +6101,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -6163,7 +6163,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -6312,7 +6312,7 @@
    LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The compiler can only warn and ignore the option if not recognized
+     # The linker can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
@@ -6363,7 +6363,7 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:6369: $lt_compile\"" >&5)
@@ -6453,7 +6453,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -6500,7 +6500,7 @@
       lt_prog_compiler_wl='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -6530,12 +6530,12 @@
 	lt_prog_compiler_pic='-KPIC'
 	lt_prog_compiler_static='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
+      pgcc* | pgf77* | pgf90* | pgf95*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-static'
+	lt_prog_compiler_static='-Bstatic'
         ;;
       ccc*)
         lt_prog_compiler_wl='-Wl,'
@@ -6625,7 +6625,7 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:6631: $lt_compile\"" >&5)
@@ -6659,7 +6659,7 @@
 fi
 
 fi
-case "$host_os" in
+case $host_os in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
@@ -6687,7 +6687,7 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:6693: $lt_compile\"" >&5)
@@ -6705,7 +6705,7 @@
        lt_cv_prog_compiler_c_o=yes
      fi
    fi
-   chmod u+w .
+   chmod u+w . 2>&5
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -6905,11 +6905,11 @@
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
 	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -7217,7 +7217,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec=' '
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  # This is similar to how AIX traditionally builds its shared libraries.
 	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -7257,7 +7257,7 @@
       ;;
 
     darwin* | rhapsody*)
-      case "$host_os" in
+      case $host_os in
         rhapsody* | darwin1.[012])
          allow_undefined_flag='${wl}-undefined ${wl}suppress'
          ;;
@@ -7286,7 +7286,7 @@
     	output_verbose_link_cmd='echo'
         archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
       archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
@@ -7295,7 +7295,7 @@
          output_verbose_link_cmd='echo'
          archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -7361,7 +7361,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -7370,7 +7370,7 @@
 	  ;;
 	esac
       else
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -7380,7 +7380,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*)
 	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld='+b $libdir'
@@ -7839,7 +7839,8 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -7892,7 +7893,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -7930,7 +7931,14 @@
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -7975,7 +7983,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -8930,7 +8938,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 8933 "configure"
+#line 8941 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -8996,7 +9004,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -9028,7 +9036,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9031 "configure"
+#line 9039 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9094,7 +9102,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
@@ -9144,7 +9152,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case "$host_os" in
+case $host_os in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -9747,7 +9755,7 @@
 compiler_lib_search_path_CXX=
 
 # Source file extension for C++ test sources.
-ac_ext=cc
+ac_ext=cpp
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -9883,7 +9891,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some GNU ld's only accept -v.
+      # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -9917,7 +9925,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -10197,7 +10205,7 @@
 	# Exported symbols can be pulled into shared objects from archives
 	whole_archive_flag_spec_CXX=' '
 	archive_cmds_need_lc_CXX=yes
-	# This is similar to how AIX traditionally builds it's shared libraries.
+	# This is similar to how AIX traditionally builds its shared libraries.
 	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
@@ -10236,7 +10244,7 @@
     fi
   ;;
       darwin* | rhapsody*)
-        case "$host_os" in
+        case $host_os in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
          ;;
@@ -10274,7 +10282,7 @@
           archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
         fi
         module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
           if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
             archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           else
@@ -10287,7 +10295,7 @@
          output_verbose_link_cmd='echo'
           archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
           module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
           archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -10367,7 +10375,7 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*)
 	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
 	hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
@@ -10383,7 +10391,7 @@
         ;;
       esac
     fi
-    case "$host_cpu" in
+    case $host_cpu in
     hppa*64*)
       hardcode_direct_CXX=no
       hardcode_shlibpath_var_CXX=no
@@ -10409,7 +10417,7 @@
 	ld_shlibs_CXX=no
 	;;
       aCC*)
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
@@ -10430,7 +10438,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case "$host_cpu" in
+	    case $host_cpu in
 	    ia64*|hppa*64*)
 	      archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
@@ -10531,7 +10539,7 @@
 
 	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
         ;;
       cxx*)
 	# Compaq C++
@@ -10763,10 +10771,11 @@
     case $cc_basename in
       CC*)
 	# Sun C++ 4.2, 5.x and Centerline C++
+        archive_cmds_need_lc_CXX=yes
 	no_undefined_flag_CXX=' -zdefs'
-	archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-R$libdir'
 	hardcode_shlibpath_var_CXX=no
@@ -10786,15 +10795,7 @@
 	esac
 	link_all_deplibs_CXX=yes
 
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	output_verbose_link_cmd='echo'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -10898,7 +10899,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -10974,6 +10975,20 @@
 
 $rm -f confest.$objext
 
+# PORTME: override above test on systems where it is broken
+case $host_os in
+solaris*)
+  case $cc_basename in
+  CC*)
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    postdeps_CXX='-lCstd -lCrun'
+    ;;
+  esac
+esac
+
+
 case " $postdeps_CXX " in
 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
 esac
@@ -11029,7 +11044,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	;;
       *)
@@ -11098,7 +11113,7 @@
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
-	    case "$host_cpu" in
+	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -11139,7 +11154,7 @@
 	    # Portland Group C++ compiler.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-static'
+	    lt_prog_compiler_static_CXX='-Bstatic'
 	    ;;
 	  cxx*)
 	    # Compaq C++
@@ -11273,14 +11288,14 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11279: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11294: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11283: \$? = $ac_status" >&5
+   echo "$as_me:11298: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -11307,7 +11322,7 @@
 fi
 
 fi
-case "$host_os" in
+case $host_os in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
@@ -11335,14 +11350,14 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11341: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11356: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11345: \$? = $ac_status" >&5
+   echo "$as_me:11360: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11353,7 +11368,7 @@
        lt_cv_prog_compiler_c_o_CXX=yes
      fi
    fi
-   chmod u+w .
+   chmod u+w . 2>&5
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -11616,7 +11631,8 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -11669,7 +11685,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -11707,7 +11723,14 @@
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -11752,7 +11775,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -12707,7 +12730,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12710 "configure"
+#line 12733 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12773,7 +12796,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -12805,7 +12828,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12808 "configure"
+#line 12831 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12871,7 +12894,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
@@ -13427,7 +13450,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case "$host_os" in
+case $host_os in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -13515,7 +13538,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -13562,7 +13585,7 @@
       lt_prog_compiler_wl_F77='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -13592,12 +13615,12 @@
 	lt_prog_compiler_pic_F77='-KPIC'
 	lt_prog_compiler_static_F77='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
+      pgcc* | pgf77* | pgf90* | pgf95*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
 	lt_prog_compiler_wl_F77='-Wl,'
 	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-static'
+	lt_prog_compiler_static_F77='-Bstatic'
         ;;
       ccc*)
         lt_prog_compiler_wl_F77='-Wl,'
@@ -13687,14 +13710,14 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13693: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13716: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13697: \$? = $ac_status" >&5
+   echo "$as_me:13720: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -13721,7 +13744,7 @@
 fi
 
 fi
-case "$host_os" in
+case $host_os in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_F77=
@@ -13749,14 +13772,14 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13755: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13778: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13759: \$? = $ac_status" >&5
+   echo "$as_me:13782: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -13767,7 +13790,7 @@
        lt_cv_prog_compiler_c_o_F77=yes
      fi
    fi
-   chmod u+w .
+   chmod u+w . 2>&5
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -13967,11 +13990,11 @@
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
 	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -14259,7 +14282,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec_F77=' '
 	  archive_cmds_need_lc_F77=yes
-	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  # This is similar to how AIX traditionally builds its shared libraries.
 	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -14299,7 +14322,7 @@
       ;;
 
     darwin* | rhapsody*)
-      case "$host_os" in
+      case $host_os in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
          ;;
@@ -14328,7 +14351,7 @@
     	output_verbose_link_cmd='echo'
         archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
       archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
@@ -14337,7 +14360,7 @@
          output_verbose_link_cmd='echo'
          archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -14403,7 +14426,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -14412,7 +14435,7 @@
 	  ;;
 	esac
       else
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -14422,7 +14445,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*)
 	  hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
@@ -14881,7 +14904,8 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -14934,7 +14958,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -14972,7 +14996,14 @@
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -15017,7 +15048,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -15871,14 +15902,14 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15877: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15908: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15881: \$? = $ac_status" >&5
+   echo "$as_me:15912: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -15961,7 +15992,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -16008,7 +16039,7 @@
       lt_prog_compiler_wl_GCJ='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case "$host_cpu" in
+      case $host_cpu in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -16038,12 +16069,12 @@
 	lt_prog_compiler_pic_GCJ='-KPIC'
 	lt_prog_compiler_static_GCJ='-static'
         ;;
-      pgcc* | pgf77* | pgf90*)
+      pgcc* | pgf77* | pgf90* | pgf95*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
 	lt_prog_compiler_wl_GCJ='-Wl,'
 	lt_prog_compiler_pic_GCJ='-fpic'
-	lt_prog_compiler_static_GCJ='-static'
+	lt_prog_compiler_static_GCJ='-Bstatic'
         ;;
       ccc*)
         lt_prog_compiler_wl_GCJ='-Wl,'
@@ -16133,14 +16164,14 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16139: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16170: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16143: \$? = $ac_status" >&5
+   echo "$as_me:16174: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16167,7 +16198,7 @@
 fi
 
 fi
-case "$host_os" in
+case $host_os in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_GCJ=
@@ -16195,14 +16226,14 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16201: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16232: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16205: \$? = $ac_status" >&5
+   echo "$as_me:16236: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16213,7 +16244,7 @@
        lt_cv_prog_compiler_c_o_GCJ=yes
      fi
    fi
-   chmod u+w .
+   chmod u+w . 2>&5
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -16413,11 +16444,11 @@
 	tmp_addflag=
 	case $cc_basename,$host_cpu in
 	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
-	pgf77* | pgf90* )			# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive,`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -16725,7 +16756,7 @@
 	  # Exported symbols can be pulled into shared objects from archives
 	  whole_archive_flag_spec_GCJ=' '
 	  archive_cmds_need_lc_GCJ=yes
-	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  # This is similar to how AIX traditionally builds its shared libraries.
 	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
@@ -16765,7 +16796,7 @@
       ;;
 
     darwin* | rhapsody*)
-      case "$host_os" in
+      case $host_os in
         rhapsody* | darwin1.[012])
          allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
          ;;
@@ -16794,7 +16825,7 @@
     	output_verbose_link_cmd='echo'
         archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
       module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
       archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
@@ -16803,7 +16834,7 @@
          output_verbose_link_cmd='echo'
          archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
          module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
           ;;
@@ -16869,7 +16900,7 @@
 
     hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
@@ -16878,7 +16909,7 @@
 	  ;;
 	esac
       else
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*|ia64*)
 	  archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
@@ -16888,7 +16919,7 @@
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	case "$host_cpu" in
+	case $host_cpu in
 	hppa*64*)
 	  hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
@@ -17347,7 +17378,8 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -17400,7 +17432,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -17438,7 +17470,14 @@
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -17483,7 +17522,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case "$host_cpu" in
+  case $host_cpu in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -18438,7 +18477,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18441 "configure"
+#line 18480 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18504,7 +18543,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
@@ -18536,7 +18575,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18539 "configure"
+#line 18578 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18602,7 +18641,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) 2>/dev/null
+    (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;

Modified: freeswitch/branches/voctel/libs/libdingaling/configure.in
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/configure.in	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/configure.in	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,7 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.59)
+
 AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
 AM_INIT_AUTOMAKE(libdingaling,0.1)
 AC_CONFIG_SRCDIR([src])

Modified: freeswitch/branches/voctel/libs/libdingaling/libdingaling.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/libdingaling.vcproj	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/libdingaling.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,7 +17,7 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
@@ -40,7 +40,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include"
+				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include;&quot;..\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -48,7 +48,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -80,7 +80,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="1"
@@ -103,7 +103,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include"
+				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include;&quot;..\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
@@ -141,7 +141,7 @@
 		</Configuration>
 		<Configuration
 			Name="Debug DLL|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(SolutionDir)Debug"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			CharacterSet="1"
@@ -164,7 +164,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include"
+				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include;&quot;..\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -220,7 +220,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release DLL|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(SolutionDir)Release"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			CharacterSet="1"
@@ -243,7 +243,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include"
+				AdditionalIncludeDirectories=".;.\src;..\iksemel\include;..\include;..\apr\include;&quot;..\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"

Modified: freeswitch/branches/voctel/libs/libdingaling/src/dingaling.def
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/src/dingaling.def	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/src/dingaling.def	Fri Sep 22 14:22:15 2006
@@ -23,3 +23,8 @@
 ldl_session_get_id
 ldl_session_set_ip
 ldl_global_set_logger
+ldl_handle_send_msg
+ldl_session_get_value
+ldl_session_set_value
+ldl_session_accept_candidate
+ldl_session_send_msg
\ No newline at end of file

Modified: freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.c	Fri Sep 22 14:22:15 2006
@@ -64,8 +64,8 @@
 #define microsleep(x) apr_sleep(x * 1000)
 
 static int opt_timeout = 30;
-static int opt_use_tls = 0;
 
+
 static struct {
 	unsigned int flags;
 	FILE *log_stream;
@@ -73,6 +73,7 @@
 	apr_pool_t *memory_pool;
 	unsigned int id;
 	ldl_logger_t logger;
+	apr_thread_mutex_t *flag_mutex;
 } globals;
 
 struct packet_node {
@@ -94,7 +95,9 @@
 	iksfilter *filter;
 	char *login;
 	char *password;
+	char *server;
 	char *status_msg;
+	uint16_t port;
 	int features;
 	int counter;
 	int job_done;
@@ -104,7 +107,9 @@
 	apr_hash_t *sessions;
 	apr_hash_t *retry_hash;
 	apr_hash_t *probe_hash;
+	apr_hash_t *sub_hash;
 	apr_thread_mutex_t *lock;
+	apr_thread_mutex_t *flag_mutex;
 	ldl_loop_callback_t loop_callback;
 	ldl_session_callback_t session_callback;
 	ldl_response_callback_t response_callback;
@@ -125,6 +130,7 @@
 	ldl_candidate_t candidates[LDL_MAX_CANDIDATES];
 	unsigned int candidate_len;
 	apr_pool_t *pool;
+	apr_hash_t *variables;
 	apr_time_t created;
 	void *private_data;
 };
@@ -170,27 +176,46 @@
 }
 
 
+char *ldl_session_get_value(ldl_session_t *session, char *key)
+{
+	return apr_hash_get(session->variables, key, APR_HASH_KEY_STRING);
+}
+
+void ldl_session_set_value(ldl_session_t *session, char *key, char *val)
+{
+	apr_hash_set(session->variables, apr_pstrdup(session->pool, key), APR_HASH_KEY_STRING, apr_pstrdup(session->pool, val));
+}
+
 char *ldl_session_get_id(ldl_session_t *session)
 {
 	return session->id;
 }
 
+void ldl_session_send_msg(ldl_session_t *session, char *subject, char *body)
+{
+	ldl_handle_send_msg(session->handle, session->them, subject, body);
+}
+
 ldl_status ldl_session_destroy(ldl_session_t **session_p)
 {
 	ldl_session_t *session = *session_p;
 
 	if (session) {
 		apr_pool_t *pool = session->pool;
+		apr_hash_t *hash = session->handle->sessions;
 
 		if (globals.debug) {
 			globals.logger(DL_LOG_DEBUG, "Destroyed Session %s\n", session->id);
 		}
+
 		if (session->id) {
-			apr_hash_set(session->handle->sessions, session->id, APR_HASH_KEY_STRING, NULL);
+			apr_hash_set(hash, session->id, APR_HASH_KEY_STRING, NULL);
 		}
+
 		if (session->them) {
-			apr_hash_set(session->handle->sessions, session->them, APR_HASH_KEY_STRING, NULL);
+			apr_hash_set(hash, session->them, APR_HASH_KEY_STRING, NULL);
 		}
+
 		apr_pool_destroy(pool);
 		pool = NULL;
 		*session_p = NULL;
@@ -223,8 +248,10 @@
 	session->handle = handle;
 	session->created = apr_time_now();
 	session->state = LDL_STATE_NEW;
+	session->variables = apr_hash_make(session->pool);
 	*session_p = session;
-	
+
+
 	if (globals.debug) {
 		globals.logger(DL_LOG_DEBUG, "Created Session %s\n", id);
 	}
@@ -260,7 +287,7 @@
 	while(xml) {
 		char *type = xtype ? xtype : iks_find_attrib(xml, "type");
 		iks *tag;
-
+		
 		if (type) {
 			
 			if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) {
@@ -281,7 +308,7 @@
 							if (!strcasecmp(iks_name(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) {
 								char *name = iks_find_attrib(itag, "name");
 								char *id = iks_find_attrib(itag, "id");
-								char *rate = iks_find_attrib(itag, "rate");
+								char *rate = iks_find_attrib(itag, "clockrate");
 								if (name && id) {
 									session->payloads[session->payload_len].name = apr_pstrdup(session->pool, name);
 									session->payloads[session->payload_len].id = atoi(id);
@@ -300,12 +327,27 @@
 					}
 					tag = iks_next_tag(tag);
 				}
-			} else if (!strcasecmp(type, "candidates")) {
+			} else if (!strcasecmp(type, "transport-accept")) {
+				signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
+			} else if (!strcasecmp(type, "transport-info")) {
+				char *tid = iks_find_attrib(xml, "id");
 				signal = LDL_SIGNAL_CANDIDATES;
 				tag = iks_child (xml);
 				
+				if (tag && !strcasecmp(iks_name(tag), "transport")) {
+					tag = iks_child(tag);
+				}
+				
 				while(tag) {
-					if (!strcasecmp(iks_name(tag), "candidate") && session->candidate_len < LDL_MAX_CANDIDATES) {
+					if (!strcasecmp(iks_name(tag), "info_element")) {
+						char *name = iks_find_attrib(tag, "name");
+						char *value = iks_find_attrib(tag, "value");
+						if (globals.debug) {
+							globals.logger(DL_LOG_DEBUG, "Info Element [%s]=[%s]\n", name, value);
+						}
+						ldl_session_set_value(session, name, value);
+						
+					} else if (!strcasecmp(iks_name(tag), "candidate") && session->candidate_len < LDL_MAX_CANDIDATES) {
 						char *key;
 						double pref = 0.0;
 						int index = -1;
@@ -329,6 +371,11 @@
 						}
 						
 						session->candidates[index].pref = pref;
+
+						if (tid) {
+							session->candidates[index].tid = apr_pstrdup(session->pool, tid);
+						}
+
 						if ((key = iks_find_attrib(tag, "name"))) {
 							session->candidates[index].name = apr_pstrdup(session->pool, key);
 						}
@@ -386,12 +433,13 @@
 	}
 
 	if (handle->session_callback && signal) {
-		handle->session_callback(handle, session, signal, msg); 
+		handle->session_callback(handle, session, signal, from, id, msg); 
 	}
 
 	return LDL_STATUS_SUCCESS;
 }
 
+const char *marker = "TRUE";
 
 static int on_presence(void *user_data, ikspak *pak)
 {
@@ -401,6 +449,13 @@
 	char *resource;
 	struct ldl_buffer *buffer;
 	size_t x;
+	
+	if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) {
+		iks *msg;
+		apr_hash_set(handle->sub_hash, 	apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker);
+		msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); 
+		apr_queue_push(handle->queue, msg);
+	}
 
 	apr_cpystrn(id, from, sizeof(id));
 	if ((resource = strchr(id, '/'))) {
@@ -456,22 +511,49 @@
 	//char *to = iks_find_attrib(pak->x, "to");
 	char *iqid = iks_find_attrib(pak->x, "id");
 	char *type = iks_find_attrib(pak->x, "type");
+	uint8_t is_result = strcasecmp(type, "result") ? 0 : 1;
+	uint8_t is_error = strcasecmp(type, "error") ? 0 : 1;
+
 	iks *xml;
 
-	//printf("XXXXX from=%s to=%s type=%s\n", from, to, type);
+	if (is_result) {
+		iks *tag = iks_child (pak->x);
+		while(tag) {
+			if (!strcasecmp(iks_name(tag), "bind")) {
+				char *jid = iks_find_cdata(tag, "jid");
+				char *resource = strchr(jid, '/');
+				iks *iq, *x;
+				handle->acc->resource = apr_pstrdup(handle->pool, resource);
+				handle->login = apr_pstrdup(handle->pool, jid);
+				if ((iq = iks_new("iq"))) {
+					iks_insert_attrib(iq, "type", "get");
+					iks_insert_attrib(iq, "id", "roster");
+					x = iks_insert(iq,  "query");
+					iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
+					iks_insert_attrib(x, "xmlns:gr", "google:roster");
+					iks_insert_attrib(x, "gr:ext", "2");
+					iks_insert_attrib(x, "gr:include", "all");
+					iks_send(handle->parser, iq);
+					iks_delete(iq);
+					break;
+				}
+			}
+			tag = iks_next_tag(tag);
+		}
+	}
 
-	if ((!strcasecmp(type, "result") || !strcasecmp(type, "error")) && iqid && from) {
+	if ((is_result || is_error) && iqid && from) {
+
 		cancel_retry(handle, iqid);
-		if (!strcasecmp(type, "result")) {
+		if (is_result) {
 			if (handle->response_callback) {
 				handle->response_callback(handle, iqid); 
 			}
 			return IKS_FILTER_EAT;
+		} else if (is_error) {
+			return IKS_FILTER_EAT;
 		}
 	}
-
-
-
 	
 	xml = iks_child (pak->x);
 	while (xml) {
@@ -505,29 +587,67 @@
 	iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps");
 	iks_insert_attrib(ctag, "ver", "1.0.0.1");
 	iks_insert_attrib(ctag, "ext", "sidebar voice-v1");
+	iks_insert_attrib(ctag, "client", "libdingaling");
 	iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
-	
+
 	apr_queue_push(handle->queue, msg);
-	ldl_set_flag(handle, LDL_FLAG_READY);
+	ldl_set_flag_locked(handle, LDL_FLAG_READY);
 	return IKS_FILTER_EAT;
 }
 
+static const char c64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+#define B64BUFFLEN 1024
+
+static int b64encode(unsigned char *in, uint32_t ilen, unsigned char *out, uint32_t olen) {
+	int y=0,bytes=0;
+	uint32_t x=0;
+	unsigned int b=0,l=0;
+
+	for(x=0;x<ilen;x++) {
+		b = (b<<8) + in[x];
+		l += 8;
+		while (l >= 6) {
+			out[bytes++] = c64[(b>>(l-=6))%64];
+			if(++y!=72) {
+				continue;
+			}
+			out[bytes++] = '\n';
+			y=0;
+		}
+	}
+
+	if (l > 0) {
+		out[bytes++] = c64[((b%16)<<(6-l))%64];
+	}
+	if (l != 0) while (l < 6) {
+		out[bytes++] = '=', l += 2;
+	}
+
+	return 0;
+}
+
 static int on_stream(ldl_handle_t *handle, int type, iks * node)
 {
 	handle->counter = opt_timeout;
 
 	switch (type) {
 	case IKS_NODE_START:
-		if (opt_use_tls && !iks_is_secure(handle->parser)) {
-			iks_start_tls(handle->parser);
+		if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser)) {
+			if (iks_has_tls()) {
+				iks_start_tls(handle->parser);
+			} else {
+				globals.logger(DL_LOG_DEBUG, "TLS NOT SUPPORTED IN THIS BUILD!\n");
+			}
 		}
 		break;
 	case IKS_NODE_NORMAL:
+		
+
 		if (strcmp("stream:features", iks_name(node)) == 0) {
 			handle->features = iks_stream_features(node);
-			if (opt_use_tls && !iks_is_secure(handle->parser))
+			if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser))
 				break;
-			if (ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
+			if (ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
 				iks *t;
 				if (handle->features & IKS_STREAM_BIND) {
 					t = iks_make_resource_bind(handle->acc);
@@ -544,22 +664,56 @@
 				if (handle->features & IKS_STREAM_SASL_MD5) {
 					iks_start_sasl(handle->parser, IKS_SASL_DIGEST_MD5, handle->acc->user, handle->password);
 				} else if (handle->features & IKS_STREAM_SASL_PLAIN) {
-					iks_start_sasl(handle->parser, IKS_SASL_PLAIN, handle->acc->user, handle->password);
+					iks *x = NULL;
+
+					if ((x = iks_new("auth"))) {
+						char s[512] = "";
+						char base64[1024] = "";
+						uint32_t slen;
+
+						iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
+						iks_insert_attrib(x, "mechanism", "PLAIN");
+						iks_insert_attrib(x, "encoding", "UTF-8");
+						snprintf(s, sizeof(s), "%c%s%c%s", 0, handle->acc->user, 0, handle->password);
+						slen = (uint32_t)(strlen(handle->acc->user) + strlen(handle->password) + 2);
+						b64encode((unsigned char *)s, slen, (unsigned char *) base64, sizeof(base64));
+						iks_insert_cdata(x, base64, 0);
+						iks_send(handle->parser, x);
+						iks_delete(x);
+					} else {
+						globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n");
+						break;
+					}
+					
 				}
 			}
 		} else if (strcmp("failure", iks_name(node)) == 0) {
 			globals.logger(DL_LOG_DEBUG, "sasl authentication failed\n");
+			if (handle->session_callback) {
+				handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_FAILURE, "core", "Login Failure", handle->login);
+			}
 		} else if (strcmp("success", iks_name(node)) == 0) {
 			globals.logger(DL_LOG_DEBUG, "XMPP server connected\n");
 			iks_send_header(handle->parser, handle->acc->server);
-			ldl_set_flag(handle, LDL_FLAG_AUTHORIZED);
+			ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED);
+			if (handle->session_callback) {
+				handle->session_callback(handle, NULL, LDL_SIGNAL_CONNECTED, "core", "Server Connected", handle->login);
+			}
 		} else {
 			ikspak *pak;
+			if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
+				if (handle->session_callback) {
+					handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "core", "Login Success", handle->login);
+				}
+				globals.logger(DL_LOG_DEBUG, "XMPP authenticated\n");
+				ldl_set_flag_locked(handle, LDL_FLAG_AUTHORIZED);
+			}
 
 			pak = iks_packet(node);
 			iks_filter_packet(handle->filter, pak);
-			if (handle->job_done == 1)
+			if (handle->job_done == 1) {
 				return IKS_HOOK;
+			}
 		}
 		break;
 #if 0
@@ -583,19 +737,18 @@
 {
 	char *cmd = iks_find_cdata(pak->x, "body");
 	char *from = iks_find_attrib(pak->x, "from");
+	char *subject = iks_find_attrib(pak->x, "subject");
 	ldl_handle_t *handle = user_data;
 	ldl_session_t *session = NULL;
 	
-	if (from && (session = apr_hash_get(handle->sessions, from, APR_HASH_KEY_STRING))) {
-		if (handle->session_callback) {
-			handle->session_callback(handle, session, LDL_SIGNAL_MSG, cmd); 
-		}
+	if (from) {
+		session = apr_hash_get(handle->sessions, from, APR_HASH_KEY_STRING);
 	}
-	
 
-	//printf("%s %s\n", handle->login, cmd);
+	if (handle->session_callback) {
+		handle->session_callback(handle, session, LDL_SIGNAL_MSG, from, subject ? subject : "N/A", cmd); 
+	}
 	
-
 	return 0;
 }
 
@@ -689,7 +842,6 @@
 		apr_time_t now = apr_time_now();
 		x++;
 
-		//printf("%s %lld %lld %u\n", packet_node->id, packet_node->next, now, packet_node->retries);
 		if (packet_node->next <= now) {
 			if (packet_node->retries > 0) {
 				packet_node->retries--;
@@ -714,6 +866,46 @@
 	apr_thread_mutex_unlock(handle->lock);
 }
 
+
+static void *APR_THREAD_FUNC queue_thread(apr_thread_t *thread, void *obj)
+{
+	ldl_handle_t *handle = (ldl_handle_t *) obj;
+
+	ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
+
+	while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
+		ldl_flush_queue(handle);
+
+		if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
+			int fd;
+
+			if ((fd = iks_fd(handle->parser)) > -1) {
+				shutdown(fd, 0x02);
+			}
+			ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);	
+			break;
+		}
+		microsleep(100);
+	}
+	
+	ldl_clear_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
+
+	return NULL;
+}
+
+static void launch_queue_thread(ldl_handle_t *handle)
+{
+    apr_thread_t *thread;
+    apr_threadattr_t *thd_attr;;
+    apr_threadattr_create(&thd_attr, handle->pool);
+    apr_threadattr_detach_set(thd_attr, 1);
+
+	apr_threadattr_stacksize_set(thd_attr, 512 * 1024);
+	apr_thread_create(&thread, thd_attr, queue_thread, handle, handle->pool);
+
+}
+
+
 static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
 {
 	while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
@@ -734,7 +926,12 @@
 
 		j_setup_filter(handle, "fixme");
 
-		e = iks_connect_tcp(handle->parser, handle->acc->server, IKS_JABBER_PORT);
+		e = iks_connect_via(handle->parser,
+							handle->server ? handle->server : handle->acc->server,
+							handle->port ? handle->port : IKS_JABBER_PORT,
+							//handle->server ? handle->server : handle->acc->server);
+							handle->acc->server);
+
 		switch (e) {
 		case IKS_OK:
 			break;
@@ -748,12 +945,18 @@
 			continue;
 		}
 
+
+
 		handle->counter = opt_timeout;
+		if (ldl_test_flag(handle, LDL_FLAG_TLS)) {
+			launch_queue_thread(handle);
+		}
+
 		while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
 			e = iks_recv(handle->parser, 1);
-			if (handle->loop_callback) {
+			if (!ldl_test_flag(handle, LDL_FLAG_TLS) && handle->loop_callback) {
 				if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
-					ldl_clear_flag(handle, LDL_FLAG_RUNNING);	
+					ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);	
 					break;
 				}
 			}
@@ -772,11 +975,12 @@
 				break;
 			}
 
-			if (ldl_test_flag(handle, LDL_FLAG_READY)) {
+			
+			if (!ldl_test_flag(handle, LDL_FLAG_TLS) && ldl_test_flag(handle, LDL_FLAG_READY)) {
 				ldl_flush_queue(handle);
 			}
 
-			if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
+			if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
 				if (IKS_NET_TLSFAIL == e) {
 					globals.logger(DL_LOG_DEBUG, "tls handshake failed\n");
 					microsleep(500);
@@ -793,10 +997,16 @@
 
 		iks_disconnect(handle->parser);
 		iks_parser_delete(handle->parser);
-		ldl_clear_flag(handle, LDL_FLAG_AUTHORIZED);
+		ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED);
+		ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED);
 	}
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
 
-	ldl_clear_flag(handle, LDL_FLAG_RUNNING);
+	while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) {
+		microsleep(100);
+	}
+
+
 }
 
 
@@ -806,7 +1016,8 @@
 	iks *iq, *sess;
 	unsigned int myid;
 	char idbuf[80];
-	
+	apr_hash_index_t *hi;
+
 	myid = next_id();
 	snprintf(idbuf, sizeof(idbuf), "%u", myid);
 	iq = iks_new("iq");
@@ -821,6 +1032,19 @@
 	iks_insert_attrib(sess, "type", type);
 	iks_insert_attrib(sess, "id", session->id);
 	iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them);	
+	for (hi = apr_hash_first(session->pool, session->variables); hi; hi = apr_hash_next(hi)) {
+		void *val = NULL;
+		const void *key = NULL;
+
+		apr_hash_this(hi, &key, NULL, &val);
+		if (val) {
+			iks *var = iks_insert(sess, "info_element");
+			iks_insert_attrib(var, "xmlns", "http://www.freeswitch.org/jie");
+			iks_insert_attrib(var, "name", (char *) key);
+			iks_insert_attrib(var, "value", (char *) val);
+		}
+	}
+
 	*sessp = sess;
 	*iqp = iq;
 	*id = myid;
@@ -870,12 +1094,55 @@
 	return session->private_data;
 }
 
+void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate)
+{
+	iks *iq, *sess, *tp;
+	unsigned int myid;
+    char idbuf[80];
+	myid = next_id();
+    snprintf(idbuf, sizeof(idbuf), "%u", myid);
 
+	iq = iks_new("iq");
+	iks_insert_attrib(iq, "type", "set");
+	iks_insert_attrib(iq, "id", idbuf);
+	iks_insert_attrib(iq, "from", session->handle->login);
+	iks_insert_attrib(iq, "to", session->them);
+	sess = iks_insert (iq, "session");
+    iks_insert_attrib(sess, "xmlns", "http://www.google.com/session");
+	iks_insert_attrib(sess, "type", "transport-accept");
+	iks_insert_attrib(sess, "id", candidate->tid);
+	iks_insert_attrib(sess, "xmlns", "http://www.google.com/session");
+	iks_insert_attrib(sess, "initiator", session->initiator ? session->initiator : session->them);
+	tp = iks_insert (sess, "transport");
+	iks_insert_attrib(tp, "xmlns", "http://www.google.com/transport/p2p");
+
+	apr_queue_push(session->handle->queue, iq);
+}
+
 void *ldl_handle_get_private(ldl_handle_t *handle)
 {
 	return handle->private_info;
 }
 
+void ldl_handle_send_msg(ldl_handle_t *handle, char *to, char *subject, char *body)
+{
+	iks *msg;
+
+	assert(handle != NULL);
+	assert(body != NULL);
+
+
+	msg = iks_make_msg(IKS_TYPE_NONE, to, body);
+	iks_insert_attrib(msg, "type", "chat");
+
+	if (subject) {
+		iks_insert_attrib(msg, "subject", subject);
+	}
+
+	apr_queue_push(handle->queue, msg);
+	
+}
+
 void ldl_global_set_logger(ldl_logger_t logger)
 {
 	globals.logger = logger;
@@ -893,18 +1160,27 @@
 
 }
 
+
 unsigned int ldl_session_candidates(ldl_session_t *session,
-								  ldl_candidate_t *candidates,
-								  unsigned int clen)
+									ldl_candidate_t *candidates,
+									unsigned int clen)
 
 {
 	iks *iq, *sess, *tag;
 	unsigned int x, id;
 
-	new_session_iq(session, &iq, &sess, &id, "candidates");
+
 	for (x = 0; x < clen; x++) {
 		char buf[512];
-		tag = iks_insert(sess, "candidate");
+		iq = NULL;
+		sess = NULL;
+		id = 0;
+
+		new_session_iq(session, &iq, &sess, &id, "transport-info");
+		tag = iks_insert(sess, "transport");
+		iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");
+		tag = iks_insert(tag, "candidate");
+
 		if (candidates[x].name) {
 			iks_insert_attrib(tag, "name", candidates[x].name);
 		}
@@ -934,13 +1210,13 @@
 
 		iks_insert_attrib(tag, "network", "0");
 		iks_insert_attrib(tag, "generation", "0");
+		schedule_packet(session->handle, id, iq, LDL_RETRY);
 	}
-	schedule_packet(session->handle, id, iq, LDL_RETRY);
 
+
 	return id;
 }
 
-
 char *ldl_handle_probe(ldl_handle_t *handle, char *id, char *buf, unsigned int len)
 {
 	iks *pres, *msg;
@@ -959,10 +1235,12 @@
 	iks_insert_attrib(pres, "type", "probe");
 	iks_insert_attrib(pres, "to", id);
 
+
 	apr_hash_set(handle->probe_hash, id, APR_HASH_KEY_STRING, &buffer);
-	
 	msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, notice); 
 	apr_queue_push(handle->queue, msg);
+	msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, notice); 
+	apr_queue_push(handle->queue, msg);
 	apr_queue_push(handle->queue, pres);
 
 	//schedule_packet(handle, next_id(), pres, LDL_RETRY);
@@ -995,13 +1273,14 @@
 								unsigned int plen,
 								ldl_description_t description)
 {
-	iks *iq, *sess, *tag, *payload;
+	iks *iq, *sess, *tag, *payload, *tp;
 	unsigned int x, id;
 	
 
 	new_session_iq(session, &iq, &sess, &id, description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate");
 	tag = iks_insert(sess, "description");
 	iks_insert_attrib(tag, "xmlns", "http://www.google.com/session/phone");
+	iks_insert_attrib(tag, "xml:lang", "en");
 	for (x = 0; x < plen; x++) {
 		char idbuf[80];
 		payload = iks_insert(tag, "payload-type");
@@ -1012,10 +1291,19 @@
 		iks_insert_attrib(payload, "name", payloads[x].name);
 		if (payloads[x].rate) {
 			sprintf(idbuf, "%d", payloads[x].rate);
-			iks_insert_attrib(payload, "rate", idbuf);
+			iks_insert_attrib(payload, "clockrate", idbuf);
 		}
+		if (payloads[x].bps) {
+			sprintf(idbuf, "%d", payloads[x].bps);
+			iks_insert_attrib(payload, "bitrate", idbuf);
+		}
 	}
 
+	if (description == LDL_DESCRIPTION_INITIATE) {
+		tp = iks_insert (sess, "transport");
+		iks_insert_attrib(tp, "xmlns", "http://www.google.com/transport/p2p");
+	}
+	
 	schedule_packet(session->handle, id, iq, LDL_RETRY);
 
 	return id;
@@ -1064,16 +1352,18 @@
 	}
 
 	memset(&globals, 0, sizeof(globals));
+
 	if (apr_pool_create(&globals.memory_pool, NULL) != LDL_STATUS_SUCCESS) {
 		globals.logger(DL_LOG_DEBUG, "Could not allocate memory pool\n");
 		return LDL_STATUS_MEMERR;
 	}
 
+	apr_thread_mutex_create(&globals.flag_mutex, APR_THREAD_MUTEX_NESTED, globals.memory_pool);
 	globals.log_stream = stdout;
 	globals.debug = debug;
 	globals.id = 300;
 	globals.logger = default_logger;
-	ldl_set_flag(&globals, LDL_FLAG_INIT);
+	ldl_set_flag_locked((&globals), LDL_FLAG_INIT);
 	
 	return LDL_STATUS_SUCCESS;
 }
@@ -1106,6 +1396,8 @@
 ldl_status ldl_handle_init(ldl_handle_t **handle,
 						   char *login,
 						   char *password,
+						   char *server,
+						   ldl_user_flag_t flags,
 						   char *status_msg,
 						   ldl_loop_callback_t loop_callback,
 						   ldl_session_callback_t session_callback,
@@ -1114,20 +1406,44 @@
 {
 	apr_pool_t *pool;
 	assert(ldl_test_flag(&globals, LDL_FLAG_INIT));
-	
+	*handle = NULL;	
 
 	if ((apr_pool_create(&pool, globals.memory_pool)) != LDL_STATUS_SUCCESS) {
 		return LDL_STATUS_MEMERR;
 	}
 
+	if (!login) {
+		globals.logger(DL_LOG_ERR, "No login supplied!\n");
+		return LDL_STATUS_FALSE;
+	}
+
+	if (!password) {
+		globals.logger(DL_LOG_ERR, "No password supplied!\n");
+		return LDL_STATUS_FALSE;
+	}
+	
+
 	if ((*handle = apr_palloc(pool, sizeof(ldl_handle_t)))) {
 		ldl_handle_t *new_handle = *handle;
 		memset(new_handle, 0, sizeof(ldl_handle_t));
 		new_handle->log_stream = globals.log_stream;
 		new_handle->login = apr_pstrdup(pool, login);
 		new_handle->password = apr_pstrdup(pool, password);
-		new_handle->status_msg = apr_pstrdup(pool, status_msg);
 
+		if (server) {
+			char *p;
+
+			new_handle->server = apr_pstrdup(pool, server);
+			if ((p = strchr(new_handle->server, ':'))) {
+				*p++ = '\0';
+				new_handle->port = atoi(p);
+			}
+		}
+
+		if (status_msg) {
+			new_handle->status_msg = apr_pstrdup(pool, status_msg);
+		}
+
 		if (loop_callback) {
 			new_handle->loop_callback = loop_callback;
 		}
@@ -1142,35 +1458,49 @@
 
 		new_handle->private_info = private_info;
 		new_handle->pool = pool;
+		new_handle->flags |= flags;
 		apr_queue_create(&new_handle->queue, LDL_HANDLE_QLEN, new_handle->pool);
 		apr_queue_create(&new_handle->retry_queue, LDL_HANDLE_QLEN, new_handle->pool);
-		new_handle->features |= IKS_STREAM_BIND|IKS_STREAM_SESSION |IKS_STREAM_SASL_PLAIN;
+		new_handle->features |= IKS_STREAM_BIND|IKS_STREAM_SESSION;
+
+		if (new_handle->flags & LDL_FLAG_SASL_PLAIN) {
+			new_handle->features |= IKS_STREAM_SASL_PLAIN;
+		} else if (new_handle->flags & LDL_FLAG_SASL_MD5) {
+			new_handle->features |= IKS_STREAM_SASL_MD5;
+		}
+
 		new_handle->sessions = apr_hash_make(new_handle->pool);
 		new_handle->retry_hash = apr_hash_make(new_handle->pool);
 		new_handle->probe_hash = apr_hash_make(new_handle->pool);
+		new_handle->sub_hash = apr_hash_make(new_handle->pool);
 		apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool);
+		apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool);
 
 		return LDL_STATUS_SUCCESS;
-	} else {
-		*handle = NULL;
-	}
-
+	} 
+	
 	return LDL_STATUS_FALSE;
 }
 
 void ldl_handle_run(ldl_handle_t *handle)
 {
-	ldl_set_flag(handle, LDL_FLAG_RUNNING);
+	ldl_set_flag_locked(handle, LDL_FLAG_RUNNING);
 	xmpp_connect(handle, handle->login, handle->password);
-	ldl_clear_flag(handle, LDL_FLAG_RUNNING);
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
 }
 
+void ldl_handle_stop(ldl_handle_t *handle)
+{
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
+}
+
 ldl_status ldl_handle_destroy(ldl_handle_t **handle)
 {
 	apr_pool_t *pool = (*handle)->pool;
 
 	ldl_flush_queue(*handle);
 	
+
 	apr_pool_destroy(pool);
 	*handle = NULL;
 	return LDL_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.h	(original)
+++ freeswitch/branches/voctel/libs/libdingaling/src/libdingaling.h	Fri Sep 22 14:22:15 2006
@@ -53,6 +53,8 @@
 
 /*! \brief A structure to store a jingle candidate */
 struct ldl_candidate {
+	/*! the transport id of the candidate */
+	char *tid;
 	/*! the name of the candidate */
 	char *name;
 	/*! the type of the candidate */
@@ -80,6 +82,8 @@
 	unsigned int id;
 	/*! the transfer rate of the payload type */
 	unsigned int rate;
+	/*! the bits per second of the payload type */
+	unsigned int bps;
 };
 typedef struct ldl_payload ldl_payload_t;
 
@@ -99,16 +103,28 @@
 	LDL_FLAG_INIT = (1 << 0),
 	LDL_FLAG_RUNNING = (1 << 1),
 	LDL_FLAG_AUTHORIZED = (1 << 2),
-	LDL_FLAG_READY = (1 << 3)
+	LDL_FLAG_READY = (1 << 3),
+	LDL_FLAG_CONNECTED = (1 << 4),
+	LDL_FLAG_QUEUE_RUNNING = (1 << 5),
 } ldl_flag_t;
 
 typedef enum {
+	LDL_FLAG_TLS = (1 << 10),
+	LDL_FLAG_SASL_PLAIN = (1 << 11),
+	LDL_FLAG_SASL_MD5 = (1 << 12)
+} ldl_user_flag_t;
+
+typedef enum {
 	LDL_SIGNAL_NONE,
 	LDL_SIGNAL_INITIATE,
 	LDL_SIGNAL_CANDIDATES,
 	LDL_SIGNAL_MSG,
 	LDL_SIGNAL_TERMINATE,
-	LDL_SIGNAL_ERROR
+	LDL_SIGNAL_ERROR,
+	LDL_SIGNAL_LOGIN_SUCCESS,
+	LDL_SIGNAL_LOGIN_FAILURE,
+	LDL_SIGNAL_CONNECTED,
+	LDL_SIGNAL_TRANSPORT_ACCEPT
 } ldl_signal_t;
 
 typedef enum {
@@ -138,7 +154,7 @@
 #define DL_LOG_EMERG DL_PRE, 0
 
 typedef ldl_status (*ldl_loop_callback_t)(ldl_handle_t *);
-typedef ldl_status (*ldl_session_callback_t)(ldl_handle_t *, ldl_session_t *, ldl_signal_t, char *);
+typedef ldl_status (*ldl_session_callback_t)(ldl_handle_t *, ldl_session_t *, ldl_signal_t, char *, char *, char *);
 typedef ldl_status (*ldl_response_callback_t)(ldl_handle_t *, char *);
 typedef void (*ldl_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...);
 
@@ -168,6 +184,23 @@
 #define ldl_clear_flag(obj, flag) (obj)->flags &= ~(flag)
 
 /*!
+  \brief Set a flag on an arbitrary object while locked
+  \param obj the object to set the flags on
+  \param flag the or'd list of flags to set
+*/
+#define ldl_set_flag_locked(obj, flag) assert(obj->flag_mutex != NULL);\
+apr_thread_mutex_lock(obj->flag_mutex);\
+(obj)->flags |= (flag);\
+apr_thread_mutex_unlock(obj->flag_mutex);
+
+/*!
+  \brief Clear a flag on an arbitrary object
+  \param obj the object to test
+  \param flag the or'd list of flags to clear
+*/
+#define ldl_clear_flag_locked(obj, flag) apr_thread_mutex_lock(obj->flag_mutex); (obj)->flags &= ~(flag); apr_thread_mutex_unlock(obj->flag_mutex);
+
+/*!
   \brief Copy flags from one arbitrary object to another
   \param dest the object to copy the flags to
   \param src the object to copy the flags from
@@ -190,6 +223,22 @@
 ldl_status ldl_session_destroy(ldl_session_t **session_p);
 
 /*!
+  \brief Get a value from a session
+  \param session the session
+  \param key the key to look up
+  \return the value
+*/
+char *ldl_session_get_value(ldl_session_t *session, char *key);
+
+/*!
+  \brief Set a value on a session
+  \param session the session
+  \param key the key to set
+  \param val the value of the key
+*/
+void ldl_session_set_value(ldl_session_t *session, char *key, char *val);
+
+/*!
   \brief Create a Jingle Session
   \param session_p pointer to reference the session
   \param handle handle to associate the session with
@@ -243,6 +292,13 @@
 void *ldl_session_get_private(ldl_session_t *session);
 
 /*!
+  \brief Accept a candidate
+  \param session the session to accept on
+  \param candidate the candidate to accept
+*/
+void ldl_session_accept_candidate(ldl_session_t *session, ldl_candidate_t *candidate);
+
+/*!
   \brief Set a custom logger
   \param logger the logger function
 */
@@ -273,6 +329,24 @@
 void *ldl_handle_get_private(ldl_handle_t *handle);
 
 /*!
+  \brief Send a message to a session
+  \param session the session handle
+  \param to the message recipiant
+  \param subject optional subject
+  \param body body of the message
+*/
+void ldl_session_send_msg(ldl_session_t *session, char *subject, char *body);
+
+/*!
+  \brief Send a message
+  \param handle the conection handle
+  \param to the message recipiant
+  \param subject optional subject
+  \param body body of the message
+*/
+void ldl_handle_send_msg(ldl_handle_t *handle, char *to, char *subject, char *body);
+
+/*!
   \brief Offer candidates to a potential session
   \param session the session to send candidates on
   \param candidates an array of candidate description objects
@@ -359,6 +433,8 @@
 ldl_status ldl_handle_init(ldl_handle_t **handle,
 						   char *login,
 						   char *password,
+						   char *server,
+						   ldl_user_flag_t flags,
 						   char *status_msg,
 						   ldl_loop_callback_t loop_callback,
 						   ldl_session_callback_t session_callback,
@@ -370,6 +446,13 @@
   \param handle the Dingaling handle to run
 */
 void ldl_handle_run(ldl_handle_t *handle);
+
+/*!
+  \brief Stop a libDingaLing handle
+  \param handle the Dingaling handle to stop
+*/
+void ldl_handle_stop(ldl_handle_t *handle);
+
 
 /*!
   \brief Destroy a libDingaLing handle

Modified: freeswitch/branches/voctel/libs/libteletone/libteletone.vcproj
==============================================================================
--- freeswitch/branches/voctel/libs/libteletone/libteletone.vcproj	(original)
+++ freeswitch/branches/voctel/libs/libteletone/libteletone.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,7 +17,7 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			CharacterSet="1"
@@ -94,7 +94,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			OutputDirectory="$(ConfigurationName)"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			CharacterSet="1"

Modified: freeswitch/branches/voctel/libs/libteletone/src/libteletone_generate.c
==============================================================================
--- freeswitch/branches/voctel/libs/libteletone/src/libteletone_generate.c	(original)
+++ freeswitch/branches/voctel/libs/libteletone/src/libteletone_generate.c	Fri Sep 22 14:22:15 2006
@@ -30,6 +30,9 @@
  *
  */
 #include <libteletone.h>
+#define SMAX 32767
+#define SMIN -32768
+#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN;
 
 
 
@@ -163,6 +166,7 @@
 			for (i = 0; i < freqlen; i++) {
 				sample += ((teletone_process_t) 2 * (ts->volume > 0 ? ts->volume : 1) * cos(tones[i] * ts->samples * period));
 			}
+			normalize_to_16bit(sample);
 			ts->buffer[ts->samples] = (teletone_audio_t)sample;
 			
 			for (c = 1; c < ts->channels; c++) {

Modified: freeswitch/branches/voctel/libs/mozilla.build.sh
==============================================================================
--- freeswitch/branches/voctel/libs/mozilla.build.sh	(original)
+++ freeswitch/branches/voctel/libs/mozilla.build.sh	Fri Sep 22 14:22:15 2006
@@ -5,7 +5,7 @@
 opts="--enable-64bit"
 fi
 
-cd nsprpub && ./configure $opts && make
+cd nsprpub && ./configure $opts && $MAKE
 
-cd ../js/src && JS_THREADSAFE=1 OTHER_LIBS="-L../../../mozilla/nsprpub/dist/lib" INCLUDES="-I../../../mozilla/nsprpub/dist/include/nspr"  make -f Makefile.ref `find . -name libjs.a`
+cd ../js/src && JS_THREADSAFE=1 JS_HAS_FILE_OBJECT=1 OTHER_LIBS="-L../../../mozilla/nsprpub/dist/lib" INCLUDES="-I../../../mozilla/nsprpub/dist/include/nspr"  $MAKE -f Makefile.ref `find . -name libjs.a`
 

Modified: freeswitch/branches/voctel/libs/srtp.build.sh
==============================================================================
--- freeswitch/branches/voctel/libs/srtp.build.sh	(original)
+++ freeswitch/branches/voctel/libs/srtp.build.sh	Fri Sep 22 14:22:15 2006
@@ -7,8 +7,8 @@
 
 ./configure $@ $opts
 
-make clean uninstall all
-make install
+$MAKE clean uninstall all
+$MAKE install
 
 
 

Modified: freeswitch/branches/voctel/libs/srtp/crypto/include/datatypes.h
==============================================================================
--- freeswitch/branches/voctel/libs/srtp/crypto/include/datatypes.h	(original)
+++ freeswitch/branches/voctel/libs/srtp/crypto/include/datatypes.h	Fri Sep 22 14:22:15 2006
@@ -392,21 +392,12 @@
 # define be64_to_cpu(x)	bswap_64((x))
 #else
 
-# ifdef HAVE_X86
-/* Fall back. */
-static inline uint32_t be32_to_cpu(uint32_t v) {
-   /* optimized for x86. */
-   asm("bswap %0" : "=r" (v) : "0" (v));
-   return v;
-}
-# else /* HAVE_X86 */
 #  ifdef HAVE_NETINET_IN_H
 #   include <netinet/in.h>
 #  elif defined HAVE_WINSOCK2_H
 #   include <winsock2.h>
 #  endif
 #  define be32_to_cpu(x)	ntohl((x))
-# endif /* HAVE_X86 */
 
 static inline uint64_t be64_to_cpu(uint64_t v) {
 # ifdef NO_64BIT_MATH

Modified: freeswitch/branches/voctel/modules.conf.in
==============================================================================
--- freeswitch/branches/voctel/modules.conf.in	(original)
+++ freeswitch/branches/voctel/modules.conf.in	Fri Sep 22 14:22:15 2006
@@ -1,33 +1,38 @@
 loggers/mod_console
+loggers/mod_syslog
+applications/mod_dptools
+applications/mod_commands
+applications/mod_conference
 applications/mod_bridgecall
 applications/mod_echo
-#applications/mod_ivrtest
+applications/mod_ivrtest
 applications/mod_playback
-#applications/mod_skel
+applications/mod_skel
+#applications/mod_rss
+#applications/mod_park
 #asr_tts/mod_cepstral
 codecs/mod_g711
+codecs/mod_ilbc
 #codecs/mod_g729
 codecs/mod_gsm
-#codecs/mod_ilbc
 codecs/mod_l16
 #codecs/mod_speex
-dialplans/mod_dialplan_demo
 #dialplans/mod_dialplan_directory
-dialplans/mod_pcre
+dialplans/mod_dialplan_xml
 #directories/mod_ldap
 endpoints/mod_exosip
 endpoints/mod_iax
-#endpoints/mod_dingaling
-#endpoints/mod_opal
-#endpoints/mod_portaudio
+endpoints/mod_dingaling
+endpoints/mod_portaudio
 #endpoints/mod_wanpipe
-#endpoints/mod_woomera
+endpoints/mod_woomera
 #event_handlers/mod_event_multicast
 #event_handlers/mod_event_test
-#event_handlers/mod_xmpp_event
+event_handlers/mod_xmpp_event
 #event_handlers/mod_zeroconf
+#event_handlers/mod_event_socket
 formats/mod_sndfile
 #languages/mod_perl
 #languages/mod_spidermonkey
 timers/mod_softtimer
-
+#xml_int/mod_xml_rpc

Modified: freeswitch/branches/voctel/src/include/switch.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch.h	(original)
+++ freeswitch/branches/voctel/src/include/switch.h	Fri Sep 22 14:22:15 2006
@@ -36,9 +36,14 @@
 #define SWITCH_H
 
 #ifdef __cplusplus
-extern "C" {
+#define SWITCH_BEGIN_EXTERN_C       extern "C" {
+#define SWITCH_END_EXTERN_C         }
+#else
+#define SWITCH_BEGIN_EXTERN_C
+#define SWITCH_END_EXTERN_C
 #endif
 
+
 //Need to include this before any other includes (MSVC Bug)
 #include <switch_platform.h>
 
@@ -47,8 +52,7 @@
 #endif
 
 #include <assert.h>
-
-#include <switch_version.h>
+#include <setjmp.h>
 #include <switch_apr.h>
 #include <switch_sqlite.h>
 #include <switch_types.h>
@@ -67,12 +71,11 @@
 #include <switch_ivr.h>
 #include <switch_rtp.h>
 #include <switch_stun.h>
-#include <switch_stun.h>
 #include <switch_log.h>
-#ifdef __cplusplus
-}
-#endif
+#include <switch_xml.h>
+#include <pcre.h>
 
+
 /** \mainpage FreeSWITCH
  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
 
@@ -96,20 +99,19 @@
  *
  *	Additionally, the experimental external modules make use of several external modules:
  *
- *	mod_Exosip:
- *		- JRTPlib (http://research.edm.luc.ac.be/jori/jrtplib/jrtplib.html)
+ *	mod_exosip:
  *		- eXoSIP (http://savannah.nongnu.org/projects/exosip/)
  *
- *	mod_iaxchan:
+ *	mod_iax:
  *		- libiax2 (forked from http://iaxclient.sourceforge.net/)
  *
- *	mod_speexcodec
+ *	mod_speex
  *		- libspeex (http://www.speex.org/)
  *
  *	mod_portaudio
  *		- portaudio (http://www.portaudio.com/)
  *
- *	mod_woomerachan
+ *	mod_woomera
  *		- openh323/woomera (http://www.voxgratia.org/)
  *
  *	mod_xmpp_event

Modified: freeswitch/branches/voctel/src/include/switch_am_config.h.in
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_am_config.h.in	(original)
+++ freeswitch/branches/voctel/src/include/switch_am_config.h.in	Fri Sep 22 14:22:15 2006
@@ -20,6 +20,15 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Define to 1 if you have the `mlock' function. */
+#undef HAVE_MLOCK
+
+/* Define to 1 if you have the `mlockall' function. */
+#undef HAVE_MLOCKALL
+
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
@@ -54,6 +63,9 @@
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `usleep' function. */
+#undef HAVE_USLEEP
 
 /* Define to 1 if you have the `vasprintf' function. */
 #undef HAVE_VASPRINTF

Modified: freeswitch/branches/voctel/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_apr.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_apr.h	Fri Sep 22 14:22:15 2006
@@ -39,15 +39,12 @@
 #ifndef SWITCH_APR_H
 #define SWITCH_APR_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <apr.h>
 #include <apr_network_io.h>
 #include <apr_errno.h>
 #include <apr_general.h>
 #include <apr_thread_proc.h>
+#include <apr_portable.h>
 #include <apr_thread_mutex.h>
 #include <apr_thread_cond.h>
 #include <apr_thread_rwlock.h>
@@ -66,6 +63,8 @@
 #include <apr_want.h>
 #include <apr_env.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.
@@ -257,6 +256,12 @@
 DoxyDefine(apr_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_pool_t *pool);)
 #define switch_thread_cond_create apr_thread_cond_create
 
+typedef apr_os_thread_t switch_thread_id_t;
+
+#define switch_thread_data_set apr_thread_data_set
+#define switch_thread_data_get apr_thread_data_get
+#define switch_thread_self apr_os_thread_current
+
 /**
  * Put the active calling thread to sleep until signaled to wake up. Each
  * condition variable must be associated with a mutex, and that mutex must
@@ -326,7 +331,7 @@
  */
 
 /** Opaque Thread structure. */
-typedef apr_thread_t switch_thread;
+typedef apr_thread_t switch_thread_t;
 
 /** Opaque Thread attributes structure. */
 typedef apr_threadattr_t switch_threadattr_t;
@@ -651,7 +656,7 @@
 									apr_int32_t flags, 
 									char *buf, 
 									apr_size_t *len);)
-//#define switch_socket_recvfrom apr_socket_recvfrom
+#define switch_socket_recvfrom apr_socket_recvfrom
 
 /**
  * Send a file from an open file descriptor to a socket, along with 
@@ -942,7 +947,7 @@
  * @{
  */
 /** The fundamental pool type */
-typedef apr_pool_t switch_memory_pool;
+typedef apr_pool_t switch_memory_pool_t;
 
 
 /**
@@ -953,7 +958,7 @@
  *         to re-use this memory for the next allocation.
  * @see apr_pool_destroy()
  */
-DoxyDefine(void switch_pool_clear(switch_memory_pool *p);)
+DoxyDefine(void switch_pool_clear(switch_memory_pool_t *p);)
 #define switch_pool_clear apr_pool_clear
 /** @} */
 
@@ -1048,6 +1053,9 @@
  /** number of microseconds since 00:00:00 january 1, 1970 UTC */
 typedef apr_time_t switch_time_t;
 
+ /** number of microseconds in the interval */
+typedef apr_interval_time_t switch_interval_time_t;
+
 /**
  * a structure similar to ANSI struct tm with the following differences:
  *  - tm_usec isn't an ANSI field
@@ -1130,7 +1138,7 @@
  */
 
 /** Abstract type for hash tables. */
-typedef apr_hash_t switch_hash;
+typedef apr_hash_t switch_hash_t;
 
 /** Abstract type for scanning hash tables. */
 typedef apr_hash_index_t switch_hash_index_t;
@@ -1342,6 +1350,20 @@
 DoxyDefine(apr_status_t switch_queue_trypush(switch_queue_t *queue, void *data);)
 #define switch_queue_trypush apr_queue_trypush
 
+/** @} */
+
+
+typedef apr_thread_rwlock_t switch_thread_rwlock_t;
+
+#define switch_thread_rwlock_create apr_thread_rwlock_create
+#define switch_thread_rwlock_destroy apr_thread_rwlock_destroy
+#define switch_thread_rwlock_pool_get apr_thread_rwlock_pool_get
+#define switch_thread_rwlock_rdlock apr_thread_rwlock_rdlock
+#define switch_thread_rwlock_tryrdlock apr_thread_rwlock_tryrdlock
+#define switch_thread_rwlock_trywrlock apr_thread_rwlock_trywrlock
+#define switch_thread_rwlock_unlock apr_thread_rwlock_unlock
+#define switch_thread_rwlock_wrlock apr_thread_rwlock_wrlock
+
 /**
  * @defgroup switch_thread_mutex Thread Mutex Routines
  * @ingroup switch_apr
@@ -1373,16 +1395,16 @@
  * most optimial mutex based on a given platform's performance charateristics,
  * it will behave as either a nested or an unnested lock.
  *
-SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock,
+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock,
 												switch_lock_flag flags,
-												switch_memory_pool *pool);
+												switch_memory_pool_t *pool);
 */
 #define switch_mutex_init apr_thread_mutex_create
 /**
  * Destroy the mutex and free the memory associated with the lock.
  * @param lock the mutex to destroy.
  */
-//SWITCH_DECLARE(switch_status) switch_mutex_destroy(switch_mutex_t *lock);
+//SWITCH_DECLARE(switch_status_t) switch_mutex_destroy(switch_mutex_t *lock);
 #define switch_mutex_destroy apr_thread_mutex_destroy
 
 /**
@@ -1390,14 +1412,14 @@
  * 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) switch_mutex_lock(switch_mutex_t *lock);
+//SWITCH_DECLARE(switch_status_t) switch_mutex_lock(switch_mutex_t *lock);
 #define switch_mutex_lock apr_thread_mutex_lock
 
 /**
  * Release the lock for the given mutex.
  * @param lock the mutex from which to release the lock.
  */
-//SWITCH_DECLARE(switch_status) switch_mutex_unlock(switch_mutex_t *lock);
+//SWITCH_DECLARE(switch_status_t) switch_mutex_unlock(switch_mutex_t *lock);
 #define switch_mutex_unlock apr_thread_mutex_unlock
 
 /**
@@ -1407,14 +1429,13 @@
  * 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) switch_mutex_trylock(switch_mutex_t *lock);
+//SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock);
 #define switch_mutex_trylock apr_thread_mutex_trylock
 
 /** @} */
 /** @} */
+/** @} */
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_buffer.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_buffer.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_buffer.h	Fri Sep 22 14:22:15 2006
@@ -38,12 +38,10 @@
 #ifndef SWITCH_BUFFER_H
 #define SWITCH_BUFFER_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /**
  * @defgroup switch_buffer Buffer Routines
  * @ingroup core1
@@ -62,59 +60,74 @@
  * \param max_len length required by the buffer
  * \return status
  */
-SWITCH_DECLARE(switch_status) switch_buffer_create(switch_memory_pool *pool, switch_buffer **buffer, switch_size_t max_len);
+SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer, switch_size_t max_len);
 
-/*! \brief Get the length of a switch_buffer 
- * \param buffer any buffer of type switch_buffer
+/*! \brief Allocate a new dynamic switch_buffer 
+ * \param buffer returned pointer to the new buffer
+ * \param blocksize length to realloc by as data is added
+ * \param start_len ammount of memory to reserve initially
+ * \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_size_t max_len);
+
+/*! \brief Get the length of a switch_buffer_t 
+ * \param buffer any buffer of type switch_buffer_t
  * \return int size of the buffer.
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_len(switch_buffer *buffer);
+SWITCH_DECLARE(switch_size_t) switch_buffer_len(switch_buffer_t *buffer);
 
-/*! \brief Get the freespace of a switch_buffer 
- * \param buffer any buffer of type switch_buffer
+/*! \brief Get the freespace of a switch_buffer_t 
+ * \param buffer any buffer of type switch_buffer_t
  * \return int freespace in the buffer.
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_freespace(switch_buffer *buffer);
+SWITCH_DECLARE(switch_size_t) switch_buffer_freespace(switch_buffer_t *buffer);
 
-/*! \brief Get the in use amount of a switch_buffer 
- * \param buffer any buffer of type switch_buffer
+/*! \brief Get the in use amount of a switch_buffer_t 
+ * \param buffer any buffer of type switch_buffer_t
  * \return int ammount of buffer curently in use
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_inuse(switch_buffer *buffer);
+SWITCH_DECLARE(switch_size_t) switch_buffer_inuse(switch_buffer_t *buffer);
 
-/*! \brief Read data from a switch_buffer up to the ammount of datalen if it is available.  Remove read data from buffer. 
- * \param buffer any buffer of type switch_buffer
+/*! \brief Read data from a switch_buffer_t up to the ammount of datalen if it is available.  Remove read data from buffer. 
+ * \param buffer any buffer of type switch_buffer_t
  * \param data pointer to the read data to be returned
  * \param datalen amount of data to be returned
  * \return int ammount of data actually read
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer *buffer, void *data, switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *data, switch_size_t datalen);
 
-/*! \brief Write data into a switch_buffer up to the length of datalen
- * \param buffer any buffer of type switch_buffer
+/*! \brief Write data into a switch_buffer_t up to the length of datalen
+ * \param buffer any buffer of type switch_buffer_t
  * \param data pointer to the data to be written
  * \param datalen amount of data to be written
  * \return int amount of buffer used after the write, or 0 if no space available
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer *buffer, void *data, switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void *data, switch_size_t datalen);
 
 /*! \brief Remove data from the buffer
- * \param buffer any buffer of type switch_buffer
+ * \param buffer any buffer of type switch_buffer_t
  * \param datalen amount of data to be removed
  * \return int size of buffer, or 0 if unable to toss that much data
  */
-SWITCH_DECLARE(switch_size_t) switch_buffer_toss(switch_buffer *buffer, switch_size_t datalen);
+SWITCH_DECLARE(switch_size_t) switch_buffer_toss(switch_buffer_t *buffer, switch_size_t datalen);
 
 /*! \brief Remove all data from the buffer
- * \param buffer any buffer of type switch_buffer
+ * \param buffer any buffer of type switch_buffer_t
  */
-SWITCH_DECLARE(void) switch_buffer_zero(switch_buffer *buffer);
-/** @} */
+SWITCH_DECLARE(void) switch_buffer_zero(switch_buffer_t *buffer);
 
+/*! \brief Destroy the buffer
+ * \param buffer buffer to destroy
+ * \note only neccessary on dynamic buffers (noop on pooled ones)
+ */
+SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer);
 
-#ifdef __cplusplus
-}
-#endif
+/** @} */
 
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_caller.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_caller.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_caller.h	Fri Sep 22 14:22:15 2006
@@ -53,18 +53,15 @@
 #ifndef SWITCH_CALLER_H
 #define SWITCH_CALLER_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef _FORMATBUG
-}
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /*! \brief Call Specific Data
  */
 struct switch_caller_profile {
+	/*! The Call's User Name */
+	char *username;
 	/*! The name of the dialplan */
 	char *dialplan;
 	/*! Caller ID Name */
@@ -77,12 +74,19 @@
 	char *ani;
 	/*! ANI II (when applicable) */
 	char *ani2;
+	/*! RDNIS */
+	char *rdnis;
 	/*! Destination Number */
 	char *destination_number;
+	/*! channel type */
+	char *source;
 	/*! channel name */
 	char *chan_name;
 	/*! unique id */
 	char *uuid;
+	/*! context */
+	char *context;
+	struct switch_caller_profile *next;
 };
 
 /*! \brief An Abstract Representation of a dialplan Application */
@@ -92,7 +96,7 @@
 	/*! An optional argument string to pass to the application */
 	char *application_data;
 	/*! A function pointer to the application */
-	switch_application_function application_function;
+	switch_application_function_t application_function;
 	struct switch_caller_application *next;
 };
 
@@ -103,11 +107,12 @@
 	/*! The number of the extension */
 	char *extension_number;
 	/*! Pointer to the current application for this extension */
-	struct switch_caller_application *current_application;
+	switch_caller_application_t *current_application;
 	/*! Pointer to the last application for this extension */
-	struct switch_caller_application *last_application;
+	switch_caller_application_t *last_application;
 	/*! Pointer to the entire stack of applications for this extension */
-	struct switch_caller_application *applications;
+	switch_caller_application_t *applications;
+	struct switch_caller_extension *next;
 };
 
 /*!
@@ -117,7 +122,7 @@
   \param extension_number extension number
   \return a new extension object allocated from the session's memory pool
 */
-SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
+SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session,
 																	  char *extension_name,
 																	  char *extension_number
 																	  );
@@ -129,32 +134,48 @@
   \param application_name the name of the application
   \param extra_data optional argument to the application
 */
-SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
-															 switch_caller_extension *caller_extension,
+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);
 
 
 /*!
+  \brief Get the value of a field in a caller profile based on it's name
+  \param caller_profile The caller profile
+  \param name the name
+  \note this function is meant for situations where the name paramater is the contents of the variable
+*/
+SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name);
+
+/*!
   \brief Create a new caller profile object
   \param pool memory pool to use
+  \param username tne username of the caller
   \param dialplan name of the dialplan module in use
   \param caller_id_name caller ID name
   \param caller_id_number caller ID number
   \param network_addr network address
   \param ani ANI information
   \param ani2 ANI II information
+  \param rdnis RDNIS
+  \param source the source 
+  \param context a logical context
   \param destination_number destination number
   \return a new profile object allocated from the session's memory pool
 */
-SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_memory_pool *pool,
-																  char *dialplan,
-																  char *caller_id_name,
-																  char *caller_id_number,
-																  char *network_addr,
-																  char *ani,
-																  char *ani2,
-																  char *destination_number);
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memory_pool_t *pool,
+																	char *username,
+																	char *dialplan,
+																	char *caller_id_name,
+																	char *caller_id_number,
+																	char *network_addr,
+																	char *ani,
+																	char *ani2,
+																	char *rdnis,
+																	char *source,
+																	char *context,
+																	char *destination_number);
 
 /*!
   \brief Clone an existing caller profile object
@@ -162,8 +183,8 @@
   \param tocopy the existing profile
 */
 	
-SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
-																	switch_caller_profile *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
@@ -172,12 +193,9 @@
   \param event the event to add the information to
 */
 
-SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event);
+SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix, switch_event_t *event);
 
-
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 /** @} */
 

Modified: freeswitch/branches/voctel/src/include/switch_channel.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_channel.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_channel.h	Fri Sep 22 14:22:15 2006
@@ -38,18 +38,19 @@
 #ifndef SWITCH_CHANNEL_H
 #define SWITCH_CHANNEL_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
-typedef struct {
+SWITCH_BEGIN_EXTERN_C
+
+struct switch_channel_timetable {
 	switch_time_t created;
 	switch_time_t answered;
 	switch_time_t hungup;
-} switch_channel_timetable_t;
+	struct switch_channel_timetable *next;
+};
 
+typedef struct switch_channel_timetable switch_channel_timetable_t;
+
 /**
  * @defgroup switch_channel Channel Functions
  * @ingroup core1
@@ -63,37 +64,65 @@
   \param channel channel to retrieve state from
   \return current state of channel
 */
-SWITCH_DECLARE(switch_channel_state) switch_channel_get_state(switch_channel *channel);
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_state(switch_channel_t *channel);
 
 /*!
   \brief Determine if a channel is ready for io
   \param channel channel to test
   \return true if the channel is ready
 */
-SWITCH_DECLARE(unsigned int) switch_channel_ready(switch_channel *channel);
+SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel);
 
+
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
+																	  const char *file,
+																	  const char *func,
+																	  int line,
+																	  switch_channel_state_t state);
+
 /*!
   \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
 */	
-SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
+#define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __FUNCTION__, __LINE__, state)
 
 /*!
+  \brief return a cause code for a given string
+  \param str the string to check
+  \return the code
+*/
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(char *str);
+
+/*!
+  \brief return the cause code for a given channel
+  \param channel the channel
+  \return the code
+*/
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel);
+
+/*!
+  \brief return a cause string for a given cause
+  \param cause the code to check
+  \return the string
+*/
+SWITCH_DECLARE(char *) switch_channel_cause2str(switch_call_cause_t cause);
+
+/*!
   \brief View the timetable of a channel
   \param channel channel to retrieve timetable from
-  \returns a pointer to the channel's timetable (created, answered, etc..)
+  \return a pointer to the channel's timetable (created, answered, etc..)
 */
-SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel *channel);
+SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel_t *channel);
 
 /*!
   \brief Allocate a new channel
   \param channel NULL pointer to allocate channel to
   \param pool memory_pool to use for allocation
-  \returns SWITCH_STATUS_SUCCESS if successful
+  \return SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_memory_pool_t *pool);
 
 /*!
   \brief Connect a newly allocated channel to a session object and setup it's initial state
@@ -102,52 +131,58 @@
   \param state the initial state of the channel
   \param flags the initial channel flags
 */
-SWITCH_DECLARE(switch_status) switch_channel_init(switch_channel *channel,
-								switch_core_session *session,
-								switch_channel_state state,
+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 Uninitalize a channel
+  \param channel the channel to uninit
+*/
+SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel);
+
+/*!
   \brief Set the given channel's caller profile
   \param channel channel to assign the profile to
   \param caller_profile the profile to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
+SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
 
 /*!
   \brief Retrive the given channel's caller profile
   \param channel channel to retrive the profile from
   \return the requested profile
 */
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch_channel *channel);
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(switch_channel_t *channel);
 
 /*!
   \brief Set the given channel's originator caller profile
   \param channel channel to assign the profile to
   \param caller_profile the profile to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
+SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
 
 /*!
   \brief Retrive the given channel's originator caller profile
   \param channel channel to retrive the profile from
   \return the requested profile
 */
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel);
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_profile(switch_channel_t *channel);
 
 /*!
   \brief Set the given channel's originatee caller profile
   \param channel channel to assign the profile to
   \param caller_profile the profile to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
+SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
 
 /*!
   \brief Retrive the given channel's originatee caller profile
   \param channel channel to retrive the profile from
   \return the requested profile
 */
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel);
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originatee_caller_profile(switch_channel_t *channel);
 
 
 /*!
@@ -155,7 +190,7 @@
   \param channel channel to retrive the unique id from
   \return the unique id
 */
-SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel *channel);
+SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel);
 
 /*!
   \brief Set a variable on a given channel
@@ -164,7 +199,7 @@
   \param value the vaule of the variable
   \returns SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status) switch_channel_set_variable(switch_channel *channel, char *varname, char *value);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value);
 
 /*!
   \brief Retrieve a variable from a given channel
@@ -172,21 +207,30 @@
   \param varname the name of the variable
   \return the value of the requested variable
 */
-SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname);
+SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname);
 
 /*!
+ * Start iterating over the entries in the channel variable list.
+ * @param channel the channel to intterate the variales for
+ * @param pool The pool to allocate the switch_hash_index_t iterator. If this
+ *          pool is NULL, then an internal, non-thread-safe iterator is used.
+ * @remark  Use switch_hash_next and switch_hash_this with this function to iterate all the channel variables
+ */
+SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool);
+
+/*!
   \brief Assign a caller extension to a given channel
   \param channel channel to assign extension to
   \param caller_extension extension to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension);
+SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension);
 
 /*!
   \brief Retrieve caller extension from a given channel
   \param channel channel to retrieve extension from
   \return the requested extension
 */
-SWITCH_DECLARE(switch_caller_extension *) switch_channel_get_caller_extension(switch_channel *channel);
+SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_caller_extension(switch_channel_t *channel);
 
 /*!
   \brief Test for presence of given flag(s) on a given channel
@@ -194,35 +238,52 @@
   \param flags or'd list of channel flags to test
   \return TRUE if flags were present
 */
-SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel *channel, switch_channel_flag flags);
+SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags);
 
 /*!
   \brief Set given flag(s) on a given channel
   \param channel channel on which to set flag(s)
   \param flags or'd list of flags to set
 */
-SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel *channel, switch_channel_flag flags);
+SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flags);
 
 /*!
+  \brief Set given flag(s) on a given channel to be applied on the next state change
+  \param channel channel on which to set flag(s)
+  \param flags or'd list of flags to set
+*/
+SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags);
+
+/*!
   \brief Clear given flag(s) from a channel
   \param channel channel to clear flags from
   \param flags or'd list of flags to clear
 */
-SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel *channel, switch_channel_flag flags);
+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);
 /*!
   \brief Answer a channel (initiate/acknowledge a successful connection)
   \param channel channel to answer
   \return SWITCH_STATUS_SUCCESS if channel was answered successfully
 */
-SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel);
+#define switch_channel_answer(channel) switch_channel_perform_answer(channel, __FILE__, __FUNCTION__, __LINE__)
 
+
+
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(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
-*/
-SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel);
+*/								
+#define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __FUNCTION__, __LINE__)
 
 /*!
   \brief add a state handler table to a given channel
@@ -230,30 +291,39 @@
   \param state_handler table of state handler functions
   \return the index number/priority of the table negative value indicates failure
 */
-SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel *channel, const switch_state_handler_table *state_handler);
+SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler);
 
 /*!
+  \brief clear a state handler table from a given channel
+  \param channel channel from which to clear the state handler table
+  \param state_handler table of state handler functions
+*/
+SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler);
+
+/*!
   \brief Retrieve an state handler tablefrom a given channel at given index level
   \param channel channel from which to retrieve the state handler table
   \param index the index of the state handler table (start from 0)
   \return given channel's state handler table at given index or NULL if requested index does not exist.
 */
-SWITCH_DECLARE(const switch_state_handler_table *) switch_channel_get_state_handler(switch_channel *channel, int index);
+SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel, int index);
 
 /*!
   \brief Set private data on channel
   \param channel channel on which to set data
+  \param key unique keyname to associate your private data to
   \param private_info void pointer to private data
   \return SWITCH_STATUS_SUCCESS if data was set
 */
-SWITCH_DECLARE(switch_status) switch_channel_set_private(switch_channel *channel, void *private_info);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, char *key, void *private_info);
 
 /*!
   \brief Retrieve private from a given channel
   \param channel channel to retrieve data from
+  \param key unique keyname to retrieve your private data
   \return void pointer to channel's private data
 */
-SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel *channel);
+SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key);
 
 /*!
   \brief Assign a name to a given channel
@@ -261,28 +331,36 @@
   \param name name to assign
   \return SWITCH_STATUS_SUCCESS if name was assigned
 */
-SWITCH_DECLARE(switch_status) switch_channel_set_name(switch_channel *channel, char *name);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, char *name);
 
 /*!
   \brief Retrieve the name of a given channel
   \param channel channel to get name of
   \return the channel's name
 */
-SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel);
+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);
+
 /*!
   \brief Hangup a channel flagging it's state machine to end
   \param channel channel to hangup
+  \param hangup_cause the appropriate hangup cause
   \return the resulting channel state.
 */
-SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel);
+#define switch_channel_hangup(channel, hangup_cause) switch_channel_perform_hangup(channel, __FILE__, __FUNCTION__, __LINE__, hangup_cause)
 
 /*!
   \brief Test for presence of DTMF on a given channel
   \param channel channel to test
   \return number of digits in the queue
 */
-SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel *channel);
+SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel);
 
 /*!
   \brief Queue DTMF on a given channel
@@ -290,7 +368,7 @@
   \param dtmf string of digits to queue
   \return SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status) switch_channel_queue_dtmf(switch_channel *channel, char *dtmf);
+SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, char *dtmf);
 
 /*!
   \brief Retrieve DTMF digits from a given channel
@@ -299,30 +377,35 @@
   \param len max size in bytes of the buffer
   \return number of bytes read into the buffer
 */
-SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf(switch_channel *channel, char *dtmf, switch_size_t len);
+SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf(switch_channel_t *channel, char *dtmf, switch_size_t len);
 
 /*!
   \brief Render the name of the provided state enum
   \param state state to get name of
   \return the string representation of the state
 */
-SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state state);
+SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t state);
 
 /*!
+  \brief Render the enum of the provided state name
+  \param name the name of the state
+  \return the enum value (numeric)
+*/
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name);
+
+/*!
   \brief Add information about a given channel to an event object
   \param channel channel to add information about
   \param event event to add information to
 */
-SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event);
+SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event);
 
 
 // These may go away
-SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode (switch_channel *channel, int freq, int bits, int channels, int ms, int kbps);
-SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode (switch_channel *channel, int *freq, int *bits, int *channels, int *ms, int *kbps);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_raw_mode (switch_channel_t *channel, int freq, int bits, int channels, int ms, int kbps);
+SWITCH_DECLARE(switch_status_t) switch_channel_get_raw_mode (switch_channel_t *channel, int *freq, int *bits, int *channels, int *ms, int *kbps);
 /** @} */
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_config.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_config.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_config.h	Fri Sep 22 14:22:15 2006
@@ -56,12 +56,10 @@
 #ifndef SWITCH_CONFIG_H
 #define SWITCH_CONFIG_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /*! \brief A simple file handle representing an open configuration file **/
 struct switch_config {
 	/*! FILE stream buffer to the opened file */
@@ -86,29 +84,28 @@
 
 /*!
   \brief Open a configuration file
-  \param cfg (switch_config *) config handle to use
+  \param cfg (switch_config_t *) config handle to use
   \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 *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 *) config handle to use
+  \param cfg (switch_config_t *) config handle to use
 */
-SWITCH_DECLARE(void) switch_config_close_file(switch_config *cfg);
+SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg);
 
 /*!
   \brief Retrieve next name/value pair from configuration file
-  \param cfg (switch_config *) config handle to use
+  \param cfg (switch_config_t *) config handle to use
   \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 *cfg, char **var, char **val);
+SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val);
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
+
 /** @} */
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_console.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_console.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_console.h	Fri Sep 22 14:22:15 2006
@@ -39,12 +39,21 @@
 #ifndef SWITCH_CONSOLE_H
 #define SWITCH_CONSOLE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+#define SWITCH_CMD_CHUNK_LEN 1024
+#define SWITCH_STANDARD_STREAM(s) if ((s.data = (char *)malloc(SWITCH_CMD_CHUNK_LEN))) { \
+		memset(s.data, 0, SWITCH_CMD_CHUNK_LEN);						\
+		s.end = s.data;\
+		s.data_size = SWITCH_CMD_CHUNK_LEN;\
+		s.write_function = switch_console_stream_write;\
+		s.alloc_len = SWITCH_CMD_CHUNK_LEN;\
+		s.alloc_chunk = SWITCH_CMD_CHUNK_LEN;\
+	}
+
+ 
+
 /*!
   \brief A simple comand loop that reads input from the terminal
 */
@@ -53,10 +62,12 @@
 /*!
   \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 channel, char *file, const char *func, int line, char *fmt, ...);
+SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, ...);
 
-#ifdef __cplusplus
-}
-#endif
+/*!
+  \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, char *fmt, ...);
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_core.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_core.h	Fri Sep 22 14:22:15 2006
@@ -38,24 +38,29 @@
 #ifndef SWITCH_CORE_H
 #define SWITCH_CORE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef _FORMATBUG
-}
-#endif
-
 #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;
+	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)*/
 	char *from;
 	/*! enumeration of the type of message */
-	switch_core_session_message_t message_id;
+	switch_core_session_message_types_t message_id;
 
 	/*! optional numeric arg*/
 	int numeric_arg;
@@ -84,41 +89,156 @@
 struct switch_core_thread_session {
 	/*! status of the thread */
 	int running;
+	/*! mutex */
+	switch_mutex_t *mutex;
 	/*! 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_memory_pool *pool;
+	switch_memory_pool_t *pool;
 };
 
 struct switch_core_session;
 struct switch_core_runtime;
+struct switch_core_port_allocator;
 
-
 /*!
   \defgroup core1 Core Library 
   \ingroup FREESWITCH
   \{ 
 */
 
+
+///\defgroup mb1 Media Bugs
+///\ingroup core1
+///\{
+
+/*!
+  \brief Add a media bug to the session
+  \param session the session to add the bug to
+  \param callback a callback for events
+  \param user_data arbitrary user data
+  \param new_bug pointer to assign new bug to
+  \return SWITCH_STATUS_SUCCESS if the operation was a success
+*/
+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_t **new_bug);
+
+
+/*!
+  \brief Remove a media bug from the session
+  \param session the session to remove the bug from
+  \param bug bug to remove
+  \return SWITCH_STATUS_SUCCESS if the operation was a success
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, 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
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all(switch_core_session_t *session);
+
+/*!
+  \brief Read a frame from the bug
+  \param bug the bug to read from
+  \param frame the frame to write the data to
+  \return the amount of data 
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame);
+
+///\}
+
+///\defgroup pa1 Port Allocation
+///\ingroup core1
+///\{
+
+/*!
+  \brief Initilize the port allocator
+  \param start the starting port
+  \param end the ending port
+  \param inc the amount to increment each port
+  \param new_allocator new pointer for the return value
+  \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);
+
+/*!
+  \brief Get a port from the port allocator
+  \param alloc the allocator object
+  \return the port
+*/
+SWITCH_DECLARE(switch_port_t) switch_core_port_allocator_request_port(switch_core_port_allocator_t *alloc);
+
+/*!
+  \brief destroythe port allocator
+  \param alloc the allocator object
+*/
+SWITCH_DECLARE(void) switch_core_port_allocator_destroy(switch_core_port_allocator_t **alloc);
+///\}
+
 ///\defgroup ss Startup/Shutdown
 ///\ingroup core1
 ///\{
 /*! 
   \brief Initilize the core
   \param console optional FILE stream for output
+  \param err a pointer to set any errors to
   \note to be called at application startup
 */
-SWITCH_DECLARE(switch_status) switch_core_init(char *console);
+SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err);
 
 /*! 
+  \brief Initilize the core and load modules
+  \param console optional FILE stream for output
+  \param err a pointer to set any errors to
+  \note to be called at application startup instead of switch_core_init.  Includes module loading.
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(char *console, const char **err);
+
+/*! 
+  \brief Set/Get Session Limit
+  \param new_limit new value (if > 0)
+  \return the current session limit
+*/
+SWITCH_DECLARE(uint32_t) switch_core_session_limit(uint32_t new_limit);
+
+/*! 
   \brief Destroy the core
   \note to be called at application shutdown
 */
-SWITCH_DECLARE(switch_status) switch_core_destroy(void);
+SWITCH_DECLARE(switch_status_t) switch_core_destroy(void);
 ///\}
 
 
+///\defgroup rwl Read/Write Locking
+///\ingroup core1
+///\{
+/*! 
+  \brief Acquire a read lock on the session
+  \param session the session to acquire from
+  \return success if it is safe to read from the session
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_session_t *session);
 
+/*! 
+  \brief Acquire a write lock on the session
+  \param session the session to acquire from
+*/
+SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session);
+
+/*! 
+  \brief Unlock a read or write lock on as given session
+  \param session the session
+*/
+SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session);
+///\}
+
 ///\defgroup sh State Handlers
 ///\ingroup core1
 ///\{
@@ -127,14 +247,14 @@
   \param state_handler a state handler to add
   \return the current index/priority of this handler
 */
-SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_table *state_handler);
+SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_table_t *state_handler);
 
 /*! 
   \brief Access a state handler
   \param index the desired index to access
   \return the desired state handler table or NULL when it does not exist.
 */
-SWITCH_DECLARE(const switch_state_handler_table *) switch_core_get_state_handler(int index);
+SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handler(int index);
 ///\}
 
 
@@ -145,25 +265,25 @@
   \brief Create a new sub memory pool from the core's master pool
   \return SWITCH_STATUS_SUCCESS on success
 */
-SWITCH_DECLARE(switch_status) switch_core_new_memory_pool(switch_memory_pool **pool);
+SWITCH_DECLARE(switch_status_t) switch_core_new_memory_pool(switch_memory_pool_t **pool);
 
 /*! 
   \brief Returns a subpool back to the main pool
   \return SWITCH_STATUS_SUCCESS on success
 */
-SWITCH_DECLARE(switch_status) switch_core_destroy_memory_pool(switch_memory_pool **pool);
+SWITCH_DECLARE(switch_status_t) switch_core_destroy_memory_pool(switch_memory_pool_t **pool);
 
 /*! 
   \brief Start the session's state machine
   \param session the session on which to start the state machine
 */
-SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session);
+SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session);
 
 /*! 
   \brief determine if the session's state machine is running
   \param session the session on which to check
 */
-SWITCH_DECLARE(unsigned int) switch_core_session_runing(switch_core_session *session);
+SWITCH_DECLARE(unsigned int) switch_core_session_running(switch_core_session_t *session);
 
 /*! 
   \brief Allocate memory from the main pool with no intention of returning it
@@ -171,7 +291,7 @@
   \return a void pointer to the allocated memory
   \note this memory never goes out of scope until the core is destroyed
 */
-SWITCH_DECLARE(void *) switch_core_permenant_alloc(switch_size_t memory);
+SWITCH_DECLARE(void *) switch_core_permanent_alloc(switch_size_t memory);
 
 /*! 
   \brief Allocate memory directly from a memory pool
@@ -179,7 +299,7 @@
   \param memory the number of bytes to allocate
   \return a void pointer to the allocated memory
 */
-SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool *pool, switch_size_t memory);
+SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool_t *pool, switch_size_t memory);
 
 /*! 
   \brief Allocate memory from a session's pool
@@ -188,14 +308,14 @@
   \return a void pointer to the newly allocated memory
   \note the memory will be in scope as long as the session exists
 */
-SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session *session, switch_size_t memory);
+SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session_t *session, switch_size_t memory);
 
 /*! 
-  \brief Copy a string using permenant memory allocation
+  \brief Copy a string using permanent memory allocation
   \param todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup);
+SWITCH_DECLARE(char *) switch_core_permanent_strdup(char *todup);
 
 /*! 
   \brief Copy a string using memory allocation from a session's pool
@@ -203,7 +323,7 @@
   \param todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session, char *todup);
+SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session, char *todup);
 
 /*! 
   \brief Copy a string using memory allocation from a given pool
@@ -211,7 +331,7 @@
   \param todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
+SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, char *todup);
 
 /*! 
   \brief Retrieve the memory pool from a session
@@ -219,7 +339,7 @@
   \return the session's pool
   \note to be used sparingly
 */
-SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
+SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_session_t *session);
 ///\}
 
 ///\defgroup sessm Session Creation / Management
@@ -231,62 +351,75 @@
   \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 *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface, switch_memory_pool *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
   \param session pointer to a pointer of the session to destroy
   \return
 */
-SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session);
+SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session_t **session);
 
 /*! 
+  \brief Provide the total number of sessions
+  \return the total number of allocated sessions
+*/
+SWITCH_DECLARE(uint32_t) switch_core_session_count(void);
+
+/*! 
   \brief Allocate and return a new session from the core based on a given endpoint module name
   \param endpoint_name the name of the endpoint module
   \param pool the pool to use
   \return the newly created session
 */
-SWITCH_DECLARE(switch_core_session *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool *pool);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t *pool);
 
 /*! 
   \brief Launch the session thread (state machine) on a given session
   \param session the session to activate the state machine on
 */
-SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *session);
+SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session_t *session);
 
 /*! 
   \brief Retrieve a pointer to the channel object associated with a given session
   \param session the session to retrieve from
   \return a pointer to the channel object
 */
-SWITCH_DECLARE(switch_channel *) switch_core_session_get_channel(switch_core_session *session);
+SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_session_t *session);
 
 /*! 
   \brief Signal a session's state machine thread that a state change has occured
 */
-SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session *session);
+SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session_t *session);
 
 /*! 
   \brief Retrieve the unique identifier from a session
   \param session the session to retrieve the uuid from
   \return a string representing the uuid
 */
-SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session);
+SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session_t *session);
 
 /*! 
   \brief Locate a session based on it's uuiid
   \param uuid_str the unique id of the session you want to find
   \return the session or NULL
+  \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
 */
-SWITCH_DECLARE(switch_core_session *) switch_core_session_locate(char *uuid_str);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str);
 
 /*! 
+  \brief Hangup All Sessions
+  \param cause the hangup cause to apply to the hungup channels
+*/
+SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause);
+
+/*! 
   \brief Send a message to another session using it's uuid
   \param uuid_str the unique id of the session you want to send a message to
-  \param message the switch_core_session_message object to send
+  \param message the switch_core_session_message_t object to send
   \return the status returned by the message handler
 */
-SWITCH_DECLARE (switch_status) switch_core_session_message_send(char *uuid_str, switch_core_session_message *message);
+SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message);
 
 /*! 
   \brief Queue an event on another session using its uuid
@@ -294,14 +427,22 @@
   \param event the event to send
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status) switch_core_session_event_send(char *uuid_str, switch_event *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event);
 
 /*! 
+  \brief Send an event to a session translating it to it's native message format
+  \param session the session to receive the event
+  \param event the event to receive
+  \return the status returned by the handler
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event);
+
+/*! 
   \brief Retrieve private user data from a session
   \param session the session to retrieve from
   \return a pointer to the private data
 */
-SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session);
+SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session_t *session);
 
 /*! 
   \brief Add private user data to a session
@@ -309,7 +450,7 @@
   \param private_info the used data to add
   \return SWITCH_STATUS_SUCCESS if data is added
 */
-SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_session *session, void *private_info);
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_private(switch_core_session_t *session, void *private_info);
 
 /*!
   \brief Add a logical stream to a session
@@ -317,7 +458,7 @@
   \param private_info an optional pointer to private data for the new stream
   \return the stream id of the new stream
 */
-SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private_info);
+SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session_t *session, void *private_info);
 
 /*!
   \brief Retreive a logical stream from a session
@@ -325,14 +466,14 @@
   \param index the index to retrieve
   \return the stream
 */
-SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index);
+SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session_t *session, int index);
 
 /*!
   \brief Determine the number of logical streams a session has
   \param session the session to query
   \return the total number of logical streams
 */
-SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session);
+SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t *session);
 
 /*! 
   \brief Launch a thread designed to exist within the scope of a given session
@@ -340,13 +481,13 @@
   \param func a function to execute in the thread
   \param obj an arguement
 */
-SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, void *(*func)(switch_thread *, 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
   \param thread_session the thread_session to indicate to
 */
-SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *thread_session);
+SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session_t *thread_session);
 
 /*! 
   \brief Launch a service thread on a session to drop inbound data
@@ -354,7 +495,7 @@
   \param stream_id which logical media channel to use
   \param thread_session the thread_session to use
 */
-SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session, int stream_id);
+SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session, switch_core_thread_session_t *thread_session, int stream_id);
 
 /*! 
   \brief Request an outgoing session spawned from an existing session using a desired endpoing module
@@ -365,18 +506,18 @@
   \param pool optional existing memory pool to donate to the session
   \return SWITCH_STATUS_SUCCESS if the session was created
 */
-SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core_session_t *session,
 																   char *endpoint_name,
-																   switch_caller_profile *caller_profile,
-																   switch_core_session **new_session,
-																   switch_memory_pool *pool);
+																   switch_caller_profile_t *caller_profile,
+																   switch_core_session_t **new_session,
+																   switch_memory_pool_t *pool);
 
 /*! 
   \brief Answer the channel of a given session
   \param session the session to answer the channel of
   \return SWITCH_STATUS_SUCCESS if the channel was answered
 */
-SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_session *session);
+SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session);
 
 /*! 
   \brief Receive a message on a given session
@@ -384,7 +525,7 @@
   \param message the message to recieve
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session, switch_core_session_message *message);
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message);
 
 /*! 
   \brief Queue an event on a given session
@@ -392,9 +533,50 @@
   \param event the event to queue
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status) switch_core_session_queue_event(switch_core_session *session, switch_event *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event);
 
+
 /*! 
+  \brief Indicate the number of waiting events on a session
+  \param session the session to check
+  \return the number of events
+*/
+SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *session);
+
+/*! 
+  \brief DE-Queue an event on a given session
+  \param session the session to de-queue the message on
+  \param event the de-queued event
+  \return the  SWITCH_STATUS_SUCCESS if the event was de-queued
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event);
+
+/*! 
+  \brief Queue a private event on a given session
+  \param session the session to queue the message on
+  \param event the event to queue
+  \return the status returned by the message handler
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event);
+
+
+/*! 
+  \brief Indicate the number of waiting private events on a session
+  \param session the session to check
+  \return the number of events
+*/
+SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_session_t *session);
+
+/*! 
+  \brief DE-Queue a private event on a given session
+  \param session the session to de-queue the message on
+  \param event the de-queued event
+  \return the  SWITCH_STATUS_SUCCESS if the event was de-queued
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, switch_event_t **event);
+
+
+/*! 
   \brief Read a frame from a session
   \param session the session to read from
   \param frame a NULL pointer to a frame to aim at the newly read frame
@@ -402,9 +584,15 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a the frame was read
 */
-SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, int stream_id);
 
 /*! 
+  \brief Reset the buffers and resampler on a session
+  \param session the session to reset
+*/
+SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session);
+
+/*! 
   \brief Write a frame to a session
   \param session the session to write to
   \param frame the frame to write
@@ -412,15 +600,21 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS a the frame was written
 */
-SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout, int stream_id);
+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);
 /*! 
   \brief Send a signal to a channel
   \param session session to send signal to
   \param sig signal to send
   \return status returned by the session's signal handler
 */
-SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal sig);
+#define switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __FUNCTION__, __LINE__, sig)
 
 /*! 
   \brief Wait for a session to be ready for input
@@ -429,7 +623,7 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS if data is available for read within timeframe specified
 */
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout, int stream_id);
 
 /*! 
   \brief Wait for a session to be ready for output
@@ -438,7 +632,7 @@
   \param stream_id which logical media channel to use
   \return SWITCH_STATUS_SUCCESS if the session is available for write within timeframe specified
 */
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout, int stream_id);
+SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout, int stream_id);
 
 /*! 
   \brief Send DTMF to a session
@@ -446,7 +640,7 @@
   \param dtmf string to send to the session
   \return SWITCH_STATUS_SUCCESS if the dtmf was written
 */
-SWITCH_DECLARE(switch_status) switch_core_session_send_dtmf(switch_core_session *session, char *dtmf);
+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
@@ -454,7 +648,7 @@
   \param outgoing_channel hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session, switch_outgoing_channel_hook outgoing_channel);
+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
@@ -466,7 +660,7 @@
   \param answer_channel hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session, switch_answer_channel_hook answer_channel);
+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
@@ -474,7 +668,7 @@
   \param receive_message hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_receive_message(switch_core_session *session, switch_receive_message_hook receive_message);
+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
@@ -482,7 +676,7 @@
   \param  read_frame hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session, switch_read_frame_hook read_frame);
+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
@@ -490,7 +684,7 @@
   \param write_frame hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session, switch_write_frame_hook write_frame);
+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
@@ -498,7 +692,7 @@
   \param kill_channel hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session, switch_kill_channel_hook kill_channel);
+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
@@ -506,7 +700,7 @@
   \param waitfor_read hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session, switch_waitfor_read_hook waitfor_read);
+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
@@ -514,7 +708,7 @@
   \param waitfor_write hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session, switch_waitfor_write_hook waitfor_write);
+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
@@ -522,7 +716,7 @@
   \param send_dtmf hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session, switch_send_dtmf_hook send_dtmf);
+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);
 ///\}
 
 ///\defgroup hashf Hash Functions
@@ -534,14 +728,14 @@
   \param pool the pool to use for the new hash
   \return SWITCH_STATUS_SUCCESS if the hash is created
 */
-SWITCH_DECLARE(switch_status) switch_core_hash_init(switch_hash **hash, switch_memory_pool *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) switch_core_hash_destroy(switch_hash *hash);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t *hash);
 
 /*! 
   \brief Insert data into a hash
@@ -551,7 +745,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) switch_core_hash_insert(switch_hash *hash, char *key, void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(switch_hash_t *hash, char *key, void *data);
 
 /*! 
   \brief Insert data into a hash with dynamicly allocated key name
@@ -560,7 +754,7 @@
   \param data the data to add
   \return SWITCH_STATUS_SUCCESS if the data is added
 */
-SWITCH_DECLARE(switch_status) switch_core_hash_insert_dup(switch_hash *hash, char *key, void *data);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_dup(switch_hash_t *hash, char *key, void *data);
 
 /*! 
   \brief Delete data from a hash based on desired key
@@ -568,7 +762,7 @@
   \param key the key from which to delete the data
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
-SWITCH_DECLARE(switch_status) switch_core_hash_delete(switch_hash *hash, char *key);
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(switch_hash_t *hash, char *key);
 
 /*! 
   \brief Retrieve data from a given hash
@@ -576,7 +770,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 *hash, char *key);
+SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, char *key);
 ///\}
 
 ///\defgroup timer Timer Functions
@@ -591,21 +785,35 @@
   \param pool the memory pool to use for allocation
   \return
 */
-SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples, switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, int samples, switch_memory_pool_t *pool);
 
 /*! 
   \brief Wait for one cycle on an existing timer
   \param timer the timer to wait on
   \return the newest sample count
 */
-SWITCH_DECLARE(int) switch_core_timer_next(switch_timer *timer);
+SWITCH_DECLARE(int) switch_core_timer_next(switch_timer_t *timer);
 
 /*! 
+  \brief Step the timer one step
+  \param timer the timer to wait on
+  \return the newest sample count
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_timer_step(switch_timer_t *timer);
+
+/*! 
+  \brief Check if the current step has been exceeded
+  \param timer the timer to wait on
+  \return the newest sample count
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer);
+
+/*! 
   \brief Destroy an allocated timer
   \param timer timer to destroy
   \return SWITCH_STATUS_SUCCESS after destruction
 */
-SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer);
+SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer);
 ///\}
 
 ///\defgroup codecs Codec Functions
@@ -623,14 +831,14 @@
   \param pool the memory pool to use
   \return SWITCH_STATUS_SUCCESS if the handle is allocated
 */
-SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, 
+SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, 
 													 char *codec_name, 
 													 uint32_t rate, 
 													 int ms, 
 													 int channels, 
 													 uint32_t flags,
-													 const switch_codec_settings *codec_settings, 
-													 switch_memory_pool *pool);
+													 const switch_codec_settings_t *codec_settings, 
+													 switch_memory_pool_t *pool);
 
 /*! 
   \brief Encode data using a codec handle
@@ -646,8 +854,8 @@
   \return SWITCH_STATUS_SUCCESS if the data was encoded
   \note encoded_data_len will be rewritten to the in-use size of encoded_data
 */
-SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
-													   switch_codec *other_codec,
+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,
@@ -670,8 +878,8 @@
   \return SWITCH_STATUS_SUCCESS if the data was decoded
   \note decoded_data_len will be rewritten to the in-use size of decoded_data
 */
-SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
-													   switch_codec *other_codec,
+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,
@@ -685,7 +893,7 @@
   \param codec the codec handle to destroy
   \return SWITCH_STATUS_SUCCESS if the codec was destroyed
 */
-SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec);
+SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec);
 
 /*! 
   \brief Assign the read codec to a given session
@@ -693,14 +901,14 @@
   \param codec the codec to add
   \return SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec);
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec);
 
 /*! 
   \brief Retrieve the read codec from a given session
   \param session session to retrieve from
   \return a pointer to the codec
 */
-SWITCH_DECLARE(switch_codec *) switch_core_session_get_read_codec(switch_core_session *session);
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_session_t *session);
 
 /*! 
   \brief Assign the write codec to a given session
@@ -708,14 +916,14 @@
   \param codec the codec to add
   \return SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec);
 
 /*! 
   \brief Retrieve the write codec from a given session
   \param session session to retrieve from
   \return a pointer to the codec
 */
-SWITCH_DECLARE(switch_codec *) switch_core_session_get_write_codec(switch_core_session *session);
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(switch_core_session_t *session);
 
 ///\}
 ///\defgroup db Database Functions
@@ -724,10 +932,28 @@
 /*! 
   \brief Open a core db (SQLite) file
   \param filename the path to the db file to open
-  \return
+  \return the db handle
 */
-SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename);
+SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename);
 
+/*! 
+  \brief Execute a sql stmt until it is accepted
+  \param db the db handle
+  \param sql the sql to execute
+  \param retries the number of retries to use
+  \return SWITCH_STATUS_SUCCESS if successful
+
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_db_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries);
+
+/*! 
+  \brief perform a test query then perform a reactive query if the first one fails
+  \param db the db handle
+  \param test_sql the test sql
+  \param reactive_sql the reactive sql
+*/
+SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *reactive_sql);
+
 #define SWITCH_CORE_DB "core"
 /*!
   \brief Open the default system database
@@ -748,7 +974,7 @@
   \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) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags, switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, char *file_path, unsigned int flags, switch_memory_pool_t *pool);
 
 /*! 
   \brief Read media from a file handle
@@ -757,7 +983,7 @@
   \param len the max size of the buffer
   \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes read if successful
 */
-SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void *data, switch_size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len);
 
 /*! 
   \brief Write media to a file handle
@@ -766,7 +992,7 @@
   \param len the amount of data to write from the buffer
   \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
 */
-SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, switch_size_t *len);
+SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len);
 
 /*! 
   \brief Seek a position in a file
@@ -776,14 +1002,33 @@
   \param whence the indicator (see traditional seek)
   \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
 */
-SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, int64_t samples, int whence);
+SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
 
 /*! 
+  \brief Set metadata to the desired string
+  \param fh the file handle to set data to
+  \param col the enum of the col name
+  \param string the string to add
+  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
+
+/*! 
+  \brief get metadata of the desired string
+  \param fh the file handle to get data from
+  \param col the enum of the col name
+  \param string pointer to the string to fetch
+  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
+
+
+/*! 
   \brief Close an open file handle
   \param fh the file handle to close
   \return SWITCH_STATUS_SUCCESS if the file handle was closed
 */
-SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh);
+SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh);
 ///\}
 
 ///\defgroup speech ASR/TTS Functions
@@ -799,12 +1044,12 @@
   \param pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the handle is opened
 */
-SWITCH_DECLARE(switch_status) switch_core_speech_open(switch_speech_handle *sh, 
+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 *flags,
-													  switch_memory_pool *pool);
+													  switch_speech_flag_t *flags,
+													  switch_memory_pool_t *pool);
 
 /*!
   \brief Feed data to the ASR module
@@ -815,7 +1060,7 @@
   \param flags flags in/out for fine tuning
   \return SWITCH_STATUS_SUCCESS with possible new flags on success
 */
-SWITCH_DECLARE(switch_status) switch_core_speech_feed_asr(switch_speech_handle *sh, void *data, unsigned int *len, int rate, switch_speech_flag *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_asr(switch_speech_handle_t *sh, void *data, unsigned int *len, int rate, switch_speech_flag_t *flags);
 
 /*! 
   \brief Get text back from the ASR module
@@ -825,7 +1070,7 @@
   \param flags flags in/out for fine tuning
   \return SWITCH_STATUS_SUCCESS with possible new flags on success
 */
-SWITCH_DECLARE(switch_status) switch_core_speech_interpret_asr(switch_speech_handle *sh, char *buf, unsigned int buflen, switch_speech_flag *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_interpret_asr(switch_speech_handle_t *sh, char *buf, unsigned int buflen, switch_speech_flag_t *flags);
 
 /*! 
   \brief Feed text to the TTS module
@@ -834,9 +1079,39 @@
   \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) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, switch_speech_flag *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags);
 
 /*! 
+  \brief Flush TTS audio on a given handle
+  \param sh the speech handle
+*/
+SWITCH_DECLARE(void) switch_core_speech_flush_tts(switch_speech_handle_t *sh);
+
+/*! 
+  \brief Set a text parameter on a TTS handle
+  \param sh the speech handle
+  \param param the parameter
+  \param val the value
+*/
+SWITCH_DECLARE(void) switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, char *val);
+
+/*! 
+  \brief Set a numeric parameter on a TTS handle
+  \param sh the speech handle
+  \param param the parameter
+  \param val the value
+*/
+SWITCH_DECLARE(void) switch_core_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val);
+
+/*! 
+  \brief Set a float parameter on a TTS handle
+  \param sh the speech handle
+  \param param the parameter
+  \param val the value
+*/
+SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val);
+
+/*! 
   \brief Read rendered audio from the TTS module
   \param sh the speech handle to read
   \param data the buffer to read to
@@ -845,18 +1120,18 @@
   \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) switch_core_speech_read_tts(switch_speech_handle *sh, 
+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 *flags);
+														  switch_speech_flag_t *flags);
 /*! 
   \brief Close an open speech handle
   \param sh the speech handle to close
   \param flags flags in/out for fine tuning
   \return SWITCH_STATUS_SUCCESS if the file handle was closed
 */
-SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, switch_speech_flag *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags);
 ///\}
 
 
@@ -873,12 +1148,12 @@
   \param pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the handle is opened
 */
-SWITCH_DECLARE(switch_status) switch_core_directory_open(switch_directory_handle *dh, 
+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 *pool);
+														 switch_memory_pool_t *pool);
 
 /*! 
   \brief Query a directory handle
@@ -887,14 +1162,14 @@
   \param query a string of filters or query data
   \return SWITCH_STATUS_SUCCESS if the query is successful
 */
-SWITCH_DECLARE(switch_status) switch_core_directory_query(switch_directory_handle *dh, char *base, char *query);
+SWITCH_DECLARE(switch_status_t) switch_core_directory_query(switch_directory_handle_t *dh, char *base, char *query);
 
 /*! 
   \brief Obtain the next record in a lookup
   \param dh a direcotry handle to use
   \return SWITCH_STATUS_SUCCESS if another record exists
 */
-SWITCH_DECLARE(switch_status) switch_core_directory_next(switch_directory_handle *dh);
+SWITCH_DECLARE(switch_status_t) switch_core_directory_next(switch_directory_handle_t *dh);
 
 /*! 
   \brief Obtain the next name/value pair in the current record
@@ -903,14 +1178,14 @@
   \param val a pointer to poinbter of the value to fill in
   \return SWITCH_STATUS_SUCCESS if an item exists
 */
-SWITCH_DECLARE(switch_status) switch_core_directory_next_pair(switch_directory_handle *dh, char **var, char **val);
+SWITCH_DECLARE(switch_status_t) switch_core_directory_next_pair(switch_directory_handle_t *dh, char **var, char **val);
 
 /*! 
   \brief Close an open directory handle
   \param dh a direcotry handle to close
   \return SWITCH_STATUS_SUCCESS if handle was closed
 */
-SWITCH_DECLARE(switch_status) switch_core_directory_close(switch_directory_handle *dh);
+SWITCH_DECLARE(switch_status_t) switch_core_directory_close(switch_directory_handle_t *dh);
 ///\}
 
 
@@ -922,15 +1197,49 @@
   \param channel text channel enumeration
   \return a FILE stream
 */
-SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel);
+SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
 
+
+/*! 
+  \brief Set the maximum priority the process can obtain
+  \return 0 on success
+*/
+SWITCH_DECLARE(int32_t) set_high_priority(void);
+
+/*! 
+  \brief Run endlessly until the system is shutdown
+  \param bg divert console to the background
+*/
+SWITCH_DECLARE(void) switch_core_runtime_loop(int bg);
+
 /*!
   \brief Set the output console to the desired file
   \param console the file path
 */
-SWITCH_DECLARE(switch_status) switch_core_set_console(char *console);
+SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console);
 
 /*!
+  \brief Breakdown a number of milliseconds into various time spec
+  \param total_ms a number of milliseconds
+  \param duration an object to store the results
+*/
+SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration);
+
+/*!
+  \brief Number of microseconds the system has been up
+  \return a number of microseconds
+*/
+SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
+
+/*!
+  \brief send a control message to the core
+  \param cmd the command
+  \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);
+
+/*!
   \brief Get the output console
   \return the FILE stream
 */
@@ -938,7 +1247,7 @@
 /*! 
   \brief Launch a thread
 */
-SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread *, void*), void *obj, switch_memory_pool *pool);
+SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread_t *, void*), void *obj, switch_memory_pool_t *pool);
 
 /*!
   \brief Initiate Globals
@@ -950,10 +1259,6 @@
   \}
 */
 
-
-#ifdef __cplusplus
-}
-#endif
-
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_event.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_event.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_event.h	Fri Sep 22 14:22:15 2006
@@ -58,14 +58,12 @@
 #ifndef SWITCH_EVENT_H
 #define SWITCH_EVENT_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #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 */
@@ -84,15 +82,15 @@
 /*! \brief Representation of an event */
 struct switch_event {
 	/*! the event id (descriptor) */
-	switch_event_t event_id;
+	switch_event_types_t event_id;
 	/*! the priority of the event */
 	switch_priority_t priority;
 	/*! the owner of the event */
 	char *owner;
 	/*! the subclass of the event */
-	switch_event_subclass *subclass;
+	switch_event_subclass_t *subclass;
 	/*! the event headers */
-	struct switch_event_header *headers;
+	switch_event_header_t *headers;
 	/*! the body of the event */
 	char *body;
 	/*! user data from the subclass provider */
@@ -107,9 +105,9 @@
 	/*! the id of the node */
 	char *id;
 	/*! the event id enumeration to bind to */
-	switch_event_t event_id;
+	switch_event_types_t event_id;
 	/*! the event subclass to bind to for custom events */
-	switch_event_subclass *subclass;
+	switch_event_subclass_t *subclass;
 	/*! a callback function to execute when the event is triggered */
 	switch_event_callback_t callback;
 	/*! private data */
@@ -124,13 +122,13 @@
   \param pool the memory pool to use for the event system (creates a new one if NULL)
   \return SWITCH_STATUS_SUCCESS when complete
 */
-SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool);
 
 /*!
   \brief Stop the eventing system
   \return SWITCH_STATUS_SUCCESS when complete
 */
-SWITCH_DECLARE(switch_status) switch_event_shutdown(void);
+SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void);
 
 /*!
   \brief Create an event
@@ -139,7 +137,7 @@
   \param subclass_name the subclass name for custom event (only valid when event_id is SWITCH_EVENT_CUSTOM)
   \return SWITCH_STATUS_SUCCESS on success
 */
-SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id, char *subclass_name);
+SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id, char *subclass_name);
 
 /*!
   \brief Set the priority of an event
@@ -147,7 +145,7 @@
   \param priority the event priority
   \return SWITCH_STATUS_SUCCESS
 */
-SWITCH_DECLARE(switch_status) switch_event_set_priority(switch_event *event, switch_priority_t priority);
+SWITCH_DECLARE(switch_status_t) switch_event_set_priority(switch_event_t *event, switch_priority_t priority);
 
 /*!
   \brief Retrieve a header value from an event
@@ -155,9 +153,16 @@
   \param header_name the name of the header to read
   \return the value of the requested header
 */
-SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header_name);
+SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name);
 
 /*!
+  \brief Retrieve the body value from an event
+  \param event the event to read the body from
+  \return the value of the body or NULL
+*/
+SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event);
+
+/*!
   \brief Add a header to an event
   \param event the event to add the header to
   \param stack the stack sense (stack it on the top or on the bottom)
@@ -165,13 +170,13 @@
   \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) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name, char *fmt, ...);
+SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, char *header_name, char *fmt, ...);
 
 /*!
   \brief Destroy an event
   \param event pointer to the pointer to event to destroy
 */
-SWITCH_DECLARE(void) switch_event_destroy(switch_event **event);
+SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event);
 
 /*!
   \brief Duplicate an event
@@ -179,7 +184,7 @@
   \param todup an event to duplicate
   \return SWITCH_STATUS_SUCCESS if the event was duplicated
 */
-SWITCH_DECLARE(switch_status) switch_event_dup(switch_event **event, switch_event *todup);
+SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_event_t *todup);
 
 /*!
   \brief Fire an event with full arguement list
@@ -190,7 +195,7 @@
   \param user_data optional private data to pass to the event handlers
   \return
 */
-SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event, void *user_data);
+SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event, void *user_data);
 
 /*!
   \brief Bind an event callback to a specific event
@@ -201,16 +206,24 @@
   \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) switch_event_bind(char *id, switch_event_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
   \param event the event id to render the name of
   \return the rendered name
 */
-SWITCH_DECLARE(char *) switch_event_name(switch_event_t event);
+SWITCH_DECLARE(char *) switch_event_name(switch_event_types_t event);
 
 /*!
+  \brief return the event id that matches a given event name
+  \param name the name of the event
+  \param type the event id to return
+  \return SWITCH_STATUS_SUCCESS if there was a match
+*/
+SWITCH_DECLARE(switch_status_t) switch_name_event(char *name, switch_event_types_t *type);
+
+/*!
   \brief Reserve a subclass name for private use with a custom event
   \param owner the owner of the event name
   \param subclass_name the name to reserve
@@ -218,7 +231,7 @@
   \note There is nothing to enforce this but I reccommend using module::event_name for the subclass names
 
 */
-SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner, char *subclass_name);
+SWITCH_DECLARE(switch_status_t) switch_event_reserve_subclass_detailed(char *owner, char *subclass_name);
 
 /*!
   \brief Render a string representation of an event sutable for printing or network transport 
@@ -229,13 +242,22 @@
   \return SWITCH_STATUS_SUCCESS if the operation was successful
   \note the body supplied by this function will supersede an existing body the event may have
 */
-SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *buf, switch_size_t buflen, char *fmt, ...);
+SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, char *buf, switch_size_t buflen, char *fmt, ...);
 
 /*!
+  \brief Render a XML representation of an event sutable for printing or network transport
+  \param event the event to render
+  \param fmt optional body of the event (varargs see standard sprintf family)
+  \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, char *fmt, ...);
+
+/*!
   \brief Determine if the event system has been initilized
   \return SWITCH_STATUS_SUCCESS if the system is running
 */
-SWITCH_DECLARE(switch_status) switch_event_running(void);
+SWITCH_DECLARE(switch_status_t) switch_event_running(void);
 
 /*!
   \brief Add a body to an event
@@ -244,7 +266,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) switch_event_add_body(switch_event *event, char *fmt, ...);
+SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, char *fmt, ...);
 
 
 /*!
@@ -268,7 +290,7 @@
   \param event the event to send (will be nulled)
   \note normaly use switch_event_fire for delivering events (only use this when you wish to deliver the event blocking on your thread)
 */
-SWITCH_DECLARE(void) switch_event_deliver(switch_event **event);
+SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event);
 
 /*!
   \brief Fire an event filling in most of the arguements with obvious values
@@ -288,8 +310,6 @@
 #define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__FUNCTION__, __LINE__, event, data)
 ///\}
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_frame.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_frame.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_frame.h	Fri Sep 22 14:22:15 2006
@@ -36,16 +36,14 @@
 #ifndef SWITCH_FRAME_H
 #define SWITCH_FRAME_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /*! \brief An abstraction of a data frame */
 struct switch_frame {
 	/*! a pointer to the codec information */
-	switch_codec *codec;
+	switch_codec_t *codec;
 	/*! the originating source of the frame */
 	const char *source;
 	/*! the raw packet */
@@ -67,11 +65,9 @@
 	/*! the timestamp of the frame */
 	uint32_t timestamp;
 	/*! frame flags */
-	switch_frame_flag flags;
+	switch_frame_flag_t flags;
 };
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_ivr.h	Fri Sep 22 14:22:15 2006
@@ -38,12 +38,12 @@
 #ifndef SWITCH_IVR_H
 #define SWITCH_IVR_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
+static const switch_state_handler_table_t noop_state_handler = {0};
+
 /**
  * @defgroup switch_ivr IVR Library
  * @ingroup core1
@@ -52,7 +52,18 @@
  * @{
  */
 
+
 /*!
+  \brief Wait for time to pass for a specified number of milliseconds
+  \param session the session to wait for.
+  \param ms the number of milliseconds
+  \return SWITCH_STATUS_SUCCESS if the channel is still up
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms);
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session);
+
+/*!
   \brief Wait for DTMF digits calling a pluggable callback function when digits are collected.
   \param session the session to read.
   \param dtmf_callback code to execute if any dtmf is dialed during the recording
@@ -60,8 +71,8 @@
   \param buflen the size of buf
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_callback(switch_core_session *session,
-																 switch_dtmf_callback_function dtmf_callback,
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
+																 switch_input_callback_function_t dtmf_callback,
 																 void *buf,
 																 unsigned int buflen);
 
@@ -74,19 +85,34 @@
   \param terminators digits to end the collection
   \param terminator actual digit that caused the collection to end (if any)
   \param timeout timeout in ms
-  \param poll_channel flag to specify if you want the function to poll the channel while running
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_count(switch_core_session *session,
-															  char *buf,
-															  unsigned int buflen,
-															  unsigned int maxdigits,
-															  const char *terminators,
-															  char *terminator,
-															  unsigned int timeout,
-                                                              unsigned int poll_channel);
-	
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
+																char *buf,
+																unsigned int buflen,
+																unsigned int maxdigits,
+																const char *terminators,
+																char *terminator,
+																unsigned int timeout);
+
 /*!
+  \brief Record a session to disk
+  \param session the session to record
+  \param file the path to the file
+  \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);
+
+/*!
+  \brief Stop Recording a session
+  \param session the session to stop recording
+  \param file the path to the file
+  \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_record_session(switch_core_session_t *session, char *file);
+
+/*!
   \brief play a file from the disk to the session
   \param session the session to play the file too
   \param fh file handle to use (NULL for builtin one)
@@ -98,11 +124,11 @@
   \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) switch_ivr_play_file(switch_core_session *session,
-												   switch_file_handle *fh,
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session,
+												   switch_file_handle_t *fh,
 												   char *file,
 												   char *timer_name,
-												   switch_dtmf_callback_function dtmf_callback,
+												   switch_input_callback_function_t dtmf_callback,
 												   void *buf,
 												   unsigned int buflen);
 
@@ -119,14 +145,23 @@
   \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 recording.
 */
-SWITCH_DECLARE(switch_status) switch_ivr_record_file(switch_core_session *session,
-													 switch_file_handle *fh,
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
+													 switch_file_handle_t *fh,
 													 char *file,
-													 switch_dtmf_callback_function dtmf_callback,
+													 switch_input_callback_function_t dtmf_callback,
 													 void *buf,
 													 unsigned int buflen);
 
 
+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,
+                                                             switch_input_callback_function_t dtmf_callback,
+                                                             char *text,
+                                                             void *buf,
+                                                             unsigned int buflen);
+
 /*!
   \brief Speak given text with given tts engine
   \param session the session to speak on
@@ -140,38 +175,76 @@
   \param buflen the len of buf
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session, 
-													char *tts_name,
-													char *voice_name,
-													char *timer_name,
-													uint32_t rate,
-													switch_dtmf_callback_function dtmf_callback,
-													char *text,
-													void *buf,
-													unsigned int buflen);
+SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, 
+													  char *tts_name,
+													  char *voice_name,
+													  char *timer_name,
+													  uint32_t rate,
+													  switch_input_callback_function_t dtmf_callback,
+													  char *text,
+													  void *buf,
+													  unsigned int buflen);
 
 /*!
+  \brief Make an outgoing call
+  \param session originating session
+  \param bleg B leg session
+  \param cause a pointer to hold call cause
+  \param bridgeto the desired remote callstring
+  \param timelimit_sec timeout in seconds for outgoing call
+  \param table optional state handler table to install on the channel
+  \param cid_name_override override the caller id name
+  \param cid_num_override override the caller id number
+  \param caller_profile_override override the entire calling caller profile
+  \return SWITCH_STATUS_SUCCESS if bleg is a running session.
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
+													 switch_core_session_t **bleg,
+													 switch_call_cause_t *cause,
+													 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);
+
+/*!
   \brief Bridge Audio from one session to another
   \param session one session
   \param peer_session the other session
-  \param timelimit maximum number of seconds to wait for both channels to be answered
   \param dtmf_callback code to execute if any dtmf is dialed during the bridge
   \param session_data data to pass to the DTMF callback for session
   \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) switch_ivr_multi_threaded_bridge(switch_core_session *session, 
-															   switch_core_session *peer_session,
-															   unsigned int timelimit,
-															   switch_dtmf_callback_function dtmf_callback,
-															   void *session_data,
-															   void *peer_session_data);
+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,
+																 void *peer_session_data);
 
+
+/*!
+  \brief Transfer an existing session to another location
+  \param session the session to transfer
+  \param extension the new extension
+  \param dialplan the new dialplan (OPTIONAL, may be NULL)
+  \param context the new context (OPTIONAL, may be NULL)
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context);
+
+
+/*!
+  \brief Bridge two existing sessions
+  \param originator_uuid the uuid of the originator
+  \param originatee_uuid the uuid of the originator
+  \return SWITCH_STATUS_SUCCESS if all is well 
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(char *originator_uuid, char *originatee_uuid);
+
 /** @} */
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif
 

Modified: freeswitch/branches/voctel/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_loadable_module.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_loadable_module.h	Fri Sep 22 14:22:15 2006
@@ -41,12 +41,10 @@
 #ifndef SWITCH_LOADABLE_MODULE_H
 #define SWITCH_LOADABLE_MODULE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /*!
   \defgroup mods Loadable Module Functions
   \ingroup core1
@@ -58,30 +56,30 @@
 	/*! the name of the module */
 	const char *module_name;
 	/*! the table of endpoints the module has implmented */
-	const switch_endpoint_interface *endpoint_interface;
+	const switch_endpoint_interface_t *endpoint_interface;
 	/*! the table of timers the module has implmented */
-	const switch_timer_interface *timer_interface;
+	const switch_timer_interface_t *timer_interface;
 	/*! the table of dialplans the module has implmented */
-	const switch_dialplan_interface *dialplan_interface;
+	const switch_dialplan_interface_t *dialplan_interface;
 	/*! the table of codecs the module has implmented */
-	const switch_codec_interface *codec_interface;
+	const switch_codec_interface_t *codec_interface;
 	/*! the table of applications the module has implmented */
-	const switch_application_interface *application_interface;
+	const switch_application_interface_t *application_interface;
 	/*! the table of api functions the module has implmented */
-	const switch_api_interface *api_interface;
+	const switch_api_interface_t *api_interface;
 	/*! the table of file formats the module has implmented */
-	const switch_file_interface *file_interface;
+	const switch_file_interface_t *file_interface;
 	/*! the table of speech interfaces the module has implmented */
-	const switch_speech_interface *speech_interface;
+	const switch_speech_interface_t *speech_interface;
 	/*! the table of directory interfaces the module has implmented */
-	const switch_directory_interface *directory_interface;
+	const switch_directory_interface_t *directory_interface;
 };
 
 /*!
   \brief Initilize the module backend and load all the modules
   \return SWITCH_STATUS_SUCCESS when complete
  */
-SWITCH_DECLARE(switch_status) switch_loadable_module_init(void);
+SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(void);
 
 /*!
   \brief Shutdown the module backend and call the shutdown routine in all loaded modules
@@ -93,63 +91,77 @@
   \param name the name of the endpoint
   \return the desired endpoint interface
  */
-SWITCH_DECLARE(switch_endpoint_interface *) switch_loadable_module_get_endpoint_interface(char *name);
+SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name);
 
 /*!
   \brief Retrieve the codec interface by it's registered name
   \param name the name of the codec
   \return the desired codec interface
  */
-SWITCH_DECLARE(switch_codec_interface *) switch_loadable_module_get_codec_interface(char *name);
+SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name);
 
 /*!
   \brief Retrieve the dialplan interface by it's registered name
   \param name the name of the dialplan
   \return the desired dialplan interface
  */
-SWITCH_DECLARE(switch_dialplan_interface *) switch_loadable_module_get_dialplan_interface(char *name);
+SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name);
 
 /*!
+  \brief build a dynamic module object and register it (for use in double embeded modules)
+  \param filename the name of the modules source file
+  \param switch_module_load the function to call when the module is loaded
+  \param switch_module_runtime a function requested to be started in it's own thread once loaded
+  \param switch_module_shutdown the function to call when the system is shutdown
+  \return the resulting status
+  \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);
+
+/*!
   \brief Retrieve the timer interface by it's registered name
   \param name the name of the timer
   \return the desired timer interface
  */
-SWITCH_DECLARE(switch_timer_interface *) switch_loadable_module_get_timer_interface(char *name);
+SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name);
 
 /*!
   \brief Retrieve the application interface by it's registered name
   \param name the name of the application
   \return the desired application interface
  */
-SWITCH_DECLARE(switch_application_interface *) switch_loadable_module_get_application_interface(char *name);
+SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name);
 
 /*!
   \brief Retrieve the API interface by it's registered name
   \param name the name of the API
   \return the desired API interface
  */
-SWITCH_DECLARE(switch_api_interface *) switch_loadable_module_get_api_interface(char *name);
+SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name);
 
 /*!
   \brief Retrieve the file format interface by it's registered name
   \param name the name of the file format
   \return the desired file format interface
  */
-SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interface(char *name);
+SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name);
 
 /*!
   \brief Retrieve the speech interface by it's registered name
   \param name the name of the speech interface
   \return the desired speech interface
  */
-SWITCH_DECLARE(switch_speech_interface *) switch_loadable_module_get_speech_interface(char *name);
+SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name);
 
 /*!
   \brief Retrieve the directory interface by it's registered name
   \param name the name of the directory interface
   \return the desired directory interface
  */
-SWITCH_DECLARE(switch_directory_interface *) switch_loadable_module_get_directory_interface(char *name);
+SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name);
 
 
 /*!
@@ -159,10 +171,10 @@
   \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 *pool, 
-													  switch_codec_interface **array, 
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
 													  int arraylen);
 
+
 /*!
   \brief Retrieve the list of loaded codecs into an array based on another array showing the sorted order
   \param array the array to populate
@@ -172,45 +184,52 @@
   \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(switch_codec_interface **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
   \param cmd the name of the API command to execute
   \param arg the optional arguement to the command
-  \param retbuf a buffer to write output to
-  \param len the length in bytes of retbuf
+  \param session an optional session
+  \param stream stream for output
   \return the status returned by the API call
 */
-SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len);
+SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
 
+
+
+/*!
+  \brief Load a module
+  \param dir the directory where the module resides
+  \param fname the file name of the module
+  \return the status
+*/
+SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname);
+
 /* Prototypes of module interface functions */
 
 /*!
   \brief Load a module
-  \param interface a pointer to a pointer to aim at your module's local interface
+  \param module_interface a pointer to a pointer to aim at your module's local interface
   \param filename the path to the module's dll or so file
   \return SWITCH_STATUS_SUCCESS on a successful load
 */
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename);
-SWITCH_MOD_DECLARE(switch_status) switch_module_reload(void);
-SWITCH_MOD_DECLARE(switch_status) switch_module_pause(void);
-SWITCH_MOD_DECLARE(switch_status) switch_module_resume(void);
-SWITCH_MOD_DECLARE(switch_status) switch_module_status(void);
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void);
+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_reload(void);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_pause(void);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_resume(void);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_status(void);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
 
+
 /*!
   \brief Shutdown a module
   \return SWITCH_STATUS_SUCCESS on a successful shutdown
 */
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void);
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
 ///\}
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_log.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_log.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_log.h	Fri Sep 22 14:22:15 2006
@@ -38,15 +38,10 @@
 #ifndef SWITCH_LOG_H
 #define SWITCH_LOG_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef _FORMATBUG
-}
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 ///\defgroup log Logger Routines
 ///\ingroup core1
 ///\{
@@ -64,14 +59,14 @@
 	/*! The function where the message originated */	
 	char *func;
 	/*! The log level of the message */	
-	switch_log_level level;
+	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) */	
 	char *content;
-} switch_log_node;
+} switch_log_node_t;
 
-typedef switch_status (*switch_log_function)(const switch_log_node *node, switch_log_level level);
+typedef switch_status_t (*switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level);
 
 
 /*! 
@@ -79,13 +74,13 @@
   \param pool the memory pool to use
   \note to be called at application startup by the core
 */
-SWITCH_DECLARE(switch_status) switch_log_init(switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool);
 
 /*! 
   \brief Shut down the logging engine
   \note to be called at application termination by the core
 */
-SWITCH_DECLARE(switch_status) switch_log_shutdown(void);
+SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void);
 
 
 /*! 
@@ -99,31 +94,29 @@
   \param ... variable args
   \note there are channel macros to supply the first 4 parameters
 */
-SWITCH_DECLARE(void) switch_log_printf(switch_text_channel channel, char *file, const char *func, int line, switch_log_level level, char *fmt, ...);
+SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file, const char *func, int line, switch_log_level_t level, char *fmt, ...);
 
 /*! 
   \brief Shut down  the logging engine
   \note to be called at application termination by the core
 */
-SWITCH_DECLARE(switch_status) switch_log_bind_logger(switch_log_function function, switch_log_level level);
+SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level);
 
 /*! 
   \brief Return the name of the specified log level
   \param level the level
   \return the name of the log level
 */
-SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level level);
+SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level);
 
 /*! 
   \brief Return the level number of the specified log level name
   \param str the name of the level
   \return the log level
 */
-SWITCH_DECLARE(switch_log_level) switch_log_str2level(const char *str);
+SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str);
 
 ///\}
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_module_interfaces.h	Fri Sep 22 14:22:15 2006
@@ -39,145 +39,156 @@
 #ifndef SWITCH_MODULE_INTERFACES_H
 #define SWITCH_MODULE_INTERFACES_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 /*! \brief A table of functions to execute at various states 
 */
 struct switch_state_handler_table {
 	/*! executed when the state changes to init */
-	switch_state_handler on_init;
+	switch_state_handler_t on_init;
 	/*! executed when the state changes to ring */
-	switch_state_handler on_ring;
+	switch_state_handler_t on_ring;
 	/*! executed when the state changes to execute */
-	switch_state_handler on_execute;
+	switch_state_handler_t on_execute;
 	/*! executed when the state changes to hangup */
-	switch_state_handler on_hangup;
+	switch_state_handler_t on_hangup;
 	/*! executed when the state changes to loopback*/
-	switch_state_handler on_loopback;
+	switch_state_handler_t on_loopback;
 	/*! executed when the state changes to transmit*/
-	switch_state_handler on_transmit;
+	switch_state_handler_t on_transmit;
+	/*! executed when the state changes to hold*/
+	switch_state_handler_t on_hold;
 };
 
+struct switch_stream_handle {
+	switch_stream_handle_write_function_t write_function;
+	void *data;
+	void *end;
+	switch_size_t data_size;
+	switch_size_t data_len;
+	switch_size_t alloc_len;
+	switch_size_t alloc_chunk;
+	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 outgoing_channel;
+	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 answer_channel;
+	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 receive_message;
+	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_queue_event {
+struct switch_io_event_hook_receive_event {
 	/*! the answer channel callback hook*/
-	switch_queue_event_hook queue_event;
-	struct switch_io_event_hook_queue_event *next;
+	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 read_frame;
+	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 write_frame;
+	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 kill_channel;
+	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 waitfor_read;
+	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 waitfor_write;
+	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 send_dtmf;
+	switch_send_dtmf_hook_t send_dtmf;
 	struct switch_io_event_hook_send_dtmf *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 */
-	struct switch_io_event_hook_outgoing_channel *outgoing_channel;
+	switch_io_event_hook_outgoing_channel_t *outgoing_channel;
 	/*! a list of answer channel hooks */
-	struct switch_io_event_hook_answer_channel *answer_channel;
+	switch_io_event_hook_answer_channel_t *answer_channel;
 	/*! a list of receive message hooks */
-	struct switch_io_event_hook_receive_message *receive_message;
+	switch_io_event_hook_receive_message_t *receive_message;
 	/*! a list of queue message hooks */
-	struct switch_io_event_hook_queue_event *queue_event;
+	switch_io_event_hook_receive_event_t *receive_event;
 	/*! a list of read frame hooks */
-	struct switch_io_event_hook_read_frame *read_frame;
+	switch_io_event_hook_read_frame_t *read_frame;
 	/*! a list of write frame hooks */
-	struct switch_io_event_hook_write_frame *write_frame;
+	switch_io_event_hook_write_frame_t *write_frame;
 	/*! a list of kill channel hooks */
-	struct switch_io_event_hook_kill_channel *kill_channel;
+	switch_io_event_hook_kill_channel_t *kill_channel;
 	/*! a list of wait for read hooks */
-	struct switch_io_event_hook_waitfor_read *waitfor_read;
+	switch_io_event_hook_waitfor_read_t *waitfor_read;
 	/*! a list of wait for write hooks */
-	struct switch_io_event_hook_waitfor_write *waitfor_write;
+	switch_io_event_hook_waitfor_write_t *waitfor_write;
 	/*! a list of send dtmf hooks */
-	struct switch_io_event_hook_send_dtmf *send_dtmf;
+	switch_io_event_hook_send_dtmf_t *send_dtmf;
 };
 
 /*! \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_status (*outgoing_channel)(switch_core_session *, switch_caller_profile *, switch_core_session **, switch_memory_pool *);
+	switch_status_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 (*answer_channel)(switch_core_session *);
+	switch_status_t (*answer_channel)(switch_core_session_t *);
 	/*! read a frame from a session */
-	switch_status (*read_frame)(switch_core_session *, switch_frame **, int, switch_io_flag, 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 (*write_frame)(switch_core_session *, switch_frame *, int, switch_io_flag, 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 (*kill_channel)(switch_core_session *, 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 (*waitfor_read)(switch_core_session *, 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 (*waitfor_write)(switch_core_session *, 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 (*send_dtmf)(switch_core_session *, char *);
+	switch_status_t (*send_dtmf)(switch_core_session_t *, char *);
 	/*! receive a message from another session*/
-	switch_status (*receive_message)(switch_core_session *, switch_core_session_message *);
+	switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
 	/*! queue a message for another session*/
-	switch_status (*queue_event)(switch_core_session *, switch_event *);
+	switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
 };
 
 /*! \brief Abstraction of an module endpoint interface
@@ -191,10 +202,10 @@
 	const char *interface_name;
 
 	/*! channel abstraction methods */
-	const switch_io_routines *io_routines;
+	const switch_io_routines_t *io_routines;
 
 	/*! state machine methods */
-	const switch_state_handler_table *state_handler;
+	const switch_state_handler_table_t *state_handler;
 
 	/*! private information */
 	void *private_info;
@@ -214,9 +225,9 @@
 	/*! current sample count based on samples parameter */
 	unsigned int samplecount;
 	/*! the timer interface provided from a loadable module */
-	struct switch_timer_interface *timer_interface;
+	switch_timer_interface_t *timer_interface;
 	/*! the timer's memory pool */
-	switch_memory_pool *memory_pool;
+	switch_memory_pool_t *memory_pool;
 	/*! private data for loadable modules to store information */
 	void *private_info;
 };
@@ -226,11 +237,15 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to allocate the timer */
-	switch_status (*timer_init)(switch_timer *);
+	switch_status_t (*timer_init)(switch_timer_t *);
 	/*! function to wait for one cycle to pass */
-	switch_status (*timer_next)(switch_timer *);
+	switch_status_t (*timer_next)(switch_timer_t *);
+	/*! function to step the timer one step */
+	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 *);
 	/*! function to deallocate the timer */
-	switch_status (*timer_destroy)(switch_timer *);
+	switch_status_t (*timer_destroy)(switch_timer_t *);
 	const struct switch_timer_interface *next;
 };
 
@@ -239,7 +254,7 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! the function to read an extension and set a channels dialpan */
-	switch_dialplan_hunt_function hunt_function;
+	switch_dialplan_hunt_function_t hunt_function;
 	const struct switch_dialplan_interface *next;
 };
 
@@ -248,15 +263,19 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the file */
-	switch_status (*file_open)(switch_file_handle *, char *file_path);
+	switch_status_t (*file_open)(switch_file_handle_t *, char *file_path);
 	/*! function to close the file */
-	switch_status (*file_close)(switch_file_handle *);
+	switch_status_t (*file_close)(switch_file_handle_t *);
 	/*! function to read from the file */
-	switch_status (*file_read)(switch_file_handle *, 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 (*file_write)(switch_file_handle *, 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 (*file_seek)(switch_file_handle *, 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);
+	/*! function to get meta data */
+	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;
@@ -265,7 +284,7 @@
 /*! an abstract representation of a file handle (some parameters based on compat with libsndfile) */
 struct switch_file_handle {
 	/*! the interface of the module that implemented the current file type */
-	const struct switch_file_interface *file_interface;
+	const switch_file_interface_t *file_interface;
 	/*! flags to control behaviour */
 	uint32_t flags;
 	/*! a file descriptor if neceessary */
@@ -287,11 +306,11 @@
 	/*! the speed of the file playback*/
 	int speed;
 	/*! the handle's memory pool */
-	switch_memory_pool *memory_pool;
+	switch_memory_pool_t *memory_pool;
 	/*! private data for the format module to store handle specific info */
 	void *private_info;
 	int64_t pos;
-	switch_buffer *audio_buffer;
+	switch_buffer_t *audio_buffer;
 };
 
 
@@ -300,24 +319,28 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the speech interface */
-	switch_status (*speech_open)(switch_speech_handle *sh,
+	switch_status_t (*speech_open)(switch_speech_handle_t *sh,
 								 char *voice_name, 
 								 int rate,
-								 switch_speech_flag *flags);
+								 switch_speech_flag_t *flags);
 	/*! function to close the speech interface */
-	switch_status (*speech_close)(switch_speech_handle *, switch_speech_flag *flags);
+	switch_status_t (*speech_close)(switch_speech_handle_t *, switch_speech_flag_t *flags);
 	/*! function to feed audio to the ASR*/
-	switch_status (*speech_feed_asr)(switch_speech_handle *sh, void *data, unsigned int *len, int rate, switch_speech_flag *flags);
+	switch_status_t (*speech_feed_asr)(switch_speech_handle_t *sh, void *data, unsigned int *len, int rate, switch_speech_flag_t *flags);
 	/*! function to read text from the ASR*/
-	switch_status (*speech_interpret_asr)(switch_speech_handle *sh, char *buf, unsigned int buflen, switch_speech_flag *flags);
+	switch_status_t (*speech_interpret_asr)(switch_speech_handle_t *sh, char *buf, unsigned int buflen, switch_speech_flag_t *flags);
 	/*! function to feed text to the TTS*/
-	switch_status (*speech_feed_tts)(switch_speech_handle *sh, char *text, switch_speech_flag *flags);
+	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 (*speech_read_tts)(switch_speech_handle *sh,
+	switch_status_t (*speech_read_tts)(switch_speech_handle_t *sh,
 									 void *data,
 									 switch_size_t *datalen,
 									 uint32_t *rate,
-									 switch_speech_flag *flags);
+									 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;
 };
@@ -326,12 +349,18 @@
 /*! an abstract representation of a asr/tts speech interface. */
 struct switch_speech_handle {
 	/*! the interface of the module that implemented the current speech interface */
-	const struct switch_speech_interface *speech_interface;
+	const switch_speech_interface_t *speech_interface;
 	/*! flags to control behaviour */
 	uint32_t flags;
-
+	/*! The Name*/
+	char *name;
+	/*! The Rate*/
+	uint32_t rate;
+	uint32_t speed;
+	char voice[80];
+	char engine[80];
 	/*! the handle's memory pool */
-	switch_memory_pool *memory_pool;
+	switch_memory_pool_t *memory_pool;
 	/*! private data for the format module to store handle specific info */
 	void *private_info;
 };
@@ -343,15 +372,15 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function to open the directory interface */
-	switch_status (*directory_open)(switch_directory_handle *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 (*directory_close)(switch_directory_handle *dh);
+	switch_status_t (*directory_close)(switch_directory_handle_t *dh);
 	/*! function to query the directory interface */
-	switch_status (*directory_query)(switch_directory_handle *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 (*directory_next)(switch_directory_handle *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 (*directory_next_pair)(switch_directory_handle *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;
 };
@@ -359,12 +388,12 @@
 /*! an abstract representation of a directory interface. */
 struct switch_directory_handle {
 	/*! the interface of the module that implemented the current directory interface */
-	const struct switch_directory_interface *directory_interface;
+	const switch_directory_interface_t *directory_interface;
 	/*! flags to control behaviour */
 	uint32_t flags;
 
 	/*! the handle's memory pool */
-	switch_memory_pool *memory_pool;
+	switch_memory_pool_t *memory_pool;
 	/*! private data for the format module to store handle specific info */
 	void *private_info;
 };
@@ -410,21 +439,27 @@
 /*! an abstract handle to a codec module */
 struct switch_codec {
 	/*! the codec interface table this handle uses */
-	const struct switch_codec_interface *codec_interface;
+	const switch_codec_interface_t *codec_interface;
 	/*! the specific implementation of the above codec */
-	const struct switch_codec_implementation *implementation;
+	const switch_codec_implementation_t *implementation;
 	/*! codec settings for this handle */
-	struct switch_codec_settings codec_settings;
+	switch_codec_settings_t codec_settings;
 	/*! flags to modify behaviour */
 	uint32_t flags;
 	/*! the handle's memory pool*/
-	switch_memory_pool *memory_pool;
+	switch_memory_pool_t *memory_pool;
 	/*! private data for the codec module to store handle specific info */
 	void *private_info;
 };
 
 /*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
 struct switch_codec_implementation {
+	/*! enumeration defining the type of the codec */
+	const switch_codec_type_t codec_type;
+	/*! the IANA code number */
+	switch_payload_t ianacode;
+	/*! the IANA code name */
+	char *iananame;
 	/*! samples transferred per second */
 	uint32_t samples_per_second;
 	/*! bits transferred per second */
@@ -444,10 +479,10 @@
 	/*! 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 (*init)(switch_codec *, switch_codec_flag, const switch_codec_settings *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 (*encode)(switch_codec *codec,
-						 switch_codec *other_codec,
+	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,
@@ -456,8 +491,8 @@
 						 uint32_t *encoded_rate,
 						 unsigned int *flag);
 	/*! function to decode encoded data into raw data */
-	switch_status (*decode)(switch_codec *codec,
-						 switch_codec *other_codec,
+	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,
@@ -466,7 +501,7 @@
 						 uint32_t *decoded_rate,
 						 unsigned int *flag);
 	/*! deinitalize a codec handle using this implementation */
-	switch_status (*destroy)(switch_codec *);
+	switch_status_t (*destroy)(switch_codec_t *);
 	const struct switch_codec_implementation *next;
 };
 
@@ -474,14 +509,8 @@
 struct switch_codec_interface {
 	/*! the name of the interface */
 	const char *interface_name;
-	/*! enumeration defining the type of the codec */
-	const switch_codec_type codec_type;
-	/*! the IANA code number */
-	switch_payload_t ianacode;
-	/*! the IANA code name */
-	char *iananame;
 	/*! a list of codec implementations related to the codec */
-	const switch_codec_implementation *implementations;
+	const switch_codec_implementation_t *implementations;
 	const struct switch_codec_interface *next;
 };
 
@@ -490,7 +519,7 @@
 	/*! the name of the interface */
 	const char *interface_name;
 	/*! function the application implements */
-	switch_application_function application_function;
+	switch_application_function_t application_function;
 	/*! the long winded description of the application */
 	const char *long_desc;
 	/*! the short and sweet description of the application */
@@ -507,12 +536,10 @@
 	/*! a description of the api function */
 	const char *desc;
 	/*! function the api call uses */
-	switch_api_function function;
+	switch_api_function_t function;
 	const struct switch_api_interface *next;
 };
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_platform.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_platform.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_platform.h	Fri Sep 22 14:22:15 2006
@@ -34,9 +34,7 @@
 #ifndef SWITCH_PLATFORM_H
 #define SWITCH_PLATFORM_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+SWITCH_BEGIN_EXTERN_C
 
 #ifdef __ICC
 #pragma warning (disable:810 869 981 279 1469 188)
@@ -46,12 +44,6 @@
 
 #ifdef _MSC_VER
 
-#ifndef FREESWITCHCORE_EXPORTS
-#pragma comment(lib, "FreeSwitchCore.lib")
-#pragma comment(lib, "libapr-1.lib")
-#pragma comment(lib, "libaprutil-1.lib")
-#pragma comment(lib, "libapriconv-1.lib")
-#endif
 
 /* disable the following warnings 
  * C4152: non standard extension, function/data ptr conversion in expression
@@ -63,8 +55,10 @@
  * C4706: assignment within conditional expression
  * C4055: type cast from data pointer to function pointer (apr carries function pointers as data pointers)
  * C4214: nonstandard extension used : bit field types other than int
+ * C4819: The file contains a character that cannot be represented in the current code page
+ * C4132: 'object' : const object should be initialized (fires innapropriately for prototyped forward declaration of cost var)
  */
-#pragma warning(disable:4152 4054 4100 4142 4200 4204 4706 4055 4214)
+#pragma warning(disable:4152 4054 4100 4142 4200 4204 4706 4055 4214 4819 4132 4510 4512 4610)
 
 #if (_MSC_VER >= 1400) // VC8+
 #ifndef _CRT_SECURE_NO_DEPRECATE
@@ -81,6 +75,9 @@
 #endif
 #endif
 
+#undef inline
+#define inline __inline
+
 #ifndef uint32_t
 typedef unsigned __int8		uint8_t;
 typedef unsigned __int16	uint16_t;
@@ -94,24 +91,18 @@
 #endif
 #define PACKED
 #include <io.h>
-#ifndef WIN32IOP_H //macro collision with perl
-#define write _write
-#define open _open
-#define close _close
-#define read _read
-#endif
 #else
 /* packed attribute */
 #ifndef PACKED
 #define PACKED __attribute__ ((__packed__))
 #endif
+#include <limits.h>
+#include <inttypes.h>
 #include <sys/types.h>
 #include <inttypes.h>
-#ifndef getpid
 #include <unistd.h>
 #include <stdlib.h>
 #include <time.h>
-#endif
 #endif // _MSC_VER
 
 
@@ -151,8 +142,6 @@
 #define DoxyDefine(x)
 #endif
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_resample.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_resample.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_resample.h	Fri Sep 22 14:22:15 2006
@@ -42,11 +42,9 @@
 #ifndef SWITCH_RESAMPLE_H
 #define SWITCH_RESAMPLE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include <stdlib.h>
 #include <switch.h>
+SWITCH_BEGIN_EXTERN_C
+#include <stdlib.h>
 
 /*!
   \defgroup resamp Audio Resample Functions
@@ -55,7 +53,7 @@
 */
 
 /*! \brief An audio resampling handle */
-struct switch_audio_resampler {
+typedef struct {
 	/*! a pointer to store the resampler object */
 	void *resampler;
 	/*! the rate to resample from in hz */
@@ -76,7 +74,7 @@
 	uint32_t to_len;
 	/*! the total size of the to buffer */
 	uint32_t to_size;
-};
+} switch_audio_resampler_t;
 
 /*!
   \brief Prepare a new resampler handle
@@ -88,18 +86,18 @@
   \param pool the memory pool to use for buffer allocation
   \return SWITCH_STATUS_SUCCESS if the handle was created
  */
-SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
+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 *pool);
+													 switch_memory_pool_t *pool);
 
 /*!
   \brief Destroy an existing resampler handle
   \param resampler the resampler handle to destroy
  */
-SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler);
+SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler);
 
 /*!
   \brief Resample one float buffer into another using specifications of a given handle
@@ -111,7 +109,7 @@
   \param last parameter denoting the last sample is being resampled
   \return the used size of dst
  */
-SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, uint32_t dstlen, int last);
+SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst, uint32_t dstlen, int last);
 
 /*!
   \brief Convert an array of floats to an array of shorts
@@ -158,10 +156,7 @@
 
 ///\}
 
-#ifdef __cplusplus
-}
-#endif
-
+SWITCH_END_EXTERN_C
 
 #endif
 

Modified: freeswitch/branches/voctel/src/include/switch_rtp.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_rtp.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_rtp.h	Fri Sep 22 14:22:15 2006
@@ -38,19 +38,14 @@
 #ifndef SWITCH_RTP_H
 #define SWITCH_RTP_H
 
-#ifdef __cplusplus
-extern "C" {
-#ifdef _FORMATBUG
-}
-#endif
-#endif
+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)(switch_rtp *rtp_session,
+typedef void (*switch_rtp_invalid_handler_t)(switch_rtp_t *rtp_session,
 										   switch_socket_t *sock,
 										   void *data,
 										   switch_size_t datalen,
@@ -61,7 +56,7 @@
   \param pool the memory pool to use for long term allocations
   \note Generally called by the core_init
 */
-SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool *pool);
+SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool);
 
 /*! 
   \brief Request a new port to be used for media
@@ -81,14 +76,15 @@
   \param pool a memory pool to use for the session
   \return the new RTP session or NULL on failure
 */
-SWITCH_DECLARE(switch_status)switch_rtp_create(switch_rtp **new_rtp_session,
-											   switch_payload_t payload,
-											   uint32_t packet_size,
-											   uint32_t ms_per_packet,
-											   switch_rtp_flag_t flags,
-											   char *crypto_key,
-											   const char **err,
-											   switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session,
+												 switch_payload_t payload,
+												 uint32_t packet_size,
+												 uint32_t ms_per_packet,
+												 switch_rtp_flag_t flags,
+												 char *crypto_key,
+												 char *timer_name,
+												 const char **err,
+												 switch_memory_pool_t *pool);
 
 
 /*!
@@ -106,17 +102,18 @@
   \param pool a memory pool to use for the session
   \return the new RTP session or NULL on failure
 */
-SWITCH_DECLARE(switch_rtp *)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 packet_size,
-										   uint32_t ms_per_packet,
-										   switch_rtp_flag_t flags,
-										   char *crypto_key,
-										   const char **err,
-										   switch_memory_pool *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 packet_size,
+											 uint32_t ms_per_packet,
+											 switch_rtp_flag_t flags,
+											 char *crypto_key,
+											 char *timer_name,
+											 const char **err,
+											 switch_memory_pool_t *pool);
 
 
 /*! 
@@ -126,7 +123,7 @@
   \param port the remote port
   \param err pointer for error messages
 */
-SWITCH_DECLARE(switch_status) switch_rtp_set_remote_address(switch_rtp *rtp_session, char *host, switch_port_t port, const char **err);
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err);
 
 /*! 
   \brief Assign a local address to the RTP session
@@ -136,32 +133,39 @@
   \param err pointer for error messages
   \note this call also binds the RTP session's socket to the new address
 */
-SWITCH_DECLARE(switch_status) switch_rtp_set_local_address(switch_rtp *rtp_session, char *host, switch_port_t port, const char **err);
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err);
 
 /*! 
   \brief Kill the socket on an existing RTP session
   \param rtp_session an RTP session to kill the socket of
 */
-SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp *rtp_session);
+SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session);
 
 /*! 
+  \brief Test if an RTP session is ready
+  \param rtp_session an RTP session to test
+  \return a true value if it's ready
+*/
+SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session);
+
+/*! 
   \brief Destroy an RTP session
   \param rtp_session an RTP session to destroy
 */
-SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp **rtp_session);
+SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session);
 
 /*! 
   \brief Acvite ICE on an RTP session
   \return SWITCH_STATUS_SUCCESS
 */
-SWITCH_DECLARE(switch_status) switch_rtp_activate_ice(switch_rtp *rtp_session, char *login, char *rlogin);
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin);
 
 /*!
   \brief Set an RTP Flag
   \param rtp_session the RTP session
   \param flags the flags to set
 */
-SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags);
+SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags);
 
 /*!
   \brief Test an RTP Flag
@@ -169,49 +173,49 @@
   \param flags the flags to test
   \return TRUE or FALSE
 */
-SWITCH_DECLARE(uint8_t) switch_rtp_test_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags);
+SWITCH_DECLARE(uint8_t) switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags);
 
 /*!
   \brief Clear an RTP Flag
   \param rtp_session the RTP session
   \param flags the flags to clear
 */
-SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags);
+SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags);
 
 /*! 
   \brief Retrieve the socket from an existing RTP session
   \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 *rtp_session);
+SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session);
 
 /*! 
   \brief Set the default packet size for a given RTP session
   \param rtp_session the RTP session to set the packet size on
   \param packet_size the new default packet size 
 */
-SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint16_t packet_size);
+SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp_t *rtp_session, uint16_t packet_size);
 
 /*! 
   \brief Get the default packet size for a given RTP session
   \param rtp_session the RTP session to get the packet size from
   \return the default packet_size of the RTP session
 */
-SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp *rtp_session);
+SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp_t *rtp_session);
 
 /*! 
   \brief Set the default payload number for a given RTP session
   \param rtp_session the RTP session to set the payload number on
   \param payload the new default payload number 
 */
-SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, switch_payload_t payload);
+SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp_t *rtp_session, switch_payload_t payload);
 
 /*! 
   \brief Get the default payload number for a given RTP session
   \param rtp_session the RTP session to get the payload number from
   \return the default payload of the RTP session
 */
-SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp *rtp_session);
+SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp_t *rtp_session);
 
 
 /*! 
@@ -220,7 +224,7 @@
   \param on_invalid the function to set
   \return 
 */
-SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid);
+SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid);
 
 /*! 
   \brief Read data from a given RTP session
@@ -231,9 +235,41 @@
   \param flags flags
   \return the number of bytes read
 */
-SWITCH_DECLARE(switch_status) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag *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
+  \param rtp_session the rtp session to use
+  \param digits the digit string to queue
+  \param duration the duration of the dtmf
+*/
+SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, char *digits, uint32_t duration);
+
+/*!
+  \brief Test for presence of DTMF on a given RTP session
+  \param rtp_session session to test
+  \return number of digits in the queue
+*/
+SWITCH_DECLARE(switch_size_t) switch_rtp_has_dtmf(switch_rtp_t *rtp_session);
+
+/*!
+  \brief Queue DTMF on a given RTP session
+  \param rtp_session RTP session to queue DTMF to
+  \param dtmf string of digits to queue
+  \return SWITCH_STATUS_SUCCESS if successful
+*/
+SWITCH_DECLARE(switch_status_t) switch_rtp_queue_dtmf(switch_rtp_t *rtp_session, char *dtmf);
+
+/*!
+  \brief Retrieve DTMF digits from a given RTP session
+  \param rtp_session RTP session to retrieve digits from
+  \param dtmf buffer to write dtmf to
+  \param len max size in bytes of the buffer
+  \return number of bytes read into the buffer
+*/
+SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, char *dtmf, switch_size_t len);
+
+/*! 
   \brief Read data from a given RTP session without copying
   \param rtp_session the RTP session to read from
   \param data a pointer to point directly to the RTP read buffer
@@ -242,7 +278,11 @@
   \param flags flags
   \return the number of bytes read
 */
-SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag *flags);
+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);
 
 /*! 
   \brief Read data from a given RTP session without copying
@@ -250,7 +290,7 @@
   \param frame a frame to populate with information
   \return the number of bytes read
 */
-SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_session, switch_frame *frame);
+SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame);
 
 /*! 
   \brief Write data to a given RTP session
@@ -261,8 +301,25 @@
   \param flags frame flags
   \return the number of bytes written
 */
-SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag *flags);
+SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag_t *flags);
 
+/*!
+  \brief Enable VAD on an RTP Session
+  \param rtp_session the RTP session
+  \param session the core session associated with the RTP session
+  \param codec the codec the channel is currenty using
+  \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);
+
+/*!
+  \brief Disable VAD on an RTP Session
+  \param rtp_session the RTP session
+  \return SWITCH_STAUTS_SUCCESS on success
+*/
+SWITCH_DECLARE(switch_status_t) switch_rtp_disable_vad(switch_rtp_t *rtp_session);
+
 /*! 
   \brief Write data to a given RTP session
   \param rtp_session the RTP session to write to
@@ -270,48 +327,54 @@
   \param ts then number of bytes to increment the timestamp by
   \return the number of bytes written
 */
-SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp *rtp_session, switch_frame *frame, uint32_t ts);
+SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, uint32_t ts);
 
 /*! 
   \brief Write data with a specified payload and sequence number to a given RTP session
   \param rtp_session the RTP session to write to
   \param data data to write
   \param datalen the size of the data
+  \param m set mark bit or not
   \param payload the IANA payload number
   \param ts then number of bytes to increment the timestamp by
   \param mseq the specific sequence number to use
   \param flags frame flags
   \return the number of bytes written
 */
-SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, uint16_t datalen, switch_payload_t payload, uint32_t ts, uint16_t mseq, switch_frame_flag *flags);
+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, switch_frame_flag_t *flags);
 
 /*! 
   \brief Retrieve the SSRC from a given RTP session
   \param rtp_session the RTP session to retrieve from
   \return the SSRC
 */
-SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp *rtp_session);
+SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session);
 
 /*! 
   \brief Associate an arbitrary data pointer with and RTP session
   \param rtp_session the RTP session to assign the pointer to
   \param private_data the private data to assign
 */
-SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp *rtp_session, void *private_data);
+SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data);
 
 /*! 
+  \brief Set the payload type to consider RFC2833 DTMF
+  \param rtp_session the RTP session to modify
+  \param te the payload type
+*/
+SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te);
+
+/*! 
   \brief Retrieve the private data from a given RTP session
   \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 *rtp_session);
+SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp_t *rtp_session);
 
 /*!
   \}
 */
 
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_sqlite.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_sqlite.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_sqlite.h	Fri Sep 22 14:22:15 2006
@@ -35,9 +35,7 @@
 #ifndef SWITCH_SQLITE_H
 #define SWITCH_SQLITE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+SWITCH_BEGIN_EXTERN_C
 
 #include <sqlite3.h>
 
@@ -57,8 +55,8 @@
  * Each open sqlite database is represented by an instance of the
  * following opaque structure.
 */
-typedef sqlite3 switch_core_db;
-typedef sqlite3_stmt switch_core_db_stmt;
+typedef sqlite3 switch_core_db_t;
+typedef sqlite3_stmt switch_core_db_stmt_t;
 /**
  * Aggregate functions use the following routine to allocate
  * a structure for storing their state.  The first time this routine
@@ -1806,10 +1804,6 @@
 /** @} */
 /** @} */
 
-
-
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_stun.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_stun.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_stun.h	Fri Sep 22 14:22:15 2006
@@ -36,6 +36,9 @@
 */
 #ifndef _SWITCH_STUN_PARSER_H
 #define _SWITCH_STUN_PARSER_H
+
+SWITCH_BEGIN_EXTERN_C
+
 #define SWITCH_STUN_DEFAULT_PORT 3478
 #define SWITCH_STUN_PACKET_MIN_LEN 20
 
@@ -206,12 +209,12 @@
   \param pool the memory pool to use
   \return SUCCESS or FAIL
 */
-SWITCH_DECLARE(switch_status) switch_stun_lookup (char **ip, 
+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 *pool);
+												  switch_memory_pool_t *pool);
 
 
 
@@ -236,4 +239,7 @@
 */
 #define switch_stun_packet_length(packet) ntohs(packet->header.length) + sizeof(switch_stun_packet_header_t)
 ///\}
+
+SWITCH_END_EXTERN_C
+
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_types.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_types.h	Fri Sep 22 14:22:15 2006
@@ -34,16 +34,10 @@
 #ifndef SWITCH_TYPES_H
 #define SWITCH_TYPES_H
 
-#ifdef __cplusplus
-extern "C" {
-#ifdef _FORMATBUG
-}
-#endif
-#endif
-
 #include <switch.h>
-#include <switch_platform.h>
 
+SWITCH_BEGIN_EXTERN_C
+
 #ifdef WIN32
 #define SWITCH_PATH_SEPARATOR "\\"
 #else
@@ -74,6 +68,42 @@
 #define SWITCH_SCRIPT_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "scripts"
 #endif
 
+#ifndef SWITCH_HTDOCS_DIR
+#define SWITCH_HTDOCS_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "htdocs"
+#endif
+
+#define SWITCH_BITS_PER_BYTE 8
+typedef uint8_t switch_byte_t;
+
+typedef enum {
+	SWITCH_BITPACK_MODE_RFC3551,
+	SWITCH_BITPACK_MODE_AAL2
+} switch_bitpack_mode_t;
+
+typedef enum {
+	SWITCH_ABC_TYPE_INIT,
+	SWITCH_ABC_TYPE_READ,
+	SWITCH_ABC_TYPE_WRITE,
+	SWITCH_ABC_TYPE_CLOSE,
+} switch_abc_type_t;
+
+typedef struct {
+	switch_byte_t *buf;
+	uint32_t buflen;
+	switch_byte_t *cur;
+	uint32_t bytes;
+	uint32_t bits_tot;
+	switch_byte_t bits_cur;
+	switch_byte_t bits_rem;
+	switch_byte_t frame_bits;
+	switch_byte_t shiftby;
+	switch_byte_t this_byte;
+	switch_byte_t under;
+	switch_byte_t over;
+	switch_bitpack_mode_t mode;
+} switch_bitpack_t;
+
+
 struct switch_directories {
 	char *base_dir;
 	char *mod_dir;
@@ -82,37 +112,86 @@
 	char *db_dir;
 	char *script_dir;
 	char *temp_dir;
+	char *htdocs_dir;
 };
 
 typedef struct switch_directories switch_directories;
 SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
 
-#define SWITCH_THREAD_STACKSIZE 512 * 1024
+#define SWITCH_THREAD_STACKSIZE 256 * 1024
 #define SWITCH_RECCOMMENDED_BUFFER_SIZE 2048
 #define SWITCH_MAX_CODECS 30
 #define SWITCH_MAX_STATE_HANDLERS 30
 #define SWITCH_TRUE 1
 #define SWITCH_FALSE 0
+#define SWITCH_CORE_QUEUE_LEN 100000
 
+
+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_t;
+
+typedef enum {
+	SWITCH_XML_SECTION_RESULT = 0,
+	SWITCH_XML_SECTION_CONFIG = (1 << 0),
+	SWITCH_XML_SECTION_DIRECTORY = (1 << 1),
+	SWITCH_XML_SECTION_DIALPLAN = (1 << 2)
+} switch_xml_section_t;
+
 /*!
+  \enum switch_vad_flag_t
+  \brief RTP Related Flags
+<pre>
+    SWITCH_VAD_FLAG_TALKING         - Currently Talking
+    SWITCH_VAD_FLAG_EVENTS_TALK     - Fire events when talking is detected
+	SWITCH_VAD_FLAG_EVENTS_NOTALK   - Fire events when not talking is detected
+	SWITCH_VAD_FLAG_CNG				- Send CNG
+</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_t;
+
+
+/*!
   \enum switch_rtp_flag_t
   \brief RTP Related Flags
 <pre>
-    SWITCH_RTP_FLAG_NOBLOCK      - Do not block
-    SWITCH_RTP_FLAG_IO           - IO is ready
-	SWITCH_RTP_FLAG_USE_TIMER    - Timeout Reads and replace with a CNG Frame
-	SWITCH_RTP_FLAG_SECURE       - Secure RTP
-	SWITCH_RTP_FLAG_AUTOADJ      - Auto-Adjust the dest based on the source
-	SWITCH_RTP_FLAG_RAW_WRITE    - Try to forward packets unscathed
+    SWITCH_RTP_FLAG_NOBLOCK       - Do not block
+    SWITCH_RTP_FLAG_IO            - IO is ready
+	SWITCH_RTP_FLAG_USE_TIMER     - Timeout Reads and replace with a CNG Frame
+	SWITCH_RTP_FLAG_TIMER_RECLOCK - Resync the timer to the current clock on slips
+	SWITCH_RTP_FLAG_SECURE        - Secure RTP
+	SWITCH_RTP_FLAG_AUTOADJ       - Auto-Adjust the dest based on the source
+	SWITCH_RTP_FLAG_RAW_WRITE     - Try to forward packets unscathed
+	SWITCH_RTP_FLAG_GOOGLEHACK    - Convert payload from 102 to 97
+	SWITCH_RTP_FLAG_VAD           - Enable VAD
+	SWITCH_RTP_FLAG_BREAK		  - Stop what you are doing and return SWITCH_STATUS_BREAK
+	SWITCH_RTP_FLAG_MINI		  - Use mini RTP when possible
+	SWITCH_RTP_FLAG_DATAWAIT	  - Do not return from reads unless there is data even when non blocking
 </pre>
  */
 typedef enum {
 	SWITCH_RTP_FLAG_NOBLOCK = ( 1 << 0),
 	SWITCH_RTP_FLAG_IO = (1 << 1),
 	SWITCH_RTP_FLAG_USE_TIMER = (1 << 2),
-	SWITCH_RTP_FLAG_SECURE = (1 << 3),
-	SWITCH_RTP_FLAG_AUTOADJ = (1 << 4),
-	SWITCH_RTP_FLAG_RAW_WRITE = (1 << 5)
+	SWITCH_RTP_FLAG_TIMER_RECLOCK = (1 << 3),
+	SWITCH_RTP_FLAG_SECURE = (1 << 4),
+	SWITCH_RTP_FLAG_AUTOADJ = (1 << 5),
+	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_DATAWAIT = (1 << 11)
 } switch_rtp_flag_t;
 
 /*!
@@ -144,9 +223,9 @@
 	SWITCH_IVR_OPTION_ASYNC = (1 << 0),
 	SWITCH_IVR_OPTION_FILE = (1 << 1)
 } switch_ivr_option_t;
-	
+
 /*!
-  \enum switch_core_session_message_t
+  \enum switch_core_session_message_types_t
   \brief Possible types of messages for inter-session communication
 <pre>
 	SWITCH_MESSAGE_REDIRECT_AUDIO     - Indication to redirect audio to another location if possible
@@ -162,7 +241,7 @@
 	SWITCH_MESSAGE_INDICATE_PROGRESS,
 	SWITCH_MESSAGE_INDICATE_BRIDGE,
 	SWITCH_MESSAGE_INDICATE_UNBRIDGE
-} switch_core_session_message_t;
+} switch_core_session_message_types_t;
 
 
 /*!
@@ -179,7 +258,7 @@
 } switch_stack_t;
 
 /*!
-  \enum switch_status
+  \enum switch_status_t
   \brief Common return values
 <pre>
     SWITCH_STATUS_SUCCESS	- General Success (common return value for most functions)
@@ -194,7 +273,9 @@
     SWITCH_STATUS_GENERR	- A general Error
     SWITCH_STATUS_INUSE		- An indication that requested resource is in use
 	SWITCH_STATUS_BREAK     - A non-fatal break of an operation
-    SWITCH_STATUS_SOCKERR  - A socket error
+    SWITCH_STATUS_SOCKERR   - A socket error
+	SWITCH_STATUS_MORE_DATA - Need More Data
+	SWITCH_STATUS_NOTFOUND  - Not Found
 </pre>
  */
 typedef enum {
@@ -210,13 +291,15 @@
 	SWITCH_STATUS_GENERR,
 	SWITCH_STATUS_INUSE,
 	SWITCH_STATUS_BREAK,
-	SWITCH_STATUS_SOCKERR
-} switch_status;
+	SWITCH_STATUS_SOCKERR,
+	SWITCH_STATUS_MORE_DATA,
+	SWITCH_STATUS_NOTFOUND
+} switch_status_t;
 
 
 
 /*!
-\enum switch_log_level
+\enum switch_log_level_t
 \brief Log Level Enumeration
 <pre>
     SWITCH_LOG_CONSOLE          - Console
@@ -240,11 +323,11 @@
 	SWITCH_LOG_CRIT = 2,
 	SWITCH_LOG_ALERT = 1,
 	SWITCH_LOG_EMERG = 0
-} switch_log_level;
+} switch_log_level_t;
 
 
 /*!
-\enum switch_text_channel
+\enum switch_text_channel_t
 \brief A target to write log/debug info to
 <pre>
 SWITCH_CHANNEL_ID_LOG			- Write to the currently defined log
@@ -256,7 +339,7 @@
 	SWITCH_CHANNEL_ID_LOG,
 	SWITCH_CHANNEL_ID_LOG_CLEAN,
 	SWITCH_CHANNEL_ID_EVENT
-} switch_text_channel;
+} switch_text_channel_t;
 
 #define SWITCH_UUID_FORMATTED_LENGTH APR_UUID_FORMATTED_LENGTH 	
 #define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __FUNCTION__, __LINE__
@@ -264,7 +347,7 @@
 #define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __FUNCTION__, __LINE__
 
 /*!
-  \enum switch_channel_state
+  \enum switch_channel_state_t
   \brief Channel States
 <pre>
 CS_NEW       - Channel is newly created 
@@ -273,6 +356,7 @@
 CS_TRANSMIT  - Channel is in a passive transmit state
 CS_EXECUTE   - Channel is executing it's dialplan 
 CS_LOOPBACK  - Channel is in loopback
+CS_HOLD		 - Channel is on hold
 CS_HANGUP    - Channel is flagged for hangup and ready to end
 CS_DONE      - Channel is ready to be destroyed and out of the state machine
 </pre>
@@ -284,13 +368,14 @@
 	CS_TRANSMIT,
 	CS_EXECUTE,
 	CS_LOOPBACK,
+	CS_HOLD,
 	CS_HANGUP,
 	CS_DONE 
-} switch_channel_state;
+} switch_channel_state_t;
 
 
 /*!
-  \enum switch_channel_flag
+  \enum switch_channel_flag_t
   \brief Channel Flags
 
 <pre>
@@ -299,7 +384,14 @@
 CF_EARLY_MEDIA  = (1 <<  2) - Channel is ready for audio before answer 
 CF_ORIGINATOR	= (1 <<  3) - Channel is an originator
 CF_TRANSFER		= (1 <<  4) - Channel is being transfered
-CF_ACCEPT_CNG     = (1 <<  5) - Channel will accept CNG frames
+CF_ACCEPT_CNG	= (1 <<  5) - Channel will accept CNG frames
+CF_LOCK_THREAD	= (1 <<  6) - Prevent the channel thread from exiting while this flag is set
+CF_BRIDGED		= (1 <<  7) - Channel in a bridge
+CF_HOLD			= (1 <<  8) - Channel is on hold
+CF_SERVICE		= (1 <<  9) - Channel has a service thread
+CF_TAGGED		= (1 << 10) - Channel is tagged
+CF_WINNER		= (1 << 11) - Channel is the winner
+CF_CONTROLLED	= (1 << 12) - Channel is under control
 </pre>
  */
 
@@ -309,12 +401,19 @@
 	CF_EARLY_MEDIA	= (1 <<  2),
 	CF_ORIGINATOR	= (1 <<  3),
 	CF_TRANSFER		= (1 <<  4),
-	CF_ACCEPT_CNG     = (1 <<  5)
-} switch_channel_flag;
+	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)
+} switch_channel_flag_t;
 
 
 /*!
-  \enum switch_frame_flag
+  \enum switch_frame_flag_t
   \brief Frame Flags
 
 <pre>
@@ -323,25 +422,29 @@
 </pre>
  */
 typedef enum {
+	SFF_NONE = 0,
 	SFF_CNG = (1 << 0),
 	SFF_RAW_RTP = (1 << 1)
-} switch_frame_flag;
+} switch_frame_flag_t;
 
 
 /*!
-  \enum switch_signal
+  \enum switch_signal_t
   \brief Signals to send to channels
 <pre>
 SWITCH_SIG_KILL - Kill the channel
+SWITCH_SIG_XFER - Stop the current io but leave it viable
 </pre>
  */
 
 typedef enum {
-	SWITCH_SIG_KILL
-} switch_signal;
+	SWITCH_SIG_NONE,
+	SWITCH_SIG_KILL,
+	SWITCH_SIG_XFER
+} switch_signal_t;
 
 /*!
-  \enum switch_codec_flag
+  \enum switch_codec_flag_t
   \brief Codec related flags
 <pre>
 SWITCH_CODEC_FLAG_ENCODE =			(1 <<  0) - Codec can encode
@@ -350,6 +453,8 @@
 SWITCH_CODEC_FLAG_SILENCE_STOP =	(1 <<  3) - End period of silence
 SWITCH_CODEC_FLAG_SILENCE =			(1 <<  4) - Silence
 SWITCH_CODEC_FLAG_FREE_POOL =		(1 <<  5) - Free codec's pool on destruction
+SWITCH_CODEC_FLAG_AAL2 =			(1 <<  6) - USE AAL2 Bitpacking
+SWITCH_CODEC_FLAG_PASSTHROUGH =		(1 <<  7) - Passthrough only
 </pre>
 */
 typedef enum {
@@ -359,12 +464,13 @@
 	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;
 
-} switch_codec_flag;
 
-
 /*!
-  \enum switch_speech_flag
+  \enum switch_speech_flag_t
   \brief Speech related flags
 <pre>
 SWITCH_SPEECH_FLAG_TTS =			(1 <<  0) - Interface can/should convert text to speech.
@@ -373,6 +479,7 @@
 SWITCH_SPEECH_FLAG_PEEK =			(1 <<  3) - Read data but do not erase it.
 SWITCH_SPEECH_FLAG_FREE_POOL =		(1 <<  4) - Free interface's pool on destruction.
 SWITCH_SPEECH_FLAG_BLOCKING =       (1 <<  5) - Indicate that a blocking call is desired 
+SWITCH_SPEECH_FLAG_PAUSE = 			(1 <<  6) - Pause toggle for playback
 </pre>
 */
 typedef enum {
@@ -382,12 +489,13 @@
 	SWITCH_SPEECH_FLAG_PEEK =			(1 <<  3),
 	SWITCH_SPEECH_FLAG_FREE_POOL =		(1 <<  4),
 	SWITCH_SPEECH_FLAG_BLOCKING =		(1 <<  5),
+	SWITCH_SPEECH_FLAG_PAUSE =			(1 <<  6)
 
-} switch_speech_flag;
+} switch_speech_flag_t;
 
 
 /*!
-  \enum switch_directory_flag
+  \enum switch_directory_flag_t
   \brief Directory Handle related flags
 <pre>
 SWITCH_DIRECTORY_FLAG_FREE_POOL =		(1 <<  0) - Free interface's pool on destruction.
@@ -396,10 +504,10 @@
 typedef enum {
 	SWITCH_DIRECTORY_FLAG_FREE_POOL =		(1 <<  0),
 
-} switch_directory_flag;
+} switch_directory_flag_t;
 
 /*!
-  \enum switch_codec_type
+  \enum switch_codec_type_t
   \brief Codec types
 <pre>
 SWITCH_CODEC_TYPE_AUDIO - Audio Codec
@@ -413,11 +521,11 @@
 	SWITCH_CODEC_TYPE_VIDEO,
 	SWITCH_CODEC_TYPE_T38,
 	SWITCH_CODEC_TYPE_APP
-} switch_codec_type;
+} switch_codec_type_t;
 
 
 /*!
-  \enum switch_timer_flag
+  \enum switch_timer_flag_t
   \brief Timer related flags
 <pre>
 SWITCH_TIMER_FLAG_FREE_POOL =		(1 <<  0) - Free timer's pool on destruction
@@ -425,10 +533,10 @@
 */
 typedef enum {
 		SWITCH_TIMER_FLAG_FREE_POOL =		(1 <<  0),
-} switch_timer_flag;
+} switch_timer_flag_t;
 
 /*!
-  \enum switch_file_flag
+  \enum switch_file_flag_t
   \brief File flags
 <pre>
 SWITCH_FILE_FLAG_READ =         (1 <<  0) - Open for read
@@ -452,28 +560,33 @@
 	SWITCH_FILE_DATA_DOUBLE =		(1 <<  6),
 	SWITCH_FILE_DATA_RAW =			(1 <<  7),
 	SWITCH_FILE_PAUSE =				(1 <<  8)
-} switch_file_flag;
+} switch_file_flag_t;
 
 typedef enum {
 	SWITCH_IO_FLAG_NOOP = 0,
-} switch_io_flag;
+} switch_io_flag_t;
 
 /* make sure this is synced with the EVENT_NAMES array in switch_event.c
    also never put any new ones before EVENT_ALL
 */
 /*!
-  \enum switch_event_t
+  \enum switch_event_types_t
   \brief Built-in Events
 
 <pre>
     SWITCH_EVENT_CUSTOM				- A custom event
-    SWITCH_EVENT_CHANNEL_CREATE		- A channel has changed state
+    SWITCH_EVENT_CHANNEL_CREATE		- A channel has been created
+    SWITCH_EVENT_CHANNEL_DESTROY	- A channel has been destroyed
     SWITCH_EVENT_CHANNEL_STATE		- A channel has changed state
     SWITCH_EVENT_CHANNEL_ANSWER		- A channel has been answered
     SWITCH_EVENT_CHANNEL_HANGUP		- A channel has been hungup
     SWITCH_EVENT_CHANNEL_EXECUTE	- A channel has executed a module's application
 	SWITCH_EVENT_CHANNEL_BRIDGE     - A channel has bridged to another channel
 	SWITCH_EVENT_CHANNEL_UNBRIDGE   - A channel has unbridged from another channel
+    SWITCH_EVENT_CHANNEL_PROGRESS	- A channel has been parked
+    SWITCH_EVENT_CHANNEL_OUTGOING	- A channel has been unparked
+	SWITCH_EVENT_CHANNEL_PARK 		- A channel has been parked
+	SWITCH_EVENT_CHANNEL_UNPARK 	- A channel has been unparked
     SWITCH_EVENT_API				- An API call has been executed
     SWITCH_EVENT_LOG				- A LOG event has been triggered
     SWITCH_EVENT_INBOUND_CHAN		- A new inbound channel has been created
@@ -482,6 +595,14 @@
     SWITCH_EVENT_SHUTDOWN			- The system has been shutdown
 	SWITCH_EVENT_PUBLISH			- Publish
 	SWITCH_EVENT_UNPUBLISH			- UnPublish
+	SWITCH_EVENT_TALK				- Talking Detected
+	SWITCH_EVENT_NOTALK				- Not Talking Detected
+	SWITCH_EVENT_SESSION_CRASH		- Session Crashed
+	SWITCH_EVENT_MODULE_LOAD		- Module was loaded
+	SWITCH_EVENT_DTMF				- DTMF was sent
+	SWITCH_EVENT_MESSAGE			- A Basic Message
+	SWITCH_EVENT_CODEC				- Codec Change
+	SWITCH_EVENT_BACKGROUND_JOB		- Background Job
     SWITCH_EVENT_ALL				- All events at once
 </pre>
 
@@ -489,12 +610,17 @@
 typedef enum {
 	SWITCH_EVENT_CUSTOM,
 	SWITCH_EVENT_CHANNEL_CREATE,
+	SWITCH_EVENT_CHANNEL_DESTROY,
 	SWITCH_EVENT_CHANNEL_STATE,
 	SWITCH_EVENT_CHANNEL_ANSWER,
 	SWITCH_EVENT_CHANNEL_HANGUP,
 	SWITCH_EVENT_CHANNEL_EXECUTE,
 	SWITCH_EVENT_CHANNEL_BRIDGE,
 	SWITCH_EVENT_CHANNEL_UNBRIDGE,
+	SWITCH_EVENT_CHANNEL_PROGRESS,
+	SWITCH_EVENT_CHANNEL_OUTGOING,
+	SWITCH_EVENT_CHANNEL_PARK,
+	SWITCH_EVENT_CHANNEL_UNPARK,
 	SWITCH_EVENT_API,
 	SWITCH_EVENT_LOG,
 	SWITCH_EVENT_INBOUND_CHAN,
@@ -503,86 +629,180 @@
 	SWITCH_EVENT_SHUTDOWN,
 	SWITCH_EVENT_PUBLISH,
 	SWITCH_EVENT_UNPUBLISH,
+	SWITCH_EVENT_TALK,
+	SWITCH_EVENT_NOTALK,
+	SWITCH_EVENT_SESSION_CRASH,
+	SWITCH_EVENT_MODULE_LOAD,
+	SWITCH_EVENT_DTMF,
+	SWITCH_EVENT_MESSAGE,
+	SWITCH_EVENT_CODEC,
+	SWITCH_EVENT_BACKGROUND_JOB,
 	SWITCH_EVENT_ALL
-} switch_event_t;
+} switch_event_types_t;
 
+typedef enum {
+	SWITCH_INPUT_TYPE_DTMF,
+	SWITCH_INPUT_TYPE_EVENT
+} switch_input_type_t;
+
+typedef enum {
+	SWITCH_CAUSE_UNALLOCATED = 1,
+	SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
+	SWITCH_CAUSE_NO_ROUTE_DESTINATION = 3,
+	SWITCH_CAUSE_CHANNEL_UNACCEPTABLE = 6,
+	SWITCH_CAUSE_CALL_AWARDED_DELIVERED = 7,
+	SWITCH_CAUSE_NORMAL_CLEARING = 16,
+	SWITCH_CAUSE_USER_BUSY = 17,
+	SWITCH_CAUSE_NO_USER_RESPONSE = 18,
+	SWITCH_CAUSE_NO_ANSWER = 19,
+	SWITCH_CAUSE_CALL_REJECTED = 21,
+	SWITCH_CAUSE_NUMBER_CHANGED = 22,
+	SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
+	SWITCH_CAUSE_INVALID_NUMBER_FORMAT = 28,
+	SWITCH_CAUSE_FACILITY_REJECTED = 29,
+	SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
+	SWITCH_CAUSE_NORMAL_UNSPECIFIED = 31,
+	SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
+	SWITCH_CAUSE_NETWORK_OUT_OF_ORDER = 38,
+	SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
+	SWITCH_CAUSE_SWITCH_CONGESTION = 42,
+	SWITCH_CAUSE_ACCESS_INFO_DISCARDED = 43,
+	SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
+	SWITCH_CAUSE_PRE_EMPTED = 45,
+	SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
+	SWITCH_CAUSE_OUTGOING_CALL_BARRED = 52,
+	SWITCH_CAUSE_INCOMING_CALL_BARRED = 54,
+	SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
+	SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
+	SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
+	SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
+	SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
+	SWITCH_CAUSE_INVALID_CALL_REFERENCE = 81,
+	SWITCH_CAUSE_INCOMPATIBLE_DESTINATION = 88,
+	SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
+	SWITCH_CAUSE_MANDATORY_IE_MISSING = 96,
+	SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
+	SWITCH_CAUSE_WRONG_MESSAGE = 98,
+	SWITCH_CAUSE_IE_NONEXIST = 99,
+	SWITCH_CAUSE_INVALID_IE_CONTENTS = 100,
+	SWITCH_CAUSE_WRONG_CALL_STATE = 101,
+	SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
+	SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
+	SWITCH_CAUSE_PROTOCOL_ERROR = 111,
+	SWITCH_CAUSE_INTERWORKING = 127,
+	SWITCH_CAUSE_CRASH = 500,
+	SWITCH_CAUSE_SYSTEM_SHUTDOWN = 501,
+	SWITCH_CAUSE_LOSE_RACE = 502,
+	SWITCH_CAUSE_MANAGER_REQUEST = 503
+} switch_call_cause_t;
+
+typedef enum {
+	SCSC_PAUSE_INBOUND,
+	SCSC_HUPALL,
+	SCSC_SHUTDOWN,
+	SCSC_CHECK_RUNNING
+} switch_session_ctl_t;
+
 typedef uint8_t switch_payload_t;
-typedef struct switch_rtp switch_rtp;
-typedef struct switch_core_session_message switch_core_session_message;
-typedef struct switch_audio_resampler switch_audio_resampler;
-typedef struct switch_event_header switch_event_header;
-typedef struct switch_event switch_event;
-typedef struct switch_event_subclass switch_event_subclass;
-typedef struct switch_event_node switch_event_node;
-typedef struct switch_loadable_module switch_loadable_module;
-typedef struct switch_frame switch_frame;
-typedef struct switch_channel switch_channel;
-typedef struct switch_endpoint_interface switch_endpoint_interface;
-typedef struct switch_timer_interface switch_timer_interface;
-typedef struct switch_dialplan_interface switch_dialplan_interface;
-typedef struct switch_codec_interface switch_codec_interface;
-typedef struct switch_application_interface switch_application_interface;
-typedef struct switch_api_interface switch_api_interface;
-typedef struct switch_file_interface switch_file_interface;
-typedef struct switch_file_handle switch_file_handle;
-typedef struct switch_core_session switch_core_session;
-typedef struct switch_loadable_module_interface switch_loadable_module_interface;
-typedef struct switch_caller_profile switch_caller_profile;
-typedef struct switch_caller_step switch_caller_step;
-typedef struct switch_caller_extension switch_caller_extension;
-typedef struct switch_caller_application switch_caller_application;
-typedef struct switch_state_handler_table switch_state_handler_table;
-typedef struct switch_timer switch_timer;
-typedef struct switch_codec switch_codec;
-typedef struct switch_core_thread_session switch_core_thread_session;
-typedef struct switch_codec_implementation switch_codec_implementation;
-typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel;
-typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel;
-typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message;
-typedef struct switch_io_event_hook_queue_event switch_io_event_hook_queue_event;
-typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame;
-typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame;
-typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel;
-typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read;
-typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write;
-typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf;
-typedef struct switch_io_routines switch_io_routines;
-typedef struct switch_io_event_hooks switch_io_event_hooks;
-typedef struct switch_buffer switch_buffer;
-typedef struct switch_codec_settings switch_codec_settings;
-typedef struct switch_config switch_config;
-typedef struct switch_speech_handle switch_speech_handle;
-typedef struct switch_speech_interface switch_speech_interface;
-typedef struct switch_directory_handle switch_directory_handle;
-typedef struct switch_directory_interface switch_directory_interface;
-typedef void (*switch_application_function)(switch_core_session *, char *);
-typedef void (*switch_event_callback_t)(switch_event *);
-typedef switch_caller_extension *(*switch_dialplan_hunt_function)(switch_core_session *);
-typedef switch_status (*switch_state_handler)(switch_core_session *);
-typedef switch_status (*switch_outgoing_channel_hook)(switch_core_session *, switch_caller_profile *, switch_core_session *);
-typedef switch_status (*switch_answer_channel_hook)(switch_core_session *);
-typedef switch_status (*switch_receive_message_hook)(switch_core_session *, switch_core_session_message *);
-typedef switch_status (*switch_queue_event_hook)(switch_core_session *, switch_event *);
-typedef switch_status (*switch_read_frame_hook)(switch_core_session *, switch_frame **, int, switch_io_flag, int);
-typedef switch_status (*switch_write_frame_hook)(switch_core_session *, switch_frame *, int, switch_io_flag, int);
-typedef switch_status (*switch_kill_channel_hook)(switch_core_session *, int);
-typedef switch_status (*switch_waitfor_read_hook)(switch_core_session *, int, int);
-typedef switch_status (*switch_waitfor_write_hook)(switch_core_session *, int, int);
-typedef switch_status (*switch_send_dtmf_hook)(switch_core_session *, char *);
-typedef switch_status (*switch_api_function)(char *in, char *out, switch_size_t outlen);
-typedef switch_status (*switch_dtmf_callback_function)(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen);
-typedef int (*switch_core_db_callback_func)(void *pArg, int argc, char **argv, char **columnNames);
+typedef struct switch_rtp switch_rtp_t;
+typedef struct switch_core_session_message switch_core_session_message_t;
+typedef struct switch_event_header switch_event_header_t;
+typedef struct switch_event switch_event_t;
+typedef struct switch_event_subclass switch_event_subclass_t;
+typedef struct switch_event_node switch_event_node_t;
+typedef struct switch_loadable_module switch_loadable_module_t;
+typedef struct switch_frame switch_frame_t;
+typedef struct switch_channel switch_channel_t;
+typedef struct switch_file_handle switch_file_handle_t;
+typedef struct switch_core_session switch_core_session_t;
+typedef struct switch_caller_profile switch_caller_profile_t;
+typedef struct switch_caller_extension switch_caller_extension_t;
+typedef struct switch_caller_application switch_caller_application_t;
+typedef struct switch_state_handler_table switch_state_handler_table_t;
+typedef struct switch_timer switch_timer_t;
+typedef struct switch_codec switch_codec_t;
+typedef struct switch_core_thread_session switch_core_thread_session_t;
+typedef struct switch_codec_implementation switch_codec_implementation_t;
+typedef struct switch_buffer switch_buffer_t;
+typedef struct switch_codec_settings switch_codec_settings_t;
+typedef struct switch_config switch_config_t;
 
-/* things we don't deserve to know about */
+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_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_directory_handle switch_directory_handle_t;
+
+typedef struct switch_loadable_module_interface switch_loadable_module_interface_t;
+typedef struct switch_endpoint_interface switch_endpoint_interface_t;
+typedef struct switch_timer_interface switch_timer_interface_t;
+typedef struct switch_dialplan_interface switch_dialplan_interface_t;
+typedef struct switch_codec_interface switch_codec_interface_t;
+typedef struct switch_application_interface switch_application_interface_t;
+typedef struct switch_api_interface switch_api_interface_t;
+typedef struct switch_file_interface switch_file_interface_t;
+typedef struct switch_speech_interface switch_speech_interface_t;
+typedef struct switch_directory_interface switch_directory_interface_t;
+typedef struct switch_core_port_allocator switch_core_port_allocator_t;
+typedef struct switch_media_bug switch_media_bug_t;
+typedef void (*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 *);
+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 struct switch_stream_handle switch_stream_handle_t;
+typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, 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 int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
+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);
+typedef switch_status_t (*switch_module_resume_t) (void);
+typedef switch_status_t (*switch_module_status_t) (void);
+typedef switch_status_t (*switch_module_runtime_t) (void);
+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)(char *section,
+													 char *tag_name,
+													 char *key_name,
+													 char *key_value,
+													 char *params);
+
+
+/* things we don't deserve to know about */
 /*! \brief A channel */
 struct switch_channel;
 /*! \brief A core session representing a call and all of it's resources */
 struct switch_core_session;
+/*! \brief An audio bug */
+struct switch_media_bug;
 
-
-#ifdef __cplusplus
-}
-#endif
+SWITCH_END_EXTERN_C
 
 #endif

Modified: freeswitch/branches/voctel/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/voctel/src/include/switch_utils.h	(original)
+++ freeswitch/branches/voctel/src/include/switch_utils.h	Fri Sep 22 14:22:15 2006
@@ -38,14 +38,10 @@
 #ifndef SWITCH_UTILS_H
 #define SWITCH_UTILS_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <switch.h>
 
+SWITCH_BEGIN_EXTERN_C
 
-
 #ifndef snprintf
 #define snprintf apr_snprintf
 #endif
@@ -54,6 +50,12 @@
 #endif
 
 
+#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;
+
+
+
 /*!
   \brief Evaluate the truthfullness of a string expression
   \param expr a string expression
@@ -65,9 +67,8 @@
 !strcasecmp(expr, "true") ||\
 atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
 
+#define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
 
-SWITCH_DECLARE(switch_status) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, switch_size_t *len);
-
 /*!
   \brief Return a printable name of a switch_priority_t
   \param priority the priority to get the name of
@@ -90,6 +91,13 @@
 SWITCH_DECLARE(unsigned char) switch_char_to_rfc2833(char key);
 
 /*!
+  \brief determine if a character is a valid DTMF key
+  \param key the key to test
+  \return TRUE or FALSE
+ */
+#define is_dtmf(key)  ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42)
+
+/*!
   \brief Duplicate a string 
 */
 #define switch_copy_string apr_cpystrn
@@ -110,10 +118,27 @@
 #define switch_set_flag(obj, flag) (obj)->flags |= (flag)
 
 /*!
+  \brief Set a flag on an arbitrary object while locked
+  \param obj the object to set the flags on
+  \param flag the or'd list of flags to set
+*/
+#define switch_set_flag_locked(obj, flag) assert(obj->flag_mutex != NULL);\
+switch_mutex_lock(obj->flag_mutex);\
+(obj)->flags |= (flag);\
+switch_mutex_unlock(obj->flag_mutex);
+
+/*!
   \brief Clear a flag on an arbitrary object
   \param obj the object to test
   \param flag the or'd list of flags to clear
 */
+#define switch_clear_flag_locked(obj, flag) switch_mutex_lock(obj->flag_mutex); (obj)->flags &= ~(flag); switch_mutex_unlock(obj->flag_mutex);
+
+/*!
+  \brief Clear a flag on an arbitrary object while locked
+  \param obj the object to test
+  \param flag the or'd list of flags to clear
+*/
 #define switch_clear_flag(obj, flag) (obj)->flags &= ~(flag)
 
 /*!
@@ -124,7 +149,14 @@
 */
 #define switch_copy_flags(dest, src, flags) (dest)->flags &= ~(flags);	(dest)->flags |= ((src)->flags & (flags))
 
+
 /*!
+  \brief Free a pointer and set it to NULL unles it already is NULL
+  \param it the pointer
+*/
+#define switch_safe_free(it) if (it) {free(it);it=NULL;}
+
+/*!
   \brief Test for NULL or zero length string
   \param s the string to test
   \return true value if the string is NULL or zero length
@@ -134,14 +166,21 @@
 /*!
   \brief Wait a desired number of microseconds and yield the CPU
 */
-#define switch_yield(ms) apr_sleep(ms * 10); apr_thread_yield();
+#if defined(HAVE_USLEEP)
+#define switch_yield(ms) usleep(ms);
+#elif defined(WIN32)
+#define switch_yield(ms) Sleep((DWORD)((ms) / 1000));
+#else
+#define switch_yield(ms) apr_sleep(ms); //apr_thread_yield();
+#endif
 
 /*!
   \brief Declares a function designed to set a dymaic global string
   \param fname the function name to declare
   \param vname the name of the global pointer to modify with the new function
 */
-#define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(char *string) { if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
+#define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(char *string) { if (!string) return;\
+if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
 
 /*!
   \brief Separate a string into an array based on a character delimeter
@@ -161,7 +200,7 @@
   \param pool the memory pool to use
   \return SWITCH_STATUS_SUCCESS when successful
 */
-SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, switch_int16_t flags, switch_memory_pool *pool);
+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, switch_int16_t flags, switch_memory_pool_t *pool);
 
 /*!
   \brief Wait for a socket
@@ -178,10 +217,11 @@
 SWITCH_DECLARE(char *) switch_cut_path(char *in);
 
 SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *search, const char *replace);
-SWITCH_DECLARE(switch_status) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len);
+SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len);
 
-#ifdef __cplusplus
-}
-#endif
+#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
 
 #endif

Modified: freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.c	Fri Sep 22 14:22:15 2006
@@ -36,51 +36,39 @@
 
 static const char modname[] = "mod_bridgecall";
 
-static void audio_bridge_function(switch_core_session *session, char *data)
+static void audio_bridge_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *caller_channel;
-	switch_core_session *peer_session;
-	switch_caller_profile *caller_profile, *caller_caller_profile;
-	char chan_type[128] = { '\0' }, *chan_data;
-	unsigned int timelimit = 60;			/* probably a useful option to pass in when there's time */
+	switch_channel_t *caller_channel;
+	switch_core_session_t *peer_session;
+	unsigned int timelimit = 60;
+	char *var;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+
 	caller_channel = switch_core_session_get_channel(session);
 	assert(caller_channel != NULL);
 
-
-	strncpy(chan_type, data, sizeof(chan_type));
-
-	if ((chan_data = strchr(chan_type, '/')) != 0) {
-		*chan_data = '\0';
-		chan_data++;
+	if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
+		timelimit = atoi(var);
 	}
 
-	caller_caller_profile = switch_channel_get_caller_profile(caller_channel);
-	caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-											   caller_caller_profile->dialplan,
-											   caller_caller_profile->caller_id_name,
-											   caller_caller_profile->caller_id_number,
-											   caller_caller_profile->network_addr, NULL, NULL, chan_data);
-
-
-
-	if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session, NULL) !=
-		SWITCH_STATUS_SUCCESS) {
+	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_ERROR, "Cannot Create Outgoing Channel!\n");
-		switch_channel_hangup(caller_channel);
+		/* Hangup the channel with the cause code from the failed originate.*/
+		switch_channel_hangup(caller_channel, cause);
 		return;
 	} else {
-		switch_ivr_multi_threaded_bridge(session, peer_session, timelimit, NULL, NULL, NULL);
+		switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
 	}
 }
 
 
-static const switch_application_interface bridge_application_interface = {
+static const switch_application_interface_t bridge_application_interface = {
 	/*.interface_name */ "bridge",
 	/*.application_function */ audio_bridge_function
 };
 
 
-static const switch_loadable_module_interface mod_bridgecall_module_interface = {
+static const switch_loadable_module_interface_t mod_bridgecall_module_interface = {
 	/*.module_name = */ modname,
 	/*.endpoint_interface = */ NULL,
 	/*.timer_interface = */ NULL,
@@ -89,11 +77,11 @@
 	/*.application_interface */ &bridge_application_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &mod_bridgecall_module_interface;
+	*module_interface = &mod_bridgecall_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_bridgecall/mod_bridgecall.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_bridgecall.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_bridgecall.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_bridgecall.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_bridgecall.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.c	Fri Sep 22 14:22:15 2006
@@ -24,6 +24,8 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
+ * Johny Kadarisman <jkr888 at gmail.com>
  *
  * 
  * mod_commands.c -- Misc. Command Module
@@ -33,48 +35,538 @@
 
 static const char modname[] = "mod_commands";
 
+static switch_status_t status_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	uint8_t html = 0;
+	switch_core_time_duration_t duration;
+	char *http = NULL;
 
-static switch_status kill_function(char *dest, char *out, size_t outlen)
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	switch_core_measure_time(switch_core_uptime(), &duration);
+
+	if (stream->event) {
+        http = switch_event_get_header(stream->event, "http-host");
+    }
+
+	if (http || (cmd && strstr(cmd, "html"))) {
+		html = 1;
+		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, "%d sessions\n", switch_core_session_count());
+	
+	if (html) {
+		stream->write_function(stream, "</b>\n");
+	}
+
+	if (cmd && strstr(cmd, "refresh=")) {
+		char *refresh = strchr(cmd, '=');
+		if (refresh) {
+			int r;
+			refresh++;
+			r = atoi(refresh);
+			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" : "");
+			}
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t ctl_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	switch_core_session *session = NULL;
+	int argc;
+	char *mydata, *argv[5];
+	uint32_t arg = 0;
 
-	if ((session = switch_core_session_locate(dest))) {
-		switch_channel *channel = switch_core_session_get_channel(session);
-		switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
-		switch_channel_hangup(channel);
-		snprintf(out, outlen, "OK\n");
+	if (switch_strlen_zero(data)) {
+		stream->write_function(stream, "USAGE: fsctl [hupall|pause|resume|shutdown]\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	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);
+		} else if (!strcmp(argv[0], "pause")) {
+			arg = 1;
+			switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+		} else if (!strcmp(argv[0], "resume")) {
+			arg = 0;
+			switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
+		} else if (!strcmp(argv[0], "shutdown")) {
+			arg = 0;
+			switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
+		} else {
+			stream->write_function(stream, "INVALID COMMAND [%s]\n", argv[0]);
+			goto end;
+		} 
+
+		stream->write_function(stream, "OK\n");
+	end:
+		free(mydata);
 	} else {
-		snprintf(out, outlen, "No Such Channel!\n");
+		stream->write_function(stream, "MEM ERR\n");
 	}
 
+    return SWITCH_STATUS_SUCCESS;
+	
+}
+
+
+static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+	switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod);
+	stream->write_function(stream, "OK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static struct switch_api_interface commands_api_interface = {
+static switch_status_t reload_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	const char *err;
+	switch_xml_t xml_root;
+
+	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;
+}
+
+static switch_status_t kill_function(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+	switch_core_session_t *session = NULL;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (dest && (session = switch_core_session_locate(dest))) {
+		switch_channel_t *channel = switch_core_session_get_channel(session);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		switch_core_session_rwunlock(session);
+		stream->write_function(stream, "OK\n");
+	} else {
+		stream->write_function(stream, "No Such Channel!\n");
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+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};
+	int argc = 0;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+	
+	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+	if (argc < 2 || argc > 4) {
+		stream->write_function(stream, "Invalid Parameters\n");
+	} else {
+		char *uuid = argv[0];
+		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");
+			} else {
+				stream->write_function(stream, "ERROR\n");
+			}
+
+			switch_core_session_rwunlock(session);
+
+		} else {
+			stream->write_function(stream, "No Such Channel!\n");
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+	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 (argc != 2) {
+		stream->write_function(stream, "Invalid Parameters\nUsage: uuid_bridge <uuid> <other_uuid>\n");
+	} else {
+		switch_ivr_uuid_bridge(argv[0], argv[1]);
+	}
+
+	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};
+	int argc = 0;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+	
+	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+	if (argc < 2) {
+		stream->write_function(stream, "Invalid Parameters\n");
+	} 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);
+
+			if (!strcasecmp(dest, "on")) {
+				switch_channel_set_flag(channel, CF_HOLD);
+			} else {
+				switch_channel_clear_flag(channel, CF_HOLD);
+			}
+
+			switch_core_session_rwunlock(session);
+
+		} else {
+			stream->write_function(stream, "No Such Channel!\n");
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t originate_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+	switch_channel_t *caller_channel;
+	switch_core_session_t *caller_session;
+	char *argv[7] = {0};
+	int x, argc = 0;
+	char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
+	uint32_t timeout = 60;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+	if (isession) {
+		stream->write_function(stream, "Illegal Usage\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (switch_strlen_zero(cmd)) {
+		stream->write_function(stream, "Usage: originate <call url> <exten> [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+	for(x = 0; x < argc; x++) {
+		if (!strcasecmp(argv[x], "undef")) {
+			argv[x] = NULL;
+		}
+	}
+
+	aleg = argv[0];
+	exten = argv[1];
+	dp = argv[2];
+	context = argv[3];
+	cid_name = argv[4];
+	cid_num = argv[5];
+	
+	if (!dp) {
+		dp = "XML";
+	}
+
+	if (!context) {
+		context = "default";
+	}
+
+	if (argv[6]) {
+		timeout = atoi(argv[6]);
+	}
+
+	if (!aleg || !exten) {
+		stream->write_function(stream, "Invalid Arguements\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, &noop_state_handler, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
+		stream->write_function(stream, "Cannot Create Outgoing Channel! [%s]\n", aleg);
+		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 == '&') {
+		switch_caller_extension_t *extension = NULL;
+		char *app_name = switch_core_session_strdup(caller_session, (exten + 1));
+		char *arg, *e;
+
+		if ((e = strchr(app_name, ')'))) {
+			*e = '\0';
+		}
+
+		if ((arg = strchr(app_name, '('))) {
+			*arg++ = '\0';
+		}
+
+		if ((extension = switch_caller_extension_new(caller_session, app_name, arg)) == 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+			switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			return SWITCH_STATUS_MEMERR;
+		}
+		switch_caller_extension_add_application(caller_session, extension, app_name, arg);
+		switch_channel_set_caller_extension(caller_channel, extension);
+		switch_channel_set_state(caller_channel, CS_EXECUTE);
+	} else {
+		switch_ivr_session_transfer(caller_session, exten, dp, context);
+	}
+	stream->write_function(stream, "Created Session: %s\n", switch_core_session_get_uuid(caller_session));
+	return SWITCH_STATUS_SUCCESS;;
+}
+
+struct holder {
+	switch_stream_handle_t *stream;
+	char *http;
+	uint32_t count;
+};
+
+static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
+	struct holder *holder = (struct holder *) pArg;
+	int x;
+
+
+	if (holder->count == 0) {
+		if (holder->http) {
+			holder->stream->write_function(holder->stream, "\n<tr>");
+		}
+
+		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>");
+			} else {
+				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++) {
+		if (holder->http) {
+			holder->stream->write_function(holder->stream, "<td>");
+			holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
+		} else {
+			holder->stream->write_function(holder->stream, "%s%s", argv[x], x == (argc - 1) ? "\n" : ",");
+		}
+	}
+	
+
+
+
+	holder->count++;
+	return 0;
+}
+
+static switch_status_t show_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	char sql[1024];
+	char *errmsg;
+	switch_core_db_t *db = switch_core_db_handle();
+	struct holder holder = {0};
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (stream->event) {
+        holder.http = switch_event_get_header(stream->event, "http-host");
+    } 
+
+    if (!cmd) {
+        sprintf (sql, "select * from interfaces");
+    }
+    else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"application") || 
+              !strcmp(cmd,"api") || !strcmp(cmd,"dialplan") || 
+              !strcmp(cmd,"file") || !strcmp(cmd,"timer") 
+            ) {
+        sprintf (sql, "select * from interfaces where type = '%s'", cmd);
+    }
+    else if ( !strcmp(cmd,"calls")) {
+        sprintf (sql, "select * from calls");
+    }
+    else if ( !strcmp(cmd,"channels")) {
+        sprintf (sql, "select * from channels");
+    }
+    else {
+        stream->write_function(stream, "Invalid interfaces type!\n");
+        stream->write_function(stream, "Example:\n");
+        stream->write_function(stream, "show <blank>|codec|application|api|dialplan|file|timer|calls|channels\n");
+        return SWITCH_STATUS_SUCCESS;
+    }
+    
+	holder.stream = stream;
+	holder.count = 0;
+
+	if (holder.http) {
+		holder.stream->write_function(holder.stream, "<table cellpadding=1 cellspacing=4 border=1>\n");
+	}
+
+	switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
+
+	if (holder.http) {
+		holder.stream->write_function(holder.stream, "</table>");
+	}
+
+
+	if (errmsg) {
+		stream->write_function(stream, "SQL ERR [%s]\n",errmsg);
+		switch_core_db_free(errmsg);
+		errmsg = NULL;
+	} else {
+		stream->write_function(stream, "\n%u total.\n", holder.count);
+	}
+
+	switch_core_db_close(db);
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+static switch_api_interface_t ctl_api_interface = {
+	/*.interface_name */ "fsctl",
+	/*.desc */ "control messages",
+	/*.function */ ctl_function,
+	/*.next */ 
+};
+
+static switch_api_interface_t uuid_bridge_api_interface = {
+	/*.interface_name */ "uuid_bridge",
+	/*.desc */ "uuid_bridge",
+	/*.function */ uuid_bridge_function,
+	/*.next */ &ctl_api_interface
+};
+
+static switch_api_interface_t status_api_interface = {
+	/*.interface_name */ "status",
+	/*.desc */ "status",
+	/*.function */ status_function,
+	/*.next */ &uuid_bridge_api_interface
+};
+
+static switch_api_interface_t show_api_interface = {
+	/*.interface_name */ "show",
+	/*.desc */ "Show",
+	/*.function */ show_function,
+	/*.next */ &status_api_interface
+};
+
+static switch_api_interface_t pause_api_interface = {
+	/*.interface_name */ "pause",
+	/*.desc */ "Pause",
+	/*.function */ pause_function,
+	/*.next */ &show_api_interface
+};
+
+static switch_api_interface_t transfer_api_interface = {
+	/*.interface_name */ "transfer",
+	/*.desc */ "Transfer",
+	/*.function */ transfer_function,
+	/*.next */ &pause_api_interface
+};
+
+static switch_api_interface_t load_api_interface = {
+	/*.interface_name */ "load",
+	/*.desc */ "Load Module",
+	/*.function */ load_function,
+	/*.next */ &transfer_api_interface
+};
+
+static switch_api_interface_t reload_api_interface = {
+	/*.interface_name */ "reloadxml",
+	/*.desc */ "Reload XML",
+	/*.function */ reload_function,
+	/*.next */ &load_api_interface,
+
+};
+
+static switch_api_interface_t commands_api_interface = {
 	/*.interface_name */ "killchan",
 	/*.desc */ "Kill Channel",
 	/*.function */ kill_function,
-	/*.next */ NULL
+	/*.next */ &reload_api_interface
 };
 
+static switch_api_interface_t originate_api_interface = {
+	/*.interface_name */ "originate",
+	/*.desc */ "Originate a Call",
+	/*.function */ originate_function,
+	/*.next */ &commands_api_interface
+};
 
-static const switch_loadable_module_interface mod_commands_module_interface = {
+
+static const switch_loadable_module_interface_t mod_commands_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
 	/*.dialplan_interface */ NULL,
 	/*.codec_interface */ NULL,
 	/*.application_interface */ NULL,
-	/*.api_interface */ &commands_api_interface
+	/*.api_interface */ &originate_api_interface
 };
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &mod_commands_module_interface;
+	*module_interface = &mod_commands_module_interface;
 
 
 	/* indicate that the module should continue to be loaded */

Modified: freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_commands/mod_commands.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_commands.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_commands.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_commands.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_commands.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.c	Fri Sep 22 14:22:15 2006
@@ -24,8 +24,8 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Brian K. West <brian.west at mac.com>
  *
- *
  * mod_echo.c -- Echo application
  *
  */
@@ -33,9 +33,9 @@
 
 static const char modname[] = "mod_echo";
 
-static void echo_function(switch_core_session *session, char *data)
+static void echo_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);	
@@ -45,13 +45,13 @@
 	switch_channel_set_state(channel, CS_LOOPBACK);
 }
 
-static const switch_application_interface echo_application_interface = {
+static const switch_application_interface_t echo_application_interface = {
 	/*.interface_name */ "echo",
 	/*.application_function */ echo_function,
 	NULL,NULL,NULL,NULL
 };
 
-static switch_loadable_module_interface echo_module_interface = {
+static switch_loadable_module_interface_t echo_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -64,10 +64,10 @@
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &echo_module_interface;
+	*module_interface = &echo_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_echo/mod_echo.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_echo.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_echo.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_echo.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_echo.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.c	Fri Sep 22 14:22:15 2006
@@ -39,20 +39,53 @@
   dtmf handler function you can hook up to be executed when a digit is dialed during playback 
    if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
-static switch_status on_dtmf(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+	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;
+		switch_copy_string((char *)buf, dtmf, buflen);
+		return SWITCH_STATUS_BREAK;
+	}
+		break;
+	default:
+		break;
+	}
+	return SWITCH_STATUS_SUCCESS;
+}
 
+static void disast_function(switch_core_session_t *session, char *data)
+{
+	void *x = NULL;
+	memset((void *) x, 0, 1000);
+	//printf("%s WOOHOO\n", (char *) 42);
 }
 
-static void dirtest_function(switch_core_session *session, char *data)
+
+static void xml_function(switch_core_session_t *session, char *data)
 {
+	switch_xml_t f1 = switch_xml_parse_file("/root/formula1.xml"), team, driver;
+	const char *teamname;
+
+	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_xml_free(f1);
+}
+
+
+static void dirtest_function(switch_core_session_t *session, char *data)
+{
 	char *var, *val;
-	switch_channel *channel;
-	switch_directory_handle dh;
+	switch_channel_t *channel;
+	switch_directory_handle_t dh;
 
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
@@ -77,23 +110,32 @@
 	}
 
 	switch_core_directory_close(&dh);
-	switch_channel_hangup(channel);
+	switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 
 }
 
-static switch_status show_dtmf(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-	
-	switch_copy_string((char *)buf, dtmf, buflen);
-	return SWITCH_STATUS_SUCCESS;
 
+	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);
+	}
+		break;
+	default:
+		break;
+	}
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
-static void tts_function(switch_core_session *session, char *data)
+static void tts_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *channel;
-	switch_codec *codec;
+	switch_channel_t *channel;
+	switch_codec_t *codec;
 	char *mydata, *text = NULL, *voice_name = NULL, *tts_name = NULL;
 	char buf[10] = "";
 	char *argv[3];
@@ -125,11 +167,11 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
 }
 
-static void ivrtest_function(switch_core_session *session, char *data)
+static void ivrtest_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *channel;
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	switch_codec *codec;
+	switch_channel_t *channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_codec_t *codec;
 	char buf[10] = "";
 	char term;
 	char say[128] = "";
@@ -152,13 +194,13 @@
 			status = switch_ivr_play_file(session, NULL, data, NULL, on_dtmf, buf, sizeof(buf));
 			
 			if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-				switch_channel_hangup(channel);
+				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 				break;
 			}
 		}
 
-		if (switch_ivr_collect_digits_count(session, buf, sizeof(buf), 10, "#*", &term, 10000, 1) != SWITCH_STATUS_SUCCESS) {
-			switch_channel_hangup(channel);
+		if (switch_ivr_collect_digits_count(session, buf, sizeof(buf), 10, "#*", &term, 10000) != SWITCH_STATUS_SUCCESS) {
+			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			break;
 		}
 
@@ -173,9 +215,9 @@
 }
 
 
-static switch_status my_on_hangup(switch_core_session *session)
+static switch_status_t my_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
@@ -185,7 +227,7 @@
 
 }
 
-static const switch_state_handler_table state_handlers = {
+static const switch_state_handler_table_t state_handlers = {
 	/*.on_init */ NULL,
 	/*.on_ring */ NULL,
 	/*.on_execute */ NULL,
@@ -194,28 +236,43 @@
 	/*.on_transmit */ NULL
 };
 
-static const switch_application_interface tts_application_interface = {
+
+static const switch_application_interface_t xml_application_interface = {
+	/*.interface_name */ "xml",
+	/*.application_function */ xml_function,
+	NULL, NULL, NULL,
+	/*.next*/ NULL
+};
+
+static const switch_application_interface_t disast_application_interface = {
+	/*.interface_name */ "disast",
+	/*.application_function */ disast_function,
+	NULL, NULL, NULL,
+	/*.next*/ &xml_application_interface
+};
+
+static const switch_application_interface_t tts_application_interface = {
 	/*.interface_name */ "tts",
 	/*.application_function */ tts_function,
 	NULL, NULL, NULL,
-	/*.next*/ NULL
+	/*.next*/ &disast_application_interface
 };
 
-static const switch_application_interface dirtest_application_interface = {
+static const switch_application_interface_t dirtest_application_interface = {
 	/*.interface_name */ "dirtest",
 	/*.application_function */ dirtest_function,
 	NULL, NULL, NULL,
 	/*.next*/ &tts_application_interface
 };
 
-static const switch_application_interface ivrtest_application_interface = {
+static const switch_application_interface_t ivrtest_application_interface = {
 	/*.interface_name */ "ivrtest",
 	/*.application_function */ ivrtest_function,
 	NULL, NULL, NULL,
 	/*.next*/ &dirtest_application_interface
 };
 
-static const switch_loadable_module_interface mod_ivrtest_module_interface = {
+static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
 	/*.module_name = */ modname,
 	/*.endpoint_interface = */ NULL,
 	/*.timer_interface = */ NULL,
@@ -224,11 +281,11 @@
 	/*.application_interface */ &ivrtest_application_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &mod_ivrtest_module_interface;
+	*module_interface = &mod_ivrtest_module_interface;
 
 	/* test global state handlers */
 	switch_core_add_state_handler(&state_handlers);
@@ -242,4 +299,4 @@
 */
 
 
-//switch_status switch_module_runtime(void)
+//switch_status_t switch_module_runtime(void)

Modified: freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_ivrtest/mod_ivrtest.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ivrtest.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_ivrtest.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_ivrtest.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ivrtest.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.c	Fri Sep 22 14:22:15 2006
@@ -37,22 +37,69 @@
   dtmf handler function you can hook up to be executed when a digit is dialed during playback 
    if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 */
-static switch_status on_dtmf(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
 
-	if (*dtmf == '*') {
-		return SWITCH_STATUS_FALSE;
+	
+	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_FALSE;
+		}
 	}
+		break;
+	default:
+		break;
+	}
 	
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static void playback_function(switch_core_session *session, char *data)
+static void speak_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
+	char buf[10];
+	char *argv[4] = {0};
+	int argc;
+	char *engine = NULL;
+	char *voice = NULL;
+	char *text = NULL;
 	char *timer_name = NULL;
+	char *mydata = NULL;
+	switch_codec_t *codec;
+
+	codec = switch_core_session_get_read_codec(session);
+	assert(codec != NULL);
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	mydata = switch_core_session_strdup(session, data);
+	argc = switch_separate_string(mydata, '|', argv, sizeof(argv)/sizeof(argv[0]));
+
+	engine = argv[0];
+	voice = argv[1];
+	text = argv[2];
+	timer_name = argv[3];
+	
+	if (!(engine && voice && text)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+	}
+
+	switch_channel_pre_answer(channel);
+	switch_ivr_speak_text(session, engine, voice, timer_name, codec->implementation->samples_per_second, on_dtmf, text, buf, sizeof(buf));
+	
+}
+
+static void playback_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	char *timer_name = NULL;
 	char *file_name = NULL;
 
 	file_name = switch_core_session_strdup(session, data);
@@ -64,40 +111,84 @@
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 
-	switch_channel_answer(channel);
+	switch_channel_pre_answer(channel);
 
 	if (switch_ivr_play_file(session, NULL, file_name, timer_name, on_dtmf, NULL, 0) != SWITCH_STATUS_SUCCESS) {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 	}
 	
 }
 
 
-static void record_function(switch_core_session *session, char *data)
+static void record_function(switch_core_session_t *session, char *data)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 
 	if (switch_ivr_record_file(session, NULL, data, on_dtmf, NULL, 0) != SWITCH_STATUS_SUCCESS) {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 	}
 	
 }
 
-static const switch_application_interface record_application_interface = {
+
+static void record_session_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	switch_ivr_record_session(session, data, NULL);	
+}
+
+
+static void stop_record_session_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	switch_ivr_stop_record_session(session, data);	
+}
+
+
+static const switch_application_interface_t speak_application_interface = {
+	/*.interface_name */ "speak",
+	/*.application_function */ speak_function
+};
+
+static const switch_application_interface_t record_application_interface = {
 	/*.interface_name */ "record",
-	/*.application_function */ record_function
+	/*.application_function */ record_function,
+	NULL,NULL,NULL,
+	&speak_application_interface
 };
 
-static const switch_application_interface playback_application_interface = {
+
+static const switch_application_interface_t record_session_application_interface = {
+	/*.interface_name */ "record_session",
+	/*.application_function */ record_session_function,
+	NULL,NULL,NULL,
+	&record_application_interface
+};
+
+
+static const switch_application_interface_t stop_record_session_application_interface = {
+	/*.interface_name */ "stop_record_session",
+	/*.application_function */ stop_record_session_function,
+	NULL,NULL,NULL,
+	&record_session_application_interface
+};
+
+static const switch_application_interface_t playback_application_interface = {
 	/*.interface_name */ "playback",
 	/*.application_function */ playback_function,
 	NULL,NULL,NULL,
-	/*.next*/				  &record_application_interface
+	/*.next*/				  &stop_record_session_application_interface
 };
 
-static const switch_loadable_module_interface mod_playback_module_interface = {
+static const switch_loadable_module_interface_t mod_playback_module_interface = {
 	/*.module_name = */ modname,
 	/*.endpoint_interface = */ NULL,
 	/*.timer_interface = */ NULL,
@@ -106,11 +197,11 @@
 	/*.application_interface */ &playback_application_interface
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &mod_playback_module_interface;
+	*module_interface = &mod_playback_module_interface;
 
 
 	/* indicate that the module should continue to be loaded */
@@ -122,4 +213,4 @@
 */
 
 
-//switch_status switch_module_runtime(void)
+//switch_status_t switch_module_runtime(void)

Modified: freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_playback/mod_playback.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_playback.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_playback.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_playback.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_playback.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/applications/mod_skel/mod_skel.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/applications/mod_skel/mod_skel.c	(original)
+++ freeswitch/branches/voctel/src/mod/applications/mod_skel/mod_skel.c	Fri Sep 22 14:22:15 2006
@@ -33,7 +33,7 @@
 
 static const char modname[] = "mod_skel";
 
-static switch_loadable_module_interface skel_module_interface = {
+static switch_loadable_module_interface_t skel_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -46,10 +46,10 @@
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &skel_module_interface;
+	*module_interface = &skel_module_interface;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
 

Modified: freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	(original)
+++ freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	Fri Sep 22 14:22:15 2006
@@ -27,6 +27,12 @@
  *
  *
  * mod_cepstral.c -- Cepstral Interface
+ * 
+ * Contains some material derived from the Cepstral Swift SDK, by  
+ * permission.  You are free to copy and modify the source under the  
+ * terms of FreeSWITCH itself, without additional permission from  
+ * Cepstral
+ * 
  *
  */
 #ifdef __ICC
@@ -36,6 +42,9 @@
 #include <swift.h>
 #include <switch.h>
 
+#define MY_BUF_LEN 1024 * 32
+#define MY_BLOCK_SIZE MY_BUF_LEN
+
 static const char modname[] = "mod_cepstral";
 
 static swift_engine *engine;
@@ -47,7 +56,7 @@
 	swift_params *params;
 	swift_voice *voice;
 	switch_mutex_t *audio_lock;
-	switch_buffer *audio_buffer;
+	switch_buffer_t *audio_buffer;
 	int done;
 	int done_gen;
 } cepstral_t;
@@ -59,26 +68,46 @@
 	cepstral_t *cepstral;
     swift_event_t rv = SWIFT_SUCCESS;
     void *buf = NULL;
-    int len = 0;
+    int len = 0, i = 0;
 	
 	cepstral = udata;
 	assert(cepstral != NULL);
 	
+	if (!cepstral->port || cepstral->done || cepstral->done_gen) {
+		return  SWIFT_UNKNOWN_ERROR;
+	}
+
 	/* Only proceed when we have success */
     if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
-		switch_mutex_lock(cepstral->audio_lock);
-		if (switch_buffer_write(cepstral->audio_buffer, buf, len) <= 0) {
-			rv = SWIFT_UNKNOWN_ERROR;
+		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);
+				break;
+			}
+			switch_mutex_unlock(cepstral->audio_lock);
+			if (!cepstral->done) {
+				for (i = 0; i < 10; i++) {
+					switch_yield(10000);
+					if (cepstral->done) {
+						break;
+					}
+				}
+			}
+			
 		}
-		switch_mutex_unlock(cepstral->audio_lock);
 	} else {
 		cepstral->done = 1;
 	}
 
+	if (cepstral->done) {
+		rv = SWIFT_UNKNOWN_ERROR;
+	}
+	
     return rv;
 }
 
-static switch_status cepstral_speech_open(switch_speech_handle *sh, char *voice_name, int rate, switch_speech_flag *flags)
+static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags)
 {
 	if (*flags & SWITCH_SPEECH_FLAG_ASR) {
 		return SWITCH_STATUS_FALSE;
@@ -91,7 +120,7 @@
 			return SWITCH_STATUS_MEMERR;
 		}
 
-		if (switch_buffer_create(sh->memory_pool, &cepstral->audio_buffer, SWITCH_RECCOMMENDED_BUFFER_SIZE) != SWITCH_STATUS_SUCCESS) {
+		if (switch_buffer_create_dynamic(&cepstral->audio_buffer, MY_BLOCK_SIZE, MY_BUF_LEN, 0) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Buffer Failed!\n");
 			return SWITCH_STATUS_MEMERR;
 		}
@@ -130,8 +159,14 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
 				goto all_done;
 			}
+
+			voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
 		}
 
+		if (voice_name) {
+            switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
+        }
+
 		swift_port_set_callback(cepstral->port, &write_audio, SWIFT_EVENT_AUDIO, cepstral);
 
 		sh->private_info = cepstral;
@@ -142,7 +177,7 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status cepstral_speech_close(switch_speech_handle *sh, switch_speech_flag *flags)
+static switch_status_t cepstral_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
 {
 	cepstral_t *cepstral;
 
@@ -150,6 +185,10 @@
 	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->engine) swift_engine_close(cepstral->engine);
@@ -157,34 +196,76 @@
 	cepstral->port = NULL;
 	//cepstral->engine = NULL;
 	
+	switch_buffer_destroy(&cepstral->audio_buffer);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status cepstral_speech_feed_tts(switch_speech_handle *sh, char *text, switch_speech_flag *flags)
+static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 {
 	cepstral_t *cepstral;
+	const char *fp = "file:";
+	int len = (int)strlen(fp);
 
 	assert(sh != NULL);
 	cepstral = sh->private_info;
 	assert(cepstral != NULL);
 
+	cepstral->done_gen = 0;
+	cepstral->done = 0;
+	
+	cepstral->tts_stream = NULL;
 
-	swift_port_speak_text(cepstral->port, text, 0, NULL, &cepstral->tts_stream, NULL); 
-	//swift_port_speak_text(cepstral->port, text, 0, NULL, NULL, NULL); 
-
+	if (cepstral->audio_buffer) {
+		switch_byte_t data[1280];
+		memset(data, 255, sizeof(data));
+		switch_mutex_lock(cepstral->audio_lock);
+		switch_buffer_write(cepstral->audio_buffer, data, sizeof(data));
+		switch_mutex_unlock(cepstral->audio_lock);
+	}
 	
-	return SWITCH_STATUS_FALSE;
+	if (!strncasecmp(text, fp, len)) {
+		text += len;
+		if (switch_strlen_zero(text)) {
+			return SWITCH_STATUS_FALSE;
+		}
+		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); 
+	} else {
+		if (switch_strlen_zero(text)) {
+			return SWITCH_STATUS_FALSE;
+		}
+		swift_port_speak_text(cepstral->port, text, 0, NULL, &cepstral->tts_stream, NULL); 
+	}
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status cepstral_speech_read_tts(switch_speech_handle *sh,
+static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
+{
+	cepstral_t *cepstral;
+
+	cepstral = sh->private_info;
+    assert(cepstral != NULL);
+
+	cepstral->done_gen = 1;
+    cepstral->done = 1;
+	if (cepstral->audio_buffer) {
+		switch_mutex_lock(cepstral->audio_lock);
+		switch_buffer_zero(cepstral->audio_buffer);
+		switch_mutex_unlock(cepstral->audio_lock);
+	}
+	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 *flags) 
+											  switch_speech_flag_t *flags) 
 {
 	cepstral_t *cepstral;
 	size_t desired = *datalen;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	size_t used, padding = 0;
 
 	assert(sh != NULL);
@@ -193,20 +274,23 @@
 
 	while(!cepstral->done) {
 		if (!cepstral->done_gen) {
-			int check = (SWIFT_STATUS_RUNNING == swift_port_status(cepstral->port, cepstral->tts_stream));
-			if (!check) {
+			int check = swift_port_status(cepstral->port, cepstral->tts_stream);
+
+			if (!check == SWIFT_STATUS_RUNNING) {
 				cepstral->done_gen = 1;
 			}
 		}
 
+		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;
 			break;
 		}
-		
 
 		/* wait for the right amount of data (unless there is no blocking flag) */
 		if (used < desired) {
@@ -245,18 +329,98 @@
 	return status;
 }
 
-static const switch_speech_interface cepstral_speech_interface = {
+static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, char *val)
+{
+	cepstral_t *cepstral;
+
+	cepstral = sh->private_info;
+	assert(cepstral != NULL);
+
+	if (!strcasecmp(param, "voice")) {
+		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)) ) {
+					cepstral->done = cepstral->done_gen = 1;
+					return;
+				}
+				voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
+			} else {
+				voice_name = NULL;
+			}
+		} else {
+			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;
+			}
+		}
+
+		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");
+				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");
+				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));
+		}
+
+		return;
+	}
+
+	swift_port_set_param_string(cepstral->port, param, val, NULL);
+}
+
+static void cepstral_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
+{
+	cepstral_t *cepstral;
+
+	cepstral = sh->private_info;
+	assert(cepstral != NULL);
+
+	swift_port_set_param_int(cepstral->port, param, val, NULL);
+
+}
+
+
+static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
+{
+	cepstral_t *cepstral;
+
+	cepstral = sh->private_info;
+	assert(cepstral != NULL);
+
+	swift_port_set_param_float(cepstral->port, param, val, NULL);
+
+}
+
+static const switch_speech_interface_t cepstral_speech_interface = {
 	/*.interface_name*/			"cepstral",
 	/*.speech_open*/			cepstral_speech_open,
 	/*.speech_close*/			cepstral_speech_close,
 	/*.speech_feed_asr*/		NULL,
 	/*.speech_interpret_asr*/	NULL,
 	/*.speech_feed_tts*/		cepstral_speech_feed_tts,
-	/*.speech_read_tts*/		cepstral_speech_read_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 cepstral_module_interface = {
+static const switch_loadable_module_interface_t cepstral_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -269,7 +433,7 @@
 	/*.directory_interface */ NULL
 };
 
-switch_status switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+switch_status_t switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	/* Open the Swift TTS Engine */
@@ -279,7 +443,7 @@
 	}
 	
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &cepstral_module_interface;
+	*module_interface = &cepstral_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/asr_tts/mod_cepstral/mod_cepstral.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,11 +65,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="swift.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_cepstral.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="C:\Program Files\Cepstral\sdk\lib\winnt;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_cepstral.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_cepstral.lib"
 				TargetMachine="1"
@@ -101,8 +101,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -146,10 +146,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="swift.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_cepstral.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="C:\Program Files\Cepstral\sdk\lib\winnt;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_g711/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_g711/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_g711/Makefile	Fri Sep 22 14:22:15 2006
@@ -1,12 +1,9 @@
-
+CFLAGS += -I$(BASE)/libs/codec/g7xx/src/include
 all:	$(MODNAME).$(DYNAMIC_LIB_EXTEN)
 
-g711.o: g711.c g711.h
-	$(CC) $(CFLAGS) -c -O2 -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE g711.c -o g711.o
-
-$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c g711.o
+$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
-	$(CC) $(SOLINK) g711.o $(MODNAME).o -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(LDFLAGS)
+	$(CC) $(SOLINK) $(MODNAME).o -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(LDFLAGS)
 
 
 

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.c	Fri Sep 22 14:22:15 2006
@@ -30,14 +30,14 @@
  *
  */
 #include <switch.h>
-#include "g711.h"
+#include <g7xx/g711.h>
 
 
-static const char modname[] = "mod_g711codec";
+static const char modname[] = "mod_g711";
 
 
-static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag flags,
-									   const struct switch_codec_settings *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;
 
@@ -52,8 +52,8 @@
 }
 
 
-static switch_status switch_g711u_encode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -68,7 +68,7 @@
 	ebuf = encoded_data;
 
 	for (i = 0; i < decoded_data_len / sizeof(short); i++) {
-		ebuf[i] = linear2ulaw(dbuf[i]);
+		ebuf[i] = linear_to_ulaw(dbuf[i]);
 	}
 
 	*encoded_data_len = i;
@@ -76,8 +76,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_g711u_decode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -96,7 +96,7 @@
 		*decoded_data_len = codec->implementation->bytes_per_frame;
 	} else {
 		for (i = 0; i < encoded_data_len; i++) {
-			dbuf[i] = ulaw2linear(ebuf[i]);
+			dbuf[i] = ulaw_to_linear(ebuf[i]);
 		}
 
 		*decoded_data_len = i * 2;
@@ -105,14 +105,14 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_g711u_destroy(switch_codec *codec)
+static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
 {
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag flags,
-									   const struct switch_codec_settings *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;
 
@@ -127,8 +127,8 @@
 }
 
 
-static switch_status switch_g711a_encode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -143,7 +143,7 @@
 	ebuf = encoded_data;
 
 	for (i = 0; i < decoded_data_len / sizeof(short); i++) {
-		ebuf[i] = linear2alaw(dbuf[i]);
+		ebuf[i] = linear_to_alaw(dbuf[i]);
 	}
 
 	*encoded_data_len = i;
@@ -151,8 +151,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_g711a_decode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -171,7 +171,7 @@
 		*decoded_data_len = codec->implementation->bytes_per_frame;
 	} else {
 		for (i = 0; i < encoded_data_len; i++) {
-			dbuf[i] = alaw2linear(ebuf[i]);
+			dbuf[i] = alaw_to_linear(ebuf[i]);
 		}
 
 		*decoded_data_len = i * 2;
@@ -180,16 +180,19 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_g711a_destroy(switch_codec *codec)
+static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
 {
 	return SWITCH_STATUS_SUCCESS;
 }
 
 /* Registration */
 
-#if 0
 
-static const switch_codec_implementation g711u_8k_60ms_implementation = {
+
+static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 0,
+	/*.iananame */ "PCMU",
 	/*.samples_per_second */ 8000,
 	/*.bits_per_second */ 19200,
 	/*.microseconds_per_frame */ 60000,
@@ -205,8 +208,11 @@
 	/*.destroy */ switch_g711u_destroy
 };
 
-
-static const switch_codec_implementation g711u_8k_30ms_implementation = {
+#if 0
+static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 0,
+	/*.iananame */ "PCMU",
 	/*.samples_per_second */ 8000,
 	/*.bits_per_second */ 96000,
 	/*.microseconds_per_frame */ 30000,
@@ -220,11 +226,13 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next */ &g711u_8k_60ms_implementation
+	/*.next */ NULL
 };
-#endif
 
-static const switch_codec_implementation g711u_16k_implementation = {
+static const switch_codec_implementation_t g711u_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 0,
+	/*.iananame */ "PCMU",
 	/*.samples_per_second */ 16000,
 	/*.bits_per_second */ 128000,
 	/*.microseconds_per_frame */ 20000,
@@ -238,9 +246,14 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
+	/*.next */ &g711u_8k_30ms_implementation
 };
+#endif
 
-static const switch_codec_implementation g711u_8k_implementation = {
+static const switch_codec_implementation_t g711u_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 0,
+	/*.iananame */ "PCMU",
 	/*.samples_per_second */ 8000,
 	/*.bits_per_second */ 64000,
 	/*.microseconds_per_frame */ 20000,
@@ -254,11 +267,15 @@
 	/*.encode */ switch_g711u_encode,
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
-	/*.next */ &g711u_16k_implementation
+	///*.next */ &g711u_16k_implementation
+	&g711u_8k_60ms_implementation
 };
 
 
-static const switch_codec_implementation g711a_8k_implementation = {
+static const switch_codec_implementation_t g711a_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 8,
+	/*.iananame */ "PCMA",
 	/*.samples_per_second */ 8000,
 	/*.bits_per_second */ 64000,
 	/*.microseconds_per_frame */ 20000,
@@ -275,24 +292,18 @@
 };
 
 
-static const switch_codec_interface g711a_codec_interface = {
+static const switch_codec_interface_t g711a_codec_interface = {
 	/*.interface_name */ "g711 alaw",
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-	/*.ianacode */ 8,
-	/*.iananame */ "PCMA",
 	/*.implementations */ &g711a_8k_implementation
 };
 
-static const switch_codec_interface g711u_codec_interface = {
+static const switch_codec_interface_t g711u_codec_interface = {
 	/*.interface_name */ "g711 ulaw",
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-	/*.ianacode */ 0,
-	/*.iananame */ "PCMU",
 	/*.implementations */ &g711u_8k_implementation,
 	/*.next */ &g711a_codec_interface
 };
 
-static switch_loadable_module_interface g711_module_interface = {
+static switch_loadable_module_interface_t g711_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -302,10 +313,10 @@
 };
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &g711_module_interface;
+	*module_interface = &g711_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_g711/mod_g711.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\g7xx\src\include&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_g711.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_g711.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_g711.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -122,7 +122,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\g7xx\src\include&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -141,10 +141,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_g711.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
@@ -185,10 +186,6 @@
 			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
 			>
-			<File
-				RelativePath=".\g711.c"
-				>
-			</File>
 			<File
 				RelativePath=".\mod_g711.c"
 				>

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.c	Fri Sep 22 14:22:15 2006
@@ -26,26 +26,32 @@
  * Anthony Minessale II <anthmct at yahoo.com>
  * Michael Jerris <mike at jerris.com>
  *
- * mod_codec_g729.c -- G729 Codec Module
+ * The g729 codec itself is not distributed with this module.
  *
+ * mod_g729.c -- G729 Codec Module
+ *
  */  
-#include "switch.h"
-#include "g729.h"
 
-static const char modname[] = "mod_codec_g729";
+static const char modname[] = "mod_g729";
 
+#include "switch.h"
 
-struct g729_context {
+#ifndef G729_PASSTHROUGH
+#include "g729.h"
 
+struct g729_context {
 	struct dec_state decoder_object;
 	struct cod_state encoder_object;
 };
+#endif
 
-
-static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags,
-									  const struct switch_codec_settings *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;
+	return SWITCH_STATUS_SUCCESS;
+#else 
 	struct g729_context *context = NULL;
 	int encoding, decoding;
 
@@ -69,19 +75,19 @@
 		return SWITCH_STATUS_SUCCESS;
 
 	}
+#endif
 }
 
-
-static switch_status switch_g729_destroy(switch_codec *codec) 
+static switch_status_t switch_g729_destroy(switch_codec_t *codec) 
 {
+#ifndef G729_PASSTHROUGH
 	codec->private_info = NULL;
+#endif
 	return SWITCH_STATUS_SUCCESS;
 }
 
-
-
-static switch_status switch_g729_encode(switch_codec *codec, 
-										switch_codec *other_codec, 
+static switch_status_t switch_g729_encode(switch_codec_t *codec, 
+										switch_codec_t *other_codec, 
 										void *decoded_data,
 
 										uint32_t decoded_data_len, 
@@ -92,7 +98,10 @@
 										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");
+	return SWITCH_STATUS_FALSE;
+#else
 	struct g729_context *context = codec->private_info;
 	int cbret = 0;
 
@@ -121,14 +130,12 @@
 			return SWITCH_STATUS_FALSE;
 		}
 	}
-
 	return SWITCH_STATUS_SUCCESS;
+#endif
 }
 
-
-
-static switch_status switch_g729_decode(switch_codec *codec, 
-										switch_codec *other_codec, 
+static switch_status_t switch_g729_decode(switch_codec_t *codec, 
+										switch_codec_t *other_codec, 
 										void *encoded_data,
 
 										uint32_t encoded_data_len, 
@@ -139,7 +146,10 @@
 										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");
+	return SWITCH_STATUS_FALSE;
+#else
 	struct g729_context *context = codec->private_info;
 	int divisor = 10;
 	int plen = 10;
@@ -166,15 +176,10 @@
 
 		if (encoded_data_len % divisor == 0) {
 			uint8_t *test;
-
 			int loops = (int) encoded_data_len / divisor;
-
 			char *edp = encoded_data;
-
 			short *ddp = decoded_data;
-
 			int x;
-
 			uint32_t new_len = 0;
 
 			test = (uint8_t *) encoded_data;
@@ -207,18 +212,16 @@
 		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;
 	}
-
-
-
 	return SWITCH_STATUS_SUCCESS;
-
+#endif
 }
 
-
-
 /* Registration */ 
 
-static const switch_codec_implementation g729_10ms_8k_implementation = { 
+static const switch_codec_implementation_t g729_10ms_8k_implementation = { 
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
+	/*.ianacode */ 18, 
+	/*.iananame */ "G729", 
 	/*.samples_per_second */ 8000, 
 	/*.bits_per_second */ 32000, 
 	/*.microseconds_per_frame */ 10000, 
@@ -234,7 +237,10 @@
 	/*.destroy */ switch_g729_destroy, 
 };
 
-static const switch_codec_implementation g729_8k_implementation = { 
+static const switch_codec_implementation_t g729_8k_implementation = { 
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
+	/*.ianacode */ 18, 
+	/*.iananame */ "G729", 
 	/*.samples_per_second */ 8000, 
 	/*.bits_per_second */ 64000, 
 	/*.microseconds_per_frame */ 20000, 
@@ -251,17 +257,12 @@
 	&g729_10ms_8k_implementation
 };
 
-
-static const switch_codec_interface g729_codec_interface = { 
+static const switch_codec_interface_t g729_codec_interface = { 
 	/*.interface_name */ "g729", 
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-	/*.ianacode */ 18, 
-	/*.iananame */ "G729", 
 	/*.implementations */ &g729_8k_implementation, 
 };
 
-
-static switch_loadable_module_interface g729_module_interface = { 
+static switch_loadable_module_interface_t g729_module_interface = { 
 	/*.module_name */ modname, 
 	/*.endpoint_interface */ NULL, 
 	/*.timer_interface */ NULL, 
@@ -270,17 +271,12 @@
 	/*.application_interface */ NULL 
 };
 
-
-
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
+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 */ 
-	*interface = &g729_module_interface;
+	*module_interface = &g729_module_interface;
 
-
 	/* indicate that the module should continue to be loaded */ 
 	return SWITCH_STATUS_SUCCESS;
-
 }

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_g729/mod_g729.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_CodecG729 Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,11 +65,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="libg729.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_g729.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_g729.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_g729.lib"
 				TargetMachine="1"
@@ -101,15 +101,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_CodecG729 Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -145,10 +145,175 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="libg729.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_g729.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/mod_g729.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug Passthrough|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				CommandLine=""
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\libg729\src\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;G729_PASSTHROUGH"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				WarnAsError="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/mod_g729.lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release Passthrough|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				CommandLine=""
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\libg729\src\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;G729_PASSTHROUGH"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.c	Fri Sep 22 14:22:15 2006
@@ -31,13 +31,13 @@
  */  
 #include "switch.h"
 #include "gsm.h"
-static const char modname[] = "mod_codec_gsm";
+static const char modname[] = "mod_gsm";
 struct gsm_context {
 	gsm encoder;
 	gsm decoder;
 };
-static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags,
-									   const struct switch_codec_settings *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 +55,7 @@
 	codec->private_info = context;
 	return SWITCH_STATUS_SUCCESS;
 }
-static switch_status switch_gsm_destroy(switch_codec *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);
@@ -67,7 +67,7 @@
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
-static switch_status switch_gsm_encode(switch_codec *codec, switch_codec *other_codec, void *decoded_data,
+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) 
 {
@@ -96,7 +96,7 @@
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
-static switch_status switch_gsm_decode(switch_codec *codec, switch_codec *other_codec, void *encoded_data,
+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) 
 {
@@ -132,7 +132,10 @@
 
 
 /* Registration */ 
-static const switch_codec_implementation gsm_8k_implementation = { 
+static const switch_codec_implementation_t gsm_8k_implementation = { 
+		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
+		/*.ianacode */ 3, 
+		/*.iananame */ "gsm", 
 		/*.samples_per_second */ 8000, 
 		/*.bits_per_second */ 13200, 
 		/*.microseconds_per_frame */ 20000, 
@@ -147,14 +150,11 @@
 		/*.decode */ switch_gsm_decode, 
 		/*.destroy */ switch_gsm_destroy, 
 };
-static const switch_codec_interface gsm_codec_interface = { 
+static const switch_codec_interface_t gsm_codec_interface = { 
 		/*.interface_name */ "gsm", 
-		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 3, 
-		/*.iananame */ "gsm", 
 		/*.implementations */ &gsm_8k_implementation, 
 };
-static switch_loadable_module_interface gsm_module_interface = { 
+static switch_loadable_module_interface_t gsm_module_interface = { 
 		/*.module_name */ modname, 
 		/*.endpoint_interface */ NULL, 
 		/*.timer_interface */ NULL, 
@@ -162,12 +162,12 @@
 		/*.codec_interface */ &gsm_codec_interface, 
 		/*.application_interface */ NULL 
 };
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
+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 */ 
-		*interface = &gsm_module_interface;
+		*module_interface = &gsm_module_interface;
 	
 		/* indicate that the module should continue to be loaded */ 
 		return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_gsm/mod_gsm.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_CodecGSM Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +64,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libgsm.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_gsm.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\libs\codec\gsm\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_gsm.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_gsm.lib"
 				TargetMachine="1"
@@ -101,15 +100,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_CodecGSM Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -144,11 +143,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libgsm.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_gsm.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\libs\codec\gsm\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.c	Fri Sep 22 14:22:15 2006
@@ -32,20 +32,31 @@
 #include "switch.h"
 #include "iLBC_encode.h"
 #include "iLBC_decode.h"
+#include "iLBC_define.h"
 
 static const char modname[] = "mod_ilbc";
 
 struct ilbc_context {
 	iLBC_Enc_Inst_t encoder;
 	iLBC_Dec_Inst_t decoder;
+	uint8_t ms;
+	uint16_t bytes;
+	uint16_t dbytes;
 };
 
-static switch_status switch_ilbc_init(switch_codec *codec, switch_codec_flag flags,
-									  const struct switch_codec_settings *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 = codec->implementation->microseconds_per_frame / 1000;
 
+
+	if (ms != 20 && ms != 30) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid speed! (I should never happen)\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
 	encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
 	decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
 
@@ -53,10 +64,21 @@
 		return SWITCH_STATUS_FALSE;
 	} else {
 		context = switch_core_alloc(codec->memory_pool, sizeof(*context));
-		if (encoding)
-			initEncode(&context->encoder, 30);
-		if (decoding)
-			initDecode(&context->decoder, 30, 0);
+		context->ms = ms;
+		if (context->ms == 20) {
+			context->bytes = NO_OF_BYTES_20MS;
+			context->dbytes = 320;
+		} else {
+			context->bytes = NO_OF_BYTES_30MS;
+			context->dbytes = 480;
+		}
+
+		if (encoding) {
+			initEncode(&context->encoder, context->ms);
+		}
+		if (decoding) {
+			initDecode(&context->decoder, context->ms, 1);
+		}
 	}
 
 	codec->private_info = context;
@@ -64,41 +86,45 @@
 }
 
 
-static switch_status switch_ilbc_destroy(switch_codec *codec) 
+static switch_status_t switch_ilbc_destroy(switch_codec_t *codec) 
 {
 	codec->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_ilbc_encode(switch_codec *codec, 
-										switch_codec *other_codec, 
-										void *decoded_data,
 
-										size_t decoded_data_len, 
-										int decoded_rate, 
-										void *encoded_data,
-
-										size_t *encoded_data_len, 
-										int *encoded_rate, 
-										unsigned int *flag) 
+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)
 {
 	struct ilbc_context *context = codec->private_info;
-	int cbret = 0;
 
 	if (!context) {
 		return SWITCH_STATUS_FALSE;
 	}
-	if (decoded_data_len % 320 == 0) {
+	if (decoded_data_len % context->dbytes == 0) {
 		unsigned int new_len = 0;
-		ilbc_signal * ddp = decoded_data;
-		ilbc_byte * edp = encoded_data;
+		unsigned char *edp = encoded_data;
+		short *ddp = decoded_data;
 		int x;
-		int loops = (int) decoded_data_len / 320;
+		uint16_t y;
+		int loops = (int) decoded_data_len / context->dbytes;
+		float buf[240];
+
 		for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
-			iLBC_encode(context->encoder, ddp, edp);
-			edp += 33;
-			ddp += 160;
-			new_len += 33;
+			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
+				buf[y] = ddp[y];
+			}
+			iLBC_encode(edp, buf, &context->encoder);
+			edp += context->bytes;
+			ddp += context->dbytes;
+			new_len += context->bytes;
 		}
 		if (new_len <= *encoded_data_len) {
 			*encoded_data_len = new_len;
@@ -110,17 +136,15 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_ilbc_decode(switch_codec *codec, 
-										switch_codec *other_codec, 
+static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
+										switch_codec_t *other_codec,
 										void *encoded_data,
-
-										size_t encoded_data_len, 
-										int encoded_rate, 
+										uint32_t encoded_data_len,
+										uint32_t encoded_rate,
 										void *decoded_data,
-
-										size_t *decoded_data_len, 
-										int *decoded_rate, 
-										unsigned int *flag) 
+										uint32_t *decoded_data_len, 
+										uint32_t *decoded_rate, 
+										unsigned int *flag)
 {
 	struct ilbc_context *context = codec->private_info;
 
@@ -128,18 +152,23 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (encoded_data_len % 33 == 0) {
-		int loops = (int) encoded_data_len / 33;
-		ilbc_byte * edp = encoded_data;
-		ilbc_signal * ddp = decoded_data;
+	if (encoded_data_len % context->bytes == 0) {
+		int loops = (int) encoded_data_len / context->bytes;
+		unsigned char *edp = encoded_data;
+		short *ddp = decoded_data;
 		int x;
+		uint16_t y;
 		unsigned int new_len = 0;
+		float buf[240];
 
 		for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
-			iLBC_decode(context->decoder, edp, ddp);
-			ddp += 160;
-			edp += 33;
-			new_len += 320;
+			iLBC_decode(buf, edp, &context->decoder, 1);
+			for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
+				ddp[y] = (short)buf[y];
+			}
+			ddp += context->dbytes / sizeof(short);
+			edp += context->bytes;
+			new_len += context->dbytes;
 		}
 		if (new_len <= *decoded_data_len) {
 			*decoded_data_len = new_len;
@@ -156,33 +185,126 @@
 
 /* Registration */ 
 
-static const switch_codec_implementation ilbc_8k_implementation = { 
+static const switch_codec_implementation_t ilbc_8k_30ms_implementation = { 
+		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
+		/*.ianacode */ 97, 
+		/*.iananame */ "iLBC", 
 		/*.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_ilbc_init, 
-		/*.encode */ switch_ilbc_encode, 
-		/*.decode */ switch_ilbc_decode, 
-		/*.destroy */ switch_ilbc_destroy, 
+		/*.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", 
+		/*.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_interface ilbc_codec_interface = { 
-		/*.interface_name */ "ilbc", 
+
+
+static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = { 
 		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
-		/*.ianacode */ 3, 
-		/*.iananame */ "ilbc", 
-		/*.implementations */ &ilbc_8k_implementation, 
+		/*.ianacode */ 102, 
+		/*.iananame */ "iLBC", 
+		/*.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", 
+		/*.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 switch_loadable_module_interface ilbc_module_interface = { 
+
+static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = { 
+		/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, 
+		/*.ianacode */ 97, 
+		/*.iananame */ "iLBC20ms",
+		/*.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_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 switch_loadable_module_interface_t ilbc_module_interface = { 
 		/*.module_name */ modname, 
 		/*.endpoint_interface */ NULL, 
 		/*.timer_interface */ NULL, 
@@ -193,12 +315,12 @@
 
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
+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 */ 
-		*interface = &ilbc_module_interface;
+		*module_interface = &ilbc_module_interface;
 	
 
 		/* indicate that the module should continue to be loaded */ 

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_ilbc/mod_ilbc.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -50,7 +50,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,12 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_ilbc.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_ilbc.lib"
 				TargetMachine="1"
@@ -100,15 +99,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -143,11 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.c	Fri Sep 22 14:22:15 2006
@@ -31,11 +31,11 @@
  */
 #include <switch.h>
 
-static const char modname[] = "mod_rawaudio";
+static const char modname[] = "mod_l16";
 
 
-static switch_status switch_raw_init(switch_codec *codec, switch_codec_flag flags,
-									 const struct switch_codec_settings *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;
 
@@ -49,15 +49,14 @@
 	}
 }
 
-static switch_status switch_raw_encode(switch_codec *codec,
-									   switch_codec *other_codec,
+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)
 {
-
 	/* 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) {
 		memcpy(encoded_data, decoded_data, decoded_data_len);
@@ -67,8 +66,8 @@
 	return SWITCH_STATUS_NOOP;
 }
 
-static switch_status switch_raw_decode(switch_codec *codec,
-									   switch_codec *other_codec,
+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,
@@ -84,13 +83,16 @@
 }
 
 
-static switch_status switch_raw_destroy(switch_codec *codec)
+static switch_status_t switch_raw_destroy(switch_codec_t *codec)
 {
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static const switch_codec_implementation raw_32k_implementation = {
+static const switch_codec_implementation_t raw_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
 	/*.samples_per_second = */ 32000,
 	/*.bits_per_second = */ 512000,
 	/*.microseconds_per_frame = */ 20000,
@@ -106,7 +108,10 @@
 	/*.destroy = */ switch_raw_destroy
 };
 
-static const switch_codec_implementation raw_22k_implementation = {
+static const switch_codec_implementation_t raw_22k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
 	/*.samples_per_second = */ 22050,
 	/*.bits_per_second = */ 352800,
 	/*.microseconds_per_frame = */ 20000,
@@ -123,7 +128,10 @@
 	/*.next = */ &raw_32k_implementation
 };
 
-static const switch_codec_implementation raw_16k_implementation = {
+static const switch_codec_implementation_t raw_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
 	/*.samples_per_second = */ 16000,
 	/*.bits_per_second = */ 256000,
 	/*.microseconds_per_frame = */ 20000,
@@ -140,7 +148,10 @@
 	/*.next = */ &raw_22k_implementation
 };
 
-static const switch_codec_implementation raw_8k_implementation = {
+static const switch_codec_implementation_t raw_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
 	/*.samples_per_second = */ 8000,
 	/*.bits_per_second = */ 128000,
 	/*.microseconds_per_frame = */ 20000,
@@ -158,7 +169,10 @@
 };
 
 
-static const switch_codec_implementation raw_8k_30ms_implementation = {
+static const switch_codec_implementation_t raw_8k_30ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
 	/*.samples_per_second */ 8000,
 	/*.bits_per_second */ 128000,
 	/*.microseconds_per_frame */ 30000,
@@ -176,15 +190,53 @@
 };
 
 
-static const switch_codec_interface raw_codec_interface = {
-	/*.interface_name */ "raw signed linear (16 bit)",
+static const switch_codec_implementation_t raw_8k_60ms_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
 	/*.ianacode */ 10,
 	/*.iananame */ "L16",
-	/*.implementations */ &raw_8k_30ms_implementation
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 256000,
+	/*.microseconds_per_frame */ 60000,
+	/*.samples_per_frame */ 480,
+	/*.bytes_per_frame */ 960,
+	/*.encoded_bytes_per_frame */ 960,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_raw_init,
+	/*.encode */ switch_raw_encode,
+	/*.decode */ switch_raw_decode,
+	/*.destroy */ switch_raw_destroy,
+	/*.next */ &raw_8k_30ms_implementation
 };
 
-static switch_loadable_module_interface raw_module_interface = {
+static const switch_codec_implementation_t raw_8k_120ms_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 10,
+	/*.iananame */ "L16",
+	/*.samples_per_second */ 8000,
+	/*.bits_per_second */ 512000,
+	/*.microseconds_per_frame */ 120000,
+	/*.samples_per_frame */ 960,
+	/*.bytes_per_frame */ 1920,
+	/*.encoded_bytes_per_frame */ 1920,
+	/*.number_of_channels */ 1,
+	/*.pref_frames_per_packet */ 1,
+	/*.max_frames_per_packet */ 1,
+	/*.init */ switch_raw_init,
+	/*.encode */ switch_raw_encode,
+	/*.decode */ switch_raw_decode,
+	/*.destroy */ switch_raw_destroy,
+	/*.next */ &raw_8k_60ms_implementation
+};
+
+
+static const switch_codec_interface_t raw_codec_interface = {
+	/*.interface_name */ "raw signed linear (16 bit)",
+	/*.implementations */ &raw_8k_120ms_implementation
+};
+
+static switch_loadable_module_interface_t raw_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -196,10 +248,10 @@
 };
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &raw_module_interface;
+	*module_interface = &raw_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_l16/mod_l16.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +64,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libresampled.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_l16.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libresample\win&quot;;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_l16.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_l16.lib"
 				TargetMachine="1"
@@ -101,8 +100,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -144,11 +143,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libresample.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_l16.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libresample\win&quot;;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_speex/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_speex/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_speex/Makefile	Fri Sep 22 14:22:15 2006
@@ -1,7 +1,7 @@
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
 
 depends:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.11.1.tar.gz --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install speex-1.1.12.tar.gz --prefix=$(PREFIX) --disable-shared --with-pic
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.c	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.c	Fri Sep 22 14:22:15 2006
@@ -33,9 +33,9 @@
 #include <speex/speex.h>
 #include <speex/speex_preprocess.h>
 
-static const char modname[] = "mod_speexcodec";
+static const char modname[] = "mod_speex";
 
-static const struct switch_codec_settings default_codec_settings = {
+static const switch_codec_settings_t default_codec_settings = {
 	/*.quality */ 5,
 	/*.complexity */ 5,
 	/*.enhancement */ 1,
@@ -55,7 +55,7 @@
 };
 
 struct speex_context {
-	switch_codec *codec;
+	switch_codec_t *codec;
 	unsigned int flags;
 
 	/* Encoder */
@@ -72,8 +72,8 @@
 	int decoder_mode;
 };
 
-static switch_status switch_speex_init(switch_codec *codec, switch_codec_flag flags,
-									   const struct switch_codec_settings *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;
@@ -157,8 +157,8 @@
 	}
 }
 
-static switch_status switch_speex_encode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -202,18 +202,16 @@
 	}
 
 
-
-
 	speex_bits_pack(&context->encoder_bits, 15, 5);
 	*encoded_data_len = speex_bits_write(&context->encoder_bits, (char *) encoded_data, context->encoder_frame_size);
 	speex_bits_reset(&context->encoder_bits);
+	(*encoded_data_len)--;
 
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_speex_decode(switch_codec *codec,
-										 switch_codec *other_codec,
+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,
@@ -227,19 +225,21 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
+
 	buf = decoded_data;
 	if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
 		speex_decode_int(context->decoder_state, NULL, buf);
 	} else {
-		speex_bits_read_from(&context->decoder_bits, (char *) encoded_data, (int) *decoded_data_len);
+		speex_bits_read_from(&context->decoder_bits, (char *) encoded_data, (int) encoded_data_len);
 		speex_decode_int(context->decoder_state, &context->decoder_bits, buf);
 	}
+	*decoded_data_len = codec->implementation->bytes_per_frame;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status switch_speex_destroy(switch_codec *codec)
+static switch_status_t switch_speex_destroy(switch_codec_t *codec)
 {
 	int encoding, decoding;
 	struct speex_context *context = codec->private_info;
@@ -267,13 +267,16 @@
 }
 
 /* Registration */
-static const switch_codec_implementation speex_32k_implementation = {
+static const switch_codec_implementation_t speex_32k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 102,
+	/*.iananame */ "speex",
 	/*.samples_per_second */ 32000,
-	/*.bits_per_second */ 512000,
+	/*.bits_per_second */ 256000,
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 640,
 	/*.bytes_per_frame */ 1280,
-	/*.encoded_bytes_per_frame */ 1280,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
@@ -283,13 +286,16 @@
 	/*.destroy */ switch_speex_destroy
 };
 
-static const switch_codec_implementation speex_16k_implementation = {
+static const switch_codec_implementation_t speex_16k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 99,
+	/*.iananame */ "speex",
 	/*.samples_per_second */ 16000,
-	/*.bits_per_second */ 256000,
+	/*.bits_per_second */ 22000,
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 320,
 	/*.bytes_per_frame */ 640,
-	/*.encoded_bytes_per_frame */ 640,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
@@ -300,13 +306,16 @@
 	/*.next */ &speex_32k_implementation
 };
 
-static const switch_codec_implementation speex_8k_implementation = {
+static const switch_codec_implementation_t speex_8k_implementation = {
+	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
+	/*.ianacode */ 98,
+	/*.iananame */ "speex",
 	/*.samples_per_second */ 8000,
-	/*.bits_per_second */ 128000,
+	/*.bits_per_second */ 11000,
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 160,
 	/*.bytes_per_frame */ 320,
-	/*.encoded_bytes_per_frame */ 320,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
@@ -317,15 +326,12 @@
 	/*.next */ &speex_16k_implementation
 };
 
-static const switch_codec_interface speex_codec_interface = {
+static const switch_codec_interface_t speex_codec_interface = {
 	/*.interface_name */ "speex",
-	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
-	/*.ianacode */ 98,
-	/*.iananame */ "speex",
 	/*.implementations */ &speex_8k_implementation
 };
 
-static switch_loadable_module_interface speex_module_interface = {
+static switch_loadable_module_interface_t speex_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -334,10 +340,10 @@
 	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &speex_module_interface;
+	*module_interface = &speex_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/codecs/mod_speex/mod_speex.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_SpeexCodec Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex\include\speex&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex-1.1.11.1\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex-1.1.11.1\include\speex&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +64,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libspeex.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_speex.dll"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\speex\win32\libspeex\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\speex-1.1.11.1\win32\libspeex\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_speex.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_speex.lib"
 				TargetMachine="1"
@@ -101,15 +100,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_SpeexCodec Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -125,7 +124,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex\include\speex&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex-1.1.11.1\include&quot;;&quot;$(InputDir)..\..\..\..\libs\speex-1.1.11.1\include\speex&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -144,11 +143,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libspeex.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_speex.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\speex\win32\libspeex\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
+				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\speex-1.1.11.1\win32\libspeex\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	(original)
+++ freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	Fri Sep 22 14:22:15 2006
@@ -54,20 +54,21 @@
 static void load_config(void)
 {
 	char *cf = "dialplan_directory.conf";
-	switch_config cfg;
-	char *var, *val;
+	switch_xml_t cfg, xml, settings, param;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
-			if (!strcmp(var, "directory_name") && val) {
+	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 (!strcmp(var, "directory-name") && val) {
 				set_global_directory_name(val);
-			} else if (!strcmp(var, "directory_name") && val) {
-				set_global_directory_name(val);
 			} else if (!strcmp(var, "host") && val) {
 				set_global_host(val);
 			} else if (!strcmp(var, "dn") && val) {
@@ -79,17 +80,17 @@
 			}
 		}
 	}
-	switch_config_close_file(&cfg);	
+	switch_xml_free(xml);
 }
 
-static switch_caller_extension *directory_dialplan_hunt(switch_core_session *session)
+static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t *session)
 {
-	switch_caller_profile *caller_profile;
-	switch_caller_extension *extension = NULL;
-	switch_channel *channel;
+	switch_caller_profile_t *caller_profile;
+	switch_caller_extension_t *extension = NULL;
+	switch_channel_t *channel;
 	char *var, *val;
 	char filter[256];
-	switch_directory_handle dh;
+	switch_directory_handle_t dh;
 	char app[512];
 	char *data;
 
@@ -116,8 +117,12 @@
 		return NULL;
 	}
 
-	sprintf(filter, "exten=%s", caller_profile->destination_number);
+	snprintf(filter, sizeof(filter), "exten=%s", caller_profile->destination_number);
+	if (caller_profile->context) {
+		snprintf(filter + strlen(filter), sizeof(filter) - strlen(filter), "context=%s", caller_profile->context);
+	}
 
+
 	switch_core_directory_query(&dh, globals.base, filter);
 	while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {
 		while (switch_core_directory_next_pair(&dh, &var, &val) == SWITCH_STATUS_SUCCESS) {
@@ -146,20 +151,20 @@
 	if (extension) {
 		switch_channel_set_state(channel, CS_EXECUTE);
 	} else {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
 	}
 
 	return extension;
 }
 
 
-static const switch_dialplan_interface directory_dialplan_interface = {
+static const switch_dialplan_interface_t directory_dialplan_interface = {
 	/*.interface_name = */ "directory",
 	/*.hunt_function = */ directory_dialplan_hunt
 	/*.next = NULL */
 };
 
-static const switch_loadable_module_interface directory_dialplan_module_interface = {
+static const switch_loadable_module_interface_t directory_dialplan_module_interface = {
 	/*.module_name = */ modname,
 	/*.endpoint_interface = */ NULL,
 	/*.timer_interface = */ NULL,
@@ -168,12 +173,12 @@
 	/*.application_interface = */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	load_config();
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &directory_dialplan_module_interface;
+	*module_interface = &directory_dialplan_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_directory.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_dialplan_directory.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_dialplan_directory.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -141,10 +141,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_directory.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.c	(original)
+++ freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.c	Fri Sep 22 14:22:15 2006
@@ -57,7 +57,7 @@
 };
 
 
-static switch_status mod_ldap_open(switch_directory_handle *dh, char *source, char *dsn, char *passwd)
+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;
@@ -86,7 +86,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status mod_ldap_close(switch_directory_handle *dh)
+static switch_status_t mod_ldap_close(switch_directory_handle_t *dh)
 {
 	struct ldap_context *context;
 
@@ -98,7 +98,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status mod_ldap_query(switch_directory_handle *dh, char *base, char *query)
+static switch_status_t mod_ldap_query(switch_directory_handle_t *dh, char *base, char *query)
 {
 	struct ldap_context *context;
 
@@ -116,7 +116,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status mod_ldap_next(switch_directory_handle *dh)
+static switch_status_t mod_ldap_next(switch_directory_handle_t *dh)
 {
 	struct ldap_context *context;
 
@@ -140,7 +140,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status mod_ldap_next_pair(switch_directory_handle *dh, char **var, char **val)
+static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **var, char **val)
 {
 	struct ldap_context *context;
 
@@ -197,7 +197,7 @@
 }
 
 
-static const switch_directory_interface ldap_directory_interface = {
+static const switch_directory_interface_t ldap_directory_interface = {
     /*.interface_name */ "ldap",
 	/*.directory_open*/ mod_ldap_open,
 	/*.directory_close*/ mod_ldap_close,
@@ -207,7 +207,7 @@
 };
 
 
-static switch_loadable_module_interface skel_module_interface = {
+static switch_loadable_module_interface_t skel_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -220,10 +220,10 @@
 	/*.directory_interface */ &ldap_directory_interface
 };
 
-switch_status switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+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 */
-	*interface = &skel_module_interface;
+	*module_interface = &skel_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/directories/mod_ldap/mod_ldap.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_ldap Debug"
+				CommandLine="cscript /nologo &quot;$(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs&quot; Mod_ldap Debug"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,11 +65,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="Ws2_32.lib olber32.lib oldap_r.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ldap.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\openldap\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_ldap.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_ldap.lib"
 				TargetMachine="1"
@@ -101,15 +101,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_ldap Release"
+				CommandLine="cscript /nologo &quot;$(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs&quot; Mod_ldap Release"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -146,10 +146,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="Ws2_32.lib olber32.lib oldap_r.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ldap.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\openldap\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
@@ -183,7 +184,7 @@
 		</Configuration>
 		<Configuration
 			Name="Debug MS-LDAP|Win32"
-			OutputDirectory="$(ConfigurationName)"
+			OutputDirectory="Debug"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
@@ -217,7 +218,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -231,11 +232,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="Ws2_32.lib Wldap32.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ldap.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\openldap\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_ldap.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_ldap.lib"
 				TargetMachine="1"
@@ -267,7 +268,7 @@
 		</Configuration>
 		<Configuration
 			Name="Release MS-LDAP|Win32"
-			OutputDirectory="$(ConfigurationName)"
+			OutputDirectory="Release"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
@@ -312,10 +313,11 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="Ws2_32.lib Wldap32.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ldap.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\openldap\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Fri Sep 22 14:22:15 2006
@@ -35,9 +35,15 @@
 #define DL_CAND_WAIT 10000000
 #define DL_CAND_INITIAL_WAIT 2000000
 
+
+#define DL_EVENT_LOGIN_SUCCESS "dingaling::login_success"
+#define DL_EVENT_LOGIN_FAILURE "dingaling::login_failure"
+#define DL_EVENT_MESSAGE "dingaling::message"
+#define DL_EVENT_CONNECTED "dingaling::connected"
+
 static const char modname[] = "mod_dingaling";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 typedef enum {
 	TFLAG_IO = (1 << 0),
@@ -51,6 +57,17 @@
 	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_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_TRANSPORT_ACCEPT = (1 << 21),
 } TFLAGS;
 
 typedef enum {
@@ -68,39 +85,43 @@
 	int codec_rates_last;
 	unsigned int flags;
 	unsigned int init;
-	switch_hash *profile_hash;
+	switch_hash_t *profile_hash;
 	int running;
 	int handles;
 } globals;
 
 struct mdl_profile {
-	char *name;
-	char *login;
-	char *password;
-	char *message;
-	char *dialplan;
-	char *ip;
-	char *extip;
-	char *lanaddr;
-	char *exten;
-	unsigned int flags;
-	ldl_handle_t *handle;
+    char *name;
+    char *login;
+    char *password;
+    char *message;
+    char *dialplan;
+    char *ip;
+    char *extip;
+    char *lanaddr;
+	char *server;
+    char *exten;
+    char *context;
+	char *timer_name;
+    ldl_handle_t *handle;
+    uint32_t flags;
+    uint32_t user_flags;
 };
 
 struct private_object {
 	unsigned int flags;
-	switch_codec read_codec;
-	switch_codec write_codec;
-	struct switch_frame read_frame;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
+	switch_frame_t read_frame;
 	struct mdl_profile *profile;
-	switch_core_session *session;
-	switch_caller_profile *caller_profile;
+	switch_core_session_t *session;
+	switch_caller_profile_t *caller_profile;
 	unsigned short samprate;
 	switch_mutex_t *mutex;
-	switch_codec_interface *codecs[SWITCH_MAX_CODECS];
+	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
 	unsigned int num_codecs;
 	int codec_index;
-	struct switch_rtp *rtp_session;
+	switch_rtp_t *rtp_session;
 	ldl_session_t *dlsession;
 	char *remote_ip;
 	switch_port_t local_port;
@@ -110,25 +131,21 @@
 	char *remote_user;
 	unsigned int cand_id;
 	unsigned int desc_id;
-	char last_digit;
 	unsigned int dc;
-	time_t last_digit_time;
-	switch_queue_t *dtmf_queue;
-	char out_digit;
-	unsigned char out_digit_packet[4];
-	unsigned int out_digit_sofar;
-	unsigned int out_digit_dur;
-	uint16_t out_digit_seq;
 	int32_t timestamp_send;
 	int32_t timestamp_recv;
-	int32_t timestamp_dtmf;
 	uint32_t last_read;
 	char *codec_name;
 	switch_payload_t codec_num;
+	switch_payload_t r_codec_num;
+	uint32_t codec_rate;
 	switch_time_t next_desc;
 	switch_time_t next_cand;
 	char *stun_ip;
+	char *recip;
+	char *dnis;
 	uint16_t stun_port;
+	switch_mutex_t *flag_mutex;
 };
 
 struct rfc2833_digit {
@@ -137,27 +154,74 @@
 };
 
 
-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_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);
 
-
-static switch_status channel_on_init(switch_core_session *session);
-static switch_status channel_on_hangup(switch_core_session *session);
-static switch_status channel_on_ring(switch_core_session *session);
-static switch_status channel_on_loopback(switch_core_session *session);
-static switch_status channel_on_transmit(switch_core_session *session);
-static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool);
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag flags, int stream_id);
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag flags, int stream_id);
-static switch_status channel_kill_channel(switch_core_session *session, int sig);
-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *msg);
+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_status_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 signal, char *from, char *subject, char *msg);
 static ldl_status handle_response(ldl_handle_t *handle, char *id);
-static switch_status load_config(void);
+static switch_status_t load_config(void);
 
+
+static void terminate_session(switch_core_session_t **session, int line, switch_call_cause_t cause)
+{
+	if (*session) {
+		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 (state < CS_INIT || !switch_core_session_running(*session)) {
+			if (state > CS_INIT && state < CS_HANGUP) {
+				channel_on_hangup(*session);
+			}
+
+			if (tech_pvt && tech_pvt->dlsession) {
+				ldl_session_set_private(tech_pvt->dlsession, NULL);
+			}
+			switch_core_session_destroy(session);
+		} else if (tech_pvt){
+			if (switch_test_flag(tech_pvt, TFLAG_TERM)) {
+				/*once is enough*/
+				return;
+			}
+
+			if (tech_pvt->dlsession) {
+				if (!switch_test_flag(tech_pvt, TFLAG_TERM)) {
+					ldl_session_terminate(tech_pvt->dlsession);
+				}
+				ldl_session_destroy(&tech_pvt->dlsession);
+			}
+			switch_set_flag_locked(tech_pvt, TFLAG_TERM);
+		}
+
+		if (state < CS_HANGUP) {
+			switch_channel_hangup(channel, cause);
+		}
+		
+		*session = NULL;
+	}
+
+}
+
 static void dl_logger(char *file, const char *func, int line, int level, char *fmt, ...)
 {
 	va_list ap;
@@ -171,36 +235,42 @@
 	va_end(ap);
 }
 
-static void get_codecs(struct private_object *tech_pvt)
+static int get_codecs(struct private_object *tech_pvt)
 {
 	assert(tech_pvt != NULL);
 	assert(tech_pvt->session != NULL);
 
-	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) {
+	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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
+				return 0;
+			}
+		} else if (((tech_pvt->num_codecs =
+					 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
-			return;
+			return 0;
 		}
-	} else if (((tech_pvt->num_codecs =
-				 switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
-		return;
 	}
+
+	return tech_pvt->num_codecs;
 }
 
 
 
-static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread *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;
 
 	profile = ldl_handle_get_private(handle);
 	globals.handles++;
+	switch_set_flag(profile, TFLAG_IO);
 	ldl_handle_run(handle);
+	switch_clear_flag(profile, TFLAG_IO);
 	globals.handles--;
 	ldl_handle_destroy(&handle);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle %s [%s] Destroyed\n", profile->name, profile->login);
@@ -210,11 +280,12 @@
 
 static void handle_thread_launch(ldl_handle_t *handle)
 {
-	switch_thread *thread;
+	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);
 	switch_thread_create(&thread, thd_attr, handle_thread_run, handle, module_pool);
 
 }
@@ -222,200 +293,259 @@
 
 static int activate_rtp(struct private_object *tech_pvt)
 {
-	switch_channel *channel = switch_core_session_get_channel(tech_pvt->session);
+	switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
 	const char *err;
+	int ms = 0;
+	switch_rtp_flag_t flags;
 
-	if (tech_pvt->rtp_session) {
-		return 0;
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
+		return 1;
 	}
 
 	if (switch_core_codec_init(&tech_pvt->read_codec,
 							   tech_pvt->codec_name,
-							   8000,
-							   20,
+							   tech_pvt->codec_rate,
+							   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_DEBUG, "Can't load codec?\n");
-		switch_channel_hangup(channel);
-		return 1;
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		return 0;
 	}
 	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\n", tech_pvt->codec_name);
-
+	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,
-							   8000,
-							   20,
+							   tech_pvt->codec_rate,
+							   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_DEBUG, "Can't load codec?\n");
-		switch_channel_hangup(channel);
-		return -1;
+		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\n",  tech_pvt->codec_name);
+	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);
+	
+	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;
+	}
+
 	if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip,
 												 tech_pvt->local_port,
 												 tech_pvt->remote_ip,
 												 tech_pvt->remote_port,
 												 tech_pvt->codec_num,
-												 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+												 0,
 												 tech_pvt->read_codec.implementation->microseconds_per_frame,
-												 SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ,
+												 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);
-		return -1;
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		return 0;
+	} else {
+		uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
+		uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
+		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
+		switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user);
+		if ((vad_in && inb) || (vad_out && !inb)) {
+			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
+			switch_set_flag_locked(tech_pvt, TFLAG_VAD);
+		}
 	}
-	switch_rtp_activate_ice(tech_pvt->rtp_session, tech_pvt->remote_user, tech_pvt->local_user);
-	
 
-	return 0;
+	return 1;
 }
 
 
 
 static int do_candidates(struct private_object *tech_pvt, int force)
 {
-	switch_channel *channel = switch_core_session_get_channel(tech_pvt->session);
+	switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
 
+	if (switch_test_flag(tech_pvt, TFLAG_DO_CAND)) {
+		return 1;
+	}
+
 	tech_pvt->next_cand += DL_CAND_WAIT;
+	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+		return 0;
+	}
+	switch_set_flag_locked(tech_pvt, TFLAG_DO_CAND);
 
 	if (force || !switch_test_flag(tech_pvt, TFLAG_RTP_READY)) {
-				ldl_candidate_t cand[1];
-				char *advip = tech_pvt->profile->extip ? tech_pvt->profile->extip : tech_pvt->profile->ip;
-				char *err;
+		ldl_candidate_t cand[1];
+		char *advip = tech_pvt->profile->extip ? tech_pvt->profile->extip : tech_pvt->profile->ip;
+		char *err;
 
-				memset(cand, 0, sizeof(cand));
-				switch_stun_random_string(tech_pvt->local_user, 16, NULL);
-				switch_stun_random_string(tech_pvt->local_pass, 16, NULL);
+		memset(cand, 0, sizeof(cand));
+		switch_stun_random_string(tech_pvt->local_user, 16, NULL);
+		switch_stun_random_string(tech_pvt->local_pass, 16, NULL);
 
+		if (switch_test_flag(tech_pvt, TFLAG_LANADDR)) {
+			advip = tech_pvt->profile->ip;
+		}
 
-				cand[0].port = tech_pvt->local_port;
-				cand[0].address = advip;
+
+		cand[0].port = tech_pvt->local_port;
+		cand[0].address = advip;
 				
-				if (!strncasecmp(advip, "stun:", 5)) {
-					char *stun_ip = advip + 5;
+		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;
-					} else {
-						if (!stun_ip) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER!\n");
-							switch_channel_hangup(channel);
-							return -1;
-						}
-
-						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) {
-							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);
-							return -1;
-						}
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port);
-					}
-					cand[0].type = "stun";
-					tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, cand[0].address);
-					tech_pvt->stun_port = cand[0].port;
-				} else {
-					cand[0].type = "local";
+			if (tech_pvt->stun_ip) {
+				cand[0].address = tech_pvt->stun_ip;
+				cand[0].port = tech_pvt->stun_port;
+			} else {
+				if (!stun_ip) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER!\n");
+					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+					return 0;
 				}
 
-				cand[0].name = "rtp";
-				cand[0].username = tech_pvt->local_user;
-				cand[0].password = tech_pvt->local_pass;
-				cand[0].pref = 1;
-				cand[0].protocol = "udp";
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
-				tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
-				switch_set_flag(tech_pvt, TFLAG_RTP_READY);
+				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) {
+					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;
+				}
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success %s:%d\n", cand[0].address, cand[0].port);
 			}
-	return 0;
+			cand[0].type = "stun";
+			tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, cand[0].address);
+			tech_pvt->stun_port = cand[0].port;
+		} else {
+			cand[0].type = "local";
+		}
+
+		cand[0].name = "rtp";
+		cand[0].username = tech_pvt->local_user;
+		cand[0].password = tech_pvt->local_pass;
+		cand[0].pref = 1;
+		cand[0].protocol = "udp";
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
+		tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
+		switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
+	}
+	switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
+	return 1;
 }
 
+static char *lame(char *in)
+{
+	if (!strncasecmp(in, "ilbc", 4)) {
+		return "iLBC";
+	} else {
+		return in;
+	}
+}
+
 static int do_describe(struct private_object *tech_pvt, int force)
 {
 	ldl_payload_t payloads[5];
-	switch_channel *channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
 
+	if (!tech_pvt->session) {
+		return 0;
+	}
+
+	if (switch_test_flag(tech_pvt, TFLAG_DO_DESC)) {
+		return 1;
+	}
+
 	tech_pvt->next_desc += DL_CAND_WAIT;
 
-	memset(payloads, 0, sizeof(payloads));
+	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+		return 0;
+	}
 
-	if (!tech_pvt->num_codecs) {
-		get_codecs(tech_pvt);
-		if (!tech_pvt->num_codecs) {
-			switch_channel_hangup(channel);
-			switch_set_flag(tech_pvt, TFLAG_BYE);
-			switch_clear_flag(tech_pvt, TFLAG_IO);
-			return -1;
-		}
+	memset(payloads, 0, sizeof(payloads));
+	switch_set_flag_locked(tech_pvt, TFLAG_DO_CAND);
+	if (!get_codecs(tech_pvt)) {
+		terminate_session(&tech_pvt->session, __LINE__, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
+		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		return 0;
 	}
 
+
 	if (force || !switch_test_flag(tech_pvt, TFLAG_CODEC_READY)) {
 		if (tech_pvt->codec_index < 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't have my codec yet here's one\n");
-			tech_pvt->codec_name = tech_pvt->codecs[0]->iananame;
+			tech_pvt->codec_name = lame(tech_pvt->codecs[0]->iananame);
 			tech_pvt->codec_num = tech_pvt->codecs[0]->ianacode;
+			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 = tech_pvt->codecs[0]->iananame;
+			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 = tech_pvt->codecs[tech_pvt->codec_index]->iananame;
+			payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
 			payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
+			payloads[0].rate = tech_pvt->codecs[tech_pvt->codec_index]->samples_per_second;
+			payloads[0].bps = tech_pvt->codecs[tech_pvt->codec_index]->bits_per_second;
 		}
 
 				
-		payloads[0].name = tech_pvt->codecs[0]->iananame;
-		payloads[0].id = tech_pvt->codecs[0]->ianacode;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Describe [%s]\n", payloads[0].name);
+		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);
-		switch_set_flag(tech_pvt, TFLAG_CODEC_READY);
+		switch_set_flag_locked(tech_pvt, TFLAG_CODEC_READY);
 	} 
-
-	return 0;
+	switch_clear_flag_locked(tech_pvt, TFLAG_DO_CAND);
+	return 1;
 }
 
-static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void *obj)
+static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread_t *thread, void *obj)
 {
-	switch_core_session *session = obj;
+	switch_core_session_t *session = obj;
 
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt = NULL;
 	switch_time_t started;
 	switch_time_t now;
 	unsigned int elapsed;
 
+	if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+		/* too late */
+		return NULL;
+	}
+
+
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	switch_set_flag(tech_pvt, TFLAG_IO);
+	switch_set_flag_locked(tech_pvt, TFLAG_IO);
 
 	started = switch_time_now();
 
@@ -429,60 +559,73 @@
 	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);
 
 		if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
-			return NULL;
+			goto out;
 		}
 
 		
 		if (now >= tech_pvt->next_desc) {
-			if (do_describe(tech_pvt, 0) < 0) {
-				break;
+			if (!do_describe(tech_pvt, 0)) {
+				goto out;
 			}
 		}
 		
 		if (tech_pvt->next_cand && now >= tech_pvt->next_cand) {
-			if (do_candidates(tech_pvt, 0) < 0) {
-				break;
+			if (!do_candidates(tech_pvt, 0)) {
+				goto out;
 			}
 		}
 		if (elapsed > 60000) {
-			switch_channel_hangup(channel);
-			switch_set_flag(tech_pvt, TFLAG_BYE);
-			switch_clear_flag(tech_pvt, TFLAG_IO);
-			return NULL;
+			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)) {
-			return NULL;
+			goto done;
 		}
 		switch_yield(1000);
 		//printf("WAIT %s %d %d %d %d\n", switch_channel_get_name(channel), switch_test_flag(tech_pvt, TFLAG_TRANSPORT), switch_test_flag(tech_pvt, TFLAG_CODEC_READY), switch_test_flag(tech_pvt, TFLAG_RTP_READY), switch_test_flag(tech_pvt, TFLAG_ANSWER));
 	}
 	
 	if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
-		return NULL;
+		goto out;
 	}	
 
-	activate_rtp(tech_pvt);
+	if (!activate_rtp(tech_pvt)) {
+		goto out;
+	}
 	
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-		do_candidates(tech_pvt, 0);
+		if (!do_candidates(tech_pvt, 0)) {
+			goto out;
+		}
 		switch_channel_answer(channel);
 		//printf("***************************ANSWER\n");
 	} else {
 		switch_core_session_thread_launch(session);
 	}
 	switch_channel_set_state(channel, CS_INIT);
+	goto done;
+	
+ out:
+	terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ done:
+	if (session) {
+		switch_core_session_rwunlock(session);
+	}
 	return NULL;
 }
 
 
-static void negotiate_thread_launch(switch_core_session *session)
+static void negotiate_thread_launch(switch_core_session_t *session)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 	
 	switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
@@ -494,13 +637,13 @@
 
 
 /* 
-State methods they get called when the state changes to the specific state 
-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.
+   State methods they get called when the state changes to the specific state 
+   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 channel_on_init(switch_core_session *session)
+static switch_status_t channel_on_init(switch_core_session_t *session)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt = NULL;
 
 	tech_pvt = switch_core_session_get_private(session);
@@ -517,9 +660,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_ring(switch_core_session *session)
+static switch_status_t channel_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -533,10 +676,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_execute(switch_core_session *session)
+static switch_status_t channel_on_execute(switch_core_session_t *session)
 {
 
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -551,9 +694,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_hangup(switch_core_session *session)
+static switch_status_t channel_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -562,16 +705,19 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
-	switch_clear_flag(tech_pvt, TFLAG_VOICE);
-	switch_set_flag(tech_pvt, TFLAG_BYE);
+	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) {
-		ldl_session_terminate(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 (tech_pvt->rtp_session) {
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
 		switch_rtp_destroy(&tech_pvt->rtp_session);
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NUKE RTP\n");
 		tech_pvt->rtp_session = NULL;
@@ -590,23 +736,30 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_kill_channel(switch_core_session *session, int sig)
+static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	if ((channel = switch_core_session_get_channel(session))) {
 		if ((tech_pvt = switch_core_session_get_private(session))) {
-			switch_clear_flag(tech_pvt, TFLAG_IO);
-			switch_clear_flag(tech_pvt, TFLAG_VOICE);
-			switch_set_flag(tech_pvt, TFLAG_BYE);
-			switch_channel_hangup(channel);
+			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) {
-				ldl_session_terminate(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 (tech_pvt->rtp_session) {
+
+			if (switch_rtp_ready(tech_pvt->rtp_session)) {
 				switch_rtp_kill_socket(tech_pvt->rtp_session);
 			}
+
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 		}
 	}
@@ -614,19 +767,19 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_loopback(switch_core_session *session)
+static switch_status_t channel_on_loopback(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_transmit(switch_core_session *session)
+static switch_status_t channel_on_transmit(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -636,7 +789,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -647,27 +800,33 @@
 
 }
 
-static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
+static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *dtmf)
 {
 	struct private_object *tech_pvt = NULL;
-	//char *digit;
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%s]\n", dtmf);
+	//snprintf(digits, sizeof(digits), "+%s\n", dtmf);
+	//ldl_handle_send_msg(tech_pvt->profile->handle, tech_pvt->recip, NULL, digits);
 
-	return SWITCH_STATUS_SUCCESS;
+	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
+									dtmf,
+									100 * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
+
+	//return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag 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;
 	switch_size_t samples = 0, frames = 0, ms = 0;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	switch_payload_t payload = 0;
-	switch_status status;
+	switch_status_t status;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -681,7 +840,7 @@
 	}
 
 	tech_pvt->read_frame.datalen = 0;
-	switch_set_flag(tech_pvt, TFLAG_READING);
+	switch_set_flag_locked(tech_pvt, TFLAG_READING);
 
 	bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
 	samples = tech_pvt->read_codec.implementation->samples_per_frame;
@@ -692,37 +851,22 @@
 	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;
 		}
 		payload = tech_pvt->read_frame.payload;
 
-		/* RFC2833 ... TBD try harder to honor the duration etc.*/
-		if (payload == 101) {
-			unsigned char *packet = tech_pvt->read_frame.data;
-			int end = packet[1]&0x80;
-			int duration = (packet[2]<<8) + packet[3];
-			char key = switch_rfc2833_to_char(packet[0]);
+		if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
+			char dtmf[128];
+			switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, dtmf, sizeof(dtmf));
+			switch_channel_queue_dtmf(channel, dtmf);
+			switch_set_flag_locked(tech_pvt, TFLAG_DTMF);
+		}
 
-			/* SHEESH.... Curse you RFC2833 inventors!!!!*/
-			if ((time(NULL) - tech_pvt->last_digit_time) > 2) {
-				tech_pvt->last_digit = 0;
-				tech_pvt->dc = 0;
-			}
-			if (duration && end) {
-				if (key != tech_pvt->last_digit) {
-					char digit_str[] = {key, 0};
-					time(&tech_pvt->last_digit_time);
-					switch_channel_queue_dtmf(channel, digit_str);
-				}
-				if (++tech_pvt->dc >= 3) {
-					tech_pvt->last_digit = 0;
-					tech_pvt->dc = 0;
-				} else {
-					tech_pvt->last_digit = key;
-				}
-			} 
+		if (switch_test_flag(tech_pvt, TFLAG_DTMF)) {
+			switch_clear_flag_locked(tech_pvt, TFLAG_DTMF);
+			return SWITCH_STATUS_BREAK;
 		}
 
 		if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) {
@@ -730,8 +874,12 @@
 		}
 
 		if (tech_pvt->read_frame.datalen > 0) {
-			bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-			frames = (tech_pvt->read_frame.datalen / bytes);
+			if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+				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;
@@ -745,10 +893,10 @@
 	}
 
 
-	switch_clear_flag(tech_pvt, TFLAG_READING);
+	switch_clear_flag_locked(tech_pvt, TFLAG_READING);
 
 	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
-		switch_channel_hangup(channel);
+		terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -756,12 +904,12 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag 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 *channel = NULL;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	int bytes = 0, samples = 0, frames = 0;
 
 
@@ -781,77 +929,21 @@
 
 
 	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
-		switch_channel_hangup(channel);
+		terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
-	switch_set_flag(tech_pvt, TFLAG_WRITING);
+	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
+	if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+		bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+		frames = ((int) frame->datalen / bytes);
+	} else {
+		frames = 1;
+	}
 
-	bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-	frames = ((int) frame->datalen / bytes);
 	samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 
-	if (tech_pvt->out_digit_dur > 0) {
-		int x, ts, loops = 1, duration;
-
-		tech_pvt->out_digit_sofar += samples;
-
-		if (tech_pvt->out_digit_sofar >= tech_pvt->out_digit_dur) {
-			duration = tech_pvt->out_digit_dur;
-			tech_pvt->out_digit_packet[1] |= 0x80;
-			tech_pvt->out_digit_dur = 0;
-			loops = 3;
-		} else {
-			duration = tech_pvt->out_digit_sofar;
-		}
-
-		ts = tech_pvt->timestamp_dtmf += samples;
-		tech_pvt->out_digit_packet[2] = (unsigned char) (duration >> 8);
-		tech_pvt->out_digit_packet[3] = (unsigned char) duration;
-		
-
-		for (x = 0; x < loops; x++) {
-			switch_rtp_write_payload(tech_pvt->rtp_session, tech_pvt->out_digit_packet, 4, 101, ts, tech_pvt->out_digit_seq, &frame->flags);
-			/*
-			printf("Send %s packet for [%c] ts=%d sofar=%u dur=%d\n", loops == 1 ? "middle" : "end", tech_pvt->out_digit, ts, 
-				   tech_pvt->out_digit_sofar, duration);
-			*/
-		}
-	}
-
-	if (!tech_pvt->out_digit_dur && tech_pvt->dtmf_queue && switch_queue_size(tech_pvt->dtmf_queue)) {
-		void *pop;
-
-		if (switch_queue_trypop(tech_pvt->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-			int x, ts;
-			struct rfc2833_digit *rdigit = pop;
-			
-			memset(tech_pvt->out_digit_packet, 0, 4);
-			tech_pvt->out_digit_sofar = 0;
-			tech_pvt->out_digit_dur = rdigit->duration;
-			tech_pvt->out_digit = rdigit->digit;
-			tech_pvt->out_digit_packet[0] = (unsigned char)switch_char_to_rfc2833(rdigit->digit);
-			tech_pvt->out_digit_packet[1] = 7;
-
-			ts = tech_pvt->timestamp_dtmf += samples;
-			tech_pvt->out_digit_seq++;
-			for (x = 0; x < 3; x++) {
-				switch_rtp_write_payload(tech_pvt->rtp_session, tech_pvt->out_digit_packet, 4, 101, ts, tech_pvt->out_digit_seq, &frame->flags);
-				/*
-				printf("Send start packet for [%c] ts=%d sofar=%u dur=%d\n", tech_pvt->out_digit, ts, 
-					   tech_pvt->out_digit_sofar, 0);
-				*/
-			}
-
-			free(rdigit);
-		}
-	}
-
-
-
-
-
 	//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);
 
 	if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, samples) < 0) {
@@ -859,15 +951,15 @@
 	}
 	tech_pvt->timestamp_send += (int) samples;
 
-	switch_clear_flag(tech_pvt, TFLAG_WRITING);
+	switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
 	//switch_mutex_unlock(tech_pvt->rtp_lock);
 	return status;
 }
 
-static switch_status channel_answer_channel(switch_core_session *session)
+static switch_status_t channel_answer_channel(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -884,9 +976,9 @@
 }
 
 
-static switch_status channel_receive_message(switch_core_session *session, switch_core_session_message *msg)
+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt;
 			
 	channel = switch_core_session_get_channel(session);
@@ -897,24 +989,53 @@
 
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
-			if (tech_pvt->rtp_session) {
-				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");
-			}
-			break;
+	  if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+			switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
+			//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
+		}
+		break;
 	case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
-			if (tech_pvt->rtp_session) {
-				switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
-			}
-			break;
+		if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+			switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
+			//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
+		}
+		break;
 	default:
 		break;
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
-static const switch_state_handler_table channel_event_handlers = {
+
+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;
+	char *subject, *body;
+
+    channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+    tech_pvt = switch_core_session_get_private(session);
+    assert(tech_pvt != NULL);
+
+
+	if (!(body = switch_event_get_body(event))) {
+		body = "";
+	}
+
+	if (!(subject = switch_event_get_header(event, "subject"))) {
+		subject = "None";
+	}
+
+	ldl_session_send_msg(tech_pvt->dlsession, subject, body);
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static const switch_state_handler_table_t channel_event_handlers = {
 	/*.on_init */ channel_on_init,
 	/*.on_ring */ channel_on_ring,
 	/*.on_execute */ channel_on_execute,
@@ -923,7 +1044,7 @@
 	/*.on_transmit */ channel_on_transmit
 };
 
-static const switch_io_routines channel_io_routines = {
+static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
 	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
@@ -932,10 +1053,11 @@
 	/*.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,
+	/*.receive_event*/ channel_receive_event
 };
 
-static const switch_endpoint_interface channel_endpoint_interface = {
+static const switch_endpoint_interface_t channel_endpoint_interface = {
 	/*.interface_name */ "dingaling",
 	/*.io_routines */ &channel_io_routines,
 	/*.event_handlers */ &channel_event_handlers,
@@ -943,26 +1065,45 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface channel_module_interface = {
+
+
+static switch_api_interface_t logout_api_interface = {
+	/*.interface_name */ "dl_logout",
+	/*.desc */ "DingaLing Logout",
+	/*.function */ dl_logout,
+	/*.next */ NULL
+};
+
+static switch_api_interface_t login_api_interface = {
+	/*.interface_name */ "dl_login",
+	/*.desc */ "DingaLing Login",
+	/*.function */ dl_login,
+	/*.next */ &logout_api_interface
+};
+
+
+
+static const switch_loadable_module_interface_t channel_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &channel_endpoint_interface,
 	/*.timer_interface */ NULL,
 	/*.dialplan_interface */ NULL,
 	/*.codec_interface */ NULL,
-	/*.application_interface */ NULL
+	/*.application_interface */ NULL,
+	/*.api_interface */ &login_api_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!
+   that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
 */
-static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool)
+static switch_status_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) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
-		switch_caller_profile *caller_profile = NULL;
+		switch_channel_t *channel;
+		switch_caller_profile_t *caller_profile = NULL;
 		struct mdl_profile *mdl_profile = NULL;
 		ldl_session_t *dlsession = NULL;
 		char *profile_name;
@@ -970,49 +1111,57 @@
 		char idbuf[1024];
 		char *full_id;
 		char sess_id[11] = "";
-		char workspace[1024];
-
-
-
+		char *dnis = NULL;
+		char workspace[1024] = "";
+		
 		switch_copy_string(workspace, outbound_profile->destination_number, sizeof(workspace));
 		profile_name = workspace;
 		if ((callto = strchr(profile_name, '/'))) {
 			*callto++ = '\0';
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid URL!\n");
-			switch_core_session_destroy(new_session);
+			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_STATUS_GENERR;
 		}
 		
+		if ((dnis = strchr(callto, ':'))) {
+			*dnis++ = '\0';
+		}
 
 		if ((mdl_profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
 			if (!ldl_handle_ready(mdl_profile->handle)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! we are not logged in yet!\n");
-				switch_core_session_destroy(new_session);
+				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return SWITCH_STATUS_GENERR;
 			}
 			if (!(full_id = ldl_handle_probe(mdl_profile->handle, callto, idbuf, sizeof(idbuf)))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Recipient!\n");
-				switch_core_session_destroy(new_session);
+				terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return SWITCH_STATUS_GENERR;
 			}
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown Profile!\n");
-			switch_core_session_destroy(new_session);
+			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_STATUS_GENERR;
 		}
-
+		
+		
 		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));
+			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
+			tech_pvt->flags |= globals.flags;
+			tech_pvt->flags |= mdl_profile->flags;
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
 			tech_pvt->session = *new_session;
 			tech_pvt->codec_index = -1;
 			tech_pvt->local_port = switch_rtp_request_port();
+			tech_pvt->recip = switch_core_session_strdup(*new_session, full_id);
+			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");
-			switch_core_session_destroy(new_session);
+			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_STATUS_GENERR;
 		}
 
@@ -1027,20 +1176,26 @@
 			tech_pvt->caller_profile = caller_profile;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doh! no caller profile\n");
-			switch_core_session_destroy(new_session);
+			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_STATUS_GENERR;
 		}
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		
 		switch_stun_random_string(sess_id, 10, "0123456789");
 
 		ldl_session_create(&dlsession, mdl_profile->handle, sess_id, full_id, mdl_profile->login);
 		tech_pvt->profile = mdl_profile;
 		ldl_session_set_private(dlsession, *new_session);
+		ldl_session_set_value(dlsession, "dnis", dnis);
+		ldl_session_set_value(dlsession, "caller_id_name", outbound_profile->caller_id_name);
+		ldl_session_set_value(dlsession, "caller_id_number", outbound_profile->caller_id_number);
 		tech_pvt->dlsession = dlsession;
-		get_codecs(tech_pvt);
+		if (!get_codecs(tech_pvt)) {
+			terminate_session(new_session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+            return SWITCH_STATUS_GENERR;
+		}
 		//tech_pvt->desc_id = ldl_session_describe(dlsession, NULL, 0, LDL_DESCRIPTION_INITIATE);
 		negotiate_thread_launch(*new_session);
 		return SWITCH_STATUS_SUCCESS;
@@ -1051,7 +1206,7 @@
 
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -1061,8 +1216,28 @@
 
 	load_config();
 
+	if (switch_event_reserve_subclass(DL_EVENT_LOGIN_SUCCESS) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_SUCCESS);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_reserve_subclass(DL_EVENT_LOGIN_FAILURE) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_LOGIN_FAILURE);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_reserve_subclass(DL_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_MESSAGE);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_reserve_subclass(DL_EVENT_CONNECTED) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!", DL_EVENT_CONNECTED);
+		return SWITCH_STATUS_GENERR;
+	}
+
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &channel_module_interface;
+	*module_interface = &channel_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
@@ -1075,7 +1250,8 @@
 	}
 	return LDL_STATUS_SUCCESS;
 }
-static void init_profile(struct mdl_profile *profile)
+
+static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
 {
 	if (profile &&
 		profile->login &&
@@ -1087,27 +1263,56 @@
 		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");			
+		}
 
-		if (ldl_handle_init(&handle,
-							profile->login,
-							profile->password,
-							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);
+		if (login) {
+			if (ldl_handle_init(&handle,
+								profile->login,
+								profile->password,
+								profile->server,
+								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);
+				handle_thread_launch(handle);
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created Profile for %s@%s\n", profile->login, profile->dialplan);
 			switch_core_hash_insert(globals.profile_hash, profile->name, profile);
-			handle_thread_launch(handle);
-		} 
+		}
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid Profile\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+						  "Invalid Profile\n"
+						  "login[%s]\n"
+						  "pass[%s]\n"
+						  "dialplan[%s]\n"
+						  "message[%s]\n"
+						  "rtp-ip[%s]\n"
+						  "name[%s]\n"
+						  "exten[%s]\n",
+						  profile->login,
+						  profile->password,
+						  profile->dialplan,
+						  profile->message,
+						  profile->ip,
+						  profile->name,
+						  profile->exten);
+
+		return SWITCH_STATUS_FALSE;
 	}
+
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	if (globals.running) {
 		int x = 0;
@@ -1119,85 +1324,210 @@
 				break;
 			}
 		}
-		ldl_global_destroy();
+		if (globals.init) {
+			ldl_global_destroy();
+		}
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status load_config(void)
+static void set_profile_val(struct mdl_profile *profile, char *var, char *val)
 {
-	switch_config cfg;
-	char *var, *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);
+	} else if (!strcasecmp(var, "dialplan")) {
+		profile->dialplan = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "name")) {
+		profile->name = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "message")) {
+		profile->message = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "rtp-ip")) {
+		profile->ip = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "ext-rtp-ip")) {
+		profile->extip = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "server")) {
+		profile->server = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "rtp-timer-name")) {
+		profile->timer_name = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "lanaddr")) {
+		profile->lanaddr = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "tls")) {
+		if (switch_true(val)) {
+			profile->user_flags |= LDL_FLAG_TLS;
+		}
+	} else if (!strcasecmp(var, "sasl")) {
+		if (!strcasecmp(val, "plain")) {
+			profile->user_flags |= LDL_FLAG_SASL_PLAIN;
+		} else if (!strcasecmp(val, "md5")) {
+			profile->user_flags |= LDL_FLAG_SASL_MD5;
+		}
+	} else if (!strcasecmp(var, "exten")) {
+		profile->exten = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "context")) {
+		profile->context = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "auto-login")) {
+		if (switch_true(val)) {
+			switch_set_flag(profile, TFLAG_AUTO);
+		}
+	} else if (!strcasecmp(var, "vad")) {
+		if (!strcasecmp(val, "in")) {
+			switch_set_flag(profile, TFLAG_VAD_IN);
+		} else if (!strcasecmp(val, "out")) {
+			switch_set_flag(profile, TFLAG_VAD_OUT);
+		} else if (!strcasecmp(val, "both")) {
+			switch_set_flag(profile, TFLAG_VAD_IN);
+			switch_set_flag(profile, TFLAG_VAD_OUT);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
+		}
+	}
+}
+
+static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	struct mdl_profile *profile;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!profile_name) {
+		stream->write_function(stream, "NO PROFILE NAME SPECIFIED\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
+		ldl_handle_stop(profile->handle);
+		stream->write_function(stream, "OK\n");
+	} else {
+		stream->write_function(stream, "NO SUCH PROFILE %s\n", profile_name);
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	char *argv[10] = {0};
+	int argc = 0;
+	char *var, *val, *myarg;
+	struct mdl_profile *profile = NULL;
+	int x;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (switch_strlen_zero(arg)) {
+		stream->write_function(stream, "FAIL\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	myarg = strdup(arg);
+
+	argc = switch_separate_string(myarg, ';', argv, (sizeof(argv) / sizeof(argv[0])));
+
+	if (!strncasecmp(argv[0], "profile=", 8)) {
+		char *profile_name = argv[0] + 8;
+		profile = switch_core_hash_find(globals.profile_hash, profile_name);
+
+		if (profile) {
+			if (switch_test_flag(profile, TFLAG_IO)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile already exists.");
+				stream->write_function(stream, "Profile already exists\n");
+				return SWITCH_STATUS_SUCCESS;
+			}
+
+		}
+	} else {
+		profile = switch_core_alloc(module_pool, sizeof(*profile));
+
+		for(x = 0; x < argc; x++) {
+			var = argv[x];
+			if ((val = strchr(var, '='))) {
+				*val++ = '\0';
+				set_profile_val(profile, var, val);
+			}
+		}
+	}
+	
+	if (profile && init_profile(profile, 1) == SWITCH_STATUS_SUCCESS) {
+		stream->write_function(stream, "OK\n");
+	} else {
+		stream->write_function(stream, "FAIL\n");
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+
+}
+
+static switch_status_t load_config(void)
+{
 	char *cf = "dingaling.conf";
 	struct mdl_profile *profile = NULL;
-	int lastcat = -1;
+	switch_xml_t cfg, xml, settings, param, xmlint;
 
 	memset(&globals, 0, sizeof(globals));
 	globals.running = 1;
 
+
 	switch_core_hash_init(&globals.profile_hash, module_pool);	
-	if (!switch_config_open_file(&cfg, cf)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "open of %s failed\n", cf);
+
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
-			if (!strcmp(var, "debug")) {
+	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, "debug")) {
 				globals.debug = atoi(val);
-			} else if (!strcmp(var, "codec_prefs")) {
+			} 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);
-			} else if (!strcmp(var, "codec_rates")) {
+			} 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);
 			}
-		} else if (!strcasecmp(cfg.category, "interface")) {
+		}
+	}
+	
+	for (xmlint = switch_xml_child(cfg, "interface"); xmlint; xmlint = xmlint->next) {
+		for (param = switch_xml_child(xmlint, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+
 			if (!globals.init) {
 				ldl_global_init(globals.debug);
 				ldl_global_set_logger(dl_logger);
 				globals.init = 1;
 			}
 
-			if (cfg.catno != lastcat) {
-				if (profile) {
-					init_profile(profile);
-					profile = NULL;
-				}
-				lastcat = cfg.catno;
-			}
-
 			if(!profile) {
 				profile = switch_core_alloc(module_pool, sizeof(*profile));
 			}
+			set_profile_val(profile, var, val);
+		}
 
-			if (!strcmp(var, "login")) {
-				profile->login = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "password")) {
-				profile->password = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "dialplan")) {
-				profile->dialplan = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "name")) {
-				profile->name = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "message")) {
-				profile->message = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "ip")) {
-				profile->ip = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "extip")) {
-				profile->extip = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "lanaddr")) {
-				profile->lanaddr = switch_core_strdup(module_pool, val);
-			} else if (!strcmp(var, "exten")) {
-				profile->exten = switch_core_strdup(module_pool, val);
-			}
+		if (profile) {
+			init_profile(profile, switch_test_flag(profile, TFLAG_AUTO) ? 1 : 0);
+			profile = NULL;
 		}
 	}
 
 	if (profile) {
-		init_profile(profile);
+		init_profile(profile, switch_test_flag(profile, TFLAG_AUTO) ? 1 : 0);
 		profile = NULL;
 	}
 
@@ -1205,112 +1535,176 @@
 		set_global_dialplan("default");
 	}
 
-	switch_config_close_file(&cfg);
+	if (!globals.init) {
+		ldl_global_init(globals.debug);
+		ldl_global_set_logger(dl_logger);
+		globals.init = 1;
+	}
+
+
+	switch_xml_free(xml);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
 
-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *msg)
+static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *from, char *subject, char *msg)
 {
 	struct mdl_profile *profile = NULL;
-	switch_core_session *session = NULL;
-	switch_channel *channel = NULL;
+	switch_core_session_t *session = NULL;
+	switch_channel_t *channel = NULL;
     struct private_object *tech_pvt = NULL;
-	char *advip;
-
-	assert(dlsession != NULL);
+	switch_event_t *event;
+	ldl_status status = LDL_STATUS_SUCCESS;
+	
 	assert(handle != NULL);
 
 	if (!(profile = ldl_handle_get_private(handle))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR NO PROFILE!\n");
-		return LDL_STATUS_FALSE;
+		status = LDL_STATUS_FALSE;
+		goto done;
 	}
 
+	if (!dlsession) {
+		switch(signal) {
+		case LDL_SIGNAL_MSG:
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", from);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "subject", subject);
+				switch_event_add_body(event, msg);
+				switch_event_fire(&event);
+			}
+			break;
+		case LDL_SIGNAL_LOGIN_SUCCESS:
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+				switch_event_fire(&event);
+			}
+			break;
+		case LDL_SIGNAL_LOGIN_FAILURE:
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_FAILURE) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+				switch_event_fire(&event);
+			}
+			break;
+		case LDL_SIGNAL_CONNECTED:
+			if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_CONNECTED) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+				switch_event_fire(&event);
+			}
+			break;
+		default:
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR\n");
+			break;
+			
+		}
+		status = LDL_STATUS_SUCCESS;
+		goto done;
+	}
+	
+
 	if ((session = ldl_session_get_private(dlsession))) {
 		tech_pvt = switch_core_session_get_private(session);
 		assert(tech_pvt != NULL);
 
 		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) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call %s is already over\n", switch_channel_get_name(channel));
-			return LDL_STATUS_FALSE;
+			status = LDL_STATUS_FALSE;
+			goto done;
 		}
 
 	} else {
 		if (signal != LDL_SIGNAL_INITIATE) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n");
-			return LDL_STATUS_FALSE;
+			status = LDL_STATUS_FALSE;
+			goto done;
 		}
 		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));
+				tech_pvt->flags |= globals.flags;
+				tech_pvt->flags |= profile->flags;
 				channel = switch_core_session_get_channel(session);
 				switch_core_session_set_private(session, tech_pvt);
 				tech_pvt->session = session;
 				tech_pvt->codec_index = -1;
 				tech_pvt->profile = profile;
 				tech_pvt->local_port = switch_rtp_request_port();
-				switch_set_flag(tech_pvt, TFLAG_ANSWER);
+				switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
+				tech_pvt->recip = switch_core_session_strdup(session, from);
+				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");
-				switch_core_session_destroy(&session);
-				return LDL_STATUS_FALSE;
+				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				status = LDL_STATUS_FALSE;
+				goto done;
 			}
 
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
-		
-			if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-																	  profile->dialplan,
-																	  ldl_session_get_caller(dlsession),
-																	  ldl_session_get_caller(dlsession),
-																	  ldl_session_get_ip(dlsession),
-																	  NULL,
-																	  NULL,
-																	  profile->exten)) != 0) {
-				char name[128];
-				snprintf(name, sizeof(name), "DingaLing/%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);
 
-			}
-		
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
 			ldl_session_set_private(dlsession, session);
 			tech_pvt->dlsession = dlsession;
 			negotiate_thread_launch(session);
+		} else {
+			status = LDL_STATUS_FALSE;
+			goto done;
 		}
+
 	}
-	
-	advip = profile->extip ? profile->extip : profile->ip;
 
 	switch(signal) {
-	case LDL_SIGNAL_NONE:
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR\n");
-		break;
 	case LDL_SIGNAL_MSG:
 		if (msg) { 
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MSG [%s]\n", msg);
 			if (*msg == '+') {
 				switch_channel_queue_dtmf(channel, msg + 1);
+				switch_set_flag_locked(tech_pvt, TFLAG_DTMF);
+				if (switch_rtp_ready(tech_pvt->rtp_session)) {
+					switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
+				}
 			}
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SESSION MSG [%s]\n", msg);
 		}
 
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", profile->login);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", from);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "subject", subject);
+			switch_event_add_body(event, msg);
+
+			if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
+				switch_event_fire(&event);
+			}
+
+		}
 		break;
+	case LDL_SIGNAL_TRANSPORT_ACCEPT:
+		switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
+		break;
 	case LDL_SIGNAL_INITIATE:
 		if (signal) {
 			ldl_payload_t *payloads;
 			unsigned int len = 0;
+			int match = 0;
 
 			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 				if (!strcasecmp(msg, "accept")) {
-					switch_set_flag(tech_pvt, TFLAG_ANSWER);
-					do_candidates(tech_pvt, 0);
+					switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
+					if (!do_candidates(tech_pvt, 0)) {
+						terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						status = LDL_STATUS_FALSE;
+						goto done;
+					}
 				}
 			}
 
@@ -1319,11 +1713,11 @@
 				break;
 			}
 
-			if (!tech_pvt->num_codecs) {
-				get_codecs(tech_pvt);
-				if (!tech_pvt->num_codecs) {
-					return LDL_STATUS_FALSE;
-				}
+
+			if (!get_codecs(tech_pvt)) {
+				terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+				status = LDL_STATUS_FALSE;
+				goto done;
 			}
 
 			
@@ -1333,18 +1727,44 @@
 				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++) {
-						if (payloads[x].id == tech_pvt->codecs[y]->ianacode) {
+						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 to %s %d\n", payloads[x].name, payloads[x].id, name, tech_pvt->codecs[y]->ianacode);
+						if (tech_pvt->codecs[y]->ianacode > 96) {
+							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);
 							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->codec_rate = payloads[x].rate;
 							if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-								do_describe(tech_pvt, 0);
+								if (!do_describe(tech_pvt, 0)) {
+									terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+									status = LDL_STATUS_FALSE;
+									goto done;
+								}
 							}
-							return LDL_STATUS_SUCCESS;
+							status = LDL_STATUS_SUCCESS;
+							goto done;
 						}
 					}
 				}
+				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);
+						status = LDL_STATUS_FALSE;
+						goto done;
+					}
+				}
 			}
 		}
 
@@ -1366,9 +1786,16 @@
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
 				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 && !strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr))) ||
+						((profile->lanaddr && lanaddr) ||
 						 (strncasecmp(candidates[x].address, "10.", 3) && 
 						  strncasecmp(candidates[x].address, "192.168.", 8) &&
 						  strncasecmp(candidates[x].address, "127.", 4) &&
@@ -1383,28 +1810,88 @@
 						  strncasecmp(candidates[x].address, "172.31.", 7)
 						  ))) {
 						ldl_payload_t payloads[5];
+						char *exten;
+						char *context;
+						char *cid_name;
+						char *cid_num;
 
 						memset(payloads, 0, sizeof(payloads));
 
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Acceptable Candidate %s:%d\n", candidates[x].address, candidates[x].port);
-						
-						if (!tech_pvt->num_codecs) {
-							get_codecs(tech_pvt);
-							if (!tech_pvt->num_codecs) {
-								return LDL_STATUS_FALSE;
+
+						if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+							ldl_session_accept_candidate(dlsession, &candidates[x]);
+						}
+
+						if (!(exten = ldl_session_get_value(dlsession, "dnis"))) {
+							exten = profile->exten;
+						}
+			
+						if (!(context = ldl_session_get_value(dlsession, "context"))) {
+							context = profile->context;
+						}
+
+						if (!(cid_name = ldl_session_get_value(dlsession, "caller_id_name"))) {
+							cid_name = tech_pvt->recip;
+						}
+
+						if (!(cid_num = ldl_session_get_value(dlsession, "caller_id_number"))) {
+							cid_num = tech_pvt->recip;
+						}
+			
+						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);
+			
+							if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																					  profile->login,
+																					  profile->dialplan,
+																					  cid_name,
+																					  cid_num,
+																					  ldl_session_get_ip(dlsession),
+																					  ldl_session_get_value(dlsession, "ani"),
+																					  ldl_session_get_value(dlsession, "ani2"),
+																					  ldl_session_get_value(dlsession, "rdnis"),
+																					  (char *)modname,
+																					  context,
+																					  exten)) != 0) {
+								char name[128];
+								snprintf(name, sizeof(name), "DingaLing/%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 (lanaddr) {
+							switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
+						}
+
+						if (!get_codecs(tech_pvt)) {
+							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)) {
-							do_candidates(tech_pvt, 0);
+							if (!do_candidates(tech_pvt, 0)) {
+								terminate_session(&session,  __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+								status = LDL_STATUS_FALSE;
+								goto done;
+							}
 						}
-						switch_set_flag(tech_pvt, TFLAG_TRANSPORT);
+				
 						
-						return LDL_STATUS_SUCCESS;
+						switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
+						
+						status = LDL_STATUS_SUCCESS;
+						goto done;
 					}
 				}
 			}
@@ -1413,24 +1900,27 @@
 	case LDL_SIGNAL_ERROR:
 	case LDL_SIGNAL_TERMINATE:
 		if (channel) {
-			switch_channel_state state = switch_channel_get_state(channel);
+			switch_channel_state_t state = switch_channel_get_state(channel);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hungup %s %u %d\n", switch_channel_get_name(channel), state, CS_INIT);
+			switch_mutex_lock(tech_pvt->flag_mutex);
+			switch_set_flag(tech_pvt, TFLAG_TERM);
 			switch_set_flag(tech_pvt, TFLAG_BYE);
 			switch_clear_flag(tech_pvt, TFLAG_IO);
-			switch_channel_hangup(channel);
-
-			if (state <= CS_INIT && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy unused Session\n");
-				switch_core_session_destroy(&session);
-			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call\n");
-			}
-
+			switch_mutex_unlock(tech_pvt->flag_mutex);
+			terminate_session(&session,  __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "End Call\n");
+			goto done;
 		}
 		break;
+
+	default:
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR\n");
+		break;
 	}
 
-	return LDL_STATUS_SUCCESS;
+ done:
+	
+	return status;
 }
 
 static ldl_status handle_response(ldl_handle_t *handle, char *id)

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_dingaling/mod_dingaling.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Dingaling Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,12 +65,12 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/NODEFAULTLIB:LIMBCTD"
-				AdditionalDependencies="libdingaling.lib Ws2_32.lib iksemel.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dingaling.dll"
-				LinkIncremental="2"
+				AdditionalDependencies="Ws2_32.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libdingaling\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\w32\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_dingaling.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_dingaling.lib"
 				TargetMachine="1"
@@ -102,15 +102,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Dingaling Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -146,11 +146,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="libdingaling.lib Ws2_32.lib iksemel.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dingaling.dll"
+				AdditionalDependencies="Ws2_32.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libdingaling\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\w32\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/Makefile	Fri Sep 22 14:22:15 2006
@@ -2,7 +2,7 @@
 LDFLAGS += -leXosip2
 OBJS=osip_rfc3264.o
 ifeq ($(OSARCH),Darwin)
-	LINKER=g++
+	LINKER=$(CC)
 else
 	LINKER=$(CC)
 endif
@@ -11,8 +11,8 @@
 
 depends:
 	#MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install jrtplib --prefix=$(PREFIX) --disable-gst
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libosip2-2.2.2.tar.gz --prefix=$(PREFIX)
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libeXosip2-2.2.3-pre1.tar.gz  --disable-josua --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libosip2-2.2.3.tar.gz --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libeXosip2-2.2.3.tar.gz  --disable-josua --prefix=$(PREFIX)
 
 
 %.o:  %.c

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.c	Fri Sep 22 14:22:15 2006
@@ -30,18 +30,23 @@
  *
  */
 
+
+
+#define MY_EVENT_REGISTER "exosip::register"
+#define MY_EVENT_EXPIRE "exosip::expire"
+
 #define HAVE_APR
 #include <switch.h>
 #include <eXosip2/eXosip.h>
 #include <osip2/osip_mt.h>
 #include <osip_rfc3264.h>
 #include <osipparser2/osip_port.h>
+#define DBFILE "exosip"
 
-
 static const char modname[] = "mod_exosip";
 #define STRLEN 15
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 
 
@@ -67,47 +72,63 @@
 	TFLAG_BYE = (1 << 8),
 	TFLAG_ANS = (1 << 9),
 	TFLAG_EARLY_MEDIA = (1 << 10),
-	TFLAG_SECURE = (1 << 11)
-	
+	TFLAG_SECURE = (1 << 11),
+	TFLAG_VAD_IN = ( 1 << 12),
+	TFLAG_VAD_OUT = ( 1 << 13),
+	TFLAG_VAD = ( 1 << 14),
+	TFLAG_TIMER = ( 1 << 15),
+	TFLAG_AA = (1 << 16),
+	TFLAG_PRE_ANSWER = (1 << 17),
+	TFLAG_REINVITE = (1 << 18)
 } TFLAGS;
 
 
 #define PACKET_LEN 160
 #define DEFAULT_BYTES_PER_FRAME 160
 
+struct reg_element {
+	char *key;
+	char *url;
+	switch_time_t expires;
+	int tid;
+};
+
 static struct {
 	int debug;
 	int bytes_per_frame;
 	char *dialplan;
-	char *extip;
-	char *ip;
+	char *extrtpip;
+	char *rtpip;
+	char *sipip;
 	int port;
 	char *codec_string;
 	char *codec_order[SWITCH_MAX_CODECS];
 	int codec_order_last;
-	switch_hash *call_hash;
-	switch_hash *srtp_hash;
+	switch_hash_t *call_hash;
+	switch_hash_t *srtp_hash;
 	int running;
 	int codec_ms;
 	int dtmf_duration;
 	unsigned int flags;
+	switch_mutex_t *reg_mutex;
+	switch_core_db_t *db;
+	switch_payload_t te;
 } globals;
 
 struct private_object {
 	unsigned int flags;
-	switch_core_session *session;
-	switch_frame read_frame;
-	switch_codec read_codec;
-	switch_codec write_codec;
-	switch_caller_profile *caller_profile;
+	switch_core_session_t *session;
+	switch_frame_t read_frame;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
+	switch_caller_profile_t *caller_profile;
 	int cid;
 	int did;
 	int tid;
 	int32_t timestamp_send;
 	int32_t timestamp_recv;
-	int32_t timestamp_dtmf;
 	int payload_num;
-	struct switch_rtp *rtp_session;
+	switch_rtp_t *rtp_session;
 	struct osip_rfc3264 *sdp_config;
 	sdp_message_t *remote_sdp;
 	sdp_message_t *local_sdp;
@@ -117,47 +138,73 @@
 	switch_port_t local_sdp_audio_port;
 	char call_id[50];
 	int ssrc;
-	char last_digit;
-	unsigned int dc;
-	time_t last_digit_time;
-	switch_queue_t *dtmf_queue;
-	char out_digit;
 	switch_time_t last_read;
-	unsigned char out_digit_packet[4];
-	unsigned int out_digit_sofar;
-	unsigned int out_digit_dur;
-	uint16_t out_digit_seq;
 	char *realm;
+	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
+	int num_codecs;
+	switch_payload_t te;
+	switch_mutex_t *flag_mutex;
 };
 
 
-struct rfc2833_digit {
-	char digit;
-	int duration;
-};
 
+static char create_interfaces_sql[] =
+"CREATE TABLE sip_registrations (\n"
+"   key             VARCHAR(255),\n"
+"   host            VARCHAR(255),\n"
+"   url             VARCHAR(255),\n"
+"   expires         INTEGER(8)"
+");\n";
+
+
+
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_extip, globals.extip)
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_extrtpip, globals.extrtpip)
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_rtpip, globals.rtpip)
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_sipip, globals.sipip)
 
-static switch_status exosip_on_init(switch_core_session *session);
-static switch_status exosip_on_hangup(switch_core_session *session);
-static switch_status exosip_on_loopback(switch_core_session *session);
-static switch_status exosip_on_transmit(switch_core_session *session);
-static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											 switch_core_session **new_session, switch_memory_pool *pool);
-static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-									   switch_io_flag flags, int stream_id);
-static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										switch_io_flag flags, int stream_id);
+static switch_status_t exosip_on_init(switch_core_session_t *session);
+static switch_status_t exosip_on_hangup(switch_core_session_t *session);
+static switch_status_t exosip_on_loopback(switch_core_session_t *session);
+static switch_status_t exosip_on_transmit(switch_core_session_t *session);
+static switch_status_t exosip_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 exosip_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 exosip_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
+										switch_io_flag_t flags, int stream_id);
 static int config_exosip(int reload);
-static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **drate, char **dpayload);
-static switch_status exosip_kill_channel(switch_core_session *session, int sig);
-static switch_status activate_rtp(struct private_object *tech_pvt);
+static switch_status_t parse_sdp_media(struct private_object *tech_pvt,
+									   sdp_media_t * media,
+									   char **dname,
+									   char **drate,
+									   char **dpayload,
+									   const switch_codec_implementation_t **impp);
+
+static switch_status_t exosip_kill_channel(switch_core_session_t *session, int sig);
+static switch_status_t activate_rtp(struct private_object *tech_pvt);
 static void deactivate_rtp(struct private_object *tech_pvt);
-static void sdp_add_rfc2833(struct osip_rfc3264 *cnf, int rate);
 
+static void tech_set_codecs(struct private_object *tech_pvt)
+{
+	if (tech_pvt->num_codecs) {
+		return;
+	}
+
+	if (globals.codec_string) {
+		tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
+																		SWITCH_MAX_CODECS,
+																		globals.codec_order,
+																		globals.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]));
+	}
+}
+
+
 static struct private_object *get_pvt_by_call_id(int id)
 {
 	char name[50];
@@ -169,7 +216,7 @@
 	return tech_pvt;
 }
 
-static switch_status exosip_on_execute(switch_core_session *session)
+static switch_status_t exosip_on_execute(switch_core_session_t *session)
 {
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -219,10 +266,10 @@
 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 exosip_on_init(switch_core_session *session)
+static switch_status_t exosip_on_init(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	char from_uri[512] = "", port[7] = "", *buf = NULL, tmp[512] = "";
 	osip_message_t *invite = NULL;
 
@@ -240,8 +287,8 @@
 		char *dest_uri;
 		char *ip, *err;
 		switch_port_t sdp_port;
-		switch_codec_interface *codecs[SWITCH_MAX_CODECS];
-		int num_codecs = 0;
+		char dbuf[256];
+
 		/* do SIP Goodies... */
 
 		/* Decide on local IP and rtp port */
@@ -250,21 +297,21 @@
 		/* Generate callerid URI */
 
 
-		if (!strcasecmp(globals.ip, "guess")) {
+		if (!strcasecmp(globals.rtpip, "guess")) {
 			eXosip_guess_localip(AF_INET, tech_pvt->local_sdp_audio_ip, sizeof(tech_pvt->local_sdp_audio_ip));
 		} else {
-			switch_copy_string(tech_pvt->local_sdp_audio_ip, globals.ip, sizeof(tech_pvt->local_sdp_audio_ip));
+			switch_copy_string(tech_pvt->local_sdp_audio_ip, globals.rtpip, sizeof(tech_pvt->local_sdp_audio_ip));
 		}
 
 		ip = tech_pvt->local_sdp_audio_ip;
 
-		if (globals.extip) {
-			if (!strncasecmp(globals.extip, "stun:", 5)) {
-				char *stun_ip = globals.extip + 5;
+		if (globals.extrtpip) {
+			if (!strncasecmp(globals.extrtpip, "stun:", 5)) {
+				char *stun_ip = globals.extrtpip + 5;
 
 				if (!stun_ip) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
-					switch_channel_hangup(channel);
+					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return SWITCH_STATUS_FALSE;
 				}
 				if (switch_stun_lookup(&ip,
@@ -274,12 +321,12 @@
 									   &err,
 									   switch_core_session_get_pool(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_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return SWITCH_STATUS_FALSE;
 				}
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", ip, sdp_port);
 			} else {
-				ip = globals.extip;
+				ip = globals.extrtpip;
 			}
 		}
 		snprintf(from_uri, sizeof(from_uri), "%s <sip:%s@%s>", 
@@ -301,42 +348,48 @@
 		snprintf(port, sizeof(port), "%i", sdp_port);
 		sdp_message_m_media_add(tech_pvt->local_sdp, "audio", port, NULL, "RTP/AVP");
 		/* Add in every codec we support on this outbound call */
-		if (globals.codec_string) {
-			num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
-																  SWITCH_MAX_CODECS,
-																  globals.codec_order,
-																  globals.codec_order_last);
-			
-		} else {
-			num_codecs =
-				switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
-												  sizeof(codecs) / sizeof(codecs[0]));
-		}
+		tech_set_codecs(tech_pvt);
+
+
+
 		
+		if (tech_pvt->num_codecs > 0) {
+			int i, lastcode = -1;
 
-		if (num_codecs > 0) {
-			int i;
-			static const switch_codec_implementation *imp;
-			for (i = 0; i < num_codecs; i++) {
-				int x = 0;
+			static const switch_codec_implementation_t *imp;
 
-				snprintf(tmp, sizeof(tmp), "%u", codecs[i]->ianacode);
-				sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
-				for (imp = codecs[i]->implementations; imp; imp = imp->next) {
+			for (i = 0; i < tech_pvt->num_codecs; i++) {
+				imp = tech_pvt->codecs[i];
+
+				if (imp) {
+					uint32_t sps = imp->samples_per_second;
+
+					if (lastcode != imp->ianacode) {
+						snprintf(tmp, sizeof(tmp), "%u", imp->ianacode);
+						sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
+						lastcode = imp->ianacode;
+					}
+
 					/* Add to SDP config */
-					sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
-								  imp->samples_per_second, x++);
-					/* Add to SDP message */
+					sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, imp->ianacode, imp->iananame, sps, 0);
 
-					snprintf(tmp, sizeof(tmp), "%u %s/%d", codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second);
+					/* Add to SDP message */
+					snprintf(tmp, sizeof(tmp), "%u %s/%d", imp->ianacode, imp->iananame, sps);
 					sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(tmp));
 					memset(tmp, 0, sizeof(tmp));
 				} 
 			}
 		}
 
-		sdp_add_rfc2833(tech_pvt->sdp_config, 8000);
 
+		sprintf(dbuf, "%u", tech_pvt->te);
+		sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
+		sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
+		sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
+		sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
+		sprintf(dbuf, "%u 0-15", tech_pvt->te);
+		sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "fmtp", osip_strdup(dbuf));
+
 		/* Setup our INVITE */
 		eXosip_lock();
 		if ((dest_uri =
@@ -348,9 +401,11 @@
 		eXosip_call_build_initial_invite(&invite, dest_uri, from_uri, NULL, NULL);
 		osip_message_set_supported(invite, "100rel, replaces");
 		/* Add SDP to the INVITE */
+
 		sdp_message_to_str(tech_pvt->local_sdp, &buf);
 		osip_message_set_body(invite, buf, strlen(buf));
 		osip_message_set_content_type(invite, "application/sdp");
+		
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OUTBOUND SDP:\n%s\n", buf);
 		free(buf);
 		/* Send the INVITE */
@@ -366,16 +421,16 @@
 	}
 
 	/* Let Media Work */
-	switch_set_flag(tech_pvt, TFLAG_IO);
+	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;
 }
 
-static switch_status exosip_on_ring(switch_core_session *session)
+static switch_status_t exosip_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -389,10 +444,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status exosip_on_hangup(switch_core_session *session)
+static switch_status_t exosip_on_hangup(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	int i;
 
 	channel = switch_core_session_get_channel(session);
@@ -402,12 +457,10 @@
 	assert(tech_pvt != NULL);
 
 	deactivate_rtp(tech_pvt);
-
 	eXosip_lock();
 	switch_core_hash_delete(globals.call_hash, tech_pvt->call_id);
-	switch_set_flag(tech_pvt, TFLAG_BYE);
-	switch_clear_flag(tech_pvt, TFLAG_IO);
-
+	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 	i = eXosip_call_terminate(tech_pvt->cid, tech_pvt->did);
 	eXosip_unlock();
 
@@ -416,18 +469,17 @@
 		switch_core_codec_destroy(&tech_pvt->write_codec);
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel),
-						  tech_pvt->cid, tech_pvt->did, i);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel), tech_pvt->cid, tech_pvt->did, i);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status exosip_on_loopback(switch_core_session *session)
+static switch_status_t exosip_on_loopback(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXOSIP LOOPBACK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status exosip_on_transmit(switch_core_session *session)
+static switch_status_t exosip_on_transmit(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXOSIP TRANSMIT\n");
 	return SWITCH_STATUS_SUCCESS;
@@ -438,7 +490,7 @@
 {
 	int loops = 0;//, sock = -1;
 
-	if (tech_pvt->rtp_session) {
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
 		while (loops < 10 && (switch_test_flag(tech_pvt, TFLAG_READING) || switch_test_flag(tech_pvt, TFLAG_WRITING))) {
 			switch_yield(10000);
 			loops++;
@@ -453,22 +505,26 @@
 	}
 }
 
-static switch_status activate_rtp(struct private_object *tech_pvt)
+static switch_status_t activate_rtp(struct private_object *tech_pvt)
 {
 	int bw, ms;
-	switch_channel *channel;
+	switch_channel_t *channel;
 	const char *err;
 	char *key = NULL;
+	switch_rtp_flag_t flags;
 
 	assert(tech_pvt != NULL);
 
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
 
-	if (tech_pvt->rtp_session) {
+
+	if (tech_pvt->rtp_session && !switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
+
+
 	if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
 		bw = tech_pvt->read_codec.implementation->bits_per_second;
 		ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
@@ -478,54 +534,94 @@
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activating RTP %s:%d->%s:%d codec: %u ms: %d\n",
-						  tech_pvt->local_sdp_audio_ip,
-						  tech_pvt->local_sdp_audio_port,
-						  tech_pvt->remote_sdp_audio_ip,
-						  tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.codec_interface->ianacode, ms);
+					  tech_pvt->local_sdp_audio_ip,
+					  tech_pvt->local_sdp_audio_port,
+					  tech_pvt->remote_sdp_audio_ip,
+					  tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.implementation->ianacode, ms);
 
 
 	if (tech_pvt->realm) {
 		if (!(key = (char *) switch_core_hash_find(globals.srtp_hash, tech_pvt->realm))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "undefined Realm %s\n", tech_pvt->realm);
-			switch_channel_hangup(channel);
-			switch_set_flag(tech_pvt, TFLAG_BYE);
-			switch_clear_flag(tech_pvt, TFLAG_IO);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+			switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 			return SWITCH_STATUS_FALSE;
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "using Realm %s\n", tech_pvt->realm);
 		}
 	}
+	flags = SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT;
+	if (switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+		flags |= SWITCH_RTP_FLAG_USE_TIMER;
+	}
 
+	if (switch_test_flag(tech_pvt, TFLAG_AA)) {
+		flags |= SWITCH_RTP_FLAG_AUTOADJ;
+	}
+
+
+	if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
+		switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+		
+		if (switch_rtp_set_remote_address(tech_pvt->rtp_session,
+										  tech_pvt->remote_sdp_audio_ip,
+										  tech_pvt->remote_sdp_audio_port,
+										  &err) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP CHANGING DEST TO: [%s:%d]\n", 
+							  tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
+		}
+		return SWITCH_STATUS_SUCCESS;
+	}
+
 	tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
 										   tech_pvt->local_sdp_audio_port,
 										   tech_pvt->remote_sdp_audio_ip,
 										   tech_pvt->remote_sdp_audio_port,
-										   tech_pvt->read_codec.codec_interface->ianacode,
-										   tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+										   tech_pvt->read_codec.implementation->ianacode,
+										   0, //tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
 										   ms,
-										   SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE,
+										   flags,
 										   key,
+										   "soft",
 										   &err, switch_core_session_get_pool(tech_pvt->session));
 
-	if (tech_pvt->rtp_session) {
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
+		uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
+		uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
+		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
+
 		tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
-		switch_set_flag(tech_pvt, TFLAG_RTP);
+		switch_set_flag_locked(tech_pvt, TFLAG_RTP);
+
+		if (tech_pvt->te > 96) {
+			switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
+		}
+
+		if ((vad_in && inb) || (vad_out && !inb)) {
+			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
+			switch_set_flag_locked(tech_pvt, TFLAG_VAD);
+		}
 	} else {
-		switch_channel *channel = switch_core_session_get_channel(tech_pvt->session);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
-		switch_channel_hangup(channel);
-		switch_set_flag(tech_pvt, TFLAG_BYE);
-		switch_clear_flag(tech_pvt, TFLAG_IO);
+		switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s][%s:%d]\n", err, 
+						  tech_pvt->local_sdp_audio_ip,
+						  tech_pvt->local_sdp_audio_port);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 		return SWITCH_STATUS_FALSE;
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status exosip_answer_channel(switch_core_session *session)
+static switch_status_t exosip_answer_channel(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	assert(session != NULL);
 
@@ -538,7 +634,8 @@
 	if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND) ) {
 		char *buf = NULL;
 		osip_message_t *answer = NULL;
-
+		char *sdp_str;
+		
 		/* Transmit 200 OK with SDP */
 		eXosip_lock();
 		eXosip_call_build_answer(tech_pvt->tid, 200, &answer);
@@ -548,7 +645,14 @@
 		free(buf);
 		eXosip_call_send_answer(tech_pvt->tid, 200, answer);
 		eXosip_unlock();
-		switch_set_flag(tech_pvt, TFLAG_ANS);
+		switch_set_flag_locked(tech_pvt, TFLAG_ANS);
+
+		sdp_message_to_str(tech_pvt->local_sdp, &sdp_str);
+		if (sdp_str) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Answer SDP:\n%s", sdp_str);
+			free(sdp_str);
+		}
+
 	}
 
 
@@ -556,15 +660,13 @@
 }
 
 
-static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-									   switch_io_flag flags, int stream_id)
+static switch_status_t exosip_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;
 	size_t bytes = 0, samples = 0, frames = 0, ms = 0;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	int payload = 0;
-	switch_time_t now, started = switch_time_now();
-	unsigned int elapsed;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -573,7 +675,7 @@
 	assert(tech_pvt != NULL);
 
 	tech_pvt->read_frame.datalen = 0;
-	switch_set_flag(tech_pvt, TFLAG_READING);
+	switch_set_flag_locked(tech_pvt, TFLAG_READING);
 
 	if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
 		bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
@@ -583,15 +685,8 @@
 		assert(0);
 	}
 	
-	if (tech_pvt->last_read) {
-		elapsed = (unsigned int)((switch_time_now() - tech_pvt->last_read) / 1000);
-		if (elapsed > 60000) {
-			return SWITCH_STATUS_TIMEOUT;
-		}
-	}
-
 	if (switch_test_flag(tech_pvt, TFLAG_IO)) {
-		switch_status status;
+		switch_status_t status;
 
 		if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
 			return SWITCH_STATUS_GENERR;
@@ -602,7 +697,6 @@
 
 
 		while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
-			now = switch_time_now();
 			tech_pvt->read_frame.flags = 0;
 
 			status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
@@ -613,45 +707,21 @@
 			payload = tech_pvt->read_frame.payload;
 
 
-			if (timeout > -1) {
-				elapsed = (unsigned int)((switch_time_now() - started) / 1000);
-				if (elapsed >= (unsigned int)timeout) {
-					return SWITCH_STATUS_SUCCESS;
-				}
+			if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
+				char dtmf[128];
+				switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, dtmf, sizeof(dtmf));
+				switch_channel_queue_dtmf(channel, dtmf);
 			}
 
-			/* RFC2833 ... TBD try harder to honor the duration etc.*/
-			if (payload == 101) {
-				unsigned char *packet = tech_pvt->read_frame.data;
-				int end = packet[1]&0x80;
-				int duration = (packet[2]<<8) + packet[3];
-				char key = switch_rfc2833_to_char(packet[0]);
 
-				/* SHEESH.... Curse you RFC2833 inventors!!!!*/
-				if ((time(NULL) - tech_pvt->last_digit_time) > 2) {
-					tech_pvt->last_digit = 0;
-					tech_pvt->dc = 0;
-				}
-				if (duration && end) {
-					if (key != tech_pvt->last_digit) {
-						char digit_str[] = {key, 0};
-						time(&tech_pvt->last_digit_time);
-						switch_channel_queue_dtmf(channel, digit_str);
-					}
-					if (++tech_pvt->dc >= 3) {
-						tech_pvt->last_digit = 0;
-						tech_pvt->dc = 0;
-					} else {
-						tech_pvt->last_digit = key;
-					}
-				} 
-			}
-
-
 			if (tech_pvt->read_frame.datalen > 0) {
 				tech_pvt->last_read = switch_time_now();
-				bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-				frames = (tech_pvt->read_frame.datalen / bytes);
+				if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+					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;
@@ -659,15 +729,15 @@
 				break;
 			}
 
-			switch_yield(1000);
 		}
 
 	}
 
-	switch_clear_flag(tech_pvt, TFLAG_READING);
 
+	switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+
 	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -677,12 +747,12 @@
 }
 
 
-static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										switch_io_flag flags, int stream_id)
+static switch_status_t exosip_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 *channel = NULL;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	int bytes = 0, samples = 0, frames = 0;
 
 	channel = switch_core_session_get_channel(session);
@@ -700,97 +770,42 @@
 	}
 
 	if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
-	switch_set_flag(tech_pvt, TFLAG_WRITING);
+	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
 	if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
-		bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-		frames = ((int) frame->datalen / bytes);
+		if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+			bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+			frames = ((int) frame->datalen / bytes);
+		} else {
+			frames = 1;
+		}
 		samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 	} else {
 		assert(0);
 	}
 
 
-	if (tech_pvt->out_digit_dur > 0) {
-		int x, ts, loops = 1, duration;
 
-		tech_pvt->out_digit_sofar += samples;
-
-		if (tech_pvt->out_digit_sofar >= tech_pvt->out_digit_dur) {
-			duration = tech_pvt->out_digit_dur;
-			tech_pvt->out_digit_packet[1] |= 0x80;
-			tech_pvt->out_digit_dur = 0;
-			loops = 3;
-		} else {
-			duration = tech_pvt->out_digit_sofar;
-		}
-
-		ts = tech_pvt->timestamp_dtmf += samples;
-		tech_pvt->out_digit_packet[2] = (unsigned char) (duration >> 8);
-		tech_pvt->out_digit_packet[3] = (unsigned char) duration;
-		
-
-		for (x = 0; x < loops; x++) {
-			frame->flags = 0;
-			switch_rtp_write_payload(tech_pvt->rtp_session, tech_pvt->out_digit_packet, 4, 101, ts, tech_pvt->out_digit_seq, &frame->flags);
-			printf("Send %s packet for [%c] ts=%d sofar=%u dur=%d\n", 
-				   loops == 1 ? "middle" : "end",
-				   tech_pvt->out_digit,
-				   ts, 
-				   tech_pvt->out_digit_sofar,
-				   duration);
-		}
-	}
-
-	if (!tech_pvt->out_digit_dur && tech_pvt->dtmf_queue && switch_queue_size(tech_pvt->dtmf_queue)) {
-		void *pop;
-
-		if (switch_queue_trypop(tech_pvt->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-			int x, ts;
-			struct rfc2833_digit *rdigit = pop;
-			
-			memset(tech_pvt->out_digit_packet, 0, 4);
-			tech_pvt->out_digit_sofar = 0;
-			tech_pvt->out_digit_dur = rdigit->duration;
-			tech_pvt->out_digit = rdigit->digit;
-			tech_pvt->out_digit_packet[0] = (unsigned char)switch_char_to_rfc2833(rdigit->digit);
-			tech_pvt->out_digit_packet[1] = 7;
-
-			ts = tech_pvt->timestamp_dtmf += samples;
-			tech_pvt->out_digit_seq++;
-			for (x = 0; x < 3; x++) {
-				frame->flags = 0;
-				switch_rtp_write_payload(tech_pvt->rtp_session, tech_pvt->out_digit_packet, 4, 101, ts, tech_pvt->out_digit_seq, &frame->flags);
-				printf("Send start packet for [%c] ts=%d sofar=%u dur=%d\n", tech_pvt->out_digit, ts, 
-					   tech_pvt->out_digit_sofar, 0);
-			}
-
-			free(rdigit);
-		}
-	}
-
-
-
 	//printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, tech_pvt->timestamp_send);
 
 	switch_rtp_write_frame(tech_pvt->rtp_session, frame, samples);
 	
 	tech_pvt->timestamp_send += (int) samples;
 
-	switch_clear_flag(tech_pvt, TFLAG_WRITING);
+	switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
 	return status;
 }
 
 
 
-static switch_status exosip_kill_channel(switch_core_session *session, int sig)
+static switch_status_t exosip_kill_channel(switch_core_session_t *session, int sig)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -798,10 +813,10 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
-	switch_set_flag(tech_pvt, TFLAG_BYE);
+	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
-	if (tech_pvt->rtp_session) {
+	if (switch_rtp_ready(tech_pvt->rtp_session)) {
 		switch_rtp_kill_socket(tech_pvt->rtp_session);
 	}
 
@@ -809,10 +824,10 @@
 
 }
 
-static switch_status exosip_waitfor_read(switch_core_session *session, int ms, int stream_id)
+static switch_status_t exosip_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -824,10 +839,10 @@
 }
 
 
-static switch_status exosip_waitfor_write(switch_core_session *session, int ms, int stream_id)
+static switch_status_t exosip_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -839,72 +854,84 @@
 
 }
 
-static switch_status exosip_send_dtmf(switch_core_session *session, char *digits)
+static switch_status_t exosip_send_dtmf(switch_core_session_t *session, char *digits)
 {
 	struct private_object *tech_pvt;
-	char *c;
 
 	tech_pvt = switch_core_session_get_private(session);
     assert(tech_pvt != NULL);
 
-	if (!tech_pvt->dtmf_queue) {
-		switch_queue_create(&tech_pvt->dtmf_queue, 100, switch_core_session_get_pool(session));
-	}
-
-	for(c = digits; *c; c++) {
-		struct rfc2833_digit *rdigit;
-
-		if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
-			memset(rdigit, 0, sizeof(*rdigit));
-			rdigit->digit = *c;
-			rdigit->duration = globals.dtmf_duration * (tech_pvt->read_codec.implementation->samples_per_second / 1000);
-			switch_queue_push(tech_pvt->dtmf_queue, rdigit);
-		} else {
-			return SWITCH_STATUS_MEMERR;
-		}
-	}
-
-	return SWITCH_STATUS_SUCCESS;
+	return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
+									digits,
+									globals.dtmf_duration * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
+	
 }
 
-static switch_status exosip_receive_message(switch_core_session *session, switch_core_session_message *msg)
+static switch_status_t exosip_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
+	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, 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");
+	  }
+	  break;
+	case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+	  if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+	    switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+	    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
+	  }
+	  break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
-		if (msg) {
-			struct private_object *tech_pvt;
-			switch_channel *channel = NULL;
-			
-			channel = switch_core_session_get_channel(session);
-			assert(channel != NULL);
+	  if (msg) {
+	    struct private_object *tech_pvt;
+	    switch_channel_t *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 (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
-				char *buf = NULL;
-				osip_message_t *progress = NULL;
+	    if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+	      char *buf = NULL;
+	      osip_message_t *progress = NULL;
 
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
+	      switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
 
-				/* Transmit 183 Progress with SDP */
-				eXosip_lock();
-				eXosip_call_build_answer(tech_pvt->tid, 183, &progress);
-				if (progress) {
-					sdp_message_to_str(tech_pvt->local_sdp, &buf);
-					osip_message_set_body(progress, buf, strlen(buf));
-					osip_message_set_content_type(progress, "application/sdp");
-					free(buf);
-					eXosip_call_send_answer(tech_pvt->tid, 183, progress);
-					switch_set_flag(tech_pvt, TFLAG_EARLY_MEDIA);
-					switch_channel_set_flag(channel, CF_EARLY_MEDIA);
-				}
-				eXosip_unlock();
-			}
-		}
+	      /* Transmit 183 Progress with SDP */
+	      eXosip_lock();
+	      eXosip_call_build_answer(tech_pvt->tid, 183, &progress);
+	      if (progress) {
+			  char *sdp_str;
+			  sdp_message_to_str(tech_pvt->local_sdp, &buf);
+			  osip_message_set_body(progress, buf, strlen(buf));
+			  osip_message_set_content_type(progress, "application/sdp");
+			  free(buf);
+			  eXosip_call_send_answer(tech_pvt->tid, 183, progress);
+			  switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+			  switch_channel_set_flag(channel, CF_EARLY_MEDIA);
+			  sdp_message_to_str(tech_pvt->local_sdp, &sdp_str);
+			  if (sdp_str) {
+				  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Progress SDP:\n%s", sdp_str);
+				  free(sdp_str);
+			  }
+	      }
+	      eXosip_unlock();
+	    }
+	  }
 		
-		break;
+	  break;
 	default:
 		break;
 	}
@@ -912,7 +939,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static const switch_io_routines exosip_io_routines = {
+static const switch_io_routines_t exosip_io_routines = {
 	/*.outgoing_channel */ exosip_outgoing_channel,
 	/*.answer_channel */ exosip_answer_channel,
 	/*.read_frame */ exosip_read_frame,
@@ -924,7 +951,7 @@
 	/*.receive_message*/ exosip_receive_message
 };
 
-static const switch_state_handler_table exosip_event_handlers = {
+static const switch_state_handler_table_t exosip_event_handlers = {
 	/*.on_init */ exosip_on_init,
 	/*.on_ring */ exosip_on_ring,
 	/*.on_execute */ exosip_on_execute,
@@ -933,7 +960,7 @@
 	/*.on_transmit */ exosip_on_transmit
 };
 
-static const switch_endpoint_interface exosip_endpoint_interface = {
+static const switch_endpoint_interface_t exosip_endpoint_interface = {
 	/*.interface_name */ "exosip",
 	/*.io_routines */ &exosip_io_routines,
 	/*.event_handlers */ &exosip_event_handlers,
@@ -941,7 +968,7 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface exosip_module_interface = {
+static const switch_loadable_module_interface_t exosip_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &exosip_endpoint_interface,
 	/*.timer_interface */ NULL,
@@ -950,20 +977,105 @@
 	/*.application_interface */ NULL
 };
 
-static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											 switch_core_session **new_session, switch_memory_pool *pool)
+
+struct callback_t {
+	char *val;
+	switch_size_t len;
+	int matches;
+};
+
+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);
+	cbt->matches++;
+	return 0;
+}
+
+static int del_callback(void *pArg, int argc, char **argv, char **columnNames){
+	switch_event_t *s_event;
+
+	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, "key", "%s", argv[0]);
+			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "url", "%s", argv[1]);
+			switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%d", argv[2]);
+			switch_event_fire(&s_event);
+		}
+	}
+	return 0;
+}
+
+
+static char *find_reg_url(switch_core_db_t *db, char *key, char *val, switch_size_t len)
 {
+	char *errmsg;
+	switch_core_db_t *udb = NULL;
+	struct callback_t cbt = {0};
+	char buf[1024];
+	char *host = NULL;
+
+	if (db) {
+		udb = db;
+	} else {
+		udb = switch_core_db_open_file(DBFILE);
+	}
+
+	switch_copy_string(buf, key, sizeof(buf));
+	key = buf;
+	if ((host = strchr(key, '%'))) {
+		*host++ = '\0';
+	}
+
+	cbt.val = val;
+	cbt.len = len;
+	switch_mutex_lock(globals.reg_mutex);
+	if (host) {
+		snprintf(val, len, "select url from sip_registrations where key='%s' and host='%s'", key, host);	
+	} else {
+		snprintf(val, len, "select url from sip_registrations where key='%s'", key);	
+	}
+
+	switch_core_db_exec(udb, val, find_callback, &cbt, &errmsg);
+
+	if (errmsg) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s][%s]\n", val, errmsg);
+		switch_core_db_free(errmsg);
+		errmsg = NULL;
+	}
+
+	if (!db) {
+		switch_core_db_close(udb);
+	}
+	switch_mutex_unlock(globals.reg_mutex);
+	return cbt.matches ? val : NULL;
+}
+
+static switch_status_t exosip_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 (!outbound_profile->destination_number) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid Destination!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
+
 	if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, pool)) != 0) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
+		switch_channel_t *channel;
 
+
 		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));
+			tech_pvt->flags = globals.flags;
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
 			tech_pvt->session = *new_session;
+			tech_pvt->te = globals.te;
+			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*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);
@@ -972,9 +1084,10 @@
 
 		if (outbound_profile) {
 			char name[128];
-			switch_caller_profile *caller_profile = NULL;
+			switch_caller_profile_t *caller_profile = NULL;
+			char tmp[1024];
+			char *url;
 
-
 			if (*outbound_profile->destination_number == '!') {
 				char *p;
 				
@@ -996,6 +1109,13 @@
 
 			caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
 
+
+			if (!strchr(caller_profile->destination_number, '@') && (url = find_reg_url(NULL, caller_profile->destination_number, tmp, sizeof(tmp)))) {
+				caller_profile->rdnis = switch_core_session_strdup(*new_session, caller_profile->destination_number);
+				caller_profile->destination_number = switch_core_session_strdup(*new_session, url);
+			}
+
+
 			switch_channel_set_caller_profile(channel, caller_profile);
 			tech_pvt->caller_profile = caller_profile;
 		} else {
@@ -1005,7 +1125,7 @@
 		}
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -1014,22 +1134,33 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
+
+
 	if (globals.running) {
 		globals.running = -1;
 		while (globals.running) {
 			switch_yield(100000);
 		}
 	}
+	switch_core_db_close(globals.db);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
+
 	/* NOTE:  **interface is **_interface because the common lib redefines interface to struct in some situations */
 
+	if ((globals.db = switch_core_db_open_file(DBFILE))) {
+		switch_core_db_test_reactive(globals.db, "select * from sip_registrations", create_interfaces_sql);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
+		return SWITCH_STATUS_TERM;
+	}
 
+	
 	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");
 		return SWITCH_STATUS_TERM;
@@ -1037,51 +1168,32 @@
 
 	switch_core_hash_init(&globals.call_hash, module_pool);
 	switch_core_hash_init(&globals.srtp_hash, module_pool);
+	switch_mutex_init(&globals.reg_mutex, SWITCH_MUTEX_NESTED, module_pool);
 
+
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &exosip_module_interface;
+	*module_interface = &exosip_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void sdp_add_rfc2833(struct osip_rfc3264 *cnf, int rate)
+static switch_status_t exosip_create_call(eXosip_event_t * event)
 {
-	sdp_media_t *med = NULL;
-	sdp_attribute_t *attr = NULL;
-	char tmp[128];
-	
-	sdp_media_init(&med);
-	sdp_attribute_init(&attr);
-	attr->a_att_field = osip_strdup("rtpmap");
-	snprintf(tmp, sizeof(tmp), "101 telephony-event/%d", rate);
-	attr->a_att_value = osip_strdup(tmp);
-	osip_list_add(med->a_attributes, attr, -1);
-	
-
-	med->m_media = osip_strdup("telephony-event");
-	osip_rfc3264_add_audio_media(cnf, med, -1);
-
-}
-
-
-static switch_status exosip_create_call(eXosip_event_t * event)
-{
-	switch_core_session *session;
+	switch_core_session_t *session;
 	sdp_message_t *remote_sdp = NULL;
 	sdp_connection_t *conn = NULL;
 	sdp_media_t *remote_med = NULL, *audio_tab[10], *video_tab[10], *t38_tab[10], *app_tab[10];
-	char local_sdp_str[8192] = "", port[8] = "";
+	char local_sdp_str[1024] = "", port[8] = "";
 	int mline = 0, pos = 0;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	char name[128];
-	char *dpayload, *dname = NULL, *drate = NULL;
+	char *dpayload = NULL, *dname = NULL, *drate = NULL;
 	char *remote_sdp_str = NULL;
+	char dbuf[256];
 
 	if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
 		struct private_object *tech_pvt;
-		switch_codec_interface *codecs[SWITCH_MAX_CODECS];
-		int num_codecs = 0;
 		switch_port_t sdp_port;
 		char *ip, *err;
 		osip_uri_t *uri;
@@ -1089,13 +1201,17 @@
 		char *displayname, *username;
 		osip_header_t *tedious;
 		char *val;
+		const switch_codec_implementation_t *imp = NULL;
 
 		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));
+			tech_pvt->flags = globals.flags;
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
 			tech_pvt->session = session;
+			tech_pvt->te = globals.te;
+			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
 			switch_core_session_destroy(&session);
@@ -1104,13 +1220,12 @@
 
 		snprintf(name, sizeof(name), "Exosip/%s-%04x", event->request->from->url->username, rand() & 0xffff);
 		switch_channel_set_name(channel, name);
+		switch_channel_set_variable(channel, "endpoint_disposition", "INVITE");
 
 		if (osip_message_header_get_byname (event->request, "SrtpRealm", 0, &tedious)) {
 			tech_pvt->realm = switch_core_session_strdup(session, osip_header_get_value(tedious));
 		}
 
-
-
 		if (!(from = osip_message_get_from(event->request))) {
 			switch_core_session_destroy(&session);
             return SWITCH_STATUS_MEMERR;
@@ -1118,7 +1233,7 @@
 		if (!(val = osip_from_get_displayname(from))) {
 			val = event->request->from->url->username;
 			if (!val) {
-				val = "n/a";
+				val = "FreeSWITCH";
 			}
 		}
 		
@@ -1140,15 +1255,21 @@
 		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																  username,
 																  globals.dialplan,
 																  displayname,
 																  username,
 																  event->request->from->url->host,
-																  NULL, NULL, event->request->req_uri->username)) != 0) {
+																  NULL,
+																  NULL,
+																  NULL,
+																  (char *)modname,
+																  NULL,
+																  event->request->req_uri->username)) != 0) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
-		switch_set_flag(tech_pvt, TFLAG_INBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_INBOUND);
 		tech_pvt->did = event->did;
 		tech_pvt->cid = event->cid;
 		tech_pvt->tid = event->tid;
@@ -1162,10 +1283,10 @@
 			return SWITCH_STATUS_GENERR;
 		}
 
-		if (!strcasecmp(globals.ip, "guess")) {
+		if (!strcasecmp(globals.rtpip, "guess")) {
 			eXosip_guess_localip(AF_INET, tech_pvt->local_sdp_audio_ip, sizeof(tech_pvt->local_sdp_audio_ip));
 		} else {
-			switch_copy_string(tech_pvt->local_sdp_audio_ip, globals.ip, sizeof(tech_pvt->local_sdp_audio_ip));
+			switch_copy_string(tech_pvt->local_sdp_audio_ip, globals.rtpip, sizeof(tech_pvt->local_sdp_audio_ip));
 		}
 		ip = tech_pvt->local_sdp_audio_ip;
 
@@ -1173,12 +1294,12 @@
 		sdp_port = tech_pvt->local_sdp_audio_port;
 
 
-		if (globals.extip) {
-			if (!strncasecmp(globals.extip, "stun:", 5)) {
-				char *stun_ip = globals.extip + 5;
+		if (globals.extrtpip) {
+			if (!strncasecmp(globals.extrtpip, "stun:", 5)) {
+				char *stun_ip = globals.extrtpip + 5;
 				if (!stun_ip) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
-					switch_channel_hangup(channel);
+					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return SWITCH_STATUS_FALSE;
 				}
 				if (switch_stun_lookup(&ip,
@@ -1188,70 +1309,83 @@
 									   &err,
 									   switch_core_session_get_pool(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_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return SWITCH_STATUS_FALSE;
 				}
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", ip, sdp_port);
 			} else {
-				ip = globals.extip;
+				ip = globals.extrtpip;
 			}
 		}
 		osip_rfc3264_init(&tech_pvt->sdp_config);
+
 		/* Add in what codecs we support locally */
+		tech_set_codecs(tech_pvt);
 
-		if (globals.codec_string) {
-			num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
-																  SWITCH_MAX_CODECS,
-																  globals.codec_order,
-																  globals.codec_order_last);
-			
-		} else {
-			num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
-														   sizeof(codecs) / sizeof(codecs[0]));
-		}
+		sdp_message_init(&tech_pvt->local_sdp);
 
-		if (num_codecs > 0) {
-			int i;
-			static const switch_codec_implementation *imp;
 
 
+		if (tech_pvt->num_codecs > 0) {
+			int i;
+			static const switch_codec_implementation_t *imp = NULL;
 
-			for (i = 0; i < num_codecs; i++) {
-				int x = 0;
+			for (i = 0; i < tech_pvt->num_codecs; i++) {
+				if ((imp = tech_pvt->codecs[i])) {
+					sdp_add_codec(tech_pvt->sdp_config,
+								  tech_pvt->codecs[i]->codec_type,
+								  imp->ianacode,
+								  imp->iananame,
+								  imp->samples_per_second,
+								  0);
 
-				for (imp = codecs[i]->implementations; imp; imp = imp->next) {
-					sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
-								  imp->samples_per_second, x++);
 				}
 			}
 		}
-		sdp_add_rfc2833(tech_pvt->sdp_config, 8000);
+		
 
-		osip_rfc3264_prepare_answer(tech_pvt->sdp_config, remote_sdp, local_sdp_str, 8192);
-		sdp_message_init(&tech_pvt->local_sdp);
+		
+
+		osip_rfc3264_prepare_answer(tech_pvt->sdp_config, remote_sdp, local_sdp_str, sizeof(local_sdp_str));		
+		
 		sdp_message_parse(tech_pvt->local_sdp, local_sdp_str);
 
 		sdp_message_to_str(remote_sdp, &remote_sdp_str);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "LOCAL SDP:\n%s\nREMOTE SDP:\n%s", local_sdp_str, remote_sdp_str);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "REMOTE SDP:\n%s", remote_sdp_str);
 
+
 		mline = 0;
 		while (0 == osip_rfc3264_match(tech_pvt->sdp_config, remote_sdp, audio_tab, video_tab, t38_tab, app_tab, mline)) {
 			if (audio_tab[0] == NULL && video_tab[0] == NULL && t38_tab[0] == NULL && app_tab[0] == NULL) {
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Got no compatible codecs!\n");
-				break;
+				goto done;
 			}
 			for (pos = 0; audio_tab[pos] != NULL; pos++) {
 				osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
 											 mline);
-				if (parse_sdp_media(audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
-					tech_pvt->payload_num = atoi(dpayload);
-					break;
+				if (parse_sdp_media(tech_pvt, audio_tab[pos], &dname, &drate, &dpayload, &imp) == SWITCH_STATUS_SUCCESS) {
+					tech_pvt->payload_num = atoi(dpayload);					
+					goto done;
 				}
 			}
 			mline++;
 		}
+	done:
+
 		free(remote_sdp_str);
+
+
+		sprintf(dbuf, "%u", tech_pvt->te);
+		sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
+		sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
+
+		sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
+		sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
+		sprintf(dbuf, "%u 0-15", tech_pvt->te);
+		sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "fmtp", osip_strdup(dbuf));
+
+
 		sdp_message_o_origin_set(tech_pvt->local_sdp, "FreeSWITCH", "0", "0", "IN", "IP4", ip);
 								 
 		sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
@@ -1281,32 +1415,38 @@
 
 		{
 			int rate = atoi(drate);
+			int ms = 0; //globals.codec_ms;
 
+
+			if (imp) {
+				ms = imp->microseconds_per_frame / 1000;
+			}
+
 			if (switch_core_codec_init(&tech_pvt->read_codec,
 									   dname,
 									   rate,
-									   globals.codec_ms,
+									   ms,
 									   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_ERROR, "Can't load codec?\n");
-				switch_channel_hangup(channel);
+				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return SWITCH_STATUS_FALSE;
 			} else {
 				if (switch_core_codec_init(&tech_pvt->write_codec,
 										   dname,
 										   rate,
-										   globals.codec_ms,
+										   ms,
 										   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_ERROR, "Can't load codec?\n");
-					switch_channel_hangup(channel);
+					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return SWITCH_STATUS_FALSE;
 				} else {
 					int ms;
 					tech_pvt->read_frame.rate = rate;
-					switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
+					switch_set_flag_locked(tech_pvt, TFLAG_USING_CODEC);
 					ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
 					tech_pvt->read_frame.codec = &tech_pvt->read_codec;
@@ -1316,6 +1456,10 @@
 			}
 		}
 
+		switch_safe_free(dname);
+		switch_safe_free(drate);
+		switch_safe_free(dpayload);
+
 		if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
 			exosip_on_hangup(session);
 			switch_core_session_destroy(&session);
@@ -1339,14 +1483,14 @@
 
 }
 
-static void destroy_call_by_event(eXosip_event_t * event)
+static void destroy_call_by_event(eXosip_event_t *event)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
+	switch_call_cause_t cause;
 
 	if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Um in case you are interested, Can't find the pvt [%d]!\n",
-							  event->cid);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot destroy nonexistant call [%d]!\n", event->cid);
 		return;
 	}
 
@@ -1355,43 +1499,113 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy %s\n", switch_channel_get_name(channel));
 	exosip_kill_channel(tech_pvt->session, SWITCH_SIG_KILL);
-	switch_channel_hangup(channel);
 
+
+	switch (event->type) {
+	case EXOSIP_CALL_RELEASED:
+		switch_channel_set_variable(channel, "endpoint_disposition", "RELEASED");
+		cause = SWITCH_CAUSE_NORMAL_CLEARING;
+		break;
+	case EXOSIP_CALL_CLOSED:
+		switch_channel_set_variable(channel, "endpoint_disposition", "CLOSED");
+		cause = SWITCH_CAUSE_NORMAL_CLEARING;
+		break;
+	case EXOSIP_CALL_NOANSWER:
+		switch_channel_set_variable(channel, "endpoint_disposition", "NO ANSWER");
+		cause = SWITCH_CAUSE_NO_ANSWER;
+		break;
+	case EXOSIP_CALL_REQUESTFAILURE:
+		switch_channel_set_variable(channel, "endpoint_disposition", "REQUEST FAILURE");
+		cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
+		break;
+	case EXOSIP_CALL_SERVERFAILURE:
+		switch_channel_set_variable(channel, "endpoint_disposition", "SERVER FAILURE");
+		cause = SWITCH_CAUSE_CALL_REJECTED;
+		break;
+	case EXOSIP_CALL_GLOBALFAILURE:
+		switch_channel_set_variable(channel, "endpoint_disposition", "GLOBAL FAILURE");
+		cause = SWITCH_CAUSE_CALL_REJECTED;
+		break;
+	default:
+		switch_channel_set_variable(channel, "endpoint_disposition", "UNKNOWN");
+		cause = SWITCH_CAUSE_SWITCH_CONGESTION;
+		break;
+	}
+
+	switch_channel_hangup(channel, cause);
+
 }
 
-static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **drate, char **dpayload)
+static switch_status_t parse_sdp_media(struct private_object *tech_pvt,
+									   sdp_media_t * media,
+									   char **dname,
+									   char **drate,
+									   char **dpayload,
+									   const switch_codec_implementation_t **impp)
 {
 	int pos = 0;
 	sdp_attribute_t *attr = NULL;
-	char *name, *rate, *payload;
-	switch_status status = SWITCH_STATUS_GENERR;
+	char *name, *payload, *rate;
+	switch_status_t status = SWITCH_STATUS_GENERR;
+	char workspace[512];
+	const switch_codec_implementation_t *imp = NULL;
 
 	while (osip_list_eol(media->a_attributes, pos) == 0) {
 		attr = (sdp_attribute_t *) osip_list_get(media->a_attributes, pos);
 		if (attr != NULL && strcasecmp(attr->a_att_field, "rtpmap") == 0) {
-			payload = attr->a_att_value;
-			if ((name = strchr(payload, ' ')) != 0) {
-				*(name++) = '\0';
-				/* Name and payload are required */
-				*dpayload = strdup(payload);
-				status = SWITCH_STATUS_SUCCESS;
-				if ((rate = strchr(name, '/')) != 0) {
-					*(rate++) = '\0';
-					*drate = strdup(rate);
-					*dname = strdup(name);
-				} else {
-					*dname = strdup(name);
-					*drate = strdup("8000");
+			switch_payload_t pt;
+			uint32_t r;
+			int32_t i;
+			uint8_t match = 0;
+			name = rate = payload = NULL;
+
+			switch_copy_string(workspace, attr->a_att_value, sizeof(workspace));
+			payload = workspace;
+			if ((name = strchr(workspace, ' ')) != 0) {
+                *(name++) = '\0';
+			}
+			if ((rate = strchr(name, '/'))) {
+				*rate++ = '\0';
+			}
+			pt = (switch_payload_t)atoi(payload);
+			r = atoi(rate);
+			
+			if (!strcasecmp(name, "telephone-event")) {
+				tech_pvt->te = pt;
+				attr = NULL;
+				pos++;
+				continue;
+			}
+
+			for(i = 0; !match && i < tech_pvt->num_codecs; i++) {
+
+				for (imp = tech_pvt->codecs[i]; imp; imp = imp->next) {
+
+					if (pt < 97) {
+						match = (pt == imp->ianacode) ? 1 : 0;
+					} else {
+						match = strcasecmp(name, imp->iananame) ? 0 : 1;
+					}
+					
+					if (match && (r == imp->samples_per_second)) {
+						break;
+					}
 				}
-			} else {
-				*dpayload = strdup("10");
-				*dname = strdup("L16");
-				*drate = strdup("8000");
+				
 			}
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
-								  *dpayload, *dname, *drate);
-			break;
+
+			if (match) {
+				*dname = strdup(name);
+				*drate = strdup(rate);
+				*dpayload = strdup(payload);
+				*impp = imp;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
+								  *dpayload, *dname, *drate);	
+				return SWITCH_STATUS_SUCCESS;
+			}
+
 		}
+
 		attr = NULL;
 		pos++;
 	}
@@ -1399,48 +1613,280 @@
 	return status;
 }
 
-static void handle_answer(eXosip_event_t * event)
+
+static char *get_header_value(eXosip_event_t *je, char *name)
 {
+	osip_header_t *hp = NULL;
+	osip_message_header_get_byname (je->request, name, 0, &hp);
+	
+	return hp ? hp->hvalue : NULL;
+}
+
+
+static void handle_message_new(eXosip_event_t *je)
+{
+	if (MSG_IS_REGISTER(je->request)) {
+		int x = 0;
+		osip_contact_t *contact;
+		osip_uri_t *contact_uri = NULL;
+		char *lame = NULL;
+		char *url;
+		char *expires = NULL;
+		osip_message_t *tmp = NULL;
+		char buf[1024];
+		char *sql = NULL;
+		time_t exptime;
+		switch_event_t *s_event;
+
+		for(;;) {
+			if (osip_message_get_contact(je->request, x++, &contact) < 0) {
+				break;
+			}
+
+			switch_safe_free(lame);
+			osip_contact_to_str((const osip_contact_t *) contact, &lame);
+			contact_uri = osip_contact_get_url(contact);
+
+			if ((url = strchr(lame, ':'))) {
+				char *p;
+				url++;
+				if ((p = strchr(url, '>'))) {
+					*p = '\0';
+				}
+
+
+				if ((expires = get_header_value(je, "expires"))) {
+					exptime = time(NULL) + atoi(expires) + 20;
+				} else {
+					exptime = time(NULL) + 3600;
+				}
+
+				
+				if (!find_reg_url(globals.db, je->request->from->url->username, buf, sizeof(buf))) {
+					sql = switch_core_db_mprintf("insert into sip_registrations values ('%s','%s','%s',%ld)", 
+												 je->request->from->url->username,
+												 je->request->from->url->host,
+												 url, exptime);
+				} else {
+					sql = switch_core_db_mprintf("update sip_registrations set url='%s', expires=%ld where key = '%s'",
+												 url,
+												 exptime,
+												 je->request->from->url->username);
+					
+				}
+
+				if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER) == SWITCH_STATUS_SUCCESS) {
+					switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "key", "%s", je->request->from->url->username);
+					switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "url", "%s", url);
+					switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", exptime);
+					switch_event_fire(&s_event);
+				}
+				if (sql) {
+					switch_mutex_lock(globals.reg_mutex);
+					switch_core_db_persistant_execute(globals.db, sql, 25);
+					switch_core_db_free(sql);
+					sql = NULL;
+					switch_mutex_unlock(globals.reg_mutex);
+				}
+				eXosip_lock();
+				if (eXosip_message_build_answer(je->tid, 200, &tmp) < 0) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "build_answer failed\n");
+					eXosip_unlock();
+					continue;
+				}
+				eXosip_message_send_answer(je->tid, 200, tmp);
+				eXosip_unlock();
+			}
+				
+		}
+		switch_safe_free(lame);		
+	} 
+}
+
+
+static int handle_call_transfer(eXosip_event_t *event)
+{
+    osip_message_t *sip = event->request;
+    osip_header_t *refer_hdr;
+	int res;
+
+    if (osip_message_header_get_byname (sip, "Refer-To", 0, &refer_hdr) < 0) {
+		eXosip_call_send_answer(event->tid, 400, NULL);
+		return 0;
+    }
+
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,  "Refer: %s\n", refer_hdr->hvalue);
+
+	res = eXosip_call_send_answer(event->tid, 202, NULL);
+    if (res) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "message_send_answer info failed! %d\n", event->tid);
+    }
+
+	{
+		osip_from_t *refer = NULL;
+		osip_uri_t *refer_uri = NULL;
+		char *refer_str = NULL;
+		
+		if (osip_from_init(&refer) < 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Memory error\n");
+			return -1;
+		}
+
+		if (osip_from_parse(refer, refer_hdr->hvalue) < 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parse error\n");
+			osip_from_free(refer);
+			refer = NULL;
+			return -1;
+		}
+
+		refer_uri = osip_from_get_url (refer);
+
+		if (osip_uri_to_str(refer_uri, &refer_str) < 0) {
+			osip_from_free(refer);
+			return -1;
+		}
+
+		printf("TEST %s\n", refer_str);
+#if 0
+
+		transfer_to = opbx_bridged_channel(p->owner);
+		if (transfer_to) {
+			/* 	    int extout = 0; */
+
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,  "Got SIP blind transfer, applying to '%s'\n", transfer_to->name);
+
+            /* Must release c's lock now, because it will not longer
+			   be accessible after the transfer! */
+			*nounlock = true;
+
+			/* 	    opbx_setstate(transfer_to, OPBX_STATE_RING); */
+			/* 	    hook_channel(transfer_to, NULL); */
+
+			opbx_mutex_unlock(&p->owner->lock);
+			/* 	    opbx_masq_park_call(p->owner, NULL, 0, &extout); */
+
+			/* 	    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,  "Parked to %d\n", extout); */
+
+			opbx_async_goto(transfer_to, p->friend->context, refer_str, 1);
+
+			{
+				osip_message_t *req = NULL;
+				if (eXosip_call_build_notify(event->did,
+											 EXOSIP_SUBCRSTATE_ACTIVE,
+											 &req) < 0) {
+					opbx_log(LOG_WARNING, "eXosip_call_build_notify failed\n");
+				} else {
+					const char sip_frag[] = "SIP/2.0 100 Trying\r\n\r\n";
+					osip_message_set_header(req, osip_strdup("Event"),
+											osip_strdup("refer"));
+					osip_message_set_body(req, sip_frag, strlen(sip_frag));
+					osip_message_set_content_type(req, "message/sipfrag");
+					if (eXosip_call_send_request(event->did, req) < 0) {
+						opbx_log(LOG_WARNING,
+								 "eXosip_call_send_request failed\n");
+					} else {
+						opbx_log(LOG_DEBUG, "Notify ok\n");
+					}
+				}
+			}
+		} else {
+			opbx_log(LOG_WARNING, "No channel up!");
+		}
+#endif
+		osip_free(refer_str);
+		osip_from_free(refer);
+    }
+    return 0;
+}
+
+static void handle_answer(eXosip_event_t *event)
+{
 	osip_message_t *ack = NULL;
 	sdp_message_t *remote_sdp = NULL;
 	sdp_connection_t *conn = NULL;
 	sdp_media_t *remote_med = NULL;
 	struct private_object *tech_pvt;
 	char *dpayload = NULL, *dname = NULL, *drate = NULL;
-	switch_channel *channel;
+	switch_channel_t *channel;
+	const switch_codec_implementation_t *imp = NULL;
+	uint8_t pre_answer = 0, reinvite = 0, isack = 0;
 
 
 	if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Um in case you are interested, Can't find the pvt!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot answer nonexistant call [%d]!\n", event->cid);
 		return;
 	}
 
+	if (event->type == EXOSIP_CALL_RINGING) {
+		pre_answer = 1;
+		if (switch_test_flag(tech_pvt, TFLAG_PRE_ANSWER)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "one pre-answer is enough for call [%d]!\n", event->cid);
+			return;
+		}
+	} else if (event->type == EXOSIP_CALL_REINVITE) {
+		reinvite = 1;
+	} else if (event->type == EXOSIP_CALL_ACK) {
+		isack = 1;
+	}
+
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
 
-	if (!event->response) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Someone answered... with no SDP information - WTF?!?\n");
-		switch_channel_hangup(channel);
-		return;
-	}
 
-	/* Get all of the remote SDP elements... stuff */
-	if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n");
-		switch_channel_hangup(channel);
-		return;
+	if (reinvite || isack) {
+		if ((remote_sdp = eXosip_get_sdp_info(event->request)) == 0) {
+			if (!isack) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n");
+				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			}
+			return;
+		}
+	} else {
+
+		if (!event->response) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Someone answered... with no SDP information - WTF?!?\n");
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			return;
+		}
+
+
+		/* Get all of the remote SDP elements... stuff */
+		if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) {
+			/* Exosip is daft, they send the same event for both 180 and 183 WTF!!*/
+			if (!pre_answer) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant Find SDP?\n");
+				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "I am daft, don't mind me.\n");
+			}
+		
+			return;
+		}
 	}
 
+	switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
 
 	conn = eXosip_get_audio_connection(remote_sdp);
 	remote_med = eXosip_get_audio_media(remote_sdp);
 
+	if (!strcmp(conn->c_addr, "0.0.0.0")) {
+		eXosip_lock();
+		eXosip_call_build_ack(event->did, &ack);
+		eXosip_call_send_ack(event->did, ack);
+		eXosip_unlock();
+
+		switch_safe_free(dname);
+		switch_safe_free(drate);
+		switch_safe_free(dpayload);
+		return;
+	}
+	
 	/* Grab IP/port */
 	tech_pvt->remote_sdp_audio_port = (switch_port_t)atoi(remote_med->m_port);
 	snprintf(tech_pvt->remote_sdp_audio_ip, 50, conn->c_addr);
 
 	/* Grab codec elements */
-	if (parse_sdp_media(remote_med, &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
+	if (parse_sdp_media(tech_pvt, remote_med, &dname, &drate, &dpayload, &imp) == SWITCH_STATUS_SUCCESS) {
 		tech_pvt->payload_num = atoi(dpayload);
 	}
 
@@ -1448,37 +1894,54 @@
 	tech_pvt->did = event->did;
 	tech_pvt->tid = event->tid;
 
+	
+	if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC) && strcasecmp(dname, tech_pvt->read_codec.implementation->iananame)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing Codec from %s to %s\n", tech_pvt->read_codec.implementation->iananame, dname);
+		switch_core_codec_destroy(&tech_pvt->read_codec);
+		switch_core_codec_destroy(&tech_pvt->write_codec);
+		switch_core_session_reset(tech_pvt->session);
+		switch_clear_flag_locked(tech_pvt, TFLAG_USING_CODEC);
+	}
 
-	{
+	if (reinvite || isack) {
+		switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+	}
+
+	if (!switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
+	
 		int rate = atoi(drate);
+		int ms = 0; //globals.codec_ms;
 
+		if (imp) {
+			ms = imp->microseconds_per_frame / 1000;
+		}
 
 		if (switch_core_codec_init(&tech_pvt->read_codec,
 								   dname,
 								   rate,
-								   globals.codec_ms,
+								   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_channel_hangup(channel);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return;
 		} else {
 			if (switch_core_codec_init(&tech_pvt->write_codec,
 									   dname,
 									   rate,
-									   globals.codec_ms,
+									   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_channel_hangup(channel);
+				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 				return;
 			} else {
 				int ms;
 				tech_pvt->read_frame.rate = rate;
-				switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
+				switch_set_flag_locked(tech_pvt, TFLAG_USING_CODEC);
 				ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Outbound Codec %s/%d %d ms\n", dname, rate, ms);
 				tech_pvt->read_frame.codec = &tech_pvt->read_codec;
@@ -1488,20 +1951,20 @@
 		}
 	}
 
-
+	
 	eXosip_lock();
 	eXosip_call_build_ack(event->did, &ack);
 	eXosip_call_send_ack(event->did, ack);
 	eXosip_unlock();
 
-	free(dname);
-	free(drate);
-	free(dpayload);
+	switch_safe_free(dname);
+	switch_safe_free(drate);
+	switch_safe_free(dpayload);
 
 
 	if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
 		exosip_on_hangup(tech_pvt->session);
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		return;
 	}
 
@@ -1509,13 +1972,80 @@
 	if (switch_test_flag(tech_pvt, TFLAG_RTP)) {
 		channel = switch_core_session_get_channel(tech_pvt->session);
 		assert(channel != NULL);
-		switch_channel_answer(channel);
+		if (pre_answer) {
+			switch_set_flag_locked(tech_pvt, TFLAG_PRE_ANSWER);
+			switch_channel_pre_answer(channel);
+		} else {
+			switch_channel_answer(channel);
+		} 
 	}
 }
 
+
+
+
+static const char *event_names[] = {
+      "EXOSIP_REGISTRATION_NEW",         
+      "EXOSIP_REGISTRATION_SUCCESS",     
+      "EXOSIP_REGISTRATION_FAILURE",     
+      "EXOSIP_REGISTRATION_REFRESHED",   
+      "EXOSIP_REGISTRATION_TERMINATED",  
+      "EXOSIP_CALL_INVITE",          
+      "EXOSIP_CALL_REINVITE",        
+      "EXOSIP_CALL_NOANSWER",        
+      "EXOSIP_CALL_PROCEEDING",      
+      "EXOSIP_CALL_RINGING",         
+      "EXOSIP_CALL_ANSWERED",        
+      "EXOSIP_CALL_REDIRECTED",      
+      "EXOSIP_CALL_REQUESTFAILURE",  
+      "EXOSIP_CALL_SERVERFAILURE",   
+      "EXOSIP_CALL_GLOBALFAILURE",   
+      "EXOSIP_CALL_ACK",             
+      "EXOSIP_CALL_CANCELLED",       
+      "EXOSIP_CALL_TIMEOUT",         
+      "EXOSIP_CALL_MESSAGE_NEW",            
+      "EXOSIP_CALL_MESSAGE_PROCEEDING",     
+      "EXOSIP_CALL_MESSAGE_ANSWERED",       
+      "EXOSIP_CALL_MESSAGE_REDIRECTED",     
+      "EXOSIP_CALL_MESSAGE_REQUESTFAILURE", 
+      "EXOSIP_CALL_MESSAGE_SERVERFAILURE",  
+      "EXOSIP_CALL_MESSAGE_GLOBALFAILURE",  
+      "EXOSIP_CALL_CLOSED",          
+      "EXOSIP_CALL_RELEASED",           
+      "EXOSIP_MESSAGE_NEW",            
+      "EXOSIP_MESSAGE_PROCEEDING",     
+      "EXOSIP_MESSAGE_ANSWERED",       
+      "EXOSIP_MESSAGE_REDIRECTED",     
+      "EXOSIP_MESSAGE_REQUESTFAILURE", 
+      "EXOSIP_MESSAGE_SERVERFAILURE",  
+      "EXOSIP_MESSAGE_GLOBALFAILURE",  
+      "EXOSIP_SUBSCRIPTION_UPDATE",       
+      "EXOSIP_SUBSCRIPTION_CLOSED",       
+      "EXOSIP_SUBSCRIPTION_NOANSWER",        
+      "EXOSIP_SUBSCRIPTION_PROCEEDING",      
+      "EXOSIP_SUBSCRIPTION_ANSWERED",        
+      "EXOSIP_SUBSCRIPTION_REDIRECTED",      
+      "EXOSIP_SUBSCRIPTION_REQUESTFAILURE",  
+      "EXOSIP_SUBSCRIPTION_SERVERFAILURE",   
+      "EXOSIP_SUBSCRIPTION_GLOBALFAILURE",   
+      "EXOSIP_SUBSCRIPTION_NOTIFY",          
+      "EXOSIP_SUBSCRIPTION_RELEASED",        
+      "EXOSIP_IN_SUBSCRIPTION_NEW",          
+      "EXOSIP_IN_SUBSCRIPTION_RELEASED",     
+      "EXOSIP_NOTIFICATION_NOANSWER",        
+      "EXOSIP_NOTIFICATION_PROCEEDING",      
+      "EXOSIP_NOTIFICATION_ANSWERED",        
+      "EXOSIP_NOTIFICATION_REDIRECTED",      
+      "EXOSIP_NOTIFICATION_REQUESTFAILURE",  
+      "EXOSIP_NOTIFICATION_SERVERFAILURE",   
+      "EXOSIP_NOTIFICATION_GLOBALFAILURE",   
+      "EXOSIP_EVENT_COUNT"                
+};
+
 static void log_event(eXosip_event_t * je)
 {
 	char buf[100];
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EVENT [%s]\n", event_names[je->type]);
 
 	buf[0] = '\0';
 	if (je->type == EXOSIP_CALL_NOANSWER) {
@@ -1635,30 +2165,51 @@
 
 static int config_exosip(int reload)
 {
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "exosip.conf";
+	switch_xml_t cfg, xml, settings, param;
 
 	globals.bytes_per_frame = DEFAULT_BYTES_PER_FRAME;
 
-
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
 	globals.dtmf_duration = 100;
+	globals.te = 101;
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
+			} else if (!strcmp(var, "use-rtp-timer") && switch_true(val)) {
+				  switch_set_flag(&globals, TFLAG_TIMER);
+			} else if (!strcmp(var, "use-rtp-auto-adjust") && switch_true(val)) {
+				  switch_set_flag(&globals, TFLAG_AA);
 			} else if (!strcmp(var, "port")) {
 				globals.port = atoi(val);
-			} else if (!strcmp(var, "extip")) {
-				set_global_extip(val);
-			} else if (!strcmp(var, "ip")) {
-				set_global_ip(val);
+			} else if (!strcmp(var, "rfc2833-pt")) {
+				globals.te = (switch_payload_t) atoi(val);
+			} else if (!strcmp(var, "vad")) {
+				if (!strcasecmp(val, "in")) {
+					switch_set_flag(&globals, TFLAG_VAD_IN);
+				} else if (!strcasecmp(val, "out")) {
+					switch_set_flag(&globals, TFLAG_VAD_OUT);
+				} else if (!strcasecmp(val, "both")) {
+					switch_set_flag(&globals, TFLAG_VAD_IN);
+					switch_set_flag(&globals, TFLAG_VAD_OUT);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
+				}
+			} else if (!strcmp(var, "ext-rtp-ip")) {
+				set_global_extrtpip(val);
+			} else if (!strcmp(var, "rtp-ip")) {
+				set_global_rtpip(val);
+			} else if (!strcmp(var, "sip-ip")) {
+				set_global_sipip(val);
 			} else if (!strcmp(var, "dialplan")) {
 				set_global_dialplan(val);
 			} else if (!strncasecmp(var, "srtp:", 5)) {
@@ -1667,12 +2218,12 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Add Realm [%s][%s]\n", name, val);
 					switch_core_hash_insert(globals.srtp_hash, switch_core_strdup(module_pool, name), switch_core_strdup(module_pool, val));
 				}
-			} else if (!strcmp(var, "codec_prefs")) {
+			} 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);
-			} else if (!strcmp(var, "codec_ms")) {
+			} else if (!strcmp(var, "codec-ms")) {
 				globals.codec_ms = atoi(val);
-			} else if (!strcmp(var, "dtmf_duration")) {
+			} else if (!strcmp(var, "dtmf-duration")) {
 				int dur = atoi(val);
 				if (dur > 10 && dur < 8000) {
 					globals.dtmf_duration = dur;
@@ -1682,24 +2233,23 @@
 			}
 		}
 	}
+	
 
-	if (!globals.ip) {
+	if (!globals.rtpip) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting ip to 'guess'\n");
-		set_global_ip("guess");
+		set_global_rtpip("guess");
 	}
 
 	if (!globals.codec_ms) {
-		globals.codec_ms = 20;
+		globals.codec_ms = 0;
 	}
 
 	if (!globals.port) {
 		globals.port = 5060;
 	}
 	
-	
+	switch_xml_free(xml);
 
-	switch_config_close_file(&cfg);
-
 	if (!globals.dialplan) {
 		set_global_dialplan("default");
 	}
@@ -1714,10 +2264,34 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+static void check_expire(time_t now)
 {
+	char sql[1024];
+	char *errmsg;
+
+	switch_mutex_lock(globals.reg_mutex);
+	snprintf(sql, sizeof(sql), "select url from sip_registrations where expires > 0 and expires < %ld", (long) now);	
+	switch_core_db_exec(globals.db, sql, del_callback, NULL, &errmsg);
+
+	if (errmsg) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s][%s]\n", sql, errmsg);
+		switch_core_db_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(globals.db, sql, 1);
+	switch_mutex_unlock(globals.reg_mutex);
+}
+
+
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
+{
 	eXosip_event_t *event = NULL;
-	switch_event *s_event;
+	switch_event_t *s_event;
+	time_t now = 0, next = 0;
+	int interval = 30;
 
 	config_exosip(0);
 
@@ -1730,7 +2304,7 @@
 		return SWITCH_STATUS_TERM;
 	}
 
-	if (eXosip_listen_addr(IPPROTO_UDP, NULL, globals.port, AF_INET, 0)) {
+	if (eXosip_listen_addr(IPPROTO_UDP, globals.sipip, globals.port, AF_INET, 0)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "eXosip_listen_addr failed!\n");
 		return SWITCH_STATUS_TERM;
 	}
@@ -1740,10 +2314,15 @@
 		switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", globals.port);
 		switch_event_fire(&s_event);
 	}
-
+	
 	globals.running = 1;
 	while (globals.running > 0) {
 		if ((event = eXosip_event_wait(0, 100)) == 0) {
+			now = time(NULL);
+			if (now >= next) {
+				check_expire(now);
+				next = now + interval;
+			}
 			switch_yield(1000);
 			continue;
 		}
@@ -1755,37 +2334,37 @@
 		log_event(event);
 
 		switch (event->type) {
+		case EXOSIP_MESSAGE_NEW:
+			handle_message_new(event);
+			break;
 		case EXOSIP_CALL_INVITE:
 			if (exosip_create_call(event) != SWITCH_STATUS_SUCCESS) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invite failure\n");
 				destroy_call_by_event(event);
 			}
 			break;
 		case EXOSIP_CALL_REINVITE:
 			/* See what the reinvite is about - on hold or whatever */
-			//handle_reinvite(event);
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Got a reinvite.\n");
+			handle_answer(event);
 			break;
 		case EXOSIP_CALL_MESSAGE_NEW:
 			if (event->request != NULL && MSG_IS_REFER(event->request)) {
-				//handle_call_transfer(event);
+				handle_call_transfer(event);
 			}
 			break;
 		case EXOSIP_CALL_ACK:
+			handle_answer(event);
 			/* If audio is not flowing and this has SDP - fire it up! */
 			break;
 		case EXOSIP_CALL_ANSWERED:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "The call was answered.\n");
 			handle_answer(event);
 			break;
 		case EXOSIP_CALL_PROCEEDING:
 			/* This is like a 100 Trying... yeah */
 			break;
 		case EXOSIP_CALL_RINGING:
-			//handle_ringing(event);
+			handle_answer(event);
 			break;
 		case EXOSIP_CALL_REDIRECTED:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call was redirect\n");
 			break;
 		case EXOSIP_CALL_CLOSED:
 			destroy_call_by_event(event);
@@ -1794,24 +2373,19 @@
 			destroy_call_by_event(event);
 			break;
 		case EXOSIP_CALL_NOANSWER:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "The call was not answered.\n");
 			destroy_call_by_event(event);
 			break;
 		case EXOSIP_CALL_REQUESTFAILURE:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Request failure\n");
 			destroy_call_by_event(event);
 			break;
 		case EXOSIP_CALL_SERVERFAILURE:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Server failure\n");
 			destroy_call_by_event(event);
 			break;
 		case EXOSIP_CALL_GLOBALFAILURE:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Global failure\n");
 			destroy_call_by_event(event);
 			break;
 			/* Registration related stuff */
 		case EXOSIP_REGISTRATION_NEW:
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Received registration attempt\n");
 			break;
 		default:
 			/* Unknown event... casually absorb it for now */

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_exosip/mod_exosip.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Exosip Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				AdditionalOptions="/D _CRT_SECURE_NO_DEPRECATE"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\libs\include;..\..\..\..\libs\libeXosip2\include;..\..\..\..\libs\osip\include;..\..\..\..\libs\osip\src\osipparser2;."
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libeXosip2-2.2.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libosip2-2.2.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libosip2-2.2.2\src\osipparser2&quot;;."
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
 				GeneratePreprocessedFile="0"
 				MinimalRebuild="true"
@@ -53,7 +53,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -67,15 +67,15 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/NODEFAULTLIB:LIBCMT"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libcpmt.lib eXosip.lib osipparser2.lib osip2.lib"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libcpmt.lib"
 				ShowProgress="0"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_exosip.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libeXosip2\platform\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\osip\platform\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				IgnoreAllDefaultLibraries="false"
 				IgnoreDefaultLibraryNames=""
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_exosip.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_exosip.lib"
 				TargetMachine="1"
@@ -107,15 +107,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Exosip Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -131,7 +131,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\libs\include;..\..\..\..\libs\libeXosip2\include;..\..\..\..\libs\osip\include;..\..\..\..\libs\osip\src\osipparser2;."
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libeXosip2-2.2.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libosip2-2.2.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libosip2-2.2.2\src\osipparser2&quot;;."
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -151,11 +151,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libcpmt.lib eXosip.lib osipparser2.lib osip2.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_exosip.dll"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libcpmt.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\libeXosip2\platform\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\osip\platform\vsnet\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.c	Fri Sep 22 14:22:15 2006
@@ -44,7 +44,7 @@
 
 static const char modname[] = "mod_iax";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 static int running = 1;
 
 
@@ -75,21 +75,25 @@
 	char *codec_rates[SWITCH_MAX_CODECS];
 	int codec_rates_last;
 	unsigned int flags;
+	int fd;
+	int calls;
+	switch_mutex_t *mutex;
 } globals;
 
 struct private_object {
 	unsigned int flags;
-	switch_codec read_codec;
-	switch_codec write_codec;
-	struct switch_frame read_frame;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
+	switch_frame_t read_frame;
 	unsigned char databuf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
-	switch_core_session *session;
+	switch_core_session_t *session;
 	struct iax_session *iax_session;
-	switch_caller_profile *caller_profile;
+	switch_caller_profile_t *caller_profile;
 	unsigned int codec;
 	unsigned int codecs;
 	unsigned short samprate;
 	switch_mutex_t *mutex;
+	switch_mutex_t *flag_mutex;
 	//switch_thread_cond_t *cond;
 };
 
@@ -128,8 +132,9 @@
 {AST_FORMAT_SLINEAR, 10, "slinear"},
 {AST_FORMAT_LPC10, 7, "lpc10"},
 {AST_FORMAT_G729A, 18, "g729"},
+{AST_FORMAT_SPEEX, 97, "speex"},
 {AST_FORMAT_SPEEX, 98, "speex"},
-{AST_FORMAT_ILBC, 999, "ilbc"},
+{AST_FORMAT_ILBC, 102, "ilbc"},
 {AST_FORMAT_MAX_AUDIO, 999, ""},
 {AST_FORMAT_JPEG, 999, ""},
 {AST_FORMAT_PNG, 999, ""},
@@ -204,18 +209,19 @@
 	IAX_QUERY = 2
 } iax_io_t;
 
-static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_session *iax_session,
+static switch_status_t iax_set_codec(struct private_object *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;
 	//int codec_ms = 20;
-	switch_channel *channel;
-	switch_codec_interface *codecs[SWITCH_MAX_CODECS];
+	switch_channel_t *channel;
+	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
 	int num_codecs = 0;
 	unsigned int local_cap = 0, mixed_cap = 0, chosen = 0, leading = 0;
 	int x, srate = 8000;
+	uint32_t interval = 0;
 
 	if (globals.codec_string) {
 		if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
@@ -233,11 +239,14 @@
 	}
 
 	for (x = 0; x < num_codecs; x++) {
-		unsigned int codec = iana2ast(codecs[x]->ianacode);
-		if (io == IAX_QUERY) {
-			iax_pref_codec_add(iax_session, codec);
+		static const switch_codec_implementation_t *imp;
+		for (imp = codecs[x]; imp; imp = imp->next) {
+			unsigned int codec = iana2ast(imp->ianacode);
+			if (io == IAX_QUERY && !(codec & local_cap)) {
+				iax_pref_codec_add(iax_session, codec);
+			}	
+			local_cap |= codec;
 		}
-		local_cap |= codec;
 	}
 
 	if (io == IAX_SET) {
@@ -247,6 +256,7 @@
 	}
 
 	leading = iana2ast(codecs[0]->ianacode);
+	interval = codecs[0]->microseconds_per_frame / 1000;
 	if (io == IAX_QUERY) {
 		chosen = leading;
 		*format = chosen;
@@ -282,8 +292,13 @@
 					int z;
 					chosen = prefs[x];
 					for (z = 0; z < num_codecs; z++) {
-						if (prefs[x] == iana2ast(codecs[z]->ianacode)) {
-							dname = codecs[z]->iananame;
+						static const switch_codec_implementation_t *imp;
+						for (imp = codecs[z]; imp; imp = imp->next) {
+							if (prefs[x] == iana2ast(imp->ianacode)) {
+								dname = imp->iananame;
+								interval = imp->microseconds_per_frame / 1000;
+								break;
+							}
 						}
 					}
 					break;
@@ -293,17 +308,27 @@
 			if (*format & mixed_cap) {	/* is the one we asked for here? */
 				chosen = *format;
 				for (x = 0; x < num_codecs; x++) {
-					unsigned int cap = iana2ast(codecs[x]->ianacode);
-					if (cap == chosen) {
-						dname = codecs[x]->iananame;
+					static const switch_codec_implementation_t *imp;
+					for (imp = codecs[x]; imp; imp = imp->next) {
+						unsigned int cap = iana2ast(imp->ianacode);
+						if (cap == chosen) {
+							dname = imp->iananame;
+							interval = imp->microseconds_per_frame / 1000;
+							break;
+						}
 					}
 				}
 			} else {			/* c'mon there has to be SOMETHING... */
 				for (x = 0; x < num_codecs; x++) {
-					unsigned int cap = iana2ast(codecs[x]->ianacode);
-					if (cap & mixed_cap) {
-						chosen = cap;
-						dname = codecs[x]->iananame;
+					static const switch_codec_implementation_t *imp;
+					for (imp = codecs[x]; imp; imp = imp->next) {
+						unsigned int cap = iana2ast(imp->ianacode);
+						if (cap & mixed_cap) {
+							chosen = cap;
+							dname = imp->iananame;
+							interval = imp->microseconds_per_frame / 1000;
+							break;
+						}
 					}
 				}
 			}
@@ -344,12 +369,12 @@
 	}
 
 	if (!strcasecmp(dname, "l16")) {
-		switch_set_flag(tech_pvt, TFLAG_LINEAR);
+		switch_set_flag_locked(tech_pvt, TFLAG_LINEAR);
 	}
 	if (switch_core_codec_init(&tech_pvt->read_codec,
 							   dname,
 							   srate,
-							   0,
+							   interval,
 							   1,
 							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 							   NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@@ -359,7 +384,7 @@
 		if (switch_core_codec_init(&tech_pvt->write_codec,
 								   dname,
 								   srate,
-								   0,
+								   interval,
 								   1,
 								   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 								   NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@@ -376,7 +401,7 @@
 			tech_pvt->read_frame.codec = &tech_pvt->read_codec;
 			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_set_flag(tech_pvt, TFLAG_CODEC);
+			switch_set_flag_locked(tech_pvt, TFLAG_CODEC);
 		}
 		tech_pvt->codec = chosen;
 		tech_pvt->codecs = local_cap;
@@ -390,18 +415,18 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_init(switch_core_session *session);
-static switch_status channel_on_hangup(switch_core_session *session);
-static switch_status channel_on_ring(switch_core_session *session);
-static switch_status channel_on_loopback(switch_core_session *session);
-static switch_status channel_on_transmit(switch_core_session *session);
-static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool);
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag flags, int stream_id);
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag flags, int stream_id);
-static switch_status channel_kill_channel(switch_core_session *session, int sig);
+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_status_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 void iax_err_cb(const char *s)
@@ -422,9 +447,9 @@
 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 channel_on_init(switch_core_session *session)
+static switch_status_t channel_on_init(switch_core_session_t *session)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt = NULL;
 
 	tech_pvt = switch_core_session_get_private(session);
@@ -437,7 +462,7 @@
 	tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
 	iax_set_private(tech_pvt->iax_session, tech_pvt);
 
-	switch_set_flag(tech_pvt, TFLAG_IO);
+	switch_set_flag_locked(tech_pvt, TFLAG_IO);
 
 	switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 	//switch_thread_cond_create(&tech_pvt->cond, switch_core_session_get_pool(session));    
@@ -445,13 +470,16 @@
 
 	/* Move Channel's State Machine to RING */
 	switch_channel_set_state(channel, CS_RING);
+	switch_mutex_lock(globals.mutex);
+	globals.calls++;
+	switch_mutex_unlock(globals.mutex);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_ring(switch_core_session *session)
+static switch_status_t channel_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -465,10 +493,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_execute(switch_core_session *session)
+static switch_status_t channel_on_execute(switch_core_session_t *session)
 {
 
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -483,9 +511,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_hangup(switch_core_session *session)
+static switch_status_t channel_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -494,8 +522,8 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
-	switch_clear_flag(tech_pvt, TFLAG_VOICE);
+	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+	switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
 	//switch_thread_cond_signal(tech_pvt->cond);
 
 	if (tech_pvt->read_codec.implementation) {
@@ -509,19 +537,25 @@
 	if (tech_pvt->iax_session) {
 		if (!switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
 			iax_hangup(tech_pvt->iax_session, "Hangup");
-			switch_set_flag(tech_pvt, TFLAG_HANGUP);
+			switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
 		}
 		iax_session_destroy(&tech_pvt->iax_session);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
-
+	switch_mutex_lock(globals.mutex);
+	globals.calls--;
+	if (globals.calls < 0) {
+		globals.calls = 0;
+	}
+	switch_mutex_unlock(globals.mutex);
+		
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_kill_channel(switch_core_session *session, int sig)
+static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -530,9 +564,9 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
-	switch_clear_flag(tech_pvt, TFLAG_VOICE);
-	switch_channel_hangup(channel);
+	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);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
@@ -541,19 +575,19 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_loopback(switch_core_session *session)
+static switch_status_t channel_on_loopback(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_transmit(switch_core_session *session)
+static switch_status_t channel_on_transmit(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -563,7 +597,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -574,7 +608,7 @@
 
 }
 
-static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
+static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *dtmf)
 {
 	struct private_object *tech_pvt = NULL;
 	char *digit;
@@ -590,10 +624,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag 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 *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 	switch_time_t started = switch_time_now();
 	unsigned int elapsed;
@@ -612,12 +646,16 @@
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
-			switch_clear_flag(tech_pvt, TFLAG_VOICE);
+			switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
 			if (!tech_pvt->read_frame.datalen) {
 				continue;
 			}
-
 			*frame = &tech_pvt->read_frame;
+#ifdef BIGENDIAN
+			if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+				switch_swap_linear((*frame)->data, (int) (*frame)->datalen);
+			}
+#endif
 			return SWITCH_STATUS_SUCCESS;
 		}
 
@@ -636,12 +674,12 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag 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 *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	//switch_frame *pframe;
+	//switch_frame_t *pframe;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -652,7 +690,7 @@
 	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
 		return SWITCH_STATUS_FALSE;
 	}
-#ifndef BIGENDIAN
+#ifdef BIGENDIAN
 	if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
 		switch_swap_linear(frame->data, (int) frame->datalen / 2);
 	}
@@ -665,10 +703,10 @@
 
 }
 
-static switch_status channel_answer_channel(switch_core_session *session)
+static switch_status_t channel_answer_channel(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -682,7 +720,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static const switch_state_handler_table channel_event_handlers = {
+static const switch_state_handler_table_t channel_event_handlers = {
 	/*.on_init */ channel_on_init,
 	/*.on_ring */ channel_on_ring,
 	/*.on_execute */ channel_on_execute,
@@ -691,7 +729,7 @@
 	/*.on_transmit */ channel_on_transmit
 };
 
-static const switch_io_routines channel_io_routines = {
+static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
 	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
@@ -702,7 +740,7 @@
 	/*.send_dtmf */ channel_send_dtmf
 };
 
-static const switch_endpoint_interface channel_endpoint_interface = {
+static const switch_endpoint_interface_t channel_endpoint_interface = {
 	/*.interface_name */ "iax",
 	/*.io_routines */ &channel_io_routines,
 	/*.event_handlers */ &channel_event_handlers,
@@ -710,7 +748,7 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface channel_module_interface = {
+static const switch_loadable_module_interface_t channel_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &channel_endpoint_interface,
 	/*.timer_interface */ NULL,
@@ -723,13 +761,13 @@
 /* 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_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool)
+static switch_status_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) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
-		switch_caller_profile *caller_profile;
+		switch_channel_t *channel;
+		switch_caller_profile_t *caller_profile;
 		unsigned int req = 0, cap = 0;
 		unsigned short samprate = 0;
 
@@ -737,6 +775,7 @@
 		if ((tech_pvt =
 			 (struct private_object *) switch_core_session_alloc(*new_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(*new_session));
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
 			tech_pvt->session = *new_session;
@@ -781,7 +820,7 @@
 				 caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -790,7 +829,7 @@
 
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -798,8 +837,9 @@
 		return SWITCH_STATUS_TERM;
 	}
 
+	
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &channel_module_interface;
+	*module_interface = &channel_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
@@ -815,38 +855,40 @@
 #define REGISTERED		1
 
 
-static switch_status load_config(void)
+static switch_status_t load_config(void)
 {
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "iax.conf";
+	switch_xml_t cfg, xml, settings, param;
 
 	memset(&globals, 0, sizeof(globals));
-
-	if (!switch_config_open_file(&cfg, cf)) {
+	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, 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);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
 			} else if (!strcmp(var, "port")) {
 				globals.port = atoi(val);
 			} else if (!strcmp(var, "ip")) {
 				set_global_ip(val);
-			} else if (!strcmp(var, "codec_master")) {
+			} else if (!strcmp(var, "codec-master")) {
 				if (!strcasecmp(val, "us")) {
 					switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS);
 				}
 			} else if (!strcmp(var, "dialplan")) {
 				set_global_dialplan(val);
-			} else if (!strcmp(var, "codec_prefs")) {
+			} 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);
-			} else if (!strcmp(var, "codec_rates")) {
+			} 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);
@@ -857,21 +899,22 @@
 	if (!globals.dialplan) {
 		set_global_dialplan("default");
 	}
+
 	if (!globals.port) {
 		globals.port = 4569;
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	//int refresh;
 	struct iax_event *iaxevent = NULL;
-	switch_event *s_event;
+	switch_event_t *s_event;
 	if (load_config() != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_TERM;
 	}
@@ -886,7 +929,7 @@
 
 	iax_set_error(iax_err_cb);
 	iax_set_output(iax_out_cb);
-	//netfd = iax_get_fd();
+	globals.fd = iax_get_fd();
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IAX Ready Port %d\n", globals.port);
 
@@ -898,15 +941,26 @@
 
 	for (;;) {
 
+
 		if (running == -1) {
 			break;
 		}
 
 		/* Wait for an event. */
 		if ((iaxevent = iax_get_event(0)) == NULL) {
-			switch_yield(1000);
+			int waitlen = 0;
+			
+			if (globals.calls == 0) {
+				waitlen = 10000;
+			} else if (globals.calls < 10) {
+				waitlen = 1000;
+			} else {
+				waitlen = 500;
+			}
+
+			switch_yield(waitlen);
 			continue;
-		} else if (iaxevent) {
+		} else {
 			struct private_object *tech_pvt = iax_get_private(iaxevent->session);
 
 			if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
@@ -949,7 +1003,7 @@
 			case IAX_EVENT_ANSWER:
 				// the other side answered our call
 				if (tech_pvt) {
-					switch_channel *channel;
+					switch_channel_t *channel;
 					if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) {
 						if (switch_channel_test_flag(channel, CF_ANSWERED)) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n",
@@ -972,19 +1026,20 @@
 									  iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
 
 				if (iaxevent) {
-					switch_core_session *session;
+					switch_core_session_t *session;
 
 					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) {
 						struct private_object *tech_pvt;
-						switch_channel *channel;
+						switch_channel_t *channel;
 
 						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));
 							channel = switch_core_session_get_channel(session);
 							switch_core_session_set_private(session, tech_pvt);
 							tech_pvt->session = session;
@@ -996,12 +1051,17 @@
 
 
 						if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																				  iaxevent->ies.username,
 																				  globals.dialplan,
 																				  iaxevent->ies.calling_name,
 																				  iaxevent->ies.calling_number,
 																				  iax_get_peer_ip(iaxevent->session),
 																				  iaxevent->ies.calling_ani,
-																				  NULL, iaxevent->ies.called_number)) != 0) {
+																				  NULL, 
+																				  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);
@@ -1032,14 +1092,17 @@
 			case IAX_EVENT_BUSY:
 			case IAX_EVENT_HANGUP:
 				if (tech_pvt) {
-					switch_channel *channel;
-
+					switch_channel_t *channel;
+					
+					switch_mutex_lock(tech_pvt->flag_mutex);
 					switch_clear_flag(tech_pvt, TFLAG_IO);
 					switch_clear_flag(tech_pvt, TFLAG_VOICE);
+					switch_mutex_unlock(tech_pvt->flag_mutex);
+
 					if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
-						switch_set_flag(tech_pvt, TFLAG_HANGUP);
-						switch_channel_hangup(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;
 					} else {
@@ -1054,7 +1117,7 @@
 				break;
 			case IAX_EVENT_VOICE:
 				if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen) != 0) {
-					switch_channel *channel;
+					switch_channel_t *channel;
 					if (((channel = switch_core_session_get_channel(tech_pvt->session)) != 0)
 						&& switch_channel_get_state(channel) <= CS_HANGUP) {
 						int bytes, frames;
@@ -1064,14 +1127,18 @@
 							break;
 						}
 
-						bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-						frames = (int) (tech_pvt->read_frame.datalen / bytes);
+						if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+							bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+							frames = (int) (tech_pvt->read_frame.datalen / bytes);
+						} else {
+							frames = 1;
+						}
 
 
 						tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 						memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
 						/* wake up the i/o thread */
-						switch_set_flag(tech_pvt, TFLAG_VOICE);
+						switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
 						//switch_thread_cond_signal(tech_pvt->cond);
 					}
 				}
@@ -1082,7 +1149,7 @@
 				break;
 			case IAX_EVENT_DTMF:
 				if (tech_pvt) {
-					switch_channel *channel;
+					switch_channel_t *channel;
 					if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) {
 						char str[2] = { (char)iaxevent->subclass };
 						if (globals.debug) {
@@ -1111,12 +1178,16 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	int x = 0;
 
 	running = -1;
 
+	if (globals.fd) {
+		/* Die Mutha $%#$@% Die Mutha $#%#$^ Die*/
+		shutdown(globals.fd, 2);
+	}
 	iax_shutdown();
 
 	while (running) {

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_iax/mod_iax.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_iax Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -51,7 +51,8 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
+				DisableSpecificWarnings="4201"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +65,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libiax2.lib Winmm.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_iax.dll"
-				LinkIncremental="2"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib Winmm.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\iax\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_iax.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_iax.lib"
 				TargetMachine="1"
@@ -101,15 +102,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_iax Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -133,6 +134,7 @@
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
 				DebugInformationFormat="3"
+				DisableSpecificWarnings="4201"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -145,11 +147,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib libiax2.lib Winmm.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_iax.dll"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib Winmm.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\iax\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_PortAudio.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_PortAudio.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_PortAudio.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_PortAudio Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio\pa_common&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio\pa_win_wmme&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio_v18_1\pa_common&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio_v18_1\pa_win_wmme&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,12 +65,12 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/NODEFAULTLIB:LIMBCTD"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib  PAStaticWMMED.lib Winmm.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_PortAudio.dll"
-				LinkIncremental="2"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib  Winmm.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\portaudio\winvc\Lib&quot;;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_PortAudio.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_PortAudio.lib"
 				TargetMachine="1"
@@ -102,15 +102,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_PortAudio Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -126,7 +126,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio\pa_common&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio\pa_win_wmme&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio_v18_1\pa_common&quot;;&quot;$(InputDir)..\..\..\..\libs\portaudio_v18_1\pa_win_wmme&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -146,11 +146,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib  PAStaticWMME.lib Winmm.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_PortAudio.dll"
+				AdditionalDependencies="Ws2_32.lib Iphlpapi.lib Winmm.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\portaudio\winvc\Lib&quot;;..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Fri Sep 22 14:22:15 2006
@@ -41,7 +41,7 @@
 
 static const char modname[] = "mod_portaudio";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 //static int running = 1;
 
 #define SAMPLE_TYPE  paInt16
@@ -73,63 +73,67 @@
 	int indev;
 	int outdev;
 	int call_id;
-	switch_hash *call_hash;
+	switch_hash_t *call_hash;
 	switch_mutex_t *device_lock;
 	int sample_rate;
 } globals;
 
 struct private_object {
 	unsigned int flags;
-	switch_codec read_codec;
-	switch_codec write_codec;
-	struct switch_frame read_frame;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
+	switch_frame_t read_frame;
 	unsigned char databuf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
-	switch_core_session *session;
-	switch_caller_profile *caller_profile;
+	switch_core_session_t *session;
+	switch_caller_profile_t *caller_profile;
 	char call_id[50];
 	PaError err;
 	PABLIO_Stream *audio_in;
 	PABLIO_Stream *audio_out;
 	int indev;
 	int outdev;
+	switch_mutex_t *flag_mutex;
 };
 
 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)
 
-	 static switch_status channel_on_init(switch_core_session *session);
-	 static switch_status channel_on_hangup(switch_core_session *session);
-	 static switch_status channel_on_ring(switch_core_session *session);
-	 static switch_status channel_on_loopback(switch_core_session *session);
-	 static switch_status channel_on_transmit(switch_core_session *session);
-	 static switch_status channel_outgoing_channel(switch_core_session *session,
-												   switch_caller_profile *outbound_profile,
-												   switch_core_session **new_session, switch_memory_pool *pool);
-	 static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-											 switch_io_flag flags, int stream_id);
-	 static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-											  switch_io_flag flags, int stream_id);
-	 static switch_status channel_kill_channel(switch_core_session *session, int sig);
-	 static switch_status engage_device(struct private_object *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_status_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(struct private_object *tech_pvt);
 	 static int dump_info(void);
-	 static switch_status load_config(void);
+	 static switch_status_t load_config(void);
 	 static int get_dev_by_name(char *name, int in);
-	 static switch_status place_call(char *dest, char *out, size_t outlen);
-	 static switch_status hup_call(char *callid, char *out, size_t outlen);
-	 static switch_status call_info(char *callid, char *out, size_t outlen);
-	 static switch_status send_dtmf(char *callid, char *out, size_t outlen);
-	 static switch_status answer_call(char *callid, char *out, size_t outlen);
+	 static switch_status_t place_call(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t hup_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t call_info(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t send_dtmf(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t answer_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
 
 /* 
    State methods they get called when the state changes to the specific state 
    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 channel_on_init(switch_core_session *session)
+
+static switch_status_t channel_on_init(switch_core_session_t *session)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt = NULL;
+	switch_time_t last;
+	int waitsec = 5 * 1000000;
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
@@ -140,17 +144,53 @@
 	tech_pvt->read_frame.data = tech_pvt->databuf;
 	tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
 
-	switch_set_flag(tech_pvt, TFLAG_IO);
+	last = switch_time_now() - waitsec;
 
-	/* Move Channel's State Machine to RING */
-	switch_channel_set_state(channel, CS_RING);
+	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+		/* Turn on the device */
+		engage_device(tech_pvt);
 
+
+		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));
+
+		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) {
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_info", buf);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call_id", tech_pvt->call_id);
+					switch_channel_event_set_data(channel, event);
+					switch_event_fire(&event);
+				}
+
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
+				last = switch_time_now();
+			}
+			switch_yield(50000);
+		}
+	}
+
+
+	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
+		switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
+	} else {
+		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;
 }
 
-static switch_status channel_on_ring(switch_core_session *session)
+static switch_status_t channel_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -164,10 +204,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_execute(switch_core_session *session)
+static switch_status_t channel_on_execute(switch_core_session_t *session)
 {
 
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -196,9 +236,9 @@
 	switch_mutex_unlock(globals.device_lock);
 }
 
-static switch_status channel_on_hangup(switch_core_session *session)
+static switch_status_t channel_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -207,7 +247,7 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
+	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 	switch_core_hash_delete(globals.call_hash, tech_pvt->call_id);
 
 	switch_core_codec_destroy(&tech_pvt->read_codec);
@@ -220,9 +260,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_kill_channel(switch_core_session *session, int sig)
+static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -231,9 +271,9 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_clear_flag(tech_pvt, TFLAG_IO);
+	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 	deactivate_audio_device(tech_pvt);
-	switch_channel_hangup(channel);
+	switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
 
@@ -241,18 +281,16 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_loopback(switch_core_session *session)
+static switch_status_t channel_on_transmit(switch_core_session_t *session)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_on_transmit(switch_core_session *session)
+static switch_status_t channel_on_loopback(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	switch_time_t last;
-	int waitsec = 5 * 1000000;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -260,38 +298,13 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	last = switch_time_now() - waitsec;
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
 
-	/* Turn on the device */
-	engage_device(tech_pvt);
-
-	while (switch_channel_get_state(channel) == CS_TRANSMIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
-		if (switch_time_now() - last >= waitsec) {
-			char buf[512];
-			switch_event *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) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_info", buf);
-				switch_event_fire(&event);
-			}
-
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
-			last = switch_time_now();
-		}
-		switch_yield(50000);
-	}
-
-
-
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -301,7 +314,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
+static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -312,7 +325,7 @@
 
 }
 
-static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
+static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *dtmf)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -324,13 +337,13 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag 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 *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 	int samples;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -358,12 +371,12 @@
 	return status;
 }
 
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag 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 *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -384,10 +397,10 @@
 
 }
 
-static switch_status channel_answer_channel(switch_core_session *session)
+static switch_status_t channel_answer_channel(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -398,43 +411,67 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
+{
+	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);
 
-static struct switch_api_interface send_dtmf_interface = {
+
+	switch (msg->message_id) {
+	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);
+		}
+	default:
+		break;
+	}
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_api_interface_t send_dtmf_interface = {
 	/*.interface_name */ "padtmf",
 	/*.desc */ "PortAudio Dial DTMF",
 	/*.function */ send_dtmf,
 	/*.next */ NULL
 };
 
-static struct switch_api_interface answer_call_interface = {
+static switch_api_interface_t answer_call_interface = {
 	/*.interface_name */ "paoffhook",
 	/*.desc */ "PortAudio Answer Call",
 	/*.function */ answer_call,
 	/*.next */ &send_dtmf_interface
 };
 
-static struct switch_api_interface channel_info_interface = {
+static switch_api_interface_t channel_info_interface = {
 	/*.interface_name */ "painfo",
 	/*.desc */ "PortAudio Call Info",
 	/*.function */ call_info,
 	/*.next */ &answer_call_interface
 };
 
-static struct switch_api_interface channel_hup_interface = {
+static switch_api_interface_t channel_hup_interface = {
 	/*.interface_name */ "pahup",
 	/*.desc */ "PortAudio Hangup Call",
 	/*.function */ hup_call,
 	/*.next */ &channel_info_interface
 };
 
-static struct switch_api_interface channel_api_interface = {
+static switch_api_interface_t channel_api_interface = {
 	/*.interface_name */ "pacall",
 	/*.desc */ "PortAudio Call",
 	/*.function */ place_call,
 	/*.next */ &channel_hup_interface
 };
 
-static const switch_state_handler_table channel_event_handlers = {
+static const switch_state_handler_table_t channel_event_handlers = {
 	/*.on_init */ channel_on_init,
 	/*.on_ring */ channel_on_ring,
 	/*.on_execute */ channel_on_execute,
@@ -443,7 +480,7 @@
 	/*.on_transmit */ channel_on_transmit
 };
 
-static const switch_io_routines channel_io_routines = {
+static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
 	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
@@ -451,10 +488,11 @@
 	/*.kill_channel */ channel_kill_channel,
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
-	/*.send_dtmf */ channel_send_dtmf
+	/*.send_dtmf */ channel_send_dtmf,
+	/*.receive_message*/ channel_receive_message
 };
 
-static const switch_endpoint_interface channel_endpoint_interface = {
+static const switch_endpoint_interface_t channel_endpoint_interface = {
 	/*.interface_name */ "portaudio",
 	/*.io_routines */ &channel_io_routines,
 	/*.event_handlers */ &channel_event_handlers,
@@ -462,7 +500,7 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface channel_module_interface = {
+static const switch_loadable_module_interface_t channel_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &channel_endpoint_interface,
 	/*.timer_interface */ NULL,
@@ -475,18 +513,20 @@
 /* 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_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool)
+static switch_status_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) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
-		switch_caller_profile *caller_profile;
+		switch_channel_t *channel;
+		switch_caller_profile_t *caller_profile;
 
 		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));
+			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;
@@ -513,7 +553,7 @@
 		}
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -523,7 +563,7 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -545,37 +585,39 @@
 	}
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &channel_module_interface;
+	*module_interface = &channel_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status load_config(void)
+static switch_status_t load_config(void)
 {
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "portaudio.conf";
+	switch_xml_t cfg, xml, settings, param;
 
 	memset(&globals, 0, sizeof(globals));
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
-			} else if (!strcmp(var, "sample_rate")) {
+			} else if (!strcmp(var, "sample-rate")) {
 				globals.sample_rate = atoi(val);
 			} else if (!strcmp(var, "dialplan")) {
 				set_global_dialplan(val);
-			} else if (!strcmp(var, "cid_name")) {
+			} else if (!strcmp(var, "cid-name")) {
 				set_global_cid_name(val);
-			} else if (!strcmp(var, "cid_num")) {
+			} else if (!strcmp(var, "cid-num")) {
 				set_global_cid_num(val);
 			} else if (!strcmp(var, "indev")) {
 				if (*val == '#') {
@@ -601,13 +643,13 @@
 		globals.sample_rate = 8000;
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 /*
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 
 	switch_yield(50000);
@@ -616,7 +658,7 @@
 }
 */
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	Pa_Terminate();
 
@@ -710,12 +752,12 @@
 	return err;
 }
 
-static switch_status engage_device(struct private_object *tech_pvt)
+static switch_status_t engage_device(struct private_object *tech_pvt)
 {
 	int sample_rate = globals.sample_rate;
 	int codec_ms = 20;
 
-	switch_channel *channel;
+	switch_channel_t *channel;
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
 
@@ -780,25 +822,30 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status place_call(char *dest, char *out, size_t outlen)
+static switch_status_t place_call(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
-	switch_core_session *session;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_core_session_t *session;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!dest) {
-		strncpy(out, "Usage: pacall <exten>", outlen - 1);
+		stream->write_function(stream, "Usage: pacall <exten>");
 		return SWITCH_STATUS_FALSE;
 	}
 
-	strncpy(out, "FAIL", outlen - 1);
-
+	stream->write_function(stream, "FAIL");
+	
 	if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
+		switch_channel_t *channel;
 
 		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));
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
 			tech_pvt->session = session;
@@ -809,9 +856,10 @@
 		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																  NULL,
 																  globals.dialplan,
 																  globals.cid_name,
-																  globals.cid_num, NULL, NULL, NULL, dest)) != 0) {
+																  globals.cid_num, NULL, NULL, NULL, NULL, (char *)modname, NULL, dest)) != 0) {
 			char name[128];
 			snprintf(name, sizeof(name), "PortAudio/%s-%04x",
 					 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
@@ -824,38 +872,42 @@
 		if ((status = engage_device(tech_pvt)) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_set_state(channel, CS_INIT);
 			switch_core_session_thread_launch(tech_pvt->session);
-			snprintf(out, outlen, "SUCCESS: %s", tech_pvt->call_id);
+			stream->write_function(stream, "SUCCESS:%s:%s", tech_pvt->call_id, switch_core_session_get_uuid(tech_pvt->session));
 		}
 	}
 	return status;
 }
 
 
-static switch_status hup_call(char *callid, char *out, size_t outlen)
+static switch_status_t hup_call(char *callid, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	char tmp[50];
 
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (callid && !strcasecmp(callid, "last")) {
 		snprintf(tmp, sizeof(tmp), "%d", globals.call_id - 1);
 		callid = tmp;
 	}
-	if (!callid || !strcasecmp(callid, "all")) {
+	if (switch_strlen_zero(callid) || !strcasecmp(callid, "all")) {
 		switch_hash_index_t *hi;
 		void *val;
 		int i = 0;
 
-		for (hi = apr_hash_first(module_pool, globals.call_hash); hi; hi = switch_hash_next(hi)) {
+		for (hi = switch_hash_first(module_pool, globals.call_hash); hi; hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			tech_pvt = val;
 			channel = switch_core_session_get_channel(tech_pvt->session);
 			assert(channel != NULL);
-			switch_channel_hangup(channel);
+			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			i++;
 		}
 
-		snprintf(out, outlen, "HUNGUP: %d", i);
+		stream->write_function(stream, "HUNGUP: %d", i);
 
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -865,22 +917,26 @@
 		channel = switch_core_session_get_channel(tech_pvt->session);
 		assert(channel != NULL);
 
-		switch_channel_hangup(channel);
-		strncpy(out, "OK", outlen - 1);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+		stream->write_function(stream, "OK");
 	} else {
-		strncpy(out, "NO SUCH CALL", outlen - 1);
+		stream->write_function(stream, "NO SUCH CALL");
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status send_dtmf(char *callid, char *out, size_t outlen)
+static switch_status_t send_dtmf(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt = NULL;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	char *dtmf;
 
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if ((dtmf = strchr(callid, ' ')) != 0) {
 		*dtmf++ = '\0';
 	} else {
@@ -891,39 +947,43 @@
 		channel = switch_core_session_get_channel(tech_pvt->session);
 		assert(channel != NULL);
 		switch_channel_queue_dtmf(channel, dtmf);
-		strncpy(out, "OK", outlen - 1);
+		stream->write_function(stream, "OK");
 	} else {
-		strncpy(out, "NO SUCH CALL", outlen - 1);
+		stream->write_function(stream, "NO SUCH CALL");
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status answer_call(char *callid, char *out, size_t outlen)
+static switch_status_t answer_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt = NULL;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
-	if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (callid && (tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
 		channel = switch_core_session_get_channel(tech_pvt->session);
 		assert(channel != NULL);
-		switch_set_flag(tech_pvt, TFLAG_ANSWER);
+		switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
 		switch_channel_answer(channel);
 	} else {
-		strncpy(out, "NO SUCH CALL", outlen - 1);
+		stream->write_function(stream, "NO SUCH CALL");
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static void print_info(struct private_object *tech_pvt, char *out, size_t outlen)
+static void print_info(struct private_object *tech_pvt, switch_stream_handle_t *stream)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	channel = switch_core_session_get_channel(tech_pvt->session);
 	assert(channel != NULL);
 
-	snprintf(out, outlen, "CALL %s\t%s\t%s\t%s\t%s\n",
-			 tech_pvt->call_id,
+	stream->write_function(stream, "CALL %s\t%s\t%s\t%s\t%s\n",
+						   tech_pvt->call_id,
 			 tech_pvt->caller_profile->caller_id_name ? tech_pvt->caller_profile->caller_id_name : "n/a",
 			 tech_pvt->caller_profile->caller_id_number ? tech_pvt->caller_profile->caller_id_number : "n/a",
 			 tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : "n/a",
@@ -931,21 +991,26 @@
 
 }
 
-static switch_status call_info(char *callid, char *out, size_t outlen)
+static switch_status_t call_info(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt;
 	switch_hash_index_t *hi;
 	void *val;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!callid || !strcasecmp(callid, "all")) {
-		for (hi = apr_hash_first(module_pool, globals.call_hash); hi; hi = switch_hash_next(hi)) {
+		for (hi = switch_hash_first(module_pool, globals.call_hash); hi; hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			tech_pvt = val;
-			print_info(tech_pvt, out + strlen(out), outlen - strlen(out));
+			print_info(tech_pvt, stream);
 		}
-	} else if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
-		print_info(tech_pvt, out, outlen);
+	} else if (callid && (tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
+		print_info(tech_pvt, stream);
 	} else {
-		strncpy(out, "NO SUCH CALL", outlen - 1);
+		stream->write_function(stream, "NO SUCH CALL");
 	}
 
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	Fri Sep 22 14:22:15 2006
@@ -38,7 +38,7 @@
 static const char modname[] = "mod_wanpipe";
 #define STRLEN 15
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 typedef enum {
 	PFLAG_ANSWER = (1 << 0),
@@ -98,14 +98,14 @@
 
 struct private_object {
 	unsigned int flags;			/* FLAGS */
-	switch_frame read_frame;	/* Frame for Writing */
-	switch_core_session *session;
-	switch_codec read_codec;
-	switch_codec write_codec;
+	switch_frame_t read_frame;	/* Frame for Writing */
+	switch_core_session_t *session;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
 	unsigned char databuf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
 	struct sangoma_pri *spri;
 	sangoma_api_hdr_t hdrframe;
-	switch_caller_profile *caller_profile;
+	switch_caller_profile_t *caller_profile;
 	int socket;
 	int callno;
 	int span;
@@ -113,9 +113,10 @@
 	q931_call *call;
 	teletone_dtmf_detect_state_t dtmf_detect;
 	teletone_generation_session_t tone_session;
-	switch_buffer *dtmf_buffer;
+	switch_buffer_t *dtmf_buffer;
 	unsigned int skip_read_frames;
 	unsigned int skip_write_frames;
+	switch_mutex_t *flag_mutex;
 #ifdef DOTRACE
 	int fd;
 	int fd2;
@@ -123,7 +124,7 @@
 };
 
 struct channel_map {
-	switch_core_session *map[36];
+	switch_core_session_t *map[36];
 };
 
 
@@ -196,24 +197,24 @@
 static void set_global_dialplan(char *dialplan);
 static int str2node(char *node);
 static int str2switch(char *swtype);
-static switch_status wanpipe_on_init(switch_core_session *session);
-static switch_status wanpipe_on_hangup(switch_core_session *session);
-static switch_status wanpipe_on_loopback(switch_core_session *session);
-static switch_status wanpipe_on_transmit(switch_core_session *session);
-static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool);
-static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag flags, int stream_id);
-static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag flags, int stream_id);
+static switch_status_t wanpipe_on_init(switch_core_session_t *session);
+static switch_status_t wanpipe_on_hangup(switch_core_session_t *session);
+static switch_status_t wanpipe_on_loopback(switch_core_session_t *session);
+static switch_status_t wanpipe_on_transmit(switch_core_session_t *session);
+static switch_status_t wanpipe_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 wanpipe_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 wanpipe_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
+										 switch_io_flag_t flags, int stream_id);
 static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
 static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
 static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
 static int check_flags(struct sangoma_pri *spri);
 static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
 static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
-static void *pri_thread_run(switch_thread *thread, void *obj);
-static switch_status config_wanpipe(int reload);
+static void *pri_thread_run(switch_thread_t *thread, void *obj);
+static switch_status_t config_wanpipe(int reload);
 
 
 /* 
@@ -221,11 +222,11 @@
    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 wanpipe_on_init(switch_core_session *session)
+static switch_status_t wanpipe_on_init(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
-	wanpipe_tdm_api_t tdm_api = {};
+	switch_channel_t *channel = NULL;
+	wanpipe_tdm_api_t tdm_api = {{0}};
 	int err = 0;
 	int mtu_mru;
 	unsigned int rate = 8000;
@@ -251,7 +252,7 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADJUSTED MTU AFTER SETTING IT TO %d is %d %d [%s]\n", new_mtu, mtu_mru, err, strerror(err));
 		if (mtu_mru != globals.mtu) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure to adjust MTU\n");
-			switch_channel_hangup(channel);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return SWITCH_STATUS_FALSE;
 		}
 	}
@@ -260,7 +261,7 @@
 		(&tech_pvt->read_codec, "L16", rate, 20, 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_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -268,7 +269,7 @@
 		(&tech_pvt->write_codec, "L16", rate, 20, 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_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 	tech_pvt->read_frame.rate = rate;
@@ -306,9 +307,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status wanpipe_on_ring(switch_core_session *session)
+static switch_status_t wanpipe_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -324,10 +325,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status wanpipe_on_hangup(switch_core_session *session)
+static switch_status_t wanpipe_on_hangup(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct channel_map *chanmap = NULL;
 
 	
@@ -337,7 +338,7 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch_set_flag(tech_pvt, TFLAG_BYE);
+	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 
 	if (!switch_test_flag(tech_pvt, TFLAG_NOSIG)) {
 		chanmap = tech_pvt->spri->private_info;
@@ -369,19 +370,21 @@
 
 	teletone_destroy_session(&tech_pvt->tone_session);
 
+	switch_buffer_destroy(&tech_pvt->dtmf_buffer);
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status wanpipe_on_loopback(switch_core_session *session)
+static switch_status_t wanpipe_on_loopback(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WANPIPE LOOPBACK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status wanpipe_on_transmit(switch_core_session *session)
+static switch_status_t wanpipe_on_transmit(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -396,10 +399,10 @@
 }
 
 
-static switch_status wanpipe_answer_channel(switch_core_session *session)
+static switch_status_t wanpipe_answer_channel(switch_core_session_t *session)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -415,11 +418,11 @@
 
 
 
-static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-										switch_io_flag flags, int stream_id)
+static switch_status_t wanpipe_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;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	uint8_t *bp;
 	int bytes = 0, res = 0;
 	char digit_str[80];
@@ -440,14 +443,14 @@
 	*frame = NULL;
 	memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf));
 	while (bytes < globals.mtu) {
+
 		if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
 			return SWITCH_STATUS_GENERR;
 		}
-		if ((res = sangoma_socket_waitfor(tech_pvt->socket, timeout, POLLIN | POLLERR)) < 0) {
+
+
+		if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLIN | POLLERR | POLLHUP) <= 0) {
 			return SWITCH_STATUS_GENERR;
-		} else if (res == 0) {
-			tech_pvt->read_frame.datalen = 0;
-			return SWITCH_STATUS_SUCCESS;
 		}
 
 		if ((res = sangoma_readmsg_socket(tech_pvt->socket,
@@ -464,7 +467,7 @@
 		bp += bytes;
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
+	if (!bytes || switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
 		return SWITCH_STATUS_GENERR;
 	}
 
@@ -497,17 +500,17 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-										 switch_io_flag flags, int stream_id)
+static switch_status_t wanpipe_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 *channel = NULL;
+	switch_channel_t *channel = NULL;
 	int result = 0;
 	int bytes = frame->datalen;
 	uint8_t *bp = frame->data;
 	unsigned char dtmf[1024];
 	int bread, bwrote = 0;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -527,10 +530,10 @@
 			}
 		}
 
+		if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLOUT | POLLERR | POLLHUP) <= 0) {
+			return SWITCH_STATUS_GENERR;
+		}
 
-		sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
-
-
 #ifdef DOTRACE	
 		write(tech_pvt->fd, dtmf, (int) bread);
 #endif
@@ -565,22 +568,29 @@
 
 	while (bytes > 0) {
 		unsigned int towrite;
-		
-		if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
+
+#if 1
+		if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLOUT | POLLERR | POLLHUP) <= 0) {
 			return SWITCH_STATUS_GENERR;
 		}
+#endif
 
-		sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
 #ifdef DOTRACE	
 		write(tech_pvt->fd, bp, (int) globals.mtu);
 #endif
 		towrite = bytes >= globals.mtu ? globals.mtu : bytes;
 
+		if (towrite < globals.mtu) {
+			int diff = globals.mtu - towrite;
+			memset(bp + towrite, 0, diff);
+			towrite = globals.mtu;
+		}
+
 		result = sangoma_sendmsg_socket(tech_pvt->socket,
 									 &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, towrite, 0);
 		if (result < 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-								  "Bad Write frame len %u write %d bytes returned %d (%s)!\n", frame->datalen,
+								  "Bad Write frame len %u write %d bytes returned %d (%s)!\n", towrite,
 								  globals.mtu, result, strerror(errno));
 			if (errno == EBUSY) {
 				continue;
@@ -599,11 +609,11 @@
 	return status;
 }
 
-static switch_status wanpipe_send_dtmf(switch_core_session *session, char *digits)
+static switch_status_t wanpipe_send_dtmf(switch_core_session_t *session, char *digits)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	int wrote = 0;
 	char *cur = NULL;
 
@@ -615,7 +625,7 @@
 
 	if (!tech_pvt->dtmf_buffer) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocate DTMF Buffer....");
-		if (switch_buffer_create(switch_core_session_get_pool(session), &tech_pvt->dtmf_buffer, 3192) != SWITCH_STATUS_SUCCESS) {
+		if (switch_buffer_create_dynamic(&tech_pvt->dtmf_buffer, 1024, 3192, 0) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Failed to allocate DTMF Buffer!\n");
 			return SWITCH_STATUS_FALSE;
 		} else {
@@ -633,15 +643,15 @@
 	return status;
 }
 
-static switch_status wanpipe_receive_message(switch_core_session *session, switch_core_session_message *msg)
+static switch_status_t wanpipe_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
 {
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status wanpipe_kill_channel(switch_core_session *session, int sig)
+static switch_status_t wanpipe_kill_channel(switch_core_session_t *session, int sig)
 {
 	struct private_object *tech_pvt;
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -649,15 +659,19 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
+	switch_mutex_lock(tech_pvt->flag_mutex);
 	switch_set_flag(tech_pvt, TFLAG_BYE);
 	switch_clear_flag(tech_pvt, TFLAG_MEDIA);
+	switch_mutex_unlock(tech_pvt->flag_mutex);
 
+	sangoma_socket_close(&tech_pvt->socket);
+
 	return SWITCH_STATUS_SUCCESS;
 
 }
 
 
-static const switch_io_routines wanpipe_io_routines = {
+static const switch_io_routines_t wanpipe_io_routines = {
 	/*.outgoing_channel */ wanpipe_outgoing_channel,
 	/*.answer_channel */ wanpipe_answer_channel,
 	/*.read_frame */ wanpipe_read_frame,
@@ -669,7 +683,7 @@
 	/*.receive_message*/ wanpipe_receive_message
 };
 
-static const switch_state_handler_table wanpipe_state_handlers = {
+static const switch_state_handler_table_t wanpipe_state_handlers = {
 	/*.on_init */ wanpipe_on_init,
 	/*.on_ring */ wanpipe_on_ring,
 	/*.on_execute */ NULL,
@@ -678,7 +692,7 @@
 	/*.on_transmit */ wanpipe_on_transmit
 };
 
-static const switch_endpoint_interface wanpipe_endpoint_interface = {
+static const switch_endpoint_interface_t wanpipe_endpoint_interface = {
 	/*.interface_name */ "wanpipe",
 	/*.io_routines */ &wanpipe_io_routines,
 	/*.state_handlers */ &wanpipe_state_handlers,
@@ -686,7 +700,7 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface wanpipe_module_interface = {
+static const switch_loadable_module_interface_t wanpipe_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &wanpipe_endpoint_interface,
 	/*.timer_interface */ NULL,
@@ -696,8 +710,8 @@
 };
 
 
-static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-											  switch_core_session **new_session, switch_memory_pool *pool)
+static switch_status_t wanpipe_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
+											  switch_core_session_t **new_session, switch_memory_pool_t *pool)
 {
 	char *bchan = NULL;
 	char name[128] = "";
@@ -723,11 +737,12 @@
 
 	if ((*new_session = switch_core_session_request(&wanpipe_endpoint_interface, pool))) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
+		switch_channel_t *channel;
 
 		switch_core_session_add_stream(*new_session, NULL);
 		if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
 			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;
@@ -739,7 +754,7 @@
 
 		
 		if (outbound_profile) {
-			switch_caller_profile *caller_profile;
+			switch_caller_profile_t *caller_profile;
 			struct sangoma_pri *spri;
 			int span = 0, autospan = 0, autochan = 0;
 			char *num, *p;
@@ -790,14 +805,14 @@
 
 			if (bchan) {
 				int chan, span;
-				sangoma_span_chan_fromif(bchan, &span, &chan);
+				
 				if (sangoma_span_chan_fromif(bchan, &span, &chan)) {
 					if ((tech_pvt->socket = sangoma_open_tdmapi_span_chan(span, chan)) < 0) {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd!\n");
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", span, chan, strerror(errno));
 						switch_core_session_destroy(new_session);
 						return SWITCH_STATUS_GENERR;
 					}
-					switch_set_flag(tech_pvt, TFLAG_NOSIG);
+					switch_set_flag_locked(tech_pvt, TFLAG_NOSIG);
 					snprintf(name, sizeof(name), "WanPipe/%s/nosig-%04x", bchan, rand() & 0xffff);
 					switch_channel_set_name(channel, name);			
 					switch_channel_set_caller_profile(channel, caller_profile);
@@ -892,7 +907,7 @@
 		}
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -914,9 +929,9 @@
 	s_pri_error(pri, s);
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
 {
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	memset(SPANS, 0, sizeof(SPANS));
 
@@ -959,12 +974,12 @@
 static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
 	struct channel_map *chanmap;
-	switch_core_session *session;
+	switch_core_session_t *session;
 	struct private_object *tech_pvt;
 
 	chanmap = spri->private_info;
 	if ((session = chanmap->map[event->hangup.channel])) {
-		switch_channel *channel = NULL;
+		switch_channel_t *channel = NULL;
 
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
@@ -978,7 +993,8 @@
 
 		tech_pvt->cause = event->hangup.cause;
 
-		switch_channel_set_state(channel, CS_HANGUP);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+
 		chanmap->map[event->hangup.channel] = NULL;
 	}
 
@@ -988,8 +1004,8 @@
 
 static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
-	switch_core_session *session;
-	switch_channel *channel;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
 	struct channel_map *chanmap;
 
 
@@ -1010,21 +1026,21 @@
 
 static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
-	switch_core_session *session;
-	switch_channel *channel;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
 	struct channel_map *chanmap;
 
 	chanmap = spri->private_info;
 
 	if ((session = chanmap->map[event->proceeding.channel])) {
-		switch_caller_profile *originator;
+		switch_caller_profile_t *originator;
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, event->proceeding.channel);
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
 		
 		if ((originator = switch_channel_get_originator_caller_profile(channel))) {
-			switch_core_session_message msg;
+			switch_core_session_message_t msg;
 
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Passing progress to Originator %s\n", originator->chan_name);
 
@@ -1047,8 +1063,8 @@
 #if 0
 static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
-	switch_core_session *session;
-	switch_channel *channel;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
 	struct channel_map *chanmap;
 	struct private_object *tech_pvt;
 
@@ -1079,8 +1095,8 @@
 static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
 	char name[128];
-	switch_core_session *session;
-	switch_channel *channel;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
 	struct channel_map *chanmap;
 
 
@@ -1108,6 +1124,7 @@
 		switch_core_session_add_stream(session, NULL);
 		if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
 			memset(tech_pvt, 0, sizeof(*tech_pvt));
+			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 			channel = switch_core_session_get_channel(session);
 			switch_core_session_set_private(session, tech_pvt);
 			sprintf(name, "s%dc%d", spri->span, event->ring.channel);
@@ -1124,17 +1141,21 @@
 		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																  NULL,
 																  globals.dialplan,
-																  "N/A",
+																  "FreeSWITCH",
 																  event->ring.callingnum,
 																  event->ring.callingani,
 																  switch_strlen_zero(ani2str) ? NULL : ani2str,
 																  NULL,
+																  NULL,
+																  (char *)modname,
+																  NULL,
 																  event->ring.callednum))) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
-		switch_set_flag(tech_pvt, TFLAG_INBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_INBOUND);
 		tech_pvt->spri = spri;
 		tech_pvt->cause = -1;
 
@@ -1172,7 +1193,7 @@
 static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
 {
 	int fd;
-	switch_core_session *session;
+	switch_core_session_t *session;
 	struct channel_map *chanmap;
 
 
@@ -1186,10 +1207,10 @@
 	chanmap = spri->private_info;
 	
 	if ((session = chanmap->map[event->restart.channel])) {
-		switch_channel *channel;
+		switch_channel_t *channel;
 		channel = switch_core_session_get_channel(session);
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hanging Up channel %s\n", switch_channel_get_name(channel));
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 	}
 	
 	if ((fd = sangoma_open_tdmapi_span_chan(spri->span, event->restart.channel)) < 0) {
@@ -1231,12 +1252,12 @@
 }
 
 
-static void *pri_thread_run(switch_thread *thread, void *obj)
+static void *pri_thread_run(switch_thread_t *thread, void *obj)
 {
 	struct sangoma_pri *spri = obj;
 	struct channel_map chanmap;
 
-	switch_event *s_event;
+	switch_event_t *s_event;
 	SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_ANY, on_anything);
 	SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RING, on_ring);
 	//SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RINGING, on_ringing);
@@ -1266,46 +1287,58 @@
 
 static void pri_thread_launch(struct sangoma_pri *spri)
 {
-	switch_thread *thread;
+	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);
 	switch_thread_create(&thread, thd_attr, pri_thread_run, spri, module_pool);
 
 }
 
-static switch_status config_wanpipe(int reload)
+static switch_status_t config_wanpipe(int reload)
 {
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "wanpipe.conf";
 	int current_span = 0;
+	switch_xml_t cfg, xml, settings, param, span;
 
 	globals.mtu = DEFAULT_MTU;
 	globals.dtmf_on = 150;
 	globals.dtmf_off = 50;
 
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+
+	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 (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
 			} else if (!strcmp(var, "mtu")) {
 				globals.mtu = atoi(val);
-			} else if (!strcmp(var, "dtmf_on")) {
+			} else if (!strcmp(var, "dtmf-on")) {
 				globals.dtmf_on = atoi(val);
-			} else if (!strcmp(var, "dtmf_off")) {
+			} else if (!strcmp(var, "dtmf-off")) {
 				globals.dtmf_off = atoi(val);
-			} else if (!strcmp(var, "supress_dtmf_tone")) {
+			} else if (!strcmp(var, "supress-dtmf-tone")) {
 				globals.supress_dtmf_tone = switch_true(val);
 			}
-		} else if (!strcasecmp(cfg.category, "span")) {
+		}
+	}
+
+	
+	for (span = switch_xml_child(cfg, "span"); span; span = span->next) {
+		for (param = switch_xml_child(span, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+
 			if (!strcmp(var, "span")) {
 				current_span = atoi(val);
 				if (current_span <= 0 || current_span > MAX_SPANS) {
@@ -1375,7 +1408,7 @@
 			}
 		}
 	}
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	if (!globals.dialplan) {
 		set_global_dialplan("default");

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.c	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.c	Fri Sep 22 14:22:15 2006
@@ -50,7 +50,7 @@
 
 static const char modname[] = "mod_woomera";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 #define STRLEN 15
 #define FRAME_LEN 480
@@ -130,10 +130,10 @@
 
 struct private_object {
 	char *name;
-	switch_frame frame;
-	switch_codec read_codec;
-	switch_codec write_codec;
-	switch_core_session *session;
+	switch_frame_t frame;
+	switch_codec_t read_codec;
+	switch_codec_t write_codec;
+	switch_core_session_t *session;
 	switch_pollfd_t read_poll;
 	switch_pollfd_t write_poll;
 	switch_pollfd_t command_poll;
@@ -152,8 +152,9 @@
 	switch_time_t started;
 	int timeout;
 	char dtmfbuf[WOOMERA_STRLEN];
-	switch_caller_profile *caller_profile;
+	switch_caller_profile_t *caller_profile;
 	struct woomera_event_queue event_queue;
+	switch_mutex_t *flag_mutex;
 };
 
 typedef struct private_object private_object;
@@ -163,18 +164,18 @@
 
 static woomera_profile default_profile;
 
-static switch_status woomerachan_on_init(switch_core_session *session);
-static switch_status woomerachan_on_hangup(switch_core_session *session);
-static switch_status woomerachan_on_ring(switch_core_session *session);
-static switch_status woomerachan_on_loopback(switch_core_session *session);
-static switch_status woomerachan_on_transmit(switch_core_session *session);
-static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-												  switch_core_session **new_session, switch_memory_pool *pool);
-static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-											switch_io_flag flags, int stream_id);
-static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-											 switch_io_flag flags, int stream_id);
-static switch_status woomerachan_kill_channel(switch_core_session *session, int sig);
+static switch_status_t woomerachan_on_init(switch_core_session_t *session);
+static switch_status_t woomerachan_on_hangup(switch_core_session_t *session);
+static switch_status_t woomerachan_on_ring(switch_core_session_t *session);
+static switch_status_t woomerachan_on_loopback(switch_core_session_t *session);
+static switch_status_t woomerachan_on_transmit(switch_core_session_t *session);
+static switch_status_t woomerachan_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 woomerachan_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 woomerachan_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 woomerachan_kill_channel(switch_core_session_t *session, int sig);
 static void tech_destroy(private_object * tech_pvt);
 static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...);
 static char *woomera_message_header(woomera_message * wmsg, char *key);
@@ -186,7 +187,7 @@
 static int woomera_profile_thread_running(woomera_profile * profile, int set, int new);
 static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **woomera_socket);
 static int tech_create_read_socket(private_object * tech_pvt);
-static void *woomera_channel_thread_run(switch_thread *thread, void *obj);
+static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj);
 static void *woomera_thread_run(void *obj);
 static int tech_activate(private_object * tech_pvt);
 
@@ -195,9 +196,9 @@
    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 woomerachan_on_init(switch_core_session *session)
+static switch_status_t woomerachan_on_init(switch_core_session_t *session)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	struct private_object *tech_pvt = NULL;
 	int rate = 8000;
 
@@ -213,7 +214,7 @@
 		(&tech_pvt->read_codec, "L16", rate, 30, 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_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -221,7 +222,7 @@
 		(&tech_pvt->write_codec, "L16", rate, 30, 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_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 	tech_pvt->frame.rate = rate;
@@ -230,7 +231,7 @@
 	switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
 
 
-	switch_set_flag(tech_pvt, TFLAG_ACTIVATE);
+	switch_set_flag_locked(tech_pvt, TFLAG_ACTIVATE);
 
 	switch_core_session_launch_thread(session, woomera_channel_thread_run, session);
 
@@ -239,9 +240,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_on_ring(switch_core_session *session)
+static switch_status_t woomerachan_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -255,10 +256,10 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_on_execute(switch_core_session *session)
+static switch_status_t woomerachan_on_execute(switch_core_session_t *session)
 {
 
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -273,9 +274,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_on_hangup(switch_core_session *session)
+static switch_status_t woomerachan_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -311,9 +312,9 @@
 }
 
 
-static switch_status woomerachan_kill_channel(switch_core_session *session, int sig)
+static switch_status_t woomerachan_kill_channel(switch_core_session_t *session, int sig)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -328,7 +329,7 @@
 
 	udp_socket_close(tech_pvt);
 
-	switch_channel_hangup(channel);
+	switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERACHAN KILL\n", switch_channel_get_name(channel));
 						  
 
@@ -336,19 +337,19 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_on_loopback(switch_core_session *session)
+static switch_status_t woomerachan_on_loopback(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WOOMERACHAN LOOPBACK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_on_transmit(switch_core_session *session)
+static switch_status_t woomerachan_on_transmit(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WOOMERACHAN TRANSMIT\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_waitfor_read(switch_core_session *session, int ms, int stream_id)
+static switch_status_t woomerachan_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -358,7 +359,7 @@
 	return switch_socket_waitfor(&tech_pvt->read_poll, ms) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status woomerachan_waitfor_write(switch_core_session *session, int ms, int stream_id)
+static switch_status_t woomerachan_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
 {
 	struct private_object *tech_pvt = NULL;
 
@@ -369,12 +370,13 @@
 //	return switch_socket_waitfor(&tech_pvt->write_poll, ms);
 }
 
-static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
-											switch_io_flag flags, int stream_id)
+static switch_status_t woomerachan_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
+											switch_io_flag_t flags, int stream_id)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	switch_frame *pframe;
+	switch_frame_t *pframe;
+	switch_size_t len;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -393,8 +395,9 @@
 	pframe = &tech_pvt->frame;
 	*frame = pframe;
 
-	pframe->datalen = sizeof(tech_pvt->databuf);
-	if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &pframe->datalen) == SWITCH_STATUS_SUCCESS) {
+	len = sizeof(tech_pvt->databuf);
+	if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) == SWITCH_STATUS_SUCCESS) {
+		pframe->datalen = (uint32_t)len;
 		pframe->samples = (int) pframe->datalen / 2;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -402,13 +405,14 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
-											 switch_io_flag flags, int stream_id)
+static switch_status_t woomerachan_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
+											 switch_io_flag_t flags, int stream_id)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
-	//switch_frame *pframe;
-
+	switch_size_t len;
+	//switch_frame_t *pframe;
+	
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -420,14 +424,16 @@
 	}
 
 	//pframe = &tech_pvt->frame;
-	if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &frame->datalen) == SWITCH_STATUS_SUCCESS) {
+	len = frame->datalen;
+	if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &len) == SWITCH_STATUS_SUCCESS) {
+		frame->datalen = (uint32_t)len;
 		return SWITCH_STATUS_SUCCESS;
 	}
 
 	return SWITCH_STATUS_GENERR;
 }
 
-static const switch_state_handler_table woomerachan_event_handlers = {
+static const switch_state_handler_table_t woomerachan_event_handlers = {
 	/*.on_init */ woomerachan_on_init,
 	/*.on_ring */ woomerachan_on_ring,
 	/*.on_execute */ woomerachan_on_execute,
@@ -436,7 +442,7 @@
 	/*.on_transmit */ woomerachan_on_transmit
 };
 
-static const switch_io_routines woomerachan_io_routines = {
+static const switch_io_routines_t woomerachan_io_routines = {
 	/*.outgoing_channel */ woomerachan_outgoing_channel,
 	/*.answer_channel */ NULL,
 	/*.read_frame */ woomerachan_read_frame,
@@ -446,7 +452,7 @@
 	/*.waitfor_write */ woomerachan_waitfor_write
 };
 
-static const switch_endpoint_interface woomerachan_endpoint_interface = {
+static const switch_endpoint_interface_t woomerachan_endpoint_interface = {
 	/*.interface_name */ "woomera",
 	/*.io_routines */ &woomerachan_io_routines,
 	/*.event_handlers */ &woomerachan_event_handlers,
@@ -454,7 +460,7 @@
 	/*.next */ NULL
 };
 
-static const switch_loadable_module_interface woomerachan_module_interface = {
+static const switch_loadable_module_interface_t woomerachan_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ &woomerachan_endpoint_interface,
 	/*.timer_interface */ NULL,
@@ -467,17 +473,18 @@
 /* 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_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
-												  switch_core_session **new_session, switch_memory_pool *pool)
+static switch_status_t woomerachan_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(&woomerachan_endpoint_interface, pool)) != 0) {
 		struct private_object *tech_pvt;
-		switch_channel *channel;
+		switch_channel_t *channel;
 
 		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));
+			switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
 			tech_pvt->profile = &default_profile;
 			channel = switch_core_session_get_channel(*new_session);
 			switch_core_session_set_private(*new_session, tech_pvt);
@@ -490,7 +497,7 @@
 
 		if (outbound_profile) {
 			char name[128];
-			switch_caller_profile *caller_profile;
+			switch_caller_profile_t *caller_profile;
 
 			snprintf(name, sizeof(name), "Woomera/%s-%04x", outbound_profile->destination_number, rand() & 0xffff);
 			switch_channel_set_name(channel, name);
@@ -505,7 +512,7 @@
 		}
 
 		switch_channel_set_flag(channel, CF_OUTBOUND);
-		switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 		switch_channel_set_state(channel, CS_INIT);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -853,7 +860,7 @@
 
 static int tech_create_read_socket(private_object * tech_pvt)
 {
-	switch_memory_pool *pool = switch_core_session_get_pool(tech_pvt->session);
+	switch_memory_pool_t *pool = switch_core_session_get_pool(tech_pvt->session);
 
 	if ((tech_pvt->port = globals.next_woomera_port++) >= WOOMERA_MAX_PORT) {
 		tech_pvt->port = globals.next_woomera_port = WOOMERA_MIN_PORT;
@@ -902,13 +909,13 @@
 			woomera_message_parse(tech_pvt->command_channel,
 								  &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue);
 		} else {
-			switch_set_flag(tech_pvt, TFLAG_PARSE_INCOMING);
+			switch_set_flag_locked(tech_pvt, TFLAG_PARSE_INCOMING);
 			woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
 			if (woomera_message_parse(tech_pvt->command_channel,
 									  &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
 									  tech_pvt->profile->name);
-				switch_set_flag(tech_pvt, TFLAG_ABORT);
+				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 			}
 		}
@@ -921,10 +928,10 @@
 
 
 
-static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
+static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
 {
-	switch_core_session *session = obj;
-	switch_channel *channel = NULL;
+	switch_core_session_t *session = obj;
+	switch_channel_t *channel = NULL;
 	struct private_object *tech_pvt = NULL;
 	woomera_message wmsg;
 	int res = 0;
@@ -944,24 +951,22 @@
 
 	for (;;) {
 		if (globals.panic) {
-			switch_set_flag(tech_pvt, TFLAG_ABORT);
+			switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_ABORT)) {
-			if (switch_channel_get_state(channel) < CS_HANGUP) {
-				switch_channel_set_state(channel, CS_HANGUP);
-			}
+			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			udp_socket_close(tech_pvt);
 			break;
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_ACTIVATE)) {
-			switch_clear_flag(tech_pvt, TFLAG_ACTIVATE);
+			switch_clear_flag_locked(tech_pvt, TFLAG_ACTIVATE);
 			tech_activate(tech_pvt);
 		}
 
 		if (switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
-			switch_clear_flag(tech_pvt, TFLAG_ANSWER);
+			switch_clear_flag_locked(tech_pvt, TFLAG_ANSWER);
 #ifdef USE_ANSWER
 			woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "ANSWER %s%s", tech_pvt->call_info.callid,
 						   WOOMERA_RECORD_SEPERATOR);
@@ -970,7 +975,7 @@
 				 &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
 									  tech_pvt->profile->name);
-				switch_set_flag(tech_pvt, TFLAG_ABORT);
+				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 				continue;
 			}
@@ -986,11 +991,11 @@
 				 &tech_pvt->event_queue) < 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
 									  tech_pvt->profile->name);
-				switch_set_flag(tech_pvt, TFLAG_ABORT);
+				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				globals.panic = 1;
 				continue;
 			}
-			switch_clear_flag(tech_pvt, TFLAG_DTMF);
+			switch_clear_flag_locked(tech_pvt, TFLAG_DTMF);
 			memset(tech_pvt->dtmfbuf, 0, sizeof(tech_pvt->dtmfbuf));
 			switch_mutex_unlock(tech_pvt->iolock);
 		}
@@ -1004,7 +1009,7 @@
 				 ((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
 			if (elapsed > tech_pvt->timeout) {
 				/* call timed out! */
-				switch_set_flag(tech_pvt, TFLAG_ABORT);
+				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 			}
 		}
 #endif
@@ -1017,7 +1022,7 @@
 			(res = woomera_message_parse(tech_pvt->command_channel, &wmsg, 100, tech_pvt->profile, NULL)) != 0) {
 
 			if (res < 0 || !strcasecmp(wmsg.command, "HANGUP")) {
-				switch_set_flag(tech_pvt, TFLAG_ABORT);
+				switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 				continue;
 			} else if (!strcasecmp(wmsg.command, "DTMF")) {
 				/*
@@ -1040,8 +1045,8 @@
 				char *cid_num;
 				char *ip;
 				char *p;
-				switch_clear_flag(tech_pvt, TFLAG_PARSE_INCOMING);
-				switch_set_flag(tech_pvt, TFLAG_INCOMING);
+				switch_clear_flag_locked(tech_pvt, TFLAG_PARSE_INCOMING);
+				switch_set_flag_locked(tech_pvt, TFLAG_INCOMING);
 				tech_pvt->call_info = wmsg;
 
 				exten = woomera_message_header(&wmsg, "Local-Number");
@@ -1062,8 +1067,9 @@
 				ip = woomera_message_header(&wmsg, "Remote-Address");
 
 				if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																		  NULL,
 																		  tech_pvt->profile->dialplan,
-																		  cid_name, cid_num, ip, NULL, NULL, exten)) != 0) {
+																		  cid_name, cid_num, ip, NULL, NULL, NULL, (char *)modname, NULL, exten)) != 0) {
 					char name[128];
 					snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
 							 rand() & 0xffff);
@@ -1084,7 +1090,7 @@
 										  &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
 										  tech_pvt->profile->name);
-					switch_set_flag(tech_pvt, TFLAG_ABORT);
+					switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
 					globals.panic = 1;
 					continue;
 				}
@@ -1121,7 +1127,7 @@
 												  WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
 												  tech_pvt->profile->name, ip);
 						}
-						switch_channel_hangup(channel);
+						switch_channel_hangup(channel, SWITCH_CAUSE_NETWORK_OUT_OF_ORDER);
 					}
 				}
 			}
@@ -1222,7 +1228,7 @@
 
 			if (!strcasecmp(wmsg.command, "INCOMING")) {
 				char *name;
-				switch_core_session *session;
+				switch_core_session_t *session;
 
 				if ((name = woomera_message_header(&wmsg, "Remote-Address")) == 0) {
 					name = woomera_message_header(&wmsg, "Channel-Name");
@@ -1231,13 +1237,14 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", name);
 				if ((session = switch_core_session_request(&woomerachan_endpoint_interface, NULL)) != 0) {
 					struct private_object *tech_pvt;
-					switch_channel *channel;
+					switch_channel_t *channel;
 
 					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));
 						tech_pvt->profile = &default_profile;
 						channel = switch_core_session_get_channel(session);
 						switch_core_session_set_private(session, tech_pvt);
@@ -1271,7 +1278,7 @@
 	return NULL;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 
 	woomera_thread_run(&default_profile);
@@ -1279,7 +1286,7 @@
 	return SWITCH_STATUS_TERM;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	int x = 0;
 	woomera_profile_thread_running(&default_profile, 1, 0);
@@ -1293,18 +1300,17 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
-	switch_config cfg;
-	char *var, *val;
 	struct woomera_profile *profile = &default_profile;
 	char *cf = "woomera.conf";
+	switch_xml_t cfg, xml, settings, param, xmlp;
 
 	memset(&globals, 0, sizeof(globals));
 	globals.next_woomera_port = WOOMERA_MIN_PORT;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
@@ -1312,17 +1318,29 @@
 	switch_set_flag(profile, PFLAG_INBOUND | PFLAG_OUTBOUND);
 	profile->name = "main";
 	strncpy(profile->dialplan, "default", sizeof(profile->dialplan) - 1);
+	strncpy(profile->audio_ip, "127.0.0.1", sizeof(profile->audio_ip) - 1);
+	strncpy(profile->woomera_host, "127.0.0.1", sizeof(profile->woomera_host) - 1);
+	profile->woomera_port = (switch_port_t)42420;
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "noload") && atoi(val)) {
 				return SWITCH_STATUS_TERM;
 			}
 			if (!strcmp(var, "debug")) {
 				globals.debug = atoi(val);
 			}
-		} else if (!strcasecmp(cfg.category, "profile")) {
-			if (!strcmp(var, "audio_ip")) {
+		}
+	}
+
+	for (xmlp = switch_xml_child(cfg, "interface"); xmlp; xmlp = xmlp->next) {
+		for (param = switch_xml_child(xmlp, "param"); param; param = param->next) {
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
+			if (!strcmp(var, "audio-ip")) {
 				strncpy(profile->audio_ip, val, sizeof(profile->audio_ip) - 1);
 			} else if (!strcmp(var, "host")) {
 				strncpy(profile->woomera_host, val, sizeof(profile->woomera_host) - 1);
@@ -1346,7 +1364,7 @@
 		}
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
@@ -1368,7 +1386,7 @@
 
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &woomerachan_module_interface;
+	*module_interface = &woomerachan_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/endpoints/mod_woomera/mod_woomera.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_woomera.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_woomera.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_woomera.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_woomera.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c	Fri Sep 22 14:22:15 2006
@@ -33,7 +33,7 @@
 
 static const char modname[] = "mod_event_multicast";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 static struct {
 	char *address;
@@ -48,14 +48,13 @@
 #define MULTICAST_EVENT "multicast::event"
 
 
-static switch_status load_config(void)
+static switch_status_t load_config(void)
 {
-	switch_config cfg;
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	char *var, *val;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	char *cf = "event_multicast.conf";
+	switch_xml_t cfg, xml, settings, param;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
@@ -64,9 +63,12 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
 		return SWITCH_STATUS_GENERR;
 	}
+	
+	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");
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
 			if (!strcasecmp(var, "address")) {
 				set_global_address(val);
 			} else if (!strcasecmp(var, "port")) {
@@ -75,13 +77,13 @@
 		}
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	return status;
 
 }
 
-static void event_handler(switch_event *event)
+static void event_handler(switch_event_t *event)
 {
 	char buf[1024];
 	size_t len;
@@ -105,7 +107,7 @@
 }
 
 
-static switch_loadable_module_interface event_test_module_interface = {
+static switch_loadable_module_interface_t event_test_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -115,7 +117,7 @@
 };
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 	memset(&globals, 0, sizeof(globals));
 	
@@ -159,7 +161,7 @@
 
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &event_test_module_interface;
+	*module_interface = &event_test_module_interface;
 
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
 		SWITCH_STATUS_SUCCESS) {
@@ -173,7 +175,7 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	int x = 0;
 
@@ -187,9 +189,9 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
-	switch_event *local_event;
+	switch_event_t *local_event;
 	char buf[1024];
 	
 	globals.running = 1;

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_event_multicast.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_event_multicast.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_event_multicast.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_event_multicast.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.c	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.c	Fri Sep 22 14:22:15 2006
@@ -36,23 +36,41 @@
 //#define TORTURE_ME
 
 
-static void event_handler(switch_event *event)
+static void event_handler(switch_event_t *event)
 {
 	char buf[1024];
+	switch_xml_t xml;
+	char *xmlstr = "N/A";
+	uint8_t dofree = 0;
 
 	switch (event->event_id) {
 	case SWITCH_EVENT_LOG:
 		return;
 	default:
 		switch_event_serialize(event, buf, sizeof(buf), NULL);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT\n--------------------------------\n%s\n", buf);
+		if ((xml = switch_event_xmlize(event, NULL))) {
+			xmlstr = switch_xml_toxml(xml);
+			dofree++;
+		}
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (text version)\n--------------------------------\n%s", buf);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
 		break;
 	}
+
+	if (dofree) {
+		if (xml) {
+			switch_xml_free(xml);
+		}
+		if (xmlstr) {
+			free(xmlstr);
+		}
+	}
 }
 
 
 
-static switch_loadable_module_interface event_test_module_interface = {
+static switch_loadable_module_interface_t event_test_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -68,12 +86,12 @@
 #define TTHREADS 500
 static int THREADS = 0;
 
-static void *torture_thread(switch_thread *thread, void *obj)
+static void *torture_thread(switch_thread_t *thread, void *obj)
 {
 	int y = 0;
 	int z = 0;
-	switch_core_thread_session *ts = obj;
-	switch_event *event;
+	switch_core_thread_session_t *ts = obj;
+	switch_event_t *event;
 
 	z = THREADS++;
 
@@ -89,14 +107,14 @@
 	}
 
 	if (ts->pool) {
-		switch_memory_pool *pool = ts->pool;
+		switch_memory_pool_t *pool = ts->pool;
 		switch_core_destroy_memory_pool(&pool);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread Ended\n");
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	THREADS = -1;
 	switch_yield(100000);
@@ -105,10 +123,10 @@
 #endif
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &event_test_module_interface;
+	*module_interface = &event_test_module_interface;
 
 	if (switch_event_reserve_subclass(MY_EVENT_COOL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_event_test/mod_event_test.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_event_test.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_event_test.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_event_test.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_event_test.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c	Fri Sep 22 14:22:15 2006
@@ -58,7 +58,7 @@
 	struct session session;
 } globals;
 
-static void event_handler(switch_event *event)
+static void event_handler(switch_event_t *event)
 {
 	char buf[1024];
 	iks *msg;
@@ -95,27 +95,29 @@
 	SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_passwd, globals.passwd)
 
 
-	 static switch_status load_config(void)
+	 static switch_status_t load_config(void)
 {
-	switch_config cfg;
-	switch_status status = SWITCH_STATUS_FALSE;
-	char *var, *val;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	char *cf = "xmpp_event.conf";
+	switch_xml_t cfg, xml, settings, param;
 	int count = 0;
 
 	memset(&globals, 0, sizeof(globals));
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "jid")) {
 				set_global_jid(val);
 				count++;
-			} else if (!strcmp(var, "target_jid")) {
+			} else if (!strcmp(var, "target-jid")) {
 				set_global_target_jid(val);
 				count++;
 			} else if (!strcmp(var, "passwd")) {
@@ -127,7 +129,7 @@
 		}
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	if (count == 3) {
 		/* TBD use config to pick what events to bind to */
@@ -146,7 +148,18 @@
 
 static int on_result(struct session *sess, ikspak * pak)
 {
+	iks *msg, *ctag;
 
+	msg = iks_make_pres (IKS_SHOW_AVAILABLE, "Available"); 
+	ctag = iks_insert(msg, "c");
+	iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps");
+	iks_insert_attrib(ctag, "ver", "1.0.0.1");
+	iks_insert_attrib(ctag, "client", "libdingaling");
+	iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
+
+	iks_send(sess->parser, msg);
+    iks_delete(msg);
+
 	return IKS_FILTER_EAT;
 }
 
@@ -216,12 +229,31 @@
 	return IKS_OK;
 }
 
+
+static int on_subscribe(void *user_data, ikspak *pak)
+{
+	char *from = iks_find_attrib(pak->x, "from");
+	struct session *sess = (struct session *) user_data;
+
+	iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "mod_xmpp_event"); 
+	iks_send(sess->parser, msg);
+	iks_delete(msg);
+		
+	msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, from, "mod_xmpp_event"); 
+	iks_send(sess->parser, msg);
+	iks_delete(msg);
+
+	return IKS_FILTER_EAT;
+}
+
 static int on_msg(void *user_data, ikspak * pak)
 {
 	char *cmd = iks_find_cdata(pak->x, "body");
 	char *arg = NULL;
-	char retbuf[1024] = "";
+	switch_stream_handle_t stream = {0};
+	char retbuf[2048] = "";
 	char *p;
+	iks *msg;
 
 	if ((p = strchr(cmd, '\r')) != 0) {
 		*p++ = '\0';
@@ -233,8 +265,19 @@
 		*arg++ = '\0';
 	}
 
-	switch_api_execute(cmd, arg, retbuf, sizeof(retbuf));
+	stream.data = retbuf;
+	stream.end = stream.data;
+	stream.data_size = sizeof(retbuf);
+	stream.write_function = switch_console_stream_write;
+	switch_api_execute(cmd, arg, NULL, &stream);
 
+	
+	msg = iks_make_msg(IKS_TYPE_NONE, globals.target_jid, retbuf);
+	iks_insert_attrib(msg, "subject", "Reply");
+	iks_send(globals.session.parser, msg);
+	iks_delete(msg);
+	
+
 	return 0;
 }
 
@@ -269,6 +312,12 @@
 	iks_filter_add_rule(my_filter, on_error, sess,
 						IKS_RULE_TYPE, IKS_PAK_IQ,
 						IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
+
+	iks_filter_add_rule(my_filter, on_subscribe, sess,
+						IKS_RULE_TYPE, IKS_PAK_S10N,
+						IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE,
+						IKS_RULE_DONE);
+
 }
 
 static void xmpp_connect(char *jabber_id, char *pass)
@@ -346,7 +395,7 @@
 
 }
 
-static switch_loadable_module_interface xmpp_event_module_interface = {
+static switch_loadable_module_interface_t xmpp_event_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -355,10 +404,10 @@
 	/*.application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **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 */
-	*interface = &xmpp_event_module_interface;
+	*module_interface = &xmpp_event_module_interface;
 
 	if (load_config() != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
@@ -369,7 +418,7 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 
 	if (RUNNING) {
@@ -382,7 +431,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	RUNNING = 1;
 	xmpp_connect(globals.jid, globals.passwd);

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_XMPPEvent Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +64,13 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="FreeSwitchCore.lib iksemel.lib Ws2_32.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xmpp_event.dll"
-				LinkIncremental="2"
+				AdditionalDependencies="Ws2_32.lib"
+				ShowProgress="0"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;;&quot;..\..\..\..\libs\iksemel\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_xmpp_event.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_xmpp_event.lib"
 				TargetMachine="1"
@@ -101,15 +102,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_XMPPEvent Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -125,7 +126,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\iksemel-1.2\include&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
@@ -145,11 +146,13 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="FreeSwitchCore.lib iksemel.lib Ws2_32.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_xmpp_event.dll"
+				AdditionalDependencies="Ws2_32.lib"
+				ShowProgress="0"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;;&quot;..\..\..\..\libs\iksemel\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c	Fri Sep 22 14:22:15 2006
@@ -34,7 +34,7 @@
 
 static const char modname[] = "mod_zeroconf";
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 static struct {
 	sw_discovery discovery;
@@ -121,7 +121,7 @@
 }
 
 
-static void event_handler(switch_event *event)
+static void event_handler(switch_event_t *event)
 {
 	sw_text_record text_record;	
 	sw_result result;
@@ -132,7 +132,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sw_text_record_init() failed\n");
 			return;
 		} else {
-			switch_event_header *hp;
+			switch_event_header_t *hp;
 			char *service = switch_event_get_header(event, "service");
 			char *port = switch_event_get_header(event, "port");
 			sw_port porti = 0;
@@ -191,22 +191,24 @@
 }
 
 
-static switch_status load_config(void)
+static switch_status_t load_config(void)
 {
-	switch_config cfg;
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	char *var, *val;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	char *cf = "zeroconf.conf";
 	int count = 0;
 	sw_discovery_oid *oid;
+	switch_xml_t cfg, xml, settings, param;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
 	}
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
+	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 (!strcmp(var, "browse")) {
 				if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bind browser to to %s\n", val);
@@ -233,14 +235,14 @@
 		}
 	}
 
-	switch_config_close_file(&cfg);
+	switch_xml_free(xml);
 
 	return status;
 
 }
 
 
-static switch_loadable_module_interface zeroconf_module_interface = {
+static switch_loadable_module_interface_t zeroconf_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -254,7 +256,7 @@
 
 static int RUNNING = 0;
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	if (RUNNING == 1) {
 		RUNNING = -1;
@@ -264,7 +266,7 @@
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	memset(&globals, 0, sizeof(globals));
@@ -296,14 +298,14 @@
 	}
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &zeroconf_module_interface;
+	*module_interface = &zeroconf_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 
 	RUNNING = 1;

Modified: freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs  Mod_zeroconf Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\howl\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\howl-1.0.0\include&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,12 +64,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies=" libhowld.lib libmDNSResponderd.lib Ws2_32.lib  iphlpapi.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_zeroconf.dll"
-				LinkIncremental="2"
+				AdditionalDependencies="Ws2_32.lib  iphlpapi.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\howl\src\lib\howl\Win32\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\howl\src\lib\mDNSResponder\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_zeroconf.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_zeroconf.lib"
 				TargetMachine="1"
@@ -101,15 +101,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs  Mod_zeroconf Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -125,7 +125,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\howl\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\howl-1.0.0\include&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -145,11 +145,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies=" libhowl.lib libmDNSResponder.lib Ws2_32.lib iphlpapi.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_zeroconf.dll"
+				AdditionalDependencies="Ws2_32.lib iphlpapi.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\libs\howl\src\lib\howl\Win32\$(OutDir)&quot;;&quot;$(InputDir)..\..\..\..\libs\howl\src\lib\mDNSResponder\Win32\$(OutDir)&quot;;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/formats/mod_sndfile/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/formats/mod_sndfile/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/formats/mod_sndfile/Makefile	Fri Sep 22 14:22:15 2006
@@ -3,7 +3,7 @@
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
 
 depends:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsndfile-1.0.12.tar.gz --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsndfile-1.0.16.tar.gz --prefix=$(PREFIX)
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o 

Modified: freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfile.c	(original)
+++ freeswitch/branches/voctel/src/mod/formats/mod_sndfile/mod_sndfile.c	Fri Sep 22 14:22:15 2006
@@ -41,7 +41,7 @@
 
 typedef struct sndfile_context sndfile_context;
 
-static switch_status sndfile_file_open(switch_file_handle *handle, char *path)
+static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *path)
 {
 	sndfile_context *context;
 	int mode = 0;
@@ -144,7 +144,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status sndfile_file_close(switch_file_handle *handle)
+static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
 {
 	sndfile_context *context = handle->private_info;
 
@@ -153,7 +153,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status sndfile_file_seek(switch_file_handle *handle, unsigned int *cur_sample, int64_t samples, int whence)
+static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
 {
 	sndfile_context *context = handle->private_info;
 
@@ -169,7 +169,7 @@
 
 }
 
-static switch_status sndfile_file_read(switch_file_handle *handle, void *data, size_t *len)
+static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len)
 {
 	size_t inlen = *len;
 	sndfile_context *context = handle->private_info;
@@ -191,7 +191,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status sndfile_file_write(switch_file_handle *handle, void *data, size_t *len)
+static switch_status_t sndfile_file_write(switch_file_handle_t *handle, void *data, size_t *len)
 {
 	size_t inlen = *len;
 	sndfile_context *context = handle->private_info;
@@ -213,22 +213,44 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t sndfile_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
+{
+	sndfile_context *context = handle->private_info;
+
+	return sf_set_string(context->handle, (int)col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+{
+	sndfile_context *context = handle->private_info;
+	const char *s;
+
+	if ((s = sf_get_string(context->handle, (int)col))) {
+		*string = s;
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
 /* Registration */
 
 static char **supported_formats;
 
-static switch_file_interface sndfile_file_interface = {
+static switch_file_interface_t sndfile_file_interface = {
 	/*.interface_name */ modname,
 	/*.file_open */ sndfile_file_open,
 	/*.file_close */ sndfile_file_close,
 	/*.file_read */ sndfile_file_read,
 	/*.file_write */ sndfile_file_write,
 	/*.file_seek */ sndfile_file_seek,
+	/*.file_set_string */ sndfile_file_set_string,
+	/*.file_get_string */ sndfile_file_get_string,
 	/*.extens */ NULL,
 	/*.next */ NULL,
 };
 
-static switch_loadable_module_interface sndfile_module_interface = {
+static switch_loadable_module_interface_t sndfile_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -239,7 +261,7 @@
 	/*.file_interface */ &sndfile_file_interface
 };
 
-static switch_status setup_formats(void)
+static switch_status_t setup_formats(void)
 {
 	SF_FORMAT_INFO info;
 	SF_INFO sfinfo;
@@ -265,7 +287,7 @@
 
 	sfinfo.channels = 1;
 	len = ((major_count + (exlen + 2)) * sizeof(char *));
-	supported_formats = switch_core_permenant_alloc(len);
+	supported_formats = switch_core_permanent_alloc(len);
 
 	len = 0;
 	for (m = 0; m < major_count; m++) {
@@ -309,7 +331,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 
@@ -319,7 +341,7 @@
 
 	/* connect my internal structure to the blank pointer passed to me */
 	sndfile_file_interface.extens = supported_formats;
-	*interface = &sndfile_module_interface;
+	*module_interface = &sndfile_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/Makefile	Fri Sep 22 14:22:15 2006
@@ -1,4 +1,4 @@
-PERL        =/usr/local/bin/perl
+PERL        = $(shell which perl)
 PERL_LIBDIR =-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE
 PERL_LIBS   =$(shell perl -MConfig -e 'print $$Config{libs}')
 CFLAGS  +=  -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts)
@@ -6,9 +6,10 @@
 LDFLAGS +=  $(shell $(PERL) -MExtUtils::Embed -e ldopts)
 LDFLAGS +=  $(shell $(PERL) -MConfig -e 'print $$Config{libs}')  
 OBJS += perlxsi.o
+SWIGCFILE=../../../switch_swig.c
+SWIGIFILE=../../../switch_swig.i
 
 
-
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) fs_perl.$(DYNAMIC_LIB_EXTEN)
 
 .perlok:
@@ -19,14 +20,17 @@
 depends:
 
 %.o:  %.c
-	$(CC) $(CFLAGS) -fPIC -c $< -o $@
+	$(CC) -fPIC $(CFLAGS) -c $< -o $@
 
 reswig: 
 	rm switch_swig_wrap.c
-	swig -DMULTIPLICITY -perl5 -module fs_perl switch_swig.c
+	swig -o switch_swig_wrap.c -l$(SWIGIFILE) -ignoremissing -DMULTIPLICITY -perl5 -module fs_perl $(SWIGCFILE)
 
+switch_swig.o: $(SWIGCFILE) Makefile
+	$(CC)  -w $(CFLAGS) -c $< -o $@
+
 switch_swig_wrap.o: switch_swig_wrap.c
-	$(CC) -w $(CFLAGS) -fPIC -c $< -o $@
+	$(CC) -w $(CFLAGS) -c $< -o $@
 
 
 fs_perl.$(DYNAMIC_LIB_EXTEN): $(MODNAME).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o
@@ -34,7 +38,7 @@
 
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS)
-	$(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN)  $(MODNAME).o $(OBJS) $(LDFLAGS)
+	$(CC) -fPIC $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN)  $(MODNAME).o $(OBJS) $(LDFLAGS)
 
 clean:
 	rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~ .perlok

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.pm
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.pm	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.pm	Fri Sep 22 14:22:15 2006
@@ -1,4 +1,5 @@
-# This file was automatically generated by SWIG
+# This file was created automatically by SWIG 1.3.29.
+# Don't modify this file, modify the SWIG interface instead.
 package fs_perl;
 require Exporter;
 require DynaLoader;
@@ -51,8 +52,8 @@
 *fs_loadable_module_init = *fs_perlc::fs_loadable_module_init;
 *fs_loadable_module_shutdown = *fs_perlc::fs_loadable_module_shutdown;
 *fs_console_loop = *fs_perlc::fs_console_loop;
-*fs_console_log = *fs_perlc::fs_console_log;
-*fs_console_clean = *fs_perlc::fs_console_clean;
+*fs_consol_log = *fs_perlc::fs_consol_log;
+*fs_consol_clean = *fs_perlc::fs_consol_clean;
 *fs_core_session_locate = *fs_perlc::fs_core_session_locate;
 *fs_channel_answer = *fs_perlc::fs_channel_answer;
 *fs_channel_pre_answer = *fs_perlc::fs_channel_pre_answer;
@@ -61,6 +62,16 @@
 *fs_channel_get_variable = *fs_perlc::fs_channel_get_variable;
 *fs_channel_set_state = *fs_perlc::fs_channel_set_state;
 *fs_ivr_play_file = *fs_perlc::fs_ivr_play_file;
+*fs_switch_ivr_record_file = *fs_perlc::fs_switch_ivr_record_file;
+*fs_switch_ivr_sleep = *fs_perlc::fs_switch_ivr_sleep;
+*fs_ivr_play_file2 = *fs_perlc::fs_ivr_play_file2;
+*fs_switch_ivr_collect_digits_callback = *fs_perlc::fs_switch_ivr_collect_digits_callback;
+*fs_switch_ivr_collect_digits_count = *fs_perlc::fs_switch_ivr_collect_digits_count;
+*fs_switch_ivr_originate = *fs_perlc::fs_switch_ivr_originate;
+*fs_switch_ivr_session_transfer = *fs_perlc::fs_switch_ivr_session_transfer;
+*fs_switch_ivr_speak_text = *fs_perlc::fs_switch_ivr_speak_text;
+*fs_switch_channel_get_variable = *fs_perlc::fs_switch_channel_get_variable;
+*fs_switch_channel_set_variable = *fs_perlc::fs_switch_channel_set_variable;
 
 # ------- VARIABLE STUBS --------
 

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/fs_perl.vcproj	Fri Sep 22 14:22:15 2006
@@ -50,7 +50,7 @@
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,8 +63,9 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="$(OutDir)\Perl\$(ProjectName).dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/Perl/$(InputName).dll"
+				Version=""
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\w32\vsnet\$(ConfigurationName)&quot;"
 				GenerateDebugInformation="true"
 				SubSystem="2"
@@ -142,7 +143,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="$(OutDir)\Perl\$(ProjectName).dll"
+				OutputFile="$(SolutionDir)$(OutDir)/Perl/$(InputName).dll"
+				Version=""
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(InputDir)..\..\..\..\w32\vsnet\$(ConfigurationName)&quot;"
 				GenerateDebugInformation="true"

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.c	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.c	Fri Sep 22 14:22:15 2006
@@ -63,7 +63,7 @@
 }
 
 
-static void perl_function(switch_core_session *session, char *data)
+static void perl_function(switch_core_session_t *session, char *data)
 {
 	char *uuid = switch_core_session_get_uuid(session);
 	char code[1024];
@@ -80,12 +80,12 @@
 	destroy_perl(&my_perl);
 }
 
-static const switch_application_interface perl_application_interface = {
+static const switch_application_interface_t perl_application_interface = {
 	/*.interface_name */ "perl",
 	/*.application_function */ perl_function
 };
 
-static switch_loadable_module_interface perl_module_interface = {
+static switch_loadable_module_interface_t perl_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -99,7 +99,7 @@
 };
 
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) 
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void) 
 {
 	if (globals.my_perl) {
 		perl_destruct(globals.my_perl);
@@ -110,7 +110,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
 	PerlInterpreter *my_perl;
@@ -133,7 +133,7 @@
 
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &perl_module_interface;
+	*module_interface = &perl_module_interface;
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/mod_perl.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -52,7 +52,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -65,11 +65,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_perl.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_perl.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_perl.lib"
 				TargetMachine="1"
@@ -101,8 +101,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -146,10 +146,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_perl.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/languages/mod_perl/switch_swig_wrap.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_perl/switch_swig_wrap.c	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_perl/switch_swig_wrap.c	Fri Sep 22 14:22:15 2006
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.26
+ * Version 1.3.29
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -8,20 +8,24 @@
  * interface file instead. 
  * ----------------------------------------------------------------------------- */
 
-/***********************************************************************
- *
+#define SWIGPERL
+#define SWIG_CASTRANK_MODE
+/* -----------------------------------------------------------------------------
  *  This section contains generic SWIG labels for method/variable
  *  declarations/attributes, and other compiler dependent labels.
- *
- ************************************************************************/
+ * ----------------------------------------------------------------------------- */
 
 /* template workaround for compilers that cannot correctly implement the C++ standard */
 #ifndef SWIGTEMPLATEDISAMBIGUATOR
-#  if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-#    define SWIGTEMPLATEDISAMBIGUATOR template
-#  else
-#    define SWIGTEMPLATEDISAMBIGUATOR 
-#  endif
+# if defined(__SUNPRO_CC)
+#   if (__SUNPRO_CC <= 0x560)
+#     define SWIGTEMPLATEDISAMBIGUATOR template
+#   else
+#     define SWIGTEMPLATEDISAMBIGUATOR 
+#   endif
+# else
+#   define SWIGTEMPLATEDISAMBIGUATOR 
+# endif
 #endif
 
 /* inline attribute */
@@ -35,13 +39,27 @@
 
 /* attribute recognised by some compilers to avoid 'unused' warnings */
 #ifndef SWIGUNUSED
-# if defined(__GNUC__) || defined(__ICC)
-#   define SWIGUNUSED __attribute__ ((unused)) 
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__)) 
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__)) 
 # else
 #   define SWIGUNUSED 
 # endif
 #endif
 
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
+# endif
+#endif
+
 /* internal SWIG method */
 #ifndef SWIGINTERN
 # define SWIGINTERN static SWIGUNUSED
@@ -52,7 +70,13 @@
 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
 #endif
 
-/* exporting methods for Windows DLLs */
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
 #ifndef SWIGEXPORT
 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 #   if defined(STATIC_LINKED)
@@ -61,7 +85,11 @@
 #     define SWIGEXPORT __declspec(dllexport)
 #   endif
 # else
-#   define SWIGEXPORT
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
 # endif
 #endif
 
@@ -74,14 +102,17 @@
 # endif 
 #endif
 
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
 
-/***********************************************************************
+/* -----------------------------------------------------------------------------
  * swigrun.swg
  *
- *     This file contains generic CAPI SWIG runtime support for pointer
- *     type checking.
- *
- ************************************************************************/
+ * This file contains generic CAPI SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
 
 /* This should only be incremented when either the layout of swig_type_info changes,
    or for whatever reason, the runtime changes incompatibly */
@@ -113,6 +144,147 @@
 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
 #endif
 
+/*  Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN        0x1
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN           0x1
+
+
+/* 
+   Flags/methods for returning states.
+   
+   The swig conversion methods, as ConvertPtr, return and integer 
+   that tells if the conversion was successful or not. And if not,
+   an error code can be returned (see swigerrors.swg for the codes).
+   
+   Use the following macros/flags to set or process the returning
+   states.
+   
+   In old swig versions, you usually write code as:
+
+     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+       // success code
+     } else {
+       //fail code
+     }
+
+   Now you can be more explicit as:
+
+    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+    } else {
+      // fail code
+    }
+
+   that seems to be the same, but now you can also do
+
+    Type *ptr;
+    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+      if (SWIG_IsNewObj(res) {
+        ...
+	delete *ptr;
+      } else {
+        ...
+      }
+    } else {
+      // fail code
+    }
+    
+   I.e., now SWIG_ConvertPtr can return new objects and you can
+   identify the case and take care of the deallocation. Of course that
+   requires also to SWIG_ConvertPtr to return new result values, as
+
+      int SWIG_ConvertPtr(obj, ptr,...) {         
+        if (<obj is ok>) {			       
+          if (<need new object>) {		       
+            *ptr = <ptr to new allocated object>; 
+            return SWIG_NEWOBJ;		       
+          } else {				       
+            *ptr = <ptr to old object>;	       
+            return SWIG_OLDOBJ;		       
+          } 				       
+        } else {				       
+          return SWIG_BADOBJ;		       
+        }					       
+      }
+
+   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+   swig errors code.
+
+   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+   allows to return the 'cast rank', for example, if you have this
+
+       int food(double)
+       int fooi(int);
+
+   and you call
+ 
+      food(1)   // cast rank '1'  (1 -> 1.0)
+      fooi(1)   // cast rank '0'
+
+   just use the SWIG_AddCast()/SWIG_CheckState()
+
+
+ */
+#define SWIG_OK                    (0) 
+#define SWIG_ERROR                 (-1)
+#define SWIG_IsOK(r)               (r >= 0)
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT         (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ                (SWIG_ERROR)
+#define SWIG_OLDOBJ                (SWIG_OK)
+#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+#  ifndef SWIG_TypeRank
+#    define SWIG_TypeRank             unsigned long
+#  endif
+#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
+#    define SWIG_MAXCASTRANK          (2)
+#  endif
+#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
+#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) { 
+  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) { 
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
+}
+#else /* no cast-rank mode */
+#  define SWIG_AddCast
+#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+
+
 #include <string.h>
 
 #ifdef __cplusplus
@@ -129,6 +301,7 @@
   swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
   struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
   void                   *clientdata;		/* language specific type data */
+  int                    owndata;		/* flag if the structure owns the clientdata */
 } swig_type_info;
 
 /* Structure to store a type and conversion function used for casting */
@@ -151,7 +324,6 @@
   void                    *clientdata;		/* Language specific module data */
 } swig_module_info;
 
-
 /* 
   Compare two type names skipping the space characters, therefore
   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
@@ -165,7 +337,7 @@
   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
     while ((*f1 == ' ') && (f1 != l1)) ++f1;
     while ((*f2 == ' ') && (f2 != l2)) ++f2;
-    if (*f1 != *f2) return (int)(*f1 - *f2);
+    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
   }
   return (l1 - f1) - (l2 - f2);
 }
@@ -285,6 +457,7 @@
      type, separated by vertical-bar characters.  We choose
      to print the last name, as it is often (?) the most
      specific. */
+  if (!type) return NULL;
   if (type->str != NULL) {
     const char *last_name = type->str;
     const char *s;
@@ -315,7 +488,12 @@
     cast = cast->next;
   }
 }
-
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+  SWIG_TypeClientData(ti, clientdata);
+  ti->owndata = 1;
+}
+  
 /*
   Search for a swig_type_info structure only by mangled name
   Search is a O(log #types)
@@ -395,7 +573,6 @@
   return 0;
 }
 
-
 /* 
    Pack binary data into a string
 */
@@ -421,7 +598,7 @@
   register const unsigned char *eu = u + sz;
   for (; u != eu; ++u) {
     register char d = *(c++);
-    register unsigned char uu = 0;
+    register unsigned char uu;
     if ((d >= '0') && (d <= '9'))
       uu = ((d - '0') << 4);
     else if ((d >= 'a') && (d <= 'f'))
@@ -499,15 +676,23 @@
 }
 #endif
 
-/* ---------------------------------------------------------------------- -*- c -*-
- * perl5.swg
- *
- * Perl5 runtime library
- * $Header: /cvsroot/swig/SWIG/Lib/perl5/perlrun.swg,v 1.21 2005/02/01 00:08:17 wuzzeb Exp $
- * ----------------------------------------------------------------------------- */
+/*  Errors in SWIG */
+#define  SWIG_UnknownError    	   -1 
+#define  SWIG_IOError        	   -2 
+#define  SWIG_RuntimeError   	   -3 
+#define  SWIG_IndexError     	   -4 
+#define  SWIG_TypeError      	   -5 
+#define  SWIG_DivisionByZero 	   -6 
+#define  SWIG_OverflowError  	   -7 
+#define  SWIG_SyntaxError    	   -8 
+#define  SWIG_ValueError     	   -9 
+#define  SWIG_SystemError    	   -10
+#define  SWIG_AttributeError 	   -11
+#define  SWIG_MemoryError    	   -12 
+#define  SWIG_NullReferenceError   -13
 
-#define SWIGPERL
-#define SWIGPERL5
+
+
 #ifdef __cplusplus
 /* Needed on some windows machines---since MS plays funny games with the header files under C++ */
 #include <math.h>
@@ -518,21 +703,227 @@
 #include "perl.h"
 #include "XSUB.h"
 
-/* Get rid of free and malloc defined by perl */
-#undef free
-#undef malloc
+/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */
 
+/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */
+#ifndef PERL_REVISION
+#  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
+#    define PERL_PATCHLEVEL_H_IMPLICIT
+#    include <patchlevel.h>
+#  endif
+#  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
+#    include <could_not_find_Perl_patchlevel.h>
+#  endif
+#  ifndef PERL_REVISION
+#    define PERL_REVISION       (5)
+#    define PERL_VERSION        PATCHLEVEL
+#    define PERL_SUBVERSION     SUBVERSION
+#  endif
+#endif
+
+#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
+#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
+#endif
+
+#ifndef SvIOK_UV
+# define SvIOK_UV(sv)       (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv)))
+#endif
+
+#ifndef SvUOK
+# define SvUOK(sv)           SvIOK_UV(sv)
+#endif
+
+#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
+#  define PL_sv_undef               sv_undef
+#  define PL_na	                    na
+#  define PL_errgv                  errgv
+#  define PL_sv_no                  sv_no
+#  define PL_sv_yes                 sv_yes
+#  define PL_markstack_ptr          markstack_ptr
+#endif
+
+#ifndef IVSIZE
+#  ifdef LONGSIZE
+#    define IVSIZE LONGSIZE
+#  else
+#    define IVSIZE 4 /* A bold guess, but the best we can make. */
+#  endif
+#endif
+
+#ifndef INT2PTR
+#  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
+#    define PTRV                  UV
+#    define INT2PTR(any,d)        (any)(d)
+#  else
+#    if PTRSIZE == LONGSIZE
+#      define PTRV                unsigned long
+#    else
+#      define PTRV                unsigned
+#    endif
+#    define INT2PTR(any,d)        (any)(PTRV)(d)
+#  endif
+
+#  define NUM2PTR(any,d)  (any)(PTRV)(d)
+#  define PTR2IV(p)       INT2PTR(IV,p)
+#  define PTR2UV(p)       INT2PTR(UV,p)
+#  define PTR2NV(p)       NUM2PTR(NV,p)
+
+#  if PTRSIZE == LONGSIZE
+#    define PTR2ul(p)     (unsigned long)(p)
+#  else
+#    define PTR2ul(p)     INT2PTR(unsigned long,p)
+#  endif
+#endif /* !INT2PTR */
+
+#ifndef get_sv
+#  define get_sv perl_get_sv
+#endif
+
+#ifndef ERRSV
+#  define ERRSV get_sv("@",FALSE)
+#endif
+
 #ifndef pTHX_
 #define pTHX_
-#endif
+#endif   
 
 #include <string.h>
 #ifdef __cplusplus
 }
 #endif
 
-/* Macro to call an XS function */
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
 
+SWIGINTERN const char*
+SWIG_Perl_ErrorType(int code) {
+  const char* type = 0;
+  switch(code) {
+  case SWIG_MemoryError:
+    type = "MemoryError";
+    break;
+  case SWIG_IOError:
+    type = "IOError";
+    break;
+  case SWIG_RuntimeError:
+    type = "RuntimeError";
+    break;
+  case SWIG_IndexError:
+    type = "IndexError";
+    break;
+  case SWIG_TypeError:
+    type = "TypeError";
+    break;
+  case SWIG_DivisionByZero:
+    type = "ZeroDivisionError";
+    break;
+  case SWIG_OverflowError:
+    type = "OverflowError";
+    break;
+  case SWIG_SyntaxError:
+    type = "SyntaxError";
+    break;
+  case SWIG_ValueError:
+    type = "ValueError";
+    break;
+  case SWIG_SystemError:
+    type = "SystemError";
+    break;
+  case SWIG_AttributeError:
+    type = "AttributeError";
+    break;
+  default:
+    type = "RuntimeError";
+  }
+  return type;
+}
+
+
+
+
+/* -----------------------------------------------------------------------------
+ * perlrun.swg
+ *
+ * This file contains the runtime support for Perl modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef PERL_OBJECT
+#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl),
+#define SWIG_PERL_OBJECT_CALL pPerl,
+#else
+#define SWIG_PERL_OBJECT_DECL
+#define SWIG_PERL_OBJECT_CALL
+#endif
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_ConvertPtr(obj, pp, type, flags)           SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
+#define SWIG_NewPointerObj(p, type, flags)              SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, p, s, type)             SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type)
+#define SWIG_NewPackedObj(p, s, type)	                SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_ConvertPtr(obj, pptr, type, 0)
+#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_NewPointerObj(ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata)                      SWIG_Perl_GetModule()
+#define SWIG_SetModule(clientdata, pointer)             SWIG_Perl_SetModule(pointer)
+
+
+/* Error manipulation */
+
+#define SWIG_ErrorType(code)                            SWIG_Perl_ErrorType(code)               
+#define SWIG_Error(code, msg)            		sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg)
+#define SWIG_fail                        		goto fail						    
+
+/* Perl-specific SWIG API */
+
+#define SWIG_MakePtr(sv, ptr, type, flags)              SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags)
+#define SWIG_MakePackedObj(sv, p, s, type)	        SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type)
+#define SWIG_SetError(str)                              SWIG_Error(SWIG_RuntimeError, str)
+
+
+#define SWIG_PERL_DECL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_DECL arg1)
+#define SWIG_PERL_CALL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_CALL arg1)
+#define SWIG_PERL_DECL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_DECL arg1, arg2)
+#define SWIG_PERL_CALL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_CALL arg1, arg2)
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+/* For backward compatibility only */
+#define SWIG_POINTER_EXCEPTION  0
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SWIG_OWNER   SWIG_POINTER_OWN
+#define SWIG_SHADOW  SWIG_OWNER << 1
+
+#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
+
+/* SWIG Perl macros */
+
+/* Macro to call an XS function */
 #ifdef PERL_OBJECT 
 #  define SWIG_CALLXS(_name) _name(cv,pPerl) 
 #else 
@@ -543,10 +934,6 @@
 #  endif 
 #endif 
 
-/* Contract support */
-
-#define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else
-
 /* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
 
 #ifdef PERL_OBJECT
@@ -565,7 +952,7 @@
 #define SWIGCLASS_STATIC
 #else
 #define MAGIC_PPERL
-#define SWIGCLASS_STATIC static
+#define SWIGCLASS_STATIC static SWIGUNUSED
 #ifndef MULTIPLICITY
 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
 typedef int (*SwigMagicFunc)(SV *, MAGIC *);
@@ -593,104 +980,64 @@
 #endif
 #endif
 
-#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
-#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
-#endif
-
-/* Modifications for newer Perl 5.005 releases */
-
-#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
-#  ifndef PL_sv_yes
-#    define PL_sv_yes sv_yes
+/* Workaround for bug in perl 5.6.x croak and earlier */
+#if (PERL_VERSION < 8)
+#  ifdef PERL_OBJECT
+#    define SWIG_croak_null() SWIG_Perl_croak_null(pPerl)
+static void SWIG_Perl_croak_null(CPerlObj *pPerl)
+#  else
+static void SWIG_croak_null()
 #  endif
-#  ifndef PL_sv_undef
-#    define PL_sv_undef sv_undef
+{
+  SV *err=ERRSV;
+#  if (PERL_VERSION < 6)
+  croak("%_", err);
+#  else
+  if (SvOK(err) && !SvROK(err)) croak("%_", err);
+  croak(Nullch);
 #  endif
-#  ifndef PL_na
-#    define PL_na na
-#  endif
-#endif
-
-#include <stdlib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SWIG_OWNER 1
-#define SWIG_SHADOW 2
-
-/* Common SWIG API */
-
-#ifdef PERL_OBJECT
-#  define SWIG_ConvertPtr(obj, pp, type, flags) \
-     SWIG_Perl_ConvertPtr(pPerl, obj, pp, type, flags)
-#  define SWIG_NewPointerObj(p, type, flags) \
-     SWIG_Perl_NewPointerObj(pPerl, p, type, flags)
-#  define SWIG_MakePackedObj(sv, p, s, type)	\
-     SWIG_Perl_MakePackedObj(pPerl, sv, p, s, type)
-#  define SWIG_ConvertPacked(obj, p, s, type, flags) \
-     SWIG_Perl_ConvertPacked(pPerl, obj, p, s, type, flags)
-
+}
 #else
-#  define SWIG_ConvertPtr(obj, pp, type, flags) \
-     SWIG_Perl_ConvertPtr(obj, pp, type, flags)
-#  define SWIG_NewPointerObj(p, type, flags) \
-     SWIG_Perl_NewPointerObj(p, type, flags)
-#  define SWIG_MakePackedObj(sv, p, s, type)	\
-     SWIG_Perl_MakePackedObj(sv, p, s, type )
-#  define SWIG_ConvertPacked(obj, p, s, type, flags) \
-     SWIG_Perl_ConvertPacked(obj, p, s, type, flags)
+#  define SWIG_croak_null() croak(Nullch)
 #endif
 
-/* Runtime API */
-#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
 
-/* Perl-specific API */
-#ifdef PERL_OBJECT
-#  define SWIG_MakePtr(sv, ptr, type, flags) \
-     SWIG_Perl_MakePtr(pPerl, sv, ptr, type, flags)
-#  define SWIG_SetError(str) \
-     SWIG_Perl_SetError(pPerl, str)
-#else
-#  define SWIG_MakePtr(sv, ptr, type, flags) \
-     SWIG_Perl_MakePtr(sv, ptr, type, flags)
-#  define SWIG_SetError(str) \
-     SWIG_Perl_SetError(str)
-#  define SWIG_SetErrorSV(str) \
-     SWIG_Perl_SetErrorSV(str)
-#endif
 
-#define SWIG_SetErrorf SWIG_Perl_SetErrorf
+#include <stdlib.h>
 
+SWIGRUNTIME const char *
+SWIG_Perl_TypeProxyName(const swig_type_info *type) {
+  if (!type) return NULL;
+  if (type->clientdata != NULL) {
+    return (const char*) type->clientdata;
+  } 
+  else {
+    return type->name;
+  }
+}
 
-#ifdef PERL_OBJECT
-#  define SWIG_MAYBE_PERL_OBJECT CPerlObj *pPerl,
-#else
-#  define SWIG_MAYBE_PERL_OBJECT
-#endif
-
-static swig_cast_info *
-SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(sv_derived_from(rv, (char *) iter->type->name), ty);
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
+  SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) 
+			    || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
 }
 
+
 /* Function for getting a pointer value */
 
-static int
+SWIGRUNTIME int
 SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
   swig_cast_info *tc;
   void *voidptr = (void *)0;
-
+  SV *tsv = 0;
   /* If magical, apply more magic */
   if (SvGMAGICAL(sv))
     mg_get(sv);
 
   /* Check to see if this is an object */
   if (sv_isobject(sv)) {
-    SV *tsv = (SV*) SvRV(sv);
     IV tmp = 0;
+    tsv = (SV*) SvRV(sv);
     if ((SvTYPE(tsv) == SVt_PVHV)) {
       MAGIC *mg;
       if (SvMAGICAL(tsv)) {
@@ -698,58 +1045,76 @@
         if (mg) {
           sv = mg->mg_obj;
           if (sv_isobject(sv)) {
-            tmp = SvIV((SV*)SvRV(sv));
+	    tsv = (SV*)SvRV(sv);
+            tmp = SvIV(tsv);
           }
         }
       } else {
-        return -1;
+        return SWIG_ERROR;
       }
     } else {
-      tmp = SvIV((SV*)SvRV(sv));
+      tmp = SvIV(tsv);
     }
-    voidptr = (void *)tmp;
-    if (!_t) {
-      *(ptr) = voidptr;
-      return 0;
-    }
+    voidptr = INT2PTR(void *,tmp);
   } else if (! SvOK(sv)) {            /* Check for undef */
     *(ptr) = (void *) 0;
-    return 0;
+    return SWIG_OK;
   } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
-    *(ptr) = (void *) 0;
-    if (!SvROK(sv))
-      return 0;
-    else
-      return -1;
+    if (!SvROK(sv)) {
+      *(ptr) = (void *) 0;
+      return SWIG_OK;
+    } else {
+      return SWIG_ERROR;
+    }
   } else {                            /* Don't know what it is */
-    *(ptr) = (void *) 0;
-    return -1;
+    return SWIG_ERROR;
   }
   if (_t) {
     /* Now see if the types match */
     char *_c = HvNAME(SvSTASH(SvRV(sv)));
-    tc = SWIG_TypeCheck(_c,_t);
+    tc = SWIG_TypeProxyCheck(_c,_t);
     if (!tc) {
-      *ptr = voidptr;
-      return -1;
+      return SWIG_ERROR;
     }
     *ptr = SWIG_TypeCast(tc,voidptr);
-    return 0;
+  } else {
+    *ptr = voidptr;
   }
-  *ptr = voidptr;
-  return 0;
+
+  /* 
+   *  DISOWN implementation: we need a perl guru to check this one.
+   */
+  if (tsv && (flags & SWIG_POINTER_DISOWN)) {
+    /* 
+     *  almost copy paste code from below SWIG_POINTER_OWN setting
+     */
+    SV *obj = sv;
+    HV *stash = SvSTASH(SvRV(obj));
+    GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE);
+    if (isGV(gv)) {
+      HV *hv = GvHVn(gv);
+      /*
+       * To set ownership (see below), a newSViv(1) entry is added. 
+       * Hence, to remove ownership, we delete the entry.
+       */
+      if (hv_exists_ent(hv, obj, 0)) {
+	hv_delete_ent(hv, obj, 0, 0);
+      }
+    }
+  }
+  return SWIG_OK;
 }
 
-static void
+SWIGRUNTIME void
 SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
   if (ptr && (flags & SWIG_SHADOW)) {
     SV *self;
     SV *obj=newSV(0);
     HV *hash=newHV();
     HV *stash;
-    sv_setref_pv(obj, (char *) t->name, ptr);
+    sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
     stash=SvSTASH(SvRV(obj));
-    if (flags & SWIG_OWNER) {
+    if (flags & SWIG_POINTER_OWN) {
       HV *hv;
       GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
       if (!isGV(gv))
@@ -765,71 +1130,57 @@
     sv_bless(sv, stash);
   }
   else {
-    sv_setref_pv(sv, (char *) t->name, ptr);
+    sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr);
   }
 }
 
-static SWIGINLINE SV *
+SWIGRUNTIMEINLINE SV *
 SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
   SV *result = sv_newmortal();
   SWIG_MakePtr(result, ptr, t, flags);
   return result;
 }
 
-static void
-  SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
+SWIGRUNTIME void
+SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
   char result[1024];
   char *r = result;
-  if ((2*sz + 1 + strlen(type->name)) > 1000) return;
+  if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return;
   *(r++) = '_';
   r = SWIG_PackData(r,ptr,sz);
-  strcpy(r,type->name);
+  strcpy(r,SWIG_Perl_TypeProxyName(type));
   sv_setpv(sv, result);
 }
 
+SWIGRUNTIME SV *
+SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) {
+  SV *result = sv_newmortal();
+  SWIG_Perl_MakePackedObj(result, ptr, sz, type);
+  return result;
+}
+
 /* Convert a packed value value */
-static int
-SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+SWIGRUNTIME int
+SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
   swig_cast_info *tc;
   const char  *c = 0;
 
-  if ((!obj) || (!SvOK(obj))) return -1;
+  if ((!obj) || (!SvOK(obj))) return SWIG_ERROR;
   c = SvPV(obj, PL_na);
   /* Pointer values must start with leading underscore */
-  if (*c != '_') return -1;
+  if (*c != '_') return SWIG_ERROR;
   c++;
   c = SWIG_UnpackData(c,ptr,sz);
   if (ty) {
     tc = SWIG_TypeCheck(c,ty);
-    if (!tc) return -1;
+    if (!tc) return SWIG_ERROR;
   }
-  return 0;
+  return SWIG_OK;
 }
 
-static SWIGINLINE void
-SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
-  if (error) sv_setpv(perl_get_sv("@", TRUE), error);
-}
 
-static SWIGINLINE void
-SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) {
-  if (error) sv_setsv(perl_get_sv("@", TRUE), error);
-}
-
-static void
-SWIG_Perl_SetErrorf(const char *fmt, ...) {
-  va_list args;
-  va_start(args, fmt);
-  sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*));
-  va_end(args);
-}
-
 /* Macros for low-level exception handling */
-#define SWIG_fail       goto fail
-#define SWIG_croak(x)   { SWIG_SetError(x); goto fail; }
-#define SWIG_croakSV(x) { SWIG_SetErrorSV(x); goto fail; }
-/* most preprocessors do not support vararg macros :-( */
-/* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */
+#define SWIG_croak(x)    { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; }
 
 
 typedef XS(SwigPerlWrapper);
@@ -859,9 +1210,6 @@
     swig_type_info **ptype;
 } swig_constant_info;
 
-#ifdef __cplusplus
-}
-#endif
 
 /* Structure for variable table */
 typedef struct {
@@ -875,14 +1223,15 @@
 #ifndef PERL_OBJECT
 #define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
   #ifndef MULTIPLICITY
-     static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
+     SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) 
   #else
-     static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) {
+     SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) 
   #endif
 #else
 #  define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
+SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) 
 #endif
+{
   MAGIC *mg;
   sv_magic(sv,sv,'U',(char *) name,strlen(name));
   mg = mg_find(sv,'U');
@@ -895,8 +1244,8 @@
 }
 
 
-static swig_module_info *
-SWIG_Perl_GetModule() {
+SWIGRUNTIME swig_module_info *
+SWIG_Perl_GetModule(void) {
   static void *type_pointer = (void *)0;
   SV *pointer;
 
@@ -911,7 +1260,7 @@
   return (swig_module_info *) type_pointer;
 }
 
-static void
+SWIGRUNTIME void
 SWIG_Perl_SetModule(swig_module_info *module) {
   SV *pointer;
 
@@ -920,6 +1269,13 @@
   sv_setiv(pointer, PTR2IV(module));
 }
 
+#ifdef __cplusplus
+}
+#endif
+
+/* Workaround perl5 global namespace pollution. Note that undefining library
+ * functions like fopen will not solve the problem on all platforms as fopen
+ * might be a macro on Windows but not necessarily on other operating systems. */
 #ifdef do_open
   #undef do_open
 #endif
@@ -971,9 +1327,6 @@
 #ifdef ref
   #undef ref
 #endif
-#ifdef ENTER
-  #undef ENTER
-#endif
 #ifdef read
   #undef read
 #endif
@@ -986,14 +1339,47 @@
 #ifdef bool
   #undef bool
 #endif
+#ifdef close
+  #undef close
+#endif
+#ifdef rewind
+  #undef rewind
+#endif
+#ifdef free
+  #undef free
+#endif
+#ifdef malloc
+  #undef malloc
+#endif
+#ifdef calloc
+  #undef calloc
+#endif
+#ifdef Stat
+  #undef Stat
+#endif
+#ifdef check
+  #undef check
+#endif
 
 
 
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
+
+
+
 /* -------- TYPES TABLE (BEGIN) -------- */
 
-#define SWIGTYPE_p_switch_core_session swig_types[0]
-static swig_type_info *swig_types[2];
-static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0};
+#define SWIGTYPE_p_char swig_types[0]
+#define SWIGTYPE_p_p_switch_core_session_t swig_types[1]
+#define SWIGTYPE_p_switch_channel_t swig_types[2]
+#define SWIGTYPE_p_switch_core_session_t swig_types[3]
+#define SWIGTYPE_p_switch_file_handle_t swig_types[4]
+#define SWIGTYPE_p_switch_input_callback_function_t swig_types[5]
+#define SWIGTYPE_p_uint32_t swig_types[6]
+static swig_type_info *swig_types[8];
+static swig_module_info swig_module = {swig_types, 7, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -1004,6 +1390,13 @@
 #define SWIG_name   "fs_perlc::boot_fs_perl"
 #define SWIG_prefix "fs_perlc::"
 
+#define SWIGVERSION 0x010329 
+
+
+#define SWIG_as_voidptr(a) (void *)((const void *)(a)) 
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 
+
+
 #ifdef __cplusplus
 extern "C"
 #endif
@@ -1017,6 +1410,240 @@
 SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
 #endif
 
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor()
+{
+  static int init = 0;
+  static swig_type_info* info = 0;
+  if (!init) {
+    info = SWIG_TypeQuery("_p_char");
+    init = 1;
+  }
+  return info;
+}
+
+
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
+{
+  if (SvPOK(obj)) {
+    STRLEN len = 0;
+    char *cstr = SvPV(obj, len); 
+    size_t size = len + 1;
+    if (cptr)  {
+      if (alloc) {
+	if (*alloc == SWIG_NEWOBJ) {
+	  *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
+	} else {
+	  *cptr = cstr;
+	  *alloc = SWIG_OLDOBJ;
+	}
+      }
+    }
+    if (psize) *psize = size;
+    return SWIG_OK;
+  } else {
+    swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+    if (pchar_descriptor) {
+      char* vptr = 0; 
+      if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
+	if (cptr) *cptr = vptr;
+	if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
+	if (alloc) *alloc = SWIG_OLDOBJ;
+	return SWIG_OK;
+      }
+    }
+  }
+  return SWIG_TypeError;
+}
+
+
+
+
+
+SWIGINTERNINLINE SV *
+SWIG_From_long  SWIG_PERL_DECL_ARGS_1(long value)
+{    
+  SV *obj = sv_newmortal();
+  sv_setiv(obj, (IV) value);
+  return obj;
+}
+
+
+SWIGINTERNINLINE SV *
+SWIG_From_int  SWIG_PERL_DECL_ARGS_1(int value)
+{    
+  return SWIG_From_long  SWIG_PERL_CALL_ARGS_1(value);
+}
+
+
+#include <limits.h>
+#ifndef LLONG_MIN
+# define LLONG_MIN	LONG_LONG_MIN
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX	LONG_LONG_MAX
+#endif
+#ifndef ULLONG_MAX
+# define ULLONG_MAX	ULONG_LONG_MAX
+#endif
+
+
+SWIGINTERN int
+SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val)
+{
+  if (SvNIOK(obj)) {
+    if (val) *val = SvNV(obj);
+    return SWIG_OK;
+  } else if (SvIOK(obj)) {
+    if (val) *val = (double) SvIV(obj);
+    return SWIG_AddCast(SWIG_OK);
+  } else {
+    const char *nptr = SvPV(obj, PL_na);
+    if (nptr) {
+      char *endptr;
+      double v = strtod(nptr, &endptr);
+      if (errno == ERANGE) {
+	errno = 0;
+	return SWIG_OverflowError;
+      } else {
+	if (*endptr == '\0') {
+	  if (val) *val = v;
+	  return SWIG_AddCast(SWIG_OK);
+	}
+      }
+    }
+  }
+  return SWIG_TypeError;
+}
+
+
+#include <float.h>
+
+
+#include <math.h>
+
+
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+  double x = *d;
+  if ((min <= x && x <= max)) {
+   double fx = floor(x);
+   double cx = ceil(x);
+   double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+   if ((errno == EDOM) || (errno == ERANGE)) {
+     errno = 0;
+   } else {
+     double summ, reps, diff;
+     if (rd < x) {
+       diff = x - rd;
+     } else if (rd > x) {
+       diff = rd - x;
+     } else {
+       return 1;
+     }
+     summ = rd + x;
+     reps = diff/summ;
+     if (reps < 8*DBL_EPSILON) {
+       *d = rd;
+       return 1;
+     }
+   }
+  }
+  return 0;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj, unsigned long *val) 
+{
+  if (SvUOK(obj)) {
+    if (val) *val = SvUV(obj);
+    return SWIG_OK;
+  } else  if (SvIOK(obj)) {
+    long v = SvIV(obj);
+    if (v >= 0) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      return SWIG_OverflowError;
+    }
+  } else {
+    int dispatch = 0;
+    const char *nptr = SvPV(obj, PL_na);
+    if (nptr) {
+      char *endptr;
+      unsigned long v = strtoul(nptr, &endptr,0);
+      if (errno == ERANGE) {
+	errno = 0;
+	return SWIG_OverflowError;
+      } else {
+	if (*endptr == '\0') {
+	  if (val) *val = v;
+	  return SWIG_AddCast(SWIG_OK);
+	}
+      }
+    }
+    if (!dispatch) {
+      double d;
+      int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d));
+      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+	if (val) *val = (unsigned long)(d);
+	return res;
+      }
+    }
+  }
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_int SWIG_PERL_DECL_ARGS_2(SV * obj, unsigned int *val)
+{
+  unsigned long v;
+  int res = SWIG_AsVal_unsigned_SS_long SWIG_PERL_CALL_ARGS_2(obj, &v);
+  if (SWIG_IsOK(res)) {
+    if ((v > UINT_MAX)) {
+      return SWIG_OverflowError;
+    } else {
+      if (val) *val = (unsigned int)(v);
+    }
+  }  
+  return res;
+}
+
+
+SWIGINTERNINLINE SV *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+  SV *obj = sv_newmortal();
+  if (size && carray) {
+    if (carray[size - 1] == 0) {
+      sv_setpv(obj, carray);
+    } else {
+      char *tmp = (char *)malloc((size + 1)*sizeof(char));
+      memcpy(tmp, carray, size);
+      tmp[size] = 0;
+      sv_setpv(obj, tmp);
+      free((char*)tmp);
+    }
+  } else {
+    sv_setsv(obj, &PL_sv_undef);
+  }
+  return obj;
+}
+
+
+SWIGINTERNINLINE SV * 
+SWIG_FromCharPtr(const char *cptr)
+{ 
+  return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
+}
+
+
+#include "switch.h"
+
 #ifdef PERL_OBJECT
 #define MAGIC_CLASS _wrap_fs_perl_var::
 class _wrap_fs_perl_var : public CPerlObj {
@@ -1024,9 +1651,8 @@
 #else
 #define MAGIC_CLASS
 #endif
-SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *sv, MAGIC *mg) {
+SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {
     MAGIC_PPERL
-    sv = sv; mg = mg;
     croak("Value is read-only.");
     return 0;
 }
@@ -1040,394 +1666,1199 @@
 extern "C" {
 #endif
 XS(_wrap_fs_core_set_globals) {
-    {
-        int argvi = 0;
-        dXSARGS;
-        
-        fs_core_set_globals();
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 0) || (items > 0)) {
+      SWIG_croak("Usage: fs_core_set_globals();");
     }
-    croak(Nullch);
+    fs_core_set_globals();
+    
+    XSRETURN(argvi);
+  fail:
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_core_init) {
-    {
-        char *arg1 = (char *) 0 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_core_init(path);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        result = (int)fs_core_init(arg1);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    char *arg1 = (char *) 0 ;
+    int result;
+    int res1 ;
+    char *buf1 = 0 ;
+    int alloc1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: fs_core_init(path);");
     }
-    croak(Nullch);
+    res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_core_init" "', argument " "1"" of type '" "char *""'");
+    }
+    arg1 = buf1;
+    result = (int)fs_core_init(arg1);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    XSRETURN(argvi);
+  fail:
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_core_destroy) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        result = (int)fs_core_destroy();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    int result;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 0) || (items > 0)) {
+      SWIG_croak("Usage: fs_core_destroy();");
     }
-    croak(Nullch);
+    result = (int)fs_core_destroy();
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    XSRETURN(argvi);
+  fail:
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_loadable_module_init) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        result = (int)fs_loadable_module_init();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    int result;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 0) || (items > 0)) {
+      SWIG_croak("Usage: fs_loadable_module_init();");
     }
-    croak(Nullch);
+    result = (int)fs_loadable_module_init();
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    XSRETURN(argvi);
+  fail:
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_loadable_module_shutdown) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        result = (int)fs_loadable_module_shutdown();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    int result;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 0) || (items > 0)) {
+      SWIG_croak("Usage: fs_loadable_module_shutdown();");
     }
-    croak(Nullch);
+    result = (int)fs_loadable_module_shutdown();
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    XSRETURN(argvi);
+  fail:
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_console_loop) {
-    {
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-
-        result = (int)fs_console_loop();
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    int result;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 0) || (items > 0)) {
+      SWIG_croak("Usage: fs_console_loop();");
     }
-    croak(Nullch);
+    result = (int)fs_console_loop();
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    XSRETURN(argvi);
+  fail:
+    SWIG_croak_null();
+  }
 }
 
 
-XS(_wrap_fs_console_log) {
-    {
-        char *arg1 = (char *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_console_log(msg);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        fs_console_log(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+XS(_wrap_fs_consol_log) {
+  {
+    char *arg1 = (char *) 0 ;
+    char *arg2 = (char *) 0 ;
+    int res1 ;
+    char *buf1 = 0 ;
+    int alloc1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_consol_log(level_str,msg);");
     }
-    croak(Nullch);
+    res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_consol_log" "', argument " "1"" of type '" "char *""'");
+    }
+    arg1 = buf1;
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_consol_log" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    fs_consol_log(arg1,arg2);
+    
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
 }
 
 
-XS(_wrap_fs_console_clean) {
-    {
-        char *arg1 = (char *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_console_clean(msg);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        fs_console_clean(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+XS(_wrap_fs_consol_clean) {
+  {
+    char *arg1 = (char *) 0 ;
+    int res1 ;
+    char *buf1 = 0 ;
+    int alloc1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: fs_consol_clean(msg);");
     }
-    croak(Nullch);
+    res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_consol_clean" "', argument " "1"" of type '" "char *""'");
+    }
+    arg1 = buf1;
+    fs_consol_clean(arg1);
+    
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    XSRETURN(argvi);
+  fail:
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_core_session_locate) {
-    {
-        char *arg1 = (char *) 0 ;
-        struct switch_core_session *result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_core_session_locate(uuid);");
-        }
-        if (!SvOK((SV*) ST(0))) arg1 = 0;
-        else arg1 = (char *) SvPV(ST(0), PL_na);
-        result = (struct switch_core_session *)fs_core_session_locate(arg1);
-        
-        ST(argvi) = sv_newmortal();
-        SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session, 0|0);
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    char *arg1 = (char *) 0 ;
+    switch_core_session_t *result = 0 ;
+    int res1 ;
+    char *buf1 = 0 ;
+    int alloc1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: fs_core_session_locate(uuid);");
     }
-    croak(Nullch);
+    res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_core_session_locate" "', argument " "1"" of type '" "char *""'");
+    }
+    arg1 = buf1;
+    result = (switch_core_session_t *)fs_core_session_locate(arg1);
+    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_switch_core_session_t, 0 | 0); argvi++ ;
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    XSRETURN(argvi);
+  fail:
+    if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_answer) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_channel_answer(session);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session");
-            }
-        }
-        fs_channel_answer(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: fs_channel_answer(session);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_answer" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    fs_channel_answer(arg1);
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_pre_answer) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_channel_pre_answer(session);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session");
-            }
-        }
-        fs_channel_pre_answer(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: fs_channel_pre_answer(session);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_pre_answer" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    fs_channel_pre_answer(arg1);
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_hangup) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 1) || (items > 1)) {
-            SWIG_croak("Usage: fs_channel_hangup(session);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session");
-            }
-        }
-        fs_channel_hangup(arg1);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_channel_hangup(session,cause);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_hangup" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_channel_hangup" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    fs_channel_hangup(arg1,arg2);
+    
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_set_variable) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        char *arg2 = (char *) 0 ;
-        char *arg3 = (char *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 3) || (items > 3)) {
-            SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        fs_channel_set_variable(arg1,arg2,arg3);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 3) || (items > 3)) {
+      SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_set_variable" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_channel_set_variable" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_channel_set_variable" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    fs_channel_set_variable(arg1,arg2,arg3);
+    
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_get_variable) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        char *arg2 = (char *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_channel_get_variable(session,var);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_channel_get_variable(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_channel_get_variable(session,var);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_get_variable" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_channel_get_variable" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    fs_channel_get_variable(arg1,arg2);
+    
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_channel_set_state) {
-    {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        char *arg2 = (char *) 0 ;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 2) || (items > 2)) {
-            SWIG_croak("Usage: fs_channel_set_state(session,state);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        fs_channel_set_state(arg1,arg2);
-        
-        
-        XSRETURN(argvi);
-        fail:
-        ;
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_channel_set_state(session,state);");
     }
-    croak(Nullch);
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_channel_set_state" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_channel_set_state" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    fs_channel_set_state(arg1,arg2);
+    
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
 }
 
 
 XS(_wrap_fs_ivr_play_file) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) 0 ;
+    switch_input_callback_function_t arg4 ;
+    void *arg5 = (void *) 0 ;
+    unsigned int arg6 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    void *argp4 ;
+    int res4 = 0 ;
+    int res5 ;
+    unsigned int val6 ;
+    int ecode6 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 6) || (items > 6)) {
+      SWIG_croak("Usage: fs_ivr_play_file(session,file,timer_name,dtmf_callback,buf,buflen);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_ivr_play_file" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_ivr_play_file" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_ivr_play_file" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
     {
-        struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
-        char *arg2 = (char *) 0 ;
-        char *arg3 = (char *) 0 ;
-        int result;
-        int argvi = 0;
-        dXSARGS;
-        
-        if ((items < 3) || (items > 3)) {
-            SWIG_croak("Usage: fs_ivr_play_file(session,file,timer_name_in);");
-        }
-        {
-            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
-                SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session");
-            }
-        }
-        if (!SvOK((SV*) ST(1))) arg2 = 0;
-        else arg2 = (char *) SvPV(ST(1), PL_na);
-        if (!SvOK((SV*) ST(2))) arg3 = 0;
-        else arg3 = (char *) SvPV(ST(2), PL_na);
-        result = (int)fs_ivr_play_file(arg1,arg2,arg3);
-        
-        ST(argvi) = sv_newmortal();
-        sv_setiv(ST(argvi++), (IV) result);
-        XSRETURN(argvi);
-        fail:
-        ;
+      res4 = SWIG_ConvertPtr(ST(3), &argp4, SWIGTYPE_p_switch_input_callback_function_t,  0 );
+      if (!SWIG_IsOK(res4)) {
+        SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "fs_ivr_play_file" "', argument " "4"" of type '" "switch_input_callback_function_t""'"); 
+      }  
+      if (!argp4) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_ivr_play_file" "', argument " "4"" of type '" "switch_input_callback_function_t""'");
+      } else {
+        arg4 = *((switch_input_callback_function_t *)(argp4));
+      }
     }
-    croak(Nullch);
+    res5 = SWIG_ConvertPtr(ST(4),SWIG_as_voidptrptr(&arg5), 0, 0);
+    if (!SWIG_IsOK(res5)) {
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "fs_ivr_play_file" "', argument " "5"" of type '" "void *""'"); 
+    }
+    ecode6 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(5), &val6);
+    if (!SWIG_IsOK(ecode6)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "fs_ivr_play_file" "', argument " "6"" of type '" "unsigned int""'");
+    } 
+    arg6 = (unsigned int)(val6);
+    result = (int)fs_ivr_play_file(arg1,arg2,arg3,arg4,arg5,arg6);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    
+    
+    SWIG_croak_null();
+  }
 }
 
 
+XS(_wrap_fs_switch_ivr_record_file) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    switch_file_handle_t *arg2 = (switch_file_handle_t *) 0 ;
+    char *arg3 = (char *) 0 ;
+    switch_input_callback_function_t arg4 ;
+    void *arg5 = (void *) 0 ;
+    unsigned int arg6 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    void *argp2 = 0 ;
+    int res2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    void *argp4 ;
+    int res4 = 0 ;
+    int res5 ;
+    unsigned int val6 ;
+    int ecode6 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 6) || (items > 6)) {
+      SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_record_file" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_switch_file_handle_t, 0 |  0 );
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_record_file" "', argument " "2"" of type '" "switch_file_handle_t *""'"); 
+    }
+    arg2 = (switch_file_handle_t *)(argp2);
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_ivr_record_file" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    {
+      res4 = SWIG_ConvertPtr(ST(3), &argp4, SWIGTYPE_p_switch_input_callback_function_t,  0 );
+      if (!SWIG_IsOK(res4)) {
+        SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "fs_switch_ivr_record_file" "', argument " "4"" of type '" "switch_input_callback_function_t""'"); 
+      }  
+      if (!argp4) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_record_file" "', argument " "4"" of type '" "switch_input_callback_function_t""'");
+      } else {
+        arg4 = *((switch_input_callback_function_t *)(argp4));
+      }
+    }
+    res5 = SWIG_ConvertPtr(ST(4),SWIG_as_voidptrptr(&arg5), 0, 0);
+    if (!SWIG_IsOK(res5)) {
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "fs_switch_ivr_record_file" "', argument " "5"" of type '" "void *""'"); 
+    }
+    ecode6 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(5), &val6);
+    if (!SWIG_IsOK(ecode6)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "fs_switch_ivr_record_file" "', argument " "6"" of type '" "unsigned int""'");
+    } 
+    arg6 = (unsigned int)(val6);
+    result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    
+    
+    SWIG_croak_null();
+  }
+}
 
+
+XS(_wrap_fs_switch_ivr_sleep) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    uint32_t arg2 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    void *argp2 ;
+    int res2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_switch_ivr_sleep(session,ms);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_sleep" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    {
+      res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_uint32_t,  0 );
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_sleep" "', argument " "2"" of type '" "uint32_t""'"); 
+      }  
+      if (!argp2) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_sleep" "', argument " "2"" of type '" "uint32_t""'");
+      } else {
+        arg2 = *((uint32_t *)(argp2));
+      }
+    }
+    result = (int)fs_switch_ivr_sleep(arg1,arg2);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    XSRETURN(argvi);
+  fail:
+    
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_ivr_play_file2) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_ivr_play_file2(session,file);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_ivr_play_file2" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_ivr_play_file2" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    result = (int)fs_ivr_play_file2(arg1,arg2);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_ivr_collect_digits_callback) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    switch_input_callback_function_t arg2 ;
+    void *arg3 = (void *) 0 ;
+    unsigned int arg4 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    void *argp2 ;
+    int res2 = 0 ;
+    int res3 ;
+    unsigned int val4 ;
+    int ecode4 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 4) || (items > 4)) {
+      SWIG_croak("Usage: fs_switch_ivr_collect_digits_callback(session,dtmf_callback,buf,buflen);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_collect_digits_callback" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    {
+      res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_switch_input_callback_function_t,  0 );
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_collect_digits_callback" "', argument " "2"" of type '" "switch_input_callback_function_t""'"); 
+      }  
+      if (!argp2) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_collect_digits_callback" "', argument " "2"" of type '" "switch_input_callback_function_t""'");
+      } else {
+        arg2 = *((switch_input_callback_function_t *)(argp2));
+      }
+    }
+    res3 = SWIG_ConvertPtr(ST(2),SWIG_as_voidptrptr(&arg3), 0, 0);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_ivr_collect_digits_callback" "', argument " "3"" of type '" "void *""'"); 
+    }
+    ecode4 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4);
+    if (!SWIG_IsOK(ecode4)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "fs_switch_ivr_collect_digits_callback" "', argument " "4"" of type '" "unsigned int""'");
+    } 
+    arg4 = (unsigned int)(val4);
+    result = (int)fs_switch_ivr_collect_digits_callback(arg1,arg2,arg3,arg4);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    
+    
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_ivr_collect_digits_count) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    unsigned int arg3 ;
+    unsigned int arg4 ;
+    char *arg5 = (char *) 0 ;
+    char *arg6 = (char *) 0 ;
+    unsigned int arg7 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    unsigned int val3 ;
+    int ecode3 = 0 ;
+    unsigned int val4 ;
+    int ecode4 = 0 ;
+    int res5 ;
+    char *buf5 = 0 ;
+    int alloc5 = 0 ;
+    int res6 ;
+    char *buf6 = 0 ;
+    int alloc6 = 0 ;
+    unsigned int val7 ;
+    int ecode7 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 7) || (items > 7)) {
+      SWIG_croak("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    ecode3 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "3"" of type '" "unsigned int""'");
+    } 
+    arg3 = (unsigned int)(val3);
+    ecode4 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4);
+    if (!SWIG_IsOK(ecode4)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "4"" of type '" "unsigned int""'");
+    } 
+    arg4 = (unsigned int)(val4);
+    res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5);
+    if (!SWIG_IsOK(res5)) {
+      SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "5"" of type '" "char const *""'");
+    }
+    arg5 = buf5;
+    res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6);
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "6"" of type '" "char *""'");
+    }
+    arg6 = buf6;
+    ecode7 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(6), &val7);
+    if (!SWIG_IsOK(ecode7)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "fs_switch_ivr_collect_digits_count" "', argument " "7"" of type '" "unsigned int""'");
+    } 
+    arg7 = (unsigned int)(val7);
+    result = (int)fs_switch_ivr_collect_digits_count(arg1,arg2,arg3,arg4,(char const *)arg5,arg6,arg7);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    
+    
+    if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
+    if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
+    
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    
+    
+    if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
+    if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
+    
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_ivr_originate) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
+    char *arg3 = (char *) 0 ;
+    uint32_t arg4 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    void *argp2 = 0 ;
+    int res2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    void *argp4 ;
+    int res4 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 4) || (items > 4)) {
+      SWIG_croak("Usage: fs_switch_ivr_originate(session,bleg,bridgeto,timelimit_sec);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_originate" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_originate" "', argument " "2"" of type '" "switch_core_session_t **""'"); 
+    }
+    arg2 = (switch_core_session_t **)(argp2);
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_ivr_originate" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    {
+      res4 = SWIG_ConvertPtr(ST(3), &argp4, SWIGTYPE_p_uint32_t,  0 );
+      if (!SWIG_IsOK(res4)) {
+        SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "fs_switch_ivr_originate" "', argument " "4"" of type '" "uint32_t""'"); 
+      }  
+      if (!argp4) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_originate" "', argument " "4"" of type '" "uint32_t""'");
+      } else {
+        arg4 = *((uint32_t *)(argp4));
+      }
+    }
+    result = (int)fs_switch_ivr_originate(arg1,arg2,arg3,arg4);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    XSRETURN(argvi);
+  fail:
+    
+    
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_ivr_session_transfer) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) 0 ;
+    char *arg4 = (char *) 0 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    int res4 ;
+    char *buf4 = 0 ;
+    int alloc4 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 4) || (items > 4)) {
+      SWIG_croak("Usage: fs_switch_ivr_session_transfer(session,extension,dialplan,context);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_session_transfer" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_session_transfer" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_ivr_session_transfer" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "fs_switch_ivr_session_transfer" "', argument " "4"" of type '" "char *""'");
+    }
+    arg4 = buf4;
+    result = (int)fs_switch_ivr_session_transfer(arg1,arg2,arg3,arg4);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_ivr_speak_text) {
+  {
+    switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) 0 ;
+    char *arg4 = (char *) 0 ;
+    uint32_t arg5 ;
+    switch_input_callback_function_t arg6 ;
+    char *arg7 = (char *) 0 ;
+    void *arg8 = (void *) 0 ;
+    unsigned int arg9 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    int res4 ;
+    char *buf4 = 0 ;
+    int alloc4 = 0 ;
+    void *argp5 ;
+    int res5 = 0 ;
+    void *argp6 ;
+    int res6 = 0 ;
+    int res7 ;
+    char *buf7 = 0 ;
+    int alloc7 = 0 ;
+    int res8 ;
+    unsigned int val9 ;
+    int ecode9 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 9) || (items > 9)) {
+      SWIG_croak("Usage: fs_switch_ivr_speak_text(session,tts_name,voice_name,timer_name,rate,dtmf_callback,text,buf,buflen);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_core_session_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_ivr_speak_text" "', argument " "1"" of type '" "switch_core_session_t *""'"); 
+    }
+    arg1 = (switch_core_session_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_ivr_speak_text" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_ivr_speak_text" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "fs_switch_ivr_speak_text" "', argument " "4"" of type '" "char *""'");
+    }
+    arg4 = buf4;
+    {
+      res5 = SWIG_ConvertPtr(ST(4), &argp5, SWIGTYPE_p_uint32_t,  0 );
+      if (!SWIG_IsOK(res5)) {
+        SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "fs_switch_ivr_speak_text" "', argument " "5"" of type '" "uint32_t""'"); 
+      }  
+      if (!argp5) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_speak_text" "', argument " "5"" of type '" "uint32_t""'");
+      } else {
+        arg5 = *((uint32_t *)(argp5));
+      }
+    }
+    {
+      res6 = SWIG_ConvertPtr(ST(5), &argp6, SWIGTYPE_p_switch_input_callback_function_t,  0 );
+      if (!SWIG_IsOK(res6)) {
+        SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "fs_switch_ivr_speak_text" "', argument " "6"" of type '" "switch_input_callback_function_t""'"); 
+      }  
+      if (!argp6) {
+        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "fs_switch_ivr_speak_text" "', argument " "6"" of type '" "switch_input_callback_function_t""'");
+      } else {
+        arg6 = *((switch_input_callback_function_t *)(argp6));
+      }
+    }
+    res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7);
+    if (!SWIG_IsOK(res7)) {
+      SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "fs_switch_ivr_speak_text" "', argument " "7"" of type '" "char *""'");
+    }
+    arg7 = buf7;
+    res8 = SWIG_ConvertPtr(ST(7),SWIG_as_voidptrptr(&arg8), 0, 0);
+    if (!SWIG_IsOK(res8)) {
+      SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "fs_switch_ivr_speak_text" "', argument " "8"" of type '" "void *""'"); 
+    }
+    ecode9 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(8), &val9);
+    if (!SWIG_IsOK(ecode9)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "fs_switch_ivr_speak_text" "', argument " "9"" of type '" "unsigned int""'");
+    } 
+    arg9 = (unsigned int)(val9);
+    result = (int)fs_switch_ivr_speak_text(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+    if (alloc7 == SWIG_NEWOBJ) free((char*)buf7);
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+    if (alloc7 == SWIG_NEWOBJ) free((char*)buf7);
+    
+    
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_channel_get_variable) {
+  {
+    switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *result = 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 2)) {
+      SWIG_croak("Usage: fs_switch_channel_get_variable(channel,varname);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_channel_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_channel_get_variable" "', argument " "1"" of type '" "switch_channel_t *""'"); 
+    }
+    arg1 = (switch_channel_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_channel_get_variable" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    result = (char *)fs_switch_channel_get_variable(arg1,arg2);
+    ST(argvi) = SWIG_FromCharPtr(result); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_fs_switch_channel_set_variable) {
+  {
+    switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) 0 ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 3) || (items > 3)) {
+      SWIG_croak("Usage: fs_switch_channel_set_variable(channel,varname,value);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_switch_channel_t, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_switch_channel_set_variable" "', argument " "1"" of type '" "switch_channel_t *""'"); 
+    }
+    arg1 = (switch_channel_t *)(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_switch_channel_set_variable" "', argument " "2"" of type '" "char *""'");
+    }
+    arg2 = buf2;
+    res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "fs_switch_channel_set_variable" "', argument " "3"" of type '" "char *""'");
+    }
+    arg3 = buf3;
+    result = (int)fs_switch_channel_set_variable(arg1,arg2,arg3);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+    if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+    SWIG_croak_null();
+  }
+}
+
+
+
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
-static swig_type_info _swigt__p_switch_core_session = {"_p_switch_core_session", "struct switch_core_session *", 0, 0, 0};
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_p_switch_core_session_t = {"_p_p_switch_core_session_t", "switch_core_session_t **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_channel_t = {"_p_switch_channel_t", "switch_channel_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_file_handle_t = {"_p_switch_file_handle_t", "switch_file_handle_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_input_callback_function_t = {"_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
 
 static swig_type_info *swig_type_initial[] = {
-  &_swigt__p_switch_core_session,
+  &_swigt__p_char,
+  &_swigt__p_p_switch_core_session_t,
+  &_swigt__p_switch_channel_t,
+  &_swigt__p_switch_core_session_t,
+  &_swigt__p_switch_file_handle_t,
+  &_swigt__p_switch_input_callback_function_t,
+  &_swigt__p_uint32_t,
 };
 
-static swig_cast_info _swigc__p_switch_core_session[] = {  {&_swigt__p_switch_core_session, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_p_switch_core_session_t[] = {  {&_swigt__p_p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_channel_t[] = {  {&_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_file_handle_t[] = {  {&_swigt__p_switch_file_handle_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_input_callback_function_t[] = {  {&_swigt__p_switch_input_callback_function_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_uint32_t[] = {  {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
 
 static swig_cast_info *swig_cast_initial[] = {
-  _swigc__p_switch_core_session,
+  _swigc__p_char,
+  _swigc__p_p_switch_core_session_t,
+  _swigc__p_switch_channel_t,
+  _swigc__p_switch_core_session_t,
+  _swigc__p_switch_file_handle_t,
+  _swigc__p_switch_input_callback_function_t,
+  _swigc__p_uint32_t,
 };
 
 
@@ -1449,8 +2880,8 @@
 {"fs_perlc::fs_loadable_module_init", _wrap_fs_loadable_module_init},
 {"fs_perlc::fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown},
 {"fs_perlc::fs_console_loop", _wrap_fs_console_loop},
-{"fs_perlc::fs_console_log", _wrap_fs_console_log},
-{"fs_perlc::fs_console_clean", _wrap_fs_console_clean},
+{"fs_perlc::fs_consol_log", _wrap_fs_consol_log},
+{"fs_perlc::fs_consol_clean", _wrap_fs_consol_clean},
 {"fs_perlc::fs_core_session_locate", _wrap_fs_core_session_locate},
 {"fs_perlc::fs_channel_answer", _wrap_fs_channel_answer},
 {"fs_perlc::fs_channel_pre_answer", _wrap_fs_channel_pre_answer},
@@ -1459,9 +2890,19 @@
 {"fs_perlc::fs_channel_get_variable", _wrap_fs_channel_get_variable},
 {"fs_perlc::fs_channel_set_state", _wrap_fs_channel_set_state},
 {"fs_perlc::fs_ivr_play_file", _wrap_fs_ivr_play_file},
+{"fs_perlc::fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file},
+{"fs_perlc::fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep},
+{"fs_perlc::fs_ivr_play_file2", _wrap_fs_ivr_play_file2},
+{"fs_perlc::fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback},
+{"fs_perlc::fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count},
+{"fs_perlc::fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate},
+{"fs_perlc::fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer},
+{"fs_perlc::fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text},
+{"fs_perlc::fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable},
+{"fs_perlc::fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable},
 {0,0}
 };
-/*************************************************************************
+/* -----------------------------------------------------------------------------
  * Type initialization:
  * This problem is tough by the requirement that no dynamic 
  * memory is used. Also, since swig_type_info structures store pointers to 
@@ -1473,7 +2914,7 @@
  * swig_module, and does all the lookup, filling in the swig_module.types
  * array with the correct data and linking the correct swig_cast_info
  * structures together.
-
+ *
  * The generated swig_type_info structures are assigned staticly to an initial 
  * array. We just loop though that array, and handle each type individually.
  * First we lookup if this type has been already loaded, and if so, use the
@@ -1487,7 +2928,7 @@
  * we find the array of casts associated with the type, and loop through it 
  * adding the casts to the list. The one last trick we need to do is making
  * sure the type pointer in the swig_cast_info struct is correct.
-
+ *
  * First off, we lookup the cast->type name to see if it is already loaded. 
  * There are three cases to handle:
  *  1) If the cast->type has already been loaded AND the type we are adding
@@ -1500,114 +2941,175 @@
  *  3) Finally, if cast->type has not already been loaded, then we add that
  *     swig_cast_info to the linked list (because the cast->type) pointer will
  *     be correct.
-**/
+ * ----------------------------------------------------------------------------- */
 
 #ifdef __cplusplus
 extern "C" {
+#if 0
+} /* c-mode */
 #endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+  size_t i;
+  swig_module_info *module_head;
+  static int init_run = 0;
+  
+  clientdata = clientdata;
+  
+  if (init_run) return;
+  init_run = 1;
+  
+  /* Initialize the swig_module */
+  swig_module.type_initial = swig_type_initial;
+  swig_module.cast_initial = swig_cast_initial;
+  
+  /* Try and load any already created modules */
+  module_head = SWIG_GetModule(clientdata);
+  if (module_head) {
+    swig_module.next = module_head->next;
+    module_head->next = &swig_module;
+  } else {
+    /* This is the first module loaded */
+    swig_module.next = &swig_module;
+    SWIG_SetModule(clientdata, &swig_module);
+  }
+  
+  /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+  for (i = 0; i < swig_module.size; ++i) {
+    swig_type_info *type = 0;
+    swig_type_info *ret;
+    swig_cast_info *cast;
     
-    SWIGRUNTIME void
-    SWIG_InitializeModule(void *clientdata) {
-        swig_type_info *type, *ret;
-        swig_cast_info *cast;
-        size_t i;
-        swig_module_info *module_head;
-        static int init_run = 0;
-        
-        clientdata = clientdata;
-        
-        if (init_run) return;
-        init_run = 1;
-        
-        /* Initialize the swig_module */
-        swig_module.type_initial = swig_type_initial;
-        swig_module.cast_initial = swig_cast_initial;
-        
-        /* Try and load any already created modules */
-        module_head = SWIG_GetModule(clientdata);
-        if (module_head) {
-            swig_module.next = module_head->next;
-            module_head->next = &swig_module;
+#ifdef SWIGRUNTIME_DEBUG
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+    
+    /* if there is another module already loaded */
+    if (swig_module.next != &swig_module) {
+      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+    }
+    if (type) {
+      /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+      if (swig_module.type_initial[i]->clientdata) {
+        type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+      }
+    } else {
+      type = swig_module.type_initial[i];
+    }
+    
+    /* Insert casting types */
+    cast = swig_module.cast_initial[i];
+    while (cast->type) {
+      /* Don't need to add information already in the list */
+      ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+      if (swig_module.next != &swig_module) {
+        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+        if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+      }
+      if (ret) {
+        if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+          printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+          cast->type = ret;
+          ret = 0;
         } else {
-            /* This is the first module loaded */
-            swig_module.next = &swig_module;
-            SWIG_SetModule(clientdata, &swig_module);
+          /* Check for casting already in the list */
+          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+          if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+          if (!ocast) ret = 0;
         }
-        
-        /* Now work on filling in swig_module.types */
-        for (i = 0; i < swig_module.size; ++i) {
-            type = 0;
-            
-            /* if there is another module already loaded */
-            if (swig_module.next != &swig_module) {
-                type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
-            }
-            if (type) {
-                /* Overwrite clientdata field */
-                if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata;
-            } else {
-                type = swig_module.type_initial[i];
-            }
-            
-            /* Insert casting types */
-            cast = swig_module.cast_initial[i];
-            while (cast->type) {
-                /* Don't need to add information already in the list */
-                ret = 0;
-                if (swig_module.next != &swig_module) {
-                    ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
-                }
-                if (ret && type == swig_module.type_initial[i]) {
-                    cast->type = ret;
-                    ret = 0;
-                }
-                
-                if (!ret) {
-                    if (type->cast) {
-                        type->cast->prev = cast;
-                        cast->next = type->cast;
-                    }
-                    type->cast = cast;
-                }
-                
-                cast++;
-            }
-            
-            /* Set entry in modules->types array equal to the type */
-            swig_module.types[i] = type;
+      }
+      
+      if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+        if (type->cast) {
+          type->cast->prev = cast;
+          cast->next = type->cast;
         }
-        swig_module.types[i] = 0;
+        type->cast = cast;
+      }
+      cast++;
     }
-    
-    /* This function will propagate the clientdata field of type to
-    * any new swig_type_info structures that have been added into the list
-    * of equivalent types.  It is like calling
-    * SWIG_TypeClientData(type, clientdata) a second time.
-    */
-    SWIGRUNTIME void
-    SWIG_PropagateClientData(void) {
-        size_t i;
-        swig_cast_info *equiv;
-        static int init_run = 0;
-        
-        if (init_run) return;
-        init_run = 1;
-        
-        for (i = 0; i < swig_module.size; i++) {
-            if (swig_module.types[i]->clientdata) {
-                equiv = swig_module.types[i]->cast;
-                while (equiv) {
-                    if (!equiv->converter) {
-                        if (equiv->type && !equiv->type->clientdata)
-                        SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
-                    }
-                    equiv = equiv->next;
-                }
-            }
+    /* Set entry in modules->types array equal to the type */
+    swig_module.types[i] = type;
+  }
+  swig_module.types[i] = 0;
+  
+#ifdef SWIGRUNTIME_DEBUG
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+  for (i = 0; i < swig_module.size; ++i) {
+    int j = 0;
+    swig_cast_info *cast = swig_module.cast_initial[i];
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+    while (cast->type) {
+      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+      cast++;
+      ++j;
+    }
+    printf("---- Total casts: %d\n",j);
+  }
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types.  It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+  size_t i;
+  swig_cast_info *equiv;
+  static int init_run = 0;
+  
+  if (init_run) return;
+  init_run = 1;
+  
+  for (i = 0; i < swig_module.size; i++) {
+    if (swig_module.types[i]->clientdata) {
+      equiv = swig_module.types[i]->cast;
+      while (equiv) {
+        if (!equiv->converter) {
+          if (equiv->type && !equiv->type->clientdata)
+          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
         }
+        equiv = equiv->next;
+      }
     }
-    
+  }
+}
+
 #ifdef __cplusplus
+#if 0
+{
+  /* c-mode */
+#endif
 }
 #endif
 
@@ -1618,55 +3120,55 @@
 #endif
 
 XS(SWIG_init) {
-    dXSARGS;
-    int i;
-    
-    SWIG_InitializeModule(0);
-    
-    /* Install commands */
-    for (i = 0; swig_commands[i].name; i++) {
-        newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
+  dXSARGS;
+  int i;
+  
+  SWIG_InitializeModule(0);
+  
+  /* Install commands */
+  for (i = 0; swig_commands[i].name; i++) {
+    newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
+  }
+  
+  /* Install variables */
+  for (i = 0; swig_variables[i].name; i++) {
+    SV *sv;
+    sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2);
+    if (swig_variables[i].type) {
+      SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
+    } else {
+      sv_setiv(sv,(IV) 0);
     }
-    
-    /* Install variables */
-    for (i = 0; swig_variables[i].name; i++) {
-        SV *sv;
-        sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2);
-        if (swig_variables[i].type) {
-            SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
-        } else {
-            sv_setiv(sv,(IV) 0);
-        }
-        swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); 
+    swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); 
+  }
+  
+  /* Install constant */
+  for (i = 0; swig_constants[i].type; i++) {
+    SV *sv;
+    sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2);
+    switch(swig_constants[i].type) {
+    case SWIG_INT:
+      sv_setiv(sv, (IV) swig_constants[i].lvalue);
+      break;
+    case SWIG_FLOAT:
+      sv_setnv(sv, (double) swig_constants[i].dvalue);
+      break;
+    case SWIG_STRING:
+      sv_setpv(sv, (char *) swig_constants[i].pvalue);
+      break;
+    case SWIG_POINTER:
+      SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
+      break;
+    case SWIG_BINARY:
+      SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
+      break;
+    default:
+      break;
     }
-    
-    /* Install constant */
-    for (i = 0; swig_constants[i].type; i++) {
-        SV *sv;
-        sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2);
-        switch(swig_constants[i].type) {
-            case SWIG_INT:
-            sv_setiv(sv, (IV) swig_constants[i].lvalue);
-            break;
-            case SWIG_FLOAT:
-            sv_setnv(sv, (double) swig_constants[i].dvalue);
-            break;
-            case SWIG_STRING:
-            sv_setpv(sv, (char *) swig_constants[i].pvalue);
-            break;
-            case SWIG_POINTER:
-            SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
-            break;
-            case SWIG_BINARY:
-            SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
-            break;
-            default:
-            break;
-        }
-        SvREADONLY_on(sv);
-    }
-    
-    ST(0) = &PL_sv_yes;
-    XSRETURN(1);
+    SvREADONLY_on(sv);
+  }
+  
+  ST(0) = &PL_sv_yes;
+  XSRETURN(1);
 }
 

Modified: freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/Makefile
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/Makefile	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/Makefile	Fri Sep 22 14:22:15 2006
@@ -61,7 +61,7 @@
 
 CFLAGS += -I$(BASE)/libs/mozilla/js/src -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX  -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/js/src -I$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX  -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -I$(OS_CONFIG)_DBG.OBJ
 LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX  -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX  -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -lteletone
-OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -lcurl
+OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -lcurl -letpan
 LINKER=$(CC)
 
 
@@ -69,7 +69,8 @@
 
 depends:
 	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) mozilla.tar.gz --prefix=$(PREFIX)
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install curl-7.15.2.tar.gz --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install curl-7.15.2.tar.gz --prefix=$(PREFIX) --without-libidn
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libetpan-0.45.tar.gz --prefix=$(PREFIX)
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o 

Modified: freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Fri Sep 22 14:22:15 2006
@@ -32,7 +32,8 @@
 #ifndef HAVE_CURL
 #define HAVE_CURL
 #endif
-#define JS_BUFFER_SIZE 131072
+#define JS_BUFFER_SIZE 1024 * 32
+#define JS_BLOCK_SIZE JS_BUFFER_SIZE
 #ifdef __ICC
 #pragma warning (disable:310 193 1418)
 #endif
@@ -106,7 +107,7 @@
 };
 
 struct js_session {
-	switch_core_session *session;
+	switch_core_session_t *session;
 	JSContext *cx;
 	JSObject *obj;
 	unsigned int flags;
@@ -116,13 +117,13 @@
 	teletone_generation_session_t ts;
 	JSContext *cx;
 	JSObject *obj;
-	switch_core_session *session;
-	switch_codec codec;
-	switch_buffer *audio_buffer;
-	switch_buffer *loop_buffer;
-	switch_memory_pool *pool;
-	switch_timer *timer;
-	switch_timer timer_base;
+	switch_core_session_t *session;
+	switch_codec_t codec;
+	switch_buffer_t *audio_buffer;
+	switch_buffer_t *loop_buffer;
+	switch_memory_pool_t *pool;
+	switch_timer_t *timer;
+	switch_timer_t timer_base;
 	char code_buffer[1024];
 	char ret_val[1024];
 	unsigned int flags;
@@ -132,16 +133,16 @@
 	char *path;
 	unsigned int flags;
 	switch_file_t *fd;
-	switch_memory_pool *pool;
+	switch_memory_pool_t *pool;
 	char *buf;
 	switch_size_t buflen;
 	int32 bufsize;
 };
 
 struct db_obj {
-	switch_memory_pool *pool;
-	switch_core_db *db;
-	switch_core_db_stmt *stmt;
+	switch_memory_pool_t *pool;
+	switch_core_db_t *db;
+	switch_core_db_stmt_t *stmt;
 	char *dbname;
 	char code_buffer[2048];
 	JSContext *cx;
@@ -149,6 +150,262 @@
 };
 
 
+/* Event Object */
+/*********************************************************************************/
+static JSBool event_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	if (argc > 0) {
+		switch_event_t *event;
+		switch_event_types_t etype;
+		char *ename = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+
+		if (switch_name_event(ename, &etype) != SWITCH_STATUS_SUCCESS) {
+			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			return JS_TRUE;
+		}
+
+		if (etype == SWITCH_EVENT_CUSTOM) {
+			char *subclass_name;
+			if (argc < 1) {
+				*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+				return JS_TRUE;
+			}
+			
+			subclass_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+			if (switch_event_create_subclass(&event, etype, subclass_name) != SWITCH_STATUS_SUCCESS) {
+				*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+				return JS_TRUE;
+			}
+
+		} else {
+			if (!switch_event_create(&event, etype) != SWITCH_STATUS_SUCCESS) {
+				*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+				return JS_TRUE;
+			}
+		}
+
+		JS_SetPrivate(cx, obj, event);
+		return JS_TRUE;
+	}
+
+	return JS_FALSE;
+}
+
+static void event_destroy(JSContext *cx, JSObject *obj)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (event) {
+		switch_event_destroy(&event);
+	}
+}
+
+static JSBool event_add_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (!event) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
+	if (argc > 1) {
+		char *hname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		char *hval = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, hname, hval);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		return JS_TRUE;
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	return JS_TRUE;
+}
+
+static JSBool event_get_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (!event) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
+	if (argc > 0) {
+		char *hname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		char *val = switch_event_get_header(event, hname);
+		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+		return JS_TRUE;
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	return JS_TRUE;
+}
+
+static JSBool event_add_body(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (!event) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
+	if (argc > 0) {
+		char *body = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		switch_event_add_body(event, body);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		return JS_TRUE;
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	return JS_TRUE;
+}
+
+static JSBool event_get_body(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (!event) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
+	*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_event_get_body(event)));
+
+	return JS_TRUE;
+}
+
+static JSBool event_serialize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+	char buf[1024];
+	uint8_t isxml = 0;
+
+	if (!event) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
+	if (argc > 0) {
+		char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		if (!strcasecmp(arg, "xml")) {
+			isxml++;
+		}
+	}
+
+	if (isxml) {
+		switch_xml_t xml;
+		char *xmlstr;
+		if ((xml = switch_event_xmlize(event, NULL))) {
+            xmlstr = switch_xml_toxml(xml);
+			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, xmlstr));
+			switch_xml_free(xml);
+            free(xmlstr);
+		} else {
+			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		}
+	} else {
+		switch_event_serialize(event, buf, sizeof(buf), NULL);
+		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, buf));
+	}
+
+	return JS_TRUE;
+}
+
+static JSBool event_fire(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (event) {
+		switch_event_fire(&event);
+		JS_SetPrivate(cx, obj, NULL);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		return JS_TRUE;
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	return JS_TRUE;
+}
+
+static JSBool event_destroy_(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+
+	if (event) {
+		switch_event_destroy(&event);
+		JS_SetPrivate(cx, obj, NULL);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+		return JS_TRUE;
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	return JS_TRUE;
+}
+
+
+
+enum event_tinyid {
+	EVENT_READY
+};
+
+static JSFunctionSpec event_methods[] = {
+	{"addHeader", event_add_header, 1},
+	{"getHeader", event_get_header, 1},
+	{"addBody", event_add_body, 1},
+	{"getBody", event_get_body, 1},
+	{"serialize", event_serialize, 0},
+	{"fire", event_fire, 0},
+	{"destroy", event_destroy_, 0},
+	{0}
+};
+
+
+static JSPropertySpec event_props[] = {
+	{"ready", EVENT_READY, JSPROP_READONLY|JSPROP_PERMANENT}, 
+	{0}
+};
+
+
+static JSBool event_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
+{
+	JSBool res = JS_TRUE;
+	switch_event_t *event = JS_GetPrivate(cx, obj);
+	char *name;
+	int param = 0;
+
+    if (!event) {
+        *vp = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+    }
+
+	
+	name = JS_GetStringBytes(JS_ValueToString(cx, id));
+    /* numbers are our props anything else is a method */
+    if (name[0] >= 48 && name[0] <= 57) {
+        param = atoi(name);
+    } else {
+        return JS_TRUE;
+    }
+	
+	switch(param) {
+	case EVENT_READY:
+		*vp = BOOLEAN_TO_JSVAL( JS_TRUE );
+		break;
+	}
+
+	return res;
+}
+
+JSClass event_class = {
+	"Event", JSCLASS_HAS_PRIVATE, 
+	JS_PropertyStub,  JS_PropertyStub,	event_getProperty,  JS_PropertyStub, 
+	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  event_destroy, NULL, NULL, NULL,
+	event_construct
+};
+
+
+
+
 static void js_error(JSContext *cx, const char *message, JSErrorReport *report)
 {
 	if (message) {
@@ -157,7 +414,7 @@
 	
 }
 
-static switch_status init_js(void)
+static switch_status_t init_js(void)
 {
 	memset(&globals, 0, sizeof(globals));
 	globals.gQuitting = JS_FALSE;
@@ -175,231 +432,292 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status js_stream_dtmf_callback(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_stream_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	char code[2048];
-	struct dtmf_callback_state *cb_state = buf;
-	struct js_session *jss = cb_state->session_state;
-	switch_file_handle *fh = cb_state->extra;
-	jsval rval;
-	char *ret;
+	switch (itype) {
+	case SWITCH_INPUT_TYPE_DTMF: {
+		char *dtmf = (char *) input;
+		char code[2048];
+		struct dtmf_callback_state *cb_state = buf;
+		struct js_session *jss = cb_state->session_state;
+		switch_file_handle_t *fh = cb_state->extra;
+		jsval rval;
+		char *ret;
 	
-	if (!jss) {
-		return SWITCH_STATUS_FALSE;
-	}
-	
-	if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
-		char *d;
-		if (!cb_state->digit_count) {
-			cb_state->digit_count = atoi(cb_state->code_buffer);
+		if (!jss) {
+			return SWITCH_STATUS_FALSE;
 		}
+	
+		if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+			char *d;
+			if (!cb_state->digit_count) {
+				cb_state->digit_count = atoi(cb_state->code_buffer);
+			}
 
-		for(d = dtmf; *d; d++) {
-			cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
-			if ((cb_state->ret_buffer_len > cb_state->digit_count)||
-				(cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
-				(cb_state->ret_buffer_len >= cb_state->digit_count)
-				) {
-				return SWITCH_STATUS_FALSE;
+			for(d = dtmf; *d; d++) {
+				cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+				if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+					(cb_state->ret_buffer_len > (int32_t) sizeof(cb_state->ret_buffer))||
+					(cb_state->ret_buffer_len >= cb_state->digit_count)
+					) {
+					return SWITCH_STATUS_FALSE;
+				}
 			}
-		}
-		return SWITCH_STATUS_SUCCESS;
-	} else {
-		snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
-		eval_some_js(code, jss->cx, jss->obj, &rval);
-		ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
+			return SWITCH_STATUS_SUCCESS;
+		} else {
+			snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+			eval_some_js(code, jss->cx, jss->obj, &rval);
+			ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
 
-		if (!strncasecmp(ret, "speed", 4)) {
-			char *p;
+			if (!strncasecmp(ret, "speed", 4)) {
+				char *p;
 			
-			if ((p = strchr(ret, ':'))) {
-				p++;
-				if (*p == '+' || *p == '-') {
-					int step;
-					if (!(step = atoi(p))) {
-						step = 1;
+				if ((p = strchr(ret, ':'))) {
+					p++;
+					if (*p == '+' || *p == '-') {
+						int step;
+						if (!(step = atoi(p))) {
+							step = 1;
+						}
+						fh->speed += step;
+					} else {
+						int speed = atoi(p);
+						fh->speed = speed;
 					}
-					fh->speed += step;
+					return SWITCH_STATUS_SUCCESS;
+				}
+			
+				return SWITCH_STATUS_FALSE;
+			} else if (!strcasecmp(ret, "pause")) {
+				if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+					switch_clear_flag(fh, SWITCH_FILE_PAUSE);
 				} else {
-					int speed = atoi(p);
-					fh->speed = speed;
+					switch_set_flag(fh, SWITCH_FILE_PAUSE);
 				}
 				return SWITCH_STATUS_SUCCESS;
-			}
-			
-			return SWITCH_STATUS_FALSE;
-		} else if (!strcasecmp(ret, "pause")) {
-			if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
-				switch_clear_flag(fh, SWITCH_FILE_PAUSE);
-			} else {
-				switch_set_flag(fh, SWITCH_FILE_PAUSE);
-			}
-			return SWITCH_STATUS_SUCCESS;
-		} else if (!strcasecmp(ret, "restart")) {
-			unsigned int pos = 0;
-			fh->speed = 0;
-			switch_core_file_seek(fh, &pos, 0, SEEK_SET);
-			return SWITCH_STATUS_SUCCESS;
-		} else if (!strncasecmp(ret, "seek", 4)) {
-			switch_codec *codec;
-			unsigned int samps = 0;
-			unsigned int pos = 0;
-			char *p;
-			codec = switch_core_session_get_read_codec(jss->session);
+			} else if (!strcasecmp(ret, "restart")) {
+				unsigned int pos = 0;
+				fh->speed = 0;
+				switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+				return SWITCH_STATUS_SUCCESS;
+			} else if (!strncasecmp(ret, "seek", 4)) {
+				switch_codec_t *codec;
+				unsigned int samps = 0;
+				unsigned int pos = 0;
+				char *p;
+				codec = switch_core_session_get_read_codec(jss->session);
 
-			if ((p = strchr(ret, ':'))) {
-				p++;
-				if (*p == '+' || *p == '-') {
-					int step;
-					if (!(step = atoi(p))) {
-						step = 1000;
-					}
-					if (step > 0) {
-						samps = step * (codec->implementation->samples_per_second / 1000);
-						switch_core_file_seek(fh, &pos, samps, SEEK_CUR);		
+				if ((p = strchr(ret, ':'))) {
+					p++;
+					if (*p == '+' || *p == '-') {
+						int step;
+						if (!(step = atoi(p))) {
+							step = 1000;
+						}
+						if (step > 0) {
+							samps = step * (codec->implementation->samples_per_second / 1000);
+							switch_core_file_seek(fh, &pos, samps, SEEK_CUR);		
+						} else {
+							samps = step * (codec->implementation->samples_per_second / 1000);
+							switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+						}
 					} else {
-						samps = step * (codec->implementation->samples_per_second / 1000);
-						switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+						samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+						switch_core_file_seek(fh, &pos, samps, SEEK_SET);
 					}
-				} else {
-					samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
-					switch_core_file_seek(fh, &pos, samps, SEEK_SET);
 				}
+
+				return SWITCH_STATUS_SUCCESS;
 			}
 
-			return SWITCH_STATUS_SUCCESS;
-		}
-
-		if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
-			return SWITCH_STATUS_SUCCESS;
-		}
+			if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+				return SWITCH_STATUS_SUCCESS;
+			}
 	
-		if (ret) {
-			switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			if (ret) {
+				switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			}
 		}
+
+		return SWITCH_STATUS_FALSE;
 	}
+		break;
+	default:
+		break;
+	}
+	return SWITCH_STATUS_SUCCESS;
 
-	return SWITCH_STATUS_FALSE;
 }
 
-
-static switch_status js_record_dtmf_callback(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_record_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	char code[2048];
-	struct dtmf_callback_state *cb_state = buf;
-	struct js_session *jss = cb_state->session_state;
-	switch_file_handle *fh = cb_state->extra;
-	jsval rval;
-	char *ret;
+	switch (itype) {
+	case SWITCH_INPUT_TYPE_DTMF: {
+		char *dtmf = (char *) input;
+		char code[2048];
+		struct dtmf_callback_state *cb_state = buf;
+		struct js_session *jss = cb_state->session_state;
+		switch_file_handle_t *fh = cb_state->extra;
+		jsval rval;
+		char *ret;
 	
-	if (!jss) {
-		return SWITCH_STATUS_FALSE;
-	}
-	
-	if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
-		char *d;
-		if (!cb_state->digit_count) {
-			cb_state->digit_count = atoi(cb_state->code_buffer);
+		if (!jss) {
+			return SWITCH_STATUS_FALSE;
 		}
-
-		for(d = dtmf; *d; d++) {
-			cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
-			if ((cb_state->ret_buffer_len > cb_state->digit_count)||
-				(cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
-				(cb_state->ret_buffer_len >= cb_state->digit_count)
-				) {
-				return SWITCH_STATUS_FALSE;
+	
+		if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+			char *d;
+			if (!cb_state->digit_count) {
+				cb_state->digit_count = atoi(cb_state->code_buffer);
 			}
-		}
-		return SWITCH_STATUS_SUCCESS;
-	} else {
-		snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
-		eval_some_js(code, jss->cx, jss->obj, &rval);
-		ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
 
-		if (!strcasecmp(ret, "pause")) {
-			if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
-				switch_clear_flag(fh, SWITCH_FILE_PAUSE);
-			} else {
-				switch_set_flag(fh, SWITCH_FILE_PAUSE);
+			for(d = dtmf; *d; d++) {
+				cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+				if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+					(cb_state->ret_buffer_len > (int32_t) sizeof(cb_state->ret_buffer))||
+					(cb_state->ret_buffer_len >= cb_state->digit_count)
+					) {
+					return SWITCH_STATUS_FALSE;
+				}
 			}
 			return SWITCH_STATUS_SUCCESS;
-		} else if (!strcasecmp(ret, "restart")) {
-			unsigned int pos = 0;
-			fh->speed = 0;
-			switch_core_file_seek(fh, &pos, 0, SEEK_SET);
-			return SWITCH_STATUS_SUCCESS;
-		}
+		} else {
+			snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+			eval_some_js(code, jss->cx, jss->obj, &rval);
+			ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
 
-		if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
-			return SWITCH_STATUS_SUCCESS;
-		}
+			if (!strcasecmp(ret, "pause")) {
+				if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+					switch_clear_flag(fh, SWITCH_FILE_PAUSE);
+				} else {
+					switch_set_flag(fh, SWITCH_FILE_PAUSE);
+				}
+				return SWITCH_STATUS_SUCCESS;
+			} else if (!strcasecmp(ret, "restart")) {
+				unsigned int pos = 0;
+				fh->speed = 0;
+				switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+				return SWITCH_STATUS_SUCCESS;
+			}
+
+			if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+				return SWITCH_STATUS_SUCCESS;
+			}
 	
-		if (ret) {
-			switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			if (ret) {
+				switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			}
 		}
+		return SWITCH_STATUS_FALSE;
 	}
+		break;
+	default:
+		break;
+	}
 
-	return SWITCH_STATUS_FALSE;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status js_speak_dtmf_callback(switch_core_session *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_speak_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
 {
-	char code[2048];
-	struct dtmf_callback_state *cb_state = buf;
-	struct js_session *jss = cb_state->session_state;
-	jsval rval;
-	char *ret;
+	switch (itype) {
+	case SWITCH_INPUT_TYPE_DTMF: {
+		char *dtmf = (char *) input;
+		char code[2048];
+		struct dtmf_callback_state *cb_state = buf;
+		struct js_session *jss = cb_state->session_state;
+		jsval rval;
+		char *ret;
 	
-	if (!jss) {
-		return SWITCH_STATUS_FALSE;
-	}
-	
-	if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
-		char *d;
-		if (!cb_state->digit_count) {
-			cb_state->digit_count = atoi(cb_state->code_buffer);
+		if (!jss) {
+			return SWITCH_STATUS_FALSE;
 		}
-
-		for(d = dtmf; *d; d++) {
-			cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
-			if ((cb_state->ret_buffer_len > cb_state->digit_count)||
-				(cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
-				(cb_state->ret_buffer_len >= cb_state->digit_count)
-				) {
-				return SWITCH_STATUS_FALSE;
+	
+		if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+			char *d;
+			if (!cb_state->digit_count) {
+				cb_state->digit_count = atoi(cb_state->code_buffer);
 			}
-		}
-		return SWITCH_STATUS_SUCCESS;
-	} else {
-		snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
-		eval_some_js(code, jss->cx, jss->obj, &rval);
-		ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
 
-		if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+			for(d = dtmf; *d; d++) {
+				cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+				if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+					(cb_state->ret_buffer_len > (int32_t) sizeof(cb_state->ret_buffer))||
+					(cb_state->ret_buffer_len >= cb_state->digit_count)
+					) {
+					return SWITCH_STATUS_FALSE;
+				}
+			}
 			return SWITCH_STATUS_SUCCESS;
-		}
+		} else {
+			snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+			eval_some_js(code, jss->cx, jss->obj, &rval);
+			ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
+
+			if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+				return SWITCH_STATUS_SUCCESS;
+			}
 	
-		if (ret) {
-			switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			if (ret) {
+				switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+			}
 		}
+
+		return SWITCH_STATUS_FALSE;
 	}
+		break;
+	default:
+		break;
+	}
 
-	return SWITCH_STATUS_FALSE;
+	return SWITCH_STATUS_SUCCESS;
+	
 }
 
+static JSBool session_flush_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+	switch_channel_t *channel;
+	char buf[256];
+	switch_size_t has;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+	if ((has = switch_channel_has_dtmf(channel))) {
+		switch_channel_dequeue_dtmf(channel, buf, has);
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+    return JS_TRUE;
+}
+
+static JSBool session_flush_events(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+	switch_event_t *event;
+
+	while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
+		switch_event_destroy(&event);
+	}
+	
+	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+    return JS_TRUE;
+	
+}
+
 static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 	char *file_name = NULL;
 	char *dtmf_callback = NULL;
 	void *bp = NULL;
 	int len = 0;
-	switch_dtmf_callback_function dtmf_func = NULL;
+	switch_input_callback_function_t dtmf_func = NULL;
 	struct dtmf_callback_state cb_state = {0};
-	switch_file_handle fh;
+	switch_file_handle_t fh;
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -437,15 +755,15 @@
 static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 	char *file_name = NULL;
 	char *timer_name = NULL;
 	char *dtmf_callback = NULL;
 	void *bp = NULL;
 	int len = 0;
-	switch_dtmf_callback_function dtmf_func = NULL;
+	switch_input_callback_function_t dtmf_func = NULL;
 	struct dtmf_callback_state cb_state = {0};
-	switch_file_handle fh;
+	switch_file_handle_t fh;
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -486,20 +804,69 @@
 	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
 }
 
+static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+    switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+	if (argc > 1) {
+		char *var, *val;
+
+		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		switch_channel_set_variable(channel, var, val);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+	} else {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	}
+ 	
+	return JS_TRUE;
+}
+
+static JSBool session_get_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+    switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+	if (argc > 0) {
+		char *var, *val;
+		
+		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		val = switch_channel_get_variable(channel, var);
+
+		if (val) {
+			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+		} else {
+			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		}
+	} else {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	}
+ 	
+	return JS_TRUE;
+}
+
+
 static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 	char *tts_name = NULL;
 	char *voice_name = NULL;
 	char *text = NULL;
 	char *dtmf_callback = NULL;
 	char *timer_name = NULL;
-	switch_codec *codec;
+	switch_codec_t *codec;
 	void *bp = NULL;
 	int len = 0;
 	struct dtmf_callback_state cb_state = {0};
-	switch_dtmf_callback_function dtmf_func = NULL;
+	switch_input_callback_function_t dtmf_func = NULL;
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -559,9 +926,7 @@
 	char *buf;
 	int digits;
 	int32 timeout = 5000;
-	int32 poll_chan = 1;
 	
-	
 	if (argc > 0) {
 		char term;
 		digits = atoi(JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
@@ -571,11 +936,9 @@
 		if (argc > 2) {
 			JS_ValueToInt32(cx, argv[2], &timeout);
 		}
-		if (argc > 3) {
-			JS_ValueToInt32(cx, argv[3], &poll_chan);
-		}
+
 		buf = switch_core_session_alloc(jss->session, digits);
-		switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout, poll_chan ? SWITCH_TRUE : SWITCH_FALSE);
+		switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout);
 		*rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) );
 		return JS_TRUE;
 	}
@@ -586,7 +949,7 @@
 static JSBool session_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -598,7 +961,7 @@
 static JSBool session_ready(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -610,7 +973,7 @@
 static JSBool session_wait_for_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
 	switch_time_t started;
 	unsigned int elapsed;
 	int32 timeout = 60;
@@ -639,7 +1002,7 @@
 {
 	JSBool retval = JS_FALSE;
 	if (argc > 1) {
-		const switch_application_interface *application_interface;
+		const switch_application_interface_t *application_interface;
 		char *app_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *app_arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -656,16 +1019,69 @@
 	return JS_TRUE;
 }
 
+static JSBool session_get_event(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+	switch_event_t *event;
 
+	if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
+		JSObject *Event;
+		if ((Event = JS_DefineObject(cx, obj, "Event", &event_class, NULL, 0))) {
+			if ((JS_SetPrivate(cx, Event, event) &&
+				 JS_DefineProperties(cx, Event, event_props) &&
+				 JS_DefineFunctions(cx, Event, event_methods))) {
+				*rval = OBJECT_TO_JSVAL ( Event );
+				return JS_TRUE;
+			}
+		}
+	}
+	
+	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+    return JS_TRUE;
+	
+}
+
+static JSBool session_send_event(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+	switch_event_t *event;
+	JSObject *Event;
+
+	if (argc > 0) {
+		if (JS_ValueToObject(cx, argv[0], &Event)) {
+			if ((event = JS_GetPrivate(cx, Event))) {
+				if (switch_core_session_receive_event(jss->session, &event) != SWITCH_STATUS_SUCCESS) {
+					*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+					return JS_TRUE;
+				}
+
+				JS_SetPrivate(cx, Event, NULL);
+			}
+		}
+	}
+
+	*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+    return JS_TRUE;
+	
+}
+
+
 static JSBool session_hangup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel *channel;
+	switch_channel_t *channel;
+	char *cause_name = NULL;
+	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
+	if (argc > 1) {
+		cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		cause = switch_channel_str2cause(cause_name);
+	}
+
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	switch_channel_hangup(channel);
+	switch_channel_hangup(channel, cause);
 	switch_core_session_kill_channel(jss->session, SWITCH_SIG_KILL);
 	return JS_TRUE;
 }
@@ -747,7 +1163,7 @@
 		url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 
-		curl_global_init(CURL_GLOBAL_ALL);
+
 		curl_handle = curl_easy_init();
 		if (!strncasecmp(url, "https", 5)) {
 			curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@@ -813,6 +1229,7 @@
 }
 #endif
 
+
 /* Session Object */
 /*********************************************************************************/
 enum session_tinyid {
@@ -823,11 +1240,17 @@
 static JSFunctionSpec session_methods[] = {
 	{"streamFile", session_streamfile, 1}, 
 	{"recordFile", session_recordfile, 1}, 
+	{"flushEvents", session_flush_events, 1}, 
+	{"flushDigits", session_flush_digits, 1}, 
 	{"speak", session_speak, 1}, 
+	{"setVariable", session_set_variable, 1}, 
+	{"getVariable", session_get_variable, 1}, 
 	{"getDigits", session_get_digits, 1},
 	{"answer", session_answer, 0}, 
 	{"ready", session_ready, 0}, 
 	{"waitForAnswer", session_wait_for_answer, 0}, 
+	{"getEvent", session_get_event, 0},
+	{"sendEvent", session_send_event, 0},
 	{"hangup", session_hangup, 0}, 
 	{"execute", session_execute, 0}, 
 	{0}
@@ -852,8 +1275,8 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	int param = 0;
 	JSBool res = JS_TRUE;
-	switch_channel *channel;
-	switch_caller_profile *caller_profile;
+	switch_channel_t *channel;
+	switch_caller_profile_t *caller_profile;
 	char *name;
 
 	channel = switch_core_session_get_channel(jss->session);
@@ -928,7 +1351,7 @@
 };
 
 
-static JSObject *new_js_session(JSContext *cx, JSObject *obj, switch_core_session *session, struct js_session *jss, char *name, int flags) 
+static JSObject *new_js_session(JSContext *cx, JSObject *obj, switch_core_session_t *session, struct js_session *jss, char *name, int flags) 
 {
 	JSObject *session_obj;
 	if ((session_obj = JS_DefineObject(cx, obj, name, &session_class, NULL, 0))) {
@@ -965,13 +1388,13 @@
 /*********************************************************************************/
 static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
-	switch_memory_pool *pool = NULL;
-	if (argc > 2) {
+	switch_memory_pool_t *pool = NULL;
+	if (argc > 1) {
+		switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 		struct js_session *jss = NULL;
 		JSObject *session_obj;
-		switch_core_session *session = NULL, *peer_session = NULL;
-		switch_caller_profile *caller_profile = NULL;
-		char *channel_type = NULL;
+		switch_core_session_t *session = NULL, *peer_session = NULL;
+		switch_caller_profile_t *caller_profile = NULL;
 		char *dest = NULL;
 		char *dialplan = NULL;
 		char *cid_name = "";
@@ -979,7 +1402,10 @@
 		char *network_addr = "";
 		char *ani = "";
 		char *ani2 = "";
-
+		char *rdnis = "";
+		char *context = "";
+		char *username = NULL;
+		char *to = NULL;
 		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
 
 		if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@@ -989,11 +1415,18 @@
 			}
 		}
 
-		channel_type = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
-		dest = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+		dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 
+		if (!strchr(dest, '/')) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Channel String\n");
+			return JS_TRUE;
+		}
+
+		if (argc > 2) {
+			dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+		}
 		if (argc > 3) {
-			dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
+			context = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
 		}
 		if (argc > 4) {
 			cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
@@ -1010,26 +1443,48 @@
 		if (argc > 8) {
 			ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
 		}
+		if (argc > 9) {
+			rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
+		}
+		if (argc > 10) {
+			username = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
+		}
+		if (argc > 11) {
+			to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
+		}
 		
+		
 		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
 			return JS_FALSE;
 		}
 
-		caller_profile = switch_caller_profile_new(pool, dialplan, cid_name, cid_num, network_addr, ani, ani2, dest);
-		if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session, pool) == SWITCH_STATUS_SUCCESS) {
-			jss = switch_core_session_alloc(peer_session, sizeof(*jss));
-			jss->session = peer_session;
-			jss->flags = 0;
-			jss->cx = cx;
-			jss->obj = obj;
-			JS_SetPrivate(cx, obj, jss);
-			switch_core_session_thread_launch(peer_session);
-			switch_set_flag(jss, S_HUP);
+		caller_profile = switch_caller_profile_new(pool,
+												   username,
+												   dialplan,
+												   cid_name,
+												   cid_num,
+												   network_addr,
+												   ani,
+												   ani2,
+												   rdnis,
+												   (char *)modname,
+												   context,
+												   dest);
+		
+		if (switch_ivr_originate(session, &peer_session, &cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
 			return JS_TRUE;
-		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Channel\n");			
 		}
+
+		jss = switch_core_session_alloc(peer_session, sizeof(*jss));
+		jss->session = peer_session;
+		jss->flags = 0;
+		jss->cx = cx;
+		jss->obj = obj;
+		JS_SetPrivate(cx, obj, jss);
+		switch_set_flag(jss, S_HUP);
+
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n");
 	}
@@ -1044,11 +1499,11 @@
 	if (cx && obj) {
 		if ((jss = JS_GetPrivate(cx, obj))) {
 			if (switch_test_flag(jss, S_HUP)) {
-				switch_channel *channel;
+				switch_channel_t *channel;
 
 				if (jss->session) {
 					channel = switch_core_session_get_channel(jss->session);
-					switch_channel_hangup(channel);
+					switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 				}
 			}
 		}
@@ -1061,7 +1516,7 @@
 /*********************************************************************************/
 static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
-	switch_memory_pool *pool;
+	switch_memory_pool_t *pool;
 	switch_file_t *fd;
 	char *path, *flags_str;
 	unsigned int flags = 0;
@@ -1091,9 +1546,10 @@
 		}
 		switch_core_new_memory_pool(&pool);
 		if (switch_file_open(&fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, pool) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File!\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File: %s\n", path);
 			switch_core_destroy_memory_pool(&pool);
-			return JS_FALSE;
+			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+			return JS_TRUE;
 		}
 		fio = switch_core_alloc(pool, sizeof(*fio));
 		fio->fd = fd;
@@ -1104,14 +1560,18 @@
 		return JS_TRUE;
 	}
 
-	return JS_FALSE;
+	return JS_TRUE;
 }
 static void fileio_destroy(JSContext *cx, JSObject *obj)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
 
 	if (fio) {
-		switch_memory_pool *pool = fio->pool;
+		switch_memory_pool_t *pool;
+			if (fio->fd) {
+			switch_file_close(fio->fd);
+		}
+		pool = fio->pool;
 		switch_core_destroy_memory_pool(&pool);
 		pool = NULL;
 	}
@@ -1125,6 +1585,10 @@
 
 	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
 
+	if (fio) {
+		return JS_TRUE;
+	}
+
 	if (!(fio->flags & SWITCH_FOPEN_READ)) {
 		return JS_TRUE;
 	}
@@ -1150,6 +1614,12 @@
 static JSBool fileio_data(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct fileio_obj *fio = JS_GetPrivate(cx, obj);
+
+	if (!fio) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
 	*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, fio->buf));
 	return JS_TRUE;
 }
@@ -1160,6 +1630,11 @@
 	switch_size_t wrote = 0;
 	char *data = NULL;
 
+	if (!fio) {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		return JS_TRUE;
+	}
+
 	if (!(fio->flags & SWITCH_FOPEN_WRITE)) {
 		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
 		return JS_TRUE;
@@ -1170,7 +1645,7 @@
 	}
 
 	if (data) {
-		wrote = 0;
+		wrote = strlen(data);
 		*rval = BOOLEAN_TO_JSVAL( (switch_file_write(fio->fd, data, &wrote) == SWITCH_STATUS_SUCCESS) ? JS_TRUE : JS_FALSE);
 	}
 
@@ -1179,7 +1654,7 @@
 }
 
 enum fileio_tinyid {
-	FILEIO_PATH
+	FILEIO_PATH, FILEIO_OPEN
 };
 
 static JSFunctionSpec fileio_methods[] = {
@@ -1192,6 +1667,7 @@
 
 static JSPropertySpec fileio_props[] = {
 	{"path", FILEIO_PATH, JSPROP_READONLY|JSPROP_PERMANENT}, 
+	{"open", FILEIO_OPEN, JSPROP_READONLY|JSPROP_PERMANENT}, 
 	{0}
 };
 
@@ -1213,8 +1689,15 @@
 	
 	switch(param) {
 	case FILEIO_PATH:
-		*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, fio->path));
+		if (fio) {
+			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, fio->path));
+		} else {
+			*vp = BOOLEAN_TO_JSVAL( JS_FALSE );
+		}
 		break;
+	case FILEIO_OPEN:
+		*vp = BOOLEAN_TO_JSVAL( fio ? JS_TRUE : JS_FALSE );
+		break;
 	}
 
 	return res;
@@ -1232,8 +1715,8 @@
 /*********************************************************************************/
 static JSBool db_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
-	switch_memory_pool *pool;
-	switch_core_db *db;
+	switch_memory_pool_t *pool;
+	switch_core_db_t *db;
 	struct db_obj *dbo;
 
 	if (argc > 0) {
@@ -1262,7 +1745,7 @@
 	struct db_obj *dbo = JS_GetPrivate(cx, obj);
 	
 	if (dbo) {
-		switch_memory_pool *pool = dbo->pool;
+		switch_memory_pool_t *pool = dbo->pool;
 		if (dbo->stmt) {
 			switch_core_db_finalize(dbo->stmt);
 			dbo->stmt = NULL;
@@ -1306,7 +1789,7 @@
 		char *sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *err = NULL;
 		void *arg = NULL;
-		switch_core_db_callback_func cb_func = NULL;
+		switch_core_db_callback_func_t cb_func = NULL;
 
 			
 		if (argc > 1) {
@@ -1462,8 +1945,8 @@
 	JSObject *session_obj;
 	struct teletone_obj *tto = NULL;
 	struct js_session *jss = NULL;
-	switch_codec *read_codec;
-	switch_memory_pool *pool;
+	switch_codec_t *read_codec;
+	switch_memory_pool_t *pool;
 	char *timer_name = NULL;
 
 	if (argc > 0) {
@@ -1526,7 +2009,7 @@
 		}
 	}
 
-	switch_buffer_create(pool, &tto->audio_buffer, JS_BUFFER_SIZE);
+	switch_buffer_create_dynamic(&tto->audio_buffer, JS_BLOCK_SIZE, JS_BUFFER_SIZE, 0);
 	tto->pool = pool;
 	tto->obj = obj;
 	tto->cx = cx;
@@ -1540,12 +2023,14 @@
 static void teletone_destroy(JSContext *cx, JSObject *obj)
 {
 	struct teletone_obj *tto = JS_GetPrivate(cx, obj);
-	switch_memory_pool *pool;
+	switch_memory_pool_t *pool;
 	if (tto) {
 		if (tto->timer) {
 			switch_core_timer_destroy(tto->timer);
 		}
 		teletone_destroy_session(&tto->ts);
+		switch_buffer_destroy(&tto->audio_buffer);
+		switch_buffer_destroy(&tto->loop_buffer);
 		switch_core_codec_destroy(&tto->codec);
 		pool = tto->pool;
 		tto->pool = NULL;
@@ -1592,13 +2077,13 @@
 
 	if (argc > 0) {
 		char *script;
-		switch_core_session *session;
-		switch_frame write_frame = {0};
+		switch_core_session_t *session;
+		switch_frame_t write_frame = {0};
 		unsigned char *fdata[1024];
-		switch_frame *read_frame;
+		switch_frame_t *read_frame;
 		int stream_id;
-		switch_core_thread_session thread_session;
-		switch_channel *channel;
+		switch_core_thread_session_t thread_session;
+		switch_channel_t *channel;
 
 		if (argc > 1) {
 			if (!JS_ValueToInt32(cx, argv[1], &loops)) {
@@ -1607,7 +2092,7 @@
 			}
 			loops--;
 			if (!tto->loop_buffer) {
-				switch_buffer_create(tto->pool, &tto->loop_buffer, JS_BUFFER_SIZE);
+				switch_buffer_create_dynamic(&tto->loop_buffer, JS_BLOCK_SIZE, JS_BUFFER_SIZE, 0);
 			}
 		} 
 
@@ -1661,13 +2146,16 @@
 				}
 
 			} else {
-				if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) {
+				switch_status_t status;
+				status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+				
+				if (!SWITCH_READ_ACCEPTABLE(status)) {
 					break;
 				}
 			}
 			if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
-				if (loops > 0) { 
-					switch_buffer *tmp;
+				if (loops) { 
+					switch_buffer_t *tmp;
 
 					/* Switcharoo*/
 					tmp = tto->audio_buffer;
@@ -1675,11 +2163,12 @@
 					tto->loop_buffer = tmp;
 					loops--;
 					/* try again */
-					if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+					if ((write_frame.datalen = 
+						 (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
 						break;
 					}
 				} else {
-					continue;
+					break;
 				}
 			}
 
@@ -1739,14 +2228,31 @@
 
 /* Built-In*/
 /*********************************************************************************/
+static JSBool js_exit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	return JS_FALSE;
+}
+
 static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
-	char *msg;
+	char *level_str, *msg;
+	switch_log_level_t level = SWITCH_LOG_DEBUG;
+	
+	if (argc > 1) {
+		if ((level_str = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+			level = switch_log_str2level(level_str);
+		}
 
-	if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "JS_LOG: %s", msg);
-		return JS_TRUE;
-	} 
+		if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[1])))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, level, "JS_LOG: %s", msg);
+			return JS_TRUE;
+		} 
+	} else if (argc > 0) {
+		if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, level, "JS_LOG: %s", msg);
+			return JS_TRUE;
+		}
+	}
 
 	return JS_FALSE;
 }
@@ -1782,8 +2288,27 @@
 	if (argc > 1) {
 		char *cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		switch_core_session_t *session = NULL;
+		switch_stream_handle_t stream = {0};
 		char retbuf[2048] = "";
-		switch_api_execute(cmd, arg, retbuf, sizeof(retbuf));
+
+		if (argc > 2) {
+			JSObject *session_obj;
+			struct js_session *jss;
+			if (JS_ValueToObject(cx, argv[2], &session_obj)) {
+				if ((jss = JS_GetPrivate(cx, session_obj))) {
+					session = jss->session;
+				}
+			}
+		}
+		
+		
+		stream.data = retbuf;
+		stream.end = stream.data;
+		stream.data_size = sizeof(retbuf);
+		switch_api_execute(cmd, arg, session, &stream);
+		stream.write_function = switch_console_stream_write;
+
 		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, retbuf));
 	} else {
 		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, ""));
@@ -1796,7 +2321,6 @@
 {
 	struct js_session *jss_a = NULL, *jss_b = NULL;
 	JSObject *session_obj_a = NULL, *session_obj_b = NULL;
-	int32 timelimit = 60;
 
 	if (argc > 1) {
 		if (JS_ValueToObject(cx, argv[0], &session_obj_a)) {
@@ -1813,18 +2337,12 @@
 		} 
 	}
 	
-	if (argc > 3) {
-		if (!JS_ValueToInt32(cx, argv[3], &timelimit)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Convert to INT\n");
-			return JS_FALSE;
-		}
-	}
 	if (!(jss_a && jss_b)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
 		return JS_FALSE;
 	}
 
-	switch_ivr_multi_threaded_bridge(jss_a->session, jss_b->session, timelimit, NULL, NULL, NULL);
+	switch_ivr_multi_threaded_bridge(jss_a->session, jss_b->session, NULL, NULL, NULL);
 	return JS_TRUE;
 }
 
@@ -1951,6 +2469,7 @@
 
 static JSFunctionSpec fs_functions[] = {
 	{"console_log", js_log, 2}, 
+	{"exit", js_exit, 0}, 
 	{"include", js_include, 1}, 
 	{"email", js_email, 2}, 
 	{"bridge", js_bridge, 2},
@@ -1979,7 +2498,7 @@
 		if (code[0] == '/') {
 			script = JS_CompileFile(cx, obj, code);
 		} else {
-			snprintf(path, sizeof(path), "%s/%s", SWITCH_GLOBAL_dirs.script_dir, code);
+			snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR, code);
 			script = JS_CompileFile(cx, obj, path);
 		}
 	}
@@ -2047,10 +2566,22 @@
 				 db_methods
 				 );
 
+	JS_InitClass(cx,
+				 javascript_object,
+				 NULL,
+				 &event_class,
+				 event_construct,
+				 3,
+				 event_props,
+				 event_methods,
+				 event_props,
+				 event_methods
+				 );
+
 	return 1;
 }
 
-static void js_parse_and_execute(switch_core_session *session, char *input_code)
+static void js_parse_and_execute(switch_core_session_t *session, char *input_code)
 {
 	JSObject *javascript_global_object = NULL;
 	char buf[1024], *script, *arg, *argv[512];
@@ -2105,7 +2636,7 @@
 
 
 
-static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread *thread, void *obj)
+static void *SWITCH_THREAD_FUNC js_thread_run(switch_thread_t *thread, void *obj)
 {
 	char *input_code = obj;
 
@@ -2119,11 +2650,11 @@
 }
 
 
-static switch_memory_pool *module_pool = NULL;
+static switch_memory_pool_t *module_pool = NULL;
 
 static void js_thread_launch(char *text)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 
 	if (!module_pool) {
@@ -2135,39 +2666,40 @@
 	
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, js_thread_run, strdup(text), module_pool);
 }
 
 
-static switch_status launch_async(char *text, char *out, size_t outlen)
+static switch_status_t launch_async(char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 
 	if (switch_strlen_zero(text)) {
-		switch_copy_string(out, "INVALID", outlen);
+		stream->write_function(stream, "INVALID");
 		return SWITCH_STATUS_SUCCESS;
 	}
 
 	js_thread_launch(text);
-	switch_copy_string(out, "OK", outlen);
+	stream->write_function(stream, "OK");
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static const switch_application_interface ivrtest_application_interface = {
+static const switch_application_interface_t ivrtest_application_interface = {
 	/*.interface_name */ "javascript",
 	/*.application_function */ js_parse_and_execute,
 	NULL, NULL, NULL,
 	/*.next*/ NULL
 };
 
-static struct switch_api_interface js_run_interface = {
+static switch_api_interface_t js_run_interface = {
 	/*.interface_name */ "jsrun",
 	/*.desc */ "run a script",
 	/*.function */ launch_async,
 	/*.next */ NULL
 };
 
-static switch_loadable_module_interface spidermonkey_module_interface = {
+static switch_loadable_module_interface_t spidermonkey_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -2180,17 +2712,25 @@
 	/*.directory_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
-	switch_status status;
+	switch_status_t status;
 
 	if ((status = init_js()) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &spidermonkey_module_interface;
+	*module_interface = &spidermonkey_module_interface;
 
+	curl_global_init(CURL_GLOBAL_ALL);
+
 	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
+{
+	curl_global_cleanup();
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/languages/mod_spidermonkey/mod_spidermonkey.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,15 +17,15 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_SpiderMonkey Debug"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\js\src&quot;;&quot;$(InputDir)..\..\..\..\libs\curl\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libteletone\src&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\js20051231\src&quot;;&quot;$(InputDir)..\..\..\..\libs\curl-7.15.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libteletone\src&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;XP_WIN;DEBUG;_X86_=1;JSFILE;EXPORT_JS_API;HAVE_CURL;CURL_STATICLIB"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -51,7 +51,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -64,13 +64,13 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				LinkLibraryDependencies="false"
-				AdditionalDependencies="js32.lib  curllib.lib ws2_32.lib winmm.lib sqlite.lib fdlibm.lib libnspr4.lib libplc4.lib  libplds4.lib libteletone.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_spidermonkey.dll"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\js\src\$(OutDir)&quot;;&quot;..\..\..\..\libs\curl\lib\$(OutDir)&quot;;&quot;..\..\..\..\libs\sqlite\$(OutDir)&quot;;..\..\..\..\libs\js\nspr\lib;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
+				LinkLibraryDependencies="true"
+				AdditionalDependencies="ws2_32.lib winmm.lib libnspr4.lib libplc4.lib libplds4.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\nspr-4.6.1.winnt5.$(OutDir)\nspr-4.6.1\lib&quot;"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_spidermonkey.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_spidermonkey.lib"
 				TargetMachine="1"
@@ -102,15 +102,15 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_SpiderMonkey Release"
+				CommandLine=""
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -126,7 +126,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\js\src&quot;;&quot;$(InputDir)..\..\..\..\libs\curl\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libteletone\src&quot;"
+				AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\js20051231\src&quot;;&quot;$(InputDir)..\..\..\..\libs\curl-7.15.2\include&quot;;&quot;$(InputDir)..\..\..\..\libs\libteletone\src&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;XP_WIN;_X86_=1;JSFILE;EXPORT_JS_API;HAVE_CURL;CURL_STATICLIB"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
@@ -146,12 +146,13 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				LinkLibraryDependencies="false"
-				AdditionalDependencies="js32.lib  curllib.lib ws2_32.lib winmm.lib sqlite.lib fdlibm.lib libnspr4.lib libplc4.lib  libplds4.lib libteletone.lib FreeSwitchCore.lib"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_spidermonkey.dll"
+				LinkLibraryDependencies="true"
+				AdditionalDependencies="ws2_32.lib winmm.lib libnspr4.lib libplc4.lib libplds4.lib"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\js\src\$(OutDir)&quot;;&quot;..\..\..\..\libs\curl\lib\$(OutDir)&quot;;&quot;..\..\..\..\libs\sqlite\$(OutDir)&quot;;..\..\..\..\libs\js\nspr\lib;&quot;..\..\..\..\w32\vsnet\$(OutDir)&quot;"
+				AdditionalLibraryDirectories="&quot;..\..\..\..\libs\nspr-4.6.1.winnt5.$(OutDir)\nspr-4.6.1\lib&quot;"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.c	(original)
+++ freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.c	Fri Sep 22 14:22:15 2006
@@ -34,7 +34,7 @@
 static const char modname[] = "mod_console";
 static const uint8_t STATIC_LEVELS[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
 
-static switch_loadable_module_interface console_module_interface = {
+static switch_loadable_module_interface_t console_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -47,9 +47,9 @@
 	/*.directory_interface */ NULL
 };
 
-static switch_memory_pool *module_pool = NULL;
-static switch_hash *log_hash = NULL;
-static switch_hash *name_hash = NULL;
+static switch_memory_pool_t *module_pool = NULL;
+static switch_hash_t *log_hash = NULL;
+static switch_hash_t *name_hash = NULL;
 static int8_t all_level = -1;
 
 static void del_mapping(char *var) {
@@ -78,37 +78,41 @@
 	switch_core_hash_insert(log_hash, name, (void *) &STATIC_LEVELS[(uint8_t)switch_log_str2level(val)]);
 }
 
-static switch_status config_logger(void)
+static switch_status_t config_logger(void)
 {
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "console.conf";
+	switch_xml_t cfg, xml, settings, param;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-		return SWITCH_STATUS_FALSE;
+		return SWITCH_STATUS_TERM;
 	}
 
 	switch_core_hash_init(&log_hash, module_pool);
 	switch_core_hash_init(&name_hash, module_pool);
+	
+	if ((settings = switch_xml_child(cfg, "mappings"))) {
+		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");
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "mappings")) {
 			add_mapping(var, val);
 		}
 	}
-	
+
+	switch_xml_free(xml);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status switch_console_logger(const switch_log_node *node, switch_log_level level)
+static switch_status_t switch_console_logger(const switch_log_node_t *node, switch_log_level_t level)
 {
 	FILE *handle;
 
 	if ((handle = switch_core_data_channel(SWITCH_CHANNEL_ID_LOG))) {
 		uint8_t *lookup = NULL;
-		switch_log_level level = SWITCH_LOG_DEBUG;
-		
+		switch_log_level_t level = SWITCH_LOG_DEBUG;		
+
 		if (log_hash) {
 			lookup = switch_core_hash_find(log_hash, node->file);
 			
@@ -118,20 +122,23 @@
 		}
 
 		if (lookup) {
-			level = (switch_log_level) *lookup;
+			level = (switch_log_level_t) *lookup;
 		} else if (all_level > -1) {
-			level = (switch_log_level) all_level;
+			level = (switch_log_level_t) all_level;
 		} 
 
 		if (!log_hash || (((all_level > - 1) || lookup) && level >= node->level)) {
 			fprintf(handle, node->data);
 		}
+	} else {
+		fprintf(stderr, "HELP I HAVE NO CONSOLE TO LOG TO!\n");
+		fflush(stderr);
 	}
 	
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 	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");
@@ -140,7 +147,7 @@
 
 
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &console_module_interface;
+	*module_interface = &console_module_interface;
 
 	/* setup my logger function */
 	switch_log_bind_logger(switch_console_logger, SWITCH_LOG_DEBUG);

Modified: freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/loggers/mod_console/mod_console.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_console.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_console.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_console.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_console.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/mod/loggers/mod_syslog/mod_syslog.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/loggers/mod_syslog/mod_syslog.c	(original)
+++ freeswitch/branches/voctel/src/mod/loggers/mod_syslog/mod_syslog.c	Fri Sep 22 14:22:15 2006
@@ -40,7 +40,7 @@
 #define MAX_LENGTH       1024
 
 static const char modname[] = "mod_syslog";
-static switch_status load_config(void);
+static switch_status_t load_config(void);
 
 static struct {
 	char *ident;
@@ -54,7 +54,7 @@
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_format, globals.format)
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_facility, globals.facility)
 
-static switch_loadable_module_interface console_module_interface = {
+static switch_loadable_module_interface_t console_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -67,7 +67,7 @@
 	/*.directory_interface */ NULL
 };
 
-static switch_status mod_syslog_logger(const switch_log_node *node, switch_log_level level)
+static switch_status_t mod_syslog_logger(const switch_log_node_t *node, switch_log_level_t level)
 {
 	char *message = NULL;
 	char line_no[sizeof(int)*8+1];
@@ -103,52 +103,33 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+static switch_status_t load_config(void)
 {
-	*interface = &console_module_interface;
-
-	switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG);
-
-	load_config();
-
-	openlog(globals.ident, LOG_PID, LOG_USER);
-	
-	return SWITCH_STATUS_SUCCESS;
-}
-
-SWITCH_MOD_DECLARE(switch_status) switch_module_unload(const switch_loadable_module_interface **interface)
-{
-	closelog();
-	
-	return SWITCH_STATUS_SUCCESS;
-}
-
-static switch_status load_config(void)
-{
-	switch_config cfg;
-	char *var, *val;
 	char *cf = "syslog.conf";
+	switch_xml_t cfg, xml, settings, param;
 
-	if (!switch_config_open_file(&cfg, cf)) {
+	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
-		return SWITCH_STATUS_TERM;
-	}
+	} else {
+		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");
 
-	while (switch_config_next_pair(&cfg, &var, &val)) {
-		if (!strcasecmp(cfg.category, "settings")) {
-			if (!strcmp(var, "ident")) {
-				set_global_ident(val);
-			} else if (!strcmp(var, "facility")) {
-				set_global_facility(val);
-			} else if (!strcmp(var, "format")) {
-				set_global_format(val);
-			} else if (!strcmp(var, "level")) {
-				set_global_level(val);;
+				if (!strcmp(var, "ident")) {
+					set_global_ident(val);
+				} else if (!strcmp(var, "facility")) {
+					set_global_facility(val);
+				} else if (!strcmp(var, "format")) {
+					set_global_format(val);
+				} else if (!strcmp(var, "level")) {
+					set_global_level(val);;
+				}
+	
 			}
 		}
+		switch_xml_free(xml);
 	}
-	
-	switch_config_close_file(&cfg);
 
 	if (switch_strlen_zero(globals.ident)) {
 		set_global_ident(DEFAULT_IDENT);
@@ -163,5 +144,30 @@
 		set_global_level(DEFAULT_LEVEL);
 	}
 
+
+	return 0;
+}
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
+{
+	switch_status_t status;
+	*interface = &console_module_interface;
+
+	if ((status=load_config()) != SWITCH_STATUS_SUCCESS) {
+		return status;
+	}
+
+	openlog(globals.ident, LOG_PID, LOG_USER);
+
+	switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG);
+	
 	return SWITCH_STATUS_SUCCESS;
 }
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_unload(const switch_loadable_module_interface_t **interface)
+{
+	closelog();
+	
+	return SWITCH_STATUS_SUCCESS;
+}
+

Modified: freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.c
==============================================================================
--- freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.c	(original)
+++ freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.c	Fri Sep 22 14:22:15 2006
@@ -32,93 +32,193 @@
 #include <switch.h>
 #include <stdio.h>
 
-static const char modname[] = "mod_softtimer";
+static switch_memory_pool_t *module_pool = NULL;
 
-#ifdef WIN32
-//#define WINTIMER
-#endif
+static struct {
+	int32_t RUNNING;
+	switch_mutex_t *mutex;
+} globals;
 
+static const char modname[] = "mod_softtimer";
+#define MAX_ELEMENTS 1000
+
 struct timer_private {
-#ifdef WINTIMER
-	LARGE_INTEGER freq;
-	LARGE_INTEGER base;
-	LARGE_INTEGER now;
-#else
-	switch_time_t reference;
-#endif
+    uint64_t reference;
 };
+typedef struct timer_private timer_private_t;
 
-static switch_status soft_timer_init(switch_timer *timer)
+struct timer_matrix {
+	uint64_t tick;
+	uint32_t count;
+};
+typedef struct timer_matrix timer_matrix_t;
+
+static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS+1];
+
+#define IDLE_SPEED 100
+
+
+static inline switch_status_t timer_init(switch_timer_t *timer)
 {
-	struct timer_private *private;
+	timer_private_t *private_info;
 
-	private = switch_core_alloc(timer->memory_pool, sizeof(*private));
-	timer->private_info = private;
+	if ((private_info = switch_core_alloc(timer->memory_pool, sizeof(*private_info)))) {
+		switch_mutex_lock(globals.mutex);
+		TIMER_MATRIX[timer->interval].count++;
+		switch_mutex_unlock(globals.mutex);
+		timer->private_info = private_info;
+		private_info->reference = TIMER_MATRIX[timer->interval].tick;
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-#ifdef WINTIMER
-	QueryPerformanceFrequency(&private->freq);
-	QueryPerformanceCounter(&private->base);
-#else
-	private->reference = switch_time_now();
-#endif
+	return SWITCH_STATUS_MEMERR;
+}
 
+static inline switch_status_t timer_step(switch_timer_t *timer)
+{
+	timer_private_t *private_info = timer->private_info;
+
+	private_info->reference += timer->interval;
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status soft_timer_next(switch_timer *timer)
+
+static inline switch_status_t timer_next(switch_timer_t *timer)
 {
-	struct timer_private *private = timer->private_info;
+	timer_private_t *private_info = timer->private_info;
 
-#ifdef WINTIMER
-	private->base.QuadPart += timer->interval * (private->freq.QuadPart / 1000);
-	for (;;) {
-		QueryPerformanceCounter(&private->now);
-		if (private->now.QuadPart >= private->base.QuadPart) {
-			break;
-		}
-		switch_yield(100);
-	}
-#else
-	private->reference += timer->interval * 1000;
-
-	while (switch_time_now() < private->reference) {
+	timer_step(timer);
+	while (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
 		switch_yield(1000);
 	}
-#endif
-
 	timer->samplecount += timer->samples;
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status soft_timer_destroy(switch_timer *timer)
+static inline switch_status_t timer_check(switch_timer_t *timer)
+
 {
+	timer_private_t *private_info = timer->private_info;
+	switch_status_t status;
+
+	if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
+		status = SWITCH_STATUS_FALSE;
+	} else {
+		private_info->reference += timer->interval;
+		status = SWITCH_STATUS_SUCCESS;
+	}
+
+	return status;
+}
+
+
+static inline switch_status_t timer_destroy(switch_timer_t *timer)
+{
+	switch_mutex_lock(globals.mutex);
+	TIMER_MATRIX[timer->interval].count--;
+	switch_mutex_unlock(globals.mutex);
 	timer->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static const switch_timer_interface soft_timer_interface = {
+static const switch_timer_interface_t timer_interface = {
 	/*.interface_name */ "soft",
-	/*.timer_init */ soft_timer_init,
-	/*.timer_next */ soft_timer_next,
-	/*.timer_destroy */ soft_timer_destroy
+	/*.timer_init */ timer_init,
+	/*.timer_next */ timer_next,
+	/*.timer_step */ timer_step,
+	/*.timer_check */ timer_check,
+	/*.timer_destroy */ timer_destroy
 };
 
-static const switch_loadable_module_interface mod_timers_module_interface = {
+static const switch_loadable_module_interface_t mod_softtimer_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
-	/*.timer_interface */ &soft_timer_interface,
+	/*.timer_interface */ &timer_interface,
 	/*.switch_dialplan_interface */ NULL,
 	/*.switch_codec_interface */ NULL,
 	/*.switch_application_interface */ NULL
 };
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 
+	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");
+		return SWITCH_STATUS_MEMERR;
+	}
+
 	/* connect my internal structure to the blank pointer passed to me */
-	*interface = &mod_timers_module_interface;
+	*module_interface = &mod_softtimer_module_interface;
 
 	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
+}
+
+/* I cant resist setting this to 10ms, we dont even run anything smaller than 20ms so this is already 
+   twice the granularity we need, we'll change it if we need anything smaller
+*/
+
+#define STEP_MS 10
+#define STEP_MIC 10000
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
+{
+	switch_time_t reference = switch_time_now();
+	uint32_t current_ms = 0;
+	uint32_t x;
+	
+	memset(&globals, 0, sizeof(globals));
+	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+
+	globals.RUNNING = 1;
+
+	while(globals.RUNNING == 1) {
+		reference += STEP_MIC;
+
+		while (switch_time_now() < reference) {
+			switch_yield(STEP_MIC);
+		}
+
+		current_ms += STEP_MS;
+
+		for (x = 0; x < MAX_ELEMENTS; x++) {
+			int i = x, index;
+			if (i == 0) {
+				i = 1;
+			}
+			
+			index = (current_ms % i == 0) ? i : 0; 
+
+			if (TIMER_MATRIX[index].count) {
+				TIMER_MATRIX[index].tick += index;
+			}
+		}
+
+		if (current_ms == MAX_ELEMENTS) {
+			current_ms = 0;
+		}
+	}
+
+	switch_mutex_lock(globals.mutex);
+	globals.RUNNING = 0;
+	switch_mutex_unlock(globals.mutex);
+
+	return SWITCH_STATUS_TERM;
+}
+
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
+{
+	
+	if (globals.RUNNING) {
+		switch_mutex_lock(globals.mutex);
+		globals.RUNNING = -1;
+		switch_mutex_unlock(globals.mutex);
+		
+		while (globals.RUNNING) {
+			switch_yield(10000);
+		}
+	}
+
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.vcproj
==============================================================================
--- freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.vcproj	(original)
+++ freeswitch/branches/voctel/src/mod/timers/mod_softtimer/mod_softtimer.vcproj	Fri Sep 22 14:22:15 2006
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="Debug"
-			IntermediateDirectory="Debug"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -50,7 +50,7 @@
 				WarningLevel="4"
 				WarnAsError="true"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -63,11 +63,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_softtimer.dll"
-				LinkIncremental="2"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
+				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="$(OutDir)/mod_softtimer.pdb"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				ImportLibrary="$(OutDir)/mod_softtimer.lib"
 				TargetMachine="1"
@@ -99,8 +99,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="Release"
-			IntermediateDirectory="Release"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -142,10 +142,11 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_softtimer.dll"
+				OutputFile="$(SolutionDir)$(OutDir)/mod/$(InputName).dll"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
 				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"

Modified: freeswitch/branches/voctel/src/switch.c
==============================================================================
--- freeswitch/branches/voctel/src/switch.c	(original)
+++ freeswitch/branches/voctel/src/switch.c	Fri Sep 22 14:22:15 2006
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
  *
  *
  * switch.c -- Main
@@ -32,107 +33,201 @@
 
 #include <switch.h>
 
-static int RUNNING = 0;
+#define PIDFILE "freeswitch.pid"
+#define LOGFILE "freeswitch.log"
 
-static int handle_SIGPIPE(int sig)
+static char *lfile = LOGFILE;
+static char *pfile = PIDFILE;
+#define SERVICENAME "Freeswitch"
+
+#ifdef __ICC
+#pragma warning (disable:167)
+#endif
+
+
+#ifdef WIN32
+#include <winsock2.h>
+#include <windows.h>
+static HANDLE shutdown_event;
+#endif
+
+	static int handle_SIGHUP(int sig)
 {
+	uint32_t arg = 0;
 	if(sig);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Sig Pipe!\n");
+	switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
 	return 0;
 }
-#ifdef TRAP_BUS
-static int handle_SIGBUS(int sig)
+
+
+static int freeswitch_kill_background()
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Sig BUS!\n");
-	return 0;
-}
+	FILE *f;
+	char path[256] = "";
+	pid_t pid = 0;
+	switch_core_set_globals();
+	snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
+	if ((f = fopen(path, "r")) == 0) {
+		fprintf(stderr, "Cannot open pid file %s.\n", path);
+		return 255;
+	}
+	fscanf(f, "%d", &pid);
+	if (pid > 0) {
+		fprintf(stderr, "Killing: %d\n", (int) pid);
+#ifdef WIN32
+		snprintf(path, sizeof(path), "Global\\Freeswitch.%d", pid);
+		shutdown_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, path);
+		if (!shutdown_event) {
+			/* we can't get the event, so we can't signal the process to shutdown */
+			fprintf(stderr, "ERROR: Can't Shutdown: %d\n", (int) pid);
+		} else {
+			SetEvent(shutdown_event);
+		}
+		CloseHandle(shutdown_event);
+#else
+		kill(pid, SIGTERM);
 #endif
+	}
 
-/* no ctl-c mofo */
-static int handle_SIGINT(int sig)
-{
-	if (sig);
+	fclose(f);
 	return 0;
 }
 
+#ifdef WIN32
+SERVICE_STATUS_HANDLE hStatus;
+SERVICE_STATUS status;
 
-static int handle_SIGHUP(int sig)
+void WINAPI ServiceCtrlHandler( DWORD control )
 {
-	if(sig);
-	RUNNING = 0;
-	return 0;
+    switch( control )
+    {
+    case SERVICE_CONTROL_SHUTDOWN:
+    case SERVICE_CONTROL_STOP:
+        // do shutdown stuff here
+		switch_core_destroy();
+        status.dwCurrentState = SERVICE_STOPPED;
+        status.dwWin32ExitCode = 0;
+        status.dwCheckPoint = 0;
+        status.dwWaitHint = 0;
+        break;
+    case SERVICE_CONTROL_INTERROGATE:
+        // just set the current state to whatever it is...
+        break;
+    }
+
+    SetServiceStatus( hStatus, &status );
 }
 
+void WINAPI service_main( DWORD numArgs, char **args )
+{
+	const char *err = NULL;
+    // we have to initialize the service-specific stuff
+    memset( &status, 0, sizeof(SERVICE_STATUS) );
+    status.dwServiceType = SERVICE_WIN32;
+    status.dwCurrentState = SERVICE_START_PENDING;
+    status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+
+    hStatus = RegisterServiceCtrlHandler( SERVICENAME, &ServiceCtrlHandler );
+
+    SetServiceStatus( hStatus, &status );
+	set_high_priority();
+	if (switch_core_init_and_modload(lfile, &err) != SWITCH_STATUS_SUCCESS) {
+	    status.dwCurrentState = SERVICE_STOPPED;
+	} else {
+		status.dwCurrentState = SERVICE_RUNNING;
+	}
+
+    SetServiceStatus( hStatus, &status );
+}
+
+#endif
+
 int main(int argc, char *argv[])
 {
-	char *lfile = "freeswitch.log";
-	char *pfile = "freeswitch.pid";
 	char path[256] = "";
 	char *ppath = NULL;
-	char *err = NULL;
-	switch_event *event;
+	const char *err = NULL;
 	int bg = 0;
 	FILE *f;
+	pid_t pid = 0;
+	int x, die = 0;
+
 #ifdef WIN32
-	SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
-#else
-	int pid;
-	nice(-20);
+    SERVICE_TABLE_ENTRY dispatchTable[] =
+    {
+        { SERVICENAME, &service_main },
+        { NULL, NULL }
+    };
 #endif
 
-#ifndef WIN32
-	if (argv[1] && !strcmp(argv[1], "-stop")) {
-		pid_t pid = 0;
-		switch_core_set_globals();
-		snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
-		if ((f = fopen(path, "r")) == 0) {
-			fprintf(stderr, "Cannot open pid file %s.\n", path);
-			return 255;
+	for (x = 1; x < argc; x++) {
+#ifdef WIN32
+		if (x == 1) {
+			if (argv[x] && !strcmp(argv[x], "-service")) {
+				if(StartServiceCtrlDispatcher( dispatchTable ) == 0 )
+					{
+						//Not loaded as a service
+						fprintf(stderr, "Error Freeswitch loaded as a console app with -service option\n");
+						fprintf(stderr, "To install the service load freeswitch with -install\n");
+					}
+				exit(0);
+			}
+			if (argv[x] && !strcmp(argv[x], "-install")) {
+				char exePath[1024];
+				char servicePath[1024];
+
+				SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
+				GetModuleFileName( NULL, exePath, 1024 );
+				snprintf(servicePath, sizeof(servicePath), "%s -service", exePath);
+				CreateService(
+							  handle,
+							  SERVICENAME,
+							  SERVICENAME,
+							  GENERIC_READ | GENERIC_EXECUTE,
+							  SERVICE_WIN32_OWN_PROCESS,
+							  SERVICE_AUTO_START,
+							  SERVICE_ERROR_IGNORE,
+							  servicePath,
+							  NULL,
+							  NULL,
+							  NULL,
+							  NULL,
+							  NULL
+							  );
+				exit(0);
+			}
+			if (argv[x] && !strcmp(argv[x], "-uninstall")) {
+				SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
+				SC_HANDLE service = OpenService( handle, SERVICENAME, DELETE );
+				if( service != NULL )
+					{
+						// remove the service!
+						DeleteService( service );
+					}
+				exit(0);
+			}
 		}
-		fscanf(f, "%d", &pid);
-		if (pid > 0) {
-			fprintf(stderr, "Killing %d\n", (int) pid);
-			kill(pid, SIGTERM);
+#endif
+		if (argv[x] && !strcmp(argv[x], "-hp")) {
+			set_high_priority();
 		}
+		
+		if (argv[x] && !strcmp(argv[x], "-stop")) {
+			die++;
+		}
 
-		fclose(f);
-		return 0;
+		if (argv[x] && !strcmp(argv[x], "-nc")) {
+			bg++;
+		}
 	}
-#endif
 
-	if (argv[1] && !strcmp(argv[1], "-nc")) {
-		bg++;
+	if (die) {
+		return freeswitch_kill_background();
 	}
 
 	if (bg) {
-		//snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.log_dir, sep, lfile);
 		ppath = lfile;
-	}
 
-
-	if (switch_core_init(ppath) != SWITCH_STATUS_SUCCESS) {
-		fprintf(stderr, "Cannot Initilize\n");
-		return 255;
-	}
-
-
-#ifdef __ICC
-#pragma warning (disable:167)
-#endif
-
-	/* set signal handlers */
-	signal(SIGINT, (void *) handle_SIGINT);
-#ifdef SIGPIPE
-	signal(SIGPIPE, (void *) handle_SIGPIPE);
-#endif
-#ifdef TRAP_BUS
-	signal(SIGBUS, (void *) handle_SIGBUS);
-#endif
-
-
-
-
-	if (bg) {
 		signal(SIGHUP, (void *) handle_SIGHUP);
 		signal(SIGTERM, (void *) handle_SIGHUP);
 
@@ -146,68 +241,21 @@
 #endif
 	}
 
+	if (switch_core_init_and_modload(ppath, &err) != SWITCH_STATUS_SUCCESS) {
+		fprintf(stderr, "Cannot Initilize [%s]\n", err);
+		return 255;
+	}
+
 	snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
 	if ((f = fopen(path, "w")) == 0) {
 		fprintf(stderr, "Cannot open pid file %s.\n", path);
 		return 255;
 	}
 
-	fprintf(f, "%d", getpid());
+	fprintf(f, "%d", pid = getpid());
 	fclose(f);
 
+	switch_core_runtime_loop(bg);
 
-	
-	if (!err) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
-		if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
-			err = "Cannot load modules";
-		}
-	}
-
-	if (err) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error: %s", err);
-		exit(-1);
-	}
-
-	if (switch_event_create(&event, SWITCH_EVENT_STARTUP) == SWITCH_STATUS_SUCCESS) {
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready");
-		switch_event_fire(&event);
-	}
-
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL);
-	snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
-
-	if (bg) {
-		bg = 0;
-		RUNNING = 1;
-		while(RUNNING) {
-#ifdef WIN32
-		bg++;
-		if(bg == 100) {
-			if ((f = fopen(path, "r")) == 0) {
-				break;
-			}
-			fclose(f);
-			bg = 0;
-		}
-#endif
-			switch_yield(10000);
-		}
-	}  else {
-		/* wait for console input */
-		switch_console_loop();
-	}
-	
-	if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) {
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Shutting Down");
-		switch_event_fire(&event);
-	}
-
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n");
-	switch_loadable_module_shutdown();
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Tearing down environment.\n");
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Exiting Now.\n");
-	switch_core_destroy();
-	return 0;
+	return switch_core_destroy();
 }

Modified: freeswitch/branches/voctel/src/switch_buffer.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_buffer.c	(original)
+++ freeswitch/branches/voctel/src/switch_buffer.c	Fri Sep 22 14:22:15 2006
@@ -29,30 +29,77 @@
  * switch_buffer.c -- Data Buffering Code
  *
  */
+#include <switch.h>
 #include <switch_buffer.h>
 
+static uint32_t buffer_id = 0;
+
+typedef enum {
+	SWITCH_BUFFER_FLAG_DYNAMIC = (1 <<  0)
+} switch_buffer_flag_t;
+
 struct switch_buffer {
-	unsigned char *data;
+	switch_byte_t *data;
+	switch_byte_t *head;
 	switch_size_t used;
+	switch_size_t actually_used;
 	switch_size_t datalen;
+	switch_size_t max_len;
+	switch_size_t blocksize;
+	uint32_t flags;
+	uint32_t id;
 };
 
-SWITCH_DECLARE(switch_status) switch_buffer_create(switch_memory_pool *pool, switch_buffer **buffer, switch_size_t max_len)
+SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer, switch_size_t max_len)
 {
-	switch_buffer *new_buffer;
+	switch_buffer_t *new_buffer;
 
-	if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer))) != 0
+	if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer_t))) != 0
 		&& (new_buffer->data = switch_core_alloc(pool, max_len)) != 0) {
 		new_buffer->datalen = max_len;
+		new_buffer->id = buffer_id++;
+		new_buffer->head = new_buffer->data;
 		*buffer = new_buffer;
 		return SWITCH_STATUS_SUCCESS;
 	}
 	return SWITCH_STATUS_MEMERR;
 }
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_len(switch_buffer *buffer)
+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)
 {
+	switch_buffer_t *new_buffer;
 
+	if ((new_buffer = malloc(sizeof(*new_buffer)))) {
+		memset(new_buffer, 0, sizeof(*new_buffer));
+
+		if (start_len) {
+			if (!(new_buffer->data = malloc(start_len))) {
+				free(new_buffer);
+				return SWITCH_STATUS_MEMERR;
+			}
+			memset(new_buffer->data, 0, start_len);
+		}
+
+		new_buffer->max_len = max_len;
+		new_buffer->datalen = start_len;
+		new_buffer->id = buffer_id++;
+		new_buffer->blocksize = blocksize;
+		new_buffer->head = new_buffer->data;
+		switch_set_flag(new_buffer, SWITCH_BUFFER_FLAG_DYNAMIC);
+		
+		*buffer = new_buffer;
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_MEMERR;
+}
+
+SWITCH_DECLARE(switch_size_t) switch_buffer_len(switch_buffer_t *buffer)
+{
+
 	assert(buffer != NULL);
 
 	return buffer->datalen;
@@ -60,21 +107,29 @@
 }
 
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_freespace(switch_buffer *buffer)
+SWITCH_DECLARE(switch_size_t) switch_buffer_freespace(switch_buffer_t *buffer)
 {
 	assert(buffer != NULL);
 
+	if (switch_test_flag(buffer, SWITCH_BUFFER_FLAG_DYNAMIC)) {
+		if (buffer->max_len) {
+			return (switch_size_t) (buffer->max_len - buffer->used);
+		}
+		return 1000000;
+	}
+
 	return (switch_size_t) (buffer->datalen - buffer->used);
+
 }
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_inuse(switch_buffer *buffer)
+SWITCH_DECLARE(switch_size_t) switch_buffer_inuse(switch_buffer_t *buffer)
 {
 	assert(buffer != NULL);
 
 	return buffer->used;
 }
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_toss(switch_buffer *buffer, switch_size_t datalen)
+SWITCH_DECLARE(switch_size_t) switch_buffer_toss(switch_buffer_t *buffer, switch_size_t datalen)
 {
 	switch_size_t reading = 0;
 
@@ -89,13 +144,14 @@
 		reading = buffer->used;
 	}
 
-	memmove(buffer->data, buffer->data + reading, buffer->datalen - reading);
-	buffer->used -= datalen;
-
-	return buffer->datalen;
+	memmove(buffer->data, buffer->data + reading, reading);
+	buffer->head = buffer->data;
+	buffer->used -= reading;
+	buffer->actually_used = buffer->used;
+	return buffer->used;
 }
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer *buffer, void *data, switch_size_t datalen)
+SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *data, switch_size_t datalen)
 {
 	switch_size_t reading = 0;
 
@@ -112,38 +168,90 @@
 		reading = buffer->used;
 	}
 
-	memcpy(data, buffer->data, reading);
-	memmove(buffer->data, buffer->data + reading, buffer->datalen - reading);
+	memcpy(data, buffer->head, reading);
 	buffer->used -= reading;
-	//printf("o %d = %d\n", reading, buffer->used);
+	buffer->head += reading;
+
+	//if (buffer->id == 4) printf("%u o %d = %d\n", buffer->id, (uint32_t)reading, (uint32_t)buffer->used);
 	return reading;
 }
 
-SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer *buffer, void *data, switch_size_t datalen)
+SWITCH_DECLARE(switch_size_t) switch_buffer_write(switch_buffer_t *buffer, void *data, switch_size_t datalen)
 {
-	switch_size_t freespace;
+	switch_size_t freespace, actual_freespace;
 
 	assert(buffer != NULL);
 	assert(data != NULL);
 	assert(buffer->data != NULL);
+	
+	if (!datalen) {
+		return buffer->used;
+	}
 
+	actual_freespace = buffer->datalen - buffer->actually_used;
+
+	if (actual_freespace < datalen) {
+		memmove(buffer->data, buffer->head, buffer->used);
+		buffer->head = buffer->data;
+		buffer->actually_used = buffer->used;
+	}
+
 	freespace = buffer->datalen - buffer->used;
 
+	/*
+	if (buffer->data != buffer->head) {
+		memmove(buffer->data, buffer->head, buffer->used);
+		buffer->head = buffer->data;
+	}
+	*/
+	if (switch_test_flag(buffer, SWITCH_BUFFER_FLAG_DYNAMIC)) {
+		if (freespace < datalen) {
+			switch_size_t new_size, new_block_size;
+
+			new_size = buffer->datalen + datalen;
+			new_block_size = buffer->datalen + buffer->blocksize;
+
+			if (new_block_size > new_size) {
+				new_size = new_block_size;
+			}
+			buffer->head = buffer->data;
+			if (!(buffer->data = realloc(buffer->data, new_size))) {
+				return 0;
+			}
+			buffer->head = buffer->data;
+			buffer->datalen = new_size;
+		}
+	}
+	
+	freespace = buffer->datalen - buffer->used;
+
 	if (freespace < datalen) {
 		return 0;
 	} else {
-		memcpy(buffer->data + buffer->used, data, datalen);
+		memcpy(buffer->head + buffer->used, data, datalen);
 		buffer->used += datalen;
+		buffer->actually_used += datalen;
 	}
-	//printf("i %d = %d\n", datalen, buffer->used);
+	//if (buffer->id == 4) printf("%u i %d = %d\n", buffer->id, (uint32_t)datalen, (uint32_t)buffer->used);
+
 	return buffer->used;
 }
 
-SWITCH_DECLARE(void) switch_buffer_zero(switch_buffer *buffer)
+SWITCH_DECLARE(void) switch_buffer_zero(switch_buffer_t *buffer)
 {
 	assert(buffer != NULL);
     assert(buffer->data != NULL);
 
 	buffer->used = 0;
-	
+	buffer->head = buffer->data;
+}
+
+SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer)
+{
+	if (*buffer && switch_test_flag((*buffer), SWITCH_BUFFER_FLAG_DYNAMIC)) {
+		free((*buffer)->data);
+		free(*buffer);
+	}
+
+	*buffer = NULL;
 }

Modified: freeswitch/branches/voctel/src/switch_caller.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_caller.c	(original)
+++ freeswitch/branches/voctel/src/switch_caller.c	Fri Sep 22 14:22:15 2006
@@ -29,26 +29,40 @@
  * switch_caller.c -- Caller Identification
  *
  */
+#include <switch.h>
 #include <switch_caller.h>
 
-SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_memory_pool *pool,
-																  char *dialplan,
-																  char *caller_id_name,
-																  char *caller_id_number,
-																  char *network_addr,
-																  char *ani, char *ani2, char *destination_number)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memory_pool_t *pool,
+																	char *username,
+																	char *dialplan,
+																	char *caller_id_name,
+																	char *caller_id_number,
+																	char *network_addr,
+																	char *ani,
+																	char *ani2, 
+																	char *rdnis,
+																	char *source,
+																	char *context,
+																	char *destination_number)
 {
 
 
-	switch_caller_profile *profile = NULL;
+	switch_caller_profile_t *profile = NULL;
 
-	if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile))) != 0) {
+	if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile_t))) != 0) {
+		if (!context) {
+			context = "default";
+		}
+		profile->username = switch_core_strdup(pool, username);
 		profile->dialplan = switch_core_strdup(pool, dialplan);
 		profile->caller_id_name = switch_core_strdup(pool, caller_id_name);
 		profile->caller_id_number = switch_core_strdup(pool, caller_id_number);
 		profile->network_addr = switch_core_strdup(pool, network_addr);
 		profile->ani = switch_core_strdup(pool, ani);
 		profile->ani2 = switch_core_strdup(pool, ani2);
+		profile->rdnis = switch_core_strdup(pool, rdnis);
+		profile->source = switch_core_strdup(pool, source);
+		profile->context = switch_core_strdup(pool, context);
 		profile->destination_number = switch_core_strdup(pool, destination_number);
 	}
 
@@ -56,30 +70,83 @@
 }
 
 
-SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
-																	switch_caller_profile *tocopy)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
+																	
 {
-	switch_caller_profile *profile = NULL;
-	if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile))) != 0) {
+	switch_caller_profile_t *profile = NULL;
+	if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile_t))) != 0) {
+		profile->username = switch_core_session_strdup(session, tocopy->username);
 		profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan);
 		profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name);
 		profile->ani = switch_core_session_strdup(session, tocopy->ani);
 		profile->ani2 = switch_core_session_strdup(session, tocopy->ani2);
 		profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number);
 		profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr);
+		profile->rdnis = switch_core_session_strdup(session, tocopy->rdnis);
 		profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number);
 		profile->uuid = switch_core_session_strdup(session, tocopy->uuid);
+		profile->source = switch_core_session_strdup(session, tocopy->source);
+		profile->context = switch_core_session_strdup(session, tocopy->context);
 		profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
 	}
 
 	return profile;
 }
 
-SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix,
-														  switch_event *event)
+SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name)
 {
+	if (!strcasecmp(name, "dialplan")) {
+		return caller_profile->dialplan;
+	}
+	if (!strcasecmp(name, "username")) {
+		return caller_profile->username;
+	}
+	if (!strcasecmp(name, "caller_id_name")) {
+		return caller_profile->caller_id_name;
+	}
+	if (!strcasecmp(name, "ani")) {
+		return caller_profile->ani;
+	}
+	if (!strcasecmp(name, "ani2")) {
+		return caller_profile->ani2;
+	}
+	if (!strcasecmp(name, "caller_id_number")) {
+		return caller_profile->caller_id_number;
+	}
+	if (!strcasecmp(name, "network_addr")) {
+		return caller_profile->network_addr;
+	}
+	if (!strcasecmp(name, "rdnis")) {
+		return caller_profile->rdnis;
+	}
+	if (!strcasecmp(name, "destination_number")) {
+		return caller_profile->destination_number;
+	}
+	if (!strcasecmp(name, "uuid")) {
+		return caller_profile->uuid;
+	}
+	if (!strcasecmp(name, "source")) {
+		return caller_profile->source;
+	}
+	if (!strcasecmp(name, "context")) {
+		return caller_profile->context;
+	}
+	if (!strcasecmp(name, "chan_name")) {
+		return caller_profile->chan_name;
+	}
+	return NULL;
+}
+
+SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix,
+														  switch_event_t *event)
+{
 	char header_name[1024];
 
+
+	if (caller_profile->username) {
+		snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
+	}
 	if (caller_profile->dialplan) {
 		snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
@@ -112,6 +179,18 @@
 		snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid);
 	}
+	if (caller_profile->source) {
+		snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source);
+	}
+	if (caller_profile->context) {
+		snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context);
+	}
+	if (caller_profile->rdnis) {
+		snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis);
+	}
 	if (caller_profile->chan_name) {
 		snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name);
@@ -119,12 +198,12 @@
 
 }
 
-SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
+SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session,
 																	  char *extension_name, char *extension_number)
 {
-	switch_caller_extension *caller_extension = NULL;
+	switch_caller_extension_t *caller_extension = NULL;
 
-	if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension))) != 0) {
+	if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
 		caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
 		caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
 		caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
@@ -134,15 +213,15 @@
 }
 
 
-SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
-															 switch_caller_extension *caller_extension,
+SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
+															 switch_caller_extension_t *caller_extension,
 															 char *application_name, char *application_data)
 {
-	switch_caller_application *caller_application = NULL;
+	switch_caller_application_t *caller_application = NULL;
 
 	assert(session != NULL);
 
-	if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application))) != 0) {
+	if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
 		caller_application->application_name = switch_core_session_strdup(session, application_name);
 		caller_application->application_data = switch_core_session_strdup(session, application_data);
 		if (!caller_extension->applications) {

Modified: freeswitch/branches/voctel/src/switch_channel.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_channel.c	(original)
+++ freeswitch/branches/voctel/src/switch_channel.c	Fri Sep 22 14:22:15 2006
@@ -24,29 +24,92 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
  *
  *
  * switch_channel.c -- Media Channel Interface
  *
  */
+#include <switch.h>
 #include <switch_channel.h>
 
+struct switch_cause_table {
+	const char *name;
+	switch_call_cause_t cause;
+};
+
+static struct switch_cause_table CAUSE_CHART[] = {
+	{ "UNALLOCATED", SWITCH_CAUSE_UNALLOCATED },
+	{ "NO_ROUTE_TRANSIT_NET", SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET },
+	{ "NO_ROUTE_DESTINATION", SWITCH_CAUSE_NO_ROUTE_DESTINATION },
+	{ "CHANNEL_UNACCEPTABLE", SWITCH_CAUSE_CHANNEL_UNACCEPTABLE },
+	{ "CALL_AWARDED_DELIVERED", SWITCH_CAUSE_CALL_AWARDED_DELIVERED },
+	{ "NORMAL_CLEARING", SWITCH_CAUSE_NORMAL_CLEARING },
+	{ "USER_BUSY", SWITCH_CAUSE_USER_BUSY },
+	{ "NO_USER_RESPONSE", SWITCH_CAUSE_NO_USER_RESPONSE },
+	{ "NO_ANSWER", SWITCH_CAUSE_NO_ANSWER },
+	{ "CALL_REJECTED", SWITCH_CAUSE_CALL_REJECTED },
+	{ "NUMBER_CHANGED", SWITCH_CAUSE_NUMBER_CHANGED },
+	{ "DESTINATION_OUT_OF_ORDER", SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER },
+	{ "INVALID_NUMBER_FORMAT", SWITCH_CAUSE_INVALID_NUMBER_FORMAT },
+	{ "FACILITY_REJECTED", SWITCH_CAUSE_FACILITY_REJECTED },
+	{ "RESPONSE_TO_STATUS_ENQUIRY", SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY },
+	{ "NORMAL_UNSPECIFIED", SWITCH_CAUSE_NORMAL_UNSPECIFIED },
+	{ "NORMAL_CIRCUIT_CONGESTION", SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION },
+	{ "NETWORK_OUT_OF_ORDER", SWITCH_CAUSE_NETWORK_OUT_OF_ORDER },
+	{ "NORMAL_TEMPORARY_FAILURE", SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE },
+	{ "SWITCH_CONGESTION", SWITCH_CAUSE_SWITCH_CONGESTION },
+	{ "ACCESS_INFO_DISCARDED", SWITCH_CAUSE_ACCESS_INFO_DISCARDED },
+	{ "REQUESTED_CHAN_UNAVAIL", SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL },
+	{ "PRE_EMPTED", SWITCH_CAUSE_PRE_EMPTED },
+	{ "FACILITY_NOT_SUBSCRIBED", SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED },
+	{ "OUTGOING_CALL_BARRED", SWITCH_CAUSE_OUTGOING_CALL_BARRED },
+	{ "INCOMING_CALL_BARRED", SWITCH_CAUSE_INCOMING_CALL_BARRED },
+	{ "BEARERCAPABILITY_NOTAUTH", SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH },
+	{ "BEARERCAPABILITY_NOTAVAIL", SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL },
+	{ "BEARERCAPABILITY_NOTIMPL", SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL },
+	{ "CHAN_NOT_IMPLEMENTED", SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED },
+	{ "FACILITY_NOT_IMPLEMENTED", SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED },
+	{ "INVALID_CALL_REFERENCE", SWITCH_CAUSE_INVALID_CALL_REFERENCE },
+	{ "INCOMPATIBLE_DESTINATION", SWITCH_CAUSE_INCOMPATIBLE_DESTINATION },
+	{ "INVALID_MSG_UNSPECIFIED", SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED },
+	{ "MANDATORY_IE_MISSING", SWITCH_CAUSE_MANDATORY_IE_MISSING },
+	{ "MESSAGE_TYPE_NONEXIST", SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST },
+	{ "WRONG_MESSAGE", SWITCH_CAUSE_WRONG_MESSAGE },
+	{ "IE_NONEXIST", SWITCH_CAUSE_IE_NONEXIST },
+	{ "INVALID_IE_CONTENTS", SWITCH_CAUSE_INVALID_IE_CONTENTS },
+	{ "WRONG_CALL_STATE", SWITCH_CAUSE_WRONG_CALL_STATE },
+	{ "RECOVERY_ON_TIMER_EXPIRE", SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE },
+	{ "MANDATORY_IE_LENGTH_ERROR", SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR },
+	{ "PROTOCOL_ERROR", SWITCH_CAUSE_PROTOCOL_ERROR },
+	{ "INTERWORKING", SWITCH_CAUSE_INTERWORKING },
+	{ "CRASH", SWITCH_CAUSE_CRASH },
+	{ "SYSTEM_SHUTDOWN", SWITCH_CAUSE_SYSTEM_SHUTDOWN },
+	{ "LOSE_RACE", SWITCH_CAUSE_LOSE_RACE },
+	{ "MANAGER_REQUEST", SWITCH_CAUSE_MANAGER_REQUEST },
+	{ NULL, 0 }
+};
+
 struct switch_channel {
 	char *name;
-	switch_buffer *dtmf_buffer;
+	switch_buffer_t *dtmf_buffer;
 	switch_mutex_t *dtmf_mutex;
-	switch_core_session *session;
-	switch_channel_state state;
+	switch_mutex_t *flag_mutex;
+	switch_mutex_t *profile_mutex;
+	switch_core_session_t *session;
+	switch_channel_state_t state;
 	uint32_t flags;
-	switch_caller_profile *caller_profile;
-	switch_caller_profile *originator_caller_profile;
-	switch_caller_profile *originatee_caller_profile;
-	switch_caller_extension *caller_extension;
-	const struct switch_state_handler_table *state_handlers[SWITCH_MAX_STATE_HANDLERS];
+	uint32_t state_flags;
+	switch_caller_profile_t *caller_profile;
+	switch_caller_profile_t *originator_caller_profile;
+	switch_caller_profile_t *originatee_caller_profile;
+	switch_caller_extension_t *caller_extension;
+	const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
 	int state_handler_index;
-	switch_hash *variables;
-	switch_channel_timetable_t times;
-	void *private_info;
+	switch_hash_t *variables;
+	switch_hash_t *private_hash;
+	switch_channel_timetable_t *times;
+	switch_call_cause_t hangup_cause;
 	int freq;
 	int bits;
 	int channels;
@@ -54,28 +117,67 @@
 	int kbps;
 };
 
-SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel *channel)
+
+SWITCH_DECLARE(char *) switch_channel_cause2str(switch_call_cause_t cause)
 {
-	return &channel->times;
+	uint8_t x;
+	char *str = "UNALLOCATED";
+
+	for(x = 0; CAUSE_CHART[x].name; x++) {
+		if (CAUSE_CHART[x].cause == cause) {
+			str = (char *) CAUSE_CHART[x].name;
+		}
+	}
+
+	return str;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, switch_memory_pool *pool)
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(char *str)
 {
+	uint8_t x;
+	switch_call_cause_t cause = SWITCH_CAUSE_UNALLOCATED;
+
+	for(x = 0; CAUSE_CHART[x].name; x++) {
+		if (!strcasecmp(CAUSE_CHART[x].name, str)) {
+			cause = CAUSE_CHART[x].cause;
+		}
+	}
+	return cause;
+}
+
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel)
+{
+	assert(channel != NULL);
+	return channel->hangup_cause;
+}
+
+SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel_t *channel)
+{
+	assert(channel != NULL);
+	return channel->times;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_memory_pool_t *pool)
+{
 	assert(pool != NULL);
 
-	if (((*channel) = switch_core_alloc(pool, sizeof(switch_channel))) == 0) {
+	if (((*channel) = switch_core_alloc(pool, sizeof(switch_channel_t))) == 0) {
 		return SWITCH_STATUS_MEMERR;
 	}
 
 	switch_core_hash_init(&(*channel)->variables, pool);
-	switch_buffer_create(pool, &(*channel)->dtmf_buffer, 128);
+	switch_core_hash_init(&(*channel)->private_hash, pool);
+	switch_buffer_create_dynamic(&(*channel)->dtmf_buffer, 128, 128, 0);
+
 	switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
-	(*channel)->times.created = switch_time_now();
+	switch_mutex_init(&(*channel)->flag_mutex, SWITCH_MUTEX_NESTED, pool);
+	switch_mutex_init(&(*channel)->profile_mutex, SWITCH_MUTEX_NESTED, pool);
+	(*channel)->hangup_cause = SWITCH_CAUSE_UNALLOCATED;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode(switch_channel *channel, int freq, int bits, int channels,
+SWITCH_DECLARE(switch_status_t) switch_channel_set_raw_mode(switch_channel_t *channel, int freq, int bits, int channels,
 														  int ms, int kbps)
 {
 
@@ -91,7 +193,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode(switch_channel *channel, int *freq, int *bits, int *channels,
+SWITCH_DECLARE(switch_status_t) switch_channel_get_raw_mode(switch_channel_t *channel, int *freq, int *bits, int *channels,
 														  int *ms, int *kbps)
 {
 	if (freq) {
@@ -115,7 +217,7 @@
 }
 
 
-SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel *channel)
+SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel)
 {
 	switch_size_t has;
 
@@ -127,10 +229,12 @@
 	return has;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_queue_dtmf(switch_channel *channel, char *dtmf)
+SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, char *dtmf)
 {
-	switch_status status;
+	switch_status_t status;
 	register switch_size_t len, inuse;
+	switch_size_t wr = 0;
+	char *p;
 
 	assert(channel != NULL);
 
@@ -143,17 +247,26 @@
 		switch_buffer_toss(channel->dtmf_buffer, strlen(dtmf));
 	}
 
-	status = switch_buffer_write(channel->dtmf_buffer, dtmf, len) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR;
+	p = dtmf;
+	while(wr < len && p) {
+		if (is_dtmf(*p)) {
+			wr++;
+		} else {
+			break;
+		}
+		p++;
+	}
+	status = switch_buffer_write(channel->dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR;
 	switch_mutex_unlock(channel->dtmf_mutex);
 
 	return status;
 }
 
 
-SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf(switch_channel *channel, char *dtmf, switch_size_t len)
+SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf(switch_channel_t *channel, char *dtmf, switch_size_t len)
 {
 	switch_size_t bytes;
-	switch_event *event;
+	switch_event_t *event;
 
 	assert(channel != NULL);
 
@@ -163,7 +276,7 @@
 	}
 	switch_mutex_unlock(channel->dtmf_mutex);
 
-	if (bytes && switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
+	if (bytes && switch_event_create(&event, SWITCH_EVENT_DTMF) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(channel, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-String", dtmf);
 		switch_event_fire(&event);
@@ -173,10 +286,15 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_init(switch_channel *channel,
-												  switch_core_session *session,
-												  switch_channel_state state, uint32_t flags)
+SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel)
 {
+	switch_buffer_destroy(&channel->dtmf_buffer);
+}
+
+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)
+{
 	assert(channel != NULL);
 	channel->state = state;
 	channel->flags = flags;
@@ -185,78 +303,112 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname)
+SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname)
 {
+	assert(channel != NULL);
 	return switch_core_hash_find(channel->variables, varname);
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_set_private(switch_channel *channel, void *private_info)
+SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool)
 {
 	assert(channel != NULL);
-	channel->private_info = private_info;
+	return switch_hash_first(pool, channel->variables);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, char *key, void *private_info)
+{
+	assert(channel != NULL);
+	switch_core_hash_insert_dup(channel->private_hash, switch_core_session_strdup(channel->session, key), private_info);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel *channel)
+SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key)
 {
 	assert(channel != NULL);
-	return channel->private_info;
+	return switch_core_hash_find(channel->private_hash, key);
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_set_name(switch_channel *channel, char *name)
+SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, char *name)
 {
 	assert(channel != NULL);
 	channel->name = NULL;
 	if (name) {
+		char *uuid = switch_core_session_get_uuid(channel->session);
 		channel->name = switch_core_session_strdup(channel->session, name);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Chan %s [%s]\n", name, uuid);
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel)
+SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel)
 {
 	assert(channel != NULL);
-	return channel->name;
+	return channel->name ? channel->name : "N/A";
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_set_variable(switch_channel *channel, char *varname, char *value)
+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value)
 {
 	assert(channel != NULL);
-	switch_core_hash_delete(channel->variables, varname);
 
-	switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
+	if (varname) {
+		switch_core_hash_delete(channel->variables, varname);
+		if (value) {
+			switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
+		} else {
+			switch_core_hash_delete(channel->variables, varname);
+		}
+		return SWITCH_STATUS_SUCCESS;
+	}
 
-	return SWITCH_STATUS_SUCCESS;
+	return SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel *channel, switch_channel_flag flags)
+SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
+	assert(channel != NULL);
 	return switch_test_flag(channel, flags) ? 1 : 0;
 }
 
-SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel *channel, switch_channel_flag flags)
+SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
-	switch_set_flag(channel, flags);
+	assert(channel != NULL);
+	switch_set_flag_locked(channel, flags);
 }
 
-SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel *channel, switch_channel_flag flags)
+SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
-	switch_clear_flag(channel, flags);
+	assert(channel != NULL);
+
+	switch_mutex_lock(channel->flag_mutex);
+	channel->state_flags |= flags;
+	switch_mutex_unlock(channel->flag_mutex);
 }
 
-SWITCH_DECLARE(switch_channel_state) switch_channel_get_state(switch_channel *channel)
+SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
 	assert(channel != NULL);
-	return channel->state;
+	switch_clear_flag_locked(channel, flags);
 }
 
-SWITCH_DECLARE(unsigned int) switch_channel_ready(switch_channel *channel)
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_state(switch_channel_t *channel)
 {
+	switch_channel_state_t state;
 	assert(channel != NULL);
-	return (channel->state > CS_RING && channel->state < CS_HANGUP) ? 1 : 0;
+
+	switch_mutex_lock(channel->flag_mutex);
+	state = channel->state;
+	switch_mutex_unlock(channel->flag_mutex);
+
+	return state;
 }
 
+SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel)
+{
+	assert(channel != NULL);
+	return (channel->state > CS_RING && channel->state < CS_HANGUP && !switch_test_flag(channel, CF_TRANSFER)) ? 1 : 0;
+}
+
 static const char *state_names[] = {
 	"CS_NEW",
 	"CS_INIT",
@@ -264,32 +416,53 @@
 	"CS_TRANSMIT",
 	"CS_EXECUTE",
 	"CS_LOOPBACK",
+	"CS_HOLD",
 	"CS_HANGUP",
-	"CS_DONE"
+	"CS_DONE",
+	NULL
 };
 
-SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state state)
+SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t state)
 {
 	return state_names[state];
 }
 
-SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state)
+
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name)
 {
-	switch_channel_state last_state;
+	uint32_t x = 0;
+	for(x = 0; state_names[x]; x++) {
+		if (!strcasecmp(state_names[x], name)) {
+			return (switch_channel_state_t) x;
+		}
+	}
+
+	return CS_DONE;
+}
+
+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)
+{
+	switch_channel_state_t last_state;
 	int ok = 0;
 
 
 	assert(channel != NULL);
+	switch_mutex_lock(channel->flag_mutex);
+
 	last_state = channel->state;
 
 	if (last_state == state) {
-		return state;
+		goto done;
 	}
 
 	if (last_state >= CS_HANGUP && state < last_state) {
-		return last_state;
+		goto done;
 	}
-
+	
 	/* STUB for more dev
 	   case CS_INIT:
 	   switch(state) {
@@ -324,7 +497,7 @@
 		case CS_TRANSMIT:
 		case CS_RING:
 		case CS_EXECUTE:
-		case CS_HANGUP:
+		case CS_HOLD:
 			ok++;
 		default:
 			break;
@@ -336,7 +509,7 @@
 		case CS_TRANSMIT:
 		case CS_RING:
 		case CS_EXECUTE:
-		case CS_HANGUP:
+		case CS_HOLD:
 			ok++;
 		default:
 			break;
@@ -348,19 +521,32 @@
 		case CS_LOOPBACK:
 		case CS_RING:
 		case CS_EXECUTE:
-		case CS_HANGUP:
+		case CS_HOLD:
 			ok++;
 		default:
 			break;
 		}
 		break;
 
+	case CS_HOLD:
+		switch (state) {
+		case CS_LOOPBACK:
+		case CS_RING:
+		case CS_EXECUTE:
+		case CS_TRANSMIT:
+			ok++;
+		default:
+			break;
+		}
+		break;
+
 	case CS_RING:
+		switch_clear_flag(channel, CF_TRANSFER);
 		switch (state) {
 		case CS_LOOPBACK:
 		case CS_EXECUTE:
-		case CS_HANGUP:
 		case CS_TRANSMIT:
+		case CS_HOLD:
 			ok++;
 		default:
 			break;
@@ -372,7 +558,7 @@
 		case CS_LOOPBACK:
 		case CS_TRANSMIT:
 		case CS_RING:
-		case CS_HANGUP:
+		case CS_HOLD:
 			ok++;
 		default:
 			break;
@@ -395,15 +581,44 @@
 
 
 	if (ok) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
-							  state_names[last_state], state_names[state]);
+		
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", 
+						  channel->name,
+						  state_names[last_state], 
+						  state_names[state]);
+		switch_mutex_lock(channel->flag_mutex);
 		channel->state = state;
+		switch_mutex_unlock(channel->flag_mutex);
+
+		if (state == CS_HANGUP && channel->hangup_cause == SWITCH_CAUSE_UNALLOCATED) {
+			channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
+		}
+		if (state < CS_HANGUP) {
+			switch_event_t *event;
+			if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
+				if (state == CS_RING) {
+					switch_channel_event_set_data(channel, event);
+				} else {
+					char state_num[25];
+					snprintf(state_num, sizeof(state_num), "%d", channel->state);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", (char *) state_num);
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
+					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
+				}
+				switch_event_fire(&event);
+			}
+		}
+				
 		if (state < CS_DONE) {
 			switch_core_session_signal_state_change(channel->session);
 		}
+		
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", channel->name,
-							  state_names[last_state], state_names[state]);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", 
+						  channel->name,
+						  state_names[last_state],
+						  state_names[state]);
 
 		//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
 		if (channel->state < CS_HANGUP) {
@@ -411,13 +626,22 @@
 			assert(0);
 		}
 	}
+ done:
+	
+	if (channel->state_flags) {
+		channel->flags |= channel->state_flags;
+		channel->state_flags = 0;
+	}
+
+	switch_mutex_unlock(channel->flag_mutex);
 	return channel->state;
 }
 
-SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event)
+SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
 {
-	switch_caller_profile *caller_profile, *originator_caller_profile, *originatee_caller_profile;
+	switch_caller_profile_t *caller_profile, *originator_caller_profile, *originatee_caller_profile;
 	switch_hash_index_t *hi;
+	switch_codec_t *codec;
 	void *val;
 	const void *var;
 	char state_num[25];
@@ -431,8 +655,17 @@
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", (char *) state_num);
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
+	
+	if ((codec = switch_core_session_get_read_codec(channel->session))) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->samples_per_second);
+	}
+	
+	if ((codec = switch_core_session_get_write_codec(channel->session))) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Rate", "%u", codec->implementation->samples_per_second);
+	}
 
-
 	/* Index Caller's Profile */
 	if (caller_profile) {
 		switch_caller_profile_event_set_data(caller_profile, "Caller", event);
@@ -461,10 +694,13 @@
 
 }
 
-SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
+SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 {
+	switch_channel_timetable_t *times;
+
 	assert(channel != NULL);
 	assert(channel->session != NULL);
+	switch_mutex_lock(channel->profile_mutex);
 
 	if (!caller_profile->uuid) {
 		caller_profile->uuid = switch_core_session_strdup(channel->session, switch_core_session_get_uuid(channel->session));
@@ -474,63 +710,105 @@
 		caller_profile->chan_name = switch_core_session_strdup(channel->session, channel->name);
 	}
 
+	if (!caller_profile->context) {
+		caller_profile->chan_name = switch_core_session_strdup(channel->session, "default");
+	}
+
 	if (!channel->caller_profile) {
-		switch_event *event;
+		switch_event_t *event;
 
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_CREATE) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(channel, event);
 			switch_event_fire(&event);
 		}
+	} 
+	
+	if ((times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*times)))) {
+		times->next = channel->times;
+		channel->times = times;
 	}
+	channel->times->created = switch_time_now();
 
+	caller_profile->next = channel->caller_profile;
 	channel->caller_profile = caller_profile;
+
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch_channel *channel)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(switch_channel_t *channel)
 {
+	switch_caller_profile_t *profile;
 	assert(channel != NULL);
-	return channel->caller_profile;
+
+	switch_mutex_lock(channel->profile_mutex);
+	profile = channel->caller_profile;
+	switch_mutex_unlock(channel->profile_mutex);
+
+	return profile;
 }
 
-SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel,
-																  switch_caller_profile *caller_profile)
+SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel,
+																  switch_caller_profile_t *caller_profile)
 {
 	assert(channel != NULL);
+	switch_mutex_lock(channel->profile_mutex);
+	caller_profile->next = channel->originator_caller_profile;
 	channel->originator_caller_profile = caller_profile;
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
-SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel,
-																  switch_caller_profile *caller_profile)
+SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel,
+																  switch_caller_profile_t *caller_profile)
 {
 	assert(channel != NULL);
+	switch_mutex_lock(channel->profile_mutex);
+	caller_profile->next = channel->originatee_caller_profile;
 	channel->originatee_caller_profile = caller_profile;
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_profile(switch_channel_t *channel)
 {
+	switch_caller_profile_t *profile;
 	assert(channel != NULL);
-	return channel->originator_caller_profile;
+
+	switch_mutex_lock(channel->profile_mutex);
+	profile = channel->originator_caller_profile;
+	switch_mutex_unlock(channel->profile_mutex);
+
+	return profile;
 }
 
-SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel *channel)
+SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel)
 {
 	assert(channel != NULL);
 	assert(channel->session != NULL);
 	return switch_core_session_get_uuid(channel->session);
 }
 
-SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originatee_caller_profile(switch_channel_t *channel)
 {
+	switch_caller_profile_t *profile;
 	assert(channel != NULL);
-	return channel->originatee_caller_profile;
+
+	switch_mutex_lock(channel->profile_mutex);
+	profile = channel->originatee_caller_profile;
+	switch_mutex_unlock(channel->profile_mutex);
+
+	return profile;
 }
 
-SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel *channel,
-													 const switch_state_handler_table *state_handler)
+SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel,
+													 const switch_state_handler_table_t *state_handler)
 {
-	int index;
+	int x, index;
 
 	assert(channel != NULL);
+	for (x = 0; x < SWITCH_MAX_STATE_HANDLERS; x++) {
+		if (channel->state_handlers[x] == state_handler) {
+			return x;
+		}
+	}
 	index = channel->state_handler_index++;
 
 	if (channel->state_handler_index >= SWITCH_MAX_STATE_HANDLERS) {
@@ -541,7 +819,7 @@
 	return index;
 }
 
-SWITCH_DECLARE(const switch_state_handler_table *) switch_channel_get_state_handler(switch_channel *channel, int index)
+SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel, int index)
 {
 	assert(channel != NULL);
 
@@ -552,15 +830,46 @@
 	return channel->state_handlers[index];
 }
 
-SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel,
-														 switch_caller_extension *caller_extension)
+SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler)
 {
+	int index, i = 0;
+	const switch_state_handler_table_t *new_handlers[SWITCH_MAX_STATE_HANDLERS] = {0};
+
 	assert(channel != NULL);
+
+	if (state_handler) {
+		for (index = 0; index < channel->state_handler_index; index++) {
+			if (channel->state_handlers[index] != state_handler) {
+				new_handlers[i++] = channel->state_handlers[index];
+			}
+		}
+	}
+	for (index = 0; index < SWITCH_MAX_STATE_HANDLERS; index++) {
+		channel->state_handlers[index] = NULL;
+	}
+
+	if (state_handler) {
+		for (index = 0; index < i; index++) {
+			channel->state_handlers[index] = new_handlers[i];
+		}
+	}
+
+	channel->state_handler_index = i;
+}
+
+SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel,
+														 switch_caller_extension_t *caller_extension)
+{
+	assert(channel != NULL);
+
+	switch_mutex_lock(channel->profile_mutex);
+	caller_extension->next = channel->caller_extension;
 	channel->caller_extension = caller_extension;
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
 
-SWITCH_DECLARE(switch_caller_extension *) switch_channel_get_caller_extension(switch_channel *channel)
+SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_caller_extension(switch_channel_t *channel)
 {
 
 	assert(channel != NULL);
@@ -568,47 +877,82 @@
 }
 
 
-SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *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)
 {
 	assert(channel != NULL);
+	switch_mutex_lock(channel->flag_mutex);
 
-	if (!channel->times.hungup) {
-		channel->times.hungup = switch_time_now();
+	if (channel->times && !channel->times->hungup) {
+		channel->times->hungup = switch_time_now();
 	}
 
 	if (channel->state < CS_HANGUP) {
+		switch_event_t *event;
+		switch_channel_state_t last_state = channel->state;
 		channel->state = CS_HANGUP;
+		channel->hangup_cause = hangup_cause;
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", 
+						  channel->name,
+						  state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
+		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", switch_channel_cause2str(channel->hangup_cause));
+			switch_channel_event_set_data(channel, event);
+			switch_event_fire(&event);
+		}
+
 		switch_core_session_kill_channel(channel->session, SWITCH_SIG_KILL);
 		switch_core_session_signal_state_change(channel->session);
 	}
+
+	switch_mutex_unlock(channel->flag_mutex);
 	return channel->state;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel)
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel,
+																const char *file,
+																const char *func,
+																int line)
 {
-	switch_core_session_message msg;
+	switch_core_session_message_t msg;
 	char *uuid = switch_core_session_get_uuid(channel->session);
-	switch_status status;
-
+	switch_status_t status;
+	
 	assert(channel != NULL);
 
 	if (channel->state >= CS_HANGUP) {
 		return SWITCH_STATUS_FALSE;
 	}
 
+	if (switch_channel_test_flag(channel, CF_ANSWERED)) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
 	msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
 	msg.from = channel->name;
 	status = switch_core_session_message_send(uuid, &msg);
 
 	if (status == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Pre-Answer %s!\n", channel->name);
+		switch_event_t *event;
+
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
 		switch_channel_set_flag(channel, CF_EARLY_MEDIA);
+		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(channel, event);
+			switch_event_fire(&event);
+		}
 	}
 
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel)
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel,
+																const char *file,
+																const char *func,
+																int line)
 {
 	assert(channel != NULL);
 
@@ -616,12 +960,16 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
+	if (switch_channel_test_flag(channel, CF_ANSWERED)) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
 	if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
-		switch_event *event;
+		switch_event_t *event;
 
-		channel->times.answered = switch_time_now();
+		channel->times->answered = switch_time_now();
 		switch_channel_set_flag(channel, CF_ANSWERED);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Answer %s!\n", channel->name);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Answer %s!\n", channel->name);
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(channel, event);
 			switch_event_fire(&event);

Modified: freeswitch/branches/voctel/src/switch_config.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_config.c	(original)
+++ freeswitch/branches/voctel/src/switch_config.c	Fri Sep 22 14:22:15 2006
@@ -29,9 +29,10 @@
  * switch_config.c -- Configuration File Parser
  *
  */
+#include <switch.h>
 #include <switch_config.h>
 
-SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path)
+SWITCH_DECLARE(int) switch_config_open_file(switch_config_t *cfg, char *file_path)
 {
 	FILE *f;
 	char *path = NULL;
@@ -40,7 +41,7 @@
 	if (file_path[0] == '/') {
 		path = file_path;
 	} else {
-		snprintf(path_buf, sizeof(path_buf), "%s/%s", SWITCH_GLOBAL_dirs.conf_dir, file_path);
+		snprintf(path_buf, sizeof(path_buf), "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, file_path);
 		path = path_buf;
 	}
 
@@ -56,7 +57,7 @@
 			int last = -1;
 			char *var, *val;
 
-			snprintf(path_buf, sizeof(path_buf), "%s/freeswitch.conf", SWITCH_GLOBAL_dirs.conf_dir);
+			snprintf(path_buf, sizeof(path_buf), "%s%sfreeswitch.conf", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR);
 			path = path_buf;
 
 			if ((f = fopen(path, "r")) == 0) {
@@ -87,7 +88,7 @@
 }
 
 
-SWITCH_DECLARE(void) switch_config_close_file(switch_config *cfg)
+SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg)
 {
 
 	if (cfg->file) {
@@ -99,7 +100,7 @@
 
 
 
-SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char **val)
+SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val)
 {
 	int ret = 0;
 	char *p, *end;

Modified: freeswitch/branches/voctel/src/switch_console.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_console.c	(original)
+++ freeswitch/branches/voctel/src/switch_console.c	Fri Sep 22 14:22:15 2006
@@ -29,15 +29,81 @@
  * switch_console.c -- Simple Console
  *
  */
-#include <switch_console.h>
 #include <switch.h>
-#define CMD_BUFLEN 1024 * 1000
+#include <switch_console.h>
+#include <switch_version.h>
+#define CMD_BUFLEN 1024;
 
-static int switch_console_process(char *cmd, char *retbuf, int retlen)
+
+SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, char *fmt, ...)
 {
-	char *arg = NULL;
+	va_list ap;
+	char *buf = handle->data;
+	char *end = handle->end;
+	int ret = 0;
+	char *data;
 
+	if (handle->data_len >= handle->data_size) {
+		return SWITCH_STATUS_FALSE;
+	}
 
+	va_start(ap, fmt);
+#ifdef HAVE_VASPRINTF
+	ret = vasprintf(&data, fmt, ap);
+#else
+	if ((data = (char *) malloc(2048))) {
+		vsnprintf(data, 2048, fmt, ap);
+	}
+#endif
+	va_end(ap);
+	
+	if (data) {
+		switch_size_t remaining = handle->data_size - handle->data_len;
+		switch_size_t need = strlen(data) + 1;
+		
+		
+		if ((remaining < need) && handle->alloc_len) {
+			switch_size_t new_len;
+			
+			if (need < handle->alloc_chunk) {
+				need = handle->alloc_chunk;
+			}
+
+			new_len = handle->data_size + need;
+			if ((handle->data = realloc(handle->data, new_len))) {
+				handle->data_size = handle->alloc_len = new_len;
+				buf = handle->data;
+
+				remaining = handle->data_size - handle->data_len;
+				handle->end = (uint8_t *)(handle->data) + handle->data_len;
+				end = handle->end;
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+				free(data);
+				return SWITCH_STATUS_FALSE;
+			}
+		}
+
+		if (remaining < need) {
+			ret = -1;
+		} else {
+			ret = 0;
+			snprintf(end, remaining, data);
+			handle->data_len = strlen(buf);
+			handle->end = (uint8_t *)(handle->data) + handle->data_len;
+		}
+		free(data);
+	}
+	
+	return ret ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+}
+
+
+static int switch_console_process(char *cmd)
+{
+	char *arg = NULL;
+	switch_stream_handle_t stream = {0};
+
 	if (!strcmp(cmd, "shutdown") || !strcmp(cmd, "...")) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bye!\n");
 		return 0;
@@ -61,15 +127,23 @@
 	if ((arg = strchr(cmd, ' ')) != 0) {
 		*arg++ = '\0';
 	}
-	if (switch_api_execute(cmd, arg, retbuf, retlen) == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
+	
+	SWITCH_STANDARD_STREAM(stream);
+	if (stream.data) {
+		if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", stream.data);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unknown Command: %s\n", cmd);
+		}
+		free(stream.data);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unknown Command: %s\n", cmd);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
 	}
+
 	return 1;
 }
 
-SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line,
+SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line,
 										   char *fmt, ...)
 {
 	char *data = NULL;
@@ -99,7 +173,7 @@
 		} else {
 			switch_size_t retsize;
 			switch_time_exp_t tm;
-			switch_event *event;
+			switch_event_t *event;
 			switch_time_exp_lt(&tm, switch_time_now());
 			switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
 
@@ -129,39 +203,58 @@
 {
 	char hostname[256];
 	char cmd[2048];
-	int running = 1, x = 0, activity = 1;
-	char *retbuf = (char *)malloc(CMD_BUFLEN);
+	uint32_t activity = 1, running = 1;
+	switch_size_t x = 0;
 
-
-	assert(retbuf != NULL);
 	gethostname(hostname, sizeof(hostname));
 
+	while(running) {
+		uint32_t arg;
+		fd_set rfds, efds;
+		struct timeval tv = {0, 20000};
 
-	while (running) {
+		switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
+		if (!arg) {
+			break;
+		}
+
 		if (activity) {
 			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\nfreeswitch@%s> ", hostname);
 		}
-		//activity = switch_socket_waitfor(fileno(stdin), 100, POLLIN | POLLERR);
 
+#ifdef _MSC_VER
+//Microsofts macros don't pass their own compilers warnings.
+#pragma warning(push)
+#pragma warning(disable: 4127 4389)
+#endif
+
+		FD_ZERO(&rfds);
+		FD_ZERO(&efds);
+		FD_SET(fileno(stdin), &rfds);
+		FD_SET(fileno(stdin), &efds);
+		activity = select(fileno(stdin)+1, &rfds, NULL, &efds, &tv);
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
 		if (activity == 0) {
 			fflush(stdout);
-			switch_sleep(100);
 			continue;
 		}
 
 		memset(&cmd, 0, sizeof(cmd));
-		for (x = 0; x < sizeof(cmd); x++) {
+		for (x = 0; x < (sizeof(cmd)-1); x++) {
 			cmd[x] = (char) getchar();
 			if (cmd[x] == '\n') {
 				cmd[x] = '\0';
 				break;
 			}
 		}
+	
 		if (cmd[0]) {
-			running = switch_console_process(cmd, retbuf, CMD_BUFLEN);
+			running = switch_console_process(cmd);
 		}
 	}
 	
-	free(retbuf);
 
 }

Modified: freeswitch/branches/voctel/src/switch_core.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_core.c	(original)
+++ freeswitch/branches/voctel/src/switch_core.c	Fri Sep 22 14:22:15 2006
@@ -24,84 +24,131 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
+ * Paul D. Tinsley <pdt at jackhammer.org>
  *
  *
  * switch_core.c -- Main Core Library
  *
  */
 
-#include <stdio.h>
 #include <switch.h>
+#include <stdio.h>
+#include <switch_version.h>
+
+#ifdef HAVE_MLOCKALL
+#include <sys/mman.h>
+#endif
+
 //#define DEBUG_ALLOC
+#define DO_EVENTS
 
+#ifdef CRASH_PROT
+#define __CP "ENABLED"
+#else
+#define __CP "DISABLED"
+#endif
+
 #define SWITCH_EVENT_QUEUE_LEN 256
+#define SWITCH_SQL_QUEUE_LEN 2000
 
+#define SWITCH_BUFFER_BLOCK_FRAMES 25
+#define SWITCH_BUFFER_START_FRAMES 50
+
+struct switch_media_bug {
+	switch_buffer_t *raw_write_buffer;
+	switch_buffer_t *raw_read_buffer;
+	switch_media_bug_callback_t callback;
+	switch_mutex_t *read_mutex;
+	switch_mutex_t *write_mutex;
+	switch_core_session_t *session;
+	void *user_data;
+	struct switch_media_bug *next;
+};
+	
 struct switch_core_session {
 	uint32_t id;
 	char name[80];
 	int thread_running;
-	switch_memory_pool *pool;
-	switch_channel *channel;
-	switch_thread *thread;
-	const switch_endpoint_interface *endpoint_interface;
-	struct switch_io_event_hooks event_hooks;
-	switch_codec *read_codec;
-	switch_codec *write_codec;
+	switch_memory_pool_t *pool;
+	switch_channel_t *channel;
+	switch_thread_t *thread;
+	const switch_endpoint_interface_t *endpoint_interface;
+	switch_io_event_hooks_t event_hooks;
+	switch_codec_t *read_codec;
+	switch_codec_t *write_codec;
 
-	switch_buffer *raw_write_buffer;
-	switch_frame raw_write_frame;
-	switch_frame enc_write_frame;
+	switch_buffer_t *raw_write_buffer;
+	switch_frame_t raw_write_frame;
+	switch_frame_t enc_write_frame;
 	uint8_t raw_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
 	uint8_t enc_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
 
-	switch_buffer *raw_read_buffer;
-	switch_frame raw_read_frame;
-	switch_frame enc_read_frame;
+	switch_buffer_t *raw_read_buffer;
+	switch_frame_t raw_read_frame;
+	switch_frame_t enc_read_frame;
 	uint8_t raw_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
 	uint8_t enc_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
 
 
-	switch_audio_resampler *read_resampler;
-	switch_audio_resampler *write_resampler;
+	switch_audio_resampler_t *read_resampler;
+	switch_audio_resampler_t *write_resampler;
 
 	switch_mutex_t *mutex;
 	switch_thread_cond_t *cond;
 
+	switch_thread_rwlock_t *rwlock;
+
 	void *streams[SWITCH_MAX_STREAMS];
 	int stream_count;
 
 	char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
 	void *private_info;
 	switch_queue_t *event_queue;
+	switch_queue_t *private_event_queue;
+	switch_thread_rwlock_t *bug_rwlock;
+	switch_media_bug_t *bugs;
 };
 
 SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs;
 
 struct switch_core_runtime {
-	time_t initiated;
+	switch_time_t initiated;
 	uint32_t session_id;
 	apr_pool_t *memory_pool;
-	switch_hash *session_table;
-	switch_core_db *db;
-	switch_core_db *event_db;
-	const struct switch_state_handler_table *state_handlers[SWITCH_MAX_STATE_HANDLERS];
+	switch_hash_t *session_table;
+	switch_mutex_t *session_table_mutex;
+#ifdef CRASH_PROT
+	switch_hash_t *stack_table;
+#endif
+	switch_core_db_t *db;
+	switch_core_db_t *event_db;
+	const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
     int state_handler_index;
 	FILE *console;
+	uint32_t session_count;
+	uint32_t session_limit;
+	switch_queue_t *sql_queue;
+	uint32_t no_new_sessions;
+	uint32_t shutting_down;
+	uint8_t running;
 };
 
 /* Prototypes */
-static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread *thread, void *obj);
-static void switch_core_standard_on_init(switch_core_session *session);
-static void switch_core_standard_on_hangup(switch_core_session *session);
-static void switch_core_standard_on_ring(switch_core_session *session);
-static void switch_core_standard_on_execute(switch_core_session *session);
-static void switch_core_standard_on_loopback(switch_core_session *session);
-static void switch_core_standard_on_transmit(switch_core_session *session);
+static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj);
+static void switch_core_standard_on_init(switch_core_session_t *session);
+static void switch_core_standard_on_hangup(switch_core_session_t *session);
+static void switch_core_standard_on_ring(switch_core_session_t *session);
+static void switch_core_standard_on_execute(switch_core_session_t *session);
+static void switch_core_standard_on_loopback(switch_core_session_t *session);
+static void switch_core_standard_on_transmit(switch_core_session_t *session);
+static void switch_core_standard_on_hold(switch_core_session_t *session);
 
 
 /* The main runtime obj we keep this hidden for ourselves */
 static struct switch_core_runtime runtime;
 
+
 static void db_pick_path(char *dbname, char *buf, switch_size_t size)
 {
 
@@ -109,13 +156,243 @@
 	if (strchr(dbname, '/')) {
 		strncpy(buf, dbname, size);
 	} else {
-		snprintf(buf, size, "%s/%s.db", SWITCH_DB_DIR, dbname);
+		snprintf(buf, size, "%s%s%s.db", SWITCH_GLOBAL_dirs.db_dir, SWITCH_PATH_SEPARATOR, dbname);
 	}
 }
 
-SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename)
+static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
 {
-	switch_core_db *db;
+	switch_buffer_destroy(&bug->raw_read_buffer);
+	switch_buffer_destroy(&bug->raw_write_buffer);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame)
+{
+	uint32_t bytes = 0;
+	uint8_t data[SWITCH_RECCOMMENDED_BUFFER_SIZE] = {0};
+	uint32_t datalen = 0;
+	int16_t *dp, *fp;
+	uint32_t x;
+	size_t rlen = switch_buffer_inuse(bug->raw_read_buffer);
+	size_t wlen = switch_buffer_inuse(bug->raw_write_buffer);
+	uint32_t blen;
+	size_t rdlen = 0;
+	uint32_t maxlen;
+
+	if (!rlen && !wlen) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	maxlen = sizeof(data) > frame->buflen ? frame->buflen :  sizeof(data);
+	if ((rdlen = rlen > wlen ? wlen : rlen) > maxlen) {
+		rdlen = maxlen;
+	}
+	
+	frame->datalen = 0;
+
+	if (rlen) {
+		switch_mutex_lock(bug->read_mutex);
+		
+		frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer,
+													   frame->data,
+													   rdlen);
+		switch_mutex_unlock(bug->read_mutex);
+	}
+
+	if (wlen) {
+		switch_mutex_lock(bug->write_mutex);
+		datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer,
+												data,
+												rdlen);
+		switch_mutex_unlock(bug->write_mutex);
+	}
+
+	bytes = (datalen > frame->datalen) ? datalen : frame->datalen;
+
+	if (bytes) {
+		dp = (int16_t *) data;
+		fp = (int16_t *) frame->data;
+		
+		rlen = frame->datalen / 2;
+		wlen = datalen / 2;
+		blen = bytes / 2;
+		
+		for(x = 0; x < blen; x++) {
+			int32_t z = 0;
+
+			if (x < rlen) {
+				z += (int32_t) *(fp+x);
+			}
+			if (x < wlen) {
+				z += (int32_t)*(dp+x);
+			}
+			switch_normalize_to_16bit(z);
+			*(fp+x) = (int16_t) z;
+		}
+
+		frame->datalen = bytes;
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
+#define MAX_BUG_BUFFER 1024 * 512
+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_t **new_bug)
+
+{
+	switch_media_bug_t *bug;
+	switch_size_t bytes;
+
+	if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
+		return SWITCH_STATUS_MEMERR;
+	}
+
+	bug->callback = callback;
+	bug->user_data = user_data;
+	bug->session = session;
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
+	bytes = session->read_codec->implementation->bytes_per_frame;
+	switch_buffer_create_dynamic(&bug->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, MAX_BUG_BUFFER);
+	bytes = session->write_codec->implementation->bytes_per_frame;
+	switch_buffer_create_dynamic(&bug->raw_write_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, MAX_BUG_BUFFER);
+	switch_mutex_init(&bug->read_mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_mutex_init(&bug->write_mutex, SWITCH_MUTEX_NESTED, session->pool);
+
+	switch_thread_rwlock_wrlock(session->bug_rwlock);
+	bug->next = session->bugs;
+	session->bugs = bug;
+	switch_thread_rwlock_unlock(session->bug_rwlock);
+	*new_bug = bug;
+
+	if (bug->callback) {
+		bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all(switch_core_session_t *session)
+{
+	switch_media_bug_t *bp;
+
+	if (session->bugs) {
+		switch_thread_rwlock_wrlock(session->bug_rwlock);
+		for (bp = session->bugs; bp; bp = bp->next) {
+			if (bp->callback) {
+				bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_CLOSE);
+			}
+			switch_core_media_bug_destroy(bp);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing BUG from %s\n", switch_channel_get_name(session->channel));
+		}
+		switch_thread_rwlock_unlock(session->bug_rwlock);
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug)
+{
+	switch_media_bug_t *bp = NULL, *last = NULL;
+
+	if (session->bugs) {
+		switch_thread_rwlock_wrlock(session->bug_rwlock);
+		for (bp = session->bugs; bp; bp = bp->next) {
+			if (bp == *bug) {
+				if (last) {
+					last->next = bp->next;
+				} else {
+					session->bugs = bp->next;
+				}
+				break;
+			}
+			last = bp;
+		}
+		switch_thread_rwlock_unlock(session->bug_rwlock);
+
+		if (bp) {
+			if (bp->callback) {
+				bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_CLOSE);
+			}
+			switch_core_media_bug_destroy(bp);
+			*bug = NULL;
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing BUG from %s\n", switch_channel_get_name(session->channel));
+			return SWITCH_STATUS_SUCCESS;
+		}
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
+struct switch_core_port_allocator {
+	switch_port_t start;
+	switch_port_t end;
+	switch_port_t next;
+	uint8_t inc;
+	switch_mutex_t *mutex;
+	switch_memory_pool_t *pool;
+};
+
+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_status_t status;
+	switch_memory_pool_t *pool;
+	switch_core_port_allocator_t *alloc;
+
+	if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
+		return status;
+	}
+
+	if (!(alloc = switch_core_alloc(pool, sizeof(*alloc)))) {
+		switch_core_destroy_memory_pool(&pool);
+		return SWITCH_STATUS_MEMERR;
+	}
+	
+	alloc->start = start;
+	alloc->next = start;
+	alloc->end = end;
+	if (!(alloc->inc = inc)) {
+		alloc->inc = 2;
+	}
+	switch_mutex_init(&alloc->mutex, SWITCH_MUTEX_NESTED, pool);
+	alloc->pool = pool;
+	*new_allocator = alloc;
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(switch_port_t) switch_core_port_allocator_request_port(switch_core_port_allocator_t *alloc)
+{
+	switch_port_t port;
+
+	switch_mutex_lock(alloc->mutex);
+	port = alloc->next;
+	alloc->next = alloc->next + alloc->inc;
+	if (alloc->next > alloc->end) {
+		alloc->next = alloc->start;
+	}
+	switch_mutex_unlock(alloc->mutex);
+	return port;
+}
+
+SWITCH_DECLARE(void) switch_core_port_allocator_destroy(switch_core_port_allocator_t **alloc)
+{
+	switch_memory_pool_t *pool = (*alloc)->pool;
+	switch_core_destroy_memory_pool(&pool);
+	*alloc = NULL;
+}
+
+SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(char *filename)
+{
+	switch_core_db_t *db;
 	char path[1024];
 
 	db_pick_path(filename, path, sizeof(path));
@@ -127,8 +404,9 @@
 	return db;
 }
 
-#if 0
-static void check_table_exists(switch_core_db *db, char *test_sql, char *create_sql) {
+
+SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *reactive_sql) 
+{
     char *errmsg;
 
     if(db) {
@@ -147,13 +425,13 @@
                 errmsg = NULL;
                 switch_core_db_exec(
 									db,
-                             create_sql,
+                             reactive_sql,
                              NULL,
                              NULL,
                              &errmsg
                              );
                 if (errmsg) {
-                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, create_sql);
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\n", errmsg, reactive_sql);
                     switch_core_db_free(errmsg);
                     errmsg = NULL;
                 }
@@ -162,10 +440,10 @@
     }
 
 }
-#endif
 
 
-SWITCH_DECLARE(switch_status) switch_core_set_console(char *console)
+
+SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console)
 {
 	if ((runtime.console = fopen(console, "a")) == 0) {
 		fprintf(stderr, "Cannot open output file %s.\n", console);
@@ -180,7 +458,7 @@
 	return runtime.console;
 }
 
-SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel)
+SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel)
 {
 	FILE *handle = stdout;
 
@@ -197,7 +475,7 @@
 	return handle;
 }
 
-SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_table *state_handler)
+SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_table_t *state_handler)
 {
 	int index = runtime.state_handler_index++;
 
@@ -209,7 +487,7 @@
 	return index;
 }
 
-SWITCH_DECLARE(const switch_state_handler_table *) switch_core_get_state_handler(int index)
+SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handler(int index)
 {
 
 	if (index > SWITCH_MAX_STATE_HANDLERS || index > runtime.state_handler_index) {
@@ -219,77 +497,168 @@
 	return runtime.state_handlers[index];
 }
 
-SWITCH_DECLARE(switch_core_session *) switch_core_session_locate(char *uuid_str)
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_session_t *session)
 {
-	switch_core_session *session;
-	session = switch_core_hash_find(runtime.session_table, uuid_str);
-	return session;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+
+	status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
+	
+	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_message_send(char *uuid_str, switch_core_session_message *message)
+SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session)
 {
-	switch_core_session *session = NULL;
+	switch_thread_rwlock_wrlock(session->rwlock);
+}
 
+SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session)
+{
+
+	switch_thread_rwlock_unlock(session->rwlock);
+
+}
+
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(char *uuid_str)
+{
+	switch_core_session_t *session;
+
+	if (uuid_str) {
+		switch_mutex_lock(runtime.session_table_mutex);
+		if ((session = switch_core_hash_find(runtime.session_table, uuid_str))) {
+			/* Acquire a read lock on the session */
+			if (switch_thread_rwlock_tryrdlock(session->rwlock) != SWITCH_STATUS_SUCCESS) {
+				/* not available, forget it */
+				session = NULL;
+			}
+		}
+		switch_mutex_unlock(runtime.session_table_mutex);
+
+		/* if its not NULL, now it's up to you to rwunlock this */
+		return session;
+	} else {
+		return NULL;
+	}
+}
+
+SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause)
+{
+	switch_hash_index_t *hi;
+	void *val;
+	switch_core_session_t *session;
+	switch_channel_t *channel;
+
+	switch_mutex_lock(runtime.session_table_mutex);
+	for (hi = switch_hash_first(runtime.memory_pool, runtime.session_table); hi; hi = switch_hash_next(hi)) {
+        switch_hash_this(hi, NULL, NULL, &val);
+		if (val) {
+			session = (switch_core_session_t *) val;
+			channel = switch_core_session_get_channel(session);
+			switch_channel_hangup(channel, cause);
+		}
+	}
+	switch_mutex_unlock(runtime.session_table_mutex);
+
+	while(runtime.session_count > 0) {
+		switch_yield(10000);
+	}
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message)
+{
+	switch_core_session_t *session = NULL;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	switch_mutex_lock(runtime.session_table_mutex);
 	if ((session = switch_core_hash_find(runtime.session_table, uuid_str)) != 0) {
-		if (switch_channel_get_state(session->channel) < CS_HANGUP) {
-			return switch_core_session_receive_message(session, message);
+		/* Acquire a read lock on the session or forget it the channel is dead */
+		if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
+			if (switch_channel_get_state(session->channel) < CS_HANGUP) {
+				status = switch_core_session_receive_message(session, message);
+			}
+			switch_thread_rwlock_unlock(session->rwlock);
 		}
 	}
+	switch_mutex_unlock(runtime.session_table_mutex);
 
-	return SWITCH_STATUS_FALSE;
+	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_event_send(char *uuid_str, switch_event *event)
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event)
 {
-	switch_core_session *session = NULL;
+	switch_core_session_t *session = NULL;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
+	switch_mutex_lock(runtime.session_table_mutex);
 	if ((session = switch_core_hash_find(runtime.session_table, uuid_str)) != 0) {
-		if (switch_channel_get_state(session->channel) < CS_HANGUP) {
-			return switch_core_session_queue_event(session, event);
+		/* Acquire a read lock on the session or forget it the channel is dead */
+		if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
+			if (switch_channel_get_state(session->channel) < CS_HANGUP) {
+				status = switch_core_session_queue_event(session, event);
+			}
+			switch_thread_rwlock_unlock(session->rwlock);
 		}
 	}
+	switch_mutex_unlock(runtime.session_table_mutex);
 
-	return SWITCH_STATUS_FALSE;
+	return status;
 }
 
-SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session)
+SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session_t *session)
 {
 	return session->uuid_str;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec)
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
 {
+	switch_event_t *event;
+
 	assert(session != NULL);
 
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-rate", "%d", codec->implementation->samples_per_second);
+		switch_event_fire(&event);
+	}
+				
 	session->read_codec = codec;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_codec *) switch_core_session_get_read_codec(switch_core_session *session)
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_session_t *session)
 {
 	return session->read_codec;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec)
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec)
 {
+	switch_event_t *event;
 	assert(session != NULL);
 
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->samples_per_second);
+		switch_event_fire(&event);
+	}
+
 	session->write_codec = codec;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_codec *) switch_core_session_get_write_codec(switch_core_session *session)
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(switch_core_session_t *session)
 {
 	return session->write_codec;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, uint32_t rate, int ms,
+SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, char *codec_name, uint32_t rate, int ms,
 													 int channels, uint32_t flags,
-													 const switch_codec_settings *codec_settings,
-													 switch_memory_pool *pool)
+													 const switch_codec_settings_t *codec_settings,
+													 switch_memory_pool_t *pool)
 {
-	const switch_codec_interface *codec_interface;
-	const switch_codec_implementation *iptr, *implementation = NULL;
+	const switch_codec_interface_t *codec_interface;
+	const switch_codec_implementation_t *iptr, *implementation = NULL;
 
 	assert(codec != NULL);
 	assert(codec_name != NULL);
@@ -311,7 +680,7 @@
 	}
 
 	if (implementation) {
-		switch_status status;
+		switch_status_t status;
 		codec->codec_interface = codec_interface;
 		codec->implementation = implementation;
 		codec->flags = flags;
@@ -324,20 +693,23 @@
 			}
 			switch_set_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL);
 		}
+
 		implementation->init(codec, flags, codec_settings);
 
 		return SWITCH_STATUS_SUCCESS;
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not then desired implementation.\n",
-							  codec_name);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms\n",
+						  codec_name,
+						  rate,
+						  ms);
 	}
 
 	return SWITCH_STATUS_NOTIMPL;
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
-													   switch_codec *other_codec,
+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,
@@ -367,13 +739,15 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
-													   switch_codec *other_codec,
+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)
+													   uint32_t *decoded_data_len, 
+													   uint32_t *decoded_rate, 
+													   unsigned int *flag)
 {
 
 	assert(codec != NULL);
@@ -401,7 +775,7 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec)
+SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
 {
 	assert(codec != NULL);
 
@@ -419,11 +793,11 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags,
-													switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh, char *file_path, unsigned int flags,
+													switch_memory_pool_t *pool)
 {
 	char *ext;
-	switch_status status;
+	switch_status_t status;
 
 	if ((ext = strrchr(file_path, '.')) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
@@ -449,39 +823,56 @@
 	return fh->file_interface->file_open(fh, file_path);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void *data, switch_size_t *len)
+SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len)
 {
 	assert(fh != NULL);
 
 	return fh->file_interface->file_read(fh, data, len);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, switch_size_t *len)
+SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len)
 {
 	assert(fh != NULL);
 
 	return fh->file_interface->file_write(fh, data, len);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, int64_t samples,
+SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples,
 													int whence)
 {
+	assert(fh != NULL);
 	return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh)
+SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
 {
+	assert(fh != NULL);
+
+	return fh->file_interface->file_set_string(fh, col, string);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
+{
+	assert(fh != NULL);
+	
+	return fh->file_interface->file_get_string(fh, col, string);
+
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
+{
 	return fh->file_interface->file_close(fh);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_directory_open(switch_directory_handle *dh, 
+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 *pool)
+														 switch_memory_pool_t *pool)
 {
-	switch_status status;
+	switch_status_t status;
 
 	if ((dh->directory_interface = switch_loadable_module_get_directory_interface(module_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid directory module [%s]!\n", module_name);
@@ -500,40 +891,41 @@
 	return dh->directory_interface->directory_open(dh, source, dsn, passwd);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_directory_query(switch_directory_handle *dh, char *base, char *query)
+SWITCH_DECLARE(switch_status_t) switch_core_directory_query(switch_directory_handle_t *dh, char *base, char *query)
 {
 	return dh->directory_interface->directory_query(dh, base, query);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_directory_next(switch_directory_handle *dh)
+SWITCH_DECLARE(switch_status_t) switch_core_directory_next(switch_directory_handle_t *dh)
 {
 	return dh->directory_interface->directory_next(dh);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_directory_next_pair(switch_directory_handle *dh, char **var, char **val)
+SWITCH_DECLARE(switch_status_t) switch_core_directory_next_pair(switch_directory_handle_t *dh, char **var, char **val)
 {
 	return dh->directory_interface->directory_next_pair(dh, var, val);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_directory_close(switch_directory_handle *dh)
+SWITCH_DECLARE(switch_status_t) switch_core_directory_close(switch_directory_handle_t *dh)
 {
 	return dh->directory_interface->directory_close(dh);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_speech_open(switch_speech_handle *sh, 
-													  char *module_name, 
-													  char *voice_name,
-													  unsigned int rate,
-													  switch_speech_flag *flags,
-													  switch_memory_pool *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)
 {
-	switch_status status;
+	switch_status_t status;
 
 	if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid speech module [%s]!\n", module_name);
 		return SWITCH_STATUS_GENERR;
 	}
 
+	switch_copy_string(sh->engine, module_name, sizeof(sh->engine));
 	sh->flags = *flags;
 	if (pool) {
 		sh->memory_pool = pool;
@@ -543,36 +935,73 @@
 		}
 		switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL);
 	}
-
+	sh->rate = rate;
+	sh->name = switch_core_strdup(pool, module_name);
 	return sh->speech_interface->speech_open(sh, voice_name, rate, flags);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_speech_feed_asr(switch_speech_handle *sh, void *data, unsigned int *len, int rate, switch_speech_flag *flags)
+SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_asr(switch_speech_handle_t *sh, void *data, unsigned int *len, int rate, switch_speech_flag_t *flags)
 {
 	assert(sh != NULL);
 	
 	return sh->speech_interface->speech_feed_asr(sh, data, len, rate, flags);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_speech_interpret_asr(switch_speech_handle *sh, char *buf, unsigned int buflen, switch_speech_flag *flags)
+SWITCH_DECLARE(switch_status_t) switch_core_speech_interpret_asr(switch_speech_handle_t *sh, char *buf, unsigned int buflen, switch_speech_flag_t *flags)
 {
 	assert(sh != NULL);
 	
 	return sh->speech_interface->speech_interpret_asr(sh, buf, buflen, flags);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *sh, char *text, switch_speech_flag *flags)
+SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 {
 	assert(sh != NULL);
 
 	return sh->speech_interface->speech_feed_tts(sh, text, flags);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle *sh, 
+SWITCH_DECLARE(void) switch_core_speech_flush_tts(switch_speech_handle_t *sh)
+{
+	assert(sh != NULL);
+
+	if (sh->speech_interface->speech_flush_tts) {
+		sh->speech_interface->speech_flush_tts(sh);
+	}
+}
+
+SWITCH_DECLARE(void) switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, char *val)
+{
+	assert(sh != NULL);
+
+	if (sh->speech_interface->speech_text_param_tts) {
+		sh->speech_interface->speech_text_param_tts(sh, param, val);
+	}
+}
+
+SWITCH_DECLARE(void) switch_core_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
+{
+	assert(sh != NULL);
+
+	if (sh->speech_interface->speech_numeric_param_tts) {
+		sh->speech_interface->speech_numeric_param_tts(sh, param, val);
+	}
+}
+
+SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
+{
+	assert(sh != NULL);
+
+	if (sh->speech_interface->speech_float_param_tts) {
+		sh->speech_interface->speech_float_param_tts(sh, param, val);
+	}
+}
+
+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 *flags)
+														  switch_speech_flag_t *flags)
 {
 	assert(sh != NULL);
 
@@ -580,16 +1009,16 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_core_speech_close(switch_speech_handle *sh, switch_speech_flag *flags)
+SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
 {
 	return sh->speech_interface->speech_close(sh, flags);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples,
-													 switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, int samples,
+													 switch_memory_pool_t *pool)
 {
-	switch_timer_interface *timer_interface;
-	switch_status status;
+	switch_timer_interface_t *timer_interface;
+	switch_status_t status;
 	memset(timer, 0, sizeof(*timer));
 	if ((timer_interface = switch_loadable_module_get_timer_interface(timer_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid timer %s!\n", timer_name);
@@ -615,7 +1044,7 @@
 
 }
 
-SWITCH_DECLARE(int) switch_core_timer_next(switch_timer *timer)
+SWITCH_DECLARE(int) switch_core_timer_next(switch_timer_t *timer)
 {
 	if (!timer->timer_interface) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer is not initilized!\n");
@@ -630,14 +1059,34 @@
 
 }
 
+SWITCH_DECLARE(switch_status_t) switch_core_timer_step(switch_timer_t *timer)
+{
+	if (!timer->timer_interface) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer is not initilized!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
-SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer)
+	return timer->timer_interface->timer_step(timer);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer)
 {
 	if (!timer->timer_interface) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer is not initilized!\n");
 		return SWITCH_STATUS_GENERR;
 	}
 
+	return timer->timer_interface->timer_check(timer);
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer)
+{
+	if (!timer->timer_interface) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer is not initilized!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
 	timer->timer_interface->timer_destroy(timer);
 
 	if (switch_test_flag(timer, SWITCH_TIMER_FLAG_FREE_POOL)) {
@@ -647,13 +1096,13 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void *switch_core_service_thread(switch_thread *thread, void *obj)
+static void *switch_core_service_thread(switch_thread_t *thread, void *obj)
 {
-	switch_core_thread_session *data = obj;
-	switch_core_session *session = data->objs[0];
+	switch_core_thread_session_t *data = obj;
+	switch_core_session_t *session = data->objs[0];
 	int *stream_id_p = data->objs[1];
-	switch_channel *channel;
-	switch_frame *read_frame;
+	switch_channel_t *channel;
+	switch_frame_t *read_frame;
 	int stream_id = *stream_id_p;
 
 	assert(thread != NULL);
@@ -661,26 +1110,26 @@
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
+	switch_channel_set_flag(channel, CF_SERVICE);
 	while (data->running > 0) {
 		switch (switch_core_session_read_frame(session, &read_frame, -1, stream_id)) {
 		case SWITCH_STATUS_SUCCESS:
-			break;
 		case SWITCH_STATUS_TIMEOUT:
+		case SWITCH_STATUS_BREAK:
 			break;
 		default:
 			data->running = -1;
 			continue;
 		}
-
-		switch_yield(10000);
 	}
 
+	switch_channel_clear_flag(channel, CF_SERVICE);
 	data->running = 0;
 	return NULL;
 }
 
 /* Either add a timeout here or make damn sure the thread cannot get hung somehow (my preference) */
-SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *thread_session)
+SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session_t *thread_session)
 {
 	if (thread_session->running > 0) {
 		thread_session->running = -1;
@@ -691,8 +1140,8 @@
 	}
 }
 
-SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session,
-												 switch_core_thread_session *thread_session, int stream_id)
+SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session,
+												 switch_core_thread_session_t *thread_session, int stream_id)
 {
 	thread_session->running = 1;
 	thread_session->objs[0] = session;
@@ -700,14 +1149,14 @@
 	switch_core_session_launch_thread(session, switch_core_service_thread, thread_session);
 }
 
-SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session)
+SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_session_t *session)
 {
 	return session->pool;
 }
 
 /* **ONLY** alloc things with this function that **WILL NOT** outlive
    the session itself or expect an earth shattering KABOOM!*/
-SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session *session, switch_size_t memory)
+SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session_t *session, switch_size_t memory)
 {
 	void *ptr = NULL;
 	assert(session != NULL);
@@ -725,9 +1174,9 @@
 }
 
 /* **ONLY** alloc things with these functions that **WILL NOT** need
-   to be freed *EVER* ie this is for *PERMENANT* memory allocation */
+   to be freed *EVER* ie this is for *PERMANENT* memory allocation */
 
-SWITCH_DECLARE(void *) switch_core_permenant_alloc(switch_size_t memory)
+SWITCH_DECLARE(void *) switch_core_permanent_alloc(switch_size_t memory)
 {
 	void *ptr = NULL;
 	assert(runtime.memory_pool != NULL);
@@ -742,7 +1191,7 @@
 	return ptr;
 }
 
-SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup)
+SWITCH_DECLARE(char *) switch_core_permanent_strdup(char *todup)
 {
 	char *duped = NULL;
 	switch_size_t len;
@@ -765,7 +1214,7 @@
 }
 
 
-SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session, char *todup)
+SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session, char *todup)
 {
 	char *duped = NULL;
 	switch_size_t len;
@@ -788,7 +1237,7 @@
 }
 
 
-SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup)
+SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, char *todup)
 {
 	char *duped = NULL;
 	switch_size_t len;
@@ -810,46 +1259,48 @@
 	return duped;
 }
 
-SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session)
+SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session_t *session)
 {
 	assert(session != NULL);
 	return session->private_info;
 }
 
 
-SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_session *session, void *private_info)
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_private(switch_core_session_t *session, void *private_info)
 {
 	assert(session != NULL);
 	session->private_info = private_info;
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private_info)
+SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session_t *session, void *private_info)
 {
 	session->streams[session->stream_count++] = private_info;
 	return session->stream_count - 1;
 }
 
-SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index)
+SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session_t *session, int index)
 {
 	return session->streams[index];
 }
 
 
-SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session)
+SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t *session)
 {
 	return session->stream_count;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_outgoing_channel(switch_core_session_t *session,
 																   char *endpoint_name,
-																   switch_caller_profile *caller_profile,
-																   switch_core_session **new_session,
-																   switch_memory_pool *pool)
+																   switch_caller_profile_t *caller_profile,
+																   switch_core_session_t **new_session,
+																   switch_memory_pool_t *pool)
 {
-	struct switch_io_event_hook_outgoing_channel *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
-	const switch_endpoint_interface *endpoint_interface;
+	switch_io_event_hook_outgoing_channel_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	const switch_endpoint_interface_t *endpoint_interface;
+	switch_channel_t *channel = NULL;
+	switch_caller_profile_t *outgoing_profile = caller_profile;
 
 	if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name);
@@ -857,9 +1308,36 @@
 	}
 
 	if (endpoint_interface->io_routines->outgoing_channel) {
-		if ((status =
-			 endpoint_interface->io_routines->outgoing_channel(session, caller_profile,
-															   new_session, pool)) == SWITCH_STATUS_SUCCESS) {
+		if (session) {
+			char *ecaller_id_name = NULL, *ecaller_id_number = NULL;
+			channel = switch_core_session_get_channel(session);
+			
+			ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name");
+			ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number");
+			
+			if (ecaller_id_name || ecaller_id_number) {
+				if (caller_profile) {
+					outgoing_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+																 caller_profile->username,
+																 caller_profile->dialplan,
+																 ecaller_id_name ? ecaller_id_name : caller_profile->caller_id_name,
+																 ecaller_id_number ? ecaller_id_number : caller_profile->caller_id_number,
+																 caller_profile->network_addr,
+																 caller_profile->ani,
+																 caller_profile->ani2, 
+																 caller_profile->rdnis,
+																 caller_profile->source,
+																 caller_profile->context,
+																 caller_profile->destination_number);
+					
+				}
+			}
+		}
+		
+		if ((status = endpoint_interface->io_routines->outgoing_channel(session,
+																		outgoing_profile,
+																		new_session,
+																		pool)) == SWITCH_STATUS_SUCCESS) {
 			if (session) {
 				for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
 					if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) {
@@ -870,13 +1348,18 @@
 		} else {
 			return status;
 		}
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate outgoing channel interface for %s\n", endpoint_name);
+		return SWITCH_STATUS_FALSE;
 	}
 
 	if (*new_session) {
-		switch_caller_profile *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
-		switch_channel *channel = NULL, *peer_channel = NULL;
+		switch_caller_profile_t *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
+		switch_channel_t *peer_channel = NULL;
+		switch_event_t *event;
+		switch_channel_t *new_channel = switch_core_session_get_channel(*new_session);
 
-		if (session && (channel = switch_core_session_get_channel(session)) != 0) {
+		if (session && channel) {
 			profile = switch_channel_get_caller_profile(channel);
 		}
 		if ((peer_channel = switch_core_session_get_channel(*new_session)) != 0) {
@@ -895,15 +1378,20 @@
 				}
 			}
 		}
+
+		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_OUTGOING) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(new_channel, event);
+			switch_event_fire(&event);
+		}
 	}
 
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_session *session)
+SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session)
 {
-	struct switch_io_event_hook_answer_channel *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_answer_channel_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	assert(session != NULL);
 	if (session->endpoint_interface->io_routines->answer_channel) {
@@ -921,11 +1409,11 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session,
-																  switch_core_session_message *message)
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session,
+																  switch_core_session_message_t *message)
 {
-	struct switch_io_event_hook_receive_message *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_receive_message_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	assert(session != NULL);
 	if (session->endpoint_interface->io_routines->receive_message) {
@@ -942,45 +1430,155 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_queue_event(switch_core_session *session, switch_event *event)
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event)
 	 
 {
-	struct switch_io_event_hook_queue_event *ptr;
-	switch_status status = SWITCH_STATUS_FALSE, istatus = SWITCH_STATUS_FALSE;;
+	switch_io_event_hook_receive_event_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	assert(session != NULL);
-	if (session->endpoint_interface->io_routines->queue_event) {
-		status = session->endpoint_interface->io_routines->queue_event(session, event);
 
-		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-			for (ptr = session->event_hooks.queue_event; ptr; ptr = ptr->next) {
-				if ((istatus = ptr->queue_event(session, event)) != SWITCH_STATUS_SUCCESS) {
-					break;
+	/* Acquire a read lock on the session or forget it the channel is dead */
+	if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
+		if (switch_channel_get_state(session->channel) < CS_HANGUP) {
+			if (session->endpoint_interface->io_routines->receive_event) {
+				status = session->endpoint_interface->io_routines->receive_event(session, *event);
+			} 
+	
+			if (status == SWITCH_STATUS_SUCCESS) {
+				for (ptr = session->event_hooks.receive_event; ptr; ptr = ptr->next) {
+					if ((status = ptr->receive_event(session, *event)) != SWITCH_STATUS_SUCCESS) {
+						break;
+					}
 				}
 			}
-		}
-		
-		if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
-			if (!session->event_queue) {
-				switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+
+			if (status == SWITCH_STATUS_BREAK) {
+				status = SWITCH_STATUS_SUCCESS;
 			}
-			switch_queue_push(session->event_queue, event);
+
+			if (status == SWITCH_STATUS_SUCCESS) {
+				switch_event_destroy(event);
+			}
 		}
+		switch_thread_rwlock_unlock(session->rwlock);
 	}
+	
+	return status;
+}
 
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event)
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	assert(session != NULL);
+
+	if (!session->event_queue) {
+		switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+	}
+
+	if (session->event_queue) {
+		if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) {
+			*event = NULL;
+			status = SWITCH_STATUS_SUCCESS;
+		}
+	} 
+
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame,
-															 int timeout, int stream_id)
+SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *session)
 {
-	struct switch_io_event_hook_read_frame *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
-	int need_codec = 0, perfect = 0;
+	if (session->event_queue) {
+		return (int32_t) switch_queue_size(session->event_queue);
+	}
 
+	return -1;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event)
+	 
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	void *pop;
+
 	assert(session != NULL);
+	
+	if (session->event_queue) {
+		if ((status = (switch_status_t) switch_queue_trypop(session->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+			*event = (switch_event_t *) pop;
+		}
+	}
+
+	return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event)
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	assert(session != NULL);
+
+	if (!session->private_event_queue) {
+		switch_queue_create(&session->private_event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+	}
+
+	if (session->private_event_queue) {
+		if (switch_queue_trypush(session->private_event_queue, *event) == SWITCH_STATUS_SUCCESS) {
+			*event = NULL;
+			status = SWITCH_STATUS_SUCCESS;
+		}
+	} 
+
+	return status;
+}
+
+SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_session_t *session)
+{
+	if (session->private_event_queue) {
+		return (int32_t) switch_queue_size(session->private_event_queue);
+	}
+
+	return -1;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, switch_event_t **event)
+	 
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	void *pop;
+
+	assert(session != NULL);
+	
+	if (session->private_event_queue) {
+		if ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+			*event = (switch_event_t *) pop;
+		}
+	}
+
+	return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame,
+															 int timeout, int stream_id)
+{
+	switch_io_event_hook_read_frame_t *ptr;
+	switch_status_t status;
+	int need_codec, perfect, do_bugs = 0;
+ top:
+	
+	status = SWITCH_STATUS_FALSE;
+	need_codec = perfect = 0;
+	
+	assert(session != NULL);
 	*frame = NULL;
 
+	while (switch_channel_test_flag(session->channel, CF_HOLD)) {
+		status = SWITCH_STATUS_BREAK;
+		goto done;
+	}
+
 	if (session->endpoint_interface->io_routines->read_frame) {
 		if ((status = session->endpoint_interface->io_routines->read_frame(session,
 																		   frame,
@@ -997,15 +1595,20 @@
 		}
 	}
 
-	if (status != SWITCH_STATUS_SUCCESS || !(*frame)) {
-		return status;
+	if (status != SWITCH_STATUS_SUCCESS) {
+		goto done;
 	}
 
+	if (!(*frame)) {
+		goto done;
+	}
+
 	assert(session != NULL);
 	assert(*frame != NULL);
 	
 	if (switch_test_flag(*frame, SFF_CNG)) {
-		return SWITCH_STATUS_SUCCESS;
+		status = SWITCH_STATUS_SUCCESS;
+		goto done;
 	}
 
 	if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
@@ -1020,8 +1623,13 @@
 		need_codec = TRUE;
 	}
 
+	if (session->bugs && !need_codec) {
+		do_bugs = 1;
+		need_codec = 1;
+	}
+
 	if (status == SWITCH_STATUS_SUCCESS && need_codec) {
-		switch_frame *enc_frame, *read_frame = *frame;
+		switch_frame_t *enc_frame, *read_frame = *frame;
 
 		if (read_frame->codec) {
 			unsigned int flag = 0;
@@ -1053,9 +1661,8 @@
 				break;
 			default:
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s decoder error!\n",
-
-									  session->read_codec->codec_interface->interface_name);
-				return status;
+								  session->read_codec->codec_interface->interface_name);
+				goto done;
 			}
 		}
 		if (session->read_resampler) {
@@ -1073,17 +1680,36 @@
 			read_frame->rate = session->read_resampler->to_rate;
 		}
 
+		if (session->bugs) {
+			switch_media_bug_t *bp;
+			switch_thread_rwlock_rdlock(session->bug_rwlock);
+			for (bp = session->bugs; bp; bp = bp->next) {
+				switch_mutex_lock(bp->read_mutex);
+				switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
+				if (bp->callback) {
+					bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ);
+				}
+				switch_mutex_unlock(bp->read_mutex);
+			}
+			switch_thread_rwlock_unlock(session->bug_rwlock);
+		}
+
+		if (do_bugs) {
+			goto done;
+		}
+
 		if (session->read_codec) {
 			if ((*frame)->datalen == session->read_codec->implementation->bytes_per_frame) {
 				perfect = TRUE;
 			} else {
 				if (!session->raw_read_buffer) {
-					switch_size_t bytes = session->read_codec->implementation->bytes_per_frame * 10;
+					switch_size_t bytes = session->read_codec->implementation->bytes_per_frame;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes\n", bytes);
-					switch_buffer_create(session->pool, &session->raw_read_buffer, bytes);
+					switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
 				}
 				if (!switch_buffer_write(session->raw_read_buffer, read_frame->data, read_frame->datalen)) {
-					return SWITCH_STATUS_MEMERR;
+					status = SWITCH_STATUS_MEMERR;
+					goto done;
 				}
 			}
 
@@ -1095,18 +1721,22 @@
 					session->raw_read_frame.rate = (*frame)->rate;
 				} else {
 					session->raw_read_frame.datalen = (uint32_t)switch_buffer_read(session->raw_read_buffer,
-																		 session->raw_read_frame.data,
-																		 session->read_codec->implementation->
-																		 bytes_per_frame);
+																				   session->raw_read_frame.data,
+																				   session->read_codec->implementation->bytes_per_frame);
+					
 					session->raw_read_frame.rate = session->read_codec->implementation->samples_per_second;
 					enc_frame = &session->raw_read_frame;
 				}
 				session->enc_read_frame.datalen = session->enc_read_frame.buflen;
+				assert(session->read_codec != NULL);				
+				assert(enc_frame != NULL);
+				assert(enc_frame->data != NULL);
+				
 				status = switch_core_codec_encode(session->read_codec,
 												  enc_frame->codec,
 												  enc_frame->data,
 												  enc_frame->datalen,
-												  enc_frame->codec->implementation->samples_per_second,
+												  session->read_codec->implementation->samples_per_second,
 												  session->enc_read_frame.data,
 												  &session->enc_read_frame.datalen,
 												  &session->enc_read_frame.rate, 
@@ -1130,17 +1760,24 @@
 					status = SWITCH_STATUS_GENERR;
 					break;
 				}
+			} else {
+				goto top;
 			}
 		}
 	}
 
+ done:
+	if (!(*frame)) {
+		status = SWITCH_STATUS_FALSE;
+	}
+
 	return status;
 }
 
-static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
+static switch_status_t perform_write(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
 {
-	struct switch_io_event_hook_write_frame *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_write_frame_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (session->endpoint_interface->io_routines->write_frame) {
 		if ((status =
@@ -1156,19 +1793,37 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame,
+SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session)
+{
+	/* sweep theese under the rug, they wont be leaked they will be reclaimed
+	   when the session ends.
+	*/
+
+	session->read_resampler = NULL;
+	session->write_resampler = NULL;
+
+	/* wipe theese, they will be recreated if need be */
+	switch_buffer_destroy(&session->raw_read_buffer);
+	switch_buffer_destroy(&session->raw_write_buffer);
+}
+
+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_status status = SWITCH_STATUS_FALSE;
-	switch_frame *enc_frame = NULL, *write_frame = frame;
-	unsigned int flag = 0, need_codec = 0, perfect = 0;
-	switch_io_flag io_flag = SWITCH_IO_FLAG_NOOP;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	switch_frame_t *enc_frame = NULL, *write_frame = frame;
+	unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0;
+	switch_io_flag_t io_flag = SWITCH_IO_FLAG_NOOP;
 
 	assert(session != NULL);
 	assert(frame != NULL);
 	assert(frame->codec != NULL);
 
+	if (switch_channel_test_flag(session->channel, CF_HOLD)) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
 	if (switch_test_flag(frame, SFF_CNG)) {
 
 		if (switch_channel_test_flag(session->channel, CF_ACCEPT_CNG)) { 
@@ -1191,10 +1846,14 @@
 		need_codec = TRUE;
 	}
 
+	if (session->bugs && !need_codec) {
+		do_bugs = 1;
+		need_codec = 1;
+	}
+
 	if (need_codec) {
 		if (frame->codec) {
 			session->raw_write_frame.datalen = session->raw_write_frame.buflen;
-
 			status = switch_core_codec_decode(frame->codec,
 											  session->write_codec,
 											  frame->data,
@@ -1234,44 +1893,69 @@
 		if (session->write_resampler) {
 			short *data = write_frame->data;
 
-			session->write_resampler->from_len =
-				switch_short_to_float(data, session->write_resampler->from, (int) write_frame->datalen / 2);
+			session->write_resampler->from_len = write_frame->datalen / 2;
+			switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len);
+
+
+
 			session->write_resampler->to_len = (uint32_t)
 				switch_resample_process(session->write_resampler, session->write_resampler->from,
 										session->write_resampler->from_len, session->write_resampler->to,
 										session->write_resampler->to_size, 0);
-			switch_float_to_short(session->write_resampler->to, data, write_frame->datalen * 2);
+			
+
+			switch_float_to_short(session->write_resampler->to, data, session->write_resampler->to_len);
+
 			write_frame->samples = session->write_resampler->to_len;
-			write_frame->datalen = session->write_resampler->to_len * 2;
+			write_frame->datalen = write_frame->samples * 2;
 			write_frame->rate = session->write_resampler->to_rate;
 		}
 
-
+		if (session->bugs) {
+			switch_media_bug_t *bp;
+			switch_thread_rwlock_rdlock(session->bug_rwlock);
+			for (bp = session->bugs; bp; bp = bp->next) {
+				switch_mutex_lock(bp->write_mutex);
+				switch_buffer_write(bp->raw_write_buffer, write_frame->data, write_frame->datalen);
+				switch_mutex_unlock(bp->write_mutex);
+				if (bp->callback) {
+					bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE);
+				}
+			}
+			switch_thread_rwlock_unlock(session->bug_rwlock);
+		}
+		if (do_bugs) {
+			do_write = 1;
+			write_frame = frame;
+			goto done;
+		}
 		if (session->write_codec) {
 			if (write_frame->datalen == session->write_codec->implementation->bytes_per_frame) {
 				perfect = TRUE;
 			} else {
 				if (!session->raw_write_buffer) {
-					switch_size_t bytes = session->write_codec->implementation->bytes_per_frame * 10;
+					switch_size_t bytes = session->write_codec->implementation->bytes_per_frame;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 										  "Engaging Write Buffer at %u bytes to accomodate %u->%u\n",
 										  bytes,
 										  write_frame->datalen, session->write_codec->implementation->bytes_per_frame);
-					if ((status =
-						 switch_buffer_create(session->pool, &session->raw_write_buffer,
-											  bytes)) != SWITCH_STATUS_SUCCESS) {
+					if ((status =switch_buffer_create_dynamic(&session->raw_write_buffer,
+															  bytes * SWITCH_BUFFER_BLOCK_FRAMES,
+															  bytes * SWITCH_BUFFER_START_FRAMES,
+															  0)) != SWITCH_STATUS_SUCCESS) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
 						return status;
 					}
 				}
+
 				if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
 					return SWITCH_STATUS_MEMERR;
 				}
 			}
 
+			
 			if (perfect) {
-
 				enc_frame = write_frame;
 				session->enc_write_frame.datalen = session->enc_write_frame.buflen;
 
@@ -1283,7 +1967,7 @@
 												  session->enc_write_frame.data,
 												  &session->enc_write_frame.datalen,
 												  &session->enc_write_frame.rate, &flag);
-
+				
 				switch (status) {
 				case SWITCH_STATUS_RESAMPLE:
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "fixme 2\n");
@@ -1307,14 +1991,15 @@
 				switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
 				uint32_t bytes = session->write_codec->implementation->bytes_per_frame;
 				switch_size_t frames = (used / bytes);
-
+				
 				status = SWITCH_STATUS_SUCCESS;
-				if (frames) {
+				if (!frames) {
+					return status;
+				} else {
 					switch_size_t x;
 					for (x = 0; x < frames; x++) {
 						if ((session->raw_write_frame.datalen = (uint32_t)
 							 switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
-
 							enc_frame = &session->raw_write_frame;
 							session->raw_write_frame.rate = session->write_codec->implementation->samples_per_second;
 							session->enc_write_frame.datalen = session->enc_write_frame.buflen;
@@ -1351,8 +2036,8 @@
 								status = SWITCH_STATUS_SUCCESS;
 								break;
 							default:
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s encoder error!\n",
-													  session->read_codec->codec_interface->interface_name);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s encoder error %d!\n",
+													  session->read_codec->codec_interface->interface_name, status);
 								write_frame = NULL;
 								return status;
 							}
@@ -1374,23 +2059,37 @@
 								write_frame->datalen = session->read_resampler->to_len * 2;
 								write_frame->rate = session->read_resampler->to_rate;
 							}
-							return perform_write(session, write_frame, timeout, io_flag, stream_id);
+							if ((status = perform_write(session, write_frame, timeout, io_flag, stream_id)) != SWITCH_STATUS_SUCCESS) {
+								break;
+							}
 						}
 					}
+					return status;
 				}
 			}
 		}
 	} else {
+		do_write = 1;
+	}
+
+ done:
+	if (do_write) {
 		return perform_write(session, frame, timeout, io_flag, stream_id);
 	}
 
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal 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)
 {
-	struct switch_io_event_hook_kill_channel *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_kill_channel_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_INFO, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig);
 
 	if (session->endpoint_interface->io_routines->kill_channel) {
 		if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) {
@@ -1406,10 +2105,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout, int stream_id)
+SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout, int stream_id)
 {
-	struct switch_io_event_hook_waitfor_read *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_waitfor_read_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (session->endpoint_interface->io_routines->waitfor_read) {
 		if ((status =
@@ -1427,11 +2126,11 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout,
+SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout,
 																int stream_id)
 {
-	struct switch_io_event_hook_waitfor_write *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_waitfor_write_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (session->endpoint_interface->io_routines->waitfor_write) {
 		if ((status =
@@ -1449,10 +2148,10 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_core_session_send_dtmf(switch_core_session *session, char *dtmf)
+SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf)
 {
-	struct switch_io_event_hook_send_dtmf *ptr;
-	switch_status status = SWITCH_STATUS_FALSE;
+	switch_io_event_hook_send_dtmf_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (session->endpoint_interface->io_routines->send_dtmf) {
 		if ((status = session->endpoint_interface->io_routines->send_dtmf(session, dtmf)) == SWITCH_STATUS_SUCCESS) {
@@ -1467,10 +2166,10 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session,
-																		  switch_outgoing_channel_hook outgoing_channel)
+SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_outgoing(switch_core_session_t *session,
+																		  switch_outgoing_channel_hook_t outgoing_channel)
 {
-	switch_io_event_hook_outgoing_channel *hook, *ptr;
+	switch_io_event_hook_outgoing_channel_t *hook, *ptr;
 
 	assert(outgoing_channel != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1489,11 +2188,11 @@
 	return SWITCH_STATUS_MEMERR;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session,
-																				switch_answer_channel_hook
+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)
 {
-	switch_io_event_hook_answer_channel *hook, *ptr;
+	switch_io_event_hook_answer_channel_t *hook, *ptr;
 
 	assert(answer_channel != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1513,10 +2212,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session,
-																			switch_read_frame_hook read_frame)
+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)
 {
-	switch_io_event_hook_read_frame *hook, *ptr;
+	switch_io_event_hook_read_frame_t *hook, *ptr;
 
 	assert(read_frame != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1536,10 +2235,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session,
-																			 switch_write_frame_hook write_frame)
+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)
 {
-	switch_io_event_hook_write_frame *hook, *ptr;
+	switch_io_event_hook_write_frame_t *hook, *ptr;
 
 	assert(write_frame != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1559,10 +2258,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session,
-																			  switch_kill_channel_hook kill_channel)
+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)
 {
-	switch_io_event_hook_kill_channel *hook, *ptr;
+	switch_io_event_hook_kill_channel_t *hook, *ptr;
 
 	assert(kill_channel != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1582,10 +2281,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session,
-																			  switch_waitfor_read_hook waitfor_read)
+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)
 {
-	switch_io_event_hook_waitfor_read *hook, *ptr;
+	switch_io_event_hook_waitfor_read_t *hook, *ptr;
 
 	assert(waitfor_read != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1605,10 +2304,10 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session,
-																			   switch_waitfor_write_hook waitfor_write)
+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)
 {
-	switch_io_event_hook_waitfor_write *hook, *ptr;
+	switch_io_event_hook_waitfor_write_t *hook, *ptr;
 
 	assert(waitfor_write != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1629,10 +2328,10 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session,
-																		   switch_send_dtmf_hook send_dtmf)
+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)
 {
-	switch_io_event_hook_send_dtmf *hook, *ptr;
+	switch_io_event_hook_send_dtmf_t *hook, *ptr;
 
 	assert(send_dtmf != NULL);
 	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
@@ -1653,52 +2352,52 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_core_new_memory_pool(switch_memory_pool **pool)
+SWITCH_DECLARE(switch_status_t) switch_core_new_memory_pool(switch_memory_pool_t **pool)
 {
 
 	assert(runtime.memory_pool != NULL);
 
-	if ((apr_pool_create(pool, runtime.memory_pool)) != SWITCH_STATUS_SUCCESS) {
+	if ((apr_pool_create(pool, NULL)) != SWITCH_STATUS_SUCCESS) {
 		*pool = NULL;
 		return SWITCH_STATUS_MEMERR;
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_destroy_memory_pool(switch_memory_pool **pool)
+SWITCH_DECLARE(switch_status_t) switch_core_destroy_memory_pool(switch_memory_pool_t **pool)
 {
 	apr_pool_destroy(*pool);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_channel *) switch_core_session_get_channel(switch_core_session *session)
+SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_session_t *session)
 {
 	return session->channel;
 }
 
-static void switch_core_standard_on_init(switch_core_session *session)
+static void switch_core_standard_on_init(switch_core_session_t *session)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard INIT %s\n", switch_channel_get_name(session->channel));
 }
 
-static void switch_core_standard_on_hangup(switch_core_session *session)
+static void switch_core_standard_on_hangup(switch_core_session_t *session)
 {
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HANGUP %s\n", switch_channel_get_name(session->channel));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HANGUP %s, cause: %s\n", switch_channel_get_name(session->channel),switch_channel_cause2str(switch_channel_get_cause(session->channel)));
 
 }
 
-static void switch_core_standard_on_ring(switch_core_session *session)
+static void switch_core_standard_on_ring(switch_core_session_t *session)
 {
-	switch_dialplan_interface *dialplan_interface = NULL;
-	switch_caller_profile *caller_profile;
-	switch_caller_extension *extension;
+	switch_dialplan_interface_t *dialplan_interface = NULL;
+	switch_caller_profile_t *caller_profile;
+	switch_caller_extension_t *extension;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard RING %s\n", switch_channel_get_name(session->channel));
 
 	if ((caller_profile = switch_channel_get_caller_profile(session->channel)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't get profile!\n");
-		switch_channel_set_state(session->channel, CS_HANGUP);
+		switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 	} else {
 		if (!switch_strlen_zero(caller_profile->dialplan)) {
 			dialplan_interface = switch_loadable_module_get_dialplan_interface(caller_profile->dialplan);
@@ -1706,9 +2405,12 @@
 
 		if (!dialplan_interface) {
 			if (switch_channel_test_flag(session->channel, CF_OUTBOUND)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, changing state to TRANSMIT\n");
-				switch_channel_set_state(session->channel, CS_TRANSMIT);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, changing state to HOLD\n");
+				switch_channel_set_state(session->channel, CS_HOLD);
 				return;
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Dialplan, Aborting\n");
+				switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			}
 		} else {
 			if ((extension = dialplan_interface->hunt_function(session)) != 0) {
@@ -1718,17 +2420,17 @@
 	}
 }
 
-static void switch_core_standard_on_execute(switch_core_session *session)
+static void switch_core_standard_on_execute(switch_core_session_t *session)
 {
-	switch_caller_extension *extension;
-	switch_event *event;
-	const switch_application_interface *application_interface;
+	switch_caller_extension_t *extension;
+	switch_event_t *event;
+	const switch_application_interface_t *application_interface;
 
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard EXECUTE\n");
 	if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Extension!\n");
-		switch_channel_set_state(session->channel, CS_HANGUP);
+		switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return;
 	}
 
@@ -1741,14 +2443,14 @@
 			 switch_loadable_module_get_application_interface(extension->current_application->application_name)) == 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n",
 								  extension->current_application->application_name);
-			switch_channel_set_state(session->channel, CS_HANGUP);
+			switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return;
 		}
 
 		if (!application_interface->application_function) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n",
 								  extension->current_application->application_name);
-			switch_channel_set_state(session->channel, CS_HANGUP);
+			switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 			return;
 		}
 		
@@ -1761,15 +2463,15 @@
 		application_interface->application_function(session, extension->current_application->application_data);
 		extension->current_application = extension->current_application->next;
 	}
-
+	
 	if (switch_channel_get_state(session->channel) == CS_EXECUTE) {
-		switch_channel_set_state(session->channel, CS_HANGUP);
+		switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);
 	}
 }
 
-static void switch_core_standard_on_loopback(switch_core_session *session)
+static void switch_core_standard_on_loopback(switch_core_session_t *session)
 {
-	switch_frame *frame;
+	switch_frame_t *frame;
 	int stream_id;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard LOOPBACK\n");
@@ -1783,29 +2485,114 @@
 	}
 }
 
-static void switch_core_standard_on_transmit(switch_core_session *session)
+static void switch_core_standard_on_transmit(switch_core_session_t *session)
 {
 	assert(session != NULL);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard TRANSMIT\n");
 }
 
-SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session *session)
+static void switch_core_standard_on_hold(switch_core_session_t *session)
 {
-	switch_thread_cond_signal(session->cond);
+	assert(session != NULL);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HOLD\n");
 }
 
-SWITCH_DECLARE(unsigned int) switch_core_session_runing(switch_core_session *session)
+SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session_t *session)
 {
+
+	/* If trylock fails the signal is already awake so we needn't bother */
+	if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
+		switch_thread_cond_signal(session->cond);
+		switch_mutex_unlock(session->mutex);
+	} 
+	
+}
+
+SWITCH_DECLARE(unsigned int) switch_core_session_running(switch_core_session_t *session)
+{
 	return session->thread_running;
 }
+#ifdef CRASH_PROT
+#if defined (__GNUC__) && defined (LINUX)
+#include <execinfo.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define STACK_LEN 10
 
-SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
+/* Obtain a backtrace and print it to stdout. */
+static void print_trace (void)
 {
-	switch_channel_state state = CS_NEW, laststate = CS_HANGUP, midstate = CS_DONE;
-	const switch_endpoint_interface *endpoint_interface;
-	const switch_state_handler_table *driver_state_handler = NULL;
-	const switch_state_handler_table *application_state_handler = NULL;
+	void *array[STACK_LEN];
+	size_t size;
+	char **strings;
+	size_t i;
 
+	size = backtrace (array, STACK_LEN);
+	strings = backtrace_symbols (array, size);
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Obtained %zd stack frames.\n", size);
+	
+	for (i = 0; i < size; i++) {
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CRIT, "%s\n", strings[i]);
+	}
+
+	free (strings);
+}
+#else
+static void print_trace (void)
+{
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Trace not avaliable =(\n");
+}
+#endif
+
+
+static int handle_fatality(int sig)
+{
+	switch_thread_id_t thread_id;
+	jmp_buf *env;
+
+	if (sig && (thread_id = switch_thread_self()) && (env = (jmp_buf *) apr_hash_get(runtime.stack_table, &thread_id, sizeof(thread_id)))) {
+		print_trace();
+		longjmp(*env, sig);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Caught signal %d for unmapped thread!", sig);
+		abort();
+	}
+
+	return 0;
+}
+#endif
+
+SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
+{
+	switch_channel_state_t state = CS_NEW, laststate = CS_HANGUP, midstate = CS_DONE, endstate;
+	const switch_endpoint_interface_t *endpoint_interface;
+	const switch_state_handler_table_t *driver_state_handler = NULL;
+	const switch_state_handler_table_t *application_state_handler = NULL;
+#ifdef CRASH_PROT
+	switch_thread_id_t thread_id = switch_thread_self();
+	jmp_buf env;
+	int sig;
+
+	signal(SIGSEGV, (void *) handle_fatality);
+	signal(SIGFPE, (void *) handle_fatality);
+#ifndef WIN32
+	signal(SIGBUS, (void *) handle_fatality);
+#endif
+
+	if ((sig = setjmp(env)) != 0) {
+		switch_event_t *event;
+
+		if (switch_event_create(&event, SWITCH_EVENT_SESSION_CRASH) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(session->channel, event);
+			switch_event_fire(&event);
+		}
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Thread has crashed for channel %s\n", switch_channel_get_name(session->channel));
+		switch_channel_hangup(session->channel, SWITCH_CAUSE_CRASH);
+	} else {
+		apr_hash_set(runtime.stack_table, &thread_id, sizeof(thread_id), &env);
+	}
+#endif
 	/*
 	   Life of the channel. you have channel and pool in your session
 	   everywhere you go you use the session to malloc with
@@ -1833,26 +2620,19 @@
 	switch_mutex_lock(session->mutex);
 
 	while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
-		switch_event *event;
-
 		if (state != laststate) {
 			int index = 0;
 			int proceed = 1;
 			midstate = state;
 
-			if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
-				switch_channel_event_set_data(session->channel, event);
-				switch_event_fire(&event);
-			}
-
 			switch (state) {
 			case CS_NEW:		/* Just created, Waiting for first instructions */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State NEW\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State NEW\n", switch_channel_get_name(session->channel));
 				break;
 			case CS_DONE:
-				continue;
+				goto done;
 			case CS_HANGUP:	/* Deactivate and end the thread */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State HANGUP\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State HANGUP\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_hangup ||
 					(driver_state_handler->on_hangup &&
 					 driver_state_handler->on_hangup(session) == SWITCH_STATUS_SUCCESS &&
@@ -1887,11 +2667,10 @@
 						switch_core_standard_on_hangup(session);
 					}
 				}
-				switch_channel_set_state(session->channel, CS_DONE);
-				midstate = switch_channel_get_state(session->channel);
+				goto done;
 				break;
 			case CS_INIT:		/* Basic setup tasks */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State INIT\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State INIT\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_init ||
 					(driver_state_handler->on_init &&
 					 driver_state_handler->on_init(session) == SWITCH_STATUS_SUCCESS &&
@@ -1927,7 +2706,7 @@
 				}
 				break;
 			case CS_RING:		/* Look for a dialplan and find something to do */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State RING\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State RING\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_ring ||
 					(driver_state_handler->on_ring &&
 					 driver_state_handler->on_ring(session) == SWITCH_STATUS_SUCCESS &&
@@ -1963,7 +2742,7 @@
 				}
 				break;
 			case CS_EXECUTE:	/* Execute an Operation */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State EXECUTE\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State EXECUTE\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_execute ||
 					(driver_state_handler->on_execute &&
 					 driver_state_handler->on_execute(session) == SWITCH_STATUS_SUCCESS &&
@@ -1999,7 +2778,7 @@
 				}
 				break;
 			case CS_LOOPBACK:	/* loop all data back to source */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State LOOPBACK\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State LOOPBACK\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_loopback ||
 					(driver_state_handler->on_loopback &&
 					 driver_state_handler->on_loopback(session) == SWITCH_STATUS_SUCCESS &&
@@ -2035,7 +2814,7 @@
 				}
 				break;
 			case CS_TRANSMIT:	/* send/recieve data to/from another channel */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "(%s) State TRANSMIT\n", switch_channel_get_name(session->channel));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State TRANSMIT\n", switch_channel_get_name(session->channel));
 				if (!driver_state_handler->on_transmit ||
 					(driver_state_handler->on_transmit &&
 					 driver_state_handler->on_transmit(session) == SWITCH_STATUS_SUCCESS &&
@@ -2071,6 +2850,43 @@
 					}
 				}
 				break;
+			case CS_HOLD:	/* wait in limbo */
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State HOLD\n", switch_channel_get_name(session->channel));
+				if (!driver_state_handler->on_hold ||
+					(driver_state_handler->on_hold &&
+					 driver_state_handler->on_hold(session) == SWITCH_STATUS_SUCCESS &&
+					 midstate == switch_channel_get_state(session->channel))) {
+
+					while((application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) {
+						if (!application_state_handler || !application_state_handler->on_hold ||
+							(application_state_handler->on_hold &&
+							 application_state_handler->on_hold(session) == SWITCH_STATUS_SUCCESS &&
+							 midstate == switch_channel_get_state(session->channel))) {
+							proceed++;
+							continue;
+						} else {
+							proceed = 0;
+							break;
+						}
+					}
+					index = 0;
+					while(proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) {
+						if (!application_state_handler || !application_state_handler->on_hold ||
+							(application_state_handler->on_hold &&
+							 application_state_handler->on_hold(session) == SWITCH_STATUS_SUCCESS &&
+							 midstate == switch_channel_get_state(session->channel))) {
+							proceed++;
+							continue;
+						} else {
+							proceed = 0;
+							break;
+						}
+					}
+					if (proceed) {
+						switch_core_standard_on_hold(session);
+					}
+				}
+				break;
 			}
 
 			if (midstate == CS_DONE) {
@@ -2080,26 +2896,55 @@
 			laststate = midstate;
 		}
 		
-		if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
+
+		endstate = switch_channel_get_state(session->channel);
+
+
+		if (midstate == endstate) {
 			switch_thread_cond_wait(session->cond, session->mutex);
-		} 
+		}
+
 	}
+ done:
+	switch_mutex_unlock(session->mutex);
 
+#ifdef CRASH_PROT
+	apr_hash_set(runtime.stack_table, &thread_id, sizeof(thread_id), NULL);
+#endif
 	session->thread_running = 0;
+
 }
 
-SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
+SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session_t **session)
 {
-	switch_memory_pool *pool;
+	switch_memory_pool_t *pool;
+	switch_event_t *event;
 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Close Channel %s\n", switch_channel_get_name((*session)->channel));
+
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data((*session)->channel, event);
+		switch_event_fire(&event);
+	}
+
+	switch_core_media_bug_remove_all(*session);
+	switch_buffer_destroy(&(*session)->raw_read_buffer);
+	switch_buffer_destroy(&(*session)->raw_write_buffer);
+	switch_channel_uninit((*session)->channel);
+
 	pool = (*session)->pool;
 	*session = NULL;
 	apr_pool_destroy(pool);
 	pool = NULL;
 
+	switch_mutex_lock(runtime.session_table_mutex);
+	if (runtime.session_count) {
+		runtime.session_count--;
+	}
+	switch_mutex_unlock(runtime.session_table_mutex);
 }
 
-SWITCH_DECLARE(switch_status) switch_core_hash_init(switch_hash **hash, switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t **hash, switch_memory_pool_t *pool)
 {
 	assert(pool != NULL);
 
@@ -2110,31 +2955,31 @@
 	return SWITCH_STATUS_GENERR;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_hash_destroy(switch_hash *hash)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t *hash)
 {
 	assert(hash != NULL);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_hash_insert_dup(switch_hash *hash, char *key, void *data)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_dup(switch_hash_t *hash, char *key, void *data)
 {
 	apr_hash_set(hash, switch_core_strdup(apr_hash_pool_get(hash), key), APR_HASH_KEY_STRING, data);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_hash_insert(switch_hash *hash, char *key, void *data)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_insert(switch_hash_t *hash, char *key, void *data)
 {
 	apr_hash_set(hash, key, APR_HASH_KEY_STRING, data);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_core_hash_delete(switch_hash *hash, char *key)
+SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(switch_hash_t *hash, char *key)
 {
 	apr_hash_set(hash, key, APR_HASH_KEY_STRING, NULL);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash *hash, char *key)
+SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, char *key)
 {
 	return apr_hash_get(hash, key, APR_HASH_KEY_STRING);
 }
@@ -2153,11 +2998,11 @@
 
 */
 
-SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void *obj, switch_memory_pool *pool)
+SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void *obj, switch_memory_pool_t *pool)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-	switch_core_thread_session *ts;
+	switch_core_thread_session_t *ts;
 	int mypool;
 
 	mypool = pool ? 0 : 1;
@@ -2183,26 +3028,34 @@
 
 }
 
-static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread *thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)
 {
-	switch_core_session *session = obj;
+	switch_core_session_t *session = obj;
 	session->thread = thread;
-	session->id = runtime.session_id++;
-
 	snprintf(session->name, sizeof(session->name), "%u", session->id);
-
+	switch_mutex_lock(runtime.session_table_mutex);
+	session->id = runtime.session_id++;
 	switch_core_hash_insert(runtime.session_table, session->uuid_str, session);
+	switch_mutex_unlock(runtime.session_table_mutex);
+
 	switch_core_session_run(session);
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session %u (%s) Locked, Waiting on external entities\n", session->id, switch_channel_get_name(session->channel));
+	switch_core_session_write_lock(session);
+	switch_core_session_rwunlock(session);
+
+	switch_mutex_lock(runtime.session_table_mutex);
 	switch_core_hash_delete(runtime.session_table, session->uuid_str);
+	switch_mutex_unlock(runtime.session_table_mutex);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Session %u (%s) Ended\n", session->id, switch_channel_get_name(session->channel));
 	switch_core_session_destroy(&session);
 	return NULL;
 }
 
 
-SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *session)
+SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session_t *session)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr;;
 	switch_threadattr_create(&thd_attr, session->pool);
 	switch_threadattr_detach_set(thd_attr, 1);
@@ -2215,10 +3068,11 @@
 	}
 }
 
-SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, switch_thread_start_t func,
+
+SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, switch_thread_start_t func,
 													   void *obj)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
 	switch_threadattr_create(&thd_attr, session->pool);
 	switch_threadattr_detach_set(thd_attr, 1);
@@ -2229,7 +3083,7 @@
 }
 
 
-SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool *pool, switch_size_t memory)
+SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool_t *pool, switch_size_t memory)
 {
 	void *ptr = NULL;
 	assert(pool != NULL);
@@ -2245,15 +3099,30 @@
 	return ptr;
 }
 
-SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface,
-																  switch_memory_pool *pool)
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t *endpoint_interface,
+																  switch_memory_pool_t *pool)
 {
-	switch_memory_pool *usepool;
-	switch_core_session *session;
+	switch_memory_pool_t *usepool;
+	switch_core_session_t *session;
 	switch_uuid_t uuid;
+	uint32_t count = 0;
 
 	assert(endpoint_interface != NULL);
 
+	switch_mutex_lock(runtime.session_table_mutex);
+	count = runtime.session_count;
+	switch_mutex_unlock(runtime.session_table_mutex);
+
+	if ((count + 1) > runtime.session_limit) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Limit!\n");
+		return NULL;
+	}
+
+	if (runtime.no_new_sessions || runtime.shutting_down) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read my lips: no new sessions!\n");
+		return NULL;
+	}
+
 	if (pool) {
 		usepool = pool;
 	} else if (switch_core_new_memory_pool(&usepool) != SWITCH_STATUS_SUCCESS) {
@@ -2261,7 +3130,7 @@
 		return NULL;
 	}
 
-	if ((session = switch_core_alloc(usepool, sizeof(switch_core_session))) == 0) {
+	if ((session = switch_core_alloc(usepool, sizeof(switch_core_session_t))) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate session\n");
 		apr_pool_destroy(usepool);
 		return NULL;
@@ -2296,15 +3165,25 @@
 	session->enc_read_frame.buflen = sizeof(session->enc_read_buf);
 
 	switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
 	switch_thread_cond_create(&session->cond, session->pool);
+	switch_thread_rwlock_create(&session->rwlock, session->pool);
 
+	switch_mutex_lock(runtime.session_table_mutex);
+	runtime.session_count++;
+	switch_mutex_unlock(runtime.session_table_mutex);
 	return session;
 }
 
-SWITCH_DECLARE(switch_core_session *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool *pool)
+SWITCH_DECLARE(uint32_t) switch_core_session_count(void)
 {
-	const switch_endpoint_interface *endpoint_interface;
+	return runtime.session_count;
+}
 
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t *pool)
+{
+	const switch_endpoint_interface_t *endpoint_interface;
+
 	if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name);
 		return NULL;
@@ -2313,188 +3192,422 @@
 	return switch_core_session_request(endpoint_interface, pool);
 }
 
-
-static void core_event_handler(switch_event *event)
+SWITCH_DECLARE(switch_status_t) switch_core_db_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries)
 {
-	char buf[1024];
-	char *sql = NULL;
 	char *errmsg;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	uint8_t forever = 0;
 
+	if (!retries) {
+		forever = 1;
+		retries = 1000;
+	}
+
+	while(retries > 0) {
+		switch_core_db_exec(
+							db,
+							sql,
+							NULL,
+							NULL,
+							&errmsg
+							);		
+		if (errmsg) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
+			switch_core_db_free(errmsg);
+			switch_yield(100000);
+			retries--;
+			if (retries == 0 && forever) {
+				retries = 1000;
+				continue;
+			}
+		} else {
+			status = SWITCH_STATUS_SUCCESS;
+			break;
+		}
+	}
+
+	return status;
+}
+
+#ifdef DO_EVENTS
+#define SQLLEN 1024 * 64
+static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, void *obj)
+{
+	void *pop;
+	uint32_t itterations = 0;
+	uint8_t trans = 0, nothing_in_queue = 0;
+	uint32_t freq = 1000, target = 1000;
+	uint32_t len = 0;
+	uint32_t sql_len = SQLLEN;
+	char *sqlbuf = (char *) malloc(sql_len);
+	
 	if (!runtime.event_db) {
 		runtime.event_db = switch_core_db_handle();
 	}
+	switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
 
+	for(;;) {
+		if (switch_queue_trypop(runtime.sql_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+			char *sql = (char *) pop;
+			uint32_t newlen;
+
+			if (sql) {
+				if (itterations == 0) {
+					char *isql = "begin transaction CORE1;\n";
+					switch_core_db_persistant_execute(runtime.event_db, isql, 0);
+					trans = 1;
+					
+				}
+
+				itterations++;
+				newlen = (uint32_t)strlen(sql) + 2;
+				if (len + newlen > sql_len) {
+					sql_len = len + SQLLEN;
+					if (!(sqlbuf = realloc(sqlbuf, sql_len))) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread ending on mem err\n");
+						break;
+					}
+				}
+				snprintf(sqlbuf + len, sql_len - len, "%s;\n", sql); 
+				len += newlen;
+				switch_core_db_free(sql);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "SQL thread ending\n");
+				break;
+			}
+		} else {
+			nothing_in_queue = 1;
+		}
+
+
+		if (trans && ((itterations == target) || nothing_in_queue)) {
+			char *isql = "end transaction CORE1";
+
+			switch_core_db_persistant_execute(runtime.event_db, sqlbuf, 0);
+			switch_core_db_persistant_execute(runtime.event_db, isql, 0);
+			itterations = 0;
+			trans = 0;
+			nothing_in_queue = 0;
+			len = 0;
+			*sqlbuf = '\0';
+		}
+		
+		if (nothing_in_queue) {
+			switch_yield(freq);
+		} 
+	}
+
+
+	free(sqlbuf);
+	return NULL;
+}
+
+
+static void switch_core_sql_thread_launch(void)
+{
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr;;
+	
+	assert(runtime.memory_pool != NULL);
+
+	switch_threadattr_create(&thd_attr, runtime.memory_pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, switch_core_sql_thread, NULL, runtime.memory_pool);
+	
+}
+
+static void core_event_handler(switch_event_t *event)
+{
+	char *sql = NULL;
+
 	switch (event->event_id) {
+	case SWITCH_EVENT_CHANNEL_DESTROY:
+		sql = switch_core_db_mprintf("delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
+		break;
 	case SWITCH_EVENT_CHANNEL_CREATE:
-		snprintf(buf, sizeof(buf), "insert into channels (uuid,created,name,state) values('%s','%s','%s','%s')",
-				 switch_event_get_header(event, "unique-id"),
-				 switch_event_get_header(event, "event-date-local"),
-				 switch_event_get_header(event, "channel-name"),
-				 switch_event_get_header(event, "channel-state")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("insert into channels (uuid,created,name,state) values('%q','%q','%q','%q')",
+									 switch_event_get_header(event, "unique-id"),
+									 switch_event_get_header(event, "event-date-local"),
+									 switch_event_get_header(event, "channel-name"),
+									 switch_event_get_header(event, "channel-state")
+									 );
 		break;
+	case SWITCH_EVENT_CODEC:
+		sql = switch_core_db_mprintf("update channels set read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q'",
+									 switch_event_get_header(event, "channel-read-codec-name"),
+									 switch_event_get_header(event, "channel-read-codec-rate"),
+									 switch_event_get_header(event, "channel-write-codec-name"),
+									 switch_event_get_header(event, "channel-write-codec-rate"),
+									 switch_event_get_header(event, "unique-id"));
+		break;
 	case SWITCH_EVENT_CHANNEL_EXECUTE:
-		snprintf(buf, sizeof(buf), "update channels set application='%s',application_data='%s' where uuid='%s'",
-				 switch_event_get_header(event, "application"),
-				 switch_event_get_header(event, "application-data"),
-				 switch_event_get_header(event, "unique-id")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q' where uuid='%q'",
+									 switch_event_get_header(event, "application"),
+									 switch_event_get_header(event, "application-data"),
+									 switch_event_get_header(event, "unique-id")
+									 );
 		break;
 	case SWITCH_EVENT_CHANNEL_STATE:
 		if (event) {
 			char *state = switch_event_get_header(event, "channel-state-number");
-			switch_channel_state state_i = atoi(state);
+			switch_channel_state_t state_i = atoi(state);
 
 			switch(state_i) {
 			case CS_HANGUP:
-				snprintf(buf, sizeof(buf), "delete from channels where uuid='%s'", switch_event_get_header(event, "unique-id"));
-				sql = buf;
+			case CS_DONE:
 				break;
 			case CS_RING:
-				snprintf(buf, sizeof(buf), "update channels set state='%s',cid_name='%s',cid_num='%s',ip_addr='%s',dest='%s'"
-						 "where uuid='%s'",
-						 switch_event_get_header(event, "channel-state"),
-						 switch_event_get_header(event, "caller-caller-id-name"),
-						 switch_event_get_header(event, "caller-caller-id-number"),
-						 switch_event_get_header(event, "caller-network-addr"),
-						 switch_event_get_header(event, "caller-destination-number"),
-						 switch_event_get_header(event, "unique-id")
-						 );
-				sql = buf;
+				sql = switch_core_db_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',ip_addr='%s',dest='%q'"
+											 "where uuid='%s'",
+											 switch_event_get_header(event, "channel-state"),
+											 switch_event_get_header(event, "caller-caller-id-name"),
+											 switch_event_get_header(event, "caller-caller-id-number"),
+											 switch_event_get_header(event, "caller-network-addr"),
+											 switch_event_get_header(event, "caller-destination-number"),
+											 switch_event_get_header(event, "unique-id")
+											 );
 				break;
 			default:
-				snprintf(buf, sizeof(buf), "update channels set state='%s' where uuid='%s'", 
-						 switch_event_get_header(event, "channel-state"),
-						 switch_event_get_header(event, "unique-id")
-						 );
-				sql = buf;
+				sql = switch_core_db_mprintf("update channels set state='%s' where uuid='%s'", 
+											 switch_event_get_header(event, "channel-state"),
+											 switch_event_get_header(event, "unique-id")
+											 );
 				break;
 			}
 		
 		}
 		break;
 	case SWITCH_EVENT_CHANNEL_BRIDGE:
-		snprintf(buf, sizeof(buf), "insert into calls values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
-				 switch_event_get_header(event, "event-calling-function"),
-				 switch_event_get_header(event, "caller-caller-id-name"),
-				 switch_event_get_header(event, "caller-caller-id-number"),
-				 switch_event_get_header(event, "caller-destination-number"),
-				 switch_event_get_header(event, "caller-channel-name"),
-				 switch_event_get_header(event, "caller-unique-id"),
-				 switch_event_get_header(event, "originatee-caller-id-name"),
-				 switch_event_get_header(event, "originatee-caller-id-number"),
-				 switch_event_get_header(event, "originatee-destination-number"),
-				 switch_event_get_header(event, "originatee-channel-name"),
-				 switch_event_get_header(event, "originatee-unique-id")
-				 );
-		sql = buf;
+		sql = switch_core_db_mprintf("insert into calls values ('%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s')",
+									 switch_event_get_header(event, "event-calling-function"),
+									 switch_event_get_header(event, "caller-caller-id-name"),
+									 switch_event_get_header(event, "caller-caller-id-number"),
+									 switch_event_get_header(event, "caller-destination-number"),
+									 switch_event_get_header(event, "caller-channel-name"),
+									 switch_event_get_header(event, "caller-unique-id"),
+									 switch_event_get_header(event, "originatee-caller-id-name"),
+									 switch_event_get_header(event, "originatee-caller-id-number"),
+									 switch_event_get_header(event, "originatee-destination-number"),
+									 switch_event_get_header(event, "originatee-channel-name"),
+									 switch_event_get_header(event, "originatee-unique-id")
+									 );
 		break;
 	case SWITCH_EVENT_CHANNEL_UNBRIDGE:
-		snprintf(buf, sizeof(buf), "delete from calls where caller_uuid='%s'", switch_event_get_header(event, "caller-unique-id"));
-		sql = buf;
+		sql = switch_core_db_mprintf("delete from calls where caller_uuid='%s'", switch_event_get_header(event, "caller-unique-id"));
 		break;
 	case SWITCH_EVENT_SHUTDOWN:
-		snprintf(buf, sizeof(buf), "delete from channels");
-		sql = buf;
+		sql = switch_core_db_mprintf("delete from channels;delete from interfaces;delete from calls");
 		break;
 	case SWITCH_EVENT_LOG:
 		return;
+	case SWITCH_EVENT_MODULE_LOAD:
+		sql = switch_core_db_mprintf("insert into interfaces (type,name) values('%q','%q')",
+									 switch_event_get_header(event, "type"),
+									 switch_event_get_header(event, "name")
+									 );
+		break;
 	default:
 		//buf[0] = '\0';
 		//switch_event_serialize(event, buf, sizeof(buf), NULL);
-		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nCORE EVENT\n--------------------------------\n%s\n", buf);
+		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nCORE EVENT\n--------------------------------\n%s\n", buf);
 		break;
 	}
 
-
-
 	if (sql) {
-		uint8_t max = 25;
-		while(max > 0) {
-			switch_core_db_exec(
-								runtime.event_db,
-								sql,
-								NULL,
-								NULL,
-								&errmsg
-								);		
-			if (errmsg) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
-				switch_core_db_free(errmsg);
-				switch_yield(100000);
-				max--;
-			} else {
-				break;
-			}
-		}
+		switch_queue_push(runtime.sql_queue, sql);
+		sql = NULL;
 	}
 }
+#endif
 
 SWITCH_DECLARE(void) switch_core_set_globals(void)
 {
 #ifdef WIN32
-#define BUFSIZE 50
+#define BUFSIZE 1024
     char lpPathBuffer[BUFSIZE];
 	DWORD dwBufSize=BUFSIZE;
-#endif
+	char exePath[1024];
+	char *lastbacklash;
+	GetModuleFileName( NULL, exePath, BUFSIZE );
+	lastbacklash = strrchr( exePath, '\\');
+	exePath[(lastbacklash - exePath + 1)] = '\0';
+	if (!SWITCH_GLOBAL_dirs.base_dir && (SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.base_dir, BUFSIZE, "%s", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.mod_dir && (SWITCH_GLOBAL_dirs.mod_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, "%smod", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.conf_dir && (SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, "%sconf", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.log_dir && (SWITCH_GLOBAL_dirs.log_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, "%slog", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.db_dir && (SWITCH_GLOBAL_dirs.db_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, "%sdb", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.script_dir && (SWITCH_GLOBAL_dirs.script_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, "%sscripts", exePath);
+	}
+	if (!SWITCH_GLOBAL_dirs.htdocs_dir && (SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, "%shtdocs", exePath);
+	}
+#else
 	SWITCH_GLOBAL_dirs.base_dir = SWITCH_PREFIX_DIR;
 	SWITCH_GLOBAL_dirs.mod_dir = SWITCH_MOD_DIR;
 	SWITCH_GLOBAL_dirs.conf_dir = SWITCH_CONF_DIR;
 	SWITCH_GLOBAL_dirs.log_dir = SWITCH_LOG_DIR;
 	SWITCH_GLOBAL_dirs.db_dir = SWITCH_DB_DIR;
 	SWITCH_GLOBAL_dirs.script_dir = SWITCH_SCRIPT_DIR;
+	SWITCH_GLOBAL_dirs.htdocs_dir = SWITCH_HTDOCS_DIR;
+#endif
 #ifdef SWITCH_TEMP_DIR
 	SWITCH_GLOBAL_dirs.temp_dir = SWITCH_TEMP_DIR;
 #else
 #ifdef WIN32
 	GetTempPath(dwBufSize, lpPathBuffer);
-	SWITCH_GLOBAL_dirs.temp_dir = lpPathBuffer;
+	if (!SWITCH_GLOBAL_dirs.htdocs_dir && (SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(BUFSIZE))) {
+		snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, "%s", lpPathBuffer);
+	}
 #else
 	SWITCH_GLOBAL_dirs.temp_dir = "/tmp/";
 #endif
 #endif
 }
 
-SWITCH_DECLARE(switch_status) switch_core_init(char *console)
+
+SWITCH_DECLARE(uint32_t) switch_core_session_limit(uint32_t new_limit)
 {
+	if (new_limit) {
+		runtime.session_limit = new_limit;
+	}
+	
+	return runtime.session_limit;
+}
 
+
+SWITCH_DECLARE(int32_t) set_high_priority(void)
+{
+#ifdef __linux__
+	struct sched_param sched = {0};
+	sched.sched_priority = 1;
+	if (sched_setscheduler(0, SCHED_RR, &sched)) {
+        sched.sched_priority = 0;
+        if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
+			return -1;
+		}
+	}
+#endif
+
+#ifdef WIN32
+	SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+#else
+	nice(-10);
+#endif
+
+#define USE_MLOCKALL
+#ifdef HAVE_MLOCKALL
+#ifdef USE_MLOCKALL
+	mlockall(MCL_CURRENT|MCL_FUTURE);
+#endif
+#endif
+	return 0;
+}
+
+SWITCH_DECLARE(void) switch_core_runtime_loop(int bg)
+{
+#ifdef WIN32
+	HANDLE shutdown_event;
+	char path[256] = "";
+#endif
+	if (bg) {
+		bg = 0;
+#ifdef WIN32
+		snprintf(path, sizeof(path), "Global\\Freeswitch.%d", getpid());
+		shutdown_event = CreateEvent(NULL, FALSE, FALSE, path);		
+		WaitForSingleObject(shutdown_event, INFINITE);
+#else
+		runtime.running = 1;
+		while(runtime.running) {
+			switch_yield(1000000);
+		}
+#endif
+	}  else {
+		/* wait for console input */
+		switch_console_loop();
+	}
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err)
+{
+	switch_xml_t xml = NULL, cfg = NULL;
 	memset(&runtime, 0, sizeof(runtime));
-	
+	runtime.session_limit = 1000;
+
 	switch_core_set_globals();
 
 	/* INIT APR and Create the pool context */
 	if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
 		apr_terminate();
+		*err = "FATAL ERROR! Could not initilize APR\n";
 		return SWITCH_STATUS_MEMERR;
 	}
 
-	
 	if (apr_pool_create(&runtime.memory_pool, NULL) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not allocate memory pool\n");
-		switch_core_destroy();
+		apr_terminate();
+		*err = "FATAL ERROR! Could not allocate memory pool\n";
 		return SWITCH_STATUS_MEMERR;
 	}
-	assert(runtime.memory_pool != NULL);
-	switch_log_init(runtime.memory_pool);
 
+	if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
+		apr_terminate();
+		return SWITCH_STATUS_MEMERR;
+	}
+
+
+	if ((xml = switch_xml_open_cfg("switch.conf", &cfg, NULL))) {
+		switch_xml_t settings, param;
+		
+		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, "max-sessions")) {
+					runtime.session_limit = atoi(val);
+				}
+			}
+		}
+		switch_xml_free(xml);
+	}
+
+	*err = NULL;
+
 	if(console) {
 		if (*console != '/') {
 			char path[265];
 			snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, console);
 			console = path;
 		}
-		switch_core_set_console(console);
+		if (switch_core_set_console(console) != SWITCH_STATUS_SUCCESS) {
+			*err = "FATAL ERROR! Could not open console\n";
+			apr_terminate();
+			return SWITCH_STATUS_GENERR;
+		}
 	} else {
 		runtime.console = stdout;
 	}
 
+	assert(runtime.memory_pool != NULL);
+	switch_log_init(runtime.memory_pool);
 
+#ifdef DO_EVENTS
+	switch_core_sql_thread_launch();
+#endif
 
-
-
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated memory pool. Sessions are %u bytes\n", sizeof(struct switch_core_session));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated memory pool. Sessions are %u bytes\n", sizeof(switch_core_session_t));
 	switch_event_init(runtime.memory_pool);
 	switch_rtp_init(runtime.memory_pool);
 
@@ -2513,7 +3626,11 @@
 			"   ip_addr  VARCHAR(255),\n"
 			"   dest  VARCHAR(255),\n"
 			"   application  VARCHAR(255),\n"
-			"   application_data  VARCHAR(255)\n"
+			"   application_data  VARCHAR(255),\n"
+			"   read_codec  VARCHAR(255),\n"
+			"   read_rate  VARCHAR(255),\n"
+			"   write_codec  VARCHAR(255),\n"
+			"   write_rate  VARCHAR(255)\n"
 			");\n";
 		char create_calls_sql[] =
 			"CREATE TABLE calls (\n"
@@ -2529,47 +3646,191 @@
 			"   callee_chan_name VARCHAR(255),\n"
 			"   callee_uuid      VARCHAR(255)\n"
 			");\n";
+		char create_interfaces_sql[] =
+			"CREATE TABLE interfaces (\n"
+			"   type             VARCHAR(255),\n"
+			"   name             VARCHAR(255)\n"
+			");\n";
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening DB\n");
 		switch_core_db_exec(runtime.db, "drop table channels", NULL, NULL, NULL);
 		switch_core_db_exec(runtime.db, "drop table calls", NULL, NULL, NULL);
+		switch_core_db_exec(runtime.db, "drop table interfaces", NULL, NULL, NULL);
 		switch_core_db_exec(runtime.db, create_channels_sql, NULL, NULL, NULL);
 		switch_core_db_exec(runtime.db, create_calls_sql, NULL, NULL, NULL);
-		
+		switch_core_db_exec(runtime.db, create_interfaces_sql, NULL, NULL, NULL);
+#ifdef DO_EVENTS		
 		if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) !=
 			SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n");
 		}
+#endif
 	}
 
 	runtime.session_id = 1;
-
+	runtime.running = 1;
 	switch_core_hash_init(&runtime.session_table, runtime.memory_pool);
+	switch_mutex_init(&runtime.session_table_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+#ifdef CRASH_PROT
+	switch_core_hash_init(&runtime.stack_table, runtime.memory_pool);
+#endif
+	runtime.initiated = switch_time_now();
+	return SWITCH_STATUS_SUCCESS;
+}
+#ifdef SIGPIPE
+static int handle_SIGPIPE(int sig)
+{
+	if(sig);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Sig Pipe!\n");
+	return 0;
+}
+#endif
+#ifdef TRAP_BUS
+static int handle_SIGBUS(int sig)
+{
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Sig BUS!\n");
+	return 0;
+}
+#endif
 
-	time(&runtime.initiated);
+/* no ctl-c mofo */
+static int handle_SIGINT(int sig)
+{
+	if (sig);
+	return 0;
+}
+SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(char *console, const char **err)
+{
+	switch_event_t *event;
+	if (switch_core_init(console, err) != SWITCH_STATUS_SUCCESS) {
+		return SWITCH_STATUS_GENERR;
+	}
+
+	/* set signal handlers */
+	signal(SIGINT, (void *) handle_SIGINT);
+#ifdef SIGPIPE
+	signal(SIGPIPE, (void *) handle_SIGPIPE);
+#endif
+#ifdef TRAP_BUS
+	signal(SIGBUS, (void *) handle_SIGBUS);
+#endif
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
+	if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
+		*err = "Cannot load modules";
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error: %s", err);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (switch_event_create(&event, SWITCH_EVENT_STARTUP) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready");
+		switch_event_fire(&event);
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\n\n", SWITCH_VERSION_FULL, __CP, switch_core_session_limit(0));
 	return SWITCH_STATUS_SUCCESS;
+
 }
 
+SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
+{
+    switch_time_t temp = total_ms / 1000;
+	memset(duration, 0, sizeof(*duration));
+	duration->mms = (uint32_t)(total_ms % 1000);
+	duration->ms = (uint32_t)(temp % 1000);
+    temp = temp / 1000;
+    duration->sec = (uint32_t)(temp % 60);
+    temp = temp / 60;
+    duration->min = (uint32_t)(temp % 60);
+	temp = temp / 60;
+	duration->hr = (uint32_t)(temp % 24);
+	temp = temp / 24;
+	duration->day = (uint32_t)(temp % 365);
+	duration->yr = (uint32_t)(temp / 365);
+}
 
-SWITCH_DECLARE(switch_status) switch_core_destroy(void)
+SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
 {
+	return switch_time_now() - runtime.initiated;
+}
 
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t *val)
+{
+
+	if (runtime.shutting_down) {
+		return -1;
+	}
+
+	switch (cmd) {
+	case SCSC_PAUSE_INBOUND:
+		runtime.no_new_sessions = *val;
+		break;
+	case SCSC_HUPALL:
+		switch_core_session_hupall(SWITCH_CAUSE_MANAGER_REQUEST);
+		break;
+	case SCSC_SHUTDOWN:
+		runtime.running = 0;
+		break;
+	case SCSC_CHECK_RUNNING:
+		*val = runtime.running;
+		break;
+	}
+
+	return 0;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
+{
+	switch_event_t *event;
+	if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) {
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Shutting Down");
+		switch_event_fire(&event);
+	}
+	runtime.shutting_down = 1;
+	runtime.no_new_sessions = 1;
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n");
+	switch_core_session_hupall(SWITCH_CAUSE_SYSTEM_SHUTDOWN);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n");
+	switch_loadable_module_shutdown();
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
 	switch_event_shutdown();
-	switch_log_shutdown();
+	
+	switch_queue_push(runtime.sql_queue, NULL);
 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
+	while (switch_queue_size(runtime.sql_queue) > 0) {
+		switch_yield(10000);
+	}
 	switch_core_db_close(runtime.db);
+	switch_core_db_close(runtime.event_db);
+	switch_xml_destroy();
 
-	if (runtime.memory_pool) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unallocating memory pool.\n");
-		apr_pool_destroy(runtime.memory_pool);
-		apr_terminate();
-	}
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n");
+	switch_log_shutdown();
 	
 	if(runtime.console != stdout && runtime.console != stderr) {
 		fclose(runtime.console);
 		runtime.console = NULL;
 	}
+
+	if (runtime.memory_pool) {
+		apr_pool_destroy(runtime.memory_pool);
+		apr_terminate();
+	}
+
+#ifdef WIN32
+	free(SWITCH_GLOBAL_dirs.base_dir);
+	free(SWITCH_GLOBAL_dirs.mod_dir);
+	free(SWITCH_GLOBAL_dirs.conf_dir);
+	free(SWITCH_GLOBAL_dirs.log_dir);
+	free(SWITCH_GLOBAL_dirs.db_dir);
+	free(SWITCH_GLOBAL_dirs.script_dir);
+	free(SWITCH_GLOBAL_dirs.htdocs_dir);
+	free(SWITCH_GLOBAL_dirs.temp_dir);
+#endif
 
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/branches/voctel/src/switch_event.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_event.c	(original)
+++ freeswitch/branches/voctel/src/switch_event.c	Fri Sep 22 14:22:15 2006
@@ -24,25 +24,32 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Michael Jerris <mike at jerris.com>
+ * Paul D. Tinsley <pdt at jackhammer.org>
  *
  *
  * switch_event.c -- Event System
  *
  */
+#include <switch.h>
 #include <switch_event.h>
 
-static switch_event_node *EVENT_NODES[SWITCH_EVENT_ALL + 1] = { NULL };
+static switch_event_node_t *EVENT_NODES[SWITCH_EVENT_ALL + 1] = { NULL };
 static switch_mutex_t *BLOCK = NULL;
 static switch_mutex_t *POOL_LOCK = NULL;
-static switch_memory_pool *RUNTIME_POOL = NULL;
-//static switch_memory_pool *APOOL = NULL;
-//static switch_memory_pool *BPOOL = NULL;
-static switch_memory_pool *THRUNTIME_POOL = NULL;
+static switch_mutex_t *EVENT_QUEUE_MUTEX = NULL;
+static switch_mutex_t *EVENT_QUEUE_HAVEMORE_MUTEX = NULL;
+static switch_thread_cond_t *EVENT_QUEUE_CONDITIONAL = NULL;
+static switch_memory_pool_t *RUNTIME_POOL = NULL;
+//static switch_memory_pool_t *APOOL = NULL;
+//static switch_memory_pool_t *BPOOL = NULL;
+static switch_memory_pool_t *THRUNTIME_POOL = NULL;
 static switch_queue_t *EVENT_QUEUE[3] = {0,0,0};
-static int POOL_COUNT_MAX = 2000;
+static int POOL_COUNT_MAX = SWITCH_CORE_QUEUE_LEN;
 
-static switch_hash *CUSTOM_HASH = NULL;
+static switch_hash_t *CUSTOM_HASH = NULL;
 static int THREAD_RUNNING = 0;
+static int EVENT_QUEUE_HAVEMORE = 0;
 
 #if 0
 static void *locked_alloc(switch_size_t len)
@@ -75,22 +82,33 @@
 #define DUP(str) locked_dup(str)
 #endif
 
+#ifndef ALLOC
 #define ALLOC(size) malloc(size)
+#endif
+#ifndef DUP
 #define DUP(str) strdup(str)
+#endif
+#ifndef FREE
 #define FREE(ptr) if (ptr) free(ptr)
+#endif
 
-/* make sure this is synced with the switch_event_t enum in switch_types.h
+/* make sure this is synced with the switch_event_types_t enum in switch_types.h
 also never put any new ones before EVENT_ALL
 */
 static char *EVENT_NAMES[] = {
 	"CUSTOM",
 	"CHANNEL_CREATE",
+	"CHANNEL_DESTROY",
 	"CHANNEL_STATE",
 	"CHANNEL_ANSWER",
 	"CHANNEL_HANGUP",
 	"CHANNEL_EXECUTE",
 	"CHANNEL_BRIDGE",
 	"CHANNEL_UNBRIDGE",
+	"CHANNEL_PROGRESS",
+	"CHANNEL_OUTGOING",
+	"CHANNEL_PARK",
+	"CHANNEL_UNPARK",
 	"API",
 	"LOG",
 	"INBOUND_CHAN",
@@ -99,11 +117,19 @@
 	"SHUTDOWN",
 	"PUBLISH",
 	"UNPUBLISH",
+	"TALK",
+	"NOTALK",
+	"SESSION_CRASH",
+	"MODULE_LOAD",
+	"DTMF",
+	"MESSAGE",
+	"CODEC",
+	"BACKGROUND_JOB",
 	"ALL"
 };
 
 
-static int switch_events_match(switch_event *event, switch_event_node *node)
+static int switch_events_match(switch_event_t *event, switch_event_node_t *node)
 {
 	int match = 0;
 
@@ -142,9 +168,9 @@
 	return match;
 }
 
-static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread *thread, void *obj)
+static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t *thread, void *obj)
 {
-	switch_event *out_event = NULL;
+	switch_event_t *out_event = NULL;
 	switch_queue_t *queue = NULL;
 	switch_queue_t *queues[3] = {0,0,0};
 	void *pop;
@@ -154,27 +180,69 @@
 	assert(obj == NULL);
 	assert(POOL_LOCK != NULL);
 	assert(RUNTIME_POOL != NULL);
+	assert(EVENT_QUEUE_MUTEX != NULL);
+	assert(EVENT_QUEUE_HAVEMORE_MUTEX != NULL);
+	assert(EVENT_QUEUE_CONDITIONAL != NULL);
 	THREAD_RUNNING = 1;
 	
 	queues[0] = EVENT_QUEUE[SWITCH_PRIORITY_HIGH];
 	queues[1] = EVENT_QUEUE[SWITCH_PRIORITY_NORMAL];
 	queues[2] = EVENT_QUEUE[SWITCH_PRIORITY_LOW];
+
+	switch_mutex_lock(EVENT_QUEUE_MUTEX);
 	
 	for(;;) {
+		int any;
+
+
 		len[1] = switch_queue_size(EVENT_QUEUE[SWITCH_PRIORITY_NORMAL]);
 		len[2] = switch_queue_size(EVENT_QUEUE[SWITCH_PRIORITY_LOW]);
 		len[0] = switch_queue_size(EVENT_QUEUE[SWITCH_PRIORITY_HIGH]);
+		any = len[1] + len[2] + len[0];
 
-		if (THREAD_RUNNING != 1 && !len[0] && !len[1] && !len[2]) {
-			break;
+	
+		if (!any) {
+			//lock on havemore so we are the only ones poking at it while we check it
+			//see if we saw anything in the queues or have a check again flag
+			switch_mutex_lock(EVENT_QUEUE_HAVEMORE_MUTEX);
+			if(!EVENT_QUEUE_HAVEMORE) {
+				//See if we need to quit
+				if (THREAD_RUNNING != 1) {
+					//give up our lock
+					switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+
+					//Game over
+					break;
+				}
+
+				//give up our lock
+				switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+
+				//wait until someone tells us we have something to do
+				switch_thread_cond_wait(EVENT_QUEUE_CONDITIONAL, EVENT_QUEUE_MUTEX);
+			} else {
+				//Caught a race, one of the queues was updated after we looked at it
+				//reset our flag
+				EVENT_QUEUE_HAVEMORE = 0;
+
+				//Give up our lock
+				switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+			}
+
+			//go grab some events
+			continue;
 		}
 
 		for(i = 0; i < 3; i++) {
 			if (len[i]) {
 				queue = queues[i];
-				while (queue && switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS) {
-					out_event = pop;
-					switch_event_deliver(&out_event);
+				while(queue) {
+					if (switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS) {
+						out_event = pop;
+						switch_event_deliver(&out_event);
+					} else {
+						break;
+					}
 				}
 			}
 		}
@@ -182,16 +250,17 @@
 		if (THREAD_RUNNING < 0) {
 			THREAD_RUNNING--;
 		}
-		switch_yield(1000);
 	}
+
+
 	THREAD_RUNNING = 0;
 	return NULL;
 }
 
-SWITCH_DECLARE(void) switch_event_deliver(switch_event **event)
+SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event)
 {
-	switch_event_t e;
-	switch_event_node *node;
+	switch_event_types_t e;
+	switch_event_node_t *node;
 
 	for (e = (*event)->event_id;; e = SWITCH_EVENT_ALL) {
 		for (node = EVENT_NODES[e]; node; node = node->next) {
@@ -210,12 +279,12 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_event_running(void)
+SWITCH_DECLARE(switch_status_t) switch_event_running(void)
 {
 	return THREAD_RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(char *) switch_event_name(switch_event_t event)
+SWITCH_DECLARE(char *) switch_event_name(switch_event_types_t event)
 {
 	assert(BLOCK != NULL);
 	assert(RUNTIME_POOL != NULL);
@@ -223,11 +292,28 @@
 	return EVENT_NAMES[event];
 }
 
-SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner, char *subclass_name)
+SWITCH_DECLARE(switch_status_t) switch_name_event(char *name, switch_event_types_t *type)
 {
+	switch_event_types_t x;
+	assert(BLOCK != NULL);
+	assert(RUNTIME_POOL != NULL);
+	
+	for (x = 0; x <= SWITCH_EVENT_ALL; x++) {
+		if (!strcasecmp(name, EVENT_NAMES[x])) {
+			*type = x;
+			return SWITCH_STATUS_SUCCESS;
+		}
+	}
+	
+	return SWITCH_STATUS_FALSE;
 
-	switch_event_subclass *subclass;
+}
 
+SWITCH_DECLARE(switch_status_t) switch_event_reserve_subclass_detailed(char *owner, char *subclass_name)
+{
+
+	switch_event_subclass_t *subclass;
+
 	assert(RUNTIME_POOL != NULL);
 	assert(CUSTOM_HASH != NULL);
 
@@ -248,13 +334,34 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_event_shutdown(void)
+SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
 {
 	int x = 0, last = 0;
 
 	if (THREAD_RUNNING > 0) {
 		THREAD_RUNNING = -1;
 
+		//Lock on havemore to make sure he event thread, if currently running
+		// doesn't check the HAVEMORE flag before we set it
+		switch_mutex_lock(EVENT_QUEUE_HAVEMORE_MUTEX);
+		//See if the event thread is sitting
+		if(switch_mutex_trylock(EVENT_QUEUE_MUTEX) == SWITCH_STATUS_SUCCESS) {
+			//we don't need havemore anymore, the thread was sitting already
+			switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+
+			//wake up the event thread
+			switch_thread_cond_signal(EVENT_QUEUE_CONDITIONAL);
+
+			//give up our lock
+			switch_mutex_unlock(EVENT_QUEUE_MUTEX);
+		} else { // it wasn't waiting which means we might have updated a queue it already looked at
+			//set a flag so it knows to read the queues again
+			EVENT_QUEUE_HAVEMORE = 1;
+
+			//variable updated, give up the mutex
+			switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+		}
+
 		while (x < 100 && THREAD_RUNNING) {
 			switch_yield(1000);
 			if (THREAD_RUNNING == last) {
@@ -266,9 +373,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr;;
 	switch_threadattr_create(&thd_attr, pool);
 	switch_threadattr_detach_set(thd_attr, 1);
@@ -295,7 +402,11 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n");
 	switch_mutex_init(&BLOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
 	switch_mutex_init(&POOL_LOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
+	switch_mutex_init(&EVENT_QUEUE_MUTEX, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
+	switch_mutex_init(&EVENT_QUEUE_HAVEMORE_MUTEX, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
+	switch_thread_cond_create(&EVENT_QUEUE_CONDITIONAL, RUNTIME_POOL);
 	switch_core_hash_init(&CUSTOM_HASH, RUNTIME_POOL);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, switch_event_thread, NULL, RUNTIME_POOL);
 
 	while (!THREAD_RUNNING) {
@@ -305,8 +416,8 @@
 
 }
 
-SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event,
-														   switch_event_t event_id,
+SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event,
+														   switch_event_types_t event_id,
 														   char *subclass_name)
 {
 
@@ -314,30 +425,31 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if ((*event = ALLOC(sizeof(switch_event))) == 0) {
+	if ((*event = ALLOC(sizeof(switch_event_t))) == 0) {
 		return SWITCH_STATUS_MEMERR;
 	}
-	memset(*event, 0, sizeof(switch_event));
+	memset(*event, 0, sizeof(switch_event_t));
 
 	(*event)->event_id = event_id;
 
 	if (subclass_name) {
 		(*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
+		switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", subclass_name);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_set_priority(switch_event *event, switch_priority_t priority)
+SWITCH_DECLARE(switch_status_t) switch_event_set_priority(switch_event_t *event, switch_priority_t priority)
 {
 	event->priority = priority;
 	switch_event_add_header(event, SWITCH_STACK_TOP, "priority", switch_priority_name(priority));
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header_name)
+SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name)
 {
-	switch_event_header *hp;
+	switch_event_header_t *hp;
 	if (header_name) {
 		for (hp = event->headers; hp; hp = hp->next) {
 			if (!strcasecmp(hp->name, header_name)) {
@@ -348,7 +460,16 @@
 	return NULL;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name,
+SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event)
+{
+	if (event) {
+		return event->body;
+	}
+
+	return NULL;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, char *header_name,
 													  char *fmt, ...)
 {
 	int ret = 0;
@@ -362,7 +483,7 @@
 	if (ret == -1) {
 		return SWITCH_STATUS_MEMERR;
 	} else {
-		switch_event_header *header, *hp;
+		switch_event_header_t *header, *hp;
 
 		if ((header = ALLOC(sizeof(*header))) == 0) {
 			return SWITCH_STATUS_MEMERR;
@@ -390,28 +511,30 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_event_add_body(switch_event *event, char *fmt, ...)
+SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, char *fmt, ...)
 {
 	int ret = 0;
 	char data[2048];
 
 	va_list ap;
-	va_start(ap, fmt);
-	vsnprintf(data, sizeof(data), fmt, ap);
-	va_end(ap);
+	if (fmt) {
+		va_start(ap, fmt);
+		ret = vsnprintf(data, sizeof(data), fmt, ap);
+		va_end(ap);
+	}
 
 	if (ret == -1) {
-		return SWITCH_STATUS_MEMERR;
+		return SWITCH_STATUS_GENERR;
 	} else {
 		event->body = DUP(data);
 		return SWITCH_STATUS_SUCCESS;
 	}
 }
 
-SWITCH_DECLARE(void) switch_event_destroy(switch_event **event)
+SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event)
 {
-	switch_event *ep = *event;
-	switch_event_header *hp, *this;
+	switch_event_t *ep = *event;
+	switch_event_header_t *hp, *this;
 
 	for (hp = ep->headers; hp;) {
 		this = hp;
@@ -425,11 +548,11 @@
 	*event = NULL;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_dup(switch_event **event, switch_event *todup)
+SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_event_t *todup)
 {
-	switch_event_header *header, *hp, *hp2;
+	switch_event_header_t *header, *hp, *hp2, *last = NULL;
 
-	if (switch_event_create_subclass(event, todup->event_id, todup->subclass->name) != SWITCH_STATUS_SUCCESS) {
+	if (switch_event_create_subclass(event, todup->event_id, todup->subclass ? todup->subclass->name : NULL) != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_GENERR;
 	}
 
@@ -437,7 +560,9 @@
 	(*event)->event_user_data = todup->event_user_data;
 	(*event)->bind_user_data = todup->bind_user_data;
 
-	for (hp = todup->headers; hp && hp->next;) {
+	hp2 = (*event)->headers;
+
+	for (hp = todup->headers; hp; hp = hp->next) {
 		if ((header = ALLOC(sizeof(*header))) == 0) {
 			return SWITCH_STATUS_MEMERR;
 		}
@@ -447,22 +572,26 @@
 		header->name = DUP(hp->name);
 		header->value = DUP(hp->value);
 
-		for (hp2 = todup->headers; hp2 && hp2->next; hp2 = hp2->next);
-
-		if (hp2) {
-			hp2->next = header;
+		if (last) {
+			last->next = header;
 		} else {
 			(*event)->headers = header;
 		}
+
+		last = header;
 	}
 
+	if (todup->body) {
+		(*event)->body = DUP(todup->body);
+	}
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *buf, switch_size_t buflen, char *fmt, ...)
+SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, char *buf, switch_size_t buflen, char *fmt, ...)
 {
 	switch_size_t len = 0;
-	switch_event_header *hp;
+	switch_event_header_t *hp;
 	char *data = NULL, *body = NULL;
 	int ret = 0;
 	va_list ap;
@@ -512,7 +641,79 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event,
+static switch_xml_t add_xml_header(switch_xml_t xml, char *name, char *value, int offset)
+{
+	switch_xml_t header = NULL;
+
+	if ((header = switch_xml_add_child_d(xml, "header", offset))) {
+		switch_xml_set_attr_d(header, "name", name);
+		switch_xml_set_attr_d(header, "value", value);	
+	}
+
+	return header;
+}
+
+SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, char *fmt, ...)
+{
+	switch_event_header_t *hp;
+	char *data = NULL, *body = NULL;
+	int ret = 0;
+	switch_xml_t xml = NULL;
+	uint32_t off = 0;
+	va_list ap;
+
+	if (!(xml = switch_xml_new("event"))) {
+		return xml;
+	}
+
+	if (fmt) {
+		va_start(ap, fmt);
+#ifdef HAVE_VASPRINTF
+		ret = vasprintf(&data, fmt, ap);
+#else
+		data = (char *) malloc(2048);
+		vsnprintf(data, 2048, fmt, ap);
+#endif
+		va_end(ap);
+		if (ret == -1) {
+			return NULL;
+		}
+	}
+
+	
+	for (hp = event->headers; hp; hp = hp->next) {
+		add_xml_header(xml, hp->name, hp->value, off++);
+	}
+
+	if (data) {
+		body = data;
+	} else if (event->body) {
+		body = event->body;
+	}
+
+	if (body) {
+		int blen = (int) strlen(body);
+		char blena[25];
+		snprintf(blena, sizeof(blena), "%d", blen);
+		if (blen) {
+			switch_xml_t xbody = NULL;
+
+			add_xml_header(xml, "Content-Length", blena, off++);
+			if ((xbody = switch_xml_add_child_d(xml, "body", off++))) {
+				switch_xml_set_txt_d(xbody, body);
+			}
+		}
+	}
+	
+	if (data) {
+		free(data);
+	}
+
+	return xml;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event,
 														 void *user_data)
 {
 
@@ -522,6 +723,10 @@
 
 	assert(BLOCK != NULL);
 	assert(RUNTIME_POOL != NULL);
+	assert(EVENT_QUEUE_HAVEMORE_MUTEX != NULL);
+	assert(EVENT_QUEUE_MUTEX != NULL);
+	assert(EVENT_QUEUE_CONDITIONAL != NULL);
+	assert(RUNTIME_POOL != NULL);
 
 	if (THREAD_RUNNING <= 0) {
 		/* sorry we're closed */
@@ -534,7 +739,7 @@
 	switch_event_add_header(*event, SWITCH_STACK_TOP, "Event-Calling-Function", func);
 	switch_event_add_header(*event, SWITCH_STACK_TOP, "Event-Calling-File", switch_cut_path(file));
 	switch_time_exp_lt(&tm, switch_time_now());
-	switch_strftime(date, &retsize, sizeof(date), "%a, %d-%b-%Y %X", &tm);
+	switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
 	switch_event_add_header(*event, SWITCH_STACK_TOP, "Event-Date-Local", date);
 	switch_rfc822_date(date, switch_time_now());
 	switch_event_add_header(*event, SWITCH_STACK_TOP, "Event-Date-GMT", date);
@@ -550,16 +755,39 @@
 	}
 
 	switch_queue_push(EVENT_QUEUE[(*event)->priority], *event);
+
+	//Lock on havemore to make sure he event thread, if currently running
+	// doesn't check the HAVEMORE flag before we set it
+	switch_mutex_lock(EVENT_QUEUE_HAVEMORE_MUTEX);
+	//See if the event thread is sitting
+	if(switch_mutex_trylock(EVENT_QUEUE_MUTEX) == SWITCH_STATUS_SUCCESS) {
+		//we don't need havemore anymore, the thread was sitting already
+		switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+
+		//wake up the event thread
+		switch_thread_cond_signal(EVENT_QUEUE_CONDITIONAL);
+
+		//give up our lock
+		switch_mutex_unlock(EVENT_QUEUE_MUTEX);
+	} else { // it wasn't waiting which means we might have updated a queue it already looked at
+		//set a flag so it knows to read the queues again
+		EVENT_QUEUE_HAVEMORE = 1;
+
+		//variable updated, give up the mutex
+		switch_mutex_unlock(EVENT_QUEUE_HAVEMORE_MUTEX);
+	}
+		
+
 	*event = NULL;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name,
+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_event_node *event_node;
-	switch_event_subclass *subclass = NULL;
+	switch_event_node_t *event_node;
+	switch_event_subclass_t *subclass = NULL;
 
 	assert(BLOCK != NULL);
 	assert(RUNTIME_POOL != NULL);
@@ -575,7 +803,7 @@
 		}
 	}
 
-	if (event <= SWITCH_EVENT_ALL && (event_node = switch_core_alloc(RUNTIME_POOL, sizeof(switch_event_node))) != 0) {
+	if (event <= SWITCH_EVENT_ALL && (event_node = switch_core_alloc(RUNTIME_POOL, sizeof(switch_event_node_t))) != 0) {
 		switch_mutex_lock(BLOCK);
 		/* <LOCKED> ----------------------------------------------- */
 		event_node->id = switch_core_strdup(RUNTIME_POOL, id);

Modified: freeswitch/branches/voctel/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_ivr.c	(original)
+++ freeswitch/branches/voctel/src/switch_ivr.c	Fri Sep 22 14:22:15 2006
@@ -32,36 +32,181 @@
 #include <switch.h>
 #include <switch_ivr.h>
 
+static const switch_state_handler_table_t audio_bridge_peer_state_handlers;
 
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_callback(switch_core_session *session,
-																 switch_dtmf_callback_function dtmf_callback,
+SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms)
+{
+	switch_channel_t *channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_time_t start, now, done = switch_time_now() + (ms * 1000);
+	switch_frame_t *read_frame;
+	int32_t left, elapsed;
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	start = switch_time_now();
+
+	for(;;) {
+		now = switch_time_now();
+		elapsed = (int32_t)((now - start) / 1000);
+		left = ms - elapsed;
+
+		if (!switch_channel_ready(channel)) {
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
+
+		if (now > done || left <= 0) {
+			break;
+		}
+
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
+			status = switch_core_session_read_frame(session, &read_frame, left, 0);
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
+				break;
+			}
+		}
+	}
+	
+
+	return status;
+}
+
+
+static void switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event)
+{
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	char *cmd = switch_event_get_header(event, "call-command");
+	unsigned long cmd_hash;
+	apr_ssize_t hlen = APR_HASH_KEY_STRING;
+	unsigned long CMD_EXECUTE = apr_hashfunc_default("execute", &hlen);
+	unsigned long CMD_HANGUP = apr_hashfunc_default("hangup", &hlen);
+
+    assert(channel != NULL);
+	hlen = (switch_size_t) strlen(cmd);
+	cmd_hash = apr_hashfunc_default(cmd, &hlen);
+
+	if (!switch_strlen_zero(cmd)) {
+		if (cmd_hash == CMD_EXECUTE) {
+			const switch_application_interface_t *application_interface;
+			char *app_name = switch_event_get_header(event, "execute-app-name");
+			char *app_arg = switch_event_get_header(event, "execute-app-arg");
+						
+			if (app_name && app_arg) {
+				if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
+					if (application_interface->application_function) {
+						application_interface->application_function(session, app_arg);
+					}
+				}
+			}
+		} else if (cmd_hash == CMD_HANGUP) {
+			char *cause_name = switch_event_get_header(event, "hangup-cause");
+			switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+
+			if (cause_name) {
+				cause = switch_channel_str2cause(cause_name);
+			}
+
+			switch_channel_hangup(channel, cause);
+		}
+	}
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session)
+{
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel;
+	switch_frame_t *frame;
+	int stream_id;
+	switch_event_t *event;
+	
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);	
+
+	switch_channel_answer(channel);
+
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PARK) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		switch_event_fire(&event);
+	}
+
+	switch_channel_set_flag(channel, CF_CONTROLLED);
+	while (switch_channel_ready(channel)) {
+		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
+			if ((status = switch_core_session_read_frame(session, &frame, -1, stream_id)) == SWITCH_STATUS_SUCCESS) {
+				if (!SWITCH_READ_ACCEPTABLE(status)) {
+					break;
+				}
+
+				if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+					switch_ivr_parse_event(session, event);
+					switch_event_destroy(&event);
+				}
+
+			}
+		}
+	}
+	switch_channel_clear_flag(channel, CF_CONTROLLED);
+
+	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNPARK) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		switch_event_fire(&event);
+	}
+
+	return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
+																 switch_input_callback_function_t input_callback,
 																 void *buf,
 																 unsigned int buflen)
 {
-	switch_channel *channel;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 
-	if (!dtmf_callback) {
+	if (!input_callback) {
 		return SWITCH_STATUS_GENERR;
 	}
 
 	while(switch_channel_ready(channel)) {
-		switch_frame *read_frame;
+		switch_frame_t *read_frame;
+		switch_event_t *event;
+
 		char dtmf[128];
 
+
+		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_ivr_parse_event(session, event);
+			switch_event_destroy(&event);
+		}
+
 		if (switch_channel_has_dtmf(channel)) {
 			switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-			status = dtmf_callback(session, dtmf, buf, buflen);
+			status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
 		}
 
+		if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);			
+			switch_event_destroy(&event);
+		}
+
 		if (status != SWITCH_STATUS_SUCCESS) {
 			break;
 		}
 
-		if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) {
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
+			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+		}
+
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
 	}
@@ -70,19 +215,17 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_ivr_collect_digits_count(switch_core_session *session,
-															  char *buf,
-															  unsigned int buflen,
-															  unsigned int maxdigits,
-															  const char *terminators,
-															  char *terminator,
-															  unsigned int timeout,
-															  unsigned int poll_channel
-															  )
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
+																char *buf,
+																unsigned int buflen,
+																unsigned int maxdigits,
+																const char *terminators,
+																char *terminator,
+																unsigned int timeout)
 {
 	unsigned int i = 0, x =  (unsigned int) strlen(buf);
-	switch_channel *channel;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *channel;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_time_t started = 0;
 	unsigned int elapsed;
 
@@ -105,7 +248,8 @@
 	}
 
 	while(switch_channel_ready(channel)) {
-		switch_frame *read_frame;
+		switch_frame_t *read_frame;
+		switch_event_t *event;
 
 		if (timeout) {
 			elapsed = (unsigned int)((switch_time_now() - started) / 1000);
@@ -114,10 +258,14 @@
 			}
 		}
 		
+		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_ivr_parse_event(session, event);
+			switch_event_destroy(&event);
+		}
+
 		if (switch_channel_has_dtmf(channel)) {
 			char dtmf[128];
 			switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-
 			for(i =0 ; i < (unsigned int) strlen(dtmf); i++) {
 
 				if (strchr(terminators, dtmf[i])) {
@@ -132,12 +280,14 @@
 				}
 			}
 		}
-		if (poll_channel) {
-			if ((status = switch_core_session_read_frame(session, &read_frame, -1, 0)) != SWITCH_STATUS_SUCCESS) {
+
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
+			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-		} else {
-			switch_yield(1000);
 		}
 	}
 
@@ -146,20 +296,22 @@
 
 
 
-SWITCH_DECLARE(switch_status) switch_ivr_record_file(switch_core_session *session, 
-													 switch_file_handle *fh,
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session, 
+													 switch_file_handle_t *fh,
 													 char *file,
-													 switch_dtmf_callback_function dtmf_callback,
+													 switch_input_callback_function_t input_callback,
 													 void *buf,
 													 unsigned int buflen)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
     char dtmf[128];
-	switch_file_handle lfh;
-	switch_frame *read_frame;
-	switch_codec codec, *read_codec;
+	switch_file_handle_t lfh;
+	switch_frame_t *read_frame;
+	switch_codec_t codec, *read_codec;
 	char *codec_name;
-	switch_status status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	char *p;
+	const char *vval;
 
 	if (!fh) {
 		fh = &lfh;
@@ -180,12 +332,48 @@
 							  file,
 							  SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
 							  switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-		switch_channel_hangup(channel);
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		switch_core_session_reset(session);
 		return SWITCH_STATUS_GENERR;
 	}
 
 	switch_channel_answer(channel);
 
+	if ((p = switch_channel_get_variable(channel, "RECORD_TITLE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
+		switch_channel_set_variable(channel, "RECORD_TITLE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COPYRIGHT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COPYRIGHT, vval);
+		switch_channel_set_variable(channel, "RECORD_COPYRIGHT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_SOFTWARE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_SOFTWARE, vval);
+		switch_channel_set_variable(channel, "RECORD_SOFTWARE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_ARTIST"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_ARTIST, vval);
+		switch_channel_set_variable(channel, "RECORD_ARTIST", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COMMENT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COMMENT, vval);
+		switch_channel_set_variable(channel, "RECORD_COMMENT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_DATE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_DATE, vval);
+		switch_channel_set_variable(channel, "RECORD_DATE", NULL);
+	}
 	
 	codec_name = "L16";
 	if (switch_core_codec_init(&codec,
@@ -201,34 +389,51 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n",
 							  codec_name, fh->samplerate, fh->channels, read_codec->implementation->microseconds_per_frame / 1000);
 		switch_core_file_close(fh);
+		switch_core_session_reset(session);
 		return SWITCH_STATUS_GENERR;
 	}
 	
 
 	while(switch_channel_ready(channel)) {
 		switch_size_t len;
+		switch_event_t *event;
 
-		if (dtmf_callback || buf) {
+
+		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_ivr_parse_event(session, event);
+			switch_event_destroy(&event);
+		}
+
+		if (input_callback || buf) {
 			/*
 			  dtmf handler function you can hook up to be executed when a digit is dialed during playback 
 			  if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 			*/
 			if (switch_channel_has_dtmf(channel)) {
 				switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-				if (dtmf_callback) {
-					status = dtmf_callback(session, dtmf, buf, buflen);
+				if (input_callback) {
+					status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
 				} else {
 					switch_copy_string((char *)buf, dtmf, buflen);
 					status = SWITCH_STATUS_BREAK;
 				}
 			}
 
+			if (input_callback) {
+				if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+					status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);			
+					switch_event_destroy(&event);
+				}
+			}
+
+
 			if (status != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
 		}
 		
-		if ((status = switch_core_session_read_frame(session, &read_frame, -1, 0)) != SWITCH_STATUS_SUCCESS) {
+		status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
 		if (!switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
@@ -239,34 +444,173 @@
 
 	switch_core_session_set_read_codec(session, read_codec);
 	switch_core_file_close(fh);
-
+	switch_core_session_reset(session);
 	return status;
 }
 
-SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session, 
-												   switch_file_handle *fh,
+static void record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+	switch_file_handle_t *fh = (switch_file_handle_t *) user_data;
+	uint8_t data[SWITCH_RECCOMMENDED_BUFFER_SIZE];
+	switch_frame_t frame = {0};
+
+	frame.data = data;
+	frame.buflen = SWITCH_RECCOMMENDED_BUFFER_SIZE;
+	
+	switch(type) {
+	case SWITCH_ABC_TYPE_INIT:
+		break;
+	case SWITCH_ABC_TYPE_CLOSE:
+		switch_core_file_close(fh);
+	case SWITCH_ABC_TYPE_READ:
+		if (fh) {
+			switch_size_t len;
+
+			if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
+				len = (switch_size_t) frame.datalen / 2;
+				switch_core_file_write(fh, frame.data, &len);
+			}
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE:
+		break;
+	}
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_record_session(switch_core_session_t *session, char *file) 
+{
+	switch_media_bug_t *bug;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+	assert(channel != NULL);
+	if ((bug = switch_channel_get_private(channel, file))) {
+		switch_channel_set_private(channel, file, NULL);
+		switch_core_media_bug_remove(session, &bug);
+		return SWITCH_STATUS_SUCCESS;
+	}
+	
+	return SWITCH_STATUS_FALSE;
+	
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file,  switch_file_handle_t *fh)
+{
+	switch_channel_t *channel;
+	switch_codec_t *read_codec;
+	char *p;
+	const char *vval;
+	switch_media_bug_t *bug;
+	switch_status_t status;
+
+	if (!fh) {
+		if (!(fh = switch_core_session_alloc(session, sizeof(*fh)))) {
+			return SWITCH_STATUS_MEMERR;
+		}
+	}
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+    read_codec = switch_core_session_get_read_codec(session);
+    assert(read_codec != NULL);
+
+    fh->channels = read_codec->implementation->number_of_channels;
+    fh->samplerate = read_codec->implementation->samples_per_second;
+
+
+    if (switch_core_file_open(fh,
+                              file,
+                              SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT,
+                              switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+        switch_core_session_reset(session);
+        return SWITCH_STATUS_GENERR;
+    }
+
+    switch_channel_answer(channel);
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_TITLE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
+		switch_channel_set_variable(channel, "RECORD_TITLE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COPYRIGHT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COPYRIGHT, vval);
+		switch_channel_set_variable(channel, "RECORD_COPYRIGHT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_SOFTWARE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_SOFTWARE, vval);
+		switch_channel_set_variable(channel, "RECORD_SOFTWARE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_ARTIST"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_ARTIST, vval);
+		switch_channel_set_variable(channel, "RECORD_ARTIST", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COMMENT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COMMENT, vval);
+		switch_channel_set_variable(channel, "RECORD_COMMENT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_DATE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_DATE, vval);
+		switch_channel_set_variable(channel, "RECORD_DATE", NULL);
+	}
+
+	
+
+	if ((status = switch_core_media_bug_add(session,
+											record_callback,
+											fh,
+											&bug)) != SWITCH_STATUS_SUCCESS) {
+		switch_core_file_close(fh);
+		return status;
+	}
+
+	switch_channel_set_private(channel, file, bug);
+	
+	return SWITCH_STATUS_SUCCESS;
+}
+
+#define FILE_STARTSAMPLES 512 * 64
+#define FILE_BLOCKSIZE 1024 * 8
+#define FILE_BUFSIZE 1024 * 64
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, 
+												   switch_file_handle_t *fh,
 												   char *file,
 												   char *timer_name,
-												   switch_dtmf_callback_function dtmf_callback,
+												   switch_input_callback_function_t input_callback,
 												   void *buf,
 												   unsigned int buflen)
 {
-	switch_channel *channel;
-	short abuf[960];
+	switch_channel_t *channel;
+	int16_t abuf[FILE_STARTSAMPLES+1];
 	char dtmf[128];
 	uint32_t interval = 0, samples = 0;
-	uint32_t len = 0, ilen = 0;
+	uint32_t ilen = 0;
 	switch_size_t olen = 0;
-	switch_frame write_frame = {0};
-	switch_timer timer;
-	switch_core_thread_session thread_session;
-	switch_codec codec;
-	switch_memory_pool *pool = switch_core_session_get_pool(session);
+	switch_frame_t write_frame = {0};
+	switch_timer_t timer;
+	switch_core_thread_session_t thread_session;
+	switch_codec_t codec;
+	switch_memory_pool_t *pool = switch_core_session_get_pool(session);
 	char *codec_name;
 	int stream_id;
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	switch_file_handle lfh;
-
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_file_handle_t lfh;
+	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
+	const char *p;
+	char *title = "", *copyright = "", *software = "", *artist = "", *comment = "", *date = "";
+	
 	if (!fh) {
 		fh = &lfh;
 		memset(fh, 0, sizeof(lfh));
@@ -279,20 +623,66 @@
 							  file,
 							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
 							  switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-		switch_channel_hangup(channel);
-		return SWITCH_STATUS_GENERR;
+		switch_core_session_reset(session);
+		return SWITCH_STATUS_NOTFOUND;
 	}
 
 
 	write_frame.data = abuf;
 	write_frame.buflen = sizeof(abuf);
 
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_TITLE, &p) == SWITCH_STATUS_SUCCESS) {
+		title = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_TITLE", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_COPYRIGHT, &p) == SWITCH_STATUS_SUCCESS) {
+		copyright = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_COPYRIGHT", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_SOFTWARE, &p) == SWITCH_STATUS_SUCCESS) {
+		software = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_SOFTWARE", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_ARTIST, &p) == SWITCH_STATUS_SUCCESS) {
+		artist = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_ARTIST", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_COMMENT, &p) == SWITCH_STATUS_SUCCESS) {
+		comment = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_COMMENT", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_DATE, &p) == SWITCH_STATUS_SUCCESS) {
+		date = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_DATE", (char *)p);
+	}
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+					  "OPEN FILE %s %uhz %u channels\n"
+					  "TITLE=%s\n"
+					  "COPYRIGHT=%s\n"
+					  "SOFTWARE=%s\n"
+					  "ARTIST=%s\n"
+					  "COMMENT=%s\n"
+					  "DATE=%s\n", file, fh->samplerate, fh->channels,
+					  title,
+					  copyright,
+					  software,
+					  artist,
+					  comment,
+					  date);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN FILE %s %uhz %u channels\n", file, fh->samplerate, fh->channels);
+	assert(read_codec != NULL);
+	interval = read_codec->implementation->microseconds_per_frame / 1000;
 
-	interval = 20;
-	samples = ((fh->samplerate / 50) * fh->channels);
-	len = samples * 2;
+	if (!fh->audio_buffer) {
+		switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
+	} 
 
 	codec_name = "L16";
 
@@ -304,19 +694,27 @@
 							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 							   NULL, pool) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
+
 		write_frame.codec = &codec;
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n",
 							  codec_name, fh->samplerate, fh->channels, interval);
 		switch_core_file_close(fh);
+		switch_core_session_reset(session);
 		return SWITCH_STATUS_GENERR;
 	}
 
+	samples = codec.implementation->bytes_per_frame / 2;
+
 	if (timer_name) {
+		uint32_t len;
+
+		len = samples * 2;
 		if (switch_core_timer_init(&timer, timer_name, interval, samples, pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
 			switch_core_codec_destroy(&codec);
 			switch_core_file_close(fh);
+			switch_core_session_reset(session);
 			return SWITCH_STATUS_GENERR;
 		}
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
@@ -335,21 +733,35 @@
 		int done = 0;
 		int do_speed = 1;
 		int last_speed = -1;
+		switch_event_t *event;
+	
 
-		if (dtmf_callback || buf) {
+		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_ivr_parse_event(session, event);
+			switch_event_destroy(&event);
+		}
+
+		if (input_callback || buf) {
 			/*
 			  dtmf handler function you can hook up to be executed when a digit is dialed during playback 
 			  if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 			*/
 			if (switch_channel_has_dtmf(channel)) {
 				switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-				if (dtmf_callback) {
-					status = dtmf_callback(session, dtmf, buf, buflen);
+				if (input_callback) {
+					status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
 				} else {
 					switch_copy_string((char *)buf, dtmf, buflen);
 					status = SWITCH_STATUS_BREAK;
 				}
 			}
+
+			if (input_callback) {
+				if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+					status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);			
+					switch_event_destroy(&event);
+				}
+			}
 			
 			if (status != SWITCH_STATUS_SUCCESS) {
 				done = 1;
@@ -366,8 +778,10 @@
 			olen = ilen;
 			do_speed = 0;
 		} else {
-			olen = ilen;
+			olen = FILE_STARTSAMPLES;
 			switch_core_file_read(fh, abuf, &olen);
+			switch_buffer_write(fh->audio_buffer, abuf, olen * 2);
+			olen = switch_buffer_read(fh->audio_buffer, abuf, ilen * 2) / 2;
 		}
 
 		if (done || olen <= 0) {
@@ -376,7 +790,7 @@
 
 		if (fh->speed > 2) {
 			fh->speed = 2;
-		} else if(fh->speed < -2) {
+		} else if (fh->speed < -2) {
 			fh->speed = -2;
 		}
 		
@@ -391,9 +805,6 @@
 			short *bp = write_frame.data;
 			switch_size_t wrote = 0;
 			
-			if (!fh->audio_buffer) {
-				switch_buffer_create(fh->memory_pool, &fh->audio_buffer, SWITCH_RECCOMMENDED_BUFFER_SIZE);
-			} 
 			
 			supplement = (int) (factor * olen);
 			newlen = (fh->speed > 0) ? olen - supplement : olen + supplement;
@@ -426,13 +837,19 @@
 
 		write_frame.datalen = (uint32_t)(olen * 2);
 		write_frame.samples = (uint32_t)olen;
+
+#ifndef WIN32
 #if __BYTE_ORDER == __BIG_ENDIAN
 		switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);
 #endif
-		
+#endif
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
+			status = switch_core_session_write_frame(session, &write_frame, -1, stream_id);
 
-			if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
+			if (status == SWITCH_STATUS_MORE_DATA) {
+				status = SWITCH_STATUS_SUCCESS;
+				continue;
+			} else if (status != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bad Write\n");
 				done = 1;
 				break;
@@ -441,13 +858,19 @@
 				break;
 			}
 		}
+		
 		if (timer_name) {
 			if (switch_core_timer_next(&timer) < 0) {
 				break;
 			}
 		} else { /* time off the channel (if you must) */
-			switch_frame *read_frame;
-			if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) {
+			switch_frame_t *read_frame;
+			switch_status_t status; 
+			while (switch_channel_test_flag(channel, CF_HOLD)) {
+				switch_yield(10000);
+			}
+			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
 		}
@@ -455,6 +878,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done playing file\n");
 	switch_core_file_close(fh);
+	switch_buffer_destroy(&fh->audio_buffer);
 	switch_core_codec_destroy(&codec);
 
 	if (timer_name) {
@@ -463,110 +887,63 @@
 		switch_core_timer_destroy(&timer);
 	}
 
+	switch_core_session_reset(session);
 	return status;
 }
 
 
 
 
-SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session, 
-													char *tts_name,
-													char *voice_name,
-													char *timer_name,
-													uint32_t rate,
-													switch_dtmf_callback_function dtmf_callback,
-													char *text,
-													void *buf,
-													unsigned int buflen)
+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,
+															 switch_input_callback_function_t input_callback,
+															 char *text,
+															 void *buf,
+															 unsigned int buflen)
 {
-	switch_channel *channel;
+	switch_channel_t *channel;
 	short abuf[960];
 	char dtmf[128];
-	int interval = 0;
-	uint32_t samples = 0;
 	uint32_t len = 0;
 	switch_size_t ilen = 0;
-	switch_frame write_frame = {0};
-	switch_timer timer;
-	switch_core_thread_session thread_session;
-	switch_codec codec;
-	switch_memory_pool *pool = switch_core_session_get_pool(session);
-	char *codec_name;
+	switch_frame_t write_frame = {0};
 	int x;
 	int stream_id;
 	int done = 0;
 	int lead_in_out = 10;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_TTS;
+	uint32_t rate = 0, samples = 0;
 
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	switch_speech_handle sh;
-	switch_speech_flag flags = SWITCH_SPEECH_FLAG_TTS;
-
-
-	memset(&sh, 0, sizeof(sh));
-
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	if (switch_core_speech_open(&sh,
-								tts_name,
-								voice_name,
-								(unsigned int)rate,
-								&flags,
-								switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
+	if (!sh) {
 		return SWITCH_STATUS_FALSE;
 	}
-
+	
 	switch_channel_answer(channel);
 
 	write_frame.data = abuf;
 	write_frame.buflen = sizeof(abuf);
 
+    samples = (uint32_t)(sh->rate / 50);
+    len = samples * 2;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name);
-	
-	interval = 20;
-	samples = (uint32_t)(rate / 50);
-	len = samples * 2;
-
-	codec_name = "L16";
-
-	if (switch_core_codec_init(&codec,
-							   codec_name,
-							   (int)rate,
-							   interval,
-							   1,
-							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-							   NULL, pool) == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
-		write_frame.codec = &codec;
-	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n",
-							  codec_name, rate, interval);
-		flags = 0;
-		switch_core_speech_close(&sh, &flags);
-		return SWITCH_STATUS_GENERR;
-	}
-
-	if (timer_name) {
-		if (switch_core_timer_init(&timer, timer_name, interval, (int)samples, pool) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
-			switch_core_codec_destroy(&codec);
-			flags = 0;
-			switch_core_speech_close(&sh, &flags);
-			return SWITCH_STATUS_GENERR;
-		}
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
-	}
-
 	flags = 0;
-	switch_core_speech_feed_tts(&sh, text, &flags);
-	write_frame.rate = rate;
+	switch_sleep(200000);
+	switch_core_speech_feed_tts(sh, text, &flags);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Speaking text: %s\n", text);
 
+	write_frame.rate = sh->rate;
+
 	memset(write_frame.data, 0, len);
 	write_frame.datalen = len;
 	write_frame.samples = len / 2;
-	
+	write_frame.codec = codec;
+
 	for( x = 0; !done && x < lead_in_out; x++) {
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
 			if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
@@ -577,40 +954,69 @@
 		}
 	}
 
-	if (timer_name) {
-		/* start a thread to absorb incoming audio */
-		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
-			switch_core_service_session(session, &thread_session, stream_id);
-		}
-	}
-
 	ilen = len;
 	while(switch_channel_ready(channel)) {
-		if (dtmf_callback || buf) {
+		switch_event_t *event;
 
+		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_ivr_parse_event(session, event);
+			switch_event_destroy(&event);
+		}
 
+		if (input_callback || buf) {
 			/*
 			  dtmf handler function you can hook up to be executed when a digit is dialed during playback 
 			  if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
 			*/
 			if (switch_channel_has_dtmf(channel)) {
-				switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-				if (dtmf_callback) {
-					status = dtmf_callback(session, dtmf, buf, buflen);
-				} else {
-					switch_copy_string((char *)buf, dtmf, buflen);
+				if (buf && !strcasecmp(buf, "_break_")) {
 					status = SWITCH_STATUS_BREAK;
+				} else {
+					switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
+					if (input_callback) {
+						status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
+					} else {
+						switch_copy_string((char *)buf, dtmf, buflen);
+						status = SWITCH_STATUS_BREAK;
+					}
 				}
 			}
-			
+
+			if (input_callback) {
+				if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+					status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);			
+					switch_event_destroy(&event);
+				}
+			}
+
 			if (status != SWITCH_STATUS_SUCCESS) {
 				done = 1;
 				break;
 			}
 		}
+		
+		if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_PAUSE)) {
+			if (timer) {
+				if ((x = switch_core_timer_next(timer)) < 0) {
+					break;
+				}
+			} else {
+				switch_frame_t *read_frame;
+				switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
 
+				while (switch_channel_test_flag(channel, CF_HOLD)) {
+					switch_yield(10000);
+				}
+			
+				if (!SWITCH_READ_ACCEPTABLE(status)) {
+					break;
+				}
+			}
+			continue;
+		}
+
 		flags = SWITCH_SPEECH_FLAG_BLOCKING;
-		status = switch_core_speech_read_tts(&sh,
+		status = switch_core_speech_read_tts(sh,
 											 abuf,
 											 &ilen,
 											 &rate,
@@ -626,10 +1032,13 @@
 					}
 				}
 			}
+			if (status == SWITCH_STATUS_BREAK) {
+				status = SWITCH_STATUS_SUCCESS;
+			}
 			done = 1;
 		}
 		
-		if (done || ilen <= 0) {
+		if (done) {
 			break;
 		}
 
@@ -647,20 +1056,123 @@
 				break;
 			}
 		}
-		if (timer_name) {
-			if ((x = switch_core_timer_next(&timer)) < 0) {
+
+		if (timer) {
+			if ((x = switch_core_timer_next(timer)) < 0) {
 				break;
 			}
 		} else { /* time off the channel (if you must) */
-			switch_frame *read_frame;
-			if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) {
+			switch_frame_t *read_frame;
+			switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+
+			while (switch_channel_test_flag(channel, CF_HOLD)) {
+				switch_yield(10000);
+			}
+			
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
 		}
-	}
 
+	}
+	
+	
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done speaking text\n");
 	flags = 0;	
+	switch_core_speech_flush_tts(sh);
+	return status;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, 
+													  char *tts_name,
+													  char *voice_name,
+													  char *timer_name,
+													  uint32_t rate,
+													  switch_input_callback_function_t input_callback,
+													  char *text,
+													  void *buf,
+													  unsigned int buflen)
+{
+	switch_channel_t *channel;
+	int interval = 0;
+	uint32_t samples = 0;
+	uint32_t len = 0;
+	switch_frame_t write_frame = {0};
+	switch_timer_t timer;
+	switch_core_thread_session_t thread_session;
+	switch_codec_t codec;
+	switch_memory_pool_t *pool = switch_core_session_get_pool(session);
+	char *codec_name;
+	int stream_id;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_speech_handle_t sh;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_TTS;
+
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+
+	memset(&sh, 0, sizeof(sh));
+	if (switch_core_speech_open(&sh,
+								tts_name,
+								voice_name,
+								(unsigned int)rate,
+								&flags,
+								switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
+		switch_core_session_reset(session);
+		return SWITCH_STATUS_FALSE;
+	}
+		
+	switch_channel_answer(channel);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name);
+	
+	interval = 20;
+	samples = (uint32_t)(rate / 50);
+	len = samples * 2;
+
+	codec_name = "L16";
+
+	if (switch_core_codec_init(&codec,
+							   codec_name,
+							   (int)rate,
+							   interval,
+							   1,
+							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+							   NULL, pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
+		write_frame.codec = &codec;
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n",
+							  codec_name, rate, interval);
+		flags = 0;
+		switch_core_speech_close(&sh, &flags);
+		switch_core_session_reset(session);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	if (timer_name) {
+		if (switch_core_timer_init(&timer, timer_name, interval, (int)samples, pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
+			switch_core_codec_destroy(&codec);
+			flags = 0;
+			switch_core_speech_close(&sh, &flags);
+
+			switch_core_session_reset(session);
+			return SWITCH_STATUS_GENERR;
+		}
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
+
+		/* start a thread to absorb incoming audio */
+		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
+			switch_core_service_session(session, &thread_session, stream_id);
+		}
+	}
+
+	switch_ivr_speak_text_handle(session, &sh, &codec, timer_name ? &timer : NULL, input_callback, text, buf, buflen);
+	flags = 0;	
 	switch_core_speech_close(&sh, &flags);
 	switch_core_codec_destroy(&codec);
 
@@ -670,6 +1182,7 @@
 		switch_core_timer_destroy(&timer);
 	}
 
+	switch_core_session_reset(session);
 	return status;
 }
 
@@ -677,22 +1190,23 @@
 /* Bridge Related Stuff*/
 /*********************************************************************************/
 struct audio_bridge_data {
-	switch_core_session *session_a;
-	switch_core_session *session_b;
+	switch_core_session_t *session_a;
+	switch_core_session_t *session_b;
 	int running;
 };
 
-static void *audio_bridge_thread(switch_thread *thread, void *obj)
+static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 {
-	struct switch_core_thread_session *his_thread, *data = obj;
+	switch_core_thread_session_t *his_thread, *data = obj;
 	int *stream_id_p;
 	int stream_id = 0, ans_a = 0, ans_b = 0;
-	switch_dtmf_callback_function dtmf_callback;
+	switch_input_callback_function_t input_callback;
+	switch_core_session_message_t msg = {0};
 	void *user_data;
 
-	switch_channel *chan_a, *chan_b;
-	switch_frame *read_frame;
-	switch_core_session *session_a, *session_b;
+	switch_channel_t *chan_a, *chan_b;
+	switch_frame_t *read_frame;
+	switch_core_session_t *session_a, *session_b;
 
 	assert(!thread || thread);
 
@@ -700,7 +1214,7 @@
 	session_b = data->objs[1];
 
 	stream_id_p = data->objs[2];
-	dtmf_callback = (switch_dtmf_callback_function) data->objs[3];
+	input_callback = (switch_input_callback_function_t) data->objs[3];
 	user_data = data->objs[4];
 	his_thread = data->objs[5];
 
@@ -715,91 +1229,145 @@
 	ans_a = switch_channel_test_flag(chan_a, CF_ANSWERED);
 	ans_b = switch_channel_test_flag(chan_b, CF_ANSWERED);
 
+	switch_channel_set_flag(chan_a, CF_BRIDGED);
 
-	while (data->running > 0 && his_thread->running > 0) {
-		switch_channel_state b_state = switch_channel_get_state(chan_b);
+	while (switch_channel_ready(chan_a) && data->running > 0 && his_thread->running > 0) {
+		switch_channel_state_t b_state = switch_channel_get_state(chan_b);
+		switch_status_t status;
+		switch_event_t *event;
 
 		switch (b_state) {
 		case CS_HANGUP:
+		case CS_DONE:
+			switch_mutex_lock(data->mutex);
 			data->running = -1;
+			switch_mutex_unlock(data->mutex);
 			continue;
 		default:
 			break;
 		}
 
-		/* If this call is running on early media and it answers for real, pass it along... */
-		if (!ans_b && switch_channel_test_flag(chan_a, CF_ANSWERED)) {
-			if (!switch_channel_test_flag(chan_b, CF_ANSWERED)) {
-				switch_channel_answer(chan_b);
-			}
-			ans_b++;
+		if (switch_channel_test_flag(chan_a, CF_TRANSFER)) {
+			break;
 		}
 
-		if (!ans_a && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
-			if (!switch_channel_test_flag(chan_a, CF_ANSWERED)) {
-				switch_channel_answer(chan_a);
+		if (!switch_channel_test_flag(chan_a, CF_HOLD)) {
+			/* If this call is running on early media and it answers for real, pass it along... */
+			if (!ans_b && switch_channel_test_flag(chan_a, CF_ANSWERED)) {
+				if (!switch_channel_test_flag(chan_b, CF_ANSWERED)) {
+					switch_channel_answer(chan_b);
+				}
+				ans_b++;
 			}
-			ans_a++;
-		}
 
-		/* if 1 channel has DTMF pass it to the other */
-		if (switch_channel_has_dtmf(chan_a)) {
-			char dtmf[128];
-			switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
-			switch_core_session_send_dtmf(session_b, dtmf);
+			if (!ans_a && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
+				if (!switch_channel_test_flag(chan_a, CF_ANSWERED)) {
+					switch_channel_answer(chan_a);
+				}
+				ans_a++;
+			}
+			
+			if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_set_flag(chan_b, CF_HOLD);
+				switch_ivr_parse_event(session_a, event);
+				switch_channel_clear_flag(chan_b, CF_HOLD);
+				switch_event_destroy(&event);
+			}
 
-			if (dtmf_callback) {
-				if (dtmf_callback(session_a, dtmf, user_data, 0) != SWITCH_STATUS_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
-					data->running = -1;
-					break;
+			/* if 1 channel has DTMF pass it to the other */
+			if (switch_channel_has_dtmf(chan_a)) {
+				char dtmf[128];
+				switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
+				switch_core_session_send_dtmf(session_b, dtmf);
+
+				if (input_callback) {
+					if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
+						switch_mutex_lock(data->mutex);
+						data->running = -1;
+						switch_mutex_unlock(data->mutex);
+						break;
+					}
 				}
 			}
+
+			if (switch_core_session_dequeue_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
+				if (input_callback) {
+					status = input_callback(session_a, event, SWITCH_INPUT_TYPE_EVENT, user_data, 0);
+				}
+
+				if (switch_core_session_receive_event(session_b, &event) != SWITCH_STATUS_SUCCESS) {
+					switch_event_destroy(&event);
+				}
+
+			}
+ 
 		}
 
 		/* read audio from 1 channel and write it to the other */
-		if (switch_core_session_read_frame(session_a, &read_frame, -1, stream_id) == SWITCH_STATUS_SUCCESS && read_frame->datalen) {
-			if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "write: %s Bad Frame....[%u] Bubye!\n", switch_channel_get_name(chan_b), read_frame->datalen);
-				data->running = -1;
-			}
+		status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
+
+		if (SWITCH_READ_ACCEPTABLE(status)) {
+			if (status != SWITCH_STATUS_BREAK) {
+				if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "write: %s Bad Frame....[%u] Bubye!\n",
+									  switch_channel_get_name(chan_b), read_frame->datalen);
+					switch_mutex_lock(data->mutex);
+					data->running = -1;
+					switch_mutex_unlock(data->mutex);
+				}
+			} 
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "read: %s Bad Frame.... Bubye!\n", switch_channel_get_name(chan_a));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "read: %s Bad Frame.... Bubye!\n", switch_channel_get_name(chan_a));
+			switch_mutex_lock(data->mutex);
 			data->running = -1;
+			switch_mutex_unlock(data->mutex);
 		}
 
 		//switch_yield(1000);
 	}
 
+	
+	msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
+	msg.from = __FILE__;
+	switch_core_session_receive_message(session_a, &msg);
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
+
+	switch_channel_clear_flag(chan_a, CF_BRIDGED);
+	switch_mutex_lock(data->mutex);
 	data->running = 0;
+	switch_mutex_unlock(data->mutex);
+	return NULL;
+}
 
-	if (his_thread->running > 0 && switch_channel_test_flag(chan_a, CF_ORIGINATOR)) {
-		if (!switch_channel_test_flag(chan_b, CF_TRANSFER)) {
-			switch_core_session_kill_channel(session_b, SWITCH_SIG_KILL);
-			switch_channel_hangup(chan_b);
-		}
-		switch_channel_clear_flag(chan_a, CF_ORIGINATOR);
-	} else if (!switch_channel_test_flag(chan_a, CF_ORIGINATOR) && !switch_channel_test_flag(chan_a, CF_TRANSFER)) {
-		switch_core_session_kill_channel(session_a, SWITCH_SIG_KILL);
-		switch_channel_hangup(chan_a);
+static switch_status_t audio_bridge_on_loopback(switch_core_session_t *session)
+{
+	switch_channel_t *channel = NULL;
+	void *arg;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if ((arg = switch_channel_get_private(channel, "_bridge_"))) {
+		switch_channel_set_private(channel, "_bridge_", NULL);
+		audio_bridge_thread(NULL, (void *) arg);
+	} else {
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 	}
-	
-	while (his_thread->running > 0) {
-		his_thread->running = -1;
-		/* wait for the other audio thread */
-		while (his_thread->running == -1) {
-			switch_yield(1000);
-		}
-	}
+	switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
 
-	data->running = 0;		
-	switch_sleep(1000000);
-	return NULL;
+	if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
+		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+	}
+	
+	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status audio_bridge_on_ring(switch_core_session *session)
+
+static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
 {
-	switch_channel *channel = NULL;
+	switch_channel_t *channel = NULL;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
@@ -807,109 +1375,544 @@
 	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 */
-	if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
-		switch_channel_set_state(channel, CS_TRANSMIT);
+	switch_channel_set_state(channel, CS_HOLD);
+	return SWITCH_STATUS_FALSE;
+}
+
+static switch_status_t audio_bridge_on_hold(switch_core_session_t *session)
+{
+	switch_channel_t *channel = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM HOLD\n");
+
+	/* put the channel in a passive state so we can loop audio to it */
+	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 */ audio_bridge_on_loopback,
+	/*.on_transmit */ NULL,
+	/*.on_hold */ audio_bridge_on_hold,
+};
+
+
+static switch_status_t uuid_bridge_on_transmit(switch_core_session_t *session)
+{
+	switch_channel_t *channel = NULL;
+	switch_core_session_t *other_session;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
+	switch_channel_clear_state_handler(channel, NULL);
+
+	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
+		switch_channel_set_flag(channel, CF_TAGGED);
 		return SWITCH_STATUS_FALSE;
 	}
 
+	if ((other_session = switch_channel_get_private(channel, "_uuid_bridge_"))) {
+		switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+		switch_channel_state_t state = switch_channel_get_state(other_channel);
+		switch_channel_state_t mystate = switch_channel_get_state(channel);
+		switch_event_t *event;
+		uint8_t ready_a, ready_b;
+		switch_caller_profile_t *profile, *new_profile;
 
-	return SWITCH_STATUS_SUCCESS;
+		switch_channel_clear_flag(channel, CF_TRANSFER);
+		switch_channel_set_private(channel, "_uuid_bridge_", NULL);
+
+		while (mystate <= CS_HANGUP && state <= CS_HANGUP && !switch_channel_test_flag(other_channel, CF_TAGGED)) {
+			switch_yield(1000);
+			state = switch_channel_get_state(other_channel);
+			mystate = switch_channel_get_state(channel);
+		}
+
+		switch_channel_clear_flag(other_channel, CF_TRANSFER|CF_TAGGED);
+
+
+		switch_core_session_reset(session);
+		switch_core_session_reset(other_session);
+		
+		ready_a = switch_channel_ready(channel);
+		ready_b = switch_channel_ready(other_channel);
+
+		if (!ready_a || !ready_b) {
+			if (!ready_a) {
+				switch_channel_hangup(other_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			}
+
+			if (!ready_b) {
+				switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			}
+			return SWITCH_STATUS_FALSE;
+		}
+		
+		/* add another profile to both sessions for CDR's sake */
+		if ((profile = switch_channel_get_caller_profile(channel))) {
+			new_profile = switch_caller_profile_clone(session, profile);
+			new_profile->destination_number = switch_core_session_strdup(session, switch_core_session_get_uuid(other_session));
+			switch_channel_set_caller_profile(channel, new_profile);
+		} 
+
+		if ((profile = switch_channel_get_caller_profile(other_channel))) {
+			new_profile = switch_caller_profile_clone(other_session, profile);
+			new_profile->destination_number = switch_core_session_strdup(other_session, switch_core_session_get_uuid(session));
+			switch_channel_set_caller_profile(other_channel, new_profile);
+		} 
+
+		/* fire events that will change the data table from "show channels" */
+		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "uuid_bridge");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", switch_core_session_get_uuid(other_session));
+			switch_event_fire(&event);
+		}
+
+		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(other_channel, event);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "uuid_bridge");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", switch_core_session_get_uuid(session));
+			switch_event_fire(&event);
+		}
+
+		switch_ivr_multi_threaded_bridge(session, other_session, NULL, NULL, NULL);
+	} else {
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+	}
+
+
+
+	return SWITCH_STATUS_FALSE;
 }
 
-static const switch_state_handler_table audio_bridge_peer_state_handlers = {
+static const switch_state_handler_table_t uuid_bridge_state_handlers = {
 	/*.on_init */ NULL,
-	/*.on_ring */ audio_bridge_on_ring,
+	/*.on_ring */ NULL,
 	/*.on_execute */ NULL,
 	/*.on_hangup */ NULL,
 	/*.on_loopback */ NULL,
-	/*.on_transmit */ NULL
+	/*.on_transmit */ uuid_bridge_on_transmit,
+	/*.on_hold */ NULL
 };
 
+struct key_collect {
+	char *key;
+	char *file;
+	switch_core_session_t *session;
+};
 
-SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_session *session, 
-															   switch_core_session *peer_session,
-															   unsigned int timelimit,
-															   switch_dtmf_callback_function dtmf_callback,
-															   void *session_data,
-															   void *peer_session_data)
-															   
 
-															   
+static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void *obj)
 {
-	struct switch_core_thread_session this_audio_thread, other_audio_thread;
-	switch_channel *caller_channel, *peer_channel;
-	time_t start;
-	int stream_id = 0;
-	switch_frame *read_frame = NULL;
+	struct key_collect *collect = (struct key_collect *) obj;
+	switch_channel_t *channel = switch_core_session_get_channel(collect->session);
+	char buf[10] = "";
+	char *p, term;
 
+
+	if (!strcasecmp(collect->key, "exec")) {
+		char *data;
+		const switch_application_interface_t *application_interface;
+		char *app_name, *app_data;
+
+		if (!(data = collect->file)) {
+			goto wbreak;
+		}
+
+		app_name = data;
+
+		if ((app_data = strchr(app_name, ' '))) {
+			*app_data++ = '\0';
+		}
+		
+		if ((application_interface = switch_loadable_module_get_application_interface(app_name)) == 0) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app_name);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			goto wbreak;
+		}
+
+		if (!application_interface->application_function) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n", app_name);
+			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+			goto wbreak;
+		}
+
+		application_interface->application_function(collect->session, app_data);
+		if (switch_channel_get_state(channel) < CS_HANGUP) {
+			switch_channel_set_flag(channel, CF_WINNER);
+		}
+		goto wbreak;
+	}
+
+	if (!switch_channel_ready(channel)) {
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		goto wbreak;
+	}
+
+	while(switch_channel_ready(channel)) {
+		memset(buf, 0, sizeof(buf));
+
+		if (collect->file) {
+
+			switch_ivr_play_file(collect->session, NULL, collect->file, NULL, NULL, buf, sizeof(buf));
+		} else {
+			switch_ivr_collect_digits_count(collect->session, buf, sizeof(buf), 1, "", &term, 0);
+		}
+
+		for(p = buf; *p; p++) {
+			if (*collect->key == *p) {
+				switch_channel_set_flag(channel, CF_WINNER);
+				goto wbreak;
+			}
+		}
+	}
+ wbreak:
+
+	return NULL;
+}
+
+static void launch_collect_thread(struct key_collect *collect)
+{
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
 	
+	switch_threadattr_create(&thd_attr, switch_core_session_get_pool(collect->session));
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, collect_thread_run, collect, switch_core_session_get_pool(collect->session));
+}
 
-	caller_channel = switch_core_session_get_channel(session);
-	assert(caller_channel != NULL);
+static uint8_t check_channel_status(switch_channel_t **peer_channels,
+									switch_core_session_t **peer_sessions,
+									uint32_t len,
+									int32_t *idx,
+									char *file,
+									char *key)
+{
 
-	switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
+	uint32_t i;
+	uint32_t hups = 0;	
+	*idx = -1;
+	
+	for (i = 0; i < len; i++) {
+		if (!peer_channels[i]) {
+			continue;
+		}
+		if (switch_channel_get_state(peer_channels[i]) >= CS_HANGUP) {
+			hups++;
+		} else if ((switch_channel_test_flag(peer_channels[i], CF_ANSWERED) || (len == 1 && switch_channel_test_flag(peer_channels[0], CF_EARLY_MEDIA))) && 
+				   !switch_channel_test_flag(peer_channels[i], CF_TAGGED)) {
 
-	peer_channel = switch_core_session_get_channel(peer_session);
-	assert(peer_channel != NULL);
+			if (key) {
+				struct key_collect *collect;
+				
+				if ((collect = switch_core_session_alloc(peer_sessions[i], sizeof(*collect)))) {
+					switch_channel_set_flag(peer_channels[i], CF_TAGGED);
+					collect->key = key;
+					if (file) {
+						collect->file = switch_core_session_strdup(peer_sessions[i], file);
+					}
+				
+					collect->session = peer_sessions[i];
+					launch_collect_thread(collect);
+				}
+			} else {
+				*idx = i;
+				return 0;
+					
+			}
+		} else if (switch_channel_test_flag(peer_channels[i], CF_WINNER)) {
+			*idx = i;
+			return 0;
+		}
+	}
 
-	memset(&other_audio_thread, 0, sizeof(other_audio_thread));
-	memset(&this_audio_thread, 0, sizeof(this_audio_thread));
-	other_audio_thread.objs[0] = session;
-	other_audio_thread.objs[1] = peer_session;
-	other_audio_thread.objs[2] = &stream_id;
-	other_audio_thread.objs[3] = (void *) dtmf_callback;
-	other_audio_thread.objs[4] = session_data;
-	other_audio_thread.objs[5] = &this_audio_thread;
-	other_audio_thread.running = 5;
+	if (hups == len) {
+		return 0;
+	} else {
+		return 1;
+	}
+	
+}
 
-	this_audio_thread.objs[0] = peer_session;
-	this_audio_thread.objs[1] = session;
-	this_audio_thread.objs[2] = &stream_id;
-	this_audio_thread.objs[3] = (void *) dtmf_callback;
-	this_audio_thread.objs[4] = peer_session_data;
-	this_audio_thread.objs[5] = &other_audio_thread;
-	this_audio_thread.running = 2;
+#define MAX_PEERS 256
+SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
+													 switch_core_session_t **bleg,
+													 switch_call_cause_t *cause,
+													 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 *peer_names[MAX_PEERS] = {0};
+	switch_core_session_t *peer_session, *peer_sessions[MAX_PEERS] = {0};
+	switch_caller_profile_t *caller_profiles[MAX_PEERS] = {0}, *caller_caller_profile;
+	char *chan_type = NULL, *chan_data;
+	switch_channel_t *peer_channel = NULL, *peer_channels[MAX_PEERS] = {0};
+	time_t start;
+	switch_frame_t *read_frame = NULL;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_channel_t *caller_channel = NULL;
+	switch_memory_pool_t *pool = NULL;
+	char *data = NULL;
+	int i, argc = 0;
+	int32_t idx = -1;
+	switch_codec_t write_codec = {0};
+	switch_frame_t write_frame = {0};
+	uint8_t err = 0, fdata[1024], pass = 0;
+	char *file = NULL, *key = NULL, *odata, *var;
 
+	write_frame.data = fdata;
+	
+	*bleg = NULL;
+	odata = strdup(bridgeto);
+	data = odata;
 
-	switch_channel_set_private(caller_channel, peer_session);
-	switch_channel_set_private(peer_channel, session);
-	switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
-	switch_core_session_thread_launch(peer_session);
-	time(&start);
+	if (!strncasecmp(data, "confirm=", 8)) {
+		data += 8;
+		file = data;
+		if ((data = strchr(file, ';'))) {
+			*data++ = '\0';
+			if ((key = strchr(file, ':'))) {
+				*key++ = '\0';
+			} else {
+				err++;
+			}
+		} else {
+			err++;
+		}
+	}
 
-	for (;;) {
-		int state = switch_channel_get_state(peer_channel);
-		if (state > CS_RING) {
-			break;
+	if (err) {
+		status = SWITCH_STATUS_GENERR;
+		goto done;
+	}
+
+	if (session) {
+		caller_channel = switch_core_session_get_channel(session);
+		assert(caller_channel != NULL);
+
+		switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
+
+		if ((var = switch_channel_get_variable(caller_channel, "group_confirm_key"))) {
+			key = switch_core_session_strdup(session, var);
+			if ((var = switch_channel_get_variable(caller_channel, "group_confirm_file"))) {
+				file = switch_core_session_strdup(session, var);
+			}
 		}
+	}
+	
+
+
+	if (file && !strcmp(file, "undef")) {
+		file = NULL;
+	}
+
+	argc = switch_separate_string(data, '&', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
+	
+	for (i = 0; i < argc; i++) {
 		
-		if (!switch_channel_ready(caller_channel)) {
-			break;
+		chan_type = peer_names[i];
+		if ((chan_data = strchr(chan_type, '/')) != 0) {
+			*chan_data = '\0';
+			chan_data++;
 		}
+	
+		if (session) {
+			if (!switch_channel_ready(caller_channel)) {
+				status = SWITCH_STATUS_FALSE;
+				goto done;
+			}
+
+			caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
+			
+			if (!cid_name_override) {
+				cid_name_override = caller_caller_profile->caller_id_name;
+			}
+			if (!cid_num_override) {
+				cid_num_override = caller_caller_profile->caller_id_number;
+			}
+
+			caller_profiles[i] = switch_caller_profile_new(switch_core_session_get_pool(session),
+														   caller_caller_profile->username,
+														   caller_caller_profile->dialplan,
+														   cid_name_override,
+														   cid_num_override,
+														   caller_caller_profile->network_addr, 
+														   NULL,
+														   NULL, 
+														   caller_caller_profile->rdnis,
+														   caller_caller_profile->source,
+														   caller_caller_profile->context,
+														   chan_data);
+			pool = NULL;
+		} else {
+			if (!cid_name_override) {
+				cid_name_override = "FreeSWITCH";
+			}
+			if (!cid_num_override) {
+				cid_num_override = "0000000000";
+			}
+
+			if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+				status = SWITCH_STATUS_TERM;
+				goto done;
+			}
+
+			if (caller_profile_override) {
+				caller_profiles[i] = switch_caller_profile_new(pool,
+															   caller_profile_override->username,
+															   caller_profile_override->dialplan,
+															   caller_profile_override->caller_id_name,
+															   caller_profile_override->caller_id_number,
+															   caller_profile_override->network_addr, 
+															   caller_profile_override->ani,
+															   caller_profile_override->ani2,
+															   caller_profile_override->rdnis,
+															   caller_profile_override->source,
+															   caller_profile_override->context,
+															   chan_data);
+			} else {
+				caller_profiles[i] = switch_caller_profile_new(pool,
+															   NULL,
+															   NULL,
+															   cid_name_override,
+															   cid_num_override,
+															   NULL,
+															   NULL, 
+															   NULL,
+															   NULL,
+															   __FILE__,
+															   NULL,
+															   chan_data);
+			}
+		}
+
+		if (switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], pool) != SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
+			if (pool) {
+				switch_core_destroy_memory_pool(&pool);
+			}
+			caller_profiles[i] = NULL;
+			peer_channels[i] = NULL;
+			peer_sessions[i] = NULL;
+			continue;
+		}
+
+		switch_core_session_read_lock(peer_sessions[i]);
+		pool = NULL;
+	
+		peer_channels[i] = switch_core_session_get_channel(peer_sessions[i]);
+		assert(peer_channels[i] != NULL);
 		
-		if ((time(NULL) - start) > timelimit) {
-			break;
+		if (table == &noop_state_handler) {
+			table = NULL;
+		} else if (!table) {
+			table = &audio_bridge_peer_state_handlers;
 		}
-		switch_yield(1000);
+
+		if (table) {
+			switch_channel_add_state_handler(peer_channels[i], table);
+		}
+
+		if (switch_core_session_running(peer_sessions[i])) {
+			switch_channel_set_state(peer_channels[i], CS_RING);
+		} else {
+			switch_core_session_thread_launch(peer_sessions[i]);
+		}
 	}
 
-	switch_channel_pre_answer(caller_channel);
-	
+	time(&start);
 
-	while (switch_channel_ready(caller_channel) &&
-		   switch_channel_ready(peer_channel) &&
-		   !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
-		   !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
-		   ((time(NULL) - start) < timelimit)) {
+	for (;;) {
+		uint32_t valid_channels = 0;
+		for (i = 0; i < argc; i++) {
+			int state;
+
+			if (!peer_channels[i]) {
+				continue;
+			}
+			valid_channels++;
+			state = switch_channel_get_state(peer_channels[i]);
+			
+			if (state >= CS_RING) {
+				goto endfor1;
+			}
 		
+			if (caller_channel && !switch_channel_ready(caller_channel)) {
+				break;
+			}
+		
+			if ((time(NULL) - start) > (time_t)timelimit_sec) {
+				break;
+			}
+			switch_yield(1000);
+		}
+
+		if (valid_channels == 0) {
+			status = SWITCH_STATUS_GENERR;
+			goto done;
+		}
+
+	}
+ endfor1:
+
+	if (session) {
+		switch_codec_t *read_codec = NULL;
+
+		switch_channel_pre_answer(caller_channel);
+		read_codec = switch_core_session_get_read_codec(session);
+
+		assert(read_codec != NULL);
+		if (!(pass = (uint8_t)switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
+			if (switch_core_codec_init(&write_codec,
+									   "L16",
+									   read_codec->implementation->samples_per_second,
+									   read_codec->implementation->microseconds_per_frame / 1000,
+									   1,
+									   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+									   NULL,
+									   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);
+				write_frame.codec = &write_codec;
+				write_frame.datalen = read_codec->implementation->bytes_per_frame;
+				write_frame.samples = write_frame.datalen / 2;
+				memset(write_frame.data, 255, write_frame.datalen);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!");
+				switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
+			}
+		}
+	}
+
+	while ((!caller_channel || switch_channel_ready(caller_channel)) && 
+		   check_channel_status(peer_channels, peer_sessions, argc, &idx, file, key) && ((time(NULL) - start) < (time_t)timelimit_sec)) {
+
 		/* read from the channel while we wait if the audio is up on it */
-		if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
-			if (switch_core_session_read_frame(session, &read_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
+		if (session && (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
+			switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+			
+			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-			if (read_frame) {
-				//memset(read_frame->data, 0, read_frame->datalen);
-				if (switch_core_session_write_frame(session, read_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
+			if (read_frame && !pass) {
+				if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
 					break;
 				}
 			}
@@ -917,17 +1920,142 @@
 		} else {
 			switch_yield(1000);
 		}
+		
+	}
 
+	if (session) {
+		switch_core_session_reset(session);
 	}
 
-	if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+	for (i = 0; i < argc; i++) {
+		if (!peer_channels[i]) {
+			continue;
+		}
+		if (i != idx) {
+			switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
+		}
+	}
+
+
+	if (idx > -1) {
+		peer_session = peer_sessions[idx];
+		peer_channel = peer_channels[idx];
+	} else {
+		status = SWITCH_STATUS_FALSE;
+		goto done;
+	}
+
+	if (caller_channel && switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
 		switch_channel_answer(caller_channel);
 	}
 
 	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
-		switch_event *event;
-		switch_core_session_message msg = {0};
+		*bleg = peer_session;
+		status = SWITCH_STATUS_SUCCESS;
+	} else {
+		status = SWITCH_STATUS_FALSE;
+	}
 
+ done:
+	*cause = SWITCH_CAUSE_UNALLOCATED;
+
+	if (status == SWITCH_STATUS_SUCCESS) {
+		if (caller_channel) {
+			switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted");
+		}
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n", switch_channel_get_name(peer_channel));
+	} else {
+		if (peer_channel) {
+			*cause = switch_channel_get_cause(peer_channel);
+		} else {
+			for (i = 0; i < argc; i++) {
+				if (!peer_channels[i]) {
+					continue;
+				}
+				
+				*cause = switch_channel_get_cause(peer_channels[i]);
+				break;
+			}
+		}
+		if (caller_channel) {
+			switch_channel_set_variable(caller_channel, "originate_disposition", switch_channel_cause2str(*cause));
+		}
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Error Cause: %d [%s]\n", *cause, switch_channel_cause2str(*cause));
+	}
+
+	if (odata) {
+		free(odata);
+	}
+	if (!pass && write_codec.implementation) {
+		switch_core_codec_destroy(&write_codec);
+	}
+
+	for (i = 0; i < argc; i++) {
+		if (!peer_channels[i]) {
+			continue;
+		}
+		switch_core_session_rwunlock(peer_sessions[i]);
+	}
+
+	return status;
+}
+
+
+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 input_callback,
+																 void *session_data,
+																 void *peer_session_data)
+	 
+
+															   
+{
+	switch_core_thread_session_t *this_audio_thread, *other_audio_thread;
+	switch_channel_t *caller_channel, *peer_channel;
+	int stream_id = 0;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	
+	caller_channel = switch_core_session_get_channel(session);
+	assert(caller_channel != NULL);
+
+	switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
+
+	peer_channel = switch_core_session_get_channel(peer_session);
+	assert(peer_channel != NULL);
+
+	other_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session_t));
+	this_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session_t));
+
+	other_audio_thread->objs[0] = session;
+	other_audio_thread->objs[1] = peer_session;
+	other_audio_thread->objs[2] = &stream_id;
+	other_audio_thread->objs[3] = (void *) input_callback;
+	other_audio_thread->objs[4] = session_data;
+	other_audio_thread->objs[5] = this_audio_thread;
+	other_audio_thread->running = 5;
+	switch_mutex_init(&other_audio_thread->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+
+	this_audio_thread->objs[0] = peer_session;
+	this_audio_thread->objs[1] = session;
+	this_audio_thread->objs[2] = &stream_id;
+	this_audio_thread->objs[3] = (void *) input_callback;
+	this_audio_thread->objs[4] = peer_session_data;
+	this_audio_thread->objs[5] = other_audio_thread;
+	this_audio_thread->running = 2;
+	switch_mutex_init(&this_audio_thread->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(peer_session));
+
+	switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
+
+	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
+		switch_channel_answer(caller_channel);
+	}
+
+	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+		switch_event_t *event;
+		switch_core_session_message_t msg = {0};
+		
+		switch_channel_set_state(peer_channel, CS_HOLD);
+
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(caller_channel, event);
 			switch_event_fire(&event);
@@ -936,23 +2064,149 @@
 		msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
 		msg.from = __FILE__;
 		msg.pointer_arg = session;
+
 		switch_core_session_receive_message(peer_session, &msg);
 		msg.pointer_arg = peer_session;
 		switch_core_session_receive_message(session, &msg);
-		
-		
-		switch_core_session_launch_thread(peer_session, audio_bridge_thread, (void *) &other_audio_thread);
-		audio_bridge_thread(NULL, (void *) &this_audio_thread);
 
-		msg.pointer_arg = NULL;
-		msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
-		switch_core_session_receive_message(peer_session, &msg);
-		switch_core_session_receive_message(session, &msg);
-		
-		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
-			switch_channel_event_set_data(caller_channel, event);
-			switch_event_fire(&event);
+		if (switch_core_session_read_lock(peer_session) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_set_private(peer_channel, "_bridge_", other_audio_thread);
+			switch_channel_set_state(peer_channel, CS_LOOPBACK);
+			audio_bridge_thread(NULL, (void *) this_audio_thread);
+
+			if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
+				switch_channel_event_set_data(caller_channel, event);
+				switch_event_fire(&event);
+			}
+
+			if (switch_channel_get_state(caller_channel) != CS_EXECUTE && !switch_channel_test_flag(caller_channel, CF_TRANSFER)) {
+				switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_CLEARING);
+			}
+
+			this_audio_thread->objs[0] = NULL;
+			this_audio_thread->objs[1] = NULL;
+			this_audio_thread->objs[2] = NULL;
+			this_audio_thread->objs[3] = NULL;
+			this_audio_thread->objs[4] = NULL;
+			this_audio_thread->objs[5] = NULL;
+			switch_mutex_lock(this_audio_thread->mutex);
+			this_audio_thread->running = 0;
+			switch_mutex_unlock(this_audio_thread->mutex);
+			
+			switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
+
+			if (other_audio_thread->running > 0) {
+				switch_mutex_lock(other_audio_thread->mutex);
+				other_audio_thread->running = -1;
+				switch_mutex_unlock(other_audio_thread->mutex);
+				while (other_audio_thread->running) {
+					switch_yield(1000);
+				}
+			}
+			switch_core_session_rwunlock(peer_session);
+			
+		} else {
+			status = SWITCH_STATUS_FALSE;
 		}
+	} else {
+		status = SWITCH_STATUS_FALSE;
 	}
-	return SWITCH_STATUS_SUCCESS;
+
+	if (status != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bridge Failed %s->%s\n", 
+						  switch_channel_get_name(caller_channel),
+						  switch_channel_get_name(peer_channel)
+						  );
+		switch_channel_hangup(peer_channel, SWITCH_CAUSE_NO_ANSWER);
+	}
+
+	return status;
 }
+
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(char *originator_uuid, char *originatee_uuid)
+{
+	switch_core_session_t *originator_session, *originatee_session;
+	switch_channel_t *originator_channel, *originatee_channel;
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	if ((originator_session = switch_core_session_locate(originator_uuid))) {
+		if ((originatee_session = switch_core_session_locate(originatee_uuid))) { 
+			originator_channel = switch_core_session_get_channel(originator_session);
+			originatee_channel = switch_core_session_get_channel(originatee_session);
+
+			/* override transmit state for originator_channel to bridge to originatee_channel 
+			 * install pointer to originatee_session into originator_channel
+			 * set CF_TRANSFER on both channels and change state to CS_TRANSMIT to
+			 * inturrupt anything they are already doing.
+			 * originatee_session will fall asleep and originator_session will bridge to it
+			 */
+			
+			switch_channel_clear_state_handler(originator_channel, NULL);
+			switch_channel_clear_state_handler(originatee_channel, NULL);
+			switch_channel_set_flag(originator_channel, CF_ORIGINATOR);
+			switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
+			switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
+			switch_channel_set_private(originator_channel, "_uuid_bridge_", originatee_session);
+
+			/* switch_channel_set_state_flag sets flags you want to be set when the next stat change happens */
+			switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
+			switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);
+
+			/* release the read locks we have on the channels */
+			switch_core_session_rwunlock(originator_session);
+			switch_core_session_rwunlock(originatee_session);
+
+			/* change the states and let the chips fall where they may */
+			switch_channel_set_state(originator_channel, CS_TRANSMIT);
+			switch_channel_set_state(originatee_channel, CS_TRANSMIT);
+			
+		} else {
+			switch_core_session_rwunlock(originator_session);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no channel for uuid %s\n", originatee_uuid);
+		}
+	}
+
+	return status;
+
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context)
+{
+	switch_channel_t *channel;
+	switch_caller_profile_t *profile, *new_profile;
+
+	assert(session != NULL);
+	assert(extension != NULL);
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if ((profile = switch_channel_get_caller_profile(channel))) {
+		new_profile = switch_caller_profile_clone(session, profile);
+		new_profile->destination_number = switch_core_session_strdup(session, extension);
+
+		if (dialplan) {
+			new_profile->dialplan = switch_core_session_strdup(session, dialplan);
+		} else {
+			dialplan = new_profile->dialplan;
+		}
+
+		if (context) {
+			new_profile->context = switch_core_session_strdup(session, context);
+		} else {
+			context = new_profile->context;
+		}
+
+		switch_channel_set_caller_profile(channel, new_profile);
+		switch_channel_set_flag(channel, CF_TRANSFER);
+		switch_channel_set_state(channel, CS_RING);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Transfer %s to %s[%s@%s]\n", 
+						  switch_channel_get_name(channel), dialplan, extension, context); 
+		return SWITCH_STATUS_SUCCESS;
+	} 
+
+	return SWITCH_STATUS_FALSE;
+}
+
+

Modified: freeswitch/branches/voctel/src/switch_loadable_module.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_loadable_module.c	(original)
+++ freeswitch/branches/voctel/src/switch_loadable_module.c	Fri Sep 22 14:22:15 2006
@@ -30,53 +30,40 @@
  *
  */
 #include <switch.h>
+#include <ctype.h>
 
-
-typedef switch_status (*switch_module_load_t) (switch_loadable_module_interface **, char *);
-typedef switch_status (*switch_module_reload_t) (void);
-typedef switch_status (*switch_module_pause_t) (void);
-typedef switch_status (*switch_module_resume_t) (void);
-typedef switch_status (*switch_module_status_t) (void);
-typedef switch_status (*switch_module_runtime_t) (void);
-typedef switch_status (*switch_module_shutdown_t) (void);
-
-
 struct switch_loadable_module {
 	char *filename;
-	const switch_loadable_module_interface *interface;
+	const switch_loadable_module_interface_t *module_interface;
 	void *lib;
 	switch_module_load_t switch_module_load;
-	switch_module_reload_t switch_module_reload;
-	switch_module_pause_t switch_module_pause;
-	switch_module_resume_t switch_module_resume;
-	switch_module_status_t switch_module_status;
 	switch_module_runtime_t switch_module_runtime;
 	switch_module_shutdown_t switch_module_shutdown;
 };
 
 struct switch_loadable_module_container {
-	switch_hash *module_hash;
-	switch_hash *endpoint_hash;
-	switch_hash *codec_hash;
-	switch_hash *dialplan_hash;
-	switch_hash *timer_hash;
-	switch_hash *application_hash;
-	switch_hash *api_hash;
-	switch_hash *file_hash;
-	switch_hash *speech_hash;
-	switch_hash *directory_hash;
-	switch_memory_pool *pool;
+	switch_hash_t *module_hash;
+	switch_hash_t *endpoint_hash;
+	switch_hash_t *codec_hash;
+	switch_hash_t *dialplan_hash;
+	switch_hash_t *timer_hash;
+	switch_hash_t *application_hash;
+	switch_hash_t *api_hash;
+	switch_hash_t *file_hash;
+	switch_hash_t *speech_hash;
+	switch_hash_t *directory_hash;
+	switch_memory_pool_t *pool;
 };
 
 static struct switch_loadable_module_container loadable_modules;
 
-static void *switch_loadable_module_exec(switch_thread *thread, void *obj)
+static void *switch_loadable_module_exec(switch_thread_t *thread, void *obj)
 {
 
 
-	switch_status status = SWITCH_STATUS_SUCCESS;
-	switch_core_thread_session *ts = obj;
-	switch_loadable_module *module = ts->objs[0];
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_core_thread_session_t *ts = obj;
+	switch_loadable_module_t *module = ts->objs[0];
 	int restarts;
 
 	assert(thread != NULL);
@@ -85,11 +72,11 @@
 	for (restarts = 0; status != SWITCH_STATUS_TERM; restarts++) {
 		status = module->switch_module_runtime();
 	}
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread ended for %s\n", module->interface->module_name);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Thread ended for %s\n", module->module_interface->module_name);
 
 	if (ts->pool) {
-		switch_memory_pool *pool = ts->pool;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroying Pool for %s\n", module->interface->module_name);
+		switch_memory_pool_t *pool = ts->pool;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroying Pool for %s\n", module->module_interface->module_name);
 		switch_core_destroy_memory_pool(&pool);
 	}
 	switch_yield(1000000);
@@ -97,26 +84,170 @@
 }
 
 
-typedef switch_status (*switch_load_fp_t)(switch_loadable_module_interface **, char *);
 
-static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool,
-													  switch_loadable_module **new_module)
+
+
+static switch_status_t switch_loadable_module_process(char *key, switch_loadable_module_t *new_module)
 {
-	switch_loadable_module *module = NULL;
+	switch_event_t *event;
+
+	switch_core_hash_insert(loadable_modules.module_hash, key, new_module);
+
+	if (new_module->module_interface->endpoint_interface) {
+		const switch_endpoint_interface_t *ptr;
+		for (ptr = new_module->module_interface->endpoint_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Endpoint '%s'\n", ptr->interface_name);
+			switch_core_hash_insert(loadable_modules.endpoint_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->codec_interface) {
+		const switch_codec_implementation_t *impl;
+		const switch_codec_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->codec_interface; ptr; ptr = ptr->next) {
+			for (impl = ptr->implementations; impl; impl = impl->next) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+								  "Adding Codec '%s' (%s) %dhz %dms\n",
+								  impl->iananame,
+								  ptr->interface_name,
+								  impl->samples_per_second, impl->microseconds_per_frame / 1000);
+				if (!switch_core_hash_find(loadable_modules.codec_hash, (char *) impl->iananame)) {
+					switch_core_hash_insert(loadable_modules.codec_hash, (char *) impl->iananame, (void *) ptr);
+				}
+			}
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "codec");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			
+		}
+	}
+
+	if (new_module->module_interface->dialplan_interface) {
+		const switch_dialplan_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->dialplan_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Dialplan '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "dialplan");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.dialplan_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->timer_interface) {
+		const switch_timer_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->timer_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Timer '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "timer");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.timer_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->application_interface) {
+		const switch_application_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->application_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Application '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "application");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.application_hash,
+									(char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->api_interface) {
+		const switch_api_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->api_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding API Function '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "api");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.api_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->file_interface) {
+		const switch_file_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->file_interface; ptr; ptr = ptr->next) {
+			int i;
+			for (i = 0; ptr->extens[i]; i++) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding File Format '%s'\n", ptr->extens[i]);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "file");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->extens[i]);
+				switch_event_fire(&event);
+			}
+				switch_core_hash_insert(loadable_modules.file_hash, (char *) ptr->extens[i], (void *) ptr);
+			}
+		}
+	}
+
+	if (new_module->module_interface->speech_interface) {
+		const switch_speech_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->speech_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Speech interface '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "speech");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.speech_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+
+	if (new_module->module_interface->directory_interface) {
+		const switch_directory_interface_t *ptr;
+
+		for (ptr = new_module->module_interface->directory_interface; ptr; ptr = ptr->next) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Directory interface '%s'\n", ptr->interface_name);
+			if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "directory");
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+				switch_event_fire(&event);
+			}
+			switch_core_hash_insert(loadable_modules.directory_hash, (char *) ptr->interface_name, (void *) ptr);
+		}
+	}
+	
+
+	return SWITCH_STATUS_SUCCESS;
+
+}
+
+static switch_status_t switch_loadable_module_load_file(char *filename, switch_loadable_module_t **new_module)
+{
+	switch_loadable_module_t *module = NULL;
 	apr_dso_handle_t *dso = NULL;
 	apr_status_t status = SWITCH_STATUS_SUCCESS;
 	apr_dso_handle_sym_t function_handle = NULL;
-	//switch_status (*load_func_ptr) (switch_loadable_module_interface **, char *) = NULL;
-	switch_load_fp_t load_func_ptr = NULL;
+	switch_module_load_t load_func_ptr = NULL;
 	int loading = 1;
 	const char *err = NULL;
-	switch_loadable_module_interface *interface = NULL;
+	switch_loadable_module_interface_t *module_interface = NULL;
 	char derr[512] = "";
 
 	assert(filename != NULL);
 
 	*new_module = NULL;
-	status = apr_dso_load(&dso, filename, pool);
+	status = apr_dso_load(&dso, filename, loadable_modules.pool);
 
 	while (loading) {
 		if (status != APR_SUCCESS) {
@@ -126,20 +257,20 @@
 		}
 
 		status = apr_dso_sym(&function_handle, dso, "switch_module_load");
-		load_func_ptr = (switch_load_fp_t) function_handle;
+		load_func_ptr = (switch_module_load_t) function_handle;
 
 		if (load_func_ptr == NULL) {
 			err = "Cannot Load";
 			break;
 		}
 
-		if (load_func_ptr(&interface, filename) != SWITCH_STATUS_SUCCESS) {
+		if (load_func_ptr(&module_interface, filename) != SWITCH_STATUS_SUCCESS) {
 			err = "Module load routine returned an error";
-			interface = NULL;
+			module_interface = NULL;
 			break;
 		}
 
-		if ((module = switch_core_permenant_alloc(sizeof(switch_loadable_module))) == 0) {
+		if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) {
 			err = "Could not allocate memory\n";
 			break;
 		}
@@ -152,26 +283,10 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	module->filename = switch_core_permenant_strdup(filename);
-	module->interface = interface;
+	module->filename = switch_core_permanent_strdup(filename);
+	module->module_interface = module_interface;
 	module->switch_module_load = load_func_ptr;
 
-	if ((status = apr_dso_sym(&function_handle, dso, "switch_module_reload")) == APR_SUCCESS) {
-		module->switch_module_reload = (switch_module_reload_t) function_handle;
-	}
-
-	if ((status = apr_dso_sym(&function_handle, dso, "switch_module_pause")) == APR_SUCCESS) {
-		module->switch_module_pause = (switch_module_pause_t) function_handle;
-	}
-
-	if ((status = apr_dso_sym(&function_handle, dso, "switch_module_resume")) == APR_SUCCESS) {
-		module->switch_module_resume = (switch_module_resume_t) function_handle;
-	}
-
-	if ((status = apr_dso_sym(&function_handle, dso, "switch_module_status")) == APR_SUCCESS) {
-		module->switch_module_status = (switch_module_status_t) function_handle;
-	}
-
 	if ((status = apr_dso_sym(&function_handle, dso, "switch_module_shutdown")) == APR_SUCCESS) {
 		module->switch_module_shutdown = (switch_module_shutdown_t) function_handle;
 	}
@@ -187,18 +302,19 @@
 	}
 
 	*new_module = module;
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", interface->module_name);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", module_interface->module_name);
 
 	return SWITCH_STATUS_SUCCESS;
 
 }
 
-static void process_module_file(char *dir, char *fname)
+SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname)
 {
 	switch_size_t len = 0;
 	char *path;
 	char *file;
-	switch_loadable_module *new_module = NULL;
+	switch_loadable_module_t *new_module = NULL;
+	switch_status_t status;
 
 #ifdef WIN32
 	const char *ext = ".dll";
@@ -210,7 +326,7 @@
 
 
 	if ((file = switch_core_strdup(loadable_modules.pool, fname)) == 0) {
-		return;
+		return SWITCH_STATUS_FALSE;
 	}
 
 	if (*file == '/') {
@@ -230,103 +346,73 @@
 			snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext);
 		}
 	}
+	
+	if ((status = switch_loadable_module_load_file(path, &new_module) == SWITCH_STATUS_SUCCESS)) {
+		return switch_loadable_module_process((char *) file, new_module);
+	} else {
+		return status;
+	}
+}
 
-	if (switch_loadable_module_load_file(path, loadable_modules.pool, &new_module) == SWITCH_STATUS_SUCCESS) {
-		switch_core_hash_insert(loadable_modules.module_hash, (char *) file, new_module);
+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_loadable_module_t *module = NULL; 
+	switch_module_load_t load_func_ptr = NULL; 
+	int loading = 1; 
+	const char *err = NULL; 
+	switch_loadable_module_interface_t *module_interface = NULL; 
 
-		if (new_module->interface->endpoint_interface) {
-			const switch_endpoint_interface *ptr;
-			for (ptr = new_module->interface->endpoint_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Endpoint '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.endpoint_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
+	if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) { 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Couldn't allocate memory\n"); 
+		return SWITCH_STATUS_GENERR; 
+	} 
 
-		if (new_module->interface->codec_interface) {
-			const switch_codec_implementation *impl;
-			const switch_codec_interface *ptr;
-
-			for (ptr = new_module->interface->codec_interface; ptr; ptr = ptr->next) {
-				for (impl = ptr->implementations; impl; impl = impl->next) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-										  "Adding Codec '%s' (%s) %dkhz %dms\n",
-										  ptr->iananame,
-										  ptr->interface_name,
-										  impl->samples_per_second, impl->microseconds_per_frame / 1000);
-				}
-
-				switch_core_hash_insert(loadable_modules.codec_hash, (char *) ptr->iananame, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->dialplan_interface) {
-			const switch_dialplan_interface *ptr;
-
-			for (ptr = new_module->interface->dialplan_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Dialplan '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.dialplan_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->timer_interface) {
-			const switch_timer_interface *ptr;
-
-			for (ptr = new_module->interface->timer_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Timer '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.timer_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->application_interface) {
-			const switch_application_interface *ptr;
-
-			for (ptr = new_module->interface->application_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Application '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.application_hash,
-										(char *) ptr->interface_name, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->api_interface) {
-			const switch_api_interface *ptr;
-
-			for (ptr = new_module->interface->api_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding API Function '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.api_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->file_interface) {
-			const switch_file_interface *ptr;
-
-			for (ptr = new_module->interface->file_interface; ptr; ptr = ptr->next) {
-				int i;
-				for (i = 0; ptr->extens[i]; i++) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding File Format '%s'\n", ptr->extens[i]);
-					switch_core_hash_insert(loadable_modules.file_hash, (char *) ptr->extens[i], (void *) ptr);
-				}
-			}
-		}
-
-		if (new_module->interface->speech_interface) {
-			const switch_speech_interface *ptr;
-
-			for (ptr = new_module->interface->speech_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Speech interface '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.speech_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
-
-		if (new_module->interface->directory_interface) {
-			const switch_directory_interface *ptr;
-
-			for (ptr = new_module->interface->directory_interface; ptr; ptr = ptr->next) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Directory interface '%s'\n", ptr->interface_name);
-				switch_core_hash_insert(loadable_modules.directory_hash, (char *) ptr->interface_name, (void *) ptr);
-			}
-		}
+	while (loading) { 
+  		load_func_ptr = (switch_module_load_t) switch_module_load; 
+  
+		if (load_func_ptr == NULL) { 
+			err = "Cannot Load"; 
+			break; 
+		} 
+  
+		if (load_func_ptr(&module_interface, filename) != SWITCH_STATUS_SUCCESS) { 
+			err = "Module load routine returned an error"; 
+			module_interface = NULL; 
+			break; 
+		} 
+  
+		if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) { 
+			err = "Could not allocate memory\n"; 
+			break; 
+		} 
+  
+		loading = 0; 
 	}
-}
+  
+	if (err) { 
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error Loading module %s\n**%s**\n", filename, err); 
+		return SWITCH_STATUS_GENERR; 
+	} 
+  
+	module->filename = switch_core_permanent_strdup(filename); 
+	module->module_interface = module_interface; 
+	module->switch_module_load = load_func_ptr; 
+  
+	if (switch_module_shutdown) { 
+		module->switch_module_shutdown = switch_module_shutdown; 
+	} 
+	if (switch_module_runtime) { 
+		module->switch_module_runtime = switch_module_runtime; 
+	} 
+	if (module->switch_module_runtime) { 
+		switch_core_launch_thread(switch_loadable_module_exec, module, loadable_modules.pool); 
+	} 
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Successfully Loaded [%s]\n", module_interface->module_name); 
+	return switch_loadable_module_process((char *) module->filename, module);
+} 
 
 #ifdef WIN32
 static void switch_loadable_module_path_init()
@@ -346,15 +432,15 @@
 }
 #endif
 
-SWITCH_DECLARE(switch_status) switch_loadable_module_init()
+SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
 {
 
 	apr_finfo_t finfo = {0};
 	apr_dir_t *module_dir_handle = NULL;
 	apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME;
 	char *cf = "modules.conf";
-	char *var, *val;
-	switch_config cfg;
+	char *pcf = "post_load_modules.conf";
+	switch_xml_t cfg, xml;
 	unsigned char all = 0;
 	unsigned int count = 0;
 
@@ -388,49 +474,57 @@
 	switch_core_hash_init(&loadable_modules.directory_hash, loadable_modules.pool);
 	switch_core_hash_init(&loadable_modules.dialplan_hash, loadable_modules.pool);
 
+	if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+		switch_xml_t mods, ld;
 
-	if (switch_config_open_file(&cfg, cf)) {
-		while (switch_config_next_pair(&cfg, &var, &val)) {
-			count++;
-
-			if (!strcasecmp(cfg.category, "modules")) {
-				if (!strcasecmp(var, "load")) {
-					if (!strcasecmp(val, "all")) {
-						if (count == 1) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading all modules.\n");
-							all = 1;
-							break;
-						} else {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "This option must be the first one to work.\n");
-						}
-					} else {
-						if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
-							continue;
-						}
-						process_module_file((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
-					}
+		if ((mods = switch_xml_child(cfg, "modules"))) {
+			for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
+				const char *val = switch_xml_attr_soft(ld, "module");
+				if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
+					continue;
 				}
+				switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
+				count++;
 			}
 		}
-		switch_config_close_file(&cfg);
+		switch_xml_free(xml);
+		
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", cf);
-		all = 1;
 	}
 
-	if (!count && !all) {
-		all = 1;
+	if ((xml = switch_xml_open_cfg(pcf, &cfg, NULL))) {
+		switch_xml_t mods, ld;
+
+		if ((mods = switch_xml_child(cfg, "modules"))) {
+			for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
+				const char *val = switch_xml_attr_soft(ld, "module");
+				if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
+					continue;
+				}
+				switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
+				count++;
+			}
+		}
+		switch_xml_free(xml);
+		
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "open of %s failed\n", pcf);
 	}
 
+	if (!count) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "No modules loaded assuming 'load all'\n");
+		all = 1;
+	}
+	
 	if (all) {
 		if (apr_dir_open(&module_dir_handle, SWITCH_GLOBAL_dirs.mod_dir, loadable_modules.pool) != APR_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", SWITCH_GLOBAL_dirs.mod_dir);
 			return SWITCH_STATUS_GENERR;
 		}
-	}
 
-	if (all) {
 		while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) {
 			const char *fname = finfo.fname;
 
@@ -450,11 +544,12 @@
 				continue;
 			}
 
-			process_module_file((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) fname);
+			switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) fname);
 		}
 		apr_dir_close(module_dir_handle);
 	}
 
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -462,12 +557,12 @@
 {
 	switch_hash_index_t *hi;
 	void *val;
-	switch_loadable_module *module;
+	switch_loadable_module_t *module;
 
 	for (hi = switch_hash_first(loadable_modules.pool, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
 		switch_hash_this(hi, NULL, NULL, &val);
-		module = (switch_loadable_module *) val;
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Checking %s\t", module->interface->module_name);
+		module = (switch_loadable_module_t *) val;
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Checking %s\t", module->module_interface->module_name);
 		if (module->switch_module_shutdown) {
 			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "(yes)\n");
 			module->switch_module_shutdown();
@@ -478,61 +573,78 @@
 
 }
 
-SWITCH_DECLARE(switch_endpoint_interface *) switch_loadable_module_get_endpoint_interface(char *name)
+SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.endpoint_hash, name);
 }
 
-SWITCH_DECLARE(switch_codec_interface *) switch_loadable_module_get_codec_interface(char *name)
+SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name)
 {
-	return switch_core_hash_find(loadable_modules.codec_hash, name);
+	char altname[256] = "";
+	switch_codec_interface_t *codec;
+	switch_size_t x;
+	
+	if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, name))) {
+		for(x = 0; x < strlen(name); x++) {
+			altname[x] = (char)toupper(name[x]);
+		}
+		if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, altname))) {
+			for(x = 0; x < strlen(name); x++) {
+				altname[x] = (char)tolower(name[x]);
+			}
+			codec = switch_core_hash_find(loadable_modules.codec_hash, altname);
+		}
+	}
+	return codec;
 }
 
-SWITCH_DECLARE(switch_dialplan_interface *) switch_loadable_module_get_dialplan_interface(char *name)
+SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.dialplan_hash, name);
 }
 
-SWITCH_DECLARE(switch_timer_interface *) switch_loadable_module_get_timer_interface(char *name)
+SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.timer_hash, name);
 }
 
-SWITCH_DECLARE(switch_application_interface *) switch_loadable_module_get_application_interface(char *name)
+SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.application_hash, name);
 }
 
-SWITCH_DECLARE(switch_api_interface *) switch_loadable_module_get_api_interface(char *name)
+SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.api_hash, name);
 }
 
-SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interface(char *name)
+SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.file_hash, name);
 }
 
-SWITCH_DECLARE(switch_speech_interface *) switch_loadable_module_get_speech_interface(char *name)
+SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.speech_hash, name);
 }
 
-SWITCH_DECLARE(switch_directory_interface *) switch_loadable_module_get_directory_interface(char *name)
+SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name)
 {
 	return switch_core_hash_find(loadable_modules.directory_hash, name);
 }
 
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array,
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
 													  int arraylen)
 {
 	switch_hash_index_t *hi;
 	void *val;
+	switch_codec_interface_t *codec_interface;
 	int i = 0;
 
 	for (hi = switch_hash_first(pool, loadable_modules.codec_hash); hi; hi = switch_hash_next(hi)) {
 		switch_hash_this(hi, NULL, NULL, &val);
-		array[i++] = val;
+		codec_interface = (switch_codec_interface_t *) val;
+		array[i++] = codec_interface->implementations;
 		if (i > arraylen) {
 			break;
 		}
@@ -542,46 +654,95 @@
 
 }
 
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface **array,
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array,
 															 int arraylen, char **prefs, int preflen)
 {
 	int x, i = 0;
-	switch_codec_interface *codec_interface;
+	switch_codec_interface_t *codec_interface;
+	const switch_codec_implementation_t *imp;
 
-	for (x = 0; x < preflen; x++) {
-		if ((codec_interface = switch_loadable_module_get_codec_interface(prefs[x])) != 0 ) {
-			array[i++] = codec_interface;
-			if (i > arraylen) {
+    for (x = 0; x < preflen; x++) {
+		char *cur, *last = NULL, *next = NULL, *name, *p, buf[256];
+		uint32_t interval = 0, rate = 0;
+
+		switch_copy_string(buf, prefs[x], sizeof(buf));
+		last = name = next = cur = buf;
+
+		for (;;) {
+			if (!next) {
 				break;
 			}
+			if ((p = strchr(next, '@'))) {
+				*p++ = '\0';
+			}
+			next = p;
+			if (cur != name) {
+				if (strchr(cur, 'i')) {
+					interval = atoi(cur);
+				} else if (strchr(cur, 'k')) {
+					rate = atoi(cur);
+				}
+			}
+			cur = next;
 		}
-	}
 
+        if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0 ) {
+			for (imp = codec_interface->implementations; imp; imp = imp->next) {
+				uint8_t match = 1;
+
+				if (interval && (uint32_t)(imp->microseconds_per_frame / 1000) != interval) {
+					match = 0;
+				}
+
+				if (match && rate && (uint32_t)imp->samples_per_second != rate) {
+					match = 0;
+				}
+
+				if (match) {
+					array[i++] = imp;
+				}
+			}
+            if (i > arraylen) {
+                break;
+            }
+        }
+    }
+
 	return i;
 }
 
-SWITCH_DECLARE(switch_status) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len)
+SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	switch_api_interface *api;
-	switch_status status;
-	switch_event *event;
+	switch_api_interface_t *api;
+	switch_status_t status;
 
-	if ((api = switch_loadable_module_get_api_interface(cmd)) != 0) {
-		status = api->function(arg, retbuf, len);
-	} else {
-		status = SWITCH_STATUS_FALSE;
-		snprintf(retbuf, len, "INVALID COMMAND [%s]", cmd);
+	assert(stream != NULL);
+	assert(stream->data != NULL);
+	assert(stream->write_function != NULL);
+
+	if (!stream->event) {
+		switch_event_create(&stream->event, SWITCH_EVENT_API);
 	}
 
-	if (switch_event_create(&event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
+	if (stream->event) {
 		if (cmd) {
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
+			switch_event_add_header(stream->event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
 		}
 		if (arg) {
-			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "API-Command-Arguement", arg);
+			switch_event_add_header(stream->event, SWITCH_STACK_BOTTOM, "API-Command-Arguement", arg);
 		}
-		switch_event_add_body(event, retbuf);
-		switch_event_fire(&event);
+	}
+
+	if ((api = switch_loadable_module_get_api_interface(cmd)) != 0) {
+		status = api->function(arg, session, stream);
+	} else {
+		status = SWITCH_STATUS_FALSE;
+		stream->write_function(stream, "INVALID COMMAND [%s]", cmd);
+		//snprintf(retbuf, len, "INVALID COMMAND [%s]", cmd);
+	}
+
+	if (stream->event) {
+		switch_event_fire(&stream->event);
 	}
 
 

Modified: freeswitch/branches/voctel/src/switch_log.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_log.c	(original)
+++ freeswitch/branches/voctel/src/switch_log.c	Fri Sep 22 14:22:15 2006
@@ -46,35 +46,35 @@
 };
 
 struct switch_log_binding {
-	switch_log_function function;
-	switch_log_level level;
+	switch_log_function_t function;
+	switch_log_level_t level;
 	struct switch_log_binding *next;
 };
 
-typedef struct switch_log_binding switch_log_binding;
+typedef struct switch_log_binding switch_log_binding_t;
 
-static switch_memory_pool *LOG_POOL = NULL;
-static switch_log_binding *BINDINGS = NULL;
+static switch_memory_pool_t *LOG_POOL = NULL;
+static switch_log_binding_t *BINDINGS = NULL;
 static switch_mutex_t *BINDLOCK = NULL;
 static switch_queue_t *LOG_QUEUE = NULL;
 static int8_t THREAD_RUNNING = 0;
 static uint8_t MAX_LEVEL = 0;
 
-SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level level)
+SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
 {
 	return LEVELS[level];
 }
 
-SWITCH_DECLARE(switch_log_level) switch_log_str2level(const char *str)
+SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str)
 {
 	int x = 0;
-	switch_log_level level = SWITCH_LOG_DEBUG;
+	switch_log_level_t level = SWITCH_LOG_DEBUG;
 	for(x = 0;;x++) {
 		if (!LEVELS[x]) {
 			break;
 		}
 		if (!strcasecmp(LEVELS[x], str)) {
-			level = (switch_log_level) x;
+			level = (switch_log_level_t) x;
 			break;
 		}
 	}
@@ -82,9 +82,9 @@
 	return level;
 }
 
-SWITCH_DECLARE(switch_status) switch_log_bind_logger(switch_log_function function, switch_log_level level)
+SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level)
 {
-	switch_log_binding *binding = NULL, *ptr = NULL;
+	switch_log_binding_t *binding = NULL, *ptr = NULL;
 	assert(function != NULL);
 
 	if (!(binding = switch_core_alloc(LOG_POOL, sizeof(*binding)))) {
@@ -111,17 +111,17 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void *SWITCH_THREAD_FUNC log_thread(switch_thread *thread, void *obj)
+static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
 {
 
 	/* To Be or Not To Be */
 	assert(obj == NULL || obj != NULL);
 	THREAD_RUNNING = 1;
 
-	for(;;) {
+	while(THREAD_RUNNING == 1) {
 		void *pop = NULL;
-		switch_log_node *node = NULL;
-		switch_log_binding *binding;
+		switch_log_node_t *node = NULL;
+		switch_log_binding_t *binding;
 		
 		if (switch_queue_pop(LOG_QUEUE, &pop) != SWITCH_STATUS_SUCCESS) {
 			break;
@@ -131,7 +131,7 @@
 			break;
 		}
 		
-		node = (switch_log_node *) pop;
+		node = (switch_log_node_t *) pop;
 
 		switch_mutex_lock(BINDLOCK);
 		for(binding = BINDINGS; binding; binding = binding->next) {
@@ -156,12 +156,13 @@
 			free(node);
 		}
 	}
+
 	THREAD_RUNNING = 0;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Logger Ended.\n");
 	return NULL;
 }
 
-SWITCH_DECLARE(void) switch_log_printf(switch_text_channel channel, char *file, const char *func, int line, switch_log_level level, char *fmt, ...)
+SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file, const char *func, int line, switch_log_level_t level, char *fmt, ...)
 {
 	char *data = NULL;
 	char *new_fmt = NULL;
@@ -211,7 +212,7 @@
 		}
 
 		if (channel == SWITCH_CHANNEL_ID_EVENT) {
-				switch_event *event;
+				switch_event_t *event;
 				if (switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
@@ -221,23 +222,23 @@
 					switch_event_fire(&event);
 				}
 		} else {
-			if (level == SWITCH_LOG_CONSOLE || !THREAD_RUNNING) {
+			if (level == SWITCH_LOG_CONSOLE || !LOG_QUEUE || !THREAD_RUNNING) {
 				fprintf(handle, data);
-			} 
-
-			if (level <= MAX_LEVEL) {
-				switch_log_node *node = malloc(sizeof(*node));
-				node->data = data;
-				node->file = strdup(filep);
-				node->func = strdup(func);
-				node->line = line;
-				node->level = level;
-				node->content = content;
-				node->timestamp = now;
-				switch_queue_push(LOG_QUEUE, node);
-			} else {
 				free(data);
-			}
+			} else if (level <= MAX_LEVEL) {
+				switch_log_node_t *node;
+
+				if ((node = malloc(sizeof(*node)))) {
+					node->data = data;
+					node->file = strdup(filep);
+					node->func = strdup(func);
+					node->line = line;
+					node->level = level;
+					node->content = content;
+					node->timestamp = now;
+					switch_queue_push(LOG_QUEUE, node);
+				}
+			} 
 		}
 	}
 
@@ -249,9 +250,9 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_log_init(switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool)
 {
-	switch_thread *thread;
+	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr;;
 
 	assert(pool != NULL);
@@ -262,8 +263,9 @@
 	switch_threadattr_detach_set(thd_attr, 1);
 
 
-	switch_queue_create(&LOG_QUEUE, 2000, LOG_POOL);
+	switch_queue_create(&LOG_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
 	switch_mutex_init(&BINDLOCK, SWITCH_MUTEX_NESTED, LOG_POOL);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 	switch_thread_create(&thread, thd_attr, log_thread, NULL, LOG_POOL);
 
 	while (!THREAD_RUNNING) {
@@ -272,9 +274,13 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_log_shutdown(void)
+SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
 {
+	THREAD_RUNNING = -1;
 	switch_queue_push(LOG_QUEUE, NULL);
+	while (THREAD_RUNNING) {
+		switch_yield(1000);
+	}
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/voctel/src/switch_resample.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_resample.c	(original)
+++ freeswitch/branches/voctel/src/switch_resample.c	Fri Sep 22 14:22:15 2006
@@ -29,6 +29,7 @@
  * switch_caller.c -- Caller Identification
  *
  */
+#include <switch.h>
 #include <switch_resample.h>
 #include <libresample.h>
 #define NORMFACT (float)0x8000
@@ -46,12 +47,12 @@
 
 
 
-SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
+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 *pool)
+													 int to_rate, uint32_t to_size, switch_memory_pool_t *pool)
 {
-	switch_audio_resampler *resampler;
+	switch_audio_resampler_t *resampler;
 	double lto_rate, lfrom_rate;
 
 	if ((resampler = switch_core_alloc(pool, sizeof(*resampler))) == 0) {
@@ -77,7 +78,7 @@
 }
 
 
-SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst,
+SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst,
 											uint32_t dstlen, int last)
 {
 	int o = 0, srcused = 0, srcpos = 0, out = 0;
@@ -100,7 +101,7 @@
 	return out;
 }
 
-SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler)
+SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler)
 {
 	resample_close(resampler->resampler);
 }

Modified: freeswitch/branches/voctel/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_rtp.c	(original)
+++ freeswitch/branches/voctel/src/switch_rtp.c	Fri Sep 22 14:22:15 2006
@@ -46,17 +46,91 @@
 #define SWITCH_RTP_CNG_PAYLOAD 13
 #define MAX_KEY_LEN      64
 #define MASTER_KEY_LEN   30
+#define RTP_MAGIC_NUMBER 42
 
 static switch_port_t NEXT_PORT = RTP_START_PORT;
 static switch_mutex_t *port_lock = NULL;
 
 typedef srtp_hdr_t rtp_hdr_t;
 
+#ifdef _MSC_VER
+#pragma pack(4)
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+
 typedef struct {
+  uint32_t ts;		/* timestamp */
+} PACKED srtp_mini_hdr_t;
+
+#else 
+typedef struct {
+  uint32_t ts;		/* timestamp */
+} PACKED srtp_mini_hdr_t;
+
+#endif
+
+#ifdef _MSC_VER
+#pragma pack()
+#endif
+
+
+
+typedef struct {
 	srtp_hdr_t header;        
 	char body[SWITCH_RTP_MAX_BUF_LEN];  
 } rtp_msg_t;
 
+
+typedef struct {
+	srtp_mini_hdr_t header;        
+	char body[SWITCH_RTP_MAX_BUF_LEN];  
+} rtp_mini_msg_t;
+
+
+struct rfc2833_digit {
+	char digit;
+	int duration;
+};
+
+struct switch_rtp_vad_data {
+	switch_core_session_t *session;
+	switch_codec_t vad_codec;
+	switch_codec_t *read_codec;
+	uint32_t bg_level;
+	uint32_t bg_count;
+	uint32_t bg_len;
+	uint32_t diff_level;
+	uint8_t hangunder;
+	uint8_t hangunder_hits;
+	uint8_t hangover;
+	uint8_t hangover_hits;
+	uint8_t cng_freq;
+	uint8_t cng_count;
+	switch_vad_flag_t flags;
+	uint32_t ts;
+	uint8_t start;
+	uint8_t start_count;
+	uint8_t scan_freq;
+	time_t next_scan;
+};
+
+
+struct switch_rtp_rfc2833_data {
+	switch_queue_t *dtmf_queue;
+	char out_digit;
+	unsigned char out_digit_packet[4];
+	unsigned int out_digit_sofar;
+	unsigned int out_digit_dur;
+	uint16_t out_digit_seq;
+	int32_t timestamp_dtmf;
+	char last_digit;
+	unsigned int dc;
+	time_t last_digit_time;
+	switch_buffer_t *dtmf_buffer;
+	switch_mutex_t *dtmf_mutex;
+};
+
 struct switch_rtp {
 	switch_socket_t *sock;
 
@@ -69,33 +143,67 @@
 	srtp_ctx_t *recv_ctx;
 	
 	uint16_t seq;
+	uint16_t rseq;
 	switch_payload_t payload;
+	switch_payload_t rpayload;
 	
-	switch_rtp_invalid_handler invalid_handler;
+	switch_rtp_invalid_handler_t invalid_handler;
 	void *private_data;
 
 	uint32_t ts;
 	uint32_t flags;
-	switch_memory_pool *pool;
+	switch_memory_pool_t *pool;
 	switch_sockaddr_t *from_addr;
 
 	char *ice_user;
 	char *user_ice;
 	switch_time_t last_stun;
 	uint32_t packet_size;
+	uint32_t rpacket_size;
 	switch_time_t last_read;
-	switch_time_t next_read;
 	uint32_t ms_per_packet;
 	uint32_t remote_port;
 	uint8_t stuncount;
-	switch_buffer *packet_buffer;
+	switch_buffer_t *packet_buffer;
+	struct switch_rtp_vad_data vad_data;
+	struct switch_rtp_rfc2833_data dtmf_data;
+	uint8_t mini;
+	switch_payload_t te;
+	switch_mutex_t *flag_mutex;
+	switch_timer_t timer;
+	uint8_t ready;
+	switch_time_t last_time;
 };
 
 static int global_init = 0;
 
-static switch_status ice_out(switch_rtp *rtp_session)
+static void switch_rtp_miniframe_probe(switch_rtp_t *rtp_session)
 {
+	const char *str = "!!!!";
+	rtp_msg_t msg = {{0}};
+	int x;
+	
+	msg.header.ssrc    = htonl(RTP_MAGIC_NUMBER);
+    msg.header.ts      = htonl(rtp_session->packet_size);
+    msg.header.seq     = htons(RTP_MAGIC_NUMBER);
+    msg.header.m       = 1;
+    msg.header.pt      = RTP_MAGIC_NUMBER;
+    msg.header.version = 2;
+    msg.header.p       = 0;
+    msg.header.x       = 0;
+    msg.header.cc      = 0;
 
+	snprintf(msg.body, sizeof(msg.body), str);
+	for(x = 0; x < 3 ; x++) {
+		switch_size_t bytes = strlen(str) + sizeof(msg.header);
+		switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&msg, &bytes);
+	}
+}
+
+
+static switch_status_t ice_out(switch_rtp_t *rtp_session)
+{
+
 	assert(rtp_session != NULL);
 	assert(rtp_session->ice_user != NULL);
 
@@ -108,12 +216,12 @@
 		if (rtp_session->last_stun) {
 			elapsed = (unsigned int)((switch_time_now() - rtp_session->last_stun) / 1000);
 
-			if (elapsed > 10000) {
+			if (elapsed > 30000) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n");
 				return SWITCH_STATUS_FALSE;
 			}
 		}
-		
+
 		packet = switch_stun_packet_build_header(SWITCH_STUN_BINDING_REQUEST, NULL, buf);
 		switch_stun_packet_attribute_add_username(packet, rtp_session->ice_user, 32);
 		bytes = switch_stun_packet_length(packet);
@@ -125,7 +233,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static void handle_ice(switch_rtp *rtp_session, void *data, switch_size_t len)
+static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len)
 {
 	switch_stun_packet_t *packet;
 	switch_stun_packet_attribute_t *attr;
@@ -175,7 +283,7 @@
 }
 
 
-SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool *pool)
+SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
 {
 	if (global_init) {
 		return;
@@ -193,15 +301,15 @@
 	switch_mutex_lock(port_lock);
 	port = NEXT_PORT;
 	NEXT_PORT += 2;
-	if (port > RTP_END_PORT) {
-		port = RTP_START_PORT;
+	if (NEXT_PORT > RTP_END_PORT) {
+		NEXT_PORT = RTP_START_PORT;
 	}
 	switch_mutex_unlock(port_lock);
 	return port;
 }
 
 
-SWITCH_DECLARE(switch_status) switch_rtp_set_local_address(switch_rtp *rtp_session, char *host, switch_port_t port, const char **err)
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err)
 {
 	*err = "Success";
 
@@ -211,8 +319,7 @@
 	}
 
 	if (rtp_session->sock) {
-		switch_socket_close(rtp_session->sock);
-		rtp_session->sock = NULL;
+		switch_rtp_kill_socket(rtp_session);
 	}
 	
 	if (switch_socket_create(&rtp_session->sock, AF_INET, SOCK_DGRAM, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
@@ -227,12 +334,13 @@
 
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
 		switch_socket_opt_set(rtp_session->sock, APR_SO_NONBLOCK, TRUE);
+		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
 	}
-	switch_set_flag(rtp_session, SWITCH_RTP_FLAG_IO);
+	switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_IO);
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_rtp_set_remote_address(switch_rtp *rtp_session, char *host, switch_port_t port, const char **err)
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err)
 {
 	*err = "Success";
 
@@ -246,16 +354,17 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_rtp_create(switch_rtp **new_rtp_session,
-												switch_payload_t payload,
-												uint32_t packet_size,
-												uint32_t ms_per_packet,
-												switch_rtp_flag_t flags, 
-												char *crypto_key,
-												const char **err,
-												switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session,
+												  switch_payload_t payload,
+												  uint32_t packet_size,
+												  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_rtp *rtp_session = NULL;
+	switch_rtp_t *rtp_session = NULL;
 	srtp_policy_t policy;
 	char key[MAX_KEY_LEN];
 	uint32_t ssrc = rand() & 0xffff;
@@ -272,9 +381,15 @@
 		return SWITCH_STATUS_MEMERR;
 	}
 
+
+
 	rtp_session->pool = pool;
 	rtp_session->flags = flags;
+	rtp_session->te = 101;
 
+	switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
+	switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
+	switch_buffer_create_dynamic(&rtp_session->dtmf_data.dtmf_buffer, 128, 128, 0);
 	/* for from address on recvfrom calls */
 	switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool);
 	
@@ -282,7 +397,7 @@
 	if (crypto_key) {
 		int len;
 
-		switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE);
+		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_SECURE);
 		crypto_policy_set_rtp_default(&policy.rtp);
 		crypto_policy_set_rtcp_default(&policy.rtcp);
 		policy.ssrc.type  = ssrc_any_inbound;
@@ -344,7 +459,6 @@
 	rtp_session->payload = payload;
 	rtp_session->ms_per_packet = ms_per_packet;
 	rtp_session->packet_size = packet_size;
-	rtp_session->next_read = switch_time_now() + rtp_session->ms_per_packet;
 
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
 		err_status_t stat;
@@ -361,26 +475,46 @@
 		}
 	}
 
+	if (!switch_strlen_zero(timer_name)) {
+		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+	}
+
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && switch_strlen_zero(timer_name)) {
+		timer_name = "soft";
+	}
+
+	if (!switch_strlen_zero(timer_name)) {
+		if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, packet_size, rtp_session->pool) == SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting timer [%s] %d bytes per %dms\n", timer_name, packet_size, ms_per_packet);
+		} else {
+			memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error starting timer [%s], async RTP disabled\n", timer_name);
+			switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+		}
+	}
+
+	rtp_session->ready++;
 	*new_rtp_session = rtp_session;
 
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_rtp *)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 packet_size,
-										   uint32_t ms_per_packet,
-										   switch_rtp_flag_t flags,
-										   char *crypto_key,
-										   const char **err,
-										   switch_memory_pool *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 packet_size,
+											 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_rtp *rtp_session;
+	switch_rtp_t *rtp_session;
 
-	if (switch_rtp_create(&rtp_session, payload, packet_size, ms_per_packet, flags, crypto_key, err, pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_rtp_create(&rtp_session, payload, packet_size, ms_per_packet, flags, crypto_key, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
 		return NULL;
 	}
 
@@ -392,11 +526,22 @@
 		return NULL;
 	}
 
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) {
+		switch_rtp_miniframe_probe(rtp_session);
+		switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_MINI);
+	}
+
 	return rtp_session;
 }
 
+SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te)
+{
+	if (te > 96) {
+		rtp_session->te = te;
+	}
+}
 
-SWITCH_DECLARE(switch_status) switch_rtp_activate_ice(switch_rtp *rtp_session, char *login, char *rlogin)
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin)
 {
 	char ice_user[80];
 	char user_ice[80];
@@ -415,92 +560,214 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp *rtp_session)
+SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session)
 {
-	apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE);
-	switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO);
+	assert(rtp_session != NULL);
+	switch_mutex_lock(rtp_session->flag_mutex);
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
+		assert(rtp_session->sock != NULL);
+		apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE);
+		switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO);
+	}
+	switch_mutex_unlock(rtp_session->flag_mutex);
 }
 
+SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session)
+{
+	return (rtp_session != NULL && rtp_session->ready) ? 1 : 0;
+}
 
-SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp **rtp_session)
+SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
 {
+	if (!switch_rtp_ready(*rtp_session)) {
+		return;
+	}
+
+	switch_mutex_lock((*rtp_session)->flag_mutex);
+	
+	if ((*rtp_session)->packet_buffer) {
+		switch_buffer_destroy(&(*rtp_session)->packet_buffer);
+	}
+			
 	switch_rtp_kill_socket(*rtp_session);
 	switch_socket_close((*rtp_session)->sock);
+	(*rtp_session)->sock = NULL;
 
+
+	if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_VAD)) {
+		switch_rtp_disable_vad(*rtp_session);
+	}
+
 	if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE)) {
 		srtp_dealloc((*rtp_session)->recv_ctx);
 		srtp_dealloc((*rtp_session)->send_ctx);
 	}
 
-	*rtp_session = NULL;
+	if ((*rtp_session)->timer.timer_interface) {
+		switch_core_timer_destroy(&(*rtp_session)->timer);
+	}
+
+	switch_mutex_unlock((*rtp_session)->flag_mutex);
+
 	return;
 }
 
-SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp *rtp_session)
+SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session)
 {
 	return rtp_session->sock;
 }
 
-SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint16_t packet_size)
+SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp_t *rtp_session, uint16_t packet_size)
 {
 	rtp_session->packet_size = packet_size;
 }
 
-SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp *rtp_session)
+SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp_t *rtp_session)
 {
 	return rtp_session->packet_size;
 }
 
-SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, switch_payload_t payload)
+SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp_t *rtp_session, switch_payload_t payload)
 {
 	rtp_session->payload = payload;
 }
 
-SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp *rtp_session)
+SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp_t *rtp_session)
 {
 	return rtp_session->payload;
 }
 
-SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp *rtp_session, switch_rtp_invalid_handler on_invalid)
+SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid)
 {
 	rtp_session->invalid_handler = on_invalid;
 }
 
-SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags) 
+SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags) 
 {
 	
-	switch_set_flag(rtp_session, flags);
+	switch_set_flag_locked(rtp_session, flags);
 
 }
 
-SWITCH_DECLARE(uint8_t) switch_rtp_test_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags) 
+SWITCH_DECLARE(uint8_t) switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags) 
 {
 	
 	return (uint8_t) switch_test_flag(rtp_session, flags);
 	
 }
 
-SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp *rtp_session, switch_rtp_flag_t flags) 
+SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags) 
 {
 	
-	switch_clear_flag(rtp_session, flags);
+	switch_clear_flag_locked(rtp_session, flags);
 
 }
 
-static int rtp_common_read(switch_rtp *rtp_session, switch_payload_t *payload_type, switch_frame_flag *flags)
+
+static void do_2833(switch_rtp_t *rtp_session)
 {
+	switch_frame_flag_t flags = 0;
+	uint32_t samples = rtp_session->packet_size;
+
+	if (rtp_session->dtmf_data.out_digit_dur > 0) {
+		int x, loops = 1, duration;
+		rtp_session->dtmf_data.out_digit_sofar += samples;
+
+		if (rtp_session->dtmf_data.out_digit_sofar >= rtp_session->dtmf_data.out_digit_dur) {
+			duration = rtp_session->dtmf_data.out_digit_dur;
+			rtp_session->dtmf_data.out_digit_packet[1] |= 0x80;
+			rtp_session->dtmf_data.out_digit_dur = 0;
+			loops = 3;
+		} else {
+			duration = rtp_session->dtmf_data.out_digit_sofar;
+		}
+
+		//ts = rtp_session->dtmf_data.timestamp_dtmf += samples;
+		rtp_session->dtmf_data.out_digit_packet[2] = (unsigned char) (duration >> 8);
+		rtp_session->dtmf_data.out_digit_packet[3] = (unsigned char) duration;
+		
+
+		for (x = 0; x < loops; x++) {
+			switch_rtp_write_manual(rtp_session, 
+									rtp_session->dtmf_data.out_digit_packet, 4, 0, rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf,
+									rtp_session->dtmf_data.out_digit_seq++, &flags);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send %s packet for [%c] ts=%d sofar=%u dur=%d\n", 
+							  loops == 1 ? "middle" : "end",
+							  rtp_session->dtmf_data.out_digit,
+							  rtp_session->dtmf_data.timestamp_dtmf, 
+							  rtp_session->dtmf_data.out_digit_sofar,
+							  duration);
+		}
+	}
+
+	if (!rtp_session->dtmf_data.out_digit_dur && rtp_session->dtmf_data.dtmf_queue && switch_queue_size(rtp_session->dtmf_data.dtmf_queue)) {
+		void *pop;
+
+		if (switch_queue_trypop(rtp_session->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+			int x;
+			struct rfc2833_digit *rdigit = pop;
+
+			memset(rtp_session->dtmf_data.out_digit_packet, 0, 4);
+			rtp_session->dtmf_data.out_digit_sofar = 0;
+			rtp_session->dtmf_data.out_digit_dur = rdigit->duration;
+			rtp_session->dtmf_data.out_digit = rdigit->digit;
+			rtp_session->dtmf_data.out_digit_packet[0] = (unsigned char)switch_char_to_rfc2833(rdigit->digit);
+			rtp_session->dtmf_data.out_digit_packet[1] = 7;
+
+			//ts = rtp_session->dtmf_data.timestamp_dtmf += samples;
+			rtp_session->dtmf_data.timestamp_dtmf++;
+
+
+			for (x = 0; x < 3; x++) {
+				switch_rtp_write_manual(rtp_session,
+										rtp_session->dtmf_data.out_digit_packet,
+										4,
+										1,
+										rtp_session->te,
+										rtp_session->dtmf_data.timestamp_dtmf,
+										rtp_session->dtmf_data.out_digit_seq++,
+										&flags);
+				switch_log_printf(SWITCH_CHANNEL_LOG,
+								  SWITCH_LOG_DEBUG,
+								  "Send start packet for [%c] ts=%d sofar=%u dur=%d\n",
+								  rtp_session->dtmf_data.out_digit,
+								  rtp_session->dtmf_data.timestamp_dtmf,
+								  rtp_session->dtmf_data.out_digit_sofar,
+								  0);
+			}
+
+			free(rdigit);
+		}
+	}
+}
+
+static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags)
+{
 	switch_size_t bytes;
-	switch_status status;
+	switch_status_t status;
+	uint8_t check = 1;
 
+	if (!rtp_session->timer.interval) {
+		rtp_session->last_time = switch_time_now();
+	}
+
 	for(;;) {
 		bytes = sizeof(rtp_msg_t);	
 		status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
+
+		if (!SWITCH_STATUS_IS_BREAK(status) && rtp_session->timer.interval) {
+			switch_core_timer_step(&rtp_session->timer);
+		}
 		
-		
+		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
+			switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
+			return 0;
+		}
+
 		if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
 			return -1;
 		}
-
+		
 		if (bytes < 0) {
 			return (int)bytes;
 		} else if (bytes > 0 && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
@@ -510,43 +777,104 @@
 			stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
 			if (stat) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-						"error: srtp unprotection failed with code %d%s\n", stat,
-						stat == err_status_replay_fail ? " (replay check failed)" :
-						stat == err_status_auth_fail ? " (auth check failed)" : "");
+								  "error: srtp unprotection failed with code %d%s\n", stat,
+								  stat == err_status_replay_fail ? " (replay check failed)" :
+								  stat == err_status_auth_fail ? " (auth check failed)" : "");
 				return -1;
 			}
 			bytes = sbytes;
+		} 
+
+		if (bytes > 0) {
+			uint32_t effective_size = (uint32_t)(bytes - sizeof(srtp_mini_hdr_t));
+			if (rtp_session->recv_msg.header.pt == RTP_MAGIC_NUMBER) {
+				if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) {
+					switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_MINI);
+					rtp_session->rpacket_size = ntohl(rtp_session->recv_msg.header.ts);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "YAY MINI-RTP! %d\n", rtp_session->rpacket_size);
+					switch_rtp_miniframe_probe(rtp_session);
+				}
+				continue;
+			}
+
+			
+			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI) && rtp_session->rpacket_size && effective_size > 0) {
+				uint32_t mfactor = (effective_size % rtp_session->rpacket_size);
+
+				if (!mfactor) {
+					uint32_t ts;	
+					rtp_mini_msg_t *mini = (rtp_mini_msg_t *) &rtp_session->recv_msg;
+					ts = mini->header.ts;
+					bytes -= sizeof(srtp_mini_hdr_t);
+
+					memmove(rtp_session->recv_msg.body, mini->body, bytes);
+
+					rtp_session->recv_msg.header.ts = ts;
+					rtp_session->recv_msg.header.seq = htons(rtp_session->rseq++);
+					rtp_session->recv_msg.header.pt = rtp_session->rpayload;
+					bytes += rtp_header_len;
+					rtp_session->recv_msg.header.version = 2;
+				}
+			}
 		}
 
-		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
-			if ((switch_time_now() - rtp_session->next_read) > 1000) {
+		if (rtp_session->timer.interval) {
+			check = (uint8_t)(switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
+		}
+
+		if (check) {
+			do_2833(rtp_session);
+
+			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
 				/* We're late! We're Late!*/
+				if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
+					switch_yield(1000);
+					continue;
+				}
 				memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD);
 				rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
 				*flags |= SFF_CNG;
-				/* Set the next waypoint and return a CNG frame */
-				rtp_session->next_read += rtp_session->ms_per_packet;
+				/* Return a CNG frame */
 				*payload_type = SWITCH_RTP_CNG_PAYLOAD;
 				return SWITCH_RTP_CNG_PAYLOAD;
 			}
+		}		
 		
-			if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
-				switch_yield(1000);
+		if (status == SWITCH_STATUS_BREAK || bytes == 0) {
+			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DATAWAIT)) {
+				switch_yield(rtp_session->ms_per_packet);
 				continue;
 			}
-		}		
-
-		if (status == SWITCH_STATUS_BREAK || bytes == 0) {
 			return 0;
 		}
 
+
+		if (rtp_session->recv_msg.header.version) {
+			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && rtp_session->from_addr->port) {
+				if ((rtp_session->from_addr->port != rtp_session->remote_port)) {
+					const char *err;
+					char *tx_host;
+					uint32_t old = rtp_session->remote_port;
+					char *old_host;
+				
+					switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
+					switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
+					if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
+										  old_host, old, tx_host, rtp_session->from_addr->port);
+						switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+					}
+				}
+				switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+			}
+		}
+
 		if (rtp_session->recv_msg.header.version == 2) {
-			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && rtp_session->from_addr->port && 
-				(rtp_session->from_addr->port != rtp_session->remote_port)) {
-				uint32_t old = rtp_session->remote_port;
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %u to %u\n", old, rtp_session->from_addr->port);
-				rtp_session->remote_port = rtp_session->from_addr->port;
+			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
+				rtp_session->recv_msg.header.pt = 97;
 			}
+			rtp_session->rseq = ntohs(rtp_session->recv_msg.header.seq);
+			rtp_session->rpayload = rtp_session->recv_msg.header.pt;
 		} else {
 			if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) {
 				handle_ice(rtp_session, (void *) &rtp_session->recv_msg, bytes);
@@ -558,28 +886,156 @@
 			return 0;
 		}
 
+		/* RFC2833 ... TBD try harder to honor the duration etc.*/
+		if (rtp_session->recv_msg.header.pt == rtp_session->te) {
+			unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
+			int end = packet[1]&0x80;
+			int duration = (packet[2]<<8) + packet[3];
+			char key = switch_rfc2833_to_char(packet[0]);
+
+			/* SHEESH.... Curse you RFC2833 inventors!!!!*/
+			if ((time(NULL) - rtp_session->dtmf_data.last_digit_time) > 2) {
+				rtp_session->dtmf_data.last_digit = 0;
+				rtp_session->dtmf_data.dc = 0;
+			}
+			if (duration && end) {
+				if (key != rtp_session->dtmf_data.last_digit) {
+					char digit_str[] = {key, 0};
+					time(&rtp_session->dtmf_data.last_digit_time);
+					switch_rtp_queue_dtmf(rtp_session, digit_str);
+				}
+				if (++rtp_session->dtmf_data.dc >= 3) {
+					rtp_session->dtmf_data.last_digit = 0;
+					rtp_session->dtmf_data.dc = 0;
+				}
+
+				rtp_session->dtmf_data.last_digit = key;
+			} else {
+				rtp_session->dtmf_data.last_digit = 0;
+				rtp_session->dtmf_data.dc = 0;
+			}
+
+			continue;
+		}
+
 		break;
 	}
 
 	rtp_session->last_read = switch_time_now();
-	rtp_session->next_read += rtp_session->ms_per_packet;
 	*payload_type = rtp_session->recv_msg.header.pt;
 
+
 	if (*payload_type == SWITCH_RTP_CNG_PAYLOAD) {
 		*flags |= SFF_CNG;
 	}
+	
+	if (bytes > 0) {
+		do_2833(rtp_session);
+	}
 
 	return (int) bytes;
 }
 
-SWITCH_DECLARE(switch_status) switch_rtp_read(switch_rtp *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag *flags)
+
+
+SWITCH_DECLARE(switch_size_t) switch_rtp_has_dtmf(switch_rtp_t *rtp_session)
 {
+	switch_size_t has;
 
+	assert(rtp_session != NULL);
+	switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
+	has = switch_buffer_inuse(rtp_session->dtmf_data.dtmf_buffer);
+	switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);
+
+	return has;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_rtp_queue_dtmf(switch_rtp_t *rtp_session, char *dtmf)
+{
+	switch_status_t status;
+	register switch_size_t len, inuse;
+	switch_size_t wr = 0;
+	char *p;
+
+	assert(rtp_session != NULL);
+
+	switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
+
+	inuse = switch_buffer_inuse(rtp_session->dtmf_data.dtmf_buffer);
+	len = strlen(dtmf);
+	
+	if (len + inuse > switch_buffer_len(rtp_session->dtmf_data.dtmf_buffer)) {
+		switch_buffer_toss(rtp_session->dtmf_data.dtmf_buffer, strlen(dtmf));
+	}
+
+	p = dtmf;
+	while(wr < len && p) {
+		if (is_dtmf(*p)) {
+			wr++;
+		} else {
+			break;
+		}
+		p++;
+	}
+	status = switch_buffer_write(rtp_session->dtmf_data.dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR;
+	switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);
+
+	return status;
+}
+
+
+SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, char *dtmf, switch_size_t len)
+{
+	switch_size_t bytes;
+
+	assert(rtp_session != NULL);
+
+	switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
+	if ((bytes = switch_buffer_read(rtp_session->dtmf_data.dtmf_buffer, dtmf, len)) > 0) {
+		*(dtmf + bytes) = '\0';
+	}
+	switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);
+
+	return bytes;
+
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, char *digits, uint32_t duration)
+{
+	char *c;
+
+	if (!rtp_session->dtmf_data.dtmf_queue) {
+		switch_queue_create(&rtp_session->dtmf_data.dtmf_queue, 100, rtp_session->pool);
+	}
+
+	for(c = digits; *c; c++) {
+		struct rfc2833_digit *rdigit;
+
+		if ((rdigit = malloc(sizeof(*rdigit))) != 0) {
+			memset(rdigit, 0, sizeof(*rdigit));
+			rdigit->digit = *c;
+			rdigit->duration = duration;
+			switch_queue_push(rtp_session->dtmf_data.dtmf_queue, rdigit);
+		} else {
+			return SWITCH_STATUS_MEMERR;
+		}
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+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)
+{
+
 	int bytes = rtp_common_read(rtp_session, payload_type, flags);
 	
 	if (bytes < 0) {
 		*datalen = 0;
 		return SWITCH_STATUS_GENERR;
+	} else if (bytes == 0) {
+		*datalen = 0;
+		return SWITCH_STATUS_BREAK;
 	} else {
 		bytes -= rtp_header_len;
 	}
@@ -591,7 +1047,7 @@
 	return SWITCH_STATUS_SUCCESS;	
 }
 
-SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read_frame(switch_rtp *rtp_session, switch_frame *frame)
+SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame)
 {
 	int bytes = rtp_common_read(rtp_session, &frame->payload, &frame->flags);
 
@@ -616,7 +1072,11 @@
 }
 
 
-SWITCH_DECLARE(switch_status) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag *flags)
+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)
 {
 
 	int bytes = rtp_common_read(rtp_session, payload_type, flags);
@@ -633,22 +1093,25 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datalen, switch_payload_t payload, switch_frame_flag *flags)
+static int rtp_common_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, switch_frame_flag_t *flags)
 {
 	switch_size_t bytes;
 	uint8_t packetize = (rtp_session->packet_size > datalen && (payload == rtp_session->payload)) ? 1 : 0;
 	uint8_t fwd = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE) && (*flags & SFF_RAW_RTP)) ? 1 : 0;
 	rtp_msg_t *send_msg;
+	uint8_t send = 1;
 
 	if (fwd) {
 		bytes = datalen;
 		send_msg = (rtp_msg_t *) data;
 	} else {
 		send_msg = &rtp_session->send_msg;
-		send_msg->header.pt = rtp_session->payload;
+		send_msg->header.pt = payload;
+		send_msg->header.m = m ? 1 : 0;
 		if (packetize) {
 			if (!rtp_session->packet_buffer) {
-				if (switch_buffer_create(rtp_session->pool, &rtp_session->packet_buffer, rtp_session->packet_size * 2) != SWITCH_STATUS_SUCCESS) {
+				if (switch_buffer_create_dynamic(&rtp_session->packet_buffer, rtp_session->packet_size, rtp_session->packet_size * 2, 0) 
+					!= SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer memory error\n");
 					return -1;
 				}
@@ -678,8 +1141,142 @@
 		bytes = sbytes;
 	}
 
-	switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)send_msg, &bytes);
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->send_msg.header.pt == 97) {
+		rtp_session->recv_msg.header.pt = 102;
+	}
 	
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) && 
+		rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
+		((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) || 
+		 (datalen > SWITCH_RTP_CNG_PAYLOAD && rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame == 0))) {
+		int16_t decoded[SWITCH_RECCOMMENDED_BUFFER_SIZE/sizeof(int16_t)];
+		uint32_t rate;
+		uint32_t flags;
+		uint32_t len = sizeof(decoded);
+		time_t now = time(NULL);
+		send = 0;
+		
+		if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) {
+			rtp_session->vad_data.bg_count = rtp_session->vad_data.bg_level = 0;
+			rtp_session->vad_data.next_scan = now + rtp_session->vad_data.scan_freq;
+			//printf("RESCAN\n");
+		}
+
+		if (switch_core_codec_decode(&rtp_session->vad_data.vad_codec,
+									 rtp_session->vad_data.read_codec,
+									 data,
+									 datalen,
+									 rtp_session->vad_data.read_codec->implementation->samples_per_second,
+									 decoded,
+									 &len,
+									 &rate,
+									 &flags) == SWITCH_STATUS_SUCCESS) {
+
+			uint32_t energy = 0;
+			uint32_t x, y = 0, z = len / sizeof(int16_t);
+			uint32_t score = 0;
+			
+			if (z) {
+				for (x = 0; x < z; x++) {
+					energy += abs(decoded[y]);
+					y += rtp_session->vad_data.read_codec->implementation->number_of_channels;
+				}
+				
+				if (++rtp_session->vad_data.start_count < rtp_session->vad_data.start) {
+					send = 1;
+				} else {
+					score = energy / z;
+					if (score && (rtp_session->vad_data.bg_count < rtp_session->vad_data.bg_len)) {
+						rtp_session->vad_data.bg_level += score;
+						if (++rtp_session->vad_data.bg_count == rtp_session->vad_data.bg_len) {
+							rtp_session->vad_data.bg_level /= rtp_session->vad_data.bg_len;
+							//rtp_session->vad_data.bg_level += (rtp_session->vad_data.bg_level / 3);
+							//printf("AVG %u\n", rtp_session->vad_data.bg_level);
+						}
+						send = 1;
+					} else {
+						if (score > rtp_session->vad_data.bg_level) {
+							uint32_t diff = score - rtp_session->vad_data.bg_level;
+
+							if (rtp_session->vad_data.hangover_hits) {
+								rtp_session->vad_data.hangover_hits--;
+							}
+
+							if (diff >= rtp_session->vad_data.diff_level || ++rtp_session->vad_data.hangunder_hits >= rtp_session->vad_data.hangunder) {
+								switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING);
+								send_msg->header.m = 1;
+								rtp_session->vad_data.hangover_hits = rtp_session->vad_data.hangunder_hits = rtp_session->vad_data.cng_count = 0;
+								if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_TALK)) {
+									switch_event_t *event;
+									if (switch_event_create(&event, SWITCH_EVENT_TALK) == SWITCH_STATUS_SUCCESS) {
+										switch_channel_t *channel = switch_core_session_get_channel(rtp_session->vad_data.session);
+										switch_channel_event_set_data(channel, event);
+										switch_event_fire(&event);
+									}
+								}
+							} 
+						} else {
+							if (rtp_session->vad_data.hangunder_hits) {
+								rtp_session->vad_data.hangunder_hits--;
+							}
+							if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING)) {
+								if (++rtp_session->vad_data.hangover_hits >= rtp_session->vad_data.hangover) {
+									switch_clear_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING);
+									rtp_session->vad_data.hangover_hits = rtp_session->vad_data.hangunder_hits = rtp_session->vad_data.cng_count = 0;
+									if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_NOTALK)) {
+										switch_event_t *event;
+										if (switch_event_create(&event, SWITCH_EVENT_NOTALK) == SWITCH_STATUS_SUCCESS) {
+											switch_channel_t *channel = switch_core_session_get_channel(rtp_session->vad_data.session);
+											switch_channel_event_set_data(channel, event);
+											switch_event_fire(&event);
+										}					
+									}
+								}
+							}
+						}
+					}
+				}
+				
+				if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING)) {
+					send = 1;
+				} else {
+					if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG) && ++rtp_session->vad_data.cng_count >= rtp_session->vad_data.cng_freq) {
+						rtp_session->send_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
+						memset(rtp_session->send_msg.body, 255, SWITCH_RTP_CNG_PAYLOAD);
+						//rtp_session->send_msg.header.ts = htonl(rtp_session->vad_data.ts);
+						//rtp_session->vad_data.ts++;
+						bytes = SWITCH_RTP_CNG_PAYLOAD;
+						send = 1;
+						rtp_session->vad_data.cng_count = 0;
+					}
+				}
+					   
+			}
+		} else {
+			return SWITCH_STATUS_GENERR;
+		}
+	}
+
+	if (send) {
+		if (rtp_session->mini) {
+			rtp_mini_msg_t mini = {{0}};
+			bytes -= rtp_header_len;
+			mini.header.ts = send_msg->header.ts;
+			memcpy(mini.body, send_msg->body, bytes);
+			bytes += sizeof(srtp_mini_hdr_t);
+			switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&mini, &bytes);
+		} else {
+			switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)send_msg, &bytes);
+		}
+
+		if (!rtp_session->mini && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_MINI)) {
+			rtp_session->mini++;
+			rtp_session->rpayload = send_msg->header.pt;
+			rtp_session->rseq = ntohs(send_msg->header.seq);
+		}
+
+	}
+
 	if (rtp_session->ice_user) {
 		if (ice_out(rtp_session) != SWITCH_STATUS_SUCCESS) {
 			return -1;
@@ -690,9 +1287,58 @@
 
 }
 
-SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag *flags)
+
+SWITCH_DECLARE(switch_status_t) switch_rtp_disable_vad(switch_rtp_t *rtp_session)
 {
+	if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD)) {
+		return SWITCH_STATUS_GENERR;
+	}
+	switch_core_codec_destroy(&rtp_session->vad_data.vad_codec);
+	switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD);
+	return SWITCH_STATUS_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)
+{
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD)) {
+		return SWITCH_STATUS_GENERR;
+	}
+	memset(&rtp_session->vad_data, 0, sizeof(rtp_session->vad_data));
+	
+	if (switch_core_codec_init(&rtp_session->vad_data.vad_codec,
+							   codec->implementation->iananame,
+							   codec->implementation->samples_per_second,
+							   codec->implementation->microseconds_per_frame / 1000,
+							   codec->implementation->number_of_channels,
+							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+							   NULL, 
+							   rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	rtp_session->vad_data.diff_level = 400;
+	rtp_session->vad_data.hangunder = 15;
+	rtp_session->vad_data.hangover = 40;
+	rtp_session->vad_data.bg_len = 5;
+	rtp_session->vad_data.bg_count = 5;
+	rtp_session->vad_data.bg_level = 300;
+	rtp_session->vad_data.read_codec = codec;
+	rtp_session->vad_data.session = session;
+	rtp_session->vad_data.flags = flags;
+	rtp_session->vad_data.cng_freq = 50;
+	rtp_session->vad_data.ts = 1;
+	rtp_session->vad_data.start = 0;
+	rtp_session->vad_data.next_scan = time(NULL);
+	rtp_session->vad_data.scan_freq = 0;
+	switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD);
+	switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG);
+	return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag_t *flags)
+{
+
 	if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
 		return -1;
 	}
@@ -703,11 +1349,11 @@
 	rtp_session->send_msg.header.seq = rtp_session->seq;
 	rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
 
-	return rtp_common_write(rtp_session, data, datalen, rtp_session->payload, flags);
+	return rtp_common_write(rtp_session, data, datalen, 0, rtp_session->payload, flags);
 
 }
 
-SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp *rtp_session, switch_frame *frame, uint32_t ts)
+SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, uint32_t ts)
 {
 	uint8_t fwd = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE) && switch_test_flag(frame, SFF_RAW_RTP)) ? 1 : 0;
 	uint8_t packetize = (rtp_session->packet_size > frame->datalen && (frame->payload == rtp_session->payload)) ? 1 : 0;
@@ -731,11 +1377,11 @@
 		rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
 	}
 
-	return rtp_common_write(rtp_session, data, len, rtp_session->payload, &frame->flags);
+	return rtp_common_write(rtp_session, data, len, 0, rtp_session->payload, &frame->flags);
 
 }
 
-SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, uint16_t datalen, uint8_t payload, uint32_t ts, uint16_t mseq, switch_frame_flag *flags)
+SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, void *data, uint16_t datalen, uint8_t m, uint8_t payload, uint32_t ts, uint16_t mseq, switch_frame_flag_t *flags)
 {
 
 	if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
@@ -744,22 +1390,22 @@
 
 	rtp_session->ts += ts;
 	rtp_session->send_msg.header.seq = htons(mseq);
-	rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
+	rtp_session->send_msg.header.ts = htonl(ts);
 
-	return rtp_common_write(rtp_session, data, datalen, payload, flags);
+	return rtp_common_write(rtp_session, data, datalen, m, payload, flags);
 }
 
-SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp *rtp_session)
+SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session)
 {
 	return rtp_session->send_msg.header.ssrc;
 }
 
-SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp *rtp_session, void *private_data)
+SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data)
 {
 	rtp_session->private_data = private_data;
 }
 
-SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp *rtp_session)
+SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp_t *rtp_session)
 {
 	return rtp_session->private_data;
 }

Modified: freeswitch/branches/voctel/src/switch_stun.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_stun.c	(original)
+++ freeswitch/branches/voctel/src/switch_stun.c	Fri Sep 22 14:22:15 2006
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Fanzhou Zhao <fanzhou at gmail.com> 2006-08-22 (Bugfix 2357-2358)
  *
  *
  * switch_stun.c STUN (Simple Traversal of UDP over NAT)
@@ -91,18 +92,18 @@
 {
 	char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 	int max;
-	uint8_t x;
+	uint16_t x;
 
 	if (!set) {
 		set = chars;
 	}
 
-	max = (int)strlen(set) - 1;
+	max = (int)strlen(set);
 
 	srand((unsigned int)apr_time_now());
 
 	for(x = 0; x < len; x++) {
-		int j = 1+(int)(max*1.0*rand()/(RAND_MAX+1.0));
+		int j = (int)(max*1.0*rand()/(RAND_MAX+1.0));
 		buf[x] = set[j];
 	}
 }
@@ -268,12 +269,12 @@
 	return 1;
 }
 
-SWITCH_DECLARE(switch_status) switch_stun_lookup (char **ip, 
+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 *pool)
+												  switch_memory_pool_t *pool)
 	 
 {
 	switch_sockaddr_t *local_addr = NULL, *remote_addr = NULL, *from_addr = NULL;

Modified: freeswitch/branches/voctel/src/switch_utils.c
==============================================================================
--- freeswitch/branches/voctel/src/switch_utils.c	(original)
+++ freeswitch/branches/voctel/src/switch_utils.c	Fri Sep 22 14:22:15 2006
@@ -34,16 +34,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-SWITCH_DECLARE(switch_status) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, switch_size_t *len)
-{
-	switch_status status;
-
-	if ((status = apr_socket_recvfrom(from, sock, flags, buf, len)) == SWITCH_STATUS_SUCCESS) {
-		from->port = ntohs(from->sa.sin.sin_port);
-	}
-	return status;
-}
-
 SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
 {
 	switch(priority) { /*lol*/
@@ -62,7 +52,7 @@
 
 SWITCH_DECLARE(char) switch_rfc2833_to_char(int event)
 {
-	if (event > -1 && event < sizeof(RFC2833_CHARS)) {
+	if (event > -1 && event < (int32_t) sizeof(RFC2833_CHARS)) {
 		return RFC2833_CHARS[event];
 	}
 	return '\0';
@@ -85,8 +75,9 @@
 SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen)
 {
 	int argc;
-	char *scan;
-	int paren = 0;
+	char *ptr;
+	int quot = 0;
+	char qc = '"';
 
 	if (!buf || !array || !arraylen) {
 		return 0;
@@ -94,25 +85,33 @@
 
 	memset(array, 0, arraylen * sizeof(*array));
 
-	scan = buf;
+	ptr = buf;
 
-	for (argc = 0; *scan && (argc < arraylen - 1); argc++) {
-		array[argc] = scan;
-		for (; *scan; scan++) {
-			if (*scan == '(')
-				paren++;
-			else if (*scan == ')') {
-				if (paren)
-					paren--;
-			} else if ((*scan == delim) && !paren) {
-				*scan++ = '\0';
+	for (argc = 0; *ptr && (argc < arraylen - 1); argc++) {
+		array[argc] = ptr;
+		for (; *ptr; ptr++) {
+			if (*ptr == qc) {
+				if (quot) {
+					quot--;
+				} else {
+					quot++;
+				}
+			} else if ((*ptr == delim) && !quot) {
+				*ptr++ = '\0';
 				break;
 			}
 		}
 	}
 
-	if (*scan) {
-		array[argc++] = scan;
+	if (*ptr) {
+		char *e;
+		if (*ptr == qc) {
+			ptr++;
+		}
+		if ((e = strchr(ptr, qc))) {
+			*e = '\0';
+		}
+		array[argc++] = ptr;
 	}
 
 	return argc;
@@ -133,8 +132,8 @@
 	return ret;
 }
 
-SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
-														  switch_int16_t flags, switch_memory_pool *pool)
+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
+														  switch_int16_t flags, switch_memory_pool_t *pool)
 {
 	switch_pollset_t *pollset;
 
@@ -154,7 +153,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len)
+SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len)
 {
 	size_t i;
 
@@ -205,12 +204,55 @@
 {
 	int nsds = 0;
 
-	if (switch_poll(poll, 1, &nsds, ms) != SWITCH_STATUS_SUCCESS) {
-		return -1;
-	}
+	switch_poll(poll, 1, &nsds, ms);
 
 	return nsds;
 }
+
+
+SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len)
+{
+    char *p;
+    size_t x = 0;
+    const char urlunsafe[] = " \"#%&+:;<=>?@[\\]^`{|}";
+    const char hex[] = "0123456789ABCDEF";
+
+    memset(buf, 0, len);
+    for( p = url ; *p ; p++) {
+        if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) {
+            if ((x + 3) > len) {
+                break;
+            }
+            buf[x++] = '%';
+            buf[x++] = hex[*p >> 4];
+            buf[x++] = hex[*p & 0x0f];
+        } else {
+            buf[x++] = *p;
+        }
+        if (x == len) {
+            break;
+        }
+    }
+    return x;
+}
+
+SWITCH_DECLARE(char *) switch_url_decode(char *s)
+{
+	char *o;
+	unsigned int tmp;
+
+	for (o = s; *s; s++, o++) {
+		if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) {
+			*o = (char)tmp;
+			s += 2;
+		} else {
+			*o = *s;
+		}
+	}
+	*o = '\0';
+	return s;
+}
+
 
 #ifdef WIN32
 //this forces certain symbols to not be optimized out of the dll

Modified: freeswitch/branches/voctel/w32/Setup/Setup.vdproj
==============================================================================
--- freeswitch/branches/voctel/w32/Setup/Setup.vdproj	(original)
+++ freeswitch/branches/voctel/w32/Setup/Setup.vdproj	Fri Sep 22 14:22:15 2006
@@ -15,37 +15,37 @@
     {
         "Entry"
         {
-        "MsmKey" = "8:_10A983E896C14286A47AAB6A8570EE6D"
+        "MsmKey" = "8:_0A2A2813738E4157B2CC6A4EF2A303BB"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
         "MsmKey" = "8:_1273F63008CF585CA0E063E436B4646F"
-        "OwnerKey" = "8:_EC68A140B58841DA9B9172BAFA5BEC63"
+        "OwnerKey" = "8:_2D09AB81AB8D45FF97E9DFA4DAC3465D"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
         "MsmKey" = "8:_1273F63008CF585CA0E063E436B4646F"
-        "OwnerKey" = "8:_2D09AB81AB8D45FF97E9DFA4DAC3465D"
+        "OwnerKey" = "8:_EC68A140B58841DA9B9172BAFA5BEC63"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_17FA3245B71F43BB9B2D995E3EE91051"
-        "OwnerKey" = "8:_833354487E2841DDA7386EB492D2F21C"
+        "MsmKey" = "8:_1CFB1AB04E024FC993E0EB4859DF8408"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_21821613411D407DA8261A0175360475"
+        "MsmKey" = "8:_2814E641538B42EFA83525986A9D5AC1"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_2BA713204D6542A9A0DE1694316EAB1A"
+        "MsmKey" = "8:_28FBC5A60B44423B8A2CC378347483CE"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
@@ -69,25 +69,25 @@
         }
         "Entry"
         {
-        "MsmKey" = "8:_36D88C9590054DCA8F6ABAE6F05C2FD6"
-        "OwnerKey" = "8:_UNDEFINED"
+        "MsmKey" = "8:_329D8DAE6C01FCF026E9DFB48B932203"
+        "OwnerKey" = "8:_28FBC5A60B44423B8A2CC378347483CE"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_3F927D72DFA53DCF09A9D5F6EB00333D"
-        "OwnerKey" = "8:_E72980C058C646E0A7FAF423EB57EA6E"
+        "MsmKey" = "8:_3FBEFE0119944C6781F81104ECEF37CA"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_413E616556854689B457A68A06830A82"
+        "MsmKey" = "8:_4A285D260C3748A4BEFA6E5A9004D128"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_4A285D260C3748A4BEFA6E5A9004D128"
+        "MsmKey" = "8:_59CFED0C4EC0492C945E4EBC04FE965F"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
@@ -99,180 +99,318 @@
         }
         "Entry"
         {
-        "MsmKey" = "8:_6226FB225DD41E9D0065BE7F6180D40E"
-        "OwnerKey" = "8:_EE46A936D4054F7286909355BF2AE5D7"
+        "MsmKey" = "8:_684D96FA2BDD46909367E651099D8C4E"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_6226FB225DD41E9D0065BE7F6180D40E"
-        "OwnerKey" = "8:_6753CE9F969E43A2A50ADEC0245F58A4"
+        "MsmKey" = "8:_69EB1A147CC2428435BDCA35014C96E1"
+        "OwnerKey" = "8:_D2EF447106B24E67907DAED3D39CFBB1"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_6753CE9F969E43A2A50ADEC0245F58A4"
+        "MsmKey" = "8:_6E5C001E7A314DCEA0A4BF52BF74BCAD"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_684D96FA2BDD46909367E651099D8C4E"
+        "MsmKey" = "8:_72A8732C0C0C4D0EAAE89DBB82073335"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_6E5C001E7A314DCEA0A4BF52BF74BCAD"
+        "MsmKey" = "8:_7358123D2D064AD1BC517911A8B23D1B"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_72A8732C0C0C4D0EAAE89DBB82073335"
+        "MsmKey" = "8:_81546E20D5C640AC84C7B7E100280727"
+        "OwnerKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_83062AA0528B40A59202BC7668F7132A"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_7358123D2D064AD1BC517911A8B23D1B"
+        "MsmKey" = "8:_83C1B93AD71B4F8F9E074F9607B60DF1"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_2F2FEC549F02436EB87961BD1B9E5783"
+        "MsmKey" = "8:_87768631363249B2B301143C193612F7"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_B20769E090034897B32E3EA4EC1BA8A0"
+        "MsmKey" = "8:_879085EF680EFDF6242DCB77439EC825"
+        "OwnerKey" = "8:_3FBEFE0119944C6781F81104ECEF37CA"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_A0D5F714A0F94250A1C39603B699AB82"
+        "MsmKey" = "8:_879085EF680EFDF6242DCB77439EC825"
+        "OwnerKey" = "8:_F0B800E719294692A02518CFD8CBAEFF"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_4A285D260C3748A4BEFA6E5A9004D128"
+        "MsmKey" = "8:_879085EF680EFDF6242DCB77439EC825"
+        "OwnerKey" = "8:_D2EF447106B24E67907DAED3D39CFBB1"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_6753CE9F969E43A2A50ADEC0245F58A4"
+        "MsmKey" = "8:_879085EF680EFDF6242DCB77439EC825"
+        "OwnerKey" = "8:_59CFED0C4EC0492C945E4EBC04FE965F"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_EE46A936D4054F7286909355BF2AE5D7"
+        "MsmKey" = "8:_91BA2668F87764F53188E93BC8D363D7"
+        "OwnerKey" = "8:_59CFED0C4EC0492C945E4EBC04FE965F"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_E72980C058C646E0A7FAF423EB57EA6E"
+        "MsmKey" = "8:_9A293E8A356A4959BB6E541B7DC213CD"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_83C1B93AD71B4F8F9E074F9607B60DF1"
+        "MsmKey" = "8:_A0D5F714A0F94250A1C39603B699AB82"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_833354487E2841DDA7386EB492D2F21C"
-        "OwnerKey" = "8:_318FCC99E8D143D6B4F9F534E63009B3"
+        "MsmKey" = "8:_A164EF86C4B57E41C8CE77B48F39DAC7"
+        "OwnerKey" = "8:_D2EF447106B24E67907DAED3D39CFBB1"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_83C1B93AD71B4F8F9E074F9607B60DF1"
+        "MsmKey" = "8:_A3936A2727E73289F5804D5DA006FD0A"
+        "OwnerKey" = "8:_28FBC5A60B44423B8A2CC378347483CE"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_A40E3F2045F44C60A8509FDFE47E6C45"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_87768631363249B2B301143C193612F7"
+        "MsmKey" = "8:_A944ADCEDF884574A23F7BA5420A6BA1"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_95DF1AC815283888345057940530D1C0"
-        "OwnerKey" = "8:_F0B800E719294692A02518CFD8CBAEFF"
+        "MsmKey" = "8:_AD2EB44FE6D548F2A8DA4F9F2CE817AC"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_9A293E8A356A4959BB6E541B7DC213CD"
+        "MsmKey" = "8:_B0A2E9B4C45D4098AFD734D0C4E3EAFB"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_A0D5F714A0F94250A1C39603B699AB82"
+        "MsmKey" = "8:_B20769E090034897B32E3EA4EC1BA8A0"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_AD2EB44FE6D548F2A8DA4F9F2CE817AC"
+        "MsmKey" = "8:_BB649A2C1ABE4895859025B09A240323"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_B20769E090034897B32E3EA4EC1BA8A0"
+        "MsmKey" = "8:_C105055EE271471A999CE7022E617EB7"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_B4DB166A7F41DC9EF58E277B90CC68AB"
-        "OwnerKey" = "8:_E72980C058C646E0A7FAF423EB57EA6E"
+        "MsmKey" = "8:_C81AC700C1BC4A55B98DF12C0CBAFD6F"
+        "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_B4DB166A7F41DC9EF58E277B90CC68AB"
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_1CFB1AB04E024FC993E0EB4859DF8408"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
         "OwnerKey" = "8:_F0B800E719294692A02518CFD8CBAEFF"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_C81AC700C1BC4A55B98DF12C0CBAFD6F"
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_EF14CB99F3414BB689D0CB0E6D6B8AB8"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_D2EF447106B24E67907DAED3D39CFBB1"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_D1269F1E49D442CF8EAC96C23E60325D"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_BB649A2C1ABE4895859025B09A240323"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_B20769E090034897B32E3EA4EC1BA8A0"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_A944ADCEDF884574A23F7BA5420A6BA1"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_A0D5F714A0F94250A1C39603B699AB82"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_83C1B93AD71B4F8F9E074F9607B60DF1"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_59CFED0C4EC0492C945E4EBC04FE965F"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_4A285D260C3748A4BEFA6E5A9004D128"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_3FBEFE0119944C6781F81104ECEF37CA"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_318FCC99E8D143D6B4F9F534E63009B3"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_2F2FEC549F02436EB87961BD1B9E5783"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_28FBC5A60B44423B8A2CC378347483CE"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_C9F3C77CAD1B477CA4024D8933D51913"
+        "OwnerKey" = "8:_2814E641538B42EFA83525986A9D5AC1"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_D0BB09AFB8D94B76918F0EE85BCCAD0A"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_D7EC5795A9C645AC8E129C2EE6D461ED"
+        "MsmKey" = "8:_D1269F1E49D442CF8EAC96C23E60325D"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_E4BCD553B2054B0F8BC67428E1A11674"
+        "MsmKey" = "8:_D2EF447106B24E67907DAED3D39CFBB1"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
-        "MsmKey" = "8:_E72980C058C646E0A7FAF423EB57EA6E"
+        "MsmKey" = "8:_D6F0F5845FAD4707975CE012A33CD607"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
         "Entry"
         {
+        "MsmKey" = "8:_D7E82DD20D5B47395F635480C8E3A1D3"
+        "OwnerKey" = "8:_F0B800E719294692A02518CFD8CBAEFF"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_D7EC5795A9C645AC8E129C2EE6D461ED"
+        "OwnerKey" = "8:_UNDEFINED"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_E1CC91FCF87955D17FC3C0A8E875B690"
+        "OwnerKey" = "8:_59CFED0C4EC0492C945E4EBC04FE965F"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_E1CC91FCF87955D17FC3C0A8E875B690"
+        "OwnerKey" = "8:_5A636BB90F7F4B86ACB8839EA2C899AA"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
+        "MsmKey" = "8:_E4BCD553B2054B0F8BC67428E1A11674"
+        "OwnerKey" = "8:_UNDEFINED"
+        "MsmSig" = "8:_UNDEFINED"
+        }
+        "Entry"
+        {
         "MsmKey" = "8:_E763C699DF0948B6984DDEB96A2DFD06"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
@@ -285,7 +423,7 @@
         }
         "Entry"
         {
-        "MsmKey" = "8:_EE46A936D4054F7286909355BF2AE5D7"
+        "MsmKey" = "8:_EF14CB99F3414BB689D0CB0E6D6B8AB8"
         "OwnerKey" = "8:_UNDEFINED"
         "MsmSig" = "8:_UNDEFINED"
         }
@@ -347,6 +485,43 @@
                 }
             }
         }
+        "Debug with MySql"
+        {
+        "DisplayName" = "8:Debug with MySql"
+        "IsDebugOnly" = "11:FALSE"
+        "IsReleaseOnly" = "11:FALSE"
+        "OutputFilename" = "8:Debug with MySql\\Setup.msi"
+        "PackageFilesAs" = "3:2"
+        "PackageFileSize" = "3:-2147483648"
+        "CabType" = "3:1"
+        "Compression" = "3:2"
+        "SignOutput" = "11:FALSE"
+        "CertificateFile" = "8:"
+        "PrivateKeyFile" = "8:"
+        "TimeStampServer" = "8:"
+        "InstallerBootstrapper" = "3:2"
+            "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
+            {
+            "Enabled" = "11:FALSE"
+            "PromptEnabled" = "11:TRUE"
+            "PrerequisitesLocation" = "2:1"
+            "Url" = "8:"
+            "ComponentsUrl" = "8:"
+                "Items"
+                {
+                    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Visual.C++.8.0.x86"
+                    {
+                    "Name" = "8:Visual C++ Runtime Libraries (x86)"
+                    "ProductCode" = "8:Microsoft.Visual.C++.8.0.x86"
+                    }
+                    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1"
+                    {
+                    "Name" = "8:Windows Installer 3.1"
+                    "ProductCode" = "8:Microsoft.Windows.Installer.3.1"
+                    }
+                }
+            }
+        }
         "Release"
         {
         "DisplayName" = "8:Release"
@@ -384,6 +559,43 @@
                 }
             }
         }
+        "Release with MySql"
+        {
+        "DisplayName" = "8:Release with MySql"
+        "IsDebugOnly" = "11:FALSE"
+        "IsReleaseOnly" = "11:FALSE"
+        "OutputFilename" = "8:Release with MySql\\Setup.msi"
+        "PackageFilesAs" = "3:2"
+        "PackageFileSize" = "3:-2147483648"
+        "CabType" = "3:1"
+        "Compression" = "3:2"
+        "SignOutput" = "11:FALSE"
+        "CertificateFile" = "8:"
+        "PrivateKeyFile" = "8:"
+        "TimeStampServer" = "8:"
+        "InstallerBootstrapper" = "3:2"
+            "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
+            {
+            "Enabled" = "11:FALSE"
+            "PromptEnabled" = "11:TRUE"
+            "PrerequisitesLocation" = "2:1"
+            "Url" = "8:"
+            "ComponentsUrl" = "8:"
+                "Items"
+                {
+                    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Visual.C++.8.0.x86"
+                    {
+                    "Name" = "8:Visual C++ Runtime Libraries (x86)"
+                    "ProductCode" = "8:Microsoft.Visual.C++.8.0.x86"
+                    }
+                    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1"
+                    {
+                    "Name" = "8:Windows Installer 3.1"
+                    "ProductCode" = "8:Microsoft.Windows.Installer.3.1"
+                    }
+                }
+            }
+        }
     }
     "Deployable"
     {
@@ -404,6 +616,26 @@
         }
         "File"
         {
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0A2A2813738E4157B2CC6A4EF2A303BB"
+            {
+            "SourcePath" = "8:..\\..\\AUTHORS"
+            "TargetName" = "8:AUTHORS"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            }
             "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1273F63008CF585CA0E063E436B4646F"
             {
             "SourcePath" = "8:iphlpapi.dll"
@@ -424,11 +656,51 @@
             "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_21821613411D407DA8261A0175360475"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_329D8DAE6C01FCF026E9DFB48B932203"
             {
-            "SourcePath" = "8:..\\..\\conf\\freeswitch.conf"
-            "TargetName" = "8:freeswitch.conf"
+            "SourcePath" = "8:MSWSOCK.dll"
+            "TargetName" = "8:MSWSOCK.dll"
             "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:TRUE"
+            "IsDependency" = "11:TRUE"
+            "IsolateTo" = "8:"
+            }
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_69EB1A147CC2428435BDCA35014C96E1"
+            {
+            "SourcePath" = "8:libsqlite.dll"
+            "TargetName" = "8:libsqlite.dll"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:TRUE"
+            "IsDependency" = "11:TRUE"
+            "IsolateTo" = "8:"
+            }
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_83062AA0528B40A59202BC7668F7132A"
+            {
+            "SourcePath" = "8:..\\..\\conf\\freeswitch.xml"
+            "TargetName" = "8:freeswitch.xml"
+            "Tag" = "8:"
             "Folder" = "8:_06036160035041E38F4179E6DB6380C5"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
@@ -444,12 +716,12 @@
             "IsDependency" = "11:FALSE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_36D88C9590054DCA8F6ABAE6F05C2FD6"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_879085EF680EFDF6242DCB77439EC825"
             {
-            "SourcePath" = "8:..\\..\\src\\mod\\languages\\mod_perl\\fs_perl.pm"
-            "TargetName" = "8:fs_perl.pm"
+            "SourcePath" = "8:libapr.dll"
+            "TargetName" = "8:libapr.dll"
             "Tag" = "8:"
-            "Folder" = "8:_27A96C279A6A44E8A2FDF8D51CD86E29"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
             "Vital" = "11:TRUE"
@@ -460,14 +732,14 @@
             "SharedLegacy" = "11:FALSE"
             "PackageAs" = "3:1"
             "Register" = "3:1"
-            "Exclude" = "11:FALSE"
-            "IsDependency" = "11:FALSE"
+            "Exclude" = "11:TRUE"
+            "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_3F927D72DFA53DCF09A9D5F6EB00333D"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_91BA2668F87764F53188E93BC8D363D7"
             {
-            "SourcePath" = "8:libaprutil-1.dll"
-            "TargetName" = "8:libaprutil-1.dll"
+            "SourcePath" = "8:libapriconv.dll"
+            "TargetName" = "8:libapriconv.dll"
             "Tag" = "8:"
             "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
             "Condition" = "8:"
@@ -480,16 +752,16 @@
             "SharedLegacy" = "11:FALSE"
             "PackageAs" = "3:1"
             "Register" = "3:1"
-            "Exclude" = "11:FALSE"
+            "Exclude" = "11:TRUE"
             "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_413E616556854689B457A68A06830A82"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A164EF86C4B57E41C8CE77B48F39DAC7"
             {
-            "SourcePath" = "8:..\\..\\src\\mod\\languages\\mod_perl\\freeswitch.pm"
-            "TargetName" = "8:freeswitch.pm"
+            "SourcePath" = "8:libaprutil.dll"
+            "TargetName" = "8:libaprutil.dll"
             "Tag" = "8:"
-            "Folder" = "8:_27A96C279A6A44E8A2FDF8D51CD86E29"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
             "Vital" = "11:TRUE"
@@ -500,14 +772,14 @@
             "SharedLegacy" = "11:FALSE"
             "PackageAs" = "3:1"
             "Register" = "3:1"
-            "Exclude" = "11:FALSE"
-            "IsDependency" = "11:FALSE"
+            "Exclude" = "11:TRUE"
+            "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_6226FB225DD41E9D0065BE7F6180D40E"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A3936A2727E73289F5804D5DA006FD0A"
             {
-            "SourcePath" = "8:perl58.dll"
-            "TargetName" = "8:perl58.dll"
+            "SourcePath" = "8:RPCRT4.dll"
+            "TargetName" = "8:RPCRT4.dll"
             "Tag" = "8:"
             "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
             "Condition" = "8:"
@@ -520,12 +792,32 @@
             "SharedLegacy" = "11:FALSE"
             "PackageAs" = "3:1"
             "Register" = "3:1"
-            "Exclude" = "11:FALSE"
+            "Exclude" = "11:TRUE"
             "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_95DF1AC815283888345057940530D1C0"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A40E3F2045F44C60A8509FDFE47E6C45"
             {
+            "SourcePath" = "8:..\\..\\COPYING"
+            "TargetName" = "8:COPYING"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            }
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D7E82DD20D5B47395F635480C8E3A1D3"
+            {
             "SourcePath" = "8:FreeSwitch.dll"
             "TargetName" = "8:FreeSwitch.dll"
             "Tag" = "8:"
@@ -544,12 +836,12 @@
             "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
-            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B4DB166A7F41DC9EF58E277B90CC68AB"
+            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E1CC91FCF87955D17FC3C0A8E875B690"
             {
-            "SourcePath" = "8:libapr-1.dll"
-            "TargetName" = "8:libapr-1.dll"
+            "SourcePath" = "8:WLDAP32.dll"
+            "TargetName" = "8:WLDAP32.dll"
             "Tag" = "8:"
-            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
             "Vital" = "11:TRUE"
@@ -560,7 +852,7 @@
             "SharedLegacy" = "11:FALSE"
             "PackageAs" = "3:1"
             "Register" = "3:1"
-            "Exclude" = "11:FALSE"
+            "Exclude" = "11:TRUE"
             "IsDependency" = "11:TRUE"
             "IsolateTo" = "8:"
             }
@@ -583,7 +875,7 @@
                     "{9EF0B969-E518-4E46-987F-47570745A589}:_06036160035041E38F4179E6DB6380C5"
                     {
                     "Name" = "8:conf"
-                    "AlwaysCreate" = "11:FALSE"
+                    "AlwaysCreate" = "11:TRUE"
                     "Condition" = "8:"
                     "Transitive" = "11:FALSE"
                     "Property" = "8:_A95348FEFEF74A31B7C08B4201803CBD"
@@ -594,7 +886,7 @@
                     "{9EF0B969-E518-4E46-987F-47570745A589}:_1C97B9EB8E024EE0AA5282BFBE006743"
                     {
                     "Name" = "8:db"
-                    "AlwaysCreate" = "11:FALSE"
+                    "AlwaysCreate" = "11:TRUE"
                     "Condition" = "8:"
                     "Transitive" = "11:FALSE"
                     "Property" = "8:_9E6DFB10CEE3456A82E42EA3751A0A25"
@@ -605,7 +897,7 @@
                     "{9EF0B969-E518-4E46-987F-47570745A589}:_27A96C279A6A44E8A2FDF8D51CD86E29"
                     {
                     "Name" = "8:perl"
-                    "AlwaysCreate" = "11:FALSE"
+                    "AlwaysCreate" = "11:TRUE"
                     "Condition" = "8:"
                     "Transitive" = "11:FALSE"
                     "Property" = "8:_0FB0CAEBEEBE4B9D8C6EC760DB498632"
@@ -616,7 +908,7 @@
                     "{9EF0B969-E518-4E46-987F-47570745A589}:_B6E020422C78490D96F78DB0E1A3F521"
                     {
                     "Name" = "8:mod"
-                    "AlwaysCreate" = "11:FALSE"
+                    "AlwaysCreate" = "11:TRUE"
                     "Condition" = "8:"
                     "Transitive" = "11:FALSE"
                     "Property" = "8:_09F2F8E16214428B84412E224BAA50C1"
@@ -624,6 +916,17 @@
                         {
                         }
                     }
+                    "{9EF0B969-E518-4E46-987F-47570745A589}:_ED8FE817D10341CEBA2571A43326876F"
+                    {
+                    "Name" = "8:log"
+                    "AlwaysCreate" = "11:TRUE"
+                    "Condition" = "8:"
+                    "Transitive" = "11:FALSE"
+                    "Property" = "8:_673CC6A86CF64CC2BD137EF46A3AD379"
+                        "Folders"
+                        {
+                        }
+                    }
                 }
             }
             "{1525181F-901A-416C-8A58-119130FE478E}:_47AC7012FEA1483795137E042EAAA132"
@@ -664,14 +967,14 @@
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:Freeswitch"
         "ProductCode" = "8:{317A9CC0-40DC-4803-A13E-5937F05F9D2E}"
-        "PackageCode" = "8:{35F86401-29E6-4EA4-9362-D05B6C91426B}"
+        "PackageCode" = "8:{35A30F10-964D-4C59-A882-360D2CAC47EC}"
         "UpgradeCode" = "8:{8080E3A5-7ADD-4173-8913-BDA439D1C8DD}"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:FALSE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
         "ProductVersion" = "8:1.0.0"
-        "Manufacturer" = "8:Freeswitch"
+        "Manufacturer" = "8:Freeswitch.org"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:"
         "Title" = "8:Freeswitch"
@@ -679,7 +982,7 @@
         "ARPCONTACT" = "8:"
         "Keywords" = "8:"
         "ARPCOMMENTS" = "8:"
-        "ARPURLINFOABOUT" = "8:"
+        "ARPURLINFOABOUT" = "8:http://www.freeswitch.org"
         "ARPPRODUCTICON" = "8:"
         "ARPIconIndex" = "3:0"
         "SearchPath" = "8:"
@@ -716,6 +1019,14 @@
                                 }
                                 "Values"
                                 {
+                                    "{ADCFDA98-8FDD-45E4-90BC-E3D20B029870}:_C59781825E5B4A9AA93BDAA5A88B7390"
+                                    {
+                                    "Name" = "8:[ProductName]"
+                                    "Condition" = "8:"
+                                    "Transitive" = "11:FALSE"
+                                    "ValueTypes" = "3:1"
+                                    "Value" = "8:"
+                                    }
                                 }
                             }
                         }
@@ -930,6 +1241,53 @@
                             }
                         }
                     }
+                    "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_E8A0FD168FA4401FBF582E01DA819A71"
+                    {
+                    "Sequence" = "3:210"
+                    "DisplayName" = "8:License Agreement"
+                    "UseDynamicProperties" = "11:TRUE"
+                    "IsDependency" = "11:FALSE"
+                    "SourcePath" = "8:<VsdDialogDir>\\VsdAdminLicenseDlg.wid"
+                        "Properties"
+                        {
+                            "BannerBitmap"
+                            {
+                            "Name" = "8:BannerBitmap"
+                            "DisplayName" = "8:#1001"
+                            "Description" = "8:#1101"
+                            "Type" = "3:8"
+                            "ContextData" = "8:Bitmap"
+                            "Attributes" = "3:4"
+                            "Setting" = "3:1"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                            "EulaText"
+                            {
+                            "Name" = "8:EulaText"
+                            "DisplayName" = "8:#1008"
+                            "Description" = "8:#1108"
+                            "Type" = "3:6"
+                            "ContextData" = "8:"
+                            "Attributes" = "3:0"
+                            "Setting" = "3:2"
+                            "Value" = "8:_A40E3F2045F44C60A8509FDFE47E6C45"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                            "Sunken"
+                            {
+                            "Name" = "8:Sunken"
+                            "DisplayName" = "8:#1007"
+                            "Description" = "8:#1107"
+                            "Type" = "3:5"
+                            "ContextData" = "8:4;True=4;False=0"
+                            "Attributes" = "3:0"
+                            "Setting" = "3:0"
+                            "Value" = "3:4"
+                            "DefaultValue" = "3:4"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                        }
+                    }
                 }
             }
             "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_9237AC900FC7421096FC1C1F479A57D9"
@@ -1031,9 +1389,56 @@
                             }
                         }
                     }
-                    "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_3106DA132FA54E148478AB6CBA658548"
+                    "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_1229F6668E004795AE90C753D37CA881"
                     {
                     "Sequence" = "3:300"
+                    "DisplayName" = "8:License Agreement"
+                    "UseDynamicProperties" = "11:TRUE"
+                    "IsDependency" = "11:FALSE"
+                    "SourcePath" = "8:<VsdDialogDir>\\VsdLicenseDlg.wid"
+                        "Properties"
+                        {
+                            "BannerBitmap"
+                            {
+                            "Name" = "8:BannerBitmap"
+                            "DisplayName" = "8:#1001"
+                            "Description" = "8:#1101"
+                            "Type" = "3:8"
+                            "ContextData" = "8:Bitmap"
+                            "Attributes" = "3:4"
+                            "Setting" = "3:1"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                            "EulaText"
+                            {
+                            "Name" = "8:EulaText"
+                            "DisplayName" = "8:#1008"
+                            "Description" = "8:#1108"
+                            "Type" = "3:6"
+                            "ContextData" = "8:"
+                            "Attributes" = "3:0"
+                            "Setting" = "3:2"
+                            "Value" = "8:_A40E3F2045F44C60A8509FDFE47E6C45"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                            "Sunken"
+                            {
+                            "Name" = "8:Sunken"
+                            "DisplayName" = "8:#1007"
+                            "Description" = "8:#1107"
+                            "Type" = "3:5"
+                            "ContextData" = "8:4;True=4;False=0"
+                            "Attributes" = "3:0"
+                            "Setting" = "3:0"
+                            "Value" = "3:4"
+                            "DefaultValue" = "3:4"
+                            "UsePlugInResources" = "11:TRUE"
+                            }
+                        }
+                    }
+                    "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_E4748A502E1E4F89B72F6B70E40E6954"
+                    {
+                    "Sequence" = "3:400"
                     "DisplayName" = "8:Confirm Installation"
                     "UseDynamicProperties" = "11:TRUE"
                     "IsDependency" = "11:FALSE"
@@ -1193,7 +1598,7 @@
         }
         "MergeModule"
         {
-            "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_17FA3245B71F43BB9B2D995E3EE91051"
+            "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_81546E20D5C640AC84C7B7E100280727"
             {
             "UseDynamicProperties" = "11:TRUE"
             "IsDependency" = "11:TRUE"
@@ -1207,7 +1612,7 @@
             "Feature" = "8:"
             "IsolateTo" = "8:"
             }
-            "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_833354487E2841DDA7386EB492D2F21C"
+            "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_C9F3C77CAD1B477CA4024D8933D51913"
             {
             "UseDynamicProperties" = "11:TRUE"
             "IsDependency" = "11:TRUE"
@@ -1224,9 +1629,9 @@
         }
         "ProjectOutput"
         {
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_10A983E896C14286A47AAB6A8570EE6D"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_1CFB1AB04E024FC993E0EB4859DF8408"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_ivrtest.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_dingaling.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1246,15 +1651,15 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{419AA391-5F3F-4BFE-A869-9D154D62A792}"
+            "OutputProjectGuid" = "8:{FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2BA713204D6542A9A0DE1694316EAB1A"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2814E641538B42EFA83525986A9D5AC1"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_dialplan_demo.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_ilbc.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1274,15 +1679,43 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{2988EB83-785F-45D4-8731-8E1E4345177E}"
+            "OutputProjectGuid" = "8:{D3EC0AFF-76FC-4210-A825-9A17410660A3}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_28FBC5A60B44423B8A2CC378347483CE"
+            {
+            "SourcePath" = "8:..\\..\\debug\\libapr.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{F6C55D93-B927-4483-BB69-15AEF3DD2DFF}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2D09AB81AB8D45FF97E9DFA4DAC3465D"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_zeroconf.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_zeroconf.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1310,7 +1743,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2F2FEC549F02436EB87961BD1B9E5783"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_iax.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_iax.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1338,7 +1771,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_318FCC99E8D143D6B4F9F534E63009B3"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_sndfile.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_sndfile.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1364,9 +1797,37 @@
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_3FBEFE0119944C6781F81104ECEF37CA"
+            {
+            "SourcePath" = "8:..\\..\\debug\\libapriconv.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{101130D1-3EA6-4ED2-B65D-CEB5243A20ED}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_4A285D260C3748A4BEFA6E5A9004D128"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_spidermonkey.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_spidermonkey.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1392,12 +1853,12 @@
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_5A636BB90F7F4B86ACB8839EA2C899AA"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_59CFED0C4EC0492C945E4EBC04FE965F"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_ldap.dll"
+            "SourcePath" = "8:..\\..\\debug\\libaprutil.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
-            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
             "Vital" = "11:TRUE"
@@ -1414,15 +1875,15 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{EC3E5C7F-EE09-47E2-80FE-546363D14A98}"
+            "OutputProjectGuid" = "8:{F057DA7F-79E5-4B00-845C-EF446EF055E3}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_6753CE9F969E43A2A50ADEC0245F58A4"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_5A636BB90F7F4B86ACB8839EA2C899AA"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_perl.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_ldap.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1442,7 +1903,7 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{7B077E7F-1BE7-4291-AB86-55E527B25CAC}"
+            "OutputProjectGuid" = "8:{EC3E5C7F-EE09-47E2-80FE-546363D14A98}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
@@ -1450,7 +1911,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_684D96FA2BDD46909367E651099D8C4E"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_dialplan_directory.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_dialplan_directory.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1478,7 +1939,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_6E5C001E7A314DCEA0A4BF52BF74BCAD"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_speex.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_speex.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1506,7 +1967,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_72A8732C0C0C4D0EAAE89DBB82073335"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_playback.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_playback.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1534,7 +1995,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_7358123D2D064AD1BC517911A8B23D1B"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_softtimer.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_softtimer.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1562,7 +2023,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_83C1B93AD71B4F8F9E074F9607B60DF1"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_xmpp_event.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_xmpp_event.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1590,7 +2051,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_87768631363249B2B301143C193612F7"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_g711.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_g711.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1618,7 +2079,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_9A293E8A356A4959BB6E541B7DC213CD"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_bridgecall.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_bridgecall.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1646,7 +2107,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_A0D5F714A0F94250A1C39603B699AB82"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\libteletone.dll"
+            "SourcePath" = "8:..\\..\\libs\\libteletone\\Debug\\libteletone.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
@@ -1672,9 +2133,37 @@
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_A944ADCEDF884574A23F7BA5420A6BA1"
+            {
+            "SourcePath" = "8:..\\..\\debug\\libsqlite.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_AD2EB44FE6D548F2A8DA4F9F2CE817AC"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_l16.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_l16.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1700,9 +2189,37 @@
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_B0A2E9B4C45D4098AFD734D0C4E3EAFB"
+            {
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_conference.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{C24FB505-05D7-4319-8485-7540B44C8603}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_B20769E090034897B32E3EA4EC1BA8A0"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_gsm.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_gsm.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1728,9 +2245,65 @@
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BB649A2C1ABE4895859025B09A240323"
+            {
+            "SourcePath" = "8:..\\..\\debug\\libpcre.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{8D04B550-D240-4A44-8A18-35DA3F7038D9}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_C105055EE271471A999CE7022E617EB7"
+            {
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_commands.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{30A5B29C-983E-4580-9FD0-D647CCDCC7EB}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_C81AC700C1BC4A55B98DF12C0CBAFD6F"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_pcre.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_dialplan_xml.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1756,9 +2329,9 @@
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D7EC5795A9C645AC8E129C2EE6D461ED"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D0BB09AFB8D94B76918F0EE85BCCAD0A"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_event_multicast.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_dptools.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1778,15 +2351,15 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{784113EF-44D9-4949-835D-7065D3C7AD08}"
+            "OutputProjectGuid" = "8:{B5881A85-FE70-4F64-8607-2CAAE52669C6}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E4BCD553B2054B0F8BC67428E1A11674"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D1269F1E49D442CF8EAC96C23E60325D"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_echo.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_xml_rpc.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1806,15 +2379,15 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{0E2C6395-13B9-46E5-9264-8859D346018D}"
+            "OutputProjectGuid" = "8:{CBEC7225-0C21-4DA8-978E-1F158F8AD950}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E72980C058C646E0A7FAF423EB57EA6E"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D2EF447106B24E67907DAED3D39CFBB1"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\FreeSwitch.dll"
+            "SourcePath" = "8:..\\..\\debug\\FreeSwitch.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
@@ -1840,9 +2413,93 @@
                 {
                 }
             }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D6F0F5845FAD4707975CE012A33CD607"
+            {
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_rss.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D7EC5795A9C645AC8E129C2EE6D461ED"
+            {
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_event_multicast.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{784113EF-44D9-4949-835D-7065D3C7AD08}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E4BCD553B2054B0F8BC67428E1A11674"
+            {
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_echo.dll"
+            "TargetName" = "8:"
+            "Tag" = "8:"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
+            "Condition" = "8:"
+            "Transitive" = "11:FALSE"
+            "Vital" = "11:TRUE"
+            "ReadOnly" = "11:FALSE"
+            "Hidden" = "11:FALSE"
+            "System" = "11:FALSE"
+            "Permanent" = "11:FALSE"
+            "SharedLegacy" = "11:FALSE"
+            "PackageAs" = "3:1"
+            "Register" = "3:1"
+            "Exclude" = "11:FALSE"
+            "IsDependency" = "11:FALSE"
+            "IsolateTo" = "8:"
+            "ProjectOutputGroupRegister" = "3:1"
+            "OutputConfiguration" = "8:"
+            "OutputGroupCanonicalName" = "8:Built"
+            "OutputProjectGuid" = "8:{0E2C6395-13B9-46E5-9264-8859D346018D}"
+            "ShowKeyOutput" = "11:TRUE"
+                "ExcludeFilters"
+                {
+                }
+            }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E763C699DF0948B6984DDEB96A2DFD06"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_PortAudio.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_PortAudio.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1870,7 +2527,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EC68A140B58841DA9B9172BAFA5BEC63"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_exosip.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_exosip.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1896,12 +2553,12 @@
                 {
                 }
             }
-            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EE46A936D4054F7286909355BF2AE5D7"
+            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EF14CB99F3414BB689D0CB0E6D6B8AB8"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\Perl\\fs_perl.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_console.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
-            "Folder" = "8:_27A96C279A6A44E8A2FDF8D51CD86E29"
+            "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
             "Condition" = "8:"
             "Transitive" = "11:FALSE"
             "Vital" = "11:TRUE"
@@ -1918,7 +2575,7 @@
             "ProjectOutputGroupRegister" = "3:1"
             "OutputConfiguration" = "8:"
             "OutputGroupCanonicalName" = "8:Built"
-            "OutputProjectGuid" = "8:{B0C6CFF9-7DCD-4A21-8BA4-C2011E18DED8}"
+            "OutputProjectGuid" = "8:{1C453396-D912-4213-89FD-9B489162B7B5}"
             "ShowKeyOutput" = "11:TRUE"
                 "ExcludeFilters"
                 {
@@ -1926,7 +2583,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_F0B800E719294692A02518CFD8CBAEFF"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\FreeSwitch.exe"
+            "SourcePath" = "8:..\\..\\debug\\FreeSwitch.exe"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_04AC783F1C9F41AEB4E947C46CE9C9FF"
@@ -1954,7 +2611,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_F84240319757424DB1C58AD0AD420127"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_event_test.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_event_test.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"
@@ -1982,7 +2639,7 @@
             }
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_FB1B9FBDC3294F1C96DAC4246C013C22"
             {
-            "SourcePath" = "8:..\\vsnet\\Debug\\mod\\mod_woomera.dll"
+            "SourcePath" = "8:..\\..\\debug\\mod\\mod_woomera.dll"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_B6E020422C78490D96F78DB0E1A3F521"



More information about the Freeswitch-svn mailing list