[Freeswitch-svn] [commit] r2277 - in freeswitch/branches/james: . conf libs libs/iax/src libs/libdingaling/src mac/xcode mac/xcode/FreeSWITCH.xcodeproj mac/xcode/libs scripts/socket scripts/socket/FreeSWITCH src src/include src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/codecs/mod_g711 src/mod/codecs/mod_l16 src/mod/dialplans/mod_dialplan_xml src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_exosip src/mod/endpoints/mod_iax src/mod/endpoints/mod_portaudio src/mod/event_handlers/mod_cdr src/mod/event_handlers/mod_event_socket src/mod/event_handlers/mod_xmpp_event src/mod/formats/mod_sndfile src/mod/languages/mod_spidermonkey src/mod/xml_int/mod_xml_rpc w32/vsnet w32/vsnet/Tools w32/vsnet/Tools/PortAudio w32/vsnet/Tools/libsndfile

Freeswitch SVN james at freeswitch.org
Sun Aug 13 00:08:46 EDT 2006


Author: james
Date: Sun Aug 13 00:08:45 2006
New Revision: 2277

Added:
   freeswitch/branches/james/mac/xcode/FreeSWITCH.xcodeproj/
      - copied from r2276, /freeswitch/trunk/mac/xcode/FreeSWITCH.xcodeproj/
   freeswitch/branches/james/mac/xcode/FreeSWITCH.xcodeproj/project.pbxproj
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/FreeSWITCH.xcodeproj/project.pbxproj
   freeswitch/branches/james/mac/xcode/Loadable Bundle.trgttmpl
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/Loadable Bundle.trgttmpl
   freeswitch/branches/james/mac/xcode/apr.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/apr.plist
   freeswitch/branches/james/mac/xcode/aprutil.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/aprutil.plist
   freeswitch/branches/james/mac/xcode/dingaling.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/dingaling.plist
   freeswitch/branches/james/mac/xcode/exosip2.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/exosip2.plist
   freeswitch/branches/james/mac/xcode/gsm.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/gsm.plist
   freeswitch/branches/james/mac/xcode/iax.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/iax.plist
   freeswitch/branches/james/mac/xcode/iksemel.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/iksemel.plist
   freeswitch/branches/james/mac/xcode/ilbc.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/ilbc.plist
   freeswitch/branches/james/mac/xcode/libfreeswitch.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/libfreeswitch.plist
   freeswitch/branches/james/mac/xcode/osip2.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/osip2.plist
   freeswitch/branches/james/mac/xcode/osipparser2.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/osipparser2.plist
   freeswitch/branches/james/mac/xcode/pcre.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/pcre.plist
   freeswitch/branches/james/mac/xcode/portaudio.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/portaudio.plist
   freeswitch/branches/james/mac/xcode/resample.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/resample.plist
   freeswitch/branches/james/mac/xcode/sndfile.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/sndfile.plist
   freeswitch/branches/james/mac/xcode/speakup.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/speakup.plist
   freeswitch/branches/james/mac/xcode/speex.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/speex.plist
   freeswitch/branches/james/mac/xcode/sqlite.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/sqlite.plist
   freeswitch/branches/james/mac/xcode/srtp.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/srtp.plist
   freeswitch/branches/james/mac/xcode/teletone.plist
      - copied unchanged from r2276, /freeswitch/trunk/mac/xcode/teletone.plist
   freeswitch/branches/james/w32/vsnet/Tools/PortAudio/
      - copied from r2276, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/
   freeswitch/branches/james/w32/vsnet/Tools/PortAudio/PortAudio.vcproj
      - copied unchanged from r2276, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/PortAudio.vcproj
   freeswitch/branches/james/w32/vsnet/Tools/PortAudio/portaudio.def
      - copied unchanged from r2276, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/portaudio.def
   freeswitch/branches/james/w32/vsnet/Tools/libsndfile/
      - copied from r2276, /freeswitch/trunk/w32/vsnet/Tools/libsndfile/
   freeswitch/branches/james/w32/vsnet/Tools/libsndfile/config.h
      - copied unchanged from r2276, /freeswitch/trunk/w32/vsnet/Tools/libsndfile/config.h
   freeswitch/branches/james/w32/vsnet/Tools/libsndfile/libsndfile.vcproj
      - copied unchanged from r2276, /freeswitch/trunk/w32/vsnet/Tools/libsndfile/libsndfile.vcproj
   freeswitch/branches/james/w32/vsnet/Tools/libsndfile/sndfile.h
      - copied unchanged from r2276, /freeswitch/trunk/w32/vsnet/Tools/libsndfile/sndfile.h
Removed:
   freeswitch/branches/james/libs/MD5
   freeswitch/branches/james/mac/xcode/libs/
Modified:
   freeswitch/branches/james/   (props changed)
   freeswitch/branches/james/Makefile.am
   freeswitch/branches/james/Makefile.in
   freeswitch/branches/james/conf/freeswitch.xml
   freeswitch/branches/james/libs/iax/src/iax.c
   freeswitch/branches/james/libs/libdingaling/src/libdingaling.c
   freeswitch/branches/james/libs/libdingaling/src/libdingaling.h
   freeswitch/branches/james/scripts/socket/FreeSWITCH/Client.pm
   freeswitch/branches/james/scripts/socket/fs.pl
   freeswitch/branches/james/src/include/switch.h
   freeswitch/branches/james/src/include/switch_apr.h
   freeswitch/branches/james/src/include/switch_core.h
   freeswitch/branches/james/src/include/switch_loadable_module.h
   freeswitch/branches/james/src/include/switch_module_interfaces.h
   freeswitch/branches/james/src/include/switch_types.h
   freeswitch/branches/james/src/include/switch_utils.h
   freeswitch/branches/james/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/james/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/james/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/james/src/mod/codecs/mod_g711/mod_g711.c
   freeswitch/branches/james/src/mod/codecs/mod_l16/mod_l16.c
   freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/Makefile
   freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/branches/james/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/james/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/branches/james/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/james/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/james/src/mod/event_handlers/mod_cdr/Makefile
   freeswitch/branches/james/src/mod/event_handlers/mod_cdr/README
   freeswitch/branches/james/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.h
   freeswitch/branches/james/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/james/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
   freeswitch/branches/james/src/mod/formats/mod_sndfile/Makefile
   freeswitch/branches/james/src/mod/formats/mod_sndfile/mod_sndfile.c
   freeswitch/branches/james/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/james/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
   freeswitch/branches/james/src/switch.c
   freeswitch/branches/james/src/switch_console.c
   freeswitch/branches/james/src/switch_core.c
   freeswitch/branches/james/src/switch_event.c
   freeswitch/branches/james/src/switch_ivr.c
   freeswitch/branches/james/src/switch_loadable_module.c
   freeswitch/branches/james/src/switch_rtp.c
   freeswitch/branches/james/src/switch_utils.c
   freeswitch/branches/james/src/switch_xml.c
   freeswitch/branches/james/w32/vsnet/Freeswitch.sln
   freeswitch/branches/james/w32/vsnet/GetLibs.vbs
   freeswitch/branches/james/w32/vsnet/Tools/   (props changed)

Log:
Update to trunk.


Modified: freeswitch/branches/james/Makefile.am
==============================================================================
--- freeswitch/branches/james/Makefile.am	(original)
+++ freeswitch/branches/james/Makefile.am	Sun Aug 13 00:08:45 2006
@@ -130,7 +130,7 @@
 lib_LTLIBRARIES		= libfreeswitch.la
 libfreeswitch_la_CFLAGS	= $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -std=c99 
 libfreeswitch_la_LDFLAGS	= -version-info 1:0:0
-libfreeswitch_la_LIBADD  = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup
+libfreeswitch_la_LIBADD  = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup -lpcre
 nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
 
 bin_PROGRAMS =	freeswitch
@@ -164,13 +164,14 @@
 	@./build/addenv.sh build/freeswitch.env PREFIX $(PREFIX)
 	@./build/addenv.sh build/freeswitch.env MAKE $(MAKE)
 	mkdir -p $(PREFIX)
-	./build/buildlib.sh . install sqlite-3.3.5.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
-	./build/buildlib.sh . install apr-1.2.6.tar.gz --prefix=$(PREFIX)
-	./build/buildlib.sh . install apr-util-1.2.6.tar.gz --with-apr=../apr-1.2.6 --prefix=$(PREFIX)
+	./build/buildlib.sh . install sqlite-3.3.6.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
+	./build/buildlib.sh . install apr-1.2.7.tar.gz --prefix=$(PREFIX)
+	./build/buildlib.sh . install apr-util-1.2.7.tar.gz --with-apr=../apr-1.2.7 --prefix=$(PREFIX)
 	./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
 	./build/buildlib.sh . install libteletone --prefix=$(PREFIX)
 	./build/buildlib.sh . install srtp --prefix=$(PREFIX)
 	./build/buildlib.sh . install libspeakup --prefix=$(PREFIX)
+	./build/buildlib.sh . install pcre-6.4.tar.gz --prefix=$(PREFIX)
 	rm build/freeswitch.env
 
 

Modified: freeswitch/branches/james/Makefile.in
==============================================================================
--- freeswitch/branches/james/Makefile.in	(original)
+++ freeswitch/branches/james/Makefile.in	Sun Aug 13 00:08:45 2006
@@ -348,7 +348,7 @@
 lib_LTLIBRARIES = libfreeswitch.la
 libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -std=c99 
 libfreeswitch_la_LDFLAGS = -version-info 1:0:0
-libfreeswitch_la_LIBADD = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup
+libfreeswitch_la_LIBADD = -lteletone -lresample -lsrtp -lsqlite3 -lspeakup -lpcre
 nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
 bin_SCRIPTS = scripts/fsxs
 freeswitch_SOURCES = src/switch.c\
@@ -805,7 +805,7 @@
 
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
-	mkdir -p $(distdir)
+	mkdir $(distdir)
 	$(mkdir_p) $(distdir)/build/config $(distdir)/src/include
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
@@ -1084,13 +1084,14 @@
 	@./build/addenv.sh build/freeswitch.env PREFIX $(PREFIX)
 	@./build/addenv.sh build/freeswitch.env MAKE $(MAKE)
 	mkdir -p $(PREFIX)
-	./build/buildlib.sh . install sqlite-3.3.5.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
-	./build/buildlib.sh . install apr-1.2.6.tar.gz --prefix=$(PREFIX)
-	./build/buildlib.sh . install apr-util-1.2.6.tar.gz --with-apr=../apr-1.2.6 --prefix=$(PREFIX)
+	./build/buildlib.sh . install sqlite-3.3.6.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
+	./build/buildlib.sh . install apr-1.2.7.tar.gz --prefix=$(PREFIX)
+	./build/buildlib.sh . install apr-util-1.2.7.tar.gz --with-apr=../apr-1.2.7 --prefix=$(PREFIX)
 	./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
 	./build/buildlib.sh . install libteletone --prefix=$(PREFIX)
 	./build/buildlib.sh . install srtp --prefix=$(PREFIX)
 	./build/buildlib.sh . install libspeakup --prefix=$(PREFIX)
+	./build/buildlib.sh . install pcre-6.4.tar.gz --prefix=$(PREFIX)
 	rm build/freeswitch.env
 
 modules: $(NAME)

Modified: freeswitch/branches/james/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/james/conf/freeswitch.xml	(original)
+++ freeswitch/branches/james/conf/freeswitch.xml	Sun Aug 13 00:08:45 2006
@@ -254,6 +254,13 @@
         <param name="message" value="Jingle all the way"/>
         <param name="rtp-ip" value="10.0.0.1"/>
         <param name="auto-login" value="true"/>
+        <!-- SASL "plain" or "md5" -->
+        <param name="sasl" value="plain"/>
+        <!-- if the server where the jabber is hosted is not the same
+        as the one in the jid -->
+        <!--<param name="server" value="alternate.server.com"/>-->
+        <!-- Enable TLS or not -->
+        <param name="tls" value="true"/>
         <!-- disable to trade async for more calls -->
         <param name="use-rtp-timer" value="true"/>
         <!-- or -->
@@ -356,7 +363,7 @@
     <!-- *NOTE* The special context name 'any' will match any context -->
     <context name="default">
       <extension name="tollfree">
-        <condition field="destination_number" expression="^(18[0{2}8{2}7{2}6{2}]\d{7})">
+        <condition field="destination_number" expression="^(18(0{2}|8{2}|7{2}|6{2})\d{7})$">
           <action application="bridge" data="exosip/$1-freeswitch at voip.trxtel.com"/>
         </condition>
       </extension>

Modified: freeswitch/branches/james/libs/iax/src/iax.c
==============================================================================
--- freeswitch/branches/james/libs/iax/src/iax.c	(original)
+++ freeswitch/branches/james/libs/iax/src/iax.c	Sun Aug 13 00:08:45 2006
@@ -1785,7 +1785,7 @@
 		convert_reply(realreply, (unsigned char *) reply);
 		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) realreply);
 	} else {
-		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) password);
+		iax_ie_append_str(&ied, IAX_IE_PASSWORD, (unsigned char *) password);
 	}
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_AUTHREP, 0, ied.buf, ied.pos, -1);
 }
@@ -1808,7 +1808,7 @@
 		convert_reply(realreply, (unsigned char *) reply);
 		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) realreply);
 	} else {
-		iax_ie_append_str(&ied, IAX_IE_MD5_RESULT, (unsigned char *) password);
+		iax_ie_append_str(&ied, IAX_IE_PASSWORD, (unsigned char *) password);
 	}
 	return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREQ, 0, ied.buf, ied.pos, -1);
 }
@@ -2244,7 +2244,7 @@
 	
 	/* How many ms from now should this packet be delivered? (remember
 	   this can be a negative number, too */
-	ms = calc_rxstamp(e->session) - ts;
+	ms = (int)(calc_rxstamp(e->session) - ts);
 
 	/*  
 	   Drop voice frame if timestamp is way off 

Modified: freeswitch/branches/james/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/james/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/branches/james/libs/libdingaling/src/libdingaling.c	Sun Aug 13 00:08:45 2006
@@ -64,8 +64,8 @@
 #define microsleep(x) apr_sleep(x * 1000)
 
 static int opt_timeout = 30;
-static int opt_use_tls = 0;
 
+
 static struct {
 	unsigned int flags;
 	FILE *log_stream;
@@ -73,6 +73,7 @@
 	apr_pool_t *memory_pool;
 	unsigned int id;
 	ldl_logger_t logger;
+	apr_thread_mutex_t *flag_mutex;
 } globals;
 
 struct packet_node {
@@ -94,7 +95,9 @@
 	iksfilter *filter;
 	char *login;
 	char *password;
+	char *server;
 	char *status_msg;
+	uint16_t port;
 	int features;
 	int counter;
 	int job_done;
@@ -105,6 +108,7 @@
 	apr_hash_t *retry_hash;
 	apr_hash_t *probe_hash;
 	apr_thread_mutex_t *lock;
+	apr_thread_mutex_t *flag_mutex;
 	ldl_loop_callback_t loop_callback;
 	ldl_session_callback_t session_callback;
 	ldl_response_callback_t response_callback;
@@ -423,6 +427,10 @@
 	struct ldl_buffer *buffer;
 	size_t x;
 
+	iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); 
+	apr_queue_push(handle->queue, msg);
+
+
 	apr_cpystrn(id, from, sizeof(id));
 	if ((resource = strchr(id, '/'))) {
 		*resource++ = '\0';
@@ -477,13 +485,59 @@
 	//char *to = iks_find_attrib(pak->x, "to");
 	char *iqid = iks_find_attrib(pak->x, "id");
 	char *type = iks_find_attrib(pak->x, "type");
+	uint8_t is_result = strcasecmp(type, "result") ? 0 : 1;
 	iks *xml;
 
-	//printf("XXXXX from=%s to=%s type=%s\n", from, to, type);
+	if (is_result) {
+		iks *tag = iks_child (pak->x);
+		while(tag) {
+			if (!strcasecmp(iks_name(tag), "bind")) {
+				char *jid = iks_find_cdata(tag, "jid");
+				char *resource = strchr(jid, '/');
+				iks *iq, *usersetting, *x;
+				handle->acc->resource = apr_pstrdup(handle->pool, resource);
+				handle->login = apr_pstrdup(handle->pool, jid);
+				if ((iq = iks_new("iq"))) {
+					char *njid = strdup(handle->login);
+					if ((resource = strchr(njid, '/'))) {
+						*resource++ = '\0';
+					}
+					iks_insert_attrib(iq, "type", "set");
+					iks_insert_attrib(iq, "to", njid);
+					iks_insert_attrib(iq, "id", "params");
 
-	if ((!strcasecmp(type, "result") || !strcasecmp(type, "error")) && iqid && from) {
+					usersetting = iks_insert(iq, "usersetting");
+					iks_insert_attrib(usersetting, "xmlns", "google:setting");
+					x = iks_insert(usersetting,  "autoacceptrequests");
+					iks_insert_attrib(x, "value", "true");
+					x = iks_insert(usersetting,  "mailnotifications");
+					iks_insert_attrib(x, "value", "false");
+					free(njid);
+					iks_send(handle->parser, iq);
+					iks_delete(iq);
+					if ((iq = iks_new("iq"))) {
+						iks_insert_attrib(iq, "type", "get");
+						iks_insert_attrib(iq, "id", "roster");
+						x = iks_insert(iq,  "query");
+						iks_insert_attrib(x, "xmlns", "jabber:iq:roster");
+						iks_insert_attrib(x, "xmlns:gr", "google:roster");
+						iks_insert_attrib(x, "gr:ext", "2");
+						iks_insert_attrib(x, "gr:include", "all");
+						iks_send(handle->parser, iq);
+						iks_delete(iq);
+					}
+
+
+				}
+				break;
+			}
+			tag = iks_next_tag(tag);
+		}
+	}
+
+	if ((is_result || !strcasecmp(type, "error")) && iqid && from) {
 		cancel_retry(handle, iqid);
-		if (!strcasecmp(type, "result")) {
+		if (is_result) {
 			if (handle->response_callback) {
 				handle->response_callback(handle, iqid); 
 			}
@@ -528,26 +582,62 @@
 	iks_insert_attrib(ctag, "ext", "sidebar voice-v1");
 	iks_insert_attrib(ctag, "client", "libdingaling");
 	iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
-	
+
 	apr_queue_push(handle->queue, msg);
-	ldl_set_flag(handle, LDL_FLAG_READY);
+	ldl_set_flag_locked(handle, LDL_FLAG_READY);
 	return IKS_FILTER_EAT;
 }
 
+static const char c64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+#define B64BUFFLEN 1024
+
+static int b64encode(unsigned char *in, uint32_t ilen, unsigned char *out, uint32_t olen) {
+	int x=0,y=0,bytes=0;
+	unsigned int b=0,l=0;
+
+	for(x=0;x<ilen;x++) {
+		b = (b<<8) + in[x];
+		l += 8;
+		while (l >= 6) {
+			out[bytes++] = c64[(b>>(l-=6))%64];
+			if(++y!=72) {
+				continue;
+			}
+			out[bytes++] = '\n';
+			y=0;
+		}
+	}
+
+	if (l > 0) {
+		out[bytes++] = c64[((b%16)<<(6-l))%64];
+	}
+	if (l != 0) while (l < 6) {
+		out[bytes++] = '=', l += 2;
+	}
+
+	return 0;
+}
+
 static int on_stream(ldl_handle_t *handle, int type, iks * node)
 {
 	handle->counter = opt_timeout;
 
 	switch (type) {
 	case IKS_NODE_START:
-		if (opt_use_tls && !iks_is_secure(handle->parser)) {
-			iks_start_tls(handle->parser);
+		if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser)) {
+			if (iks_has_tls()) {
+				iks_start_tls(handle->parser);
+			} else {
+				globals.logger(DL_LOG_DEBUG, "TLS NOT SUPPORTED IN THIS BUILD!\n");
+			}
 		}
 		break;
 	case IKS_NODE_NORMAL:
+		
+
 		if (strcmp("stream:features", iks_name(node)) == 0) {
 			handle->features = iks_stream_features(node);
-			if (opt_use_tls && !iks_is_secure(handle->parser))
+			if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser))
 				break;
 			if (ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
 				iks *t;
@@ -566,7 +656,27 @@
 				if (handle->features & IKS_STREAM_SASL_MD5) {
 					iks_start_sasl(handle->parser, IKS_SASL_DIGEST_MD5, handle->acc->user, handle->password);
 				} else if (handle->features & IKS_STREAM_SASL_PLAIN) {
-					iks_start_sasl(handle->parser, IKS_SASL_PLAIN, handle->acc->user, handle->password);
+					iks *x = NULL;
+
+					if ((x = iks_new("auth"))) {
+						char s[512] = "";
+						char base64[1024] = "";
+						uint32_t slen;
+
+						iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
+						iks_insert_attrib(x, "mechanism", "PLAIN");
+						iks_insert_attrib(x, "encoding", "UTF-8");
+						snprintf(s, sizeof(s), "%c%s%c%s", 0, handle->acc->user, 0, handle->password);
+						slen = strlen(handle->acc->user) + strlen(handle->password) + 2;
+						b64encode((unsigned char *)s, slen, (unsigned char *) base64, sizeof(base64));
+						iks_insert_cdata(x, base64, 0);
+						iks_send(handle->parser, x);
+						iks_delete(x);
+					} else {
+						globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n");
+						break;
+					}
+					
 				}
 			}
 		} else if (strcmp("failure", iks_name(node)) == 0) {
@@ -577,25 +687,25 @@
 		} else if (strcmp("success", iks_name(node)) == 0) {
 			globals.logger(DL_LOG_DEBUG, "XMPP server connected\n");
 			iks_send_header(handle->parser, handle->acc->server);
-			ldl_set_flag(handle, LDL_FLAG_CONNECTED);
+			ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED);
 			if (handle->session_callback) {
 				handle->session_callback(handle, NULL, LDL_SIGNAL_CONNECTED, "core", "Server Connected", handle->login);
 			}
 		} else {
 			ikspak *pak;
-
 			if (!ldl_test_flag(handle, LDL_FLAG_AUTHORIZED)) {
 				if (handle->session_callback) {
 					handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_SUCCESS, "core", "Login Success", handle->login);
 				}
 				globals.logger(DL_LOG_DEBUG, "XMPP authenticated\n");
-				ldl_set_flag(handle, LDL_FLAG_AUTHORIZED);
+				ldl_set_flag_locked(handle, LDL_FLAG_AUTHORIZED);
 			}
 
 			pak = iks_packet(node);
 			iks_filter_packet(handle->filter, pak);
-			if (handle->job_done == 1)
+			if (handle->job_done == 1) {
 				return IKS_HOOK;
+			}
 		}
 		break;
 #if 0
@@ -724,7 +834,6 @@
 		apr_time_t now = apr_time_now();
 		x++;
 
-		//printf("%s %lld %lld %u\n", packet_node->id, packet_node->next, now, packet_node->retries);
 		if (packet_node->next <= now) {
 			if (packet_node->retries > 0) {
 				packet_node->retries--;
@@ -749,6 +858,46 @@
 	apr_thread_mutex_unlock(handle->lock);
 }
 
+
+static void *APR_THREAD_FUNC queue_thread(apr_thread_t *thread, void *obj)
+{
+	ldl_handle_t *handle = (ldl_handle_t *) obj;
+
+	ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
+
+	while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
+		ldl_flush_queue(handle);
+
+		if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
+			int fd;
+
+			if ((fd = iks_fd(handle->parser)) > -1) {
+				shutdown(fd, 0x02);
+			}
+			ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);	
+			break;
+		}
+		microsleep(100);
+	}
+	
+	ldl_clear_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
+
+	return NULL;
+}
+
+static void launch_queue_thread(ldl_handle_t *handle)
+{
+    apr_thread_t *thread;
+    apr_threadattr_t *thd_attr;;
+    apr_threadattr_create(&thd_attr, handle->pool);
+    apr_threadattr_detach_set(thd_attr, 1);
+
+	apr_threadattr_stacksize_set(thd_attr, 512 * 1024);
+	apr_thread_create(&thread, thd_attr, queue_thread, handle, handle->pool);
+
+}
+
+
 static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
 {
 	while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
@@ -769,7 +918,12 @@
 
 		j_setup_filter(handle, "fixme");
 
-		e = iks_connect_tcp(handle->parser, handle->acc->server, IKS_JABBER_PORT);
+		e = iks_connect_via(handle->parser,
+							handle->server ? handle->server : handle->acc->server,
+							handle->port ? handle->port : IKS_JABBER_PORT,
+							//handle->server ? handle->server : handle->acc->server);
+							handle->acc->server);
+
 		switch (e) {
 		case IKS_OK:
 			break;
@@ -783,12 +937,18 @@
 			continue;
 		}
 
+
+
 		handle->counter = opt_timeout;
+		if (ldl_test_flag(handle, LDL_FLAG_TLS)) {
+			launch_queue_thread(handle);
+		}
+
 		while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
 			e = iks_recv(handle->parser, 1);
-			if (handle->loop_callback) {
+			if (!ldl_test_flag(handle, LDL_FLAG_TLS) && handle->loop_callback) {
 				if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
-					ldl_clear_flag(handle, LDL_FLAG_RUNNING);	
+					ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);	
 					break;
 				}
 			}
@@ -807,7 +967,8 @@
 				break;
 			}
 
-			if (ldl_test_flag(handle, LDL_FLAG_READY)) {
+			
+			if (!ldl_test_flag(handle, LDL_FLAG_TLS) && ldl_test_flag(handle, LDL_FLAG_READY)) {
 				ldl_flush_queue(handle);
 			}
 
@@ -828,11 +989,16 @@
 
 		iks_disconnect(handle->parser);
 		iks_parser_delete(handle->parser);
-		ldl_clear_flag(handle, LDL_FLAG_CONNECTED);
-		ldl_clear_flag(handle, LDL_FLAG_AUTHORIZED);
+		ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED);
+		ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED);
 	}
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
 
-	ldl_clear_flag(handle, LDL_FLAG_RUNNING);
+	while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) {
+		microsleep(100);
+	}
+
+
 }
 
 
@@ -1134,16 +1300,18 @@
 	}
 
 	memset(&globals, 0, sizeof(globals));
+
 	if (apr_pool_create(&globals.memory_pool, NULL) != LDL_STATUS_SUCCESS) {
 		globals.logger(DL_LOG_DEBUG, "Could not allocate memory pool\n");
 		return LDL_STATUS_MEMERR;
 	}
 
+	apr_thread_mutex_create(&globals.flag_mutex, APR_THREAD_MUTEX_NESTED, globals.memory_pool);
 	globals.log_stream = stdout;
 	globals.debug = debug;
 	globals.id = 300;
 	globals.logger = default_logger;
-	ldl_set_flag(&globals, LDL_FLAG_INIT);
+	ldl_set_flag_locked((&globals), LDL_FLAG_INIT);
 	
 	return LDL_STATUS_SUCCESS;
 }
@@ -1176,6 +1344,8 @@
 ldl_status ldl_handle_init(ldl_handle_t **handle,
 						   char *login,
 						   char *password,
+						   char *server,
+						   ldl_user_flag_t flags,
 						   char *status_msg,
 						   ldl_loop_callback_t loop_callback,
 						   ldl_session_callback_t session_callback,
@@ -1184,20 +1354,44 @@
 {
 	apr_pool_t *pool;
 	assert(ldl_test_flag(&globals, LDL_FLAG_INIT));
-	
+	*handle = NULL;	
 
 	if ((apr_pool_create(&pool, globals.memory_pool)) != LDL_STATUS_SUCCESS) {
 		return LDL_STATUS_MEMERR;
 	}
 
+	if (!login) {
+		globals.logger(DL_LOG_ERR, "No login supplied!\n");
+		return LDL_STATUS_FALSE;
+	}
+
+	if (!password) {
+		globals.logger(DL_LOG_ERR, "No password supplied!\n");
+		return LDL_STATUS_FALSE;
+	}
+	
+
 	if ((*handle = apr_palloc(pool, sizeof(ldl_handle_t)))) {
 		ldl_handle_t *new_handle = *handle;
 		memset(new_handle, 0, sizeof(ldl_handle_t));
 		new_handle->log_stream = globals.log_stream;
 		new_handle->login = apr_pstrdup(pool, login);
 		new_handle->password = apr_pstrdup(pool, password);
-		new_handle->status_msg = apr_pstrdup(pool, status_msg);
 
+		if (server) {
+			char *p;
+
+			new_handle->server = apr_pstrdup(pool, server);
+			if ((p = strchr(new_handle->server, ':'))) {
+				*p++ = '\0';
+				new_handle->port = atoi(p);
+			}
+		}
+
+		if (status_msg) {
+			new_handle->status_msg = apr_pstrdup(pool, status_msg);
+		}
+
 		if (loop_callback) {
 			new_handle->loop_callback = loop_callback;
 		}
@@ -1212,32 +1406,39 @@
 
 		new_handle->private_info = private_info;
 		new_handle->pool = pool;
+		new_handle->flags |= flags;
 		apr_queue_create(&new_handle->queue, LDL_HANDLE_QLEN, new_handle->pool);
 		apr_queue_create(&new_handle->retry_queue, LDL_HANDLE_QLEN, new_handle->pool);
-		new_handle->features |= IKS_STREAM_BIND|IKS_STREAM_SESSION |IKS_STREAM_SASL_PLAIN;
+		new_handle->features |= IKS_STREAM_BIND|IKS_STREAM_SESSION;
+
+		if (new_handle->flags & LDL_FLAG_SASL_PLAIN) {
+			new_handle->features |= IKS_STREAM_SASL_PLAIN;
+		} else if (new_handle->flags & LDL_FLAG_SASL_MD5) {
+			new_handle->features |= IKS_STREAM_SASL_MD5;
+		}
+
 		new_handle->sessions = apr_hash_make(new_handle->pool);
 		new_handle->retry_hash = apr_hash_make(new_handle->pool);
 		new_handle->probe_hash = apr_hash_make(new_handle->pool);
 		apr_thread_mutex_create(&new_handle->lock, APR_THREAD_MUTEX_NESTED, new_handle->pool);
+		apr_thread_mutex_create(&new_handle->flag_mutex, APR_THREAD_MUTEX_NESTED, new_handle->pool);
 
 		return LDL_STATUS_SUCCESS;
-	} else {
-		*handle = NULL;
-	}
-
+	} 
+	
 	return LDL_STATUS_FALSE;
 }
 
 void ldl_handle_run(ldl_handle_t *handle)
 {
-	ldl_set_flag(handle, LDL_FLAG_RUNNING);
+	ldl_set_flag_locked(handle, LDL_FLAG_RUNNING);
 	xmpp_connect(handle, handle->login, handle->password);
-	ldl_clear_flag(handle, LDL_FLAG_RUNNING);
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
 }
 
 void ldl_handle_stop(ldl_handle_t *handle)
 {
-	ldl_clear_flag(handle, LDL_FLAG_RUNNING);
+	ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
 }
 
 ldl_status ldl_handle_destroy(ldl_handle_t **handle)
@@ -1246,6 +1447,7 @@
 
 	ldl_flush_queue(*handle);
 	
+
 	apr_pool_destroy(pool);
 	*handle = NULL;
 	return LDL_STATUS_SUCCESS;

Modified: freeswitch/branches/james/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/branches/james/libs/libdingaling/src/libdingaling.h	(original)
+++ freeswitch/branches/james/libs/libdingaling/src/libdingaling.h	Sun Aug 13 00:08:45 2006
@@ -100,10 +100,17 @@
 	LDL_FLAG_RUNNING = (1 << 1),
 	LDL_FLAG_AUTHORIZED = (1 << 2),
 	LDL_FLAG_READY = (1 << 3),
-	LDL_FLAG_CONNECTED = (1 << 4)
+	LDL_FLAG_CONNECTED = (1 << 4),
+	LDL_FLAG_QUEUE_RUNNING = (1 << 5),
 } ldl_flag_t;
 
 typedef enum {
+	LDL_FLAG_TLS = (1 << 10),
+	LDL_FLAG_SASL_PLAIN = (1 << 11),
+	LDL_FLAG_SASL_MD5 = (1 << 12)
+} ldl_user_flag_t;
+
+typedef enum {
 	LDL_SIGNAL_NONE,
 	LDL_SIGNAL_INITIATE,
 	LDL_SIGNAL_CANDIDATES,
@@ -172,6 +179,23 @@
 #define ldl_clear_flag(obj, flag) (obj)->flags &= ~(flag)
 
 /*!
+  \brief Set a flag on an arbitrary object while locked
+  \param obj the object to set the flags on
+  \param flag the or'd list of flags to set
+*/
+#define ldl_set_flag_locked(obj, flag) assert(obj->flag_mutex != NULL);\
+apr_thread_mutex_lock(obj->flag_mutex);\
+(obj)->flags |= (flag);\
+apr_thread_mutex_unlock(obj->flag_mutex);
+
+/*!
+  \brief Clear a flag on an arbitrary object
+  \param obj the object to test
+  \param flag the or'd list of flags to clear
+*/
+#define ldl_clear_flag_locked(obj, flag) apr_thread_mutex_lock(obj->flag_mutex); (obj)->flags &= ~(flag); apr_thread_mutex_unlock(obj->flag_mutex);
+
+/*!
   \brief Copy flags from one arbitrary object to another
   \param dest the object to copy the flags to
   \param src the object to copy the flags from
@@ -389,6 +413,8 @@
 ldl_status ldl_handle_init(ldl_handle_t **handle,
 						   char *login,
 						   char *password,
+						   char *server,
+						   ldl_user_flag_t flags,
 						   char *status_msg,
 						   ldl_loop_callback_t loop_callback,
 						   ldl_session_callback_t session_callback,

Modified: freeswitch/branches/james/scripts/socket/FreeSWITCH/Client.pm
==============================================================================
--- freeswitch/branches/james/scripts/socket/FreeSWITCH/Client.pm	(original)
+++ freeswitch/branches/james/scripts/socket/FreeSWITCH/Client.pm	Sun Aug 13 00:08:45 2006
@@ -89,7 +89,7 @@
   my ($self,$data) = @_;
   my $s = $self->{_sock};
 
-  print $s $data;
+  print $s $data ;
 }
 
 sub cmd($$$) {
@@ -97,12 +97,26 @@
   my $cmd = shift;
   my $to = shift;
 
-  $self->output($cmd);
+  $self->output($cmd->{command});
+  foreach(keys %{$cmd}) {
+    next if ($_ eq "command");
+    $self->output($cmd->{$_});
+  }
+  $self->output("\n\n");
+
   my $h = $self->readhash($to);
 
   $h;
 }
 
+sub disconnect($) {
+  my $self = shift;
+  $self->{_sock}->shutdown(2);
+  $self->{_sock}->close();
+  undef $self->{_sock};
+  delete $self->{_sock};
+}
+
 sub connect($) {
   my $self = shift;
 
@@ -120,8 +134,7 @@
 
   if ($h->{"content-type"} eq "auth/request") {
     my $pass = $self->{"_password"};
-    $self->output("auth $pass");
-    $h = $self->readhash(undef);
+    $h = $self->cmd({command => "auth $pass"});
   }
 
   if ($h->{'reply-text'} =~ "OK") {

Modified: freeswitch/branches/james/scripts/socket/fs.pl
==============================================================================
--- freeswitch/branches/james/scripts/socket/fs.pl	(original)
+++ freeswitch/branches/james/scripts/socket/fs.pl	Sun Aug 13 00:08:45 2006
@@ -11,21 +11,29 @@
 
 my $log = shift;
 
+$SIG{CHLD} = sub {$fs->disconnect(); die "done"};
+
 if ($log) {
   $pid = fork;
   if (!$pid) {
     my $fs2 = init FreeSWITCH::Client {-password => $password} or die "Error $@";
-    $fs2->cmd("log $log");
+    
+
+    $fs2->cmd({ command => "log $log" });
     while (1) {
       my $reply = $fs2->readhash(undef);
-      
+      if ($reply->{socketerror}) {
+	die "socket error";
+      }
       if ($reply->{body}) {
 	print $reply->{body} . "\n";
       } elsif ($reply->{'reply-text'}) {
 	print $reply->{'reply-text'} . "\n";
       }
     }
+    exit;
   }
+
 }
 
 
@@ -34,8 +42,11 @@
   my $reply;
 
   if ($_) {
-    my $reply = $fs->cmd("api $_");
-      
+    my $reply = $fs->cmd({command => "api $_"});
+    if ($reply->{socketerror}) {
+      $fs2->disconnect();
+      die "socket error";
+    }
     if ($reply->{body}) {
       print $reply->{body};
     } elsif ($reply->{'reply-text'}) {

Modified: freeswitch/branches/james/src/include/switch.h
==============================================================================
--- freeswitch/branches/james/src/include/switch.h	(original)
+++ freeswitch/branches/james/src/include/switch.h	Sun Aug 13 00:08:45 2006
@@ -73,6 +73,7 @@
 #include <switch_stun.h>
 #include <switch_log.h>
 #include <switch_xml.h>
+#include <pcre.h>
 
 
 /** \mainpage FreeSWITCH

Modified: freeswitch/branches/james/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_apr.h	(original)
+++ freeswitch/branches/james/src/include/switch_apr.h	Sun Aug 13 00:08:45 2006
@@ -656,7 +656,7 @@
 									apr_int32_t flags, 
 									char *buf, 
 									apr_size_t *len);)
-//#define switch_socket_recvfrom apr_socket_recvfrom
+#define switch_socket_recvfrom apr_socket_recvfrom
 
 /**
  * Send a file from an open file descriptor to a socket, along with 

Modified: freeswitch/branches/james/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_core.h	(original)
+++ freeswitch/branches/james/src/include/switch_core.h	Sun Aug 13 00:08:45 2006
@@ -206,7 +206,7 @@
   \return a void pointer to the allocated memory
   \note this memory never goes out of scope until the core is destroyed
 */
-SWITCH_DECLARE(void *) switch_core_permenant_alloc(switch_size_t memory);
+SWITCH_DECLARE(void *) switch_core_permanent_alloc(switch_size_t memory);
 
 /*! 
   \brief Allocate memory directly from a memory pool
@@ -226,11 +226,11 @@
 SWITCH_DECLARE(void *) switch_core_session_alloc(switch_core_session_t *session, switch_size_t memory);
 
 /*! 
-  \brief Copy a string using permenant memory allocation
+  \brief Copy a string using permanent memory allocation
   \param todup the string to duplicate
   \return a pointer to the newly duplicated string
 */
-SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup);
+SWITCH_DECLARE(char *) switch_core_permanent_strdup(char *todup);
 
 /*! 
   \brief Copy a string using memory allocation from a session's pool
@@ -865,6 +865,25 @@
   \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
 */
 SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
+
+/*! 
+  \brief Set metadata to the desired string
+  \param fh the file handle to set data to
+  \param col the enum of the col name
+  \param string the string to add
+  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
+
+/*! 
+  \brief get metadata of the desired string
+  \param fh the file handle to get data from
+  \param col the enum of the col name
+  \param string pointer to the string to fetch
+  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
+
 
 /*! 
   \brief Close an open file handle

Modified: freeswitch/branches/james/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_loadable_module.h	(original)
+++ freeswitch/branches/james/src/include/switch_loadable_module.h	Sun Aug 13 00:08:45 2006
@@ -191,10 +191,11 @@
   \brief Execute a registered API command
   \param cmd the name of the API command to execute
   \param arg the optional arguement to the command
+  \param session an optional session
   \param stream stream for output
   \return the status returned by the API call
 */
-SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_stream_handle_t *stream);
+SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
 
 
 

Modified: freeswitch/branches/james/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/branches/james/src/include/switch_module_interfaces.h	Sun Aug 13 00:08:45 2006
@@ -266,6 +266,10 @@
 	switch_status_t (*file_write)(switch_file_handle_t *, void *data, switch_size_t *len);
 	/*! function to seek to a certian position in the file */
 	switch_status_t (*file_seek)(switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence);
+	/*! function to set meta data */
+	switch_status_t (*file_set_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
+	/*! function to get meta data */
+	switch_status_t (*file_get_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
 	/*! list of supported file extensions */
 	char **extens;
 	const struct switch_file_interface *next;

Modified: freeswitch/branches/james/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_types.h	(original)
+++ freeswitch/branches/james/src/include/switch_types.h	Sun Aug 13 00:08:45 2006
@@ -94,7 +94,17 @@
 #define SWITCH_FALSE 0
 #define SWITCH_CORE_QUEUE_LEN 100000
 
+
 typedef enum {
+	SWITCH_AUDIO_COL_STR_TITLE                    = 0x01,
+	SWITCH_AUDIO_COL_STR_COPYRIGHT                = 0x02,
+	SWITCH_AUDIO_COL_STR_SOFTWARE                 = 0x03,
+	SWITCH_AUDIO_COL_STR_ARTIST                   = 0x04,
+	SWITCH_AUDIO_COL_STR_COMMENT                  = 0x05,
+	SWITCH_AUDIO_COL_STR_DATE                     = 0x06
+} switch_audio_col_t;
+
+typedef enum {
 	SWITCH_XML_SECTION_RESULT = 0,
 	SWITCH_XML_SECTION_CONFIG = (1 << 0),
 	SWITCH_XML_SECTION_DIRECTORY = (1 << 1),
@@ -543,6 +553,7 @@
 	SWITCH_EVENT_SESSION_CRASH		- Session Crashed
 	SWITCH_EVENT_MODULE_LOAD		- Module was loaded
 	SWITCH_EVENT_DTMF				- DTMF was sent
+	SWITCH_EVENT_MESSAGE			- A Basic Message
     SWITCH_EVENT_ALL				- All events at once
 </pre>
 
@@ -570,6 +581,7 @@
 	SWITCH_EVENT_SESSION_CRASH,
 	SWITCH_EVENT_MODULE_LOAD,
 	SWITCH_EVENT_DTMF,
+	SWITCH_EVENT_MESSAGE,
 	SWITCH_EVENT_ALL
 } switch_event_types_t;
 
@@ -695,7 +707,7 @@
 typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char *);
 typedef struct switch_stream_handle switch_stream_handle_t;
 typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, char *fmt, ...);
-typedef switch_status_t (*switch_api_function_t)(char *in, switch_stream_handle_t *stream);
+typedef switch_status_t (*switch_api_function_t)(char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
 typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
 															void *input,
 															switch_input_type_t input_type,

Modified: freeswitch/branches/james/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/james/src/include/switch_utils.h	(original)
+++ freeswitch/branches/james/src/include/switch_utils.h	Sun Aug 13 00:08:45 2006
@@ -61,8 +61,7 @@
 !strcasecmp(expr, "true") ||\
 atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
 
-
-SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, switch_size_t *len);
+#define SWITCH_STATUS_IS_BREAK(x) (x || x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
 
 /*!
   \brief Return a printable name of a switch_priority_t

Modified: freeswitch/branches/james/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/james/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/james/src/mod/applications/mod_commands/mod_commands.c	Sun Aug 13 00:08:45 2006
@@ -35,10 +35,15 @@
 
 static const char modname[] = "mod_commands";
 
-static switch_status_t status_function(char *cmd, switch_stream_handle_t *stream)
+static switch_status_t status_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	uint8_t html = 0;
 	switch_core_time_duration_t duration;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	switch_core_measure_time(switch_core_uptime(), &duration);
 
 	if (cmd && strstr(cmd, "html")) {
@@ -75,19 +80,27 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t load_function(char *mod, switch_stream_handle_t *stream)
+static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
 	switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod);
-	 stream->write_function(stream, "OK\n");
+	stream->write_function(stream, "OK\n");
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
-static switch_status_t reload_function(char *mod, switch_stream_handle_t *stream)
+static switch_status_t reload_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	const char *err;
 	switch_xml_t xml_root;
 
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+	
 	if ((xml_root = switch_xml_open_root(1, &err))) {
 		switch_xml_free(xml_root);
 	}
@@ -96,10 +109,14 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t kill_function(char *dest, switch_stream_handle_t *stream)
+static switch_status_t kill_function(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
 
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if ((session = switch_core_session_locate(dest))) {
 		switch_channel_t *channel = switch_core_session_get_channel(session);
 		switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
@@ -114,11 +131,15 @@
 }
 
 
-static switch_status_t transfer_function(char *cmd, switch_stream_handle_t *stream)
+static switch_status_t transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
 	char *argv[4] = {0};
 	int argc = 0;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
@@ -151,11 +172,15 @@
 
 
 
-static switch_status_t pause_function(char *cmd, switch_stream_handle_t *stream)
+static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
 	char *argv[4] = {0};
 	int argc = 0;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
@@ -230,12 +255,16 @@
 	return 0;
 }
 
-static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream)
+static switch_status_t show_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	char sql[1024];
 	char *errmsg;
 	switch_core_db_t *db = switch_core_db_handle();
 	struct holder holder = {0};
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
 
 	if (stream->event) {
         holder.http = switch_event_get_header(stream->event, "http-host");

Modified: freeswitch/branches/james/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/james/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/james/src/mod/applications/mod_conference/mod_conference.c	Sun Aug 13 00:08:45 2006
@@ -188,7 +188,7 @@
 static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin);
 static switch_status_t conference_say(conference_obj_t *conference, char *text, uint32_t leadin);
 static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim);
-static switch_status_t conf_function(char *buf, switch_stream_handle_t *stream);
+static switch_status_t conf_function(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t audio_bridge_on_ring(switch_core_session_t *session);
 static switch_status_t conference_outcall(conference_obj_t *conference, switch_core_session_t *session, char *bridgeto, char *cid_name, char *cid_num);
 static void conference_function(switch_core_session_t *session, char *data);
@@ -1232,6 +1232,7 @@
 static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim)
 {
 	conference_member_t *member = NULL;
+
 	switch_mutex_lock(conference->member_mutex);
 
 	for (member = conference->members; member; member = member->next) {
@@ -1264,7 +1265,7 @@
 }
 
 /* API Interface Function */
-static switch_status_t conf_function(char *buf, switch_stream_handle_t *stream)
+static switch_status_t conf_function(char *buf, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	char *lbuf = NULL;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -1293,6 +1294,10 @@
 		"conference <confname> transfer <member_id> <conference_name>\n"
 		;
 
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (stream->event) {
 		http = switch_event_get_header(stream->event, "http-host");
 	}
@@ -2064,7 +2069,7 @@
 			break;
 		}
 		
-		if ((time(NULL) - start) > timelimit) {
+		if ((time(NULL) - start) > (time_t)timelimit) {
 			break;
 		}
 		switch_yield(1000);
@@ -2075,10 +2080,9 @@
 	}
 
 	while ((!caller_channel || switch_channel_ready(caller_channel)) &&
-		   switch_channel_ready(peer_channel) &&
 		   !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
 		   !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
-		   ((time(NULL) - start) < timelimit)) {
+		   ((time(NULL) - start) < (time_t)timelimit)) {
 		
 		/* read from the channel while we wait if the audio is up on it */
 		if (session && (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {

Modified: freeswitch/branches/james/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/james/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/james/src/mod/applications/mod_dptools/mod_dptools.c	Sun Aug 13 00:08:45 2006
@@ -71,16 +71,66 @@
 	}
 }
 
+static void strftime_function(switch_core_session_t *session, char *data)
+{
+	char *argv[2];
+	int argc;
+	char *lbuf;
+
+	if ((lbuf = switch_core_session_strdup(session, data))&&(argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
+		switch_size_t retsize;
+		switch_time_exp_t tm;
+		char date[80] = "";
+		switch_channel_t *channel;
+
+		channel = switch_core_session_get_channel(session);
+		assert(channel != NULL);
+
+		switch_time_exp_lt(&tm, switch_time_now());
+		switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
+		switch_channel_set_variable(channel, argv[0], date);
+	}
+}
+
+static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
+{
+	switch_size_t retsize;
+	switch_time_exp_t tm;
+	char date[80] = "";
+	
+	switch_time_exp_lt(&tm, switch_time_now());
+	switch_strftime(date, &retsize, sizeof(date), fmt, &tm);
+	stream->write_function(stream, date);
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_api_interface_t dptools_api_interface = {
+	/*.interface_name */ "strftime",
+	/*.desc */ "strftime",
+	/*.function */ strftime_api_function,
+	/*.next */ NULL
+};
+
 static const switch_application_interface_t set_application_interface = {
 	/*.interface_name */ "set",
 	/*.application_function */ set_function
 };
 
+static const switch_application_interface_t strftime_application_interface = {
+	/*.interface_name */ "strftime",
+	/*.application_function */ strftime_function,
+	NULL,NULL,NULL,
+	&set_application_interface
+
+};
+
 static const switch_application_interface_t sleep_application_interface = {
 	/*.interface_name */ "sleep",
 	/*.application_function */ sleep_function,
 	NULL,NULL,NULL,
-	&set_application_interface
+	&strftime_application_interface
 };
 
 static const switch_loadable_module_interface_t mod_dptools_module_interface = {
@@ -89,7 +139,8 @@
 	/*.timer_interface = */ NULL,
 	/*.dialplan_interface = */ NULL,
 	/*.codec_interface = */ NULL,
-	/*.application_interface */ &sleep_application_interface
+	/*.application_interface */ &sleep_application_interface,
+	/*.api_interface */ &dptools_api_interface
 };
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)

Modified: freeswitch/branches/james/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/branches/james/src/mod/codecs/mod_g711/mod_g711.c	(original)
+++ freeswitch/branches/james/src/mod/codecs/mod_g711/mod_g711.c	Sun Aug 13 00:08:45 2006
@@ -33,7 +33,7 @@
 #include "g711.h"
 
 
-static const char modname[] = "mod_g711codec";
+static const char modname[] = "mod_g711";
 
 
 static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,

Modified: freeswitch/branches/james/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/james/src/mod/codecs/mod_l16/mod_l16.c	(original)
+++ freeswitch/branches/james/src/mod/codecs/mod_l16/mod_l16.c	Sun Aug 13 00:08:45 2006
@@ -31,7 +31,7 @@
  */
 #include <switch.h>
 
-static const char modname[] = "mod_rawaudio";
+static const char modname[] = "mod_l16";
 
 
 static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,

Modified: freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/Makefile
==============================================================================
--- freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/Makefile	(original)
+++ freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/Makefile	Sun Aug 13 00:08:45 2006
@@ -1,9 +1,8 @@
-LDFLAGS += -lpcre -L/usr/local/lib
+LDFLAGS += -L/usr/local/lib
 
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
 
 depends:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install pcre-6.4.tar.gz --prefix=$(PREFIX)
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o 

Modified: freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/branches/james/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Sun Aug 13 00:08:45 2006
@@ -33,8 +33,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <pcre.h>
 
+
 static const char modname[] = "mod_dialplan_xml";
 
 #define cleanre(re)	if (re) {\
@@ -122,6 +122,13 @@
 	substituted[y++] = '\0';
 }
 
+typedef enum {
+	BREAK_ON_TRUE,
+	BREAK_ON_FALSE,
+	BREAK_ALWAYS,
+	BREAK_NEVER
+} break_t;
+
 static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, switch_caller_extension_t **extension)
 {
 	switch_xml_t xcond, xaction;
@@ -135,17 +142,50 @@
 
 	for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
 		char *field = NULL;
+		char *do_break_a = NULL;
 		char *expression = NULL;
 		char *field_data = NULL;
+		char retbuf[1024] = "";
 		pcre *re = NULL;
 		int ovector[30];
-
+		break_t do_break_i = BREAK_ON_FALSE;
+		
 		field = (char *) switch_xml_attr(xcond, "field");
+
 		expression = (char *) switch_xml_attr_soft(xcond, "expression");
-		
+
+		if ((do_break_a = (char *) switch_xml_attr(xcond, "break"))) {
+			if (!strcasecmp(do_break_a, "on-true")) {
+				do_break_i = BREAK_ON_TRUE;
+			} else if (!strcasecmp(do_break_a, "on-false")) {
+				do_break_i = BREAK_ON_FALSE;
+			} else if (!strcasecmp(do_break_a, "always")) {
+				do_break_i = BREAK_ALWAYS;
+			} else if (!strcasecmp(do_break_a, "never")) {
+				do_break_i = BREAK_NEVER;
+			}
+		}
+
 		if (field) {
 			if (*field == '$') {
 				field_data = switch_channel_get_variable(channel, field + 1);
+			} else if (*field == '%') {
+				switch_stream_handle_t stream = {0};
+				char *cmd = switch_core_session_strdup(session, field + 1);
+				char *arg;
+				
+				if (cmd) {
+					if ((arg = strchr(cmd, ' '))) {
+						*arg++ = '\0';
+					}
+					stream.data = retbuf;
+					stream.end = stream.data;
+					stream.data_size = sizeof(retbuf);
+					stream.write_function = switch_console_stream_write;
+					if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
+						field_data = retbuf;
+					}
+				}
 			} else {
 				field_data = switch_caller_get_field_by_name(caller_profile, field);
 			}
@@ -155,7 +195,27 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression);
 			if (!(proceed = perform_regex(channel, field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
-				break;
+
+				for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
+					char *application = (char*) switch_xml_attr_soft(xaction, "application");
+					char *data = (char *) switch_xml_attr_soft(xaction, "data");
+
+					if (!*extension) {
+						if ((*extension =
+							 switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+							return 0;
+						}
+					}
+					
+					switch_caller_extension_add_application(session, *extension, application, data);
+				}
+
+				if (do_break_i == BREAK_ON_FALSE || do_break_i == BREAK_ALWAYS) {
+					break;
+				} else {
+					continue;
+				}
 			}
 			assert(re != NULL);
 		}
@@ -186,6 +246,10 @@
 		}
 
 		cleanre(re);
+
+		if (do_break_i == BREAK_ON_TRUE || do_break_i == BREAK_ALWAYS) {
+			break;
+		}
 	}
 	return proceed;
 }

Modified: freeswitch/branches/james/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/james/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/james/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Sun Aug 13 00:08:45 2006
@@ -97,10 +97,12 @@
     char *ip;
     char *extip;
     char *lanaddr;
+	char *server;
     char *exten;
     char *context;
     ldl_handle_t *handle;
-    unsigned int flags;
+    uint32_t flags;
+    uint32_t user_flags;
 };
 
 struct private_object {
@@ -151,8 +153,8 @@
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string);
 
-static switch_status_t dl_login(char *arg, switch_stream_handle_t *stream);
-static switch_status_t dl_logout(char *profile_name, switch_stream_handle_t *stream);
+static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
+static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream);
 static switch_status_t channel_on_init(switch_core_session_t *session);
 static switch_status_t channel_on_hangup(switch_core_session_t *session);
 static switch_status_t channel_on_ring(switch_core_session_t *session);
@@ -1146,6 +1148,8 @@
 			if (ldl_handle_init(&handle,
 								profile->login,
 								profile->password,
+								profile->server,
+								profile->user_flags,
 								profile->message,
 								handle_loop,
 								handle_signalling,
@@ -1224,8 +1228,20 @@
 		profile->ip = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "ext-rtp-ip")) {
 		profile->extip = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "server")) {
+		profile->server = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "lanaddr")) {
 		profile->lanaddr = switch_core_strdup(module_pool, val);
+	} else if (!strcasecmp(var, "tls")) {
+		if (switch_true(val)) {
+			profile->user_flags |= LDL_FLAG_TLS;
+		}
+	} else if (!strcasecmp(var, "sasl")) {
+		if (!strcasecmp(val, "plain")) {
+			profile->user_flags |= LDL_FLAG_SASL_PLAIN;
+		} else if (!strcasecmp(val, "md5")) {
+			profile->user_flags |= LDL_FLAG_SASL_MD5;
+		}
 	} else if (!strcasecmp(var, "exten")) {
 		profile->exten = switch_core_strdup(module_pool, val);
 	} else if (!strcasecmp(var, "context")) {
@@ -1248,10 +1264,14 @@
 	}
 }
 
-static switch_status_t dl_logout(char *profile_name, switch_stream_handle_t *stream)
+static switch_status_t dl_logout(char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct mdl_profile *profile;
 
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!profile_name) {
 		stream->write_function(stream, "NO PROFILE NAME SPECIFIED\n");
 		return SWITCH_STATUS_SUCCESS;
@@ -1267,13 +1287,17 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t dl_login(char *arg, switch_stream_handle_t *stream)
+static switch_status_t dl_login(char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	char *argv[10] = {0};
 	int argc = 0;
 	char *var, *val, *myarg;
 	struct mdl_profile *profile = NULL;
 	int x;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
 
 	if (switch_strlen_zero(arg)) {
 		stream->write_function(stream, "FAIL\n");

Modified: freeswitch/branches/james/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/branches/james/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/branches/james/src/mod/endpoints/mod_exosip/mod_exosip.c	Sun Aug 13 00:08:45 2006
@@ -586,7 +586,9 @@
 		}
 	} else {
 		switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s][%s:%d]\n", err, 
+						  tech_pvt->local_sdp_audio_ip,
+						  tech_pvt->local_sdp_audio_port);
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
@@ -2095,7 +2097,7 @@
 	char *errmsg;
 
 	switch_mutex_lock(globals.reg_mutex);
-	snprintf(sql, sizeof(sql), "select url from sip_registrations where expires > 0 and expires < %ld", now);	
+	snprintf(sql, sizeof(sql), "select url from sip_registrations where expires > 0 and expires < %ld", (long) now);	
 	switch_core_db_exec(globals.db, sql, del_callback, NULL, &errmsg);
 
 	if (errmsg) {
@@ -2104,7 +2106,7 @@
 		errmsg = NULL;
 	}
 	
-	snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires < %ld", now);
+	snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires < %ld", (long) now);
 	switch_core_db_persistant_execute(globals.db, sql, 1);
 	switch_mutex_unlock(globals.reg_mutex);
 }

Modified: freeswitch/branches/james/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/james/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/branches/james/src/mod/endpoints/mod_iax/mod_iax.c	Sun Aug 13 00:08:45 2006
@@ -239,10 +239,9 @@
 		static const switch_codec_implementation_t *imp;
 		for (imp = codecs[x]; imp; imp = imp->next) {
 			unsigned int codec = iana2ast(imp->ianacode);
-		
-			if (io == IAX_QUERY) {
+			if (io == IAX_QUERY && !(codec & local_cap)) {
 				iax_pref_codec_add(iax_session, codec);
-			}
+			}	
 			local_cap |= codec;
 		}
 	}
@@ -254,6 +253,7 @@
 	}
 
 	leading = iana2ast(codecs[0]->ianacode);
+	interval = codecs[0]->microseconds_per_frame / 1000;
 	if (io == IAX_QUERY) {
 		chosen = leading;
 		*format = chosen;
@@ -638,8 +638,12 @@
 			if (!tech_pvt->read_frame.datalen) {
 				continue;
 			}
-
 			*frame = &tech_pvt->read_frame;
+#ifdef BIGENDIAN
+			if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+				switch_swap_linear((*frame)->data, (int) (*frame)->datalen);
+			}
+#endif
 			return SWITCH_STATUS_SUCCESS;
 		}
 
@@ -674,7 +678,7 @@
 	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
 		return SWITCH_STATUS_FALSE;
 	}
-#ifndef BIGENDIAN
+#ifdef BIGENDIAN
 	if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
 		switch_swap_linear(frame->data, (int) frame->datalen / 2);
 	}

Modified: freeswitch/branches/james/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/branches/james/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/branches/james/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Sun Aug 13 00:08:45 2006
@@ -116,11 +116,11 @@
 	 static int dump_info(void);
 	 static switch_status_t load_config(void);
 	 static int get_dev_by_name(char *name, int in);
-	 static switch_status_t place_call(char *dest, switch_stream_handle_t *stream);
-	 static switch_status_t hup_call(char *callid, switch_stream_handle_t *stream);
-	 static switch_status_t call_info(char *callid, switch_stream_handle_t *stream);
-	 static switch_status_t send_dtmf(char *callid, switch_stream_handle_t *stream);
-	 static switch_status_t answer_call(char *callid, switch_stream_handle_t *stream);
+	 static switch_status_t place_call(char *dest, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t hup_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t call_info(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t send_dtmf(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
+	 static switch_status_t answer_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream);
 
 /* 
    State methods they get called when the state changes to the specific state 
@@ -822,11 +822,15 @@
 	return SWITCH_STATUS_FALSE;
 }
 
-static switch_status_t place_call(char *dest, switch_stream_handle_t *stream)
+static switch_status_t place_call(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!dest) {
 		stream->write_function(stream, "Usage: pacall <exten>");
 		return SWITCH_STATUS_FALSE;
@@ -875,12 +879,16 @@
 }
 
 
-static switch_status_t hup_call(char *callid, switch_stream_handle_t *stream)
+static switch_status_t hup_call(char *callid, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt;
 	switch_channel_t *channel = NULL;
 	char tmp[50];
 
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (callid && !strcasecmp(callid, "last")) {
 		snprintf(tmp, sizeof(tmp), "%d", globals.call_id - 1);
 		callid = tmp;
@@ -919,12 +927,16 @@
 }
 
 
-static switch_status_t send_dtmf(char *callid, switch_stream_handle_t *stream)
+static switch_status_t send_dtmf(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt = NULL;
 	switch_channel_t *channel = NULL;
 	char *dtmf;
 
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if ((dtmf = strchr(callid, ' ')) != 0) {
 		*dtmf++ = '\0';
 	} else {
@@ -943,12 +955,16 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t answer_call(char *callid, switch_stream_handle_t *stream)
+static switch_status_t answer_call(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt = NULL;
 	switch_channel_t *channel = NULL;
 
-	if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (callid && (tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
 		channel = switch_core_session_get_channel(tech_pvt->session);
 		assert(channel != NULL);
 		switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
@@ -975,11 +991,16 @@
 
 }
 
-static switch_status_t call_info(char *callid, switch_stream_handle_t *stream)
+static switch_status_t call_info(char *callid, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	struct private_object *tech_pvt;
 	switch_hash_index_t *hi;
 	void *val;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!callid || !strcasecmp(callid, "all")) {
 		for (hi = switch_hash_first(module_pool, globals.call_hash); hi; hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_cdr/Makefile
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_cdr/Makefile	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_cdr/Makefile	Sun Aug 13 00:08:45 2006
@@ -1,7 +1,7 @@
 LDFLAGS += -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
 CFLAGS += -I/usr/include/mysql -L/usr/lib64/mysql 
 CPPCC = g++
-OBJS=cdrcontainer.o basecdr.o baseregistry.o mysqlcdr.o pddcdr.o
+OBJS=cdrcontainer.o basecdr.o baseregistry.o mysqlcdr.o pddcdr.o csvcdr.o
 
 
 all:	depends $(OBJS) $(MODNAME).$(DYNAMIC_LIB_EXTEN)

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_cdr/README
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_cdr/README	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_cdr/README	Sun Aug 13 00:08:45 2006
@@ -49,7 +49,7 @@
 
 Class:		MysqlCDR, located in mysqlcdr.h and mysqlcdr.cpp
 Description:	This class logs the call detail record to a MySQL 4.1.x or greater database using prepared
-		statements.  This class is a little more complex than the prior two in that the fixed channel variables are treated as additional columns on the main freeswitchcdr database table for improved normalization of the database.  As such, you need to specify the format of each fixed channel variable as well.  If you do not specify, it will default to a varchar column type, and will not execute if the table schema does not match.  Therefore it is very important to make sure that any fixed channel variables you log exist as columns on the table.  The supplemental channel variables are stored in a separate table using a key / value pair linking to the callid of the call.
+		statements.  This class is a little more complex than the prior two in that the fixed channel variables are treated as additional columns on the main freeswitchcdr database table for improved normalization of the database.  As such, you need to specify the format of each fixed channel variable as well.  If you do not specify, it will default to a varchar column type, and will not execute if the table schema does not match.  Therefore it is very important to make sure that any fixed channel variables you log exist as columns on the table.  The supplemental channel variables are stored in a separate table using a key / value pair linking to the callid of the call.  Recommended to use at least one other logger in conjuction with this one just to be on the safe side, as failover handling of errors to write to the db are not yet implemented, and therefore there is a risk of data loss if the database connection is lost entirely (it will be limited to only those records created at the time of the loss of connection) or some other fatal error is encountered.
 Configuration:	Section: <mysqlcdr>
 		<param name="hostname" value=""/> value is the hostname or IP of the MySQL server (required)
 		<param name="username" value=""/> value is the username to connect to the MySQL server with (required)

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_cdr/basecdr.cpp	Sun Aug 13 00:08:45 2006
@@ -59,6 +59,7 @@
 {
 	if(newchannel != 0)
 	{
+		errorstate = 0;
 		memset(clid,0,80);
 		memset(dialplan,0,80);
 		memset(myuuid,0,37);
@@ -84,9 +85,10 @@
 		if(newchannel->callerprofile->caller_id_name != 0)
 		{
 			strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
-			strncat(clid," ",1);
+			strncat(clid," <",2);
 			if(newchannel->callerprofile->caller_id_number != 0 )
 				strncat(clid,newchannel->callerprofile->caller_id_number,strlen(clid)+strlen(newchannel->callerprofile->caller_id_number));
+			strncat(clid,">",1);
 		}
 		
 		// Get the ANI information if it's set
@@ -100,9 +102,7 @@
 	
 		if(newchannel->callerprofile->network_addr != 0)
 			strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
-		
-		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Channel caller_profile loaded.\n");
-		
+				
 		originated = newchannel->originate;
 	
 		if(newchannel->originateprofile->uuid != 0)
@@ -146,8 +146,6 @@
 		hangupcause = switch_channel_get_cause(newchannel->channel);
 		hangupcause_text = switch_channel_cause2str(hangupcause);
 	
-		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Call state & length calculated.\n");
-		
 		if(newchannel->callerextension != 0)
 			if(newchannel->callerextension->last_application != 0)
 			{
@@ -158,8 +156,6 @@
 			}
 		
 		amaflags=0;
-		
-		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Processing completed.\n");
 	}
 }
 

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	Sun Aug 13 00:08:45 2006
@@ -83,10 +83,10 @@
 std::list<std::string> MysqlCDR::chanvars_supp_list;
 std::vector<switch_mod_cdr_sql_types_t> MysqlCDR::chanvars_fixed_types;
 bool MysqlCDR::activated = 0;
-char* MysqlCDR::sql_query = 0;
+char MysqlCDR::sql_query[1024] = "";
 std::string MysqlCDR::tmp_sql_query;
 char MysqlCDR::sql_query_chanvars[100] = "";
-MYSQL* MysqlCDR:: conn = 0;
+MYSQL* MysqlCDR::conn = 0;
 MYSQL_STMT* MysqlCDR::stmt=0;
 MYSQL_STMT* MysqlCDR::stmt_chanvars=0;
 char MysqlCDR::hostname[255] = "";
@@ -208,38 +208,38 @@
 			}
 			
 			tmp_sql_query.append(")");
-			
-			std::vector<char> tempfirstvector(tmp_sql_query.begin(), tmp_sql_query.end());
-			tempfirstvector.push_back('\0');
-			sql_query = &tempfirstvector[0];
 	
 			char tempsql_query_chanvars[] = "INSERT INTO chanvars (callid,varname,varvalue) VALUES(?,?,?)";
 			memset(sql_query_chanvars,0,100);
 			strncpy(sql_query_chanvars,tempsql_query_chanvars,strlen(tempsql_query_chanvars));
 
-			conn = mysql_init(NULL);
-			mysql_options(conn, MYSQL_READ_DEFAULT_FILE, "");
-			if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL)
-			{
-				char *error1 = "Cannot connect to MySQL Server.  The error was: ";
-				const char *error2 = mysql_error(conn);
-				strncat(error1,error2,strlen(error2));
-				switch_console_printf(SWITCH_CHANNEL_LOG,error1);
-			}
-			else
-				connectionstate = 1;
+			strncpy(sql_query,tmp_sql_query.c_str(),tmp_sql_query.size());
+			connect_to_database();
+		}
+	}
+}
+
+void MysqlCDR::connect_to_database()
+{
+	conn = mysql_init(NULL);
+	mysql_options(conn, MYSQL_READ_DEFAULT_FILE, "");
+	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);
+	}
+	else
+		connectionstate = 1;
 	
-			mysql_autocommit(conn,0);
-			stmt = mysql_stmt_init(conn);
+	mysql_autocommit(conn,0);
+	stmt = mysql_stmt_init(conn);
 		
-			mysql_stmt_prepare(stmt,sql_query,(long unsigned int)strlen(sql_query));
+	mysql_stmt_prepare(stmt,sql_query,(long unsigned int)strlen(sql_query));
 		
-			if(logchanvars)
-			{
-				stmt_chanvars = mysql_stmt_init(conn);
-				mysql_stmt_prepare(stmt_chanvars,sql_query_chanvars,(long unsigned int)strlen(sql_query_chanvars));
-			}
-		}
+	if(logchanvars)
+	{
+		stmt_chanvars = mysql_stmt_init(conn);
+		mysql_stmt_prepare(stmt_chanvars,sql_query_chanvars,(long unsigned int)strlen(sql_query_chanvars));
 	}
 }
 
@@ -390,10 +390,8 @@
 					*x = 0;
 					bool* is_null = new bool;
 					*is_null = 0;
-					std::cout << "CDR_TINY: " << iItr->second << " and its size is " << iItr->second.size() << " bytes." << std::endl << std::endl;
 					if(iItr->second.size() > 0)
 					{
-						std::cout << "Converting iItr->second to type char." << std::endl;
 						std::istringstream istring(iItr->second);
 						istring >> *x;
 					}
@@ -433,75 +431,93 @@
 	bindmetemp = new MYSQL_BIND[bindme.size()];
 	copy(bindme.begin(), bindme.end(), bindmetemp);
 	
-	mysql_stmt_bind_param(stmt,bindmetemp);
-	int bah = mysql_stmt_execute(stmt);
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",bah);
-	
-	const char* bah2 = mysql_stmt_error(stmt);
-	switch_console_printf(SWITCH_CHANNEL_LOG,"MySQL encountered error: %s\n",bah2);
-		
-	if(logchanvars && chanvars_supp.size() > 0)
+	for(int mysql_ping_result = -1, count = 0, mysql_stmt_error_code = -1; mysql_ping_result != 0 && count < 5 && mysql_stmt_error_code != 0 ; count++)
 	{
-		long long insertid = mysql_stmt_insert_id(stmt);
-
-		std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
-		iEnd = chanvars_supp.end();
-		for(iItr = chanvars_supp.begin(); iItr != iEnd; iItr++)
+		mysql_ping_result = mysql_ping(conn);
+		if(mysql_ping_result)
 		{
-			MYSQL_BIND bindme_chanvars[3];
-			memset(bindme_chanvars,0,sizeof(bindme_chanvars));
+			switch(mysql_ping_result)
+			{
+				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");
+					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");
+					connect_to_database();
+				}
+			}
+		}
+		else
+		{
+			mysql_stmt_bind_param(stmt,bindmetemp);
+			mysql_stmt_error_code = mysql_stmt_execute(stmt);
 			
-			bindme_chanvars[0].buffer_type = MYSQL_TYPE_LONGLONG;
-			bindme_chanvars[0].buffer = &insertid;
+			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);
 			
-			std::vector<char> tempfirstvector(iItr->first.begin(), iItr->first.end());
-			tempfirstvector.push_back('\0');
-			char* varname_temp = &tempfirstvector[0];
+				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);
+			}
+			else
+				errorstate = 0;
+			
+			if(logchanvars && chanvars_supp.size() > 0 && errorstate == 0)
+			{
+				long long insertid = mysql_stmt_insert_id(stmt);
 
-			bindme_chanvars[1].buffer_type = MYSQL_TYPE_VAR_STRING;
-			long unsigned int varname_length = (long unsigned int)(iItr->first.size());
-			bindme_chanvars[1].length = &varname_length;
-			bindme_chanvars[1].buffer_length = varname_length;
-			bindme_chanvars[1].buffer = varname_temp;
+				std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
+				iEnd = chanvars_supp.end();
+				for(iItr = chanvars_supp.begin(); iItr != iEnd; iItr++)
+				{
+					MYSQL_BIND bindme_chanvars[3];
+					memset(bindme_chanvars,0,sizeof(bindme_chanvars));
 			
-			std::vector<char> tempsecondvector(iItr->second.begin(), iItr->second.end());
-			tempsecondvector.push_back('\0');
-			char* varvalue_temp = &tempsecondvector[0];
+					bindme_chanvars[0].buffer_type = MYSQL_TYPE_LONGLONG;
+					bindme_chanvars[0].buffer = &insertid;
 			
-			bindme_chanvars[2].buffer_type = MYSQL_TYPE_VAR_STRING;
-			if(iItr->second.size() == 0)
-				bindme_chanvars[2].is_null = (my_bool*)1;
-			else
-			{
-				long unsigned int varvalue_length = (long unsigned int)(iItr->second.size());
-				bindme_chanvars[2].length = &varvalue_length;
-				bindme_chanvars[2].buffer_length = varvalue_length;
-				bindme_chanvars[2].buffer = varvalue_temp;
+					std::vector<char> tempfirstvector(iItr->first.begin(), iItr->first.end());
+					tempfirstvector.push_back('\0');
+					char* varname_temp = &tempfirstvector[0];
+
+					bindme_chanvars[1].buffer_type = MYSQL_TYPE_VAR_STRING;
+					long unsigned int varname_length = (long unsigned int)(iItr->first.size());
+					bindme_chanvars[1].length = &varname_length;
+					bindme_chanvars[1].buffer_length = varname_length;
+					bindme_chanvars[1].buffer = varname_temp;
+			
+					std::vector<char> tempsecondvector(iItr->second.begin(), iItr->second.end());
+					tempsecondvector.push_back('\0');
+					char* varvalue_temp = &tempsecondvector[0];
+			
+					bindme_chanvars[2].buffer_type = MYSQL_TYPE_VAR_STRING;
+					if(iItr->second.size() == 0)
+						bindme_chanvars[2].is_null = (my_bool*)1;
+					else
+					{
+						long unsigned int varvalue_length = (long unsigned int)(iItr->second.size());
+						bindme_chanvars[2].length = &varvalue_length;
+						bindme_chanvars[2].buffer_length = varvalue_length;
+						bindme_chanvars[2].buffer = varvalue_temp;
+					}
+			
+					mysql_stmt_bind_param(stmt_chanvars,bindme_chanvars);
+					mysql_stmt_execute(stmt_chanvars);
+				}
 			}
 			
-			mysql_stmt_bind_param(stmt_chanvars,bindme_chanvars);
-			mysql_stmt_execute(stmt_chanvars);
+			if(errorstate == 0)
+				mysql_commit(conn);
+			else
+				mysql_rollback(conn);
 		}
 	}
-	
-	
-	mysql_commit(conn);
-	
-	/* For future use
-	if(!mysql_stmt_execute(stmt))
-	{
-		if(errorstate == TRUE)
-			reprocess_tempdumped_data();
-		mysql_commit(conn);
-		errorstate=FALSE();
-	}
-	else
-	{
-		errorstate = TRUE;
-		mysql_rollback(conn);
-		tempdump_data();
-	}
-	*/
 	
 	delete [] bindmetemp;
 	if(temp_chanvars_holder.size() > 0)

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.h
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.h	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_cdr/mysqlcdr.h	Sun Aug 13 00:08:45 2006
@@ -36,6 +36,7 @@
 #include <list>
 #include <sstream>
 #include <mysql.h>
+#include <errmsg.h>
 
 #ifndef MYSQLCDR
 #define MYSQLCDR
@@ -55,7 +56,7 @@
 
 	private:
 		static bool activated;
-		static char *sql_query;
+		static char sql_query[1024];
 		static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
 		static char sql_query_chanvars[100];
 		static MYSQL *conn;
@@ -94,6 +95,7 @@
 		template <typename T> void add_parameter(T& param, enum_field_types type, bool *is_null=0);
 		void add_string_parameter(char* param, long unsigned int& param_length, enum_field_types type, bool* is_null=0);
 		void set_mysql_time(switch_time_exp_t& param, MYSQL_TIME& destination);
+		void connect_to_database();
 };
 
 #endif

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Sun Aug 13 00:08:45 2006
@@ -31,8 +31,8 @@
  */
 #include <switch.h>
 #define CMD_BUFLEN 1024 * 1000
+#define IS_BREAK(x) ((int)x || SWITCH_STATUS_BREAK || (int)x == 730035 || (int)x == 35)
 
-
 static const char modname[] = "mod_event_socket";
 static char *MARKER = "1";
 
@@ -114,15 +114,28 @@
 	
 	switch_mutex_lock(listen_list.mutex);
 	for (l = listen_list.listeners; l; l = l->next) {
-		if (switch_test_flag(l, LFLAG_EVENTS) && (l->event_list[(uint8_t)event->event_id] || l->event_list[(uint8_t)SWITCH_EVENT_ALL])) {
+		uint8_t send = 0;
+
+		if (!switch_test_flag(l, LFLAG_EVENTS)) {
+			continue;
+		}
+
+		if (l->event_list[(uint8_t)SWITCH_EVENT_ALL]) {
+			send = 1;
+		} else if ((l->event_list[(uint8_t)event->event_id])) {
 			if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
-				if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
-					switch_queue_push(l->event_queue, clone);
-				} else {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
-				}
+				send = 1;
 			}
 		}
+
+		if (send) {
+			if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
+				switch_queue_push(l->event_queue, clone);
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+			}
+		}
+
 	}
 	switch_mutex_unlock(listen_list.mutex);
 }
@@ -149,7 +162,14 @@
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
+	listener_t *l;
 
+	switch_mutex_lock(listen_list.mutex);
+	for (l = listen_list.listeners; l; l = l->next) {
+		close_socket(&l->sock);
+	}
+	switch_mutex_unlock(listen_list.mutex);
+
 	close_socket(&listen_list.sock);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -201,8 +221,167 @@
 	}
 }
 
-static void parse_command(listener_t *listener, char *cmd, char *reply, uint32_t reply_len)
+static switch_status_t read_packet(listener_t *listener, switch_event_t **event, uint32_t timeout) 
 {
+	switch_size_t mlen;
+	char mbuf[1024] = "";
+	char buf[1024] = "";
+	switch_size_t len;
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	int count = 0, bytes = 0;
+	uint32_t elapsed = 0;
+	time_t start = 0;
+	void *pop;
+	char *ptr;
+	uint8_t crcount = 0;
+
+	*event = NULL;
+	start = time(NULL);
+	ptr = mbuf;
+
+	while(listener->sock) {
+		uint8_t do_sleep = 1;
+		mlen = 1;
+		status = switch_socket_recv(listener->sock, ptr, &mlen);
+
+		if (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS) {
+			return SWITCH_STATUS_FALSE;
+		}
+
+		if (mlen) {
+			bytes++;
+			do_sleep = 0;
+
+			if (*mbuf == '\r' || *mbuf == '\n') { /* bah */
+				ptr = mbuf;
+				mbuf[0] = '\0';
+				continue;
+			}
+
+			if (*ptr == '\n') {
+				crcount++;
+			} else if (*ptr != '\r') {
+				crcount = 0;
+			}
+			ptr++;
+			if (crcount == 2) {
+				char *next;
+				char *cur = mbuf;
+
+				while(cur) {
+					if ((next = strchr(cur, '\r')) || (next = strchr(cur, '\n'))) {
+						while (*next == '\r' || *next == '\n') {
+							next++;
+						}
+					}
+					count++;
+					if (count == 1) {
+						switch_event_create(event, SWITCH_EVENT_MESSAGE);
+						switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Command", mbuf);
+					} else {
+						char *var, *val;
+						var = mbuf;
+						if ((val = strchr(var, ':'))) {
+							*val++ = '\0';
+							while(*val == ' ') {
+								val++;
+							}
+						} 
+						if (var && val) {
+							switch_event_add_header(*event, SWITCH_STACK_BOTTOM, var, val);
+						}
+					}
+					
+					cur = next;
+				}
+				break;
+			}
+		}
+
+		if (timeout) {
+			elapsed = (uint32_t)(time(NULL) - start);
+			if (elapsed >= timeout) {
+				switch_clear_flag_locked(listener, LFLAG_RUNNING);
+				return SWITCH_STATUS_FALSE;
+			}
+		}
+		
+		if (!*mbuf) {
+			if (switch_test_flag(listener, LFLAG_LOG)) {
+				if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+					char *data = (char *) pop;
+
+
+					if (data) {
+						snprintf(buf, sizeof(buf), "Content-Type: log/data\nContent-Length: %"APR_SSIZE_T_FMT"\n\n", strlen(data));
+						len = strlen(buf) + 1;
+						switch_socket_send(listener->sock, buf, &len);
+						len = strlen(data) + 1;
+						switch_socket_send(listener->sock, data, &len);
+					
+						free(data);
+					}
+					do_sleep = 0;
+				}
+			}
+
+			if (switch_test_flag(listener, LFLAG_EVENTS)) {
+				if (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+					char hbuf[512];
+					switch_event_t *event = (switch_event_t *) pop;
+					char *etype, *packet, *xmlstr = NULL;
+
+					do_sleep = 0;
+					if (listener->format == EVENT_FORMAT_PLAIN) {
+						etype = "plain";
+						switch_event_serialize(event, buf, sizeof(buf), NULL);
+						packet = buf;
+					} else {
+						switch_xml_t xml;
+						etype = "xml";
+
+						if ((xml = switch_event_xmlize(event, NULL))) {
+							xmlstr = switch_xml_toxml(xml);
+							packet = xmlstr;
+							switch_xml_free(xml);
+						} else {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML ERROR!\n");
+							continue;
+						}
+					}
+			
+					len = strlen(packet) + 1;
+
+					snprintf(hbuf, sizeof(hbuf), "Content-Length: %"APR_SSIZE_T_FMT"\n" 
+							 "Content-Type: text/event-%s\n"
+							 "\n", len, etype);
+
+					len = strlen(hbuf) + 1;
+					switch_socket_send(listener->sock, hbuf, &len);
+
+					len = strlen(packet) + 1;
+					switch_socket_send(listener->sock, packet, &len);
+
+					if (xmlstr) {
+						free(xmlstr);
+					}
+				}
+			}
+		}
+		if (do_sleep) {
+			switch_yield(1000);
+		}
+	}
+	
+	return status;
+
+}
+
+static switch_status_t parse_command(listener_t *listener, switch_event_t *event, char *reply, uint32_t reply_len)
+{
+	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	char *cmd = switch_event_get_header(event, "command");
+
 	*reply = '\0';
 
 	if (!strncasecmp(cmd, "exit", 4)) {
@@ -252,7 +431,7 @@
 			*arg++ = '\0';
 		}
 		
-		if (switch_api_execute(api_cmd, arg, &stream) == SWITCH_STATUS_SUCCESS) {
+		if (switch_api_execute(api_cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
 			switch_size_t len;
 			char buf[1024];
 
@@ -262,7 +441,7 @@
 			switch_socket_send(listener->sock, buf, &len);
 			len = strlen(listener->retbuf) + 1;
 			switch_socket_send(listener->sock, listener->retbuf, &len);
-			return;
+			return SWITCH_STATUS_SUCCESS;
 		} 
 	} else if (!strncasecmp(cmd, "log", 3)) {
 
@@ -282,6 +461,9 @@
 			snprintf(reply, reply_len, "-ERR invalid log level");
 		}
 	} else if (!strncasecmp(cmd, "nolog", 5)) {
+		void *pop;
+		while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS);
+		
 		if (switch_test_flag(listener, LFLAG_LOG)) {
 			switch_clear_flag_locked(listener, LFLAG_LOG);
 			snprintf(reply, reply_len, "+OK no longer logging");
@@ -341,6 +523,9 @@
 		snprintf(reply, reply_len, "+OK event listener enabled %s", listener->format == EVENT_FORMAT_XML ? "xml" : "plain");
 		
 	} else if (!strncasecmp(cmd, "noevents", 8)) {
+		void *pop;
+		while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS);
+
 		if (switch_test_flag(listener, LFLAG_EVENTS)) {
 			uint8_t x = 0;
 			switch_clear_flag_locked(listener, LFLAG_EVENTS);
@@ -356,10 +541,15 @@
 	} 
 	
  done:
+	if (event) {
+		switch_event_destroy(&event);
+	}
+
 	if (switch_strlen_zero(reply)) {
 		snprintf(reply, reply_len, "-ERR command not found");
 	}
 
+	return status;
 }
 
 static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
@@ -368,9 +558,7 @@
 	char buf[1024];
 	switch_size_t len;
 	switch_status_t status;
-	void *pop;
-	uint32_t elapsed;
-	time_t start = 0;
+	switch_event_t *event;
 	char reply[512] = "";
 
 	assert(listener != NULL);
@@ -386,126 +574,59 @@
 	len = strlen(buf) + 1;
 	switch_socket_send(listener->sock, buf, &len);
 		
-	start = time(NULL);
 
-	while(!switch_test_flag(listener, LFLAG_AUTHED)) {
-		len = sizeof(buf);
-		memset(buf, 0, len);
-		status = switch_socket_recv(listener->sock, buf, &len);
-		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-			break;
-		}
-
-		if (len) {
-			parse_command(listener, buf, reply, sizeof(reply));
-			if (!switch_strlen_zero(reply)) {
-				snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
-				len = strlen(buf) + 1;
-				switch_socket_send(listener->sock, buf, &len);
-			}
+	while (!switch_test_flag(listener, LFLAG_AUTHED)) {
+		
+		status = read_packet(listener, &event, 25);
+		if (status != SWITCH_STATUS_SUCCESS) {
 			goto done;
 		}
-		
-		if (status == SWITCH_STATUS_BREAK) {
-			elapsed = (uint32_t)(time(NULL) - start);
-			if (elapsed >= 15) {
-				switch_clear_flag_locked(listener, LFLAG_RUNNING);
-				break;
-			}
-
-			//switch_yield(1000);
+		if (!event) {
 			continue;
 		}
-
+		if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			goto done;
+		}
+		if (!switch_strlen_zero(reply)) {
+			snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
+			len = strlen(buf) + 1;
+			switch_socket_send(listener->sock, buf, &len);
+		}
+		break;
 	}
 		
- done:
 
 	while(switch_test_flag(listener, LFLAG_RUNNING) && listen_list.ready) {
-		uint8_t do_sleep = 1;
+		switch_event_t *event;
+
 		len = sizeof(buf);
 		memset(buf, 0, len);
-		status = switch_socket_recv(listener->sock, buf, &len);
+		status = read_packet(listener, &event, 0);
 		
-		if (!len && status != SWITCH_STATUS_BREAK) {
+		if (status != SWITCH_STATUS_SUCCESS) {
 			break;
 		}
-		
-		if (len) {
-			parse_command(listener, buf, reply, sizeof(reply));
-			if (!switch_strlen_zero(reply)) {
-				snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
-				len = strlen(buf) + 1;
-				switch_socket_send(listener->sock, buf, &len);
-			}
+
+		if (!event) {
 			continue;
 		}
 
-		if (switch_test_flag(listener, LFLAG_LOG)) {
-			if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-				char *data = (char *) pop;
-				if (data) {
-					snprintf(buf, sizeof(buf), "Content-Type: log/data\nContent-Length: %"APR_SSIZE_T_FMT"\n\n", strlen(data));
-					len = strlen(buf) + 1;
-					switch_socket_send(listener->sock, buf, &len);
-					len = strlen(data) + 1;
-					switch_socket_send(listener->sock, data, &len);
-					
-					free(data);
-				}
-				do_sleep = 0;
-			}
+		if (parse_command(listener, event, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
+			switch_clear_flag_locked(listener, LFLAG_RUNNING);
+			break;
 		}
 
-		if (switch_test_flag(listener, LFLAG_EVENTS)) {
-			if (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-				char hbuf[512];
-				switch_event_t *event = (switch_event_t *) pop;
-				char *etype, *packet, *xmlstr = NULL;
 
-				do_sleep = 0;
-				if (listener->format == EVENT_FORMAT_PLAIN) {
-					etype = "plain";
-					switch_event_serialize(event, buf, sizeof(buf), NULL);
-					packet = buf;
-				} else {
-					switch_xml_t xml;
-					etype = "xml";
-
-					if ((xml = switch_event_xmlize(event, NULL))) {
-						xmlstr = switch_xml_toxml(xml);
-						packet = xmlstr;
-						switch_xml_free(xml);
-					} else {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML ERROR!\n");
-						continue;
-					}
-				}
-			
-				len = strlen(packet) + 1;
-
-				snprintf(hbuf, sizeof(hbuf), "Content-Length: %"APR_SSIZE_T_FMT"\n" 
-						 "Content-Type: text/event-%s\n"
-						 "\n", len, etype);
-
-				len = strlen(hbuf) + 1;
-				switch_socket_send(listener->sock, hbuf, &len);
-
-				len = strlen(packet) + 1;
-				switch_socket_send(listener->sock, packet, &len);
-			
-				switch_event_destroy(&event);
-
-				if (xmlstr) {
-					free(xmlstr);
-				}
-			}
+		if (!switch_strlen_zero(reply)) {
+			snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
+			len = strlen(buf) + 1;
+			switch_socket_send(listener->sock, buf, &len);
 		}
-
-		if (do_sleep) {
-			switch_yield(1000);
-		}
+			
 	}
+
+ done:
 
 	remove_listener(listener);
 	close_socket(&listener->sock);

Modified: freeswitch/branches/james/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
==============================================================================
--- freeswitch/branches/james/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c	(original)
+++ freeswitch/branches/james/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c	Sun Aug 13 00:08:45 2006
@@ -240,7 +240,7 @@
 	stream.end = stream.data;
 	stream.data_size = sizeof(retbuf);
 	stream.write_function = switch_console_stream_write;
-	switch_api_execute(cmd, arg, &stream);
+	switch_api_execute(cmd, arg, NULL, &stream);
 
 	return 0;
 }

Modified: freeswitch/branches/james/src/mod/formats/mod_sndfile/Makefile
==============================================================================
--- freeswitch/branches/james/src/mod/formats/mod_sndfile/Makefile	(original)
+++ freeswitch/branches/james/src/mod/formats/mod_sndfile/Makefile	Sun Aug 13 00:08:45 2006
@@ -3,7 +3,7 @@
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
 
 depends:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsndfile-1.0.12.tar.gz --prefix=$(PREFIX)
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsndfile-1.0.16.tar.gz --prefix=$(PREFIX)
 
 $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
 	$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o 

Modified: freeswitch/branches/james/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/branches/james/src/mod/formats/mod_sndfile/mod_sndfile.c	(original)
+++ freeswitch/branches/james/src/mod/formats/mod_sndfile/mod_sndfile.c	Sun Aug 13 00:08:45 2006
@@ -213,6 +213,26 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t sndfile_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
+{
+	sndfile_context *context = handle->private_info;
+
+	return sf_set_string(context->handle, (int)col, string) ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
+{
+	sndfile_context *context = handle->private_info;
+	const char *s;
+
+	if ((s = sf_get_string(context->handle, (int)col))) {
+		*string = s;
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
 /* Registration */
 
 static char **supported_formats;
@@ -224,6 +244,8 @@
 	/*.file_read */ sndfile_file_read,
 	/*.file_write */ sndfile_file_write,
 	/*.file_seek */ sndfile_file_seek,
+	/*.file_set_string */ sndfile_file_set_string,
+	/*.file_get_string */ sndfile_file_get_string,
 	/*.extens */ NULL,
 	/*.next */ NULL,
 };
@@ -265,7 +287,7 @@
 
 	sfinfo.channels = 1;
 	len = ((major_count + (exlen + 2)) * sizeof(char *));
-	supported_formats = switch_core_permenant_alloc(len);
+	supported_formats = switch_core_permanent_alloc(len);
 
 	len = 0;
 	for (m = 0; m < major_count; m++) {

Modified: freeswitch/branches/james/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/james/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/james/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Sun Aug 13 00:08:45 2006
@@ -1705,12 +1705,15 @@
 				}
 
 			} else {
-				if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) {
+				switch_status_t status;
+				status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+				
+				if (!SWITCH_READ_ACCEPTABLE(status)) {
 					break;
 				}
 			}
 			if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
-				if (loops > 0) { 
+				if (loops) { 
 					switch_buffer_t *tmp;
 
 					/* Switcharoo*/
@@ -1719,11 +1722,12 @@
 					tto->loop_buffer = tmp;
 					loops--;
 					/* try again */
-					if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+					if ((write_frame.datalen = 
+						 (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
 						break;
 					}
 				} else {
-					continue;
+					break;
 				}
 			}
 
@@ -1838,13 +1842,25 @@
 	if (argc > 1) {
 		char *cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		switch_core_session_t *session = NULL;
 		switch_stream_handle_t stream = {0};
 		char retbuf[2048] = "";
 
+		if (argc > 2) {
+			JSObject *session_obj;
+			struct js_session *jss;
+			if (JS_ValueToObject(cx, argv[2], &session_obj)) {
+				if ((jss = JS_GetPrivate(cx, session_obj))) {
+					session = jss->session;
+				}
+			}
+		}
+		
+		
 		stream.data = retbuf;
 		stream.end = stream.data;
 		stream.data_size = sizeof(retbuf);
-		switch_api_execute(cmd, arg, &stream);
+		switch_api_execute(cmd, arg, session, &stream);
 		stream.write_function = switch_console_stream_write;
 
 		*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, retbuf));
@@ -2203,7 +2219,7 @@
 }
 
 
-static switch_status_t launch_async(char *text, switch_stream_handle_t *stream)
+static switch_status_t launch_async(char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 
 	if (switch_strlen_zero(text)) {

Modified: freeswitch/branches/james/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/branches/james/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	(original)
+++ freeswitch/branches/james/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	Sun Aug 13 00:08:45 2006
@@ -272,7 +272,7 @@
 	ResponseStatus(r,200);
 	ResponseContentType(r, m);
     ResponseWrite(r);
-	switch_api_execute(command, r->query, &stream);
+	switch_api_execute(command, r->query, NULL, &stream);
 	HTTPWriteEnd(r);
     return TRUE;
 }
@@ -296,7 +296,7 @@
 	stream.end = stream.data;
 	stream.data_size = CMDLEN;
 	stream.write_function = switch_console_stream_write;
-	switch_api_execute(command, arg, &stream);
+	switch_api_execute(command, arg, NULL, &stream);
 
     /* Return our result. */
     val = xmlrpc_build_value(envP, "s", retbuf);

Modified: freeswitch/branches/james/src/switch.c
==============================================================================
--- freeswitch/branches/james/src/switch.c	(original)
+++ freeswitch/branches/james/src/switch.c	Sun Aug 13 00:08:45 2006
@@ -84,10 +84,6 @@
 	nice(-20);
 #endif
 
-#ifdef HAVE_MLOCKALL
-	mlockall(MCL_CURRENT|MCL_FUTURE);
-#endif
-
 #ifndef WIN32
 	if (argv[1] && !strcmp(argv[1], "-stop")) {
 		pid_t pid = 0;
@@ -181,6 +177,11 @@
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready");
 		switch_event_fire(&event);
 	}
+
+#ifdef HAVE_MLOCKALL
+	mlockall(MCL_CURRENT|MCL_FUTURE);
+#endif
+
 
 #ifdef CRASH_PROT
 #define __CP "ENABLED"

Modified: freeswitch/branches/james/src/switch_console.c
==============================================================================
--- freeswitch/branches/james/src/switch_console.c	(original)
+++ freeswitch/branches/james/src/switch_console.c	Sun Aug 13 00:08:45 2006
@@ -108,7 +108,7 @@
 	stream.end = stream.data;
 	stream.data_size = retlen;
 	stream.write_function = switch_console_stream_write;
-	if (switch_api_execute(cmd, arg, &stream) == SWITCH_STATUS_SUCCESS) {
+	if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unknown Command: %s\n", cmd);

Modified: freeswitch/branches/james/src/switch_core.c
==============================================================================
--- freeswitch/branches/james/src/switch_core.c	(original)
+++ freeswitch/branches/james/src/switch_core.c	Sun Aug 13 00:08:45 2006
@@ -543,9 +543,26 @@
 SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples,
 													int whence)
 {
+	assert(fh != NULL);
 	return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
 }
 
+SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
+{
+	assert(fh != NULL);
+
+	return fh->file_interface->file_set_string(fh, col, string);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
+{
+	assert(fh != NULL);
+	
+	return fh->file_interface->file_get_string(fh, col, string);
+
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
 {
 	return fh->file_interface->file_close(fh);
@@ -840,9 +857,9 @@
 }
 
 /* **ONLY** alloc things with these functions that **WILL NOT** need
-   to be freed *EVER* ie this is for *PERMENANT* memory allocation */
+   to be freed *EVER* ie this is for *PERMANENT* memory allocation */
 
-SWITCH_DECLARE(void *) switch_core_permenant_alloc(switch_size_t memory)
+SWITCH_DECLARE(void *) switch_core_permanent_alloc(switch_size_t memory)
 {
 	void *ptr = NULL;
 	assert(runtime.memory_pool != NULL);
@@ -857,7 +874,7 @@
 	return ptr;
 }
 
-SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup)
+SWITCH_DECLARE(char *) switch_core_permanent_strdup(char *todup)
 {
 	char *duped = NULL;
 	switch_size_t len;

Modified: freeswitch/branches/james/src/switch_event.c
==============================================================================
--- freeswitch/branches/james/src/switch_event.c	(original)
+++ freeswitch/branches/james/src/switch_event.c	Sun Aug 13 00:08:45 2006
@@ -112,6 +112,7 @@
 	"SESSION_CRASH",
 	"MODULE_LOAD",
 	"DTMF",
+	"MESSAGE",
 	"ALL"
 };
 

Modified: freeswitch/branches/james/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/james/src/switch_ivr.c	(original)
+++ freeswitch/branches/james/src/switch_ivr.c	Sun Aug 13 00:08:45 2006
@@ -214,6 +214,8 @@
 	switch_codec_t codec, *read_codec;
 	char *codec_name;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	char *p;
+	const char *vval;
 
 	if (!fh) {
 		fh = &lfh;
@@ -241,6 +243,41 @@
 
 	switch_channel_answer(channel);
 
+	if ((p = switch_channel_get_variable(channel, "RECORD_TITLE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_TITLE, vval);
+		switch_channel_set_variable(channel, "RECORD_TITLE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COPYRIGHT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COPYRIGHT, vval);
+		switch_channel_set_variable(channel, "RECORD_COPYRIGHT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_SOFTWARE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_SOFTWARE, vval);
+		switch_channel_set_variable(channel, "RECORD_SOFTWARE", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_ARTIST"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_ARTIST, vval);
+		switch_channel_set_variable(channel, "RECORD_ARTIST", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_COMMENT"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_COMMENT, vval);
+		switch_channel_set_variable(channel, "RECORD_COMMENT", NULL);
+	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_DATE"))) {
+		vval = (const char *) switch_core_session_strdup(session, p);
+		switch_core_file_set_string(fh, SWITCH_AUDIO_COL_STR_DATE, vval);
+		switch_channel_set_variable(channel, "RECORD_DATE", NULL);
+	}
 	
 	codec_name = "L16";
 	if (switch_core_codec_init(&codec,
@@ -333,7 +370,9 @@
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_file_handle_t lfh;
 	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
-
+	const char *p;
+	char *title = "", *copyright = "", *software = "", *artist = "", *comment = "", *date = "";
+	
 	if (!fh) {
 		fh = &lfh;
 		memset(fh, 0, sizeof(lfh));
@@ -354,8 +393,52 @@
 	write_frame.data = abuf;
 	write_frame.buflen = sizeof(abuf);
 
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_TITLE, &p) == SWITCH_STATUS_SUCCESS) {
+		title = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_TITLE", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_COPYRIGHT, &p) == SWITCH_STATUS_SUCCESS) {
+		copyright = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_COPYRIGHT", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_SOFTWARE, &p) == SWITCH_STATUS_SUCCESS) {
+		software = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_SOFTWARE", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_ARTIST, &p) == SWITCH_STATUS_SUCCESS) {
+		artist = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_ARTIST", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_COMMENT, &p) == SWITCH_STATUS_SUCCESS) {
+		comment = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_COMMENT", (char *)p);
+	}
+	
+	if (switch_core_file_get_string(fh, SWITCH_AUDIO_COL_STR_DATE, &p) == SWITCH_STATUS_SUCCESS) {
+		date = (char *) switch_core_session_strdup(session, (char *)p);
+		switch_channel_set_variable(channel, "RECORD_DATE", (char *)p);
+	}
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, 
+					  "OPEN FILE %s %uhz %u channels\n"
+					  "TITLE=%s\n"
+					  "COPYRIGHT=%s\n"
+					  "SOFTWARE=%s\n"
+					  "ARTIST=%s\n"
+					  "COMMENT=%s\n"
+					  "DATE=%s\n", file, fh->samplerate, fh->channels,
+					  title,
+					  copyright,
+					  software,
+					  artist,
+					  comment,
+					  date);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN FILE %s %uhz %u channels\n", file, fh->samplerate, fh->channels);
 
 	interval = read_codec->implementation->microseconds_per_frame / 1000;
 
@@ -370,6 +453,7 @@
 							   SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
 							   NULL, pool) == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
+
 		write_frame.codec = &codec;
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n",
@@ -409,7 +493,7 @@
 		int do_speed = 1;
 		int last_speed = -1;
 		switch_event_t *event;
-
+	
 		if (input_callback || buf) {
 			/*
 			  dtmf handler function you can hook up to be executed when a digit is dialed during playback 
@@ -507,10 +591,12 @@
 
 		write_frame.datalen = (uint32_t)(olen * 2);
 		write_frame.samples = (uint32_t)olen;
+
+#ifndef WIN32
 #if __BYTE_ORDER == __BIG_ENDIAN
 		switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);
 #endif
-		
+#endif
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
 			status = switch_core_session_write_frame(session, &write_frame, -1, stream_id);
 
@@ -1120,7 +1206,7 @@
 			break;
 		}
 		
-		if ((time(NULL) - start) > timelimit) {
+		if ((time(NULL) - start) > (time_t)timelimit) {
 			break;
 		}
 		switch_yield(1000);
@@ -1133,7 +1219,7 @@
 		   switch_channel_ready(peer_channel) &&
 		   !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
 		   !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
-		   ((time(NULL) - start) < timelimit)) {
+		   ((time(NULL) - start) < (time_t)timelimit)) {
 		
 		/* read from the channel while we wait if the audio is up on it */
 		if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {

Modified: freeswitch/branches/james/src/switch_loadable_module.c
==============================================================================
--- freeswitch/branches/james/src/switch_loadable_module.c	(original)
+++ freeswitch/branches/james/src/switch_loadable_module.c	Sun Aug 13 00:08:45 2006
@@ -270,7 +270,7 @@
 			break;
 		}
 
-		if ((module = switch_core_permenant_alloc(sizeof(switch_loadable_module_t))) == 0) {
+		if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) {
 			err = "Could not allocate memory\n";
 			break;
 		}
@@ -283,7 +283,7 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	module->filename = switch_core_permenant_strdup(filename);
+	module->filename = switch_core_permanent_strdup(filename);
 	module->module_interface = module_interface;
 	module->switch_module_load = load_func_ptr;
 
@@ -365,7 +365,7 @@
 	const char *err = NULL; 
 	switch_loadable_module_interface_t *module_interface = NULL; 
 
-	if ((module = switch_core_permenant_alloc(sizeof(switch_loadable_module_t))) == 0) { 
+	if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) { 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Couldn't allocate memory\n"); 
 		return SWITCH_STATUS_GENERR; 
 	} 
@@ -384,7 +384,7 @@
 			break; 
 		} 
   
-		if ((module = switch_core_permenant_alloc(sizeof(switch_loadable_module_t))) == 0) { 
+		if ((module = switch_core_permanent_alloc(sizeof(switch_loadable_module_t))) == 0) { 
 			err = "Could not allocate memory\n"; 
 			break; 
 		} 
@@ -397,7 +397,7 @@
 		return SWITCH_STATUS_GENERR; 
 	} 
   
-	module->filename = switch_core_permenant_strdup(filename); 
+	module->filename = switch_core_permanent_strdup(filename); 
 	module->module_interface = module_interface; 
 	module->switch_module_load = load_func_ptr; 
   
@@ -711,7 +711,7 @@
 	return i;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_stream_handle_t *stream)
+SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	switch_api_interface_t *api;
 	switch_status_t status;
@@ -734,7 +734,7 @@
 	}
 
 	if ((api = switch_loadable_module_get_api_interface(cmd)) != 0) {
-		status = api->function(arg, stream);
+		status = api->function(arg, session, stream);
 	} else {
 		status = SWITCH_STATUS_FALSE;
 		stream->write_function(stream, "INVALID COMMAND [%s]", cmd);

Modified: freeswitch/branches/james/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/james/src/switch_rtp.c	(original)
+++ freeswitch/branches/james/src/switch_rtp.c	Sun Aug 13 00:08:45 2006
@@ -298,8 +298,8 @@
 	switch_mutex_lock(port_lock);
 	port = NEXT_PORT;
 	NEXT_PORT += 2;
-	if (port > RTP_END_PORT) {
-		port = RTP_START_PORT;
+	if (NEXT_PORT > RTP_END_PORT) {
+		NEXT_PORT = RTP_START_PORT;
 	}
 	switch_mutex_unlock(port_lock);
 	return port;

Modified: freeswitch/branches/james/src/switch_utils.c
==============================================================================
--- freeswitch/branches/james/src/switch_utils.c	(original)
+++ freeswitch/branches/james/src/switch_utils.c	Sun Aug 13 00:08:45 2006
@@ -34,16 +34,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, switch_size_t *len)
-{
-	switch_status_t status;
-
-	if ((status = apr_socket_recvfrom(from, sock, flags, buf, len)) == SWITCH_STATUS_SUCCESS) {
-		from->port = ntohs(from->sa.sin.sin_port);
-	}
-	return status;
-}
-
 SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
 {
 	switch(priority) { /*lol*/

Modified: freeswitch/branches/james/src/switch_xml.c
==============================================================================
--- freeswitch/branches/james/src/switch_xml.c	(original)
+++ freeswitch/branches/james/src/switch_xml.c	Sun Aug 13 00:08:45 2006
@@ -617,7 +617,7 @@
         attr = (char **)SWITCH_XML_NIL;
         d = ++s;
         
-        if (isalpha(*s) || *s == '_' || *s == ':' || *s < '\0') { // new tag
+        if (isalpha(*s) || *s == '_' || *s == ':' || (int8_t) *s < '\0') { // new tag
             if (! root->cur)
                 return switch_xml_err(root, d, "markup outside of root element");
 

Modified: freeswitch/branches/james/w32/vsnet/Freeswitch.sln
==============================================================================
--- freeswitch/branches/james/w32/vsnet/Freeswitch.sln	(original)
+++ freeswitch/branches/james/w32/vsnet/Freeswitch.sln	Sun Aug 13 00:08:45 2006
@@ -642,8 +642,8 @@
 		{05515420-16DE-4E63-BE73-85BE85BA5142}.Debug|Win32.Build.0 = Debug|Win32
 		{05515420-16DE-4E63-BE73-85BE85BA5142}.Release|Win32.ActiveCfg = Release|Win32
 		{05515420-16DE-4E63-BE73-85BE85BA5142}.Release|Win32.Build.0 = Release|Win32
-		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Debug|Win32.ActiveCfg = Debug with MySql|Win32
-		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Debug|Win32.Build.0 = Debug with MySql|Win32
+		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Debug|Win32.Build.0 = Debug|Win32
 		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Release|Win32.ActiveCfg = Release|Win32
 		{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection

Modified: freeswitch/branches/james/w32/vsnet/GetLibs.vbs
==============================================================================
--- freeswitch/branches/james/w32/vsnet/GetLibs.vbs	(original)
+++ freeswitch/branches/james/w32/vsnet/GetLibs.vbs	Sun Aug 13 00:08:45 2006
@@ -175,6 +175,8 @@
 	BuildLibs_srtp BuildDebug, BuildRelease
 	FSO.CopyFile LibDestDir & "srtp\include\*.h", LibDestDir & "include"
 	FSO.CopyFile LibDestDir & "srtp\crypto\include\*.h", LibDestDir & "include"
+	BuildLibs_pcre BuildDebug, BuildRelease
+	FSO.CopyFile LibDestDir & "pcre\win32\pcre.h", LibDestDir & "include"
 End If
 
 If BuildModXMLRpc Then
@@ -248,16 +250,13 @@
 '  Lib Build Sectiton
 '  ******************
 Sub BuildLibs_aprutil(BuildDebug, BuildRelease)
-	If Not FSO.FolderExists(LibDestDir & "apr-util") Then 
-'		WgetUnCompress "ftp://ftp.wayne.edu/apache/apr/apr-util-1.2.6.tar.gz", LibDestDir
-		If Not FSO.FolderExists(LibDestDir & "apr-util-1.2.6") Then
-			Wscript.echo "Unable to get apr-util from default download location, Trying backup location:"
-			WgetUnCompress LibsBase & "apr-util-1.2.6.tar.gz", LibDestDir
-		End If
-		RenameFolder LibDestDir & "apr-util-1.2.6", "apr-util"
+	If Not FSO.FolderExists(LibDestDir & "apr-util") Then
+		Wscript.echo "Unable to get apr-util from default download location, Trying backup location:"
+		WgetUnCompress LibsBase & "apr-util-1.2.7.tar.gz", LibDestDir
+		RenameFolder LibDestDir & "apr-util-1.2.7", "apr-util"
 		FSO.CopyFile Utilsdir & "apr\xml.vcproj", LibDestDir & "apr-util\xml\expat\lib\", True
 		FSO.CopyFile Utilsdir & "apr\libaprutil.vcproj", LibDestDir & "apr-util\", True
-	End If 
+	End If
 	If FSO.FolderExists(LibDestDir & "apr-util") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr-util\xml\expat\lib\LibD\xml.lib") Then 
@@ -285,15 +284,12 @@
 End Sub
 
 Sub BuildLibs_apriconv(BuildDebug, BuildRelease)
-	If Not FSO.FolderExists(LibDestDir & "apr-iconv") Then 
-'		WgetUnCompress "ftp://ftp.wayne.edu/apache/apr/apr-iconv-1.1.1.tar.gz", LibDestDir
-		If Not FSO.FolderExists(LibDestDir & "apr-iconv-1.1.1") Then
-			Wscript.echo "Unable to get apr-iconv from default download location, Trying backup location:"
-			WgetUnCompress LibsBase & "apr-iconv-1.1.1.tar.gz", LibDestDir
-		End If
+	If Not FSO.FolderExists(LibDestDir & "apr-iconv") Then
+		Wscript.echo "Unable to get apr-iconv from default download location, Trying backup location:"
+		WgetUnCompress LibsBase & "apr-iconv-1.1.1.tar.gz", LibDestDir
 		RenameFolder LibDestDir & "apr-iconv-1.1.1", "apr-iconv"
 		FSO.CopyFile Utilsdir & "apr\libapriconv.vcproj", LibDestDir & "apr-iconv\", True
-	End If 
+	End If
 	If FSO.FolderExists(LibDestDir & "apr-iconv") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr-iconv\Debug\libapriconv-1.lib") Then 
@@ -315,16 +311,13 @@
 End Sub
 
 Sub BuildLibs_apr(BuildDebug, BuildRelease)
-	If Not FSO.FolderExists(LibDestDir & "apr") Then 
-'		WgetUnCompress "ftp://ftp.wayne.edu/apache/apr/apr-1.2.6.tar.gz", LibDestDir
-		If Not FSO.FolderExists(LibDestDir & "apr-1.2.6") Then
-			Wscript.echo "Unable to get apr from default download location, Trying backup location:"
-			WgetUnCompress LibsBase & "apr-1.2.6.tar.gz", LibDestDir
-		End If
-		RenameFolder LibDestDir & "apr-1.2.6", "apr"
+	If Not FSO.FolderExists(LibDestDir & "apr") Then
+		Wscript.echo "Unable to get apr from default download location, Trying backup location:"
+		WgetUnCompress LibsBase & "apr-1.2.7.tar.gz", LibDestDir
+		RenameFolder LibDestDir & "apr-1.2.7", "apr"
 		FSO.CopyFile Utilsdir & "apr\libapr.vcproj", LibDestDir & "apr\", True
 		FSO.CopyFile Utilsdir & "apr\apr.hw", LibDestDir & "apr\include\", True
-	End If 
+	End If
 	If FSO.FolderExists(LibDestDir & "apr") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr\Debug\libapr-1.lib") Then 
@@ -421,16 +414,13 @@
 End Sub
 
 Sub BuildLibs_sqlite(BuildDebug, BuildRelease)
-	If Not FSO.FolderExists(LibDestDir & "sqlite") Then 
-		WgetUnCompress "http://www.sqlite.org/sqlite-source-3_3_5.zip", LibDestDir 
-		If Not FSO.FolderExists(LibDestDir & "sqlite-source-3_3_5") Then
+		If Not FSO.FolderExists(LibDestDir & "sqlite") Then
 			Wscript.echo "Unable to get SQLite from default download location, Trying backup location:"
-			WgetUnCompress LibsBase & "sqlite-source-3_3_5.zip", LibDestDir
+			WgetUnCompress LibsBase & "sqlite-source-3_3_6.zip", LibDestDir
+			RenameFolder LibDestDir & "sqlite-source-3_3_6", "sqlite"
+			FSO.CopyFile Utilsdir & "sqlite.vcproj", LibDestDir & "sqlite\", True
+			FindReplaceInFile LibDestDir & "sqlite\sqlite.vcproj", "WIN32;", "_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;"
 		End If
-		RenameFolder LibDestDir & "sqlite-source-3_3_5", "sqlite"
-		FSO.CopyFile Utilsdir & "sqlite.vcproj", LibDestDir & "sqlite\", True
-		FindReplaceInFile LibDestDir & "sqlite\sqlite.vcproj", "WIN32;", "_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;"
-	End If
 	If FSO.FolderExists(LibDestDir & "sqlite") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "sqlite\Debug DLL\sqlite.lib") Then 
@@ -629,9 +619,10 @@
 
 Sub BuildLibs_libsndfile(BuildDebug, BuildRelease)
 	If Not FSO.FolderExists(LibDestDir & "libsndfile") Then 
-		WgetUnCompress LibsBase & "libsndfile-1.0.12.tar.gz", LibDestDir
-		RenameFolder LibDestDir & "libsndfile-1.0.12", "libsndfile"
-		FSO.CopyFile Utilsdir & "libsndfile.vcproj", LibDestDir & "libsndfile\Win32\", True
+		WgetUnCompress LibsBase & "libsndfile-1.0.16.tar.gz", LibDestDir
+		RenameFolder LibDestDir & "libsndfile-1.0.16", "libsndfile"
+		FSO.CopyFile Utilsdir & "libsndfile\*.*", LibDestDir & "libsndfile\Win32\", True
+		FindReplaceInFile LibDestDir & "libsndfile\src\common.c", "memset (ptr + most,", "memset ((char *)ptr + most,"
 	End If 
 	If FSO.FolderExists(LibDestDir & "libsndfile") Then 
 		If BuildDebug Then
@@ -927,6 +918,16 @@
 		FSO.CopyFile FreeswitchDir & "src\include\switch_version.h.in", FreeswitchDir & "src\include\switch_version.h", true
 		FindReplaceInFile FreeswitchDir & "src\include\switch_version.h", "@SVN_VERSION@", VERSION
 	End If
+	If VERSION = "" Then
+		VERSION = "UNKNOWN"
+		Set MyFile = fso.CreateTextFile(UtilsDir & "lastversion", True)
+		MyFile.WriteLine(VERSION)
+		MyFile.Close
+	
+		FSO.CopyFile FreeswitchDir & "src\include\switch_version.h.in", FreeswitchDir & "src\include\switch_version.h", true
+		FindReplaceInFile FreeswitchDir & "src\include\switch_version.h", "@SVN_VERSION@", VERSION
+	End If
+	
 End Sub
 
 Sub BuildViaVCBuild(ProjectFile, BuildType)
@@ -984,6 +985,7 @@
 End Sub
 
 Sub RenameFolder(FolderName, NewFolderName)
+	wscript.echo FolderName
 	Set Folder=FSO.GetFolder(FolderName)
 	Folder.Name = NewFolderName
 End Sub



More information about the Freeswitch-svn mailing list