[Freeswitch-svn] [commit] r4924 - in freeswitch/branches/mikej/sofiasip-upgrade: . build/config libs/apr-util libs/apr/include/arch/unix libs/curl libs/curl/docs libs/curl/lib libs/curl/src libs/curl/tests libs/js/nsprpub/pr/src libs/js/nsprpub/pr/src/io libs/js/nsprpub/pr/src/malloc libs/js/nsprpub/pr/src/md/unix libs/js/nsprpub/pr/src/memory libs/js/nsprpub/pr/src/misc libs/js/nsprpub/pr/src/pthreads libs/js/nsprpub/pr/src/threads libs/udns libs/win32/js libs/xmlrpc-c/src scripts/socket/FreeSWITCH scripts/socket/socket2me src src/include src/mod src/mod/applications/mod_enum src/mod/endpoints/mod_sofia src/mod/endpoints/mod_wanpipe src/mod/endpoints/mod_wanpipe/libsangoma src/mod/event_handlers/mod_cdr src/mod/languages/mod_spidermonkey_core_db

Freeswitch SVN mikej at freeswitch.org
Fri Apr 13 10:44:30 EDT 2007


Author: mikej
Date: Fri Apr 13 10:44:28 2007
New Revision: 4924

Added:
   freeswitch/branches/mikej/sofiasip-upgrade/build/config/libcurl.m4
      - copied unchanged from r4923, /freeswitch/trunk/build/config/libcurl.m4
   freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/socket2me/
      - copied from r4923, /freeswitch/trunk/scripts/socket/socket2me/
   freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/socket2me/Makefile
      - copied unchanged from r4923, /freeswitch/trunk/scripts/socket/socket2me/Makefile
   freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/socket2me/README
      - copied unchanged from r4923, /freeswitch/trunk/scripts/socket/socket2me/README
   freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/socket2me/socket2me.c
      - copied unchanged from r4923, /freeswitch/trunk/scripts/socket/socket2me/socket2me.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/lib_api.c
      - copied unchanged from r4923, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/lib_api.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/testapp.c
      - copied unchanged from r4923, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/testapp.c
Removed:
   freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/apr_private.h.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/docs/
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/tests/
Modified:
   freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4
   freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build-outputs.mk
   freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build.conf
   freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/configure.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/include/arch/unix/   (props changed)
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/   (props changed)
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/Makefile.am
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/configure.ac
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/lib/config.h.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.am
   freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.inc
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prfdcach.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/pripv6.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prlog.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/prmem.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/objs.mk
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/memory/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/prinit.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptio.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptthread.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/Makefile.in
   freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/prcthr.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/udns/udns_resolver.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/js/js.vcproj
   freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/src/Makefile
   freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/FreeSWITCH/Client.pm
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/Makefile
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/csvcdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/curlcdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/odbccdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/pddcdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/xmlcdr.cpp
   freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_db.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_session.c
   freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c

Log:
merged changes from trunk revisions 4899-4923.

Modified: freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4	Fri Apr 13 10:44:28 2007
@@ -6,4 +6,4 @@
 m4_include([build/config/ac_gcc_x86_cpuid.m4])
 m4_include([build/config/ax_lib_mysql.m4])
 m4_include([libs/apr/build/apr_common.m4])
-m4_include([libs/curl/docs/libcurl/libcurl.m4])
+m4_include([build/config/libcurl.m4])

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build-outputs.mk
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build-outputs.mk	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build-outputs.mk	Fri Apr 13 10:44:28 2007
@@ -38,7 +38,6 @@
 misc/apu_version.lo: misc/apu_version.c .make.dirs include/apu_version.h
 misc/apr_queue.lo: misc/apr_queue.c .make.dirs include/apr_queue.h
 uri/apr_uri.lo: uri/apr_uri.c .make.dirs include/apr_uri.h
-xml/apr_xml.lo: xml/apr_xml.c .make.dirs include/apr_xml.h include/apr_xlate.h
 strmatch/apr_strmatch.lo: strmatch/apr_strmatch.c .make.dirs include/apr_strmatch.h
 xlate/xlate.lo: xlate/xlate.c .make.dirs include/apr_xlate.h
 dbd/apr_dbd_sqlite2.lo: dbd/apr_dbd_sqlite2.c .make.dirs 
@@ -46,7 +45,7 @@
 dbd/apr_dbd.lo: dbd/apr_dbd.c .make.dirs include/apr_dbd.h
 dbd/apr_dbd_sqlite3.lo: dbd/apr_dbd_sqlite3.c .make.dirs 
 
-OBJECTS_all = buckets/apr_buckets_file.lo buckets/apr_brigade.lo buckets/apr_buckets_mmap.lo buckets/apr_buckets_heap.lo buckets/apr_buckets.lo buckets/apr_buckets_socket.lo buckets/apr_buckets_pool.lo buckets/apr_buckets_alloc.lo buckets/apr_buckets_pipe.lo buckets/apr_buckets_eos.lo buckets/apr_buckets_flush.lo buckets/apr_buckets_refcount.lo buckets/apr_buckets_simple.lo crypto/apr_md5.lo crypto/uuid.lo crypto/apr_sha1.lo crypto/getuuid.lo crypto/apr_md4.lo dbm/apr_dbm_berkeleydb.lo dbm/apr_dbm_gdbm.lo dbm/apr_dbm_ndbm.lo dbm/apr_dbm.lo dbm/apr_dbm_sdbm.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_option.lo ldap/apr_ldap_init.lo ldap/apr_ldap_url.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_date.lo misc/apu_version.lo misc/apr_queue.lo uri/apr_uri.lo xml/apr_xml.lo strmatch/apr_strmatch.lo xlate/xlate.lo dbd/apr_dbd_sqlite2.lo dbd/apr_dbd_pgsql.lo dbd/apr_dbd.lo dbd/apr_dbd_sqlite3.lo
+OBJECTS_all = buckets/apr_buckets_file.lo buckets/apr_brigade.lo buckets/apr_buckets_mmap.lo buckets/apr_buckets_heap.lo buckets/apr_buckets.lo buckets/apr_buckets_socket.lo buckets/apr_buckets_pool.lo buckets/apr_buckets_alloc.lo buckets/apr_buckets_pipe.lo buckets/apr_buckets_eos.lo buckets/apr_buckets_flush.lo buckets/apr_buckets_refcount.lo buckets/apr_buckets_simple.lo crypto/apr_md5.lo crypto/uuid.lo crypto/apr_sha1.lo crypto/getuuid.lo crypto/apr_md4.lo dbm/apr_dbm_berkeleydb.lo dbm/apr_dbm_gdbm.lo dbm/apr_dbm_ndbm.lo dbm/apr_dbm.lo dbm/apr_dbm_sdbm.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_option.lo ldap/apr_ldap_init.lo ldap/apr_ldap_url.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_date.lo misc/apu_version.lo misc/apr_queue.lo uri/apr_uri.lo strmatch/apr_strmatch.lo xlate/xlate.lo dbd/apr_dbd_sqlite2.lo dbd/apr_dbd_pgsql.lo dbd/apr_dbd.lo dbd/apr_dbd_sqlite3.lo
 
 OBJECTS_unix = $(OBJECTS_all)
 
@@ -58,11 +57,11 @@
 
 OBJECTS_os390 = $(OBJECTS_all)
 
-HEADERS = $(top_srcdir)/include/apr_optional.h $(top_srcdir)/include/apu_version.h $(top_srcdir)/include/apr_dbm.h $(top_srcdir)/include/apr_strmatch.h $(top_srcdir)/include/apr_buckets.h $(top_srcdir)/include/apr_optional_hooks.h $(top_srcdir)/include/apr_sdbm.h $(top_srcdir)/include/apr_md4.h $(top_srcdir)/include/apr_reslist.h $(top_srcdir)/include/apr_base64.h $(top_srcdir)/include/apr_ldap_option.h $(top_srcdir)/include/apr_xml.h $(top_srcdir)/include/apr_anylock.h $(top_srcdir)/include/apr_rmm.h $(top_srcdir)/include/apr_ldap_init.h $(top_srcdir)/include/apr_ldap_url.h $(top_srcdir)/include/apr_md5.h $(top_srcdir)/include/apr_date.h $(top_srcdir)/include/apr_hooks.h $(top_srcdir)/include/apr_xlate.h $(top_srcdir)/include/apr_queue.h $(top_srcdir)/include/apr_uri.h $(top_srcdir)/include/apr_uuid.h $(top_srcdir)/include/apr_sha1.h $(top_srcdir)/include/apr_dbd.h
+HEADERS = $(top_srcdir)/include/apr_optional.h $(top_srcdir)/include/apu_version.h $(top_srcdir)/include/apr_dbm.h $(top_srcdir)/include/apr_strmatch.h $(top_srcdir)/include/apr_buckets.h $(top_srcdir)/include/apr_optional_hooks.h $(top_srcdir)/include/apr_sdbm.h $(top_srcdir)/include/apr_md4.h $(top_srcdir)/include/apr_reslist.h $(top_srcdir)/include/apr_base64.h $(top_srcdir)/include/apr_ldap_option.h $(top_srcdir)/include/apr_anylock.h $(top_srcdir)/include/apr_rmm.h $(top_srcdir)/include/apr_ldap_init.h $(top_srcdir)/include/apr_ldap_url.h $(top_srcdir)/include/apr_md5.h $(top_srcdir)/include/apr_date.h $(top_srcdir)/include/apr_hooks.h $(top_srcdir)/include/apr_xlate.h $(top_srcdir)/include/apr_queue.h $(top_srcdir)/include/apr_uri.h $(top_srcdir)/include/apr_uuid.h $(top_srcdir)/include/apr_sha1.h $(top_srcdir)/include/apr_dbd.h
 
-SOURCE_DIRS = xml dbd dbm encoding hooks buckets misc crypto uri strmatch dbm/sdbm ldap xlate $(EXTRA_SOURCE_DIRS)
+SOURCE_DIRS = dbd dbm encoding hooks buckets misc crypto uri strmatch dbm/sdbm ldap xlate $(EXTRA_SOURCE_DIRS)
 
-BUILD_DIRS = buckets crypto dbd dbm dbm/sdbm encoding hooks ldap misc strmatch uri xlate xml
+BUILD_DIRS = buckets crypto dbd dbm dbm/sdbm encoding hooks ldap misc strmatch uri xlate
 
 .make.dirs: $(srcdir)/build-outputs.mk
 	@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build.conf
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build.conf	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build.conf	Fri Apr 13 10:44:28 2007
@@ -15,10 +15,10 @@
   ldap/*.c
   misc/*.c
   uri/apr_uri.c
-  xml/*.c
   strmatch/*.c
   xlate/*.c
   dbd/*.c
+#  xml/*.c
 
 # we have no platform-specific subdirs
 platform_dirs =

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/configure.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/configure.in	Fri Apr 13 10:44:28 2007
@@ -122,7 +122,7 @@
 APU_CHECK_DBD_MYSQL
 APU_CHECK_DBD_SQLITE3
 APU_CHECK_DBD_SQLITE2
-APU_FIND_EXPAT
+#APU_FIND_EXPAT
 APU_FIND_ICONV
 
 AC_SEARCH_LIBS(crypt, crypt ufc)

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/Makefile.am	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/Makefile.am	Fri Apr 13 10:44:28 2007
@@ -29,13 +29,12 @@
 bin_SCRIPTS = curl-config
 
 SUBDIRS = lib src
-DIST_SUBDIRS = $(SUBDIRS) tests include packages docs
+DIST_SUBDIRS = $(SUBDIRS) include packages
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcurl.pc
 
 dist-hook:
-	rm -rf $(top_builddir)/tests/log
 	find $(distdir) -name "*.dist" -exec rm {} \;
 	(distit=`find $(srcdir) -name "*.dist"`; \
 	for file in $$distit; do \
@@ -43,88 +42,11 @@
 	  cp $$file $(distdir)$$strip; \
 	done)
 
-html:
-	cd docs; make html
-
-pdf:
-	cd docs; make pdf
-
-check: test
-
-if CROSSCOMPILING
-test-full: test
-test-torture: test
-
-test:
-	@echo "NOTICE: we can't run the tests when cross-compiling!"
-
-else
-
-test:
-	@(cd tests; $(MAKE) all quiet-test)
-
-test-full:
-	@(cd tests; $(MAKE) all full-test)
-
-test-torture:
-	@(cd tests; $(MAKE) all torture-test)
-
-endif
-
-#
-# Build source and binary rpms. For rpm-3.0 and above, the ~/.rpmmacros
-# must contain the following line:
-# %_topdir /home/loic/local/rpm
-# and that /home/loic/local/rpm contains the directory SOURCES, BUILD etc.
-#
-# cd /home/loic/local/rpm ; mkdir -p SOURCES BUILD RPMS/i386 SPECS SRPMS
-#
-# If additional configure flags are needed to build the package, add the
-# following in ~/.rpmmacros
-# %configure CFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{_prefix} ${AM_CONFIGFLAGS}
-# and run make rpm in the following way:
-# AM_CONFIGFLAGS='--with-uri=/home/users/loic/local/RedHat-6.2' make rpm
-#
-
-rpms:
-	$(MAKE) RPMDIST=curl rpm
-	$(MAKE) RPMDIST=curl-ssl rpm
-
-rpm:
-	RPM_TOPDIR=`rpm --showrc | $(PERL) -n -e 'print if(s/.*_topdir\s+(.*)/$$1/)'` ; \
-	cp $(srcdir)/packages/Linux/RPM/$(RPMDIST).spec $$RPM_TOPDIR/SPECS ; \
-	cp $(PACKAGE)-$(VERSION).tar.gz $$RPM_TOPDIR/SOURCES ; \
-	rpm -ba --clean --rmsource $$RPM_TOPDIR/SPECS/$(RPMDIST).spec ; \
-	mv $$RPM_TOPDIR/RPMS/i386/$(RPMDIST)-*.rpm . ; \
-	mv $$RPM_TOPDIR/SRPMS/$(RPMDIST)-*.src.rpm .
-
-#
-# Build a Solaris pkkgadd format file
-# run 'make pkgadd' once you've done './configure' and 'make' to make a Solaris pkgadd format
-# file (which ends up back in this directory).
-# The pkgadd file is in 'pkgtrans' format, so to install on Solaris, do
-# pkgadd -d ./HAXXcurl-*
-#
-
-# gak - libtool requires an absoulte directory, hence the pwd below...
-pkgadd:
-	umask 022 ; \
-	make install DESTDIR=`/bin/pwd`/packages/Solaris/root ; \
-	cat COPYING > $(srcdir)/packages/Solaris/copyright ; \
-	cd $(srcdir)/packages/Solaris && $(MAKE) package
-
-#
-# Build a cygwin binary tarball installation file
-# resulting .tar.bz2 file will end up at packages/Win32/cygwin
-cygwinbin:
-	$(MAKE) -C packages/Win32/cygwin cygwinbin
-
 # We extend the standard install with a custom hook:
 install-data-hook:
 	cd include && $(MAKE) install
-	cd docs && $(MAKE) install
 
 # We extend the standard uninstall with a custom hook:
 uninstall-hook:
 	cd include && $(MAKE) uninstall
-	cd docs && $(MAKE) uninstall
+

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/configure.ac
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/configure.ac	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/configure.ac	Fri Apr 13 10:44:28 2007
@@ -34,7 +34,7 @@
 
 AC_CONFIG_SRCDIR([lib/urldata.h])
 AM_CONFIG_HEADER(lib/config.h src/config.h)
-AM_MAINTAINER_MODE
+#AM_MAINTAINER_MODE
 
 dnl SED is needed by some of the tools
 AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
@@ -2038,17 +2038,10 @@
 AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
 
 AC_CONFIG_FILES([Makefile \
-	   docs/Makefile \
-           docs/examples/Makefile \
-           docs/libcurl/Makefile \
 	   include/Makefile \
 	   include/curl/Makefile \
 	   src/Makefile \
            lib/Makefile \
-           tests/Makefile \
-           tests/data/Makefile \
-           tests/server/Makefile \
-           tests/libtest/Makefile \
 	   packages/Makefile \
 	   packages/Win32/Makefile \
 	   packages/Win32/cygwin/Makefile \

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/lib/config.h.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/lib/config.h.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/lib/config.h.in	Fri Apr 13 10:44:28 2007
@@ -621,16 +621,16 @@
 /* Define to the function return type for send. */
 #undef SEND_TYPE_RETV
 
-/* The size of `curl_off_t', as computed by sizeof. */
+/* The size of a `curl_off_t', as computed by sizeof. */
 #undef SIZEOF_CURL_OFF_T
 
-/* The size of `long', as computed by sizeof. */
+/* The size of a `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
-/* The size of `size_t', as computed by sizeof. */
+/* The size of a `size_t', as computed by sizeof. */
 #undef SIZEOF_SIZE_T
 
-/* The size of `time_t', as computed by sizeof. */
+/* The size of a `time_t', as computed by sizeof. */
 #undef SIZEOF_TIME_T
 
 /* Define to 1 if you have the ANSI C header files. */
@@ -685,7 +685,7 @@
 /* type to use in place of in_addr_t if not defined */
 #undef in_addr_t
 
-/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* Define to `unsigned' if <sys/types.h> does not define. */
 #undef size_t
 
 /* type to use in place of socklen_t if not defined */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.am	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.am	Fri Apr 13 10:44:28 2007
@@ -33,50 +33,11 @@
            -I$(top_srcdir)/lib     \
            -I$(top_srcdir)/src
 
-bin_PROGRAMS = curl
-
 include Makefile.inc
 
-curl_LDADD = ../lib/libcurl.la
-curl_DEPENDENCIES = ../lib/libcurl.la
-BUILT_SOURCES = hugehelp.c
-CLEANFILES = hugehelp.c
-NROFF=@NROFF@ @MANOPT@ # figured out by the configure script
-
 EXTRA_DIST = mkhelp.pl makefile.dj Makefile.vc6 Makefile.b32 Makefile.m32 \
 	Makefile.riscos config.h.in macos/curl.mcp.xml.sit.hqx		  \
 	macos/MACINSTALL.TXT macos/src/curl_GUSIConfig.cpp		  \
 	macos/src/macos_main.cpp config-amigaos.h makefile.amiga curl.rc  \
 	Makefile.netware Makefile.inc Makefile.Watcom
 
-MANPAGE=$(top_srcdir)/docs/curl.1
-README=$(top_srcdir)/docs/MANUAL
-MKHELP=$(top_srcdir)/src/mkhelp.pl
-HUGE=hugehelp.c
-
-if USE_MANUAL
-# Here are the stuff to create a built-in manual
-
-if HAVE_LIBZ
-# This generates the hugehelp.c file in both uncompressed and compressed formats
-$(HUGE): $(README) $(MANPAGE)  mkhelp.pl
-	echo '#include "setup.h"' > $(HUGE)
-	echo '#ifndef HAVE_LIBZ' >> $(HUGE)
-	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) $(README) >> $(HUGE)
-	echo '#else' >> $(HUGE)
-	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) -c $(README) >> $(HUGE)
-	echo '#endif /* HAVE_LIBZ */' >> $(HUGE)
-else # HAVE_LIBZ
-# This generates the hugehelp.c file uncompressed only
-$(HUGE): $(README) $(MANPAGE)  mkhelp.pl
-	echo '#include "setup.h"' > $(HUGE)
-	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) $(README) >> $(HUGE)
-endif
-
-else # USE_MANUAL
-# built-in manual has been disabled, make a blank file
-$(HUGE):
-	echo "/* built-in manual is disabled, blank function */" > $(HUGE)
-	echo '#include "hugehelp.h"' >> $(HUGE)
-	echo "void hugehelp(void) {}" >>$(HUGE)
-endif

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.inc
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.inc	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/curl/src/Makefile.inc	Fri Apr 13 10:44:28 2007
@@ -5,13 +5,13 @@
 CURLX_ONES =  $(top_srcdir)/lib/strtoofft.c $(top_srcdir)/lib/timeval.c \
 	$(top_srcdir)/lib/strdup.c 
 
-CURL_SOURCES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
-	getpass.c homedir.c
+#CURL_SOURCES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
+#	getpass.c homedir.c
 
 CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
 	config-riscos.h urlglob.h version.h \
 	writeout.h writeenv.h getpass.h homedir.h
 
-curl_SOURCES = $(CURL_SOURCES) $(CURLX_ONES) $(CURL_HFILES)
+#curl_SOURCES = $(CURL_SOURCES) $(CURLX_ONES) $(CURL_HFILES)
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -46,7 +46,7 @@
 
 include $(topsrcdir)/config/config.mk
 
-DIRS = io linking malloc md memory misc threads
+DIRS = io malloc md memory misc threads
 
 # For VAC++ 4 geticcdata rule in config/OS2.mk
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
@@ -62,7 +62,7 @@
 endif
 
 ifeq ($(USE_CPLUS), 1)
-	DIRS += cplus
+#	DIRS += cplus
 endif
 
 #
@@ -222,50 +222,29 @@
     $(OBJDIR)/prvrsion.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prfdcach.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prmwait.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prmapopt.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/priometh.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX) \
+    io/$(OBJDIR)/prmapopt.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prlayer.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prlog.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prmmap.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prpolevt.$(OBJ_SUFFIX) \
+    io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prprf.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prscanf.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prstdio.$(OBJ_SUFFIX) \
-    threads/$(OBJDIR)/prcmon.$(OBJ_SUFFIX) \
-	threads/$(OBJDIR)/prrwlock.$(OBJ_SUFFIX) \
 	threads/$(OBJDIR)/prtpd.$(OBJ_SUFFIX) \
-    linking/$(OBJDIR)/prlink.$(OBJ_SUFFIX) \
     malloc/$(OBJDIR)/prmem.$(OBJ_SUFFIX) \
     md/$(OBJDIR)/prosdep.$(OBJ_SUFFIX) \
-    memory/$(OBJDIR)/prshm.$(OBJ_SUFFIX) \
-    memory/$(OBJDIR)/prshma.$(OBJ_SUFFIX) \
     memory/$(OBJDIR)/prseg.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/pralarm.$(OBJ_SUFFIX) \
+    misc/$(OBJDIR)/prnetdb.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/pratom.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prcountr.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prdtoa.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prenv.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prerr.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/prerror.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prerrortable.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/prinit.$(OBJ_SUFFIX) \
+   misc/$(OBJDIR)/pripc.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/prinrval.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/pripc.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prlog2.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prlong.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prnetdb.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/prolock.$(OBJ_SUFFIX)	 \
-    misc/$(OBJDIR)/prrng.$(OBJ_SUFFIX)	 \
-    misc/$(OBJDIR)/prsystem.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prthinfo.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prtpool.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/prtrace.$(OBJ_SUFFIX) \
     misc/$(OBJDIR)/prtime.$(OBJ_SUFFIX)
 
 # ilib now rejects empty objects
 ifneq ($(MOZ_OS2_TOOLS),VACPP)
-OBJS += malloc/$(OBJDIR)/prmalloc.$(OBJ_SUFFIX)
+#OBJS += malloc/$(OBJDIR)/prmalloc.$(OBJ_SUFFIX)
 endif
 
 ifdef USE_PTHREADS
@@ -278,16 +257,12 @@
 OBJS += \
     io/$(OBJDIR)/prdir.$(OBJ_SUFFIX) \
     io/$(OBJDIR)/prfile.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prio.$(OBJ_SUFFIX) \
-    io/$(OBJDIR)/prsocket.$(OBJ_SUFFIX) \
-    misc/$(OBJDIR)/pripcsem.$(OBJ_SUFFIX)
+    io/$(OBJDIR)/prio.$(OBJ_SUFFIX) 
+
 
 ifndef USE_BTHREADS
 OBJS += \
 	threads/$(OBJDIR)/prcthr.$(OBJ_SUFFIX) \
-	threads/$(OBJDIR)/prdump.$(OBJ_SUFFIX) \
-	threads/$(OBJDIR)/prmon.$(OBJ_SUFFIX) \
-	threads/$(OBJDIR)/prsem.$(OBJ_SUFFIX) \
 	threads/combined/$(OBJDIR)/prucpu.$(OBJ_SUFFIX) \
 	threads/combined/$(OBJDIR)/prucv.$(OBJ_SUFFIX) \
 	threads/combined/$(OBJDIR)/prulock.$(OBJ_SUFFIX) \

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -58,14 +58,11 @@
     prmwait.c \
     priometh.c \
     pripv6.c \
-	prmapopt.c \
+    prmapopt.c \
     prlayer.c \
     prlog.c \
 	prmmap.c \
-    prpolevt.c \
 	prprf.c \
-	prscanf.c \
-	prstdio.c  \
 	$(NULL)
 
 ifndef USE_PTHREADS
@@ -73,7 +70,6 @@
 	    prdir.c \
 	    prfile.c \
 	    prio.c \
-	    prsocket.c \
 	    $(NULL)
 endif
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prfdcach.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prfdcach.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prfdcach.c	Fri Apr 13 10:44:28 2007
@@ -259,8 +259,8 @@
     ** be overridden at runtime using environment variables
     ** or a super-wiz-bang API.
     */
-    const char *low = PR_GetEnv("NSPR_FD_CACHE_SIZE_LOW");
-    const char *high = PR_GetEnv("NSPR_FD_CACHE_SIZE_HIGH");
+    //const char *low = PR_GetEnv("NSPR_FD_CACHE_SIZE_LOW");
+    //const char *high = PR_GetEnv("NSPR_FD_CACHE_SIZE_HIGH");
 
     /* 
     ** _low is allowed to be zero, _high is not.
@@ -274,8 +274,8 @@
     _pr_fd_cache.limit_high = 0;
 #endif  /* defined(DEBUG) */
 
-    if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
-    if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
+    //if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
+    //if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
 
     if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low)
         _pr_fd_cache.limit_high = _pr_fd_cache.limit_low;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/pripv6.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/pripv6.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/pripv6.c	Fri Apr 13 10:44:28 2007
@@ -279,7 +279,6 @@
 
 #if defined(_PR_INET6_PROBE)
 PRBool _pr_ipv6_is_present;
-extern PRBool _pr_test_ipv6_socket(void);
 
 #if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
 extern PRStatus _pr_find_getipnodebyname(void);
@@ -292,17 +291,7 @@
 static PRBool
 _pr_probe_ipv6_presence(void)
 {
-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
-    if (_pr_find_getipnodebyname() != PR_SUCCESS)
         return PR_FALSE;
-#endif
-
-#if !defined(_PR_INET6) && defined(_PR_HAVE_GETADDRINFO)
-    if (_pr_find_getaddrinfo() != PR_SUCCESS)
-        return PR_FALSE;
-#endif
-
-    return _pr_test_ipv6_socket();
 }
 #endif  /* _PR_INET6_PROBE */
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prlog.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prlog.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/io/prlog.c	Fri Apr 13 10:44:28 2007
@@ -204,11 +204,11 @@
 
 void _PR_InitLog(void)
 {
-    char *ev;
+    char *ev = NULL;
 
     _pr_logLock = PR_NewLock();
 
-    ev = PR_GetEnv("NSPR_LOG_MODULES");
+//    ev = PR_GetEnv("NSPR_LOG_MODULES");
     if (ev && ev[0]) {
         char module[64];  /* Security-Critical: If you change this
                            * size, you must also change the sscanf
@@ -255,7 +255,7 @@
         }
         PR_SetLogBuffering(isSync ? bufSize : 0);
 
-        ev = PR_GetEnv("NSPR_LOG_FILE");
+        //ev = PR_GetEnv("NSPR_LOG_FILE");
         if (ev && ev[0]) {
             if (!PR_SetLogFile(ev)) {
 #ifdef XP_PC
@@ -316,9 +316,9 @@
 
 static void _PR_SetLogModuleLevel( PRLogModuleInfo *lm )
 {
-    char *ev;
+    char *ev = NULL;
 
-    ev = PR_GetEnv("NSPR_LOG_MODULES");
+    //ev = PR_GetEnv("NSPR_LOG_MODULES");
     if (ev && ev[0]) {
         char module[64];  /* Security-Critical: If you change this
                            * size, you must also change the sscanf

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -59,7 +59,7 @@
 
 DEFINES += -D_NSPR_BUILD_
 
-CSRCS = prmalloc.c prmem.c
+CSRCS =  prmem.c
 
 include $(topsrcdir)/config/rules.mk
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/prmem.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/prmem.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/malloc/prmem.c	Fri Apr 13 10:44:28 2007
@@ -210,25 +210,6 @@
     return;
 }
 
-PR_IMPLEMENT(void)
-PR_FPrintZoneStats(PRFileDesc *debug_out)
-{
-    int i, j;
-
-    for (j = 0; j < THREAD_POOLS; j++) {
-        for (i = 0; i < MEM_ZONES; i++) {
-            MemoryZone   *mz   = &zones[i][j];
-            MemoryZone    zone = *mz;
-            if (zone.elements || zone.misses || zone.hits) {
-                PR_fprintf(debug_out,
-"pool: %d, zone: %d, size: %d, free: %d, hit: %d, miss: %d, contend: %d\n",
-                    j, i, zone.blockSize, zone.elements,
-                    zone.hits, zone.misses, zone.contention);
-            }
-	}
-    }
-}
-
 static void *
 pr_ZoneMalloc(PRUint32 size)
 {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -49,8 +49,6 @@
 	unix.c    \
 	unix_errors.c    \
 	uxproces.c \
-	uxrng.c \
-	uxshm.c \
 	uxwrap.c \
 	$(NULL)
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/objs.mk
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/objs.mk	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/md/unix/objs.mk	Fri Apr 13 10:44:28 2007
@@ -42,8 +42,6 @@
 	unix.c    \
 	unix_errors.c \
 	uxproces.c \
-	uxrng.c \
-	uxshm.c \
 	uxwrap.c \
 	$(NULL)
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/memory/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/memory/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/memory/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -46,7 +46,7 @@
 
 include $(topsrcdir)/config/config.mk
 
-CSRCS = prseg.c prshm.c prshma.c
+CSRCS = prseg.c
 
 ifdef GC_LEAK_DETECTOR
 CSRCS += prgcleak.c

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -47,35 +47,16 @@
 include $(topsrcdir)/config/config.mk
 
 CSRCS = \
-	pralarm.c  \
 	pratom.c   \
-	prcountr.c \
-	prdtoa.c   \
-	prenv.c    \
-	prerr.c  \
 	prerror.c  \
-	prerrortable.c  \
+        pripc.c \
 	prinit.c   \
+	prnetdb.c   \
 	prinrval.c \
-	pripc.c \
-	prlog2.c   \
-	prlong.c   \
-	prnetdb.c  \
 	prolock.c  \
-	prrng.c    \
-	prsystem.c \
 	prtime.c   \
-	prthinfo.c \
-	prtpool.c \
-	prtrace.c  \
 	$(NULL)
 
-ifndef USE_PTHREADS
-CSRCS += \
-	pripcsem.c \
-	$(NULL)
-endif
-
 TARGETS	= $(OBJS)
 
 INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/prinit.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/prinit.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/misc/prinit.c	Fri Apr 13 10:44:28 2007
@@ -202,7 +202,7 @@
     _PR_InitSegs();
     _PR_InitStacks();
 	_PR_InitTPD();
-    _PR_InitEnv();
+    //_PR_InitEnv();
     _PR_InitLayerCache();
     _PR_InitClock();
 
@@ -234,20 +234,20 @@
     _PR_InitMem();
 #endif
 
-    _PR_InitCMon();
+    //_PR_InitCMon();
     _PR_InitIO();
-    _PR_InitNet();
+    //_PR_InitNet();
     _PR_InitLog();
-    _PR_InitLinker();
+    //_PR_InitLinker();
     _PR_InitCallOnce();
-    _PR_InitDtoa();
+    //_PR_InitDtoa();
     _PR_InitMW();
-    _PR_InitRWLocks();
+    //_PR_InitRWLocks();
 
-    nspr_InitializePRErrorTable();
+    //nspr_InitializePRErrorTable();
 
 #if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
-	_pr_init_ipv6();
+	//_pr_init_ipv6();
 #endif
 	
     _PR_MD_FINAL_INIT();
@@ -420,9 +420,9 @@
 #endif
 
         _PR_CleanupMW();
-        _PR_CleanupDtoa();
+        //_PR_CleanupDtoa();
         _PR_CleanupCallOnce();
-		_PR_ShutdownLinker();
+		//_PR_ShutdownLinker();
         /* Release the primordial thread's private data, etc. */
         _PR_CleanupThread(me);
 
@@ -452,7 +452,7 @@
          * Ideally, for each _PR_InitXXX(), there should be a corresponding
          * _PR_XXXCleanup() that we can call here.
          */
-        _PR_CleanupNet();
+        //_PR_CleanupNet();
         _PR_CleanupIO();
 #ifdef WINNT
         _PR_CleanupCPUs();
@@ -461,7 +461,7 @@
         PR_DestroyLock(_pr_sleeplock);
         _pr_sleeplock = NULL;
         _PR_CleanupLayerCache();
-        _PR_CleanupEnv();
+        //_PR_CleanupEnv();
         _PR_CleanupStacks();
         _PR_CleanupBeforeExit();
         _pr_initialized = PR_FALSE;
@@ -543,25 +543,6 @@
     }
 }
 
-/*
- * OBSOLETE
- */
-PR_IMPLEMENT(void)
-PR_SetStdioRedirect(
-    PRProcessAttr *attr,
-    PRSpecialFD stdioFd,
-    PRFileDesc *redirectFd)
-{
-#if defined(DEBUG)
-    static PRBool warn = PR_TRUE;
-    if (warn) {
-        warn = _PR_Obsolete("PR_SetStdioRedirect()",
-                "PR_ProcessAttrSetStdioRedirect()");
-    }
-#endif
-    PR_ProcessAttrSetStdioRedirect(attr, stdioFd, redirectFd);
-}
-
 PR_IMPLEMENT(PRStatus)
 PR_ProcessAttrSetCurrentDirectory(
     PRProcessAttr *attr,
@@ -659,75 +640,6 @@
     return PR_SUCCESS;
 }
 
-PR_IMPLEMENT(PRFileDesc *) PR_GetInheritedFD(
-    const char *name)
-{
-    PRFileDesc *fd;
-    const char *envVar;
-    const char *ptr;
-    int len = strlen(name);
-    PROsfd osfd;
-    int nColons;
-    PRIntn fileType;
-
-    envVar = PR_GetEnv("NSPR_INHERIT_FDS");
-    if (NULL == envVar || '\0' == envVar[0]) {
-        PR_SetError(PR_UNKNOWN_ERROR, 0);
-        return NULL;
-    }
-
-    ptr = envVar;
-    while (1) {
-        if ((ptr[len] == ':') && (strncmp(ptr, name, len) == 0)) {
-            ptr += len + 1;
-            PR_sscanf(ptr, "%d:0x%" PR_SCNxOSFD, &fileType, &osfd);
-            switch ((PRDescType)fileType) {
-                case PR_DESC_FILE:
-                    fd = PR_ImportFile(osfd);
-                    break;
-                case PR_DESC_PIPE:
-                    fd = PR_ImportPipe(osfd);
-                    break;
-                case PR_DESC_SOCKET_TCP:
-                    fd = PR_ImportTCPSocket(osfd);
-                    break;
-                case PR_DESC_SOCKET_UDP:
-                    fd = PR_ImportUDPSocket(osfd);
-                    break;
-                default:
-                    PR_ASSERT(0);
-                    PR_SetError(PR_UNKNOWN_ERROR, 0);
-                    fd = NULL;
-                    break;
-            }
-            if (fd) {
-                /*
-                 * An inherited FD is inheritable by default.
-                 * The child process needs to call PR_SetFDInheritable
-                 * to make it non-inheritable if so desired.
-                 */
-                fd->secret->inheritable = _PR_TRI_TRUE;
-            }
-            return fd;
-        }
-        /* Skip three colons */
-        nColons = 0;
-        while (*ptr) {
-            if (*ptr == ':') {
-                if (++nColons == 3) {
-                    break;
-                }
-            }
-            ptr++;
-        }
-        if (*ptr == '\0') {
-            PR_SetError(PR_UNKNOWN_ERROR, 0);
-            return NULL;
-        }
-        ptr++;
-    }
-}
-
 PR_IMPLEMENT(PRProcess*) PR_CreateProcess(
     const char *path,
     char *const *argv,
@@ -850,19 +762,9 @@
     }
     return once->status;
 }
-
 PRBool _PR_Obsolete(const char *obsolete, const char *preferred)
 {
-#if defined(DEBUG)
-#ifndef XP_MAC
-    PR_fprintf(
-        PR_STDERR, "'%s' is obsolete. Use '%s' instead.\n",
-        obsolete, (NULL == preferred) ? "something else" : preferred);
-#else
-#pragma unused (obsolete, preferred)
-#endif
-#endif
-    return PR_FALSE;
+  return PR_FALSE;
 }  /* _PR_Obsolete */
 
 /* prinit.c */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -55,8 +55,8 @@
 endif
 
 CSRCS = \
+        ptsynch.c \
 	ptio.c \
-	ptsynch.c \
 	ptthread.c \
 	ptmisc.c \
 	$(NULL)

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptio.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptio.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptio.c	Fri Apr 13 10:44:28 2007
@@ -374,46 +374,13 @@
 
 PTDebug pt_debug;  /* this is shared between several modules */
 
-PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg)
-{
-    PTDebug stats;
-    char buffer[100];
-    PRExplodedTime tod;
-    PRInt64 elapsed, aMil;
-    stats = pt_debug;  /* a copy */
-    PR_ExplodeTime(stats.timeStarted, PR_LocalTimeParameters, &tod);
-    (void)PR_FormatTime(buffer, sizeof(buffer), "%T", &tod);
-
-    LL_SUB(elapsed, PR_Now(), stats.timeStarted);
-    LL_I2L(aMil, 1000000);
-    LL_DIV(elapsed, elapsed, aMil);
-    
-    if (NULL != msg) PR_fprintf(debug_out, "%s", msg);
-    PR_fprintf(
-        debug_out, "\tstarted: %s[%lld]\n", buffer, elapsed);
-    PR_fprintf(
-        debug_out, "\tlocks [created: %u, destroyed: %u]\n",
-        stats.locks_created, stats.locks_destroyed);
-    PR_fprintf(
-        debug_out, "\tlocks [acquired: %u, released: %u]\n",
-        stats.locks_acquired, stats.locks_released);
-    PR_fprintf(
-        debug_out, "\tcvars [created: %u, destroyed: %u]\n",
-        stats.cvars_created, stats.cvars_destroyed);
-    PR_fprintf(
-        debug_out, "\tcvars [notified: %u, delayed_delete: %u]\n",
-        stats.cvars_notified, stats.delayed_cv_deletes);
-}  /* PT_FPrintStats */
-
-#else
+#endif  /* DEBUG */
 
 PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg)
 {
     /* do nothing */
 }  /* PT_FPrintStats */
 
-#endif  /* DEBUG */
-
 #if defined(_PR_POLL_WITH_SELECT)
 /*
  * OSF1 and HPUX report the POLLHUP event for a socket when the
@@ -3374,6 +3341,8 @@
     return fd;
 }  /* PR_AllocFileDesc */
 
+#if 0
+
 #if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
 PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
 #if defined(_PR_INET6_PROBE)
@@ -3484,7 +3453,7 @@
 #endif
     return fd;
 }  /* PR_Socket */
-
+#endif
 /*****************************************************************************/
 /****************************** I/O public methods ***************************/
 /*****************************************************************************/
@@ -4312,6 +4281,7 @@
     return &dir->d;
 }  /* PR_ReadDir */
 
+#if 0
 PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket(void)
 {
     PRIntn domain = PF_INET;
@@ -4336,6 +4306,8 @@
     return PR_Socket(af, SOCK_STREAM, 0);
 }  /* PR_NewTCPSocket */
 
+#endif
+
 PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *fds[2])
 {
     PRInt32 osfd[2];

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptthread.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptthread.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/pthreads/ptthread.c	Fri Apr 13 10:44:28 2007
@@ -938,9 +938,9 @@
         PR_Unlock(pt_book.ml);
 
         _PR_CleanupMW();
-        _PR_CleanupDtoa();
+        //_PR_CleanupDtoa();
         _PR_CleanupCallOnce();
-        _PR_ShutdownLinker();
+        //_PR_ShutdownLinker();
         _PR_LogCleanup();
         _PR_CleanupNet();
         /* Close all the fd's before calling _PR_CleanupIO */
@@ -963,7 +963,7 @@
         PR_DestroyLock(_pr_sleeplock);
         _pr_sleeplock = NULL;
         _PR_CleanupLayerCache();
-        _PR_CleanupEnv();
+        //_PR_CleanupEnv();
 #ifdef _PR_ZONE_ALLOCATOR
         _PR_DestroyZones();
 #endif

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/Makefile.in	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/Makefile.in	Fri Apr 13 10:44:28 2007
@@ -58,24 +58,15 @@
 
 ifdef USE_PTHREADS
 CSRCS = \
-	prcmon.c \
-	prrwlock.c   \
 	prtpd.c \
 	$(NULL)
 else
 ifdef USE_BTHREADS
 CSRCS = \
-	prcmon.c \
-	prrwlock.c   \
 	prtpd.c \
 	$(NULL)
 else
 CSRCS =	\
-	prcmon.c  \
-	prdump.c  \
-	prmon.c   \
-	prsem.c   \
-	prrwlock.c   \
 	prcthr.c \
 	prtpd.c \
 	$(NULL)

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/prcthr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/prcthr.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/js/nsprpub/pr/src/threads/prcthr.c	Fri Apr 13 10:44:28 2007
@@ -73,14 +73,6 @@
     thread->environment = NULL;
 }
 
-PR_IMPLEMENT(PRStatus) PR_Yield()
-{
-    static PRBool warning = PR_TRUE;
-    if (warning) warning = _PR_Obsolete(
-        "PR_Yield()", "PR_Sleep(PR_INTERVAL_NO_WAIT)");
-    return (PR_Sleep(PR_INTERVAL_NO_WAIT));
-}
-
 /*
 ** Make the current thread sleep until "timeout" ticks amount of time
 ** has expired. If "timeout" is PR_INTERVAL_NO_WAIT then the call is

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/udns/udns_resolver.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/udns/udns_resolver.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/udns/udns_resolver.c	Fri Apr 13 10:44:28 2007
@@ -46,9 +46,6 @@
 # include <unistd.h>
 # include <fcntl.h>
 # include <sys/time.h>
-# ifdef HAVE_CONFIG_H
-#  include <config.h>
-# endif
 # ifdef HAVE_POLL
 #  include <sys/poll.h>
 # endif
@@ -77,7 +74,7 @@
 # define EAFNOSUPPORT EINVAL
 #endif
 
-union sockaddr_ns {
+union usockaddr_ns {
   struct sockaddr sa;
   struct sockaddr_in sin;
 #if HAVE_INET6
@@ -184,7 +181,7 @@
   unsigned dnsc_port;			/* default port (DNS_PORT) */
   unsigned dnsc_udpbuf;			/* size of UDP buffer */
   /* array of nameserver addresses */
-  union sockaddr_ns dnsc_serv[DNS_MAXSERV];
+  union usockaddr_ns dnsc_serv[DNS_MAXSERV];
   unsigned dnsc_nserv;			/* number of nameservers */
   unsigned dnsc_salen;			/* length of socket addresses */
   /* search list for unqualified names */
@@ -272,7 +269,7 @@
 };
 
 static int dns_add_serv_internal(struct dns_ctx *ctx, const char *serv) {
-  union sockaddr_ns *sns;
+  union usockaddr_ns *sns;
   if (!serv)
     return (ctx->dnsc_nserv = 0);
   if (ctx->dnsc_nserv >= DNS_MAXSERV)
@@ -688,7 +685,7 @@
   dns_socket sock;
   unsigned i;
   int port;
-  union sockaddr_ns *sns;
+  union usockaddr_ns *sns;
 #if HAVE_INET6
   unsigned have_inet6 = 0;
 #endif
@@ -922,7 +919,7 @@
     return;
   }
   DNS_DBGQ(ctx, q, 1,
-           &ctx->dnsc_serv[q->dnsq_servi].sa, sizeof(union sockaddr_ns),
+           &ctx->dnsc_serv[q->dnsq_servi].sa, sizeof(union usockaddr_ns),
            q->dnsq_buf, q->dnsq_len);
   q->dnsq_servwait |= 1 << q->dnsq_servi;	/* expect reply from this ns */
 
@@ -1045,7 +1042,7 @@
   dnsc_t *pbuf;
   dnscc_t *pend, *pcur;
   void *result;
-  union sockaddr_ns sns;
+  union usockaddr_ns sns;
   socklen_t slen;
 
   SETCTX(ctx);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/js/js.vcproj
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/js/js.vcproj	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/js/js.vcproj	Fri Apr 13 10:44:28 2007
@@ -693,84 +693,107 @@
 			Name="NSPR Source"
 			>
 			<File
-				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntgc.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntinrval.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntio.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntmisc.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntsec.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntsem.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\ntthread.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\pralarm.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\pratom.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\threads\prcmon.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prcountr.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\prcthr.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prdir.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prdtoa.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\threads\prdump.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prenv.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prerr.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\prerror.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prerrortable.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prfdcach.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prfile.c"
@@ -779,78 +802,101 @@
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\prinit.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\prinrval.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prio.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\priometh.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\pripc.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\pripcsem.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\pripv6.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prlayer.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\linking\prlink.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prlog.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prlog2.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prlong.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\malloc\prmalloc.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\prmapopt.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\malloc\prmem.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prmmap.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\threads\prmon.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prmwait.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prnetdb.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\prolock.c"
@@ -859,82 +905,79 @@
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\prosdep.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\prpolevt.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\io\prprf.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prrng.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\threads\prrwlock.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\prscanf.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\memory\prseg.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\threads\prsem.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\memory\prshm.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\memory\prshma.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\prsocket.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\io\prstdio.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prsystem.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prthinfo.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\misc\prtime.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\prtpd.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prtpool.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\misc\prtrace.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\combined\prucpu.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\combined\prucv.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\combined\prulock.c"
@@ -943,26 +986,35 @@
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\combined\prustack.c"
 				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\threads\combined\pruthr.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\md\windows\w32ipcsem.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\w32poll.c"
 				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\md\windows\w32rng.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\js\nsprpub\pr\src\md\windows\w32shm.c"
-				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\js\nsprpub\pr\src\md\windows\win32_errors.c"

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/src/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/src/Makefile	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/src/Makefile	Fri Apr 13 10:44:28 2007
@@ -10,9 +10,11 @@
 default: all
 
 SUBDIRS =
+CPPCLEAN = 
 
 ifeq ($(ENABLE_CPLUSPLUS),yes)
   SUBDIRS += cpp
+  CPPCLEAN += cpp/clean
 endif
 
 WININET_TRANSPORT_DIR = $(SRCDIR)/lib/wininet_transport
@@ -131,7 +133,7 @@
 
 .PHONY: clean clean-local distclean
 clean: clean-common clean-local
-clean-local: cpp/clean
+clean-local: $(CPPCLEAN)
 
 distclean: clean distclean-common
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/FreeSWITCH/Client.pm
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/FreeSWITCH/Client.pm	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/scripts/socket/FreeSWITCH/Client.pm	Fri Apr 13 10:44:28 2007
@@ -208,6 +208,22 @@
   return $self->sendmsg($hash);
 }
 
+sub unicast($$$$$$) {
+  my $self = shift;
+
+  my $hash = {
+	      'command' => "sendmsg",
+	      'call-command' => "unicast",
+	      'local_ip' => $_[0],
+	      'local_port' => $_[1],
+	      'remote_ip' => $_[2],
+	      'remote_port' => $_[3],
+	      'transport' => $_[4]
+	     };
+
+  return $self->sendmsg($hash);
+}
+
 sub call_data($) {
   my $self = shift;
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core_db.h	Fri Apr 13 10:44:28 2007
@@ -457,6 +457,11 @@
  */
 SWITCH_DECLARE(void) switch_core_db_free(char *z);
 
+/**
+ * Call this routine to find the number of rows changed by the last statement.
+ */
+SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db);
+
 /** Return values for switch_core_db_exec() and switch_core_db_step()*/
 #define SWITCH_CORE_DB_OK           0	/* Successful result */
 /* beginning-of-error-codes */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h	Fri Apr 13 10:44:28 2007
@@ -42,6 +42,28 @@
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
+
+struct switch_unicast_conninfo {
+	switch_core_session_t *session;
+	switch_codec_t read_codec;
+	switch_frame_t write_frame;
+	switch_byte_t write_frame_data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+	switch_socket_t *socket;
+	char *local_ip;
+	switch_port_t local_port;
+	char *remote_ip;
+	switch_port_t remote_port;
+	switch_sockaddr_t *local_addr;
+	switch_sockaddr_t *remote_addr;
+	switch_mutex_t *flag_mutex;
+	int32_t flags;
+	int type;
+	int transport;
+	int stream_id;
+};
+typedef struct switch_unicast_conninfo switch_unicast_conninfo_t;
+
+
 /**
  * @defgroup switch_ivr IVR Library
  * @ingroup core1
@@ -49,6 +71,15 @@
  *	building blocks for a higher level IVR interface.
  * @{
  */
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session, 
+															char *local_ip,
+															switch_port_t local_port,
+															char *remote_ip,
+															switch_port_t remote_port,
+															char *transport);
+
 /*!
   \brief Generate an XML CDR report.
   \param session the session to get the data from.
@@ -79,9 +110,7 @@
 /*!
   \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
-  \param buf an object to maintain across calls
-  \param buflen the size of buf
+  \param args arguements to pass for callbacks etc
   \param timeout a timeout in milliseconds
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
@@ -179,11 +208,8 @@
   \param session the session to play the file too
   \param fh file handle to use (NULL for builtin one)
   \param file the path to the file
-  \param dtmf_callback code to execute if any dtmf is dialed during the playback
-  \param buf an object to maintain across calls
-  \param buflen the size of buf
+  \param args arguements to pass for callbacks etc
   \return SWITCH_STATUS_SUCCESS if all is well
-  \note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop playback.
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, char *file, switch_input_args_t *args);
 
@@ -193,12 +219,9 @@
   \param session the session to record from
   \param fh file handle to use
   \param file the path to the file
-  \param dtmf_callback code to execute if any dtmf is dialed during the recording
-  \param buf an object to maintain across calls
-  \param buflen the size of buf
+  \param args arguements to pass for callbacks etc
   \param limit max limit to record for (0 for infinite)
   \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_t) switch_ivr_record_file(switch_core_session_t *session,
 													   switch_file_handle_t *fh, char *file, switch_input_args_t *args, uint32_t limit);
@@ -240,10 +263,8 @@
   \param tts_name the desired tts module
   \param voice_name the desired voice
   \param rate the sample rate
-  \param dtmf_callback code to execute if any dtmf is dialed during the audio
   \param text the text to speak
-  \param buf an option data pointer to pass to the callback or a string to put encountered digits in
-  \param buflen the len of buf
+  \param args arguements to pass for callbacks etc
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
@@ -274,7 +295,7 @@
   \brief Bridge Audio from one session to another
   \param session one session
   \param peer_session the other session
-  \param dtmf_callback code to execute if any dtmf is dialed during the bridge
+  \param dtmf_callback a callback for messages and dtmf
   \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
@@ -460,6 +481,7 @@
 /*!
   \brief Feed digits collected into the stream for event match testing
   \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
+  \param stream a stream to write data to
   \param digit a digit to collect and test against the map of digit strings
   \return NULL if no match found or consumer data that was associated with a given digit string when matched
 */
@@ -525,14 +547,15 @@
  *\param name A pointer to the name of this menu.
  *\param greeting_sound Optional pointer to a main sound (press 1 for this 2 for that).
  *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops.
- *\param exit_sound Optional pointer to a sound to play upon exiting the menu
+ *\param exit_sound Optional pointer to a sound to play upon exiting the menu.
  *\param invalid_sound Optional pointer to a sound to play after invalid input.
- *\param tts_engine Text To Speech engine name
- *\param tts_voice Text To Speech engine voice name
+ *\param tts_engine Text To Speech engine name.
+ *\param tts_voice Text To Speech engine voice name.
+ *\param phrase_lang the language to use for the phrase macros.
  *\param timeout A number of milliseconds to pause before looping.
  *\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
- *\param pool memory pool (NULL to create one)
- *\return SWITCH_STATUS_SUCCESS if the menu was created
+ *\param pool memory pool (NULL to create one).
+ *\return SWITCH_STATUS_SUCCESS if the menu was created.
  */
 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu,
 													 switch_ivr_menu_t * main,

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h	Fri Apr 13 10:44:28 2007
@@ -117,6 +117,13 @@
 #define SWITCH_BITS_PER_BYTE 8
 	typedef uint8_t switch_byte_t;
 
+
+typedef enum {
+	SUF_NONE = 0,
+	SUF_THREAD_RUNNING = (1 << 0),
+	SUF_READY = (1 << 1)
+} switch_unicast_flag_t;
+
 typedef enum {
 	SWITCH_FALSE = 0,
 	SWITCH_TRUE = 1
@@ -531,6 +538,7 @@
 CF_RING_READY   = (1 << 18) - Channel is ready to send ringback
 CF_BREAK        = (1 << 19) - Channel should stop what it's doing
 CF_BROADCAST    = (1 << 20) - Channel is broadcasting
+CF_UNICAST      = (1 << 21) - Channel has a unicast connection
 </pre>
  */
 
@@ -555,7 +563,8 @@
 	CF_GEN_RINGBACK = (1 << 17),
 	CF_RING_READY = (1 << 18),
 	CF_BREAK = (1 << 19),
-	CF_BROADCAST = (1 << 20)
+	CF_BROADCAST = (1 << 20),
+	CF_UNICAST = (1 << 21)
 } switch_channel_flag_t;
 
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_utils.h	Fri Apr 13 10:44:28 2007
@@ -90,7 +90,7 @@
   \brief find the char representation of an ip adress
   \param buf the buffer to write the ip adress found into
   \param len the length of the buf
-  \param the struct in_addr * to get the adress from
+  \param in the struct in_addr * to get the adress from
   \return the ip adress string
 */
 SWITCH_DECLARE(char *) get_addr(char *buf, switch_size_t len, struct in_addr *in);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am	Fri Apr 13 10:44:28 2007
@@ -7,7 +7,7 @@
 	@set fnord $$MAKEFLAGS; amf=$$2; \
 	target=`echo $@ | sed -e 's|^.*-||'`; \
 	modname=`echo $@ | sed -e 's|-.*||'`; \
-	confmoddir=`cat $(switch_builddir)/modules.conf | grep $$modname | sed -e 's|#||' `; \
+	confmoddir=`cat $(switch_builddir)/modules.conf | grep $$modname$$ | sed -e 's|#||' `; \
 	if test -z "$$confmoddir" ; then moddir=$@ ; else  \
 		if test -d  "$(switch_srcdir)/src/mod/$$confmoddir" ; then \
 			moddir="$(switch_srcdir)/src/mod/$$confmoddir" ; else \

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/Makefile	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_enum/Makefile	Fri Apr 13 10:44:28 2007
@@ -1,11 +1,10 @@
 BASE=../../../..
 UDNS_DIR=$(BASE)/libs/udns
-UDNSA=$(UDNS_DIR)/libudns.a
-LOCAL_CFLAGS=-I$(UDNS_DIR)
-LOCAL_LIBADD=$(UDNSA)
-include $(BASE)/build/modmake.rules
+LOCAL_CFLAGS=-I$(UDNS_DIR) -DHAVE_POLL
+LOCAL_OBJS=$(UDNS_DIR)/udns_dn.o $(UDNS_DIR)/udns_dntosp.o $(UDNS_DIR)/udns_parse.o $(UDNS_DIR)/udns_misc.o \
+$(UDNS_DIR)/udns_rr_a.o $(UDNS_DIR)/udns_rr_ptr.o $(UDNS_DIR)/udns_rr_mx.o $(UDNS_DIR)/udns_rr_txt.o $(UDNS_DIR)/udns_bl.o \
+$(UDNS_DIR)/udns_rr_srv.o $(UDNS_DIR)/udns_rr_naptr.o $(UDNS_DIR)/udns_codes.o $(UDNS_DIR)/udns_resolver.o
+
 
-$(UDNSA): $(UDNS_DIR) $(UDNS_DIR)/.update
-	cd $(UDNS_DIR) && $(MAKE) staticlib
-	$(TOUCH_TARGET)
+include $(BASE)/build/modmake.rules
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Apr 13 10:44:28 2007
@@ -882,7 +882,7 @@
 		}
 
 		profile = gateway_ptr->profile;
-		tech_pvt->from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from);
+		tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from);
 		if (!strchr(dest, '@')) {
 			tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s@%s", dest, gateway_ptr->register_proxy + 4);
 		} else {

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h	Fri Apr 13 10:44:28 2007
@@ -278,6 +278,7 @@
 	char *far_end_contact;
 	char *contact_url;
 	char *from_str;
+	char *gateway_from_str;
 	char *rm_encoding;
 	char *rm_fmtp;
 	char *fmtp_out;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c	Fri Apr 13 10:44:28 2007
@@ -417,7 +417,8 @@
 		tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
 								  NUTAG_URL(url),
 								  SIPTAG_TO_STR(tech_pvt->dest_to),
-								  SIPTAG_FROM_STR(tech_pvt->from_str),
+								  TAG_IF(tech_pvt->gateway_from_str, SIPTAG_FROM_STR(tech_pvt->gateway_from_str)),
+								  TAG_IF(!tech_pvt->gateway_from_str, SIPTAG_FROM_STR(tech_pvt->from_str)),
 								  TAG_IF(tech_pvt->invite_contact, SIPTAG_CONTACT_STR(tech_pvt->invite_contact)),
 								  TAG_IF(!tech_pvt->invite_contact, SIPTAG_CONTACT_STR(tech_pvt->profile->url)),
 								  TAG_END());

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile	Fri Apr 13 10:44:28 2007
@@ -3,20 +3,23 @@
 LIBPRI=libpri-1.2.4
 LIBPRI_FILE=$(LIBPRI).tar.gz
 LIBPRI_DIR=$(BASE)/libs/$(LIBPRI)
-WANPIPE=wanpipe-3.1.0.p13
+WANPIPE=wanpipe-3.1.0.p15
 WANPIPE_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
 WANPIPE_FILE=$(WANPIPE).tgz
 WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
 WANPIPE_INCLUDE=$(WANPIPE_DIR)/patches/kdrivers/include
 WANPIPE_KO=$(WANPIPE_DIR)/patches/kdrivers/src/net/wanpipe.ko
 WANPIPE_INSTALLED_KO=$(shell echo "/lib/modules/`uname -r`/kernel/drivers/net/wan/wanpipe.ko")
-LIBSANGOMA_DIR=$(WANPIPE_DIR)/api/libsangoma
+LIBSANGOMA_DIR=./libsangoma
 LOCAL_CFLAGS  =-w -I$(WANPIPE_INCLUDE) -I$(LIBSANGOMA_DIR) -I/usr/local/include -I$(LIBPRI_DIR) -I/usr/src/linux/include -I. -I/usr/include 
 LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API
 LOCAL_OBJS = ss7boost_client.o $(LIBPRI_DIR)/copy_string.o $(LIBPRI_DIR)/pri.o $(LIBPRI_DIR)/q921.o $(LIBPRI_DIR)/prisched.o $(LIBPRI_DIR)/q931.o $(LIBPRI_DIR)/pri_facility.o $(LIBSANGOMA_DIR)/libsangoma.o $(LIBSANGOMA_DIR)/sangoma_pri.o 
 
 include $(BASE)/build/modmake.rules 
 
+testapp: testapp.c $(LIBSANGOMA_DIR)/libsangoma.o
+	$(CC) -I$(WANPIPE_DIR)/api/lib $(CFLAGS) $(LOCAL_CFLAGS) lib_api.c testapp.c $(LIBSANGOMA_DIR)/libsangoma.o -o testapp
+
 $(LIBPRI_DIR):
 	$(GETLIB) $(LIBPRI_HOST) $(LIBPRI_FILE)
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c	Fri Apr 13 10:44:28 2007
@@ -23,96 +23,99 @@
 #define DFT_CARD "wanpipe1"
 
 #if defined(WIN32)
-//extern int    verbose;
+//extern int	verbose;
 
 #define DEV_NAME_LEN	100
 char device_name[DEV_NAME_LEN];
 
 /* IOCTL management structures and variables*/
-wan_udp_hdr_t wan_udp;
+wan_udp_hdr_t	wan_udp;
 
 #include "win_api_common.h"
 
 static wan_cmd_api_t api_cmd;
-static api_tx_hdr_t *tx_hdr = (api_tx_hdr_t *) api_cmd.data;
+static api_tx_hdr_t *tx_hdr = (api_tx_hdr_t *)api_cmd.data;
 
 /* keeps the LAST (and single) event received */
 static wp_tdm_api_rx_hdr_t last_tdm_api_event_buffer;
 
-#endif /* WIN32 */
+#endif	/* WIN32 */
 
-void sangoma_socket_close(sng_fd_t * sp)
+void sangoma_socket_close(sng_fd_t *sp) 
 {
 #if defined(WIN32)
-	if (*sp != INVALID_HANDLE_VALUE) {
+	if(	*sp != INVALID_HANDLE_VALUE){
 		CloseHandle(*sp);
 		*sp = INVALID_HANDLE_VALUE;
 	}
 #else
-	if (*sp > -1) {
-		close(*sp);
-		*sp = -1;
-	}
+    if (*sp > -1) {
+	close(*sp);
+	*sp = -1;
+    }
 #endif
 }
 
 int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags)
 {
 #if defined(WIN32)
-	API_POLL_STRUCT api_poll;
+	API_POLL_STRUCT	api_poll;
 
 	memset(&api_poll, 0x00, sizeof(API_POLL_STRUCT));
-
+	
 	api_poll.user_flags_bitmap = flags;
 
-	if (DoApiPollCommand(fd, &api_poll)) {
+	if(DoApiPollCommand(fd, &api_poll)){
 		//failed
 		return 0;
 	}
 
-	switch (api_poll.operation_status) {
-	case SANG_STATUS_RX_DATA_AVAILABLE:
-		break;
-
-	default:
-		prn(1, "Error: sangoma_socket_waitfor(): Unknown Operation Status: %d\n", api_poll.operation_status);
-		return 0;
-	}							//switch()
+	switch(api_poll.operation_status)
+	{
+		case SANG_STATUS_RX_DATA_AVAILABLE:
+			break;
 
-	if (api_poll.poll_events_bitmap == 0) {
-		prn(1, "Error: invalid Poll Events bitmap: 0x%X\n", api_poll.poll_events_bitmap);
+		default:
+			prn(1, "Error: sangoma_socket_waitfor(): Unknown Operation Status: %d\n", 
+				api_poll.operation_status);
+			return 0;
+	}//switch()
+
+	if(api_poll.poll_events_bitmap == 0){
+		prn(1, "Error: invalid Poll Events bitmap: 0x%X\n",
+			api_poll.poll_events_bitmap);
 	}
 	return api_poll.poll_events_bitmap;
 #else
-	struct pollfd pfds[1];
-	int res;
+    struct pollfd pfds[1];
+    int res;
 
-	memset(&pfds[0], 0, sizeof(pfds[0]));
-	pfds[0].fd = fd;
-	pfds[0].events = flags;
-	res = poll(pfds, 1, timeout);
-	if (res > 0) {
-		if ((pfds[0].revents & POLLERR)) {
-			res = -1;
-		} else if ((pfds[0].revents)) {
-			res = 1;
-		}
+    memset(&pfds[0], 0, sizeof(pfds[0]));
+    pfds[0].fd = fd;
+    pfds[0].events = flags;
+    res = poll(pfds, 1, timeout);
+    if (res > 0) {
+	if ((pfds[0].revents & POLLERR)) {
+		res = -1;
+	} else if((pfds[0].revents)) {
+		res = 1;
 	}
+    }
 
-	return res;
+    return res;
 #endif
 }
 
 
 int sangoma_span_chan_toif(int span, int chan, char *interface_name)
 {
-	sprintf(interface_name, "s%ic%i", span, chan);
+ 	sprintf(interface_name,"s%ic%i",span,chan);
 	return 0;
 }
 
 int sangoma_interface_toi(char *interface_name, int *span, int *chan)
 {
-	char *p = NULL, *sp = NULL, *ch = NULL;
+	char *p=NULL, *sp = NULL, *ch = NULL;
 	int ret = 0;
 	char data[FNAME_LEN];
 
@@ -128,7 +131,7 @@
 			}
 		}
 
-		if (ch && sp) {
+		if(ch && sp) {
 			*span = atoi(sp);
 			*chan = atoi(ch);
 			ret = 1;
@@ -159,7 +162,7 @@
 			}
 		}
 
-		if (ch && sp) {
+		if(ch && sp) {
 			*span = atoi(sp);
 			*chan = atoi(ch);
 			ret = 1;
@@ -172,123 +175,132 @@
 	return ret;
 }
 
-sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan)
+sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan) 
 {
-	char fname[FNAME_LEN];
+   	char fname[FNAME_LEN];
 #if defined(WIN32)
 
 	//NOTE: under Windows Interfaces are zero based but 'chan' is 1 based.
-	//      Subtract 1 from 'chan'.
-	_snprintf(fname, FNAME_LEN, "\\\\.\\WANPIPE%d_IF%d", span, chan - 1);
+	//		Subtract 1 from 'chan'.
+	_snprintf(fname , FNAME_LEN, "\\\\.\\WANPIPE%d_IF%d", span, chan - 1);
 
 	//prn(verbose, "Opening device: %s...\n", fname);
 
-	return CreateFile(fname,
-					  GENERIC_READ | GENERIC_WRITE,
-					  FILE_SHARE_READ | FILE_SHARE_WRITE,
-					  (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, (HANDLE) NULL);
+	return CreateFile(	fname, 
+						GENERIC_READ | GENERIC_WRITE, 
+						FILE_SHARE_READ | FILE_SHARE_WRITE,
+						(LPSECURITY_ATTRIBUTES)NULL, 
+						OPEN_EXISTING,
+						FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
+						(HANDLE)NULL
+						);
 #else
-	int fd = -1;
+  	int fd=-1;
 
-	sprintf(fname, "/dev/wptdm_s%dc%d", span, chan);
+	sprintf(fname,"/dev/wptdm_s%dc%d",span,chan);
 
 	fd = open(fname, O_RDWR);
 
-	return fd;
+	return fd;  
 #endif
-}
+}            
 
-sng_fd_t sangoma_create_socket_by_name(char *device, char *card)
+sng_fd_t sangoma_create_socket_by_name(char *device, char *card) 
 {
-	int span, chan;
-	sangoma_interface_toi(device, &span, &chan);
-
-	return sangoma_open_tdmapi_span_chan(span, chan);
+	int span,chan;
+	sangoma_interface_toi(device,&span,&chan);
+	
+	return sangoma_open_tdmapi_span_chan(span,chan);
 }
 
-
-sng_fd_t sangoma_open_tdmapi_span(int span)
+          
+sng_fd_t sangoma_open_tdmapi_span(int span) 
 {
-	int i = 0;
+    int i=0;
 #if defined(WIN32)
 	sng_fd_t fd = INVALID_HANDLE_VALUE;
 
-	for (i = 1; i < 32; i++) {
-		if ((fd = sangoma_open_tdmapi_span_chan(span, i)) == INVALID_HANDLE_VALUE) {
+	for(i = 1; i < 32; i++){
+		if((fd = sangoma_open_tdmapi_span_chan(span, i)) == INVALID_HANDLE_VALUE){
 			//prn(verbose, "Span: %d, chan: %d: is not running, consider 'busy'\n",
-			//  span, i);
+			//	span, i);
 			continue;
 		}
+
 		//get the open handle counter
-		wan_udp.wan_udphdr_command = GET_OPEN_HANDLES_COUNTER;
+		wan_udp.wan_udphdr_command = GET_OPEN_HANDLES_COUNTER; 
 		wan_udp.wan_udphdr_data_len = 0;
 
 		DoManagementCommand(fd, &wan_udp);
-		if (wan_udp.wan_udphdr_return_code) {
-			prn(1, "Error: command GET_OPEN_HANDLES_COUNTER failed! Span: %d, chan: %d\n", span, i);
+		if(wan_udp.wan_udphdr_return_code){
+			prn(1, "Error: command GET_OPEN_HANDLES_COUNTER failed! Span: %d, chan: %d\n",
+				span, i);
 			//don't forget to close!! otherwize counter will stay incremented.
 			sangoma_socket_close(&fd);
 			continue;
 		}
+
 		//prn(verbose, "open handles counter: %d\n", *(int*)&wan_udp.wan_udphdr_data[0]);
-		if (*(int *) &wan_udp.wan_udphdr_data[0] == 1) {
+		if(*(int*)&wan_udp.wan_udphdr_data[0] == 1){
 			//this is the only process using this chan/span, so it is 'free'
 			//prn(verbose, "Found 'free' Span: %d, chan: %d\n",span, i);
 			break;
 		}
 		//don't forget to close!! otherwize counter will stay incremented.
 		sangoma_socket_close(&fd);
-	}							//for()
+	}//for()
 
 #else
-	unsigned char fname[FNAME_LEN];
-	int fd = 0;
-	for (i = 1; i < 32; i++) {
-		sprintf(fname, "/dev/wptdm_s%dc%d", span, i);
+    unsigned char fname[FNAME_LEN];
+	int fd=0;
+	for (i=1;i<32;i++){
+		sprintf(fname,"/dev/wptdm_s%dc%d",span,i);
 		fd = open(fname, O_RDWR);
-		if (fd < 0) {
-			continue;
+		if (fd < 0){
+         	continue;
 		}
 		break;
 	}
-#endif
-	return fd;
-}
+#endif	
+    return fd;  
+}      
 
 int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
 {
-	int rx_len = 0;
+	int rx_len=0;
 
 #if defined(WIN32)
-	static RX_DATA_STRUCT rx_data;
-	api_header_t *pri;
-	wp_tdm_api_rx_hdr_t *tdm_api_rx_hdr;
-	wp_tdm_api_rx_hdr_t *user_buf = (wp_tdm_api_rx_hdr_t *) hdrbuf;
+	static RX_DATA_STRUCT	rx_data;
+	api_header_t			*pri;
+	wp_tdm_api_rx_hdr_t		*tdm_api_rx_hdr;
+	wp_tdm_api_rx_hdr_t		*user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf;
 
-	if (hdrlen != sizeof(wp_tdm_api_rx_hdr_t)) {
+	if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){
 		//error
 		prn(1, "Error: sangoma_readmsg_tdm(): invalid size of user's 'header buffer'.\
 Should be 'sizeof(wp_tdm_api_rx_hdr_t)'.\n");
 		return -1;
 	}
 
-	if (DoReadCommand(fd, &rx_data)) {
+	if(DoReadCommand(fd, &rx_data) ){
 		//error
 		prn(1, "Error: DoReadCommand() failed! Check messages log.\n");
 		return -1;
 	}
+
 	//use our special buffer at rxdata to hold received data
 	pri = &rx_data.api_header;
-	tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t *) rx_data.data;
+	tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;
 
 	user_buf->wp_tdm_api_event_type = pri->operation_status;
 
-	switch (pri->operation_status) {
+	switch(pri->operation_status)
+	{
 	case SANG_STATUS_RX_DATA_AVAILABLE:
 		//prn(verbose, "SANG_STATUS_RX_DATA_AVAILABLE\n");
 
-		if (pri->data_length > datalen) {
-			rx_len = 0;
+		if(pri->data_length > datalen){
+			rx_len=0;
 			break;
 		}
 		memcpy(databuf, rx_data.data, pri->data_length);
@@ -303,11 +315,12 @@
 		rx_len = pri->data_length;
 
 		//make copy for use with sangoma_tdm_read_event() - indirect access.
-		memcpy(&last_tdm_api_event_buffer, tdm_api_rx_hdr, sizeof(wp_tdm_api_rx_hdr_t));
+		memcpy(	&last_tdm_api_event_buffer,	tdm_api_rx_hdr, sizeof(wp_tdm_api_rx_hdr_t));
 		break;
 
 	default:
-		switch (pri->operation_status) {
+		switch(pri->operation_status)
+		{
 		case SANG_STATUS_RX_DATA_TIMEOUT:
 			//no data in READ_CMD_TIMEOUT, try again.
 			prn(1, "Error: Timeout on read.\n");
@@ -331,43 +344,43 @@
 		default:
 			prn(1, "Rx:Unknown Operation Status: %d\n", pri->operation_status);
 			break;
-		}						//switch()
+		}//switch()
 		return 0;
-	}							//switch()
+	}//switch()
 
 #else
 	struct msghdr msg;
 	struct iovec iov[2];
 
-	memset(&msg, 0, sizeof(struct msghdr));
+	memset(&msg,0,sizeof(struct msghdr));
 
-	iov[0].iov_len = hdrlen;
-	iov[0].iov_base = hdrbuf;
+	iov[0].iov_len=hdrlen;
+	iov[0].iov_base=hdrbuf;
 
-	iov[1].iov_len = datalen;
-	iov[1].iov_base = databuf;
+	iov[1].iov_len=datalen;
+	iov[1].iov_base=databuf;
 
-	msg.msg_iovlen = 2;
-	msg.msg_iov = iov;
+	msg.msg_iovlen=2;
+	msg.msg_iov=iov;
 
-	rx_len = read(fd, &msg, datalen + hdrlen);
+	rx_len = read(fd,&msg,datalen+hdrlen);
 
-	if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)) {
+	if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){
 		return -EINVAL;
 	}
 
-	rx_len -= sizeof(wp_tdm_api_rx_hdr_t);
+	rx_len-=sizeof(wp_tdm_api_rx_hdr_t);
 #endif
-	return rx_len;
-}
+    return rx_len;
+}                    
 
 int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag)
 {
 	int bsent;
 
 #if defined(WIN32)
-	static TX_DATA_STRUCT local_tx_data;
-	api_header_t *pri;
+	static TX_DATA_STRUCT	local_tx_data;
+	api_header_t			*pri;
 
 	pri = &local_tx_data.api_header;
 
@@ -375,35 +388,36 @@
 	memcpy(local_tx_data.data, databuf, pri->data_length);
 
 	//queue data for transmission
-	if (DoWriteCommand(fd, &local_tx_data)) {
+	if(	DoWriteCommand(fd, &local_tx_data)){
 		//error
 		prn(1, "Error: DoWriteCommand() failed!! Check messages log.\n");
 		return -1;
 	}
 
-	bsent = 0;
+	bsent=0;
 	//check that frame was transmitted
-	switch (local_tx_data.api_header.operation_status) {
+	switch(local_tx_data.api_header.operation_status)
+	{
 	case SANG_STATUS_SUCCESS:
 		bsent = datalen;
 		break;
-
+				
 	case SANG_STATUS_TX_TIMEOUT:
 		//error
 		prn(1, "****** Error: SANG_STATUS_TX_TIMEOUT ******\n");
 		//Check messages log or look at statistics.
 		break;
-
+				
 	case SANG_STATUS_TX_DATA_TOO_LONG:
 		//Attempt to transmit data longer than the pre-configured maximum.
 		//Maximum length is set in 'Interface Properties',
 		//in the 'Device Manager'.
 		prn(1, "****** SANG_STATUS_TX_DATA_TOO_LONG ******\n");
 		break;
-
+				
 	case SANG_STATUS_TX_DATA_TOO_SHORT:
 		//Minimum is 1 byte  for Primary   port,
-		//           2 bytes for Secondary port
+		//			 2 bytes for Secondary port
 		prn(1, "****** SANG_STATUS_TX_DATA_TOO_SHORT ******\n");
 		break;
 
@@ -416,27 +430,28 @@
 		break;
 
 	default:
-		prn(1, "Unknown return code (0x%X) on transmission!\n", local_tx_data.api_header.operation_status);
+		prn(1, "Unknown return code (0x%X) on transmission!\n",
+			local_tx_data.api_header.operation_status);
 		break;
-	}							//switch()
+	}//switch()
 #else
 	struct msghdr msg;
 	struct iovec iov[2];
 
-	memset(&msg, 0, sizeof(struct msghdr));
+	memset(&msg,0,sizeof(struct msghdr));
 
-	iov[0].iov_len = hdrlen;
-	iov[0].iov_base = hdrbuf;
+	iov[0].iov_len=hdrlen;
+	iov[0].iov_base=hdrbuf;
 
-	iov[1].iov_len = datalen;
-	iov[1].iov_base = databuf;
+	iov[1].iov_len=datalen;
+	iov[1].iov_base=databuf;
 
-	msg.msg_iovlen = 2;
-	msg.msg_iov = iov;
+	msg.msg_iovlen=2;
+	msg.msg_iov=iov;
 
-	bsent = write(fd, &msg, datalen + hdrlen);
-	if (bsent > 0) {
-		bsent -= sizeof(wp_tdm_api_tx_hdr_t);
+	bsent = write(fd,&msg,datalen+hdrlen);
+	if (bsent > 0){
+		bsent-=sizeof(wp_tdm_api_tx_hdr_t);
 	}
 #endif
 	return bsent;
@@ -449,17 +464,17 @@
  * Execute TDM command
  *
  */
-static int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 #if defined(WIN32)
 	err = tdmv_api_ioctl(fd, &tdm_api->wp_tdm_cmd);
 #else
-	err = ioctl(fd, SIOC_WANPIPE_TDM_API, &tdm_api->wp_tdm_cmd);
-	if (err < 0) {
+	err = ioctl(fd,SIOC_WANPIPE_TDM_API,&tdm_api->wp_tdm_cmd);
+	if (err < 0){
 		char tmp[50];
-		sprintf(tmp, "TDM API: CMD: %i\n", tdm_api->wp_tdm_cmd.cmd);
+		sprintf(tmp,"TDM API: CMD: %i\n",tdm_api->wp_tdm_cmd.cmd);
 		perror(tmp);
 		return -1;
 	}
@@ -471,35 +486,40 @@
  * Get Full TDM API configuration per channel
  *
  */
-int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_FULL_CFG;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	printf("TDM API CFG:\n");
-	printf("\thw_tdm_coding:\t%d\n", tdm_api->wp_tdm_cmd.hw_tdm_coding);
-	printf("\tusr_mtu_mru:\t%d\n", tdm_api->wp_tdm_cmd.hw_mtu_mru);
-	printf("\tusr_period:\t%d\n", tdm_api->wp_tdm_cmd.usr_period);
-	printf("\ttdm_codec:\t%d\n", tdm_api->wp_tdm_cmd.tdm_codec);
-	printf("\tpower_level:\t%d\n", tdm_api->wp_tdm_cmd.power_level);
-	printf("\trx_disable:\t%d\n", tdm_api->wp_tdm_cmd.rx_disable);
-	printf("\ttx_disable:\t%d\n", tdm_api->wp_tdm_cmd.tx_disable);
-	printf("\tusr_mtu_mru:\t%d\n", tdm_api->wp_tdm_cmd.usr_mtu_mru);
-	printf("\tidle flag:\t0x%02X\n", tdm_api->wp_tdm_cmd.idle_flag);
-	printf("\tfe alarms:\t0x%02X\n", tdm_api->wp_tdm_cmd.fe_alarms);
-
-	printf("\trx pkt\t%d\ttx pkt\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_packets, tdm_api->wp_tdm_cmd.stats.tx_packets);
-	printf("\trx err\t%d\ttx err\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_errors, tdm_api->wp_tdm_cmd.stats.tx_errors);
+	printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_tdm_cmd.hw_tdm_coding);
+	printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_tdm_cmd.hw_mtu_mru);
+	printf("\tusr_period:\t%d\n",tdm_api->wp_tdm_cmd.usr_period);
+	printf("\ttdm_codec:\t%d\n",tdm_api->wp_tdm_cmd.tdm_codec);
+	printf("\tpower_level:\t%d\n",tdm_api->wp_tdm_cmd.power_level);
+	printf("\trx_disable:\t%d\n",tdm_api->wp_tdm_cmd.rx_disable);
+	printf("\ttx_disable:\t%d\n",tdm_api->wp_tdm_cmd.tx_disable);
+	printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_tdm_cmd.usr_mtu_mru);
+	printf("\tidle flag:\t0x%02X\n",tdm_api->wp_tdm_cmd.idle_flag);
+	printf("\tfe alarms:\t0x%02X\n",tdm_api->wp_tdm_cmd.fe_alarms);
+	
+	printf("\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->wp_tdm_cmd.stats.rx_packets,
+				tdm_api->wp_tdm_cmd.stats.tx_packets);
+	printf("\trx err\t%d\ttx err\t%d\n",
+				tdm_api->wp_tdm_cmd.stats.rx_errors,
+				tdm_api->wp_tdm_cmd.stats.tx_errors);
 #ifndef __WINDOWS__
-	printf("\trx ovr\t%d\ttx idl\t%d\n", tdm_api->wp_tdm_cmd.stats.rx_fifo_errors, tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
-#endif
-
+	printf("\trx ovr\t%d\ttx idl\t%d\n",
+				tdm_api->wp_tdm_cmd.stats.rx_fifo_errors,
+				tdm_api->wp_tdm_cmd.stats.tx_carrier_errors);
+#endif				
+	
 	return 0;
 }
 
@@ -515,14 +535,14 @@
  * }
  *
  */
-int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec)
+int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_CODEC;
 	tdm_api->wp_tdm_cmd.tdm_codec = codec;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
 
 	return err;
 }
@@ -539,18 +559,18 @@
  * }
  *
  */
-int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_CODEC;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
-	return tdm_api->wp_tdm_cmd.tdm_codec;
+	return tdm_api->wp_tdm_cmd.tdm_codec;	
 }
 
 
@@ -561,14 +581,14 @@
  *  10,20,30,40,50 ms      
  *
  */
-int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period)
+int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_USR_PERIOD;
 	tdm_api->wp_tdm_cmd.usr_period = period;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
 
 	return err;
 }
@@ -580,14 +600,14 @@
  *  10,20,30,40,50 ms      
  *
  */
-int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_PERIOD;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
@@ -600,15 +620,15 @@
  * Coding Format will be ULAW/ALAW based on T1/E1 
  */
 
-int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api)
 {
-	int err;
-	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
-		return err;
-	}
-	return tdm_api->wp_tdm_cmd.hw_tdm_coding;
+        int err;
+        tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING;
+        err=sangoma_tdm_cmd_exec(fd,tdm_api);
+        if (err){
+                return err;
+        }
+        return tdm_api->wp_tdm_cmd.hw_tdm_coding;
 }
 
 
@@ -618,14 +638,14 @@
  * The USER MTU/MRU values will change each time a PERIOD
  * or CODEC is adjusted.
  */
-int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_MTU_MRU;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
@@ -638,14 +658,14 @@
  * This option is not implemented yet
  *
  */
-int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power)
+int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_POWER_LEVEL;
 	tdm_api->wp_tdm_cmd.power_level = power;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
 
 	return err;
 }
@@ -656,43 +676,42 @@
  * This option is not implemented yet
  *
  */
-int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_POWER_LEVEL;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return tdm_api->wp_tdm_cmd.power_level;
 }
 
-int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 #if 0
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_FLUSH_BUFFERS;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 #endif
 	return 0;
 }
 
-int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec)
-{
-
+int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec) {
+	
 	int err;
-
+	
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RBS_EVENTS;
-	tdm_api->wp_tdm_cmd.rbs_poll = poll_in_sec;
-
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	tdm_api->wp_tdm_cmd.rbs_poll=poll_in_sec; 
+	
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
@@ -700,180 +719,185 @@
 }
 
 
-int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
-{
+int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) {
 
 	int err;
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RBS_EVENTS;
-
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs)
+int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs) 
 {
-
+	
 	int err;
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_WRITE_RBS_BITS;
-	tdm_api->wp_tdm_cmd.rbs_tx_bits = rbs;
-
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	tdm_api->wp_tdm_cmd.rbs_tx_bits=rbs; 
+	
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
-}
+}        
 
-int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	wp_tdm_api_rx_hdr_t *rx_event;
 
-#if defined(WIN32)
+#if defined(WIN32)	
 	rx_event = &last_tdm_api_event_buffer;
 #else
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
-
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	rx_event = &tdm_api->wp_tdm_cmd.event;
 #endif
 
-	switch (rx_event->wp_tdm_api_event_type) {
-
+	switch (rx_event->wp_tdm_api_event_type){
+	
 	case WP_TDM_EVENT_RBS:
-		printf("%d: GOT RBS EVENT %p\n", (int) fd, tdm_api->wp_tdm_event.wp_rbs_event);
+		printf("%d: GOT RBS EVENT %p\n",(int)fd,tdm_api->wp_tdm_event.wp_rbs_event);
 		if (tdm_api->wp_tdm_event.wp_rbs_event) {
-			tdm_api->wp_tdm_event.wp_rbs_event(fd, rx_event->wp_tdm_api_event_rbs_rx_bits);
+			tdm_api->wp_tdm_event.wp_rbs_event(fd,rx_event->wp_tdm_api_event_rbs_rx_bits);
 		}
-
+		
 		break;
-
+		
 	case WP_TDM_EVENT_DTMF:
-		printf("%d: GOT DTMF EVENT\n", (int) fd);
+		printf("%d: GOT DTMF EVENT\n",(int)fd);
 		if (tdm_api->wp_tdm_event.wp_dtmf_event) {
 			tdm_api->wp_tdm_event.wp_dtmf_event(fd,
-												rx_event->wp_tdm_api_event_dtmf_digit,
-												rx_event->wp_tdm_api_event_dtmf_type, rx_event->wp_tdm_api_event_dtmf_port);
+						rx_event->wp_tdm_api_event_dtmf_digit,
+						rx_event->wp_tdm_api_event_dtmf_type,
+						rx_event->wp_tdm_api_event_dtmf_port);
 		}
 		break;
-
+		
 	case WP_TDM_EVENT_RXHOOK:
-		printf("%d: GOT RXHOOK EVENT\n", (int) fd);
+		printf("%d: GOT RXHOOK EVENT\n",(int)fd);
 		if (tdm_api->wp_tdm_event.wp_rxhook_event) {
-			tdm_api->wp_tdm_event.wp_rxhook_event(fd, rx_event->wp_tdm_api_event_rxhook_state);
+			tdm_api->wp_tdm_event.wp_rxhook_event(fd,
+						rx_event->wp_tdm_api_event_rxhook_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_RING_DETECT:
-		printf("%d: GOT RXRING EVENT\n", (int) fd);
+		printf("%d: GOT RXRING EVENT\n",(int)fd);
 		if (tdm_api->wp_tdm_event.wp_rxring_event) {
-			tdm_api->wp_tdm_event.wp_rxring_event(fd, rx_event->wp_tdm_api_event_ring_state);
+			tdm_api->wp_tdm_event.wp_rxring_event(fd,
+						rx_event->wp_tdm_api_event_ring_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_RING_TRIP:
-		printf("%d: GOT RING TRIP EVENT\n", (int) fd);
+		printf("%d: GOT RING TRIP EVENT\n",(int)fd);
 		if (tdm_api->wp_tdm_event.wp_ringtrip_event) {
-			tdm_api->wp_tdm_event.wp_ringtrip_event(fd, rx_event->wp_tdm_api_event_ring_state);
+			tdm_api->wp_tdm_event.wp_ringtrip_event(fd,
+						rx_event->wp_tdm_api_event_ring_state);
 		}
 		break;
 
 	case WP_TDM_EVENT_FE_ALARM:
-		printf("%d: GOT FE ALARMS EVENT %i\n", (int) fd, rx_event->wp_tdm_api_event_fe_alarm);
+		printf("%d: GOT FE ALARMS EVENT %i\n",(int)fd,
+				rx_event->wp_tdm_api_event_fe_alarm);
 		if (tdm_api->wp_tdm_event.wp_fe_alarm_event) {
-			tdm_api->wp_tdm_event.wp_fe_alarm_event(fd, rx_event->wp_tdm_api_event_fe_alarm);
-		}
-
+			tdm_api->wp_tdm_event.wp_fe_alarm_event(fd,
+						rx_event->wp_tdm_api_event_fe_alarm);
+		}    
+		
 	default:
-		printf("%d: Unknown TDM event!", (int) fd);
+		printf("%d: Unknown TDM event!", (int)fd);
 		break;
 	}
-
+	
 	return 0;
-}
+}        
 
-int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
-
+	
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_DTMF_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_DTMF_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	int err;
-
+	
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RM_DTMF_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RM_DTMF_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_ENABLE_RXHOOK_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return 0;
 }
 
-int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api) 
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_DISABLE_RXHOOK_EVENTS;
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
@@ -884,18 +908,18 @@
  * GET Front End Alarms
  * 
  */
-int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api)
+int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api)
 {
 	int err;
 
 	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_FE_ALARMS;
 
-	err = sangoma_tdm_cmd_exec(fd, tdm_api);
-	if (err) {
+	err=sangoma_tdm_cmd_exec(fd,tdm_api);
+	if (err){
 		return err;
 	}
 
 	return tdm_api->wp_tdm_cmd.fe_alarms;
-}
+}         
 
 #endif /* WANPIPE_TDM_API */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h	Fri Apr 13 10:44:28 2007
@@ -34,7 +34,7 @@
 #ifdef WANPIPE_TDM_API
 #include <wanpipe_tdm_api.h>	//for TDMV API
 #endif
-#include <sang_status_defines.h>	//return codes
+#include <sang_status_defines.h>//return codes
 #include <sang_api.h>			//for IOCTL codes
 #include <sdla_te1_pmc.h>		//RBS definitions
 #include <sdla_te1.h>			//TE1 macros
@@ -94,7 +94,7 @@
 /* Open Span/Chan devices
  * open_tdmapi_span_chan: open device based on span chan values 
  * sangoma_open_tdmapi_span: open first available device on span
- */
+ */     
 
 sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan);
 sng_fd_t sangoma_open_tdmapi_span(int span);
@@ -104,65 +104,68 @@
 /* Device Rx/Tx functions 
  * writemsg_tdm: 	tx header + data from separate buffers 
  * readmsg_tdm: 	rx header + data to separate buffers
- */
-int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag);
-int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
+ */    
+int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, 
+						 void *databuf, unsigned short datalen, int flag);
+int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, 
+						void *databuf, int datalen, int flag);
 
 #define sangoma_readmsg_socket sangoma_readmsg_tdm
 #define sangoma_sendmsg_socket sangoma_writemsg_tdm
 
 #ifdef WANPIPE_TDM_API
 
-void sangoma_socket_close(sng_fd_t * sp);
+void sangoma_socket_close(sng_fd_t *sp);
 int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags);
 
 /* Get Full TDM API configuration per chan */
-int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* Get/Set TDM Codec per chan */
-int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec);
-int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec);
+int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* Get/Set USR Tx/Rx Period in milliseconds */
-int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period);
-int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period);
+int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* Get user MTU/MRU values in bytes */
-int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* Not supported yet */
-int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power);
-int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power);
+int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* Flush buffers from current channel */
-int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
-int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec);
-int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec);
+int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
-int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs);
+int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs);
 
-int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* DTMF Detection on Octasic chip */
-int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
-int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* DTMF Detection on A200 (SLIC) chip */
-int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
-int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 /* On/Off hook events on A200 (Analog) card */
-int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
-int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
-int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
+int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
 #ifndef LIBSANGOMA_GET_HWCODING
 #define LIBSANGOMA_GET_HWCODING 1
 #endif
-int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api);
+int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api);
 
-#endif /* WANPIPE_TDM_API */
+#endif 	/* WANPIPE_TDM_API */
 
 #endif

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	Fri Apr 13 10:44:28 2007
@@ -80,8 +80,8 @@
 	char map[SANGOMA_MAX_CHAN_PER_SPAN][SWITCH_UUID_FORMATTED_LENGTH + 1];
 };
 
-unsigned int txseq = 0;
-unsigned int rxseq = 0;
+unsigned int txseq=0;
+unsigned int rxseq=0;
 
 #define SETUP_LEN CORE_MAX_CHAN_PER_SPAN*CORE_MAX_SPANS+1
 
@@ -99,7 +99,7 @@
 
 typedef struct ss7boost_handle ss7boost_handle_t;
 
-static int isup_exec_command(ss7boost_handle_t * ss7boost_handle, int span, int chan, int id, int cmd, int cause);
+static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int chan, int id, int cmd, int cause);
 
 static struct {
 	int debug;
@@ -210,38 +210,38 @@
 
 
 
-static int local_sangoma_tdm_read_event(sng_fd_t fd, wp_tdm_api_rx_hdr_t * rx_event)
+static int local_sangoma_tdm_read_event(sng_fd_t fd, wp_tdm_api_rx_hdr_t *rx_event)
 {
 	wanpipe_tdm_api_t tdm_api[1];
-
+	
 #if defined(WIN32)
-	rx_event = &last_tdm_api_event_buffer;
+    rx_event = &last_tdm_api_event_buffer;
 #else
-	int err;
+    int err;
 
-	tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
+    tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
 
-	if ((err = sangoma_tdm_cmd_exec(fd, tdm_api))) {
-		return err;
-	}
+    if ((err = sangoma_tdm_cmd_exec(fd, tdm_api))) {
+        return err;
+    }
 
-	rx_event = &tdm_api->wp_tdm_cmd.event;
+    rx_event = &tdm_api->wp_tdm_cmd.event;
 #endif
 
 	return 0;
 }
 
-static int analog_set_state(analog_channel_t * alc, analog_state_t state)
+static int analog_set_state(analog_channel_t *alc, analog_state_t state)
 {
 	alc->state = state;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing State to %d\n", state);
 }
 
-static void analog_check_state(analog_channel_t * alc)
+static void analog_check_state(analog_channel_t *alc)
 {
 	wanpipe_tdm_api_t tdm_api;
 
-	switch (alc->state) {
+	switch(alc->state) {
 	case ANALOG_STATE_DOWN:
 		sangoma_tdm_enable_rxhook_events(alc->sock->fd, &tdm_api);
 		analog_set_state(alc, ANALOG_STATE_ONHOOK);
@@ -251,11 +251,11 @@
 	}
 }
 
-static void analog_parse_event(analog_channel_t * alc)
+static void analog_parse_event(analog_channel_t *alc)
 {
 	wp_tdm_api_rx_hdr_t rx_event;
 	int err = local_sangoma_tdm_read_event(alc->sock->fd, &rx_event);
-
+	
 	if (err < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error reading event!\n");
 		return;
@@ -269,21 +269,21 @@
 
 }
 
-static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *obj)
 {
 
-	for (;;) {
+	for(;;) {
 		int i = 0, sel_on = -1;
 		fd_set oob;
 		FD_ZERO(&oob);
-
-		for (i = 0; i < globals.fxs_index; i++) {
+		
+		for(i = 0; i < globals.fxs_index; i++) {
 			int fd;
 			assert(FXS_ANALOG_CHANNELS[i]);
 			assert(FXS_ANALOG_CHANNELS[i]->sock);
 
 			fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
-
+			
 			analog_check_state(FXS_ANALOG_CHANNELS[i]);
 
 			FD_SET(fd, &oob);
@@ -295,7 +295,7 @@
 
 		if (sel_on > -1) {
 			if (select(++sel_on, NULL, NULL, &oob, NULL)) {
-				for (i = 0; i < globals.fxs_index; i++) {
+				for(i = 0; i < globals.fxs_index; i++) {
 					int fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
 					if (FD_ISSET(fd, &oob)) {
 						analog_parse_event(FXS_ANALOG_CHANNELS[i]);
@@ -307,7 +307,7 @@
 }
 
 
-static int wp_close(private_object_t * tech_pvt)
+static int wp_close(private_object_t *tech_pvt)
 {
 	int ret = 0;
 
@@ -317,16 +317,16 @@
 		ret = 1;
 	}
 	switch_mutex_unlock(globals.hash_mutex);
-
+	
 	return ret;
 }
 
-static wpsock_t *wp_open(private_object_t * tech_pvt, int span, int chan)
+static wpsock_t *wp_open(private_object_t *tech_pvt, int span, int chan)
 {
 	sng_fd_t fd;
 	wpsock_t *sock;
 	char name[25];
-
+	
 	snprintf(name, sizeof(name), "s%dc%d", span, chan);
 
 	switch_mutex_lock(globals.hash_mutex);
@@ -364,7 +364,7 @@
 	wpsock_t *sock;
 	sng_fd_t fd;
 	char name[25];
-
+	
 	snprintf(name, sizeof(name), "s%dc%d", span, chan);
 
 	switch_mutex_lock(globals.hash_mutex);
@@ -380,7 +380,7 @@
 		sangoma_socket_close(&fd);
 		return 0;
 	}
-
+	
 	return -1;
 }
 
@@ -444,7 +444,7 @@
 	if (!strcasecmp(dp, "local"))
 		return PRI_LOCAL_ISDN;
 	if (!strcasecmp(dp, "private"))
-		return PRI_PRIVATE;
+		return PRI_PRIVATE;		
 	if (!strcasecmp(dp, "unknown"))
 		return PRI_UNKNOWN;
 
@@ -460,25 +460,26 @@
 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_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
-													switch_caller_profile_t *outbound_profile,
+static switch_call_cause_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 * pevent);
-static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
-static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
+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 *pevent);
+static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
+static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
 static int check_flags(struct sangoma_pri *spri);
-static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
-static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent);
-static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t * thread, void *obj);
+static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
+static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent);
+static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t *thread, void *obj);
 static switch_status_t config_wanpipe(int reload);
 
 
-static switch_status_t wanpipe_codec_init(private_object_t * tech_pvt)
+static switch_status_t wanpipe_codec_init(private_object_t *tech_pvt)
 {
 	int err = 0;
-	wanpipe_tdm_api_t tdm_api = { {0} };
+	wanpipe_tdm_api_t tdm_api = {{0}};
 	unsigned int rate = 8000;
 	switch_channel_t *channel = NULL;
 
@@ -491,21 +492,21 @@
 	assert(channel != NULL);
 
 	err = sangoma_tdm_set_codec(tech_pvt->wpsock->fd, &tdm_api, WP_SLINEAR);
-
+	
 	sangoma_tdm_set_usr_period(tech_pvt->wpsock->fd, &tdm_api, globals.samples_per_frame / 8);
 	tech_pvt->frame_size = sangoma_tdm_get_usr_mtu_mru(tech_pvt->wpsock->fd, &tdm_api);
 
 	if (switch_core_codec_init
-		(&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
-		 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+		(&tech_pvt->read_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 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, "%s Cannot set read codec\n", switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
 	}
 
 	if (switch_core_codec_init
-		(&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 1,
-		 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+		(&tech_pvt->write_codec, "L16", NULL, rate, globals.samples_per_frame / 8, 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, "%s Cannot set read codec\n", switch_channel_get_name(channel));
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return SWITCH_STATUS_FALSE;
@@ -515,25 +516,25 @@
 	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);
 
-#ifdef DOTRACE
-	tech_pvt->fd = open("/tmp/wp-in.raw", O_WRONLY | O_TRUNC | O_CREAT);
-	tech_pvt->fd2 = open("/tmp/wp-out.raw", O_WRONLY | O_TRUNC | O_CREAT);
+#ifdef DOTRACE	
+						tech_pvt->fd = open("/tmp/wp-in.raw", O_WRONLY | O_TRUNC | O_CREAT);
+						tech_pvt->fd2 = open("/tmp/wp-out.raw", O_WRONLY | O_TRUNC | O_CREAT);
 #endif
 
 	/* Setup artificial DTMF stuff */
 	memset(&tech_pvt->tone_session, 0, sizeof(tech_pvt->tone_session));
 	teletone_init_session(&tech_pvt->tone_session, 1024, NULL, NULL);
-
+	
 	if (globals.debug) {
 		tech_pvt->tone_session.debug = globals.debug;
 		tech_pvt->tone_session.debug_stream = stdout;
 	}
-
+	
 	tech_pvt->tone_session.rate = rate;
 	tech_pvt->tone_session.duration = globals.dtmf_on * (tech_pvt->tone_session.rate / 1000);
 	tech_pvt->tone_session.wait = globals.dtmf_off * (tech_pvt->tone_session.rate / 1000);
-
-	teletone_dtmf_detect_init(&tech_pvt->dtmf_detect, rate);
+	
+	teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio init %s\n", switch_channel_get_name(channel));
 
 	switch_set_flag(tech_pvt, TFLAG_CODEC);
@@ -562,46 +563,46 @@
 
 	tech_pvt->read_frame.data = tech_pvt->databuf;
 
-	if (tech_pvt->ss7boost_handle) {
+	if (tech_pvt->ss7boost_handle)  {
 		if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
 			ss7boost_client_event_t event;
 
 			event.calling_number_presentation = tech_pvt->boost_pres;
 			event.trunk_group = tech_pvt->boost_trunk_group;
-
+		
 			switch_mutex_lock(tech_pvt->ss7boost_handle->mutex);
 			tech_pvt->setup_index = ++tech_pvt->ss7boost_handle->setup_index;
 			if (tech_pvt->ss7boost_handle->setup_index == SETUP_LEN - 1) {
 				tech_pvt->ss7boost_handle->setup_index = 0;
 			}
 			switch_mutex_unlock(tech_pvt->ss7boost_handle->mutex);
-
+		
 			switch_copy_string(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index],
-							   switch_core_session_get_uuid(session), sizeof(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index]));
-
-
-			ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number, tech_pvt->caller_profile->destination_number,
-									  tech_pvt->setup_index);
-
+							   switch_core_session_get_uuid(session), 
+							   sizeof(tech_pvt->ss7boost_handle->setup_array[tech_pvt->setup_index]));
+		
+			
+			ss7boost_client_call_init(&event, tech_pvt->caller_profile->caller_id_number, tech_pvt->caller_profile->destination_number, tech_pvt->setup_index);
+			
 			if (ss7boost_client_connection_write(&tech_pvt->ss7boost_handle->mcon, &event) <= 0) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Critical System Error: Failed to tx on ISUP socket [%s]\n", strerror(errno));
 			}
-
+			
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Called Event TG=%d\n", tech_pvt->boost_trunk_group);
 			goto done;
 		}
-	}
+	} 
 
 	if ((status = wanpipe_codec_init(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return status;
 	}
-
+	
 	if (switch_test_flag(tech_pvt, TFLAG_NOSIG)) {
 		switch_channel_mark_answered(channel);
 	}
 
-  done:
+ done:
 
 	/* Move Channel's State Machine to RING */
 	switch_channel_set_state(channel, CS_RING);
@@ -621,7 +622,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WANPIPE RING\n");
 
-
+	
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -632,7 +633,7 @@
 	switch_channel_t *channel = NULL;
 	struct channel_map *chanmap = NULL;
 
-
+	
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -655,20 +656,24 @@
 		switch_mutex_unlock(tech_pvt->ss7boost_handle->mutex);
 		if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
 			isup_exec_command(tech_pvt->ss7boost_handle,
-							  tech_pvt->boost_span_number, tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_NORMAL);
+							  tech_pvt->boost_span_number,
+							  tech_pvt->boost_chan_number,
+							  -1,
+							  SIGBOOST_EVENT_CALL_STOPPED,
+							  SIGBOOST_RELEASE_CAUSE_NORMAL);
 		}
 	} else if (tech_pvt->spri) {
 		chanmap = tech_pvt->spri->private_info;
 
-		if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
+		//if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
 			pri_hangup(tech_pvt->spri->pri, tech_pvt->call, switch_channel_get_cause(channel));
 			pri_destroycall(tech_pvt->spri->pri, tech_pvt->call);
-		}
+			//}
 
 		switch_mutex_lock(globals.channel_mutex);
 		*chanmap->map[tech_pvt->callno] = '\0';
 		switch_mutex_unlock(globals.channel_mutex);
-
+		
 	}
 
 	switch_set_flag_locked(tech_pvt, TFLAG_BYE);
@@ -676,7 +681,7 @@
 	teletone_destroy_session(&tech_pvt->tone_session);
 
 	switch_buffer_destroy(&tech_pvt->dtmf_buffer);
-
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -720,7 +725,12 @@
 			pri_answer(tech_pvt->spri->pri, tech_pvt->call, 0, 1);
 		}
 	} else if (tech_pvt->ss7boost_handle) {
-		isup_exec_command(tech_pvt->ss7boost_handle, tech_pvt->boost_span_number, tech_pvt->boost_chan_number, -1, SIGBOOST_EVENT_CALL_ANSWERED, 0);
+		isup_exec_command(tech_pvt->ss7boost_handle,
+						  tech_pvt->boost_span_number,
+						  tech_pvt->boost_chan_number,
+						  -1,
+						  SIGBOOST_EVENT_CALL_ANSWERED,
+						  0);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -728,7 +738,8 @@
 
 
 
-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_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
+										switch_io_flag_t flags, int stream_id)
 {
 	private_object_t *tech_pvt;
 	switch_channel_t *channel = NULL;
@@ -761,7 +772,8 @@
 		}
 
 		if ((bread = sangoma_readmsg_socket(tech_pvt->wpsock->fd,
-											&tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
+										  &tech_pvt->hdrframe,
+										  sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
 			if (errno == EBUSY) {
 				continue;
 			} else {
@@ -780,10 +792,10 @@
 	tech_pvt->read_frame.datalen = bytes;
 	tech_pvt->read_frame.samples = bytes / 2;
 
-	teletone_dtmf_detect(&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+	teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
 	teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
-
-	if (digit_str[0]) {
+	
+	if(digit_str[0]) {
 		switch_channel_queue_dtmf(channel, digit_str);
 		if (globals.debug) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
@@ -797,7 +809,8 @@
 		memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
 		tech_pvt->skip_read_frames--;
 	}
-#ifdef DOTRACE
+
+#ifdef DOTRACE	
 	write(tech_pvt->fd2, tech_pvt->read_frame.data, (int) tech_pvt->read_frame.datalen);
 #endif
 	//printf("read %d\n", tech_pvt->read_frame.datalen);
@@ -805,7 +818,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-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 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)
 {
 	private_object_t *tech_pvt;
 	uint32_t dtmf_blen;
@@ -822,24 +836,25 @@
 	if (tech_pvt->dtmf_buffer && (dtmf_blen = switch_buffer_inuse(tech_pvt->dtmf_buffer))) {
 		uint32_t len = dtmf_blen > frame->datalen ? frame->datalen : dtmf_blen;
 
-		switch_buffer_read(tech_pvt->dtmf_buffer, tech_pvt->auxbuf, len);
+		switch_buffer_read(tech_pvt->dtmf_buffer, tech_pvt->auxbuf, len);		
 		if (len < frame->datalen) {
 			uint8_t *data = frame->data;
 			memcpy(data + len, tech_pvt->auxbuf + len, frame->datalen - len);
 		}
-		data = tech_pvt->auxbuf;
-	}
-
+		data= tech_pvt->auxbuf;
+	} 
+	
 	if (tech_pvt->skip_write_frames) {
 		tech_pvt->skip_write_frames--;
 		return SWITCH_STATUS_SUCCESS;
 	}
+
 #ifdef DOTRACE
 	write(tech_pvt->fd, data, frame->datalen);
 #endif
 
 	result = sangoma_sendmsg_socket(tech_pvt->wpsock->fd, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), data, frame->datalen, 0);
-
+	
 	if (result < 0 && errno != EBUSY) {
 		return SWITCH_STATUS_GENERR;
 	}
@@ -871,13 +886,13 @@
 		}
 	}
 	for (cur = digits; *cur; cur++) {
-		if ((wrote = teletone_mux_tones(&tech_pvt->tone_session, &tech_pvt->tone_session.TONES[(int) *cur]))) {
+		if ((wrote = teletone_mux_tones(&tech_pvt->tone_session, &tech_pvt->tone_session.TONES[(int)*cur]))) {
 			switch_buffer_write(tech_pvt->dtmf_buffer, tech_pvt->tone_session.buffer, wrote * 2);
 		}
 	}
 
 	tech_pvt->skip_read_frames = 200;
-
+	
 	return status;
 }
 
@@ -888,7 +903,7 @@
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
-
+			
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
@@ -930,7 +945,7 @@
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	switch (sig) {
+	switch(sig) {
 	case SWITCH_SIG_KILL:
 		switch_clear_flag_locked(tech_pvt, TFLAG_MEDIA);
 		break;
@@ -953,8 +968,8 @@
 	/*.kill_channel */ wanpipe_kill_channel,
 	/*.waitfor_read */ NULL,
 	/*.waitfor_read */ NULL,
-	/*.send_dtmf */ wanpipe_send_dtmf,
-	/*.receive_message */ wanpipe_receive_message
+	/*.send_dtmf*/ wanpipe_send_dtmf,
+	/*.receive_message*/ wanpipe_receive_message
 };
 
 static const switch_state_handler_table_t wanpipe_state_handlers = {
@@ -984,8 +999,7 @@
 };
 
 
-static switch_call_cause_t wanpipe_outgoing_channel(switch_core_session_t *session,
-													switch_caller_profile_t *outbound_profile,
+static switch_call_cause_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;
@@ -994,7 +1008,7 @@
 	char *dest;
 	int ready = 0, is_pri = 0, is_boost = 0, is_raw = 0;
 	switch_call_cause_t cause = SWITCH_CAUSE_SUCCESS;
-
+	
 	if (!outbound_profile) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
 		cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -1008,7 +1022,7 @@
 		cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 		goto error;
 	}
-
+	
 	*dest++ = '\0';
 
 	if (!strcasecmp(protocol, "raw")) {
@@ -1027,7 +1041,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error No SS7BOOST Spans Configured.\n");
 		}
 	}
-
+	
 	if (!ready) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Continue!\n");
 		cause = SWITCH_CAUSE_NETWORK_OUT_OF_ORDER;
@@ -1061,7 +1075,7 @@
 			goto error;
 		}
 
-
+		
 		caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
 
 		if (is_pri) {
@@ -1124,7 +1138,7 @@
 				}
 				switch_set_flag_locked(tech_pvt, TFLAG_NOSIG);
 				snprintf(name, sizeof(name), "wanpipe/%s/nosig", bchan);
-				switch_channel_set_name(channel, name);
+				switch_channel_set_name(channel, name);			
 				switch_channel_set_caller_profile(channel, caller_profile);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid address\n");
@@ -1146,18 +1160,18 @@
 
 				if (SPANS[span] && (spri = &SPANS[span]->spri) && switch_test_flag(spri, SANGOMA_PRI_READY)) {
 					chanmap = spri->private_info;
-
+						
 					if (autochan > 0) {
-						for (callno = 1; callno < SANGOMA_MAX_CHAN_PER_SPAN; callno++) {
-							if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
+						for(callno = 1; callno < SANGOMA_MAX_CHAN_PER_SPAN; callno++) {
+							if ((SPANS[span]->bchans & (1 << callno)) && ! *chanmap->map[callno]) {
 								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
 								goto done;
 							}
 						}
 						callno = 0;
 					} else if (autochan < 0) {
-						for (callno = SANGOMA_MAX_CHAN_PER_SPAN; callno > 0; callno--) {
-							if ((SPANS[span]->bchans & (1 << callno)) && !*chanmap->map[callno]) {
+						for(callno = SANGOMA_MAX_CHAN_PER_SPAN; callno > 0; callno--) {
+							if ((SPANS[span]->bchans & (1 << callno)) && ! *chanmap->map[callno]) {
 								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing channel s%dc%d\n", span, callno);
 								goto done;
 							}
@@ -1172,7 +1186,7 @@
 					span--;
 				}
 			}
-		  done:
+		done:
 			switch_mutex_unlock(globals.channel_mutex);
 
 			if (!spri || callno == 0 || callno == (SANGOMA_MAX_CHAN_PER_SPAN)) {
@@ -1181,26 +1195,31 @@
 				cause = SWITCH_CAUSE_SWITCH_CONGESTION;
 				goto error;
 			}
-
+				
 			tech_pvt->callno = callno;
-
+				
 			if (spri && (tech_pvt->call = pri_new_call(spri->pri))) {
 				struct pri_sr *sr;
-
+					
 				snprintf(name, sizeof(name), "wanpipe/pri/s%dc%d/%s", spri->span, callno, caller_profile->destination_number);
-				switch_channel_set_name(channel, name);
+				switch_channel_set_name(channel, name);			
 				switch_channel_set_caller_profile(channel, caller_profile);
 				sr = pri_sr_new();
 				pri_sr_set_channel(sr, callno, 0, 0);
 				pri_sr_set_bearer(sr, 0, SPANS[span]->l1);
 				pri_sr_set_called(sr, caller_profile->destination_number, SPANS[span]->dp, 1);
 				pri_sr_set_caller(sr,
-								  caller_profile->caller_id_number, caller_profile->caller_id_name, SPANS[span]->dp,
+								  caller_profile->caller_id_number,
+								  caller_profile->caller_id_name,
+								  SPANS[span]->dp,
 								  PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
-				pri_sr_set_redirecting(sr, caller_profile->caller_id_number, SPANS[span]->dp, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN,
+				pri_sr_set_redirecting(sr,
+									   caller_profile->caller_id_number,
+									   SPANS[span]->dp,
+									   PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN,
 									   PRI_REDIR_UNCONDITIONAL);
-
-				if (pri_setup(spri->pri, tech_pvt->call, sr)) {
+				
+				if (pri_setup(spri->pri, tech_pvt->call , sr)) {
 					switch_core_session_destroy(new_session);
 					pri_sr_free(sr);
 					cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -1215,7 +1234,9 @@
 					goto error;
 				}
 				pri_sr_free(sr);
-				switch_copy_string(chanmap->map[callno], switch_core_session_get_uuid(*new_session), sizeof(chanmap->map[callno]));
+				switch_copy_string(chanmap->map[callno],
+								   switch_core_session_get_uuid(*new_session),
+								   sizeof(chanmap->map[callno]));
 				tech_pvt->spri = spri;
 			}
 		} else if (is_boost) {
@@ -1224,8 +1245,8 @@
 			if ((p = strchr(caller_profile->destination_number, '/'))) {
 				char *grp = caller_profile->destination_number;
 				*p = '\0';
-				caller_profile->destination_number = p + 1;
-				tech_pvt->boost_trunk_group = atoi(grp + 1) - 1;
+				caller_profile->destination_number = p+1;
+				tech_pvt->boost_trunk_group = atoi(grp+1) - 1;
 				if (tech_pvt->boost_trunk_group < 0) {
 					tech_pvt->boost_trunk_group = 0;
 				}
@@ -1248,7 +1269,7 @@
 		cause = SWITCH_CAUSE_SUCCESS;
 	}
 
-  error:
+ error:
 	switch_safe_free(protocol);
 	return cause;
 }
@@ -1310,7 +1331,7 @@
 
 /*event Handlers */
 
-static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "number is: %s\n", pevent->ring.callednum);
 	if (strlen(pevent->ring.callednum) > 3) {
@@ -1320,7 +1341,7 @@
 	return 0;
 }
 
-static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	struct channel_map *chanmap;
 	switch_core_session_t *session;
@@ -1343,7 +1364,7 @@
 		tech_pvt->cause = pevent->hangup.cause;
 		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 		switch_channel_hangup(channel, tech_pvt->cause);
-
+		
 		switch_mutex_lock(globals.channel_mutex);
 		*chanmap->map[pevent->hangup.channel] = '\0';
 		switch_mutex_unlock(globals.channel_mutex);
@@ -1355,7 +1376,7 @@
 	return 0;
 }
 
-static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1373,12 +1394,12 @@
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Answer on channel s%dc%d but it's not in use?\n", spri->span, pevent->answer.channel);
 	}
-
+	
 	return 0;
 }
 
 
-static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1390,10 +1411,10 @@
 		switch_core_session_message_t *msg;
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, pevent->proceeding.channel);
-
+		
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
-
+		
 		if ((msg = malloc(sizeof(*msg)))) {
 			memset(msg, 0, sizeof(*msg));
 			msg->message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
@@ -1404,18 +1425,18 @@
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 		}
-
+		
 		switch_core_session_rwunlock(session);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-						  "-- Proceeding on channel s%dc%d but it's not in use?\n", spri->span, pevent->proceeding.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d but it's not in use?\n", 
+						  spri->span, pevent->proceeding.channel);
 	}
 
 	return 0;
 }
 
 
-static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	switch_core_session_t *session;
 	switch_channel_t *channel;
@@ -1434,35 +1455,34 @@
 
 		switch_core_session_rwunlock(session);
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-						  "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel,
-						  chanmap->map[pevent->ringing.channel]);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, pevent->ringing.channel, chanmap->map[pevent->ringing.channel]);
 	}
 
 	return 0;
 }
 
 
-static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	char name[128];
 	switch_core_session_t *session;
 	switch_channel_t *channel;
 	struct channel_map *chanmap;
 	int ret = 0;
-
+	
 	switch_mutex_lock(globals.channel_mutex);
 
 	chanmap = spri->private_info;
 	if (switch_core_session_locate(chanmap->map[pevent->ring.channel])) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate Ring on channel s%dc%d (ignored)\n", spri->span, pevent->ring.channel);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate Ring on channel s%dc%d (ignored)\n",
+							  spri->span, pevent->ring.channel);
 		switch_core_session_rwunlock(session);
 		ret = 0;
 		goto done;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Ring on channel s%dc%d (from %s to %s)\n", spri->span,
-					  pevent->ring.channel, pevent->ring.callingnum, pevent->ring.callednum);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Ring on channel s%dc%d (from %s to %s)\n", spri->span, pevent->ring.channel,
+						  pevent->ring.callingnum, pevent->ring.callednum);
 
 
 	pri_proceeding(spri->pri, pevent->ring.call, pevent->ring.channel, 0);
@@ -1494,14 +1514,21 @@
 		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-																  NULL, globals.dialplan, "FreeSWITCH", pevent->ring.callingnum,
+																  NULL,
+																  globals.dialplan,
+																  "FreeSWITCH",
+																  pevent->ring.callingnum,
 #ifdef WIN32
 																  NULL,
 #else
 																  pevent->ring.callingani,
 #endif
 																  switch_strlen_zero(ani2str) ? NULL : ani2str,
-																  NULL, NULL, (char *) modname, NULL, pevent->ring.callednum))) {
+																  NULL,
+																  NULL,
+																  (char *)modname,
+																  NULL,
+																  pevent->ring.callednum))) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
@@ -1512,7 +1539,7 @@
 		if (!tech_pvt->call) {
 			tech_pvt->call = pevent->ring.call;
 		}
-
+		
 		tech_pvt->callno = pevent->ring.channel;
 		tech_pvt->span = spri->span;
 
@@ -1521,16 +1548,16 @@
 		}
 
 		switch_copy_string(chanmap->map[pevent->ring.channel], switch_core_session_get_uuid(session), sizeof(chanmap->map[pevent->ring.channel]));
-
+		
 		switch_channel_set_state(channel, CS_INIT);
 		switch_core_session_thread_launch(session);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n");
 	}
 
-  done:
+ done:
 	switch_mutex_unlock(globals.channel_mutex);
-
+	
 	return ret;
 }
 
@@ -1540,7 +1567,7 @@
 	return 0;
 }
 
-static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 	switch_core_session_t *session;
 	struct channel_map *chanmap;
@@ -1554,7 +1581,7 @@
 
 
 	chanmap = spri->private_info;
-
+	
 	if ((session = switch_core_session_locate(chanmap->map[pevent->restart.channel]))) {
 		switch_channel_t *channel;
 		channel = switch_core_session_get_channel(session);
@@ -1562,13 +1589,13 @@
 		switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		switch_core_session_rwunlock(session);
 	}
-
+	
 	wp_restart(spri->span, pevent->restart.channel);
 
 	return 0;
 }
 
-static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 
 	if (!switch_test_flag(spri, SANGOMA_PRI_READY)) {
@@ -1579,26 +1606,27 @@
 	return 0;
 }
 
-static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 
 	if (switch_test_flag(spri, SANGOMA_PRI_READY)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Span %d D-Chan DOWN!\n", spri->span);
 		switch_clear_flag(spri, SANGOMA_PRI_READY);
 	}
-
+	
 	return 0;
 }
 
-static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event * pevent)
+static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
 {
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Caught Event span %d %u (%s)\n", spri->span, event_type, sangoma_pri_event_str(event_type));
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Caught Event span %d %u (%s)\n", spri->span, event_type,
+						  sangoma_pri_event_str(event_type));
 	return 0;
 }
 
 
-static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC pri_thread_run(switch_thread_t *thread, void *obj)
 {
 	struct sangoma_pri *spri = obj;
 	struct channel_map chanmap;
@@ -1637,7 +1665,7 @@
 {
 	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);
@@ -1646,7 +1674,7 @@
 }
 
 
-static int isup_exec_command(ss7boost_handle_t * ss7boost_handle, int span, int chan, int id, int cmd, int cause)
+static int isup_exec_command(ss7boost_handle_t *ss7boost_handle, int span, int chan, int id, int cmd, int cause)
 {
 	ss7boost_client_event_t oevent;
 	int r = 0;
@@ -1654,12 +1682,12 @@
 	switch_mutex_lock(ss7boost_handle->mutex);
 	ss7boost_client_event_init(&oevent, cmd, chan, span);
 	oevent.release_cause = cause;
-
+	
 	if (id >= 0) {
 		oevent.call_setup_id = id;
 	}
-
-	if (ss7boost_client_connection_write(&ss7boost_handle->mcon, &oevent) <= 0) {
+	
+	if (ss7boost_client_connection_write(&ss7boost_handle->mcon, &oevent) <= 0){
 		r = -1;
 	}
 
@@ -1671,26 +1699,26 @@
 #ifdef USE_WAITFOR_SOCKET
 static int waitfor_socket(int fd, int timeout, int flags)
 {
-	struct pollfd pfds[1];
-	int res;
-
-	memset(&pfds[0], 0, sizeof(pfds[0]));
-	pfds[0].fd = fd;
-	pfds[0].events = flags;
-	res = poll(pfds, 1, timeout);
-
-	if (res > 0) {
-		if (pfds[0].revents & POLLIN) {
-			res = 1;
-		} else if ((pfds[0].revents & POLLERR)) {
-			res = -1;
-		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "System Error: Poll Event Error no event!\n");
-			res = -1;
-		}
+    struct pollfd pfds[1];
+    int res;
+ 
+    memset(&pfds[0], 0, sizeof(pfds[0]));
+    pfds[0].fd = fd;
+    pfds[0].events = flags;
+    res = poll(pfds, 1, timeout);
+
+    if (res > 0) {
+	if(pfds[0].revents & POLLIN) {
+		res = 1;
+	} else if ((pfds[0].revents & POLLERR)) {
+		res = -1;
+    	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"System Error: Poll Event Error no event!\n");
+		res = -1;
 	}
+    }
 
-	return res;
+    return res;
 }
 #endif
 
@@ -1708,7 +1736,7 @@
 }
 
 
-static void handle_call_stop(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_stop(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	char *uuid = ss7boost_handle->span_chanmap[event->span].map[event->chan];
 
@@ -1718,7 +1746,7 @@
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-
+	
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
 
@@ -1730,25 +1758,35 @@
 		}
 		*uuid = '\0';
 
-	}
+	} 
 
-	isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED_ACK, 0);
+	isup_exec_command(ss7boost_handle,
+					  event->span, 
+					  event->chan, 
+					  -1,
+					  SIGBOOST_EVENT_CALL_STOPPED_ACK,
+					  0);
 
 
 }
 
-static void handle_call_start(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_start(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	switch_core_session_t *session = NULL;
 	switch_channel_t *channel = NULL;
 	char name[128];
 
 	if (*ss7boost_handle->span_chanmap[event->span].map[event->chan]) {
-		isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_NACK, SIGBOOST_RELEASE_CAUSE_BUSY);
+		isup_exec_command(ss7boost_handle,
+						  event->span, 
+						  event->chan, 
+						  -1,
+						  SIGBOOST_EVENT_CALL_START_NACK,
+						  SIGBOOST_RELEASE_CAUSE_BUSY);		
 		return;
 	}
 
-
+	
 	if ((session = switch_core_session_request(&wanpipe_endpoint_interface, NULL))) {
 		private_object_t *tech_pvt;
 
@@ -1758,7 +1796,7 @@
 			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, "wanpipe/ss7boost/s%dc%d", event->span + 1, event->chan + 1);
+			sprintf(name, "wanpipe/ss7boost/s%dc%d", event->span+1, event->chan+1);
 			switch_channel_set_name(channel, name);
 			tech_pvt->session = session;
 		} else {
@@ -1768,13 +1806,21 @@
 
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-																  NULL, globals.dialplan, "FreeSWITCH(boost)", (char *) event->calling_number_digits,
+																  NULL,
+																  globals.dialplan,
+																  "FreeSWITCH(boost)",
+																  (char *)event->calling_number_digits,
 #ifdef WIN32
 																  NULL,
 #else
-																  (char *) event->calling_number_digits,
+																  (char *)event->calling_number_digits,
 #endif
-																  NULL, NULL, NULL, (char *) modname, NULL, (char *) event->called_number_digits))) {
+																  NULL,
+																  NULL,
+																  NULL,
+																  (char *)modname,
+																  NULL,
+																  (char *)event->called_number_digits))) {
 			switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 		}
 
@@ -1786,73 +1832,88 @@
 		tech_pvt->boost_span_number = event->span;
 		tech_pvt->boost_chan_number = event->chan;
 		tech_pvt->boost_pres = event->calling_number_presentation;
-
-		if (!wp_open(tech_pvt, event->span + 1, event->chan + 1)) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span + 1, event->chan + 1);
+		
+		if (!wp_open(tech_pvt, event->span+1, event->chan+1)) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open channel %d:%d\n", event->span+1, event->chan+1);
 			goto fail;
 		}
 
-		switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
-						   switch_core_session_get_uuid(session), sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
-
+		switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan], switch_core_session_get_uuid(session), 
+						   sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
+		
 		switch_channel_set_state(channel, CS_INIT);
-		isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_START_ACK, 0);
+		isup_exec_command(ss7boost_handle,
+						  event->span, 
+						  event->chan, 
+						  -1,
+						  SIGBOOST_EVENT_CALL_START_ACK,
+						  0);
 		switch_core_session_thread_launch(session);
 		return;
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n");
 	}
 
-
-  fail:
+	
+ fail:
 	if (session) {
 		switch_core_session_destroy(&session);
 	}
 
-	isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_CALL_STOPPED, SIGBOOST_RELEASE_CAUSE_BUSY);
+	isup_exec_command(ss7boost_handle,
+					  event->span, 
+					  event->chan, 
+					  -1,
+					  SIGBOOST_EVENT_CALL_STOPPED,
+					  SIGBOOST_RELEASE_CAUSE_BUSY);
 
 }
 
 
-static void handle_heartbeat(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_heartbeat(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Heartbeat!\n");
 
-	isup_exec_command(ss7boost_handle, event->span, event->chan, -1, SIGBOOST_EVENT_HEARTBEAT, 0);
+	isup_exec_command(ss7boost_handle,
+					  event->span, 
+					  event->chan, 
+					  -1,
+					  SIGBOOST_EVENT_HEARTBEAT,
+					  0);
 }
 
 
-static void handle_call_start_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_start_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	char *uuid = ss7boost_handle->setup_array[event->call_setup_id];
-
+	
 	if (*uuid) {
 		switch_core_session_t *session;
 
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-
+	
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
-
+			
 			tech_pvt = switch_core_session_get_private(session);
 			assert(tech_pvt != NULL);
-
+			
 			tech_pvt->ss7boost_handle = ss7boost_handle;
 			tech_pvt->boost_span_number = event->span;
 			tech_pvt->boost_chan_number = event->chan;
-
-			switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan],
-							   switch_core_session_get_uuid(session), sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
+			
+			switch_copy_string(ss7boost_handle->span_chanmap[event->span].map[event->chan], switch_core_session_get_uuid(session), 
+							   sizeof(ss7boost_handle->span_chanmap[event->span].map[event->chan]));
 
 
 
 			if (!tech_pvt->wpsock) {
-				if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
-									  tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1, strerror(errno));
+				if (!wp_open(tech_pvt, tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", 
+									  tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1, strerror(errno));
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return;
 				}
@@ -1863,29 +1924,29 @@
 			}
 
 			switch_channel_mark_pre_answered(channel);
-
+			
 			switch_core_session_rwunlock(session);
 		}
 		*uuid = '\0';
 	}
 }
 
-static void handle_call_start_nack_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_start_nack_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	// WTF IS THIS! ?
 }
 
-static void handle_call_answer(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_answer(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	char *uuid = ss7boost_handle->span_chanmap[event->span].map[event->chan];
 
 	if (*uuid) {
 		switch_core_session_t *session;
-
+		
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-
+	
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
 
@@ -1893,9 +1954,9 @@
 			assert(tech_pvt != NULL);
 
 			if (!tech_pvt->wpsock) {
-				if (!wp_open(tech_pvt, tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n",
-									  tech_pvt->boost_span_number + 1, tech_pvt->boost_chan_number + 1, strerror(errno));
+				if (!wp_open(tech_pvt, tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open fd for s%dc%d! [%s]\n", 
+									  tech_pvt->boost_span_number+1, tech_pvt->boost_chan_number+1, strerror(errno));
 					switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					return;
 				}
@@ -1904,7 +1965,7 @@
 					return;
 				}
 			}
-
+			
 			switch_channel_mark_answered(channel);
 			switch_core_session_rwunlock(session);
 		} else {
@@ -1917,36 +1978,41 @@
 	}
 }
 
-static void handle_call_stop_ack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_stop_ack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	// TODO anything here?
 }
 
 
-static void handle_call_start_nack(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static void handle_call_start_nack(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	char *uuid = ss7boost_handle->setup_array[event->call_setup_id];
-
+	
 	if (*uuid) {
 		switch_core_session_t *session;
 
 		if ((session = switch_core_session_locate(uuid))) {
 			private_object_t *tech_pvt;
 			switch_channel_t *channel;
-
+	
 			channel = switch_core_session_get_channel(session);
 			assert(channel != NULL);
-
+			
 			tech_pvt = switch_core_session_get_private(session);
 			assert(tech_pvt != NULL);
-
+			
 			tech_pvt->ss7boost_handle = ss7boost_handle;
 			tech_pvt->boost_span_number = event->span;
 			tech_pvt->boost_chan_number = event->chan;
-
+			
 			switch_channel_hangup(channel, event->release_cause);
-
-			isup_exec_command(ss7boost_handle, event->span, event->chan, event->call_setup_id, SIGBOOST_EVENT_CALL_START_NACK_ACK, 0);
+			
+			isup_exec_command(ss7boost_handle,
+							  event->span,
+							  event->chan, 
+							  event->call_setup_id,
+							  SIGBOOST_EVENT_CALL_START_NACK_ACK,
+							  0);
 
 			switch_core_session_rwunlock(session);
 		} else {
@@ -1956,14 +2022,14 @@
 	}
 }
 
-static int parse_ss7_event(ss7boost_handle_t * ss7boost_handle, ss7boost_client_event_t * event)
+static int parse_ss7_event(ss7boost_handle_t *ss7boost_handle, ss7boost_client_event_t *event)
 {
 	int ret = 0;
 
 	switch_mutex_lock(ss7boost_handle->mutex);
-
-	validate_number((unsigned char *) event->called_number_digits);
-	validate_number((unsigned char *) event->calling_number_digits);
+		
+	validate_number((unsigned char*)event->called_number_digits);
+	validate_number((unsigned char*)event->calling_number_digits);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 					  "\nRX EVENT\n"
@@ -1982,16 +2048,21 @@
 					  "\n",
 					  ss7boost_client_event_id_name(event->event_id),
 					  event->event_id,
-					  event->span + 1,
-					  event->chan + 1,
+					  event->span+1,
+					  event->chan+1,
 					  (event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
 					  (event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
-					  switch_channel_cause2str(event->release_cause), event->span + 1, event->chan + 1, event->event_id, event->call_setup_id,
-					  event->seqno);
-
-
-	switch (event->event_id) {
+					  switch_channel_cause2str(event->release_cause),
+					  event->span+1,
+					  event->chan+1,
+					  event->event_id,
+					  event->call_setup_id,
+					  event->seqno
+					  );
+	
 
+	switch(event->event_id) {
+	
 	case SIGBOOST_EVENT_CALL_START:
 		handle_call_start(ss7boost_handle, event);
 		break;
@@ -2017,7 +2088,7 @@
 		handle_call_stop_ack(ss7boost_handle, event);
 		break;
 	default:
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n",
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Warning no handler implemented for [%s]\n", 
 						  ss7boost_client_event_id_name(event->event_id));
 		break;
 	}
@@ -2025,40 +2096,48 @@
 	return ret;
 }
 
-static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t * thread, void *obj)
+static void *SWITCH_THREAD_FUNC boost_thread_run(switch_thread_t *thread, void *obj)
 {
 	ss7boost_handle_t *ss7boost_handle = (ss7boost_handle_t *) obj;
 	ss7boost_client_event_t *event;
 
 	if (ss7boost_client_connection_open(&ss7boost_handle->mcon,
-										ss7boost_handle->local_ip,
-										ss7boost_handle->local_port,
-										ss7boost_handle->remote_ip, ss7boost_handle->remote_port, module_pool) != SWITCH_STATUS_SUCCESS) {
+									ss7boost_handle->local_ip, 
+									ss7boost_handle->local_port,
+									ss7boost_handle->remote_ip,
+									ss7boost_handle->remote_port,
+									module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FATAL ERROR CREATING CLIENT CONNECTION\n");
 		return NULL;
 	}
-
-	isup_exec_command(ss7boost_handle, 0, 0, -1, SIGBOOST_EVENT_SYSTEM_RESTART, 0);
-
-
+			
+	isup_exec_command(ss7boost_handle,
+					  0,
+					  0, 
+					  -1,
+					  SIGBOOST_EVENT_SYSTEM_RESTART,
+					  0);
+	
+	
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Started\n");
-
+	
 	switch_mutex_lock(globals.hash_mutex);
 	globals.configured_boost_spans++;
 	switch_mutex_unlock(globals.hash_mutex);
 
 	globals.ss7boost_handle = ss7boost_handle;
-
-	for (;;) {
+	
+	for(;;) {
 		if (ss7boost_client_connection_read(&ss7boost_handle->mcon, &event) == SWITCH_STATUS_SUCCESS) {
-			struct timeval current;
-			struct timeval difftime;
-			gettimeofday(&current, NULL);
-			timersub(&current, &event->tv, &difftime);
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket Event [%s] T=%d:%d\n",
-							  ss7boost_client_event_id_name(event->event_id), (int) difftime.tv_sec, (int) difftime.tv_usec);
-
-			parse_ss7_event(ss7boost_handle, event);
+				struct timeval current;
+				struct timeval difftime;
+				gettimeofday(&current,NULL);
+				timersub (&current, &event->tv, &difftime);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket Event [%s] T=%d:%d\n",
+								  ss7boost_client_event_id_name(event->event_id),
+								  (int)difftime.tv_sec, (int)difftime.tv_usec);
+				
+				parse_ss7_event(ss7boost_handle, event);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: Reading from Boost Socket! %s\n", strerror(errno));
 			break;
@@ -2067,17 +2146,17 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Close udp socket\n");
 	ss7boost_client_connection_close(&ss7boost_handle->mcon);
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Ended\n");
-
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Monitor Thread Ended\n");	
+	
 
 	return NULL;
 }
 
-static void launch_ss7boost_handle(ss7boost_handle_t * ss7boost_handle)
+static void launch_ss7boost_handle(ss7boost_handle_t *ss7boost_handle)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
-
+	
 	switch_threadattr_create(&thd_attr, module_pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -2134,7 +2213,7 @@
 		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 (!strcasecmp(var, "local-ip")) {
 				local_ip = val;
 			} else if (!strcasecmp(var, "local-port")) {
@@ -2165,7 +2244,7 @@
 	}
 
 	analog_channels = switch_xml_child(cfg, "analog_channels");
-	for (channel = switch_xml_child(analog_channels, "channel"); channel; channel = channel->next) {
+	for(channel = switch_xml_child(analog_channels, "channel"); channel; channel = channel->next) {
 		char *c_type = (char *) switch_xml_attr(channel, "type");
 		char *c_dev = (char *) switch_xml_attr(channel, "device");
 		char *user = NULL;
@@ -2175,7 +2254,7 @@
 		analog_type_t a_type = ANALOG_TYPE_UNKNOWN;
 		wpsock_t *sock;
 		int chan, span;
-
+		
 		if (!c_type) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required attribute 'type'\n");
 			continue;
@@ -2199,16 +2278,16 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid device name '%s'\n", c_dev);
 			continue;
 		}
-
+		
 		if (!(sock = wp_open(NULL, span, chan))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev, strerror(errno));
 			continue;
 		}
 
 		for (param = switch_xml_child(channel, "param"); param; param = param->next) {
-			char *var = (char *) switch_xml_attr_soft(param, "name");
-			char *val = (char *) switch_xml_attr_soft(param, "value");
-
+            char *var = (char *) switch_xml_attr_soft(param, "name");
+            char *val = (char *) switch_xml_attr_soft(param, "value");
+			
 			if (!strcasecmp(var, "user")) {
 				user = var;
 			} else if (!strcasecmp(var, "domain")) {
@@ -2234,7 +2313,7 @@
 		if (cid_num) {
 			alc->cid_name = strdup(cid_num);
 		}
-
+		
 		alc->a_type = a_type;
 		alc->sock = sock;
 		alc->chan = chan;
@@ -2251,7 +2330,7 @@
 	if (globals.fxs_index) {
 		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);
@@ -2266,10 +2345,10 @@
 		int32_t i = 0;
 
 		current_span = 0;
-
+		
 		if (id) {
 			char *p;
-
+			
 			min_span = atoi(id);
 			if ((p = strchr(id, '-'))) {
 				p++;
@@ -2285,16 +2364,16 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing SPAN ID!\n");
 			continue;
 		}
-
+		
 		for (i = min_span; i <= max_span; i++) {
 			current_span = i;
-
+			
 			if (current_span <= 0 || current_span > MAX_SPANS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN %d!\n", current_span);
 				current_span = 0;
 				continue;
 			}
-
+			
 			if (!SPANS[current_span]) {
 				if (!(SPANS[current_span] = switch_core_alloc(module_pool, sizeof(*SPANS[current_span])))) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
@@ -2302,12 +2381,12 @@
 				}
 				SPANS[current_span]->span = current_span;
 			}
-
+			
 
 			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, "dchan")) {
 					SPANS[current_span]->dchan = atoi(val);
 				} else if (!strcmp(var, "bchan")) {
@@ -2320,7 +2399,7 @@
 						fromi = atoi(from);
 						toi = atoi(to);
 						if (fromi > 0 && toi > 0 && fromi < toi && fromi < MAX_SPANS && toi < MAX_SPANS) {
-							for (x = fromi; x <= toi; x++) {
+							for(x = fromi; x <= toi; x++) {
 								SPANS[current_span]->bchans |= (1 << x);
 							}
 						} else {
@@ -2354,14 +2433,18 @@
 
 
 	globals.configured_spans = 0;
-	for (current_span = 1; current_span < MAX_SPANS; current_span++) {
+	for(current_span = 1; current_span < MAX_SPANS; current_span++) {
 		if (SPANS[current_span]) {
 
 			if (!SPANS[current_span]->l1) {
 				SPANS[current_span]->l1 = PRI_LAYER_1_ULAW;
 			}
 			if (sangoma_init_pri(&SPANS[current_span]->spri,
-								 current_span, SPANS[current_span]->dchan, SPANS[current_span]->pswitch, SPANS[current_span]->node, globals.debug)) {
+								 current_span,
+								 SPANS[current_span]->dchan,
+								 SPANS[current_span]->pswitch,
+								 SPANS[current_span]->node,
+								 globals.debug)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot launch span %d\n", current_span);
 				continue;
 			}
@@ -2378,3 +2461,6 @@
 	return SWITCH_STATUS_SUCCESS;
 
 }
+
+
+

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/basecdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the BaseCDR class that all other CDR classes inherit from.
  * It handles the bulk of the processing of data from the switch_channel_t objects.
@@ -214,7 +215,7 @@
 		{
 			if(fixed)
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"Wildcards are not allow in the fixed chanvars list.  Item removed.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Wildcards are not allow in the fixed chanvars list.  Item removed.\n");
 				iItr = chanvarlist.erase(iItr);
 			}
 			else
@@ -271,19 +272,19 @@
 						sql_type = CDR_TINY;
 						break;
 					default:
-						switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string).  You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str());
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string).  You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n", tempstring2.c_str(), tempstring.c_str());
 						sql_type = CDR_STRING;
 				}
 			}
 			else
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string).  You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str());
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string).  You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n", tempstring2.c_str(), tempstring.c_str());
 				sql_type = CDR_STRING;
 			}
 		}
 		else
 		{
-			switch_console_printf(SWITCH_CHANNEL_LOG,"No parameter set, for channel variable %s, using default type of string.\n",iItr->c_str());
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No parameter set, for channel variable %s, using default type of string.\n", iItr->c_str());
 			sql_type = CDR_STRING;
 			tempstring = *iItr;
 		}

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/cdrcontainer.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the CDRContainer singleton object used by mod_cdr to control
  * the creation, processing, and destruction of various CDR logger objects.
@@ -53,7 +54,7 @@
 	newchannel = 0;
 	
 	if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL))) 
-		switch_console_printf(SWITCH_CHANNEL_LOG,"open of %s failed\n", configfile);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", configfile);
 	else
 	{	
 		BaseRegistry& registry(BaseRegistry::get());
@@ -89,7 +90,7 @@
 		ptr->disconnect();
 	}
 		
-	switch_console_printf(SWITCH_CHANNEL_LOG,"mod_cdr shutdown gracefully.");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_cdr shutdown gracefully.");
 }
 
 #ifdef SWITCH_QUEUE_ENHANCED
@@ -225,7 +226,7 @@
 			basecdr_creator func = *it;
 			
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_LOG,"Adding a new logger object to the queue.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 		}
 		newchannel->callerprofile = newchannel->callerprofile->next;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/csvcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/csvcdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/csvcdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the CsvCDR class that handles processing CDRs to a CSV format.
  * This is the standard CSV module, and has a list of predefined variables to log out which can be
@@ -101,7 +102,7 @@
 
 void CsvCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_LOG, "CsvCDR::connect() - Loading configuration file.\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CsvCDR::connect() - Loading configuration file.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	
@@ -170,7 +171,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -182,11 +183,11 @@
 			if(outputfile.good())
 			{
 				activated = 1;
-				switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR activated, log rotation will occur at or after %d MB\n",(int)(filesize_limit >> 20));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CsvCDR activated, log rotation will occur at or after %d MB\n", (int)(filesize_limit >> 20));
 			}
 		}
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CsvCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
 	}
 }
 
@@ -228,7 +229,7 @@
 	outputfile.open(filename.c_str(),std::ios_base::app|std::ios_base::binary);
 	if(outputfile.fail())
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Could not open the CSV file %s .  CsvCDR logger will not be functional until this is resolved and a reload is issued.  Failbit is set to %d.\n",filename.c_str(),outputfile.fail());
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open the CSV file %s .  CsvCDR logger will not be functional until this is resolved and a reload is issued.  Failbit is set to %d.\n", filename.c_str(), outputfile.fail());
 		activated = 0;
 	}
 	else
@@ -332,7 +333,7 @@
 	chanvars_fixed_list.clear();
 	chanvars_supp_list.clear();
 	connectionstate = 0;
-	switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CsvCDR...  Done!\n");	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down CsvCDR...  Done!\n");	
 }
 
 AUTO_REGISTER_BASECDR(CsvCDR);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/curlcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/curlcdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/curlcdr.cpp	Fri Apr 13 10:44:28 2007
@@ -28,6 +28,7 @@
  * Yossi Neiman <freeswitch AT cartissolutions.com>
  * Bret McDanel <trixter AT 0xdecafbad.com>
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the CurlCDR class that handles processing CDRs to HTTP endpoint.
  * This is the standard Curl module, and has a list of predefined variables to log out which can be
@@ -106,14 +107,14 @@
 
 void CurlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_LOG, "CurlCDR::connect() - Loading configuration file.\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CurlCDR::connect() - Loading configuration file.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 
-    switch_console_printf(SWITCH_CHANNEL_LOG,"Checking to see if curlcdr is valid\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking to see if curlcdr is valid\n");
 	if ((settings = switch_xml_child(cfg, "curlcdr"))) 
 	{
-        switch_console_printf(SWITCH_CHANNEL_LOG,"curlcdr appears to be!!!\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "curlcdr appears to be!!!\n");
 		int count_config_params = 0;  // Need to make sure all params are set before we load
 		for (param = switch_xml_child(settings, "param"); param; param = param->next) 
 		{
@@ -168,7 +169,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -179,13 +180,13 @@
             if(strlen(gateway_url))
 			{
 				activated = 1;
-				switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR activated");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CurlCDR activated");
 			}
             else
-                switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR::connect(): You must specify a gateway_url to have the records logged to.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CurlCDR::connect(): You must specify a gateway_url to have the records logged to.\n");
 		}
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"CurlCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a gateway_url to have the records logged to.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CurlCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a gateway_url to have the records logged to.\n");
 	}
 }
 
@@ -370,7 +371,7 @@
 	chanvars_fixed_list.clear();
 	chanvars_supp_list.clear();
 	connectionstate = 0;
-	switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CurlCDR...  Done!");	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down CurlCDR...  Done!");	
 }
 
 AUTO_REGISTER_BASECDR(CurlCDR);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mod_cdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mod_cdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This source file describes the most basic portions of the CDR module.  These are the functions
  * and structures that the Freeswitch core looks for when opening up the DSO file to create the load, shutdown
@@ -130,7 +131,7 @@
 	
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) 
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG, "OH OH - Can't swim, no pool\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH - Can't swim, no pool\n");
 		return SWITCH_STATUS_TERM;
 	}
 
@@ -144,7 +145,7 @@
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	RUNNING = 1;
-	switch_console_printf(SWITCH_CHANNEL_LOG, "mod_cdr made it to runtime.  Wee!\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mod_cdr made it to runtime.  Wee!\n");
 	newcdrcontainer->process_records();
 	
 	return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the MysqlCDR class which handles formatting a CDR out to
  * a MySQL 4.1.x or greater server using prepared statements.
@@ -183,7 +184,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -192,7 +193,7 @@
 		if (count_config_params==4)
 			activated = 1;
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module.  You must specify a hostname, username, password, and database to use MysqlCDR.  You only supplied %d parameters.\n",count_config_params);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You did not specify the minimum parameters for using this module.  You must specify a hostname, username, password, and database to use MysqlCDR.  You only supplied %d parameters.\n", count_config_params);
 		
 		if(activated)
 		{
@@ -241,7 +242,7 @@
 	if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL)
 	{
 		const char *error1 = mysql_error(conn);
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Cannot connect to MySQL Server.  The error was: %s\n",error1);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot connect to MySQL Server.  The error was: %s\n", error1);
 	}
 	else
 		connectionstate = 1;
@@ -446,7 +447,7 @@
 					break;
 				}
 				default:
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
 			}
 			i++;
 		}
@@ -466,13 +467,13 @@
 				case CR_SERVER_GONE_ERROR:
 				case CR_SERVER_LOST:
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We lost connection to the MySQL server.  Trying to reconnect.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We lost connection to the MySQL server.  Trying to reconnect.\n");
 					connect_to_database();
 					break;
 				}
 				default:
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We have encountered an unknown error when pinging the MySQL server.  Attempting to reconnect anyways.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We have encountered an unknown error when pinging the MySQL server.  Attempting to reconnect anyways.\n");
 					connect_to_database();
 				}
 			}
@@ -485,10 +486,10 @@
 			if(mysql_stmt_error_code != 0)
 			{
 				errorstate = 1;
-				switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",mysql_stmt_error_code);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MysqlCDR::process_record() - Statement executed? Error: %d\n", mysql_stmt_error_code);
 			
 				const char* mysql_stmt_error_string = mysql_stmt_error(stmt);
-				switch_console_printf(SWITCH_CHANNEL_LOG,"MySQL encountered error: %s\n",mysql_stmt_error_string);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MySQL encountered error: %s\n", mysql_stmt_error_string);
 			}
 			else
 				errorstate = 0;
@@ -585,7 +586,7 @@
 					break;
 				}
 				default:
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
 			}
 			
 			bool* tempbool = (bool*) temp_chanvars_holder.front();

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/odbccdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/odbccdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/odbccdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the OdbcCDR class which handles formatting a CDR out to
  * an ODBC backend using prepared statements.
@@ -201,7 +202,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -216,7 +217,7 @@
 		if (count_config_params==4)
 			activated = 1;
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module.  You must specify a DSN,hostname, username, password, and database to use OdbcCDR.  You only supplied %d parameters.\n",count_config_params);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You did not specify the minimum parameters for using this module.  You must specify a DSN,hostname, username, password, and database to use OdbcCDR.  You only supplied %d parameters.\n", count_config_params);
 		
 		if(activated)
 		{
@@ -275,7 +276,7 @@
 		ODBC_res = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &ODBC_env);
 		if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) 
 		{
-			switch_console_printf(SWITCH_CHANNEL_LOG,"Error allocating a new ODBC handle.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating a new ODBC handle.\n");
 			connectionstate = 0;
 		}
 	}
@@ -284,7 +285,7 @@
 	
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) 
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Error with ODBCSetEnv\n");
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error with ODBCSetEnv\n");
 		SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 		connectionstate = 0;
 	}
@@ -293,7 +294,7 @@
 
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Error AllocHDB %d\n",ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error AllocHDB %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 		connectionstate = 0;
 	}
@@ -306,14 +307,14 @@
 	ODBC_res = SQLConnect(ODBC_con, (SQLCHAR*)dsn, SQL_NTS, (SQLCHAR*)username, SQL_NTS, (SQLCHAR*)password, SQL_NTS);
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) 
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Error connecting to the ODBC database on %d\n",ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error connecting to the ODBC database on %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con);
 		SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
 		connectionstate = 0;
 	}
 	else 
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Connected to %s\n", dsn);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to %s\n", dsn);
 		connectionstate = 1;
 	}
 	
@@ -325,7 +326,7 @@
 
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 	}
 		
@@ -333,7 +334,7 @@
 
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 	}
 		
@@ -343,7 +344,7 @@
 
 		if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 		{
-			switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
 			SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_chanvars);
 		}
 		
@@ -351,7 +352,7 @@
 
 		if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 		{
-			switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
 			SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
 		}
 	}
@@ -360,7 +361,7 @@
 	
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Failure in allocating a prepared statement %d\n", ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure in allocating a prepared statement %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping);
 	}
 	
@@ -368,7 +369,7 @@
 	
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO))
 	{
-		switch_console_printf(SWITCH_CHANNEL_LOG,"Error in preparing a statement: %d\n", ODBC_res);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in preparing a statement: %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt_ping);
 	}
 	
@@ -400,7 +401,7 @@
 		if(ODBC_res != SQL_SUCCESS && ODBC_res != SQL_SUCCESS_WITH_INFO)
 		{
 			// Try to reconnect and reprepare
-			switch_console_printf(SWITCH_CHANNEL_LOG,"Error pinging the ODBC backend.  Attempt #%d to reconnect.\n",count+1);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error pinging the ODBC backend.  Attempt #%d to reconnect.\n", count+1);
 			connect_to_database();
 		}
 	}
@@ -502,7 +503,7 @@
 					break;
 				}
 				default:
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
 			}
 			i++;
 		}
@@ -585,7 +586,7 @@
 					break;
 				}
 				default:
-					switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "We should not get to this point in this switch/case statement.\n");
 			}
 		}
 	}

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/pddcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/pddcdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/pddcdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: This C++ source file describes the PddCDR class which handles formatting a CDR out to
  * individual text files in a Perl Data Dumper format.
@@ -101,7 +102,7 @@
 
 void PddCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_LOG, "PddCDR::connect() - Loading configuration file.\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PddCDR::connect() - Loading configuration file.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	
@@ -135,11 +136,11 @@
 			}
 			else if (!strcmp(var, "chanvars_fixed"))
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
 			}
 			else if (!strcmp(var, "chanvars_supp"))
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PddCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
 			}
 			else if(!strcmp(var,"timezone"))
 			{
@@ -149,7 +150,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+				 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -158,7 +159,7 @@
 		if(count_config_params > 0)
 			activated = 1;
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"PddCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PddCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
 	}
 }
 
@@ -168,7 +169,7 @@
 	
 	bool retval = 0;
 	if(!outputfile)
-		switch_console_printf(SWITCH_CHANNEL_LOG, "PddCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PddCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
 	else
 	{
 		// Format the call record and proceed from here...
@@ -247,7 +248,7 @@
 	logchanvars = 0;
 	outputfile_path.clear();
 	chanvars_supp_list.clear();
-	switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down PddCDR...  Done!");	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down PddCDR...  Done!");	
 }
 
 AUTO_REGISTER_BASECDR(PddCDR);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp	Fri Apr 13 10:44:28 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  * Description: his C++ header file describes the SqliteCDR class which handles formatting a CDR out to
  * a SQLite database using prepared statements.
@@ -141,7 +142,7 @@
 					use_utc_time = 0;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					use_utc_time = 0;
 				}
 			}
@@ -150,7 +151,7 @@
 		if (count_config_params==1)
 			activated = 1;
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"You did not specify the minimum parameters for using this module.  You must specify an explicit (complete) path to the location of the database file in order to use SqliteCDR.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You did not specify the minimum parameters for using this module.  You must specify an explicit (complete) path to the location of the database file in order to use SqliteCDR.\n");
 		
 		if(activated)
 		{
@@ -192,7 +193,7 @@
 			
 			if(sql_rc != SWITCH_CORE_DB_OK)
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error opening database filename %s.  The error was: %s.  SqliteCDR logging has been disabled until the problem is resolved and modcdr_reload is initiated.\n",db_filename.c_str(),switch_core_db_errmsg(db));
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error opening database filename %s.  The error was: %s.  SqliteCDR logging has been disabled until the problem is resolved and modcdr_reload is initiated.\n", db_filename.c_str(), switch_core_db_errmsg(db));
 				activated = 0;
 				switch_core_db_close(db);
 			}
@@ -223,13 +224,13 @@
 					}
 				}
 				else
-					switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error in executing query %s: The error was %s.\n",sql_query_check_tables,errormessage);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error in executing query %s: The error was %s.\n", sql_query_check_tables, errormessage);
 				
 				switch_core_db_free_table(result);
 			
 				if(!temp_sql_tables["freeswitchcdr"])
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
 					// Must create the missing freeswitchcdr table.
 					char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n"
 						"callid INTEGER PRIMARY KEY AUTOINCREMENT,\n"
@@ -262,7 +263,7 @@
 			
 				if(!temp_sql_tables["chanvars"])
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the chanvars table in the SQLite mod_cdr database file.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating the chanvars table in the SQLite mod_cdr database file.\n");
 					// Must create the missing chanvars table.
 					char sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
 						"callid INTEGER default 0,\n"
@@ -321,13 +322,13 @@
 										tempstring2 = resultstring.substr(i,(j-i));
 								
 									freeswitchcdr_columns[tempstring1] = tempstring2;
-									// switch_console_printf(SWITCH_CHANNEL_LOG,"tempstring1 = %s, tempstring2 = %s\n",tempstring1.c_str(),tempstring2.c_str());
+									//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tempstring1 = %s, tempstring2 = %s\n", tempstring1.c_str(), tempstring2.c_str());
 									if(resultstring.find('\n',j+1) == (j+1))
 										j++;
 									i = j+1;
 								}
 								else
-									switch_console_printf(SWITCH_CHANNEL_LOG,"There has been a parsing problem with the freeswitchcdr schema.\n");
+									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There has been a parsing problem with the freeswitchcdr schema.\n");
 							}
 						}
 					}
@@ -346,9 +347,9 @@
 							case CDR_TINY:
 								if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
 								{
-									//switch_console_printf(SWITCH_CHANNEL_LOG,"freeswitchcdr_columns[%s] == %s.\n",iItr->c_str(),freeswitchcdr_columns[*iItr].c_str());
+									//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "freeswitchcdr_columns[%s] == %s.\n", iItr->c_str(), freeswitchcdr_columns[*iItr].c_str());
 									if(freeswitchcdr_columns[*iItr].find("INTEGER",0) == std::string::npos)
-										switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type.  This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+										switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type.  This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
 								}
 								else
 									freeswitchcdr_add_columns[*iItr] = "INTEGER";
@@ -357,7 +358,7 @@
 								if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
 								{
 									if(freeswitchcdr_columns[*iItr].find("REAL",0) == std::string::npos)
-										switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type.  This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+										switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type.  This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
 								}
 								else
 									freeswitchcdr_add_columns[*iItr] = "REAL";
@@ -367,19 +368,19 @@
 								if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
 								{
 									if(freeswitchcdr_columns[*iItr].find("TEXT",0) == std::string::npos)
-										switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type.  This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+										switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type.  This is not necessarily fatal, but may result in unexpected behavior.\n", iItr->c_str());
 								}
 								else
 									freeswitchcdr_add_columns[*iItr] = "TEXT";
 								break;
 							default:
-								switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement.  Please notify the author.\n");
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oh bother, I should not have fallen into this hole in the switch/case statement.  Please notify the author.\n");
 						}
 					}
 					
 					if(freeswitchcdr_add_columns.size())
 					{
-						switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table schema.\n");
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Updating the freeswitchcdr table schema.\n");
 						std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswitchcdr ADD ";
 						std::map<std::string, std::string>::iterator iItr, iEnd;
 						for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++)
@@ -388,7 +389,7 @@
 							sql_query_freeswitchcdr_alter_table.append(iItr->first);
 							sql_query_freeswitchcdr_alter_table.append(" ");
 							sql_query_freeswitchcdr_alter_table.append(iItr->second);
-							switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table with the following SQL command: %s.\n",sql_query_freeswitchcdr_alter_table.c_str());
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Updating the freeswitchcdr table with the following SQL command: %s.\n", sql_query_freeswitchcdr_alter_table.c_str());
 							switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL);
 						}
 					}
@@ -514,7 +515,7 @@
 					break;
 				}
 				default:
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement.  Please notify the author.\n");
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oh bother, I should not have fallen into this hole in the switch/case statement.  Please notify the author.\n");
 			}
 		}
 	}
@@ -525,7 +526,7 @@
 		if(sql_rc == SWITCH_CORE_DB_BUSY)
 			sql_rc = switch_core_db_step(stmt);
 		else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE)
-			switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt.  The error was: %s\n",switch_core_db_errmsg(db));
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error executing switch_core_db_step on SqliteCDR::stmt.  The error was: %s\n", switch_core_db_errmsg(db));
 	}
 	
 	sql_rc = switch_core_db_reset(stmt);
@@ -546,7 +547,7 @@
 				if(sql_rc == SWITCH_CORE_DB_BUSY)
 					sql_rc = switch_core_db_step(stmt_chanvars);
 				else if (sql_rc == SWITCH_CORE_DB_ERROR || sql_rc == SWITCH_CORE_DB_MISUSE)
-					switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars.  The error was: %s\n",switch_core_db_errmsg(db));
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars.  The error was: %s\n", switch_core_db_errmsg(db));
 			}
 			
 			switch_core_db_reset(stmt_chanvars);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/xmlcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/xmlcdr.cpp	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/xmlcdr.cpp	Fri Apr 13 10:44:28 2007
@@ -25,6 +25,7 @@
  * 
  * Yossi Neiman <freeswitch AT cartissolutions.com>
  * Ken Rice of Asteria Solutions Group, INC <ken AT asteriasgi.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  * 
  * Description: This C++ source file describes the XmlCDR class which handles formatting a CDR out to
  * individual text files in a XML format.
@@ -103,7 +104,7 @@
 
 void XmlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::connect() - Loading configuration file.\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::connect() - Loading configuration file.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	
@@ -137,11 +138,11 @@
 			}
 			else if (!strcmp(var, "chanvars_fixed"))
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
 			}
 			else if (!strcmp(var, "chanvars_supp"))
 			{
-				switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XmlCDR has no need for a fixed or supplemental list of channel variables due to the nature of the format.  Please use the setting parameter of \"chanvars\" instead and try again.\n");
 			}
 			else if(!strcmp(var,"timezone"))
 			{
@@ -151,7 +152,7 @@
 					convert_time = switch_time_exp_lt;
 				else
 				{
-					switch_console_printf(SWITCH_CHANNEL_LOG,"Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n",val);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid configuration parameter for timezone.  Possible values are utc and local.  You entered: %s\nDefaulting to local.\n", val);
 					convert_time = switch_time_exp_lt;
 				}
 			}
@@ -160,7 +161,7 @@
 		if(count_config_params > 0)
 			activated = 1;
 		else
-			switch_console_printf(SWITCH_CHANNEL_LOG,"XmlCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XmlCDR::connect(): You did not specify the minimum parameters for using this module.  You must specify at least a path to have the records logged to.\n");
 	}
 }
 
@@ -170,10 +171,10 @@
 	outputfile.open(outputfile_name.c_str());
 	
 	if(!outputfile)
-		switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XmlCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n", outputfile_name.c_str());
 	else
 	{
-		//switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record():  Preping the CDR to %s.\n",outputfile_name.c_str());
+		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::process_record():  Preping the CDR to %s.\n", outputfile_name.c_str());
 		// Format the call record and proceed from here...
 		outputfile << "<?xml version=\"1.0\"?>" << std::endl;
 		outputfile << "<document type=\"freeswitch-cdr/xml\">" << std::endl;
@@ -215,7 +216,7 @@
 		}
 		outputfile << "\t</chanvars>" << std::endl << "</document>" << std::endl << std::endl;
 
-		//switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record():  Dumping the CDR to %s.\n",outputfile_name.c_str());
+		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "XmlCDR::process_record():  Dumping the CDR to %s.\n", outputfile_name.c_str());
 		retval = 1;
 	}
 	
@@ -249,7 +250,7 @@
 	logchanvars = 0;
 	outputfile_path.clear();
 	chanvars_supp_list.clear();
-	switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down XmlCDR...  Done!");	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down XmlCDR...  Done!");	
 }
 
 AUTO_REGISTER_BASECDR(XmlCDR);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	Fri Apr 13 10:44:28 2007
@@ -117,7 +117,7 @@
 static JSBool db_exec(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
 	struct db_obj *dbo = JS_GetPrivate(cx, obj);
-	*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
+	*rval = INT_TO_JSVAL(0);
 
 	if (argc > 0) {
 		char *sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -137,7 +137,11 @@
 		if (err) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s\n", err);
 			switch_core_db_free(err);
-			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+			*rval = INT_TO_JSVAL(-1);
+		} else {
+			int count = switch_core_db_changes(dbo->db);
+
+			*rval = INT_TO_JSVAL(count);
 		}
 	}
 	return JS_TRUE;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_db.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_db.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_db.c	Fri Apr 13 10:44:28 2007
@@ -142,6 +142,10 @@
 	sqlite3_free(z);
 }
 
+SWITCH_DECLARE(int) switch_core_db_changes(switch_core_db_t *db) {
+    return sqlite3_changes(db);
+}
+
 SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...)
 {
 	va_list ap;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_session.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core_session.c	Fri Apr 13 10:44:28 2007
@@ -599,6 +599,8 @@
 		switch_channel_dequeue_dtmf(channel, buf, sizeof(buf));
 	}
 
+	switch_ivr_deactivate_unicast(session);
+
 	switch_channel_clear_flag(channel, CF_BREAK);
 }
 
@@ -647,6 +649,8 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Close Channel %s\n", switch_channel_get_name((*session)->channel));
 
+	switch_ivr_deactivate_unicast(*session);
+	
 	switch_scheduler_del_task_group((*session)->uuid_str);
 
 	switch_mutex_lock(runtime.session_table_mutex);
@@ -667,6 +671,9 @@
 	switch_channel_uninit((*session)->channel);
 
 	pool = (*session)->pool;
+#ifndef NDEBUG
+	memset(*session, 0, sizeof(switch_core_session_t));
+#endif
 	*session = NULL;
 	apr_pool_destroy(pool);
 	pool = NULL;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c	Fri Apr 13 10:44:28 2007
@@ -80,6 +80,176 @@
 }
 
 
+static void *SWITCH_THREAD_FUNC unicast_thread_run(switch_thread_t *thread, void *obj)
+{
+	switch_unicast_conninfo_t *conninfo = (switch_unicast_conninfo_t *) obj;
+	switch_size_t len;
+	switch_channel_t *channel;
+
+	if (!conninfo) {
+		return NULL;
+	}
+
+	channel = switch_core_session_get_channel(conninfo->session);
+	
+	while(switch_test_flag(conninfo, SUF_READY) && switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
+		len = conninfo->write_frame.buflen;
+		if (switch_socket_recv(conninfo->socket, conninfo->write_frame.data, &len) != SWITCH_STATUS_SUCCESS || len == 0) {
+			break;
+		}
+		conninfo->write_frame.datalen = (uint32_t)len;
+		conninfo->write_frame.samples = conninfo->write_frame.datalen / 2;
+		switch_core_session_write_frame(conninfo->session, &conninfo->write_frame, -1, conninfo->stream_id);
+	}
+	
+	switch_clear_flag_locked(conninfo, SUF_READY);
+	switch_clear_flag_locked(conninfo, SUF_THREAD_RUNNING);
+
+	return NULL;
+}
+
+static void unicast_thread_launch(switch_unicast_conninfo_t *conninfo)
+{
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
+
+	switch_threadattr_create(&thd_attr, switch_core_session_get_pool(conninfo->session));
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_set_flag_locked(conninfo, SUF_THREAD_RUNNING);
+	switch_thread_create(&thread, thd_attr, unicast_thread_run, conninfo, switch_core_session_get_pool(conninfo->session));
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session)
+{
+	switch_channel_t *channel;
+	switch_unicast_conninfo_t *conninfo;
+	int sanity = 0;
+	
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	if (switch_channel_test_flag(channel, CF_UNICAST)) {
+		if ((conninfo = switch_channel_get_private(channel, "unicast"))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down unicast connection\n");
+			switch_clear_flag_locked(conninfo, SUF_READY);
+			switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE);
+			while(switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
+				switch_yield(10000);
+				if (++sanity >= 10000) {
+					break;
+				}
+			}
+			switch_core_codec_destroy(&conninfo->read_codec);
+			switch_socket_close(conninfo->socket);
+		}
+		switch_channel_clear_flag(channel, CF_UNICAST);
+		return SWITCH_STATUS_SUCCESS;
+	}
+	
+	return SWITCH_STATUS_FALSE;
+	
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_t *session, 
+															char *local_ip,
+															switch_port_t local_port,
+															char *remote_ip,
+															switch_port_t remote_port,
+															char *transport)
+{
+	switch_channel_t *channel;
+	switch_unicast_conninfo_t *conninfo;
+	switch_codec_t *read_codec;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
+	assert(conninfo != NULL);
+
+	conninfo->local_ip = switch_core_session_strdup(session, local_ip);
+	conninfo->local_port = local_port;
+
+	conninfo->remote_ip = switch_core_session_strdup(session, remote_ip);
+	conninfo->remote_port = remote_port;
+	conninfo->session = session;
+	
+	if (!strcasecmp(transport, "udp")) {
+		conninfo->type = AF_INET;
+		conninfo->transport = SOCK_DGRAM;
+	} else if (!strcasecmp(transport, "tcp")) {
+		conninfo->type = AF_INET;
+		conninfo->transport = SOCK_STREAM;
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid transport %s\n", transport);
+		goto fail;
+	}
+
+	switch_mutex_init(&conninfo->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+	
+	read_codec = switch_core_session_get_read_codec(session);
+	
+	if (switch_core_codec_init(&conninfo->read_codec,
+							   "L16",
+							   NULL,
+							   read_codec->implementation->samples_per_second,
+							   read_codec->implementation->microseconds_per_frame / 1000,
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+							   NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+						  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
+						  read_codec->implementation->samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
+		goto fail;
+	}
+
+	conninfo->write_frame.data = conninfo->write_frame_data;
+	conninfo->write_frame.buflen = sizeof(conninfo->write_frame_data);
+	conninfo->write_frame.codec = &conninfo->read_codec;
+	
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n",
+					  conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
+
+	if (switch_sockaddr_info_get(&conninfo->local_addr,
+								 conninfo->local_ip, SWITCH_UNSPEC, conninfo->local_port, 0, 
+								 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		goto fail;
+	}
+	
+	if (switch_sockaddr_info_get(&conninfo->remote_addr, 
+								 conninfo->remote_ip, SWITCH_UNSPEC, conninfo->remote_port, 0,
+								 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		goto fail;
+	}
+	
+	if (switch_socket_create(&conninfo->socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+		if (switch_socket_bind(conninfo->socket, conninfo->local_addr) != SWITCH_STATUS_SUCCESS) {
+			goto fail;
+		}
+	} else {
+		goto fail;
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created unicast connection %s:%d->%s:%d\n",
+					  conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
+	switch_channel_set_private(channel, "unicast", conninfo);
+	switch_channel_set_flag(channel, CF_UNICAST);
+	switch_set_flag_locked(conninfo, SUF_READY);
+	return SWITCH_STATUS_SUCCESS;
+
+ fail:
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating unicast connection %s:%d->%s:%d\n",
+					  conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
+	return SWITCH_STATUS_FALSE;	
+
+
+}
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -89,6 +259,7 @@
 	unsigned long CMD_EXECUTE = switch_hashfunc_default("execute", &hlen);
 	unsigned long CMD_HANGUP = switch_hashfunc_default("hangup", &hlen);
 	unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
+	unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
 
 	assert(channel != NULL);
 	assert(event != NULL);
@@ -109,7 +280,7 @@
 		char *app_name = switch_event_get_header(event, "execute-app-name");
 		char *app_arg = switch_event_get_header(event, "execute-app-arg");
 		char *loop_h = switch_event_get_header(event, "loops");
-		int loops = 0;
+		int loops = 1;
 	
 		if (loop_h) {
 			loops = atoi(loop_h);
@@ -130,6 +301,31 @@
 				}
 			}
 		}
+	} else if (cmd_hash == CMD_UNICAST) {
+		char *local_ip = switch_event_get_header(event, "local_ip");
+		char *local_port = switch_event_get_header(event, "local_port");
+		char *remote_ip = switch_event_get_header(event, "remote_ip");
+		char *remote_port = switch_event_get_header(event, "remote_port");
+		char *transport = switch_event_get_header(event, "transport");
+
+		if (switch_strlen_zero(local_ip)) {
+			local_ip = "127.0.0.1";
+		}
+		if (switch_strlen_zero(remote_ip)) {
+			remote_ip = "127.0.0.1";
+		}
+		if (switch_strlen_zero(local_port)) {
+			local_port = "8025";
+		}
+		if (switch_strlen_zero(remote_port)) {
+			remote_port = "8026";
+		}
+		if (switch_strlen_zero(transport)) {
+			transport = "udp";
+		}
+
+		switch_ivr_activate_unicast(session, local_ip, (switch_port_t)atoi(local_port), remote_ip, (switch_port_t)atoi(remote_port), transport);
+
 	} 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;
@@ -154,10 +350,11 @@
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_channel_t *channel;
-	switch_frame_t *frame;
+	switch_frame_t *read_frame;
 	int stream_id = 0;
 	switch_event_t *event;
-
+	switch_unicast_conninfo_t *conninfo = NULL;
+	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -171,10 +368,73 @@
 	switch_channel_set_flag(channel, CF_CONTROLLED);
 	while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED)) {
 
-		if ((status = switch_core_session_read_frame(session, &frame, -1, stream_id)) == SWITCH_STATUS_SUCCESS) {
+		if ((status = switch_core_session_read_frame(session, &read_frame, -1, stream_id)) == SWITCH_STATUS_SUCCESS) {
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
+			
+			if (switch_channel_test_flag(channel, CF_UNICAST)) {
+				if (!conninfo) {
+					if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
+						switch_channel_clear_flag(channel, CF_UNICAST);
+					}
+					
+					if (conninfo) {
+						unicast_thread_launch(conninfo);
+					}
+				}
+
+				if (conninfo) {
+					switch_size_t len;
+					uint32_t flags = 0;
+					switch_byte_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE];
+					uint32_t rate = read_codec->implementation->samples_per_second;
+					uint32_t dlen = sizeof(decoded);
+					switch_status_t status;
+					switch_byte_t *sendbuf = NULL;
+					uint32_t sendlen = 0;
+
+					if (switch_test_flag(read_frame, SFF_CNG)) {
+						sendlen = read_codec->implementation->bytes_per_frame;
+						memset(decoded, 255, sendlen);
+						sendbuf = decoded;
+						status = SWITCH_STATUS_SUCCESS;
+					} else {
+					
+						status = switch_core_codec_decode(
+														  read_codec,
+														  &conninfo->read_codec,
+														  read_frame->data,
+														  read_frame->datalen,
+														  read_codec->implementation->samples_per_second,
+														  decoded, &dlen, &rate, &flags);
+						switch (status) {
+						case SWITCH_STATUS_NOOP:
+						case SWITCH_STATUS_BREAK:
+							sendbuf = read_frame->data;
+							sendlen = read_frame->datalen;
+							status = SWITCH_STATUS_SUCCESS;
+							break;
+						case SWITCH_STATUS_SUCCESS:
+							sendbuf = decoded;
+							sendlen = dlen;
+							status = SWITCH_STATUS_SUCCESS;
+							break;
+						default:
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Codec Error\n");
+							switch_ivr_deactivate_unicast(session);
+							break;
+						}
+					}
+
+					if (status == SWITCH_STATUS_SUCCESS) {
+						len = sendlen;
+						if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *)sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
+							switch_ivr_deactivate_unicast(session);
+						}
+					}
+				}
+			}
 
 			if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
 				switch_ivr_parse_event(session, event);
@@ -212,6 +472,10 @@
 		switch_event_fire(&event);
 	}
 
+	if (switch_channel_test_flag(channel, CF_UNICAST)) {
+		switch_ivr_deactivate_unicast(session);
+	}
+
 	return status;
 }
 



More information about the Freeswitch-svn mailing list