[Freeswitch-svn] [commit] r2281 - in freeswitch/branches/mishehu: . conf libs/iax/src libs/libdingaling/src mac/xcode src src/include src/mod/applications/mod_conference 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/languages/mod_spidermonkey w32/vsnet w32/vsnet/Tools/PortAudio

Freeswitch SVN mishehu at freeswitch.org
Sun Aug 13 02:21:26 EDT 2006


Author: mishehu
Date: Sun Aug 13 02:21:25 2006
New Revision: 2281

Added:
   freeswitch/branches/mishehu/mac/xcode/Loadable Bundle.trgttmpl
      - copied unchanged from r2280, /freeswitch/trunk/mac/xcode/Loadable Bundle.trgttmpl
   freeswitch/branches/mishehu/w32/vsnet/Tools/PortAudio/
      - copied from r2280, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/
   freeswitch/branches/mishehu/w32/vsnet/Tools/PortAudio/PortAudio.vcproj
      - copied unchanged from r2280, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/PortAudio.vcproj
   freeswitch/branches/mishehu/w32/vsnet/Tools/PortAudio/portaudio.def
      - copied unchanged from r2280, /freeswitch/trunk/w32/vsnet/Tools/PortAudio/portaudio.def
Modified:
   freeswitch/branches/mishehu/Makefile.am
   freeswitch/branches/mishehu/Makefile.in
   freeswitch/branches/mishehu/conf/freeswitch.xml
   freeswitch/branches/mishehu/libs/iax/src/iax.c
   freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.c
   freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.h
   freeswitch/branches/mishehu/src/include/switch.h
   freeswitch/branches/mishehu/src/include/switch_utils.h
   freeswitch/branches/mishehu/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/Makefile
   freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/branches/mishehu/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/branches/mishehu/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/mishehu/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/pddcdr.cpp
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/branches/mishehu/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/mishehu/src/switch.c
   freeswitch/branches/mishehu/src/switch_ivr.c
   freeswitch/branches/mishehu/src/switch_rtp.c
   freeswitch/branches/mishehu/src/switch_xml.c
   freeswitch/branches/mishehu/w32/vsnet/Freeswitch.sln
   freeswitch/branches/mishehu/w32/vsnet/GetLibs.vbs

Log:
Merged in minor fixes to time formatting and a segfault caused by a single-legged call.  Merged up to trunk r2280.

Modified: freeswitch/branches/mishehu/Makefile.am
==============================================================================
--- freeswitch/branches/mishehu/Makefile.am	(original)
+++ freeswitch/branches/mishehu/Makefile.am	Sun Aug 13 02:21:25 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
@@ -171,6 +171,7 @@
 	./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/mishehu/Makefile.in
==============================================================================
--- freeswitch/branches/mishehu/Makefile.in	(original)
+++ freeswitch/branches/mishehu/Makefile.in	Sun Aug 13 02:21:25 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'`; \
@@ -1091,6 +1091,7 @@
 	./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/mishehu/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/mishehu/conf/freeswitch.xml	(original)
+++ freeswitch/branches/mishehu/conf/freeswitch.xml	Sun Aug 13 02:21:25 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/mishehu/libs/iax/src/iax.c
==============================================================================
--- freeswitch/branches/mishehu/libs/iax/src/iax.c	(original)
+++ freeswitch/branches/mishehu/libs/iax/src/iax.c	Sun Aug 13 02:21:25 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/mishehu/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.c	Sun Aug 13 02:21:25 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,63 @@
 	iks_insert_attrib(ctag, "ext", "sidebar voice-v1");
 	iks_insert_attrib(ctag, "client", "libdingaling");
 	iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
-	
+
 	apr_queue_push(handle->queue, msg);
-	ldl_set_flag(handle, LDL_FLAG_READY);
+	ldl_set_flag_locked(handle, LDL_FLAG_READY);
 	return IKS_FILTER_EAT;
 }
 
+static const char c64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+#define B64BUFFLEN 1024
+
+static int b64encode(unsigned char *in, uint32_t ilen, unsigned char *out, uint32_t olen) {
+	int y=0,bytes=0;
+	uint32_t x=0;
+	unsigned int b=0,l=0;
+
+	for(x=0;x<ilen;x++) {
+		b = (b<<8) + in[x];
+		l += 8;
+		while (l >= 6) {
+			out[bytes++] = c64[(b>>(l-=6))%64];
+			if(++y!=72) {
+				continue;
+			}
+			out[bytes++] = '\n';
+			y=0;
+		}
+	}
+
+	if (l > 0) {
+		out[bytes++] = c64[((b%16)<<(6-l))%64];
+	}
+	if (l != 0) while (l < 6) {
+		out[bytes++] = '=', l += 2;
+	}
+
+	return 0;
+}
+
 static int on_stream(ldl_handle_t *handle, int type, iks * node)
 {
 	handle->counter = opt_timeout;
 
 	switch (type) {
 	case IKS_NODE_START:
-		if (opt_use_tls && !iks_is_secure(handle->parser)) {
-			iks_start_tls(handle->parser);
+		if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser)) {
+			if (iks_has_tls()) {
+				iks_start_tls(handle->parser);
+			} else {
+				globals.logger(DL_LOG_DEBUG, "TLS NOT SUPPORTED IN THIS BUILD!\n");
+			}
 		}
 		break;
 	case IKS_NODE_NORMAL:
+		
+
 		if (strcmp("stream:features", iks_name(node)) == 0) {
 			handle->features = iks_stream_features(node);
-			if (opt_use_tls && !iks_is_secure(handle->parser))
+			if (ldl_test_flag(handle, LDL_FLAG_TLS) && !iks_is_secure(handle->parser))
 				break;
 			if (ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
 				iks *t;
@@ -566,7 +657,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 = (uint32_t)(strlen(handle->acc->user) + strlen(handle->password) + 2);
+						b64encode((unsigned char *)s, slen, (unsigned char *) base64, sizeof(base64));
+						iks_insert_cdata(x, base64, 0);
+						iks_send(handle->parser, x);
+						iks_delete(x);
+					} else {
+						globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n");
+						break;
+					}
+					
 				}
 			}
 		} else if (strcmp("failure", iks_name(node)) == 0) {
@@ -577,25 +688,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 +835,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 +859,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 +919,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 +938,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 +968,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 +990,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 +1301,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 +1345,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 +1355,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 +1407,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 +1448,7 @@
 
 	ldl_flush_queue(*handle);
 	
+
 	apr_pool_destroy(pool);
 	*handle = NULL;
 	return LDL_STATUS_SUCCESS;

Modified: freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.h
==============================================================================
--- freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.h	(original)
+++ freeswitch/branches/mishehu/libs/libdingaling/src/libdingaling.h	Sun Aug 13 02:21:25 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/mishehu/src/include/switch.h
==============================================================================
--- freeswitch/branches/mishehu/src/include/switch.h	(original)
+++ freeswitch/branches/mishehu/src/include/switch.h	Sun Aug 13 02:21:25 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/mishehu/src/include/switch_utils.h
==============================================================================
--- freeswitch/branches/mishehu/src/include/switch_utils.h	(original)
+++ freeswitch/branches/mishehu/src/include/switch_utils.h	Sun Aug 13 02:21:25 2006
@@ -61,6 +61,8 @@
 !strcasecmp(expr, "true") ||\
 atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
 
+#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
   \param priority the priority to get the name of

Modified: freeswitch/branches/mishehu/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/mishehu/src/mod/applications/mod_conference/mod_conference.c	Sun Aug 13 02:21:25 2006
@@ -2069,7 +2069,7 @@
 			break;
 		}
 		
-		if ((time(NULL) - start) > timelimit) {
+		if ((time(NULL) - start) > (time_t)timelimit) {
 			break;
 		}
 		switch_yield(1000);
@@ -2080,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/mishehu/src/mod/dialplans/mod_dialplan_xml/Makefile
==============================================================================
--- freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/Makefile	(original)
+++ freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/Makefile	Sun Aug 13 02:21:25 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/mishehu/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/branches/mishehu/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Sun Aug 13 02:21:25 2006
@@ -33,7 +33,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <pcre.h>
+
 
 static const char modname[] = "mod_dialplan_xml";
 

Modified: freeswitch/branches/mishehu/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Sun Aug 13 02:21:25 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 {
@@ -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")) {

Modified: freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_exosip/mod_exosip.c	Sun Aug 13 02:21:25 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/mishehu/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_iax/mod_iax.c	Sun Aug 13 02:21:25 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/mishehu/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/branches/mishehu/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Sun Aug 13 02:21:25 2006
@@ -964,7 +964,7 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
+	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);

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp	Sun Aug 13 02:21:25 2006
@@ -82,49 +82,56 @@
 		callanswerdate = newchannel->timetable->answered;
 		callenddate = newchannel->timetable->hungup;
 	
-		if(newchannel->callerprofile->caller_id_name != 0)
+		if (newchannel->callerprofile) 
 		{
-			strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
-			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);
-		}
+			if(newchannel->callerprofile->caller_id_name != 0)
+			{
+				strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
+				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
+			if(newchannel->callerprofile->ani != 0)
+				strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
+			if(newchannel->callerprofile->ani2 != 0)
+				strncpy(ani2,newchannel->callerprofile->ani2,strlen(newchannel->callerprofile->ani2));
 		
-		// Get the ANI information if it's set
-		if(newchannel->callerprofile->ani != 0)
-			strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
-		if(newchannel->callerprofile->ani2 != 0)
-			strncpy(ani2,newchannel->callerprofile->ani2,strlen(newchannel->callerprofile->ani2));
-	
-		if(newchannel->callerprofile->dialplan != 0)
-			strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
-	
-		if(newchannel->callerprofile->network_addr != 0)
-			strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
-				
+			if(newchannel->callerprofile->dialplan != 0)
+				strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
+		
+			if(newchannel->callerprofile->network_addr != 0)
+				strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
+		}
+
 		originated = newchannel->originate;
 	
-		if(newchannel->originateprofile->uuid != 0)
+		if(newchannel->originateprofile && newchannel->originateprofile->uuid != 0)
 			strncpy(destuuid,newchannel->originateprofile->uuid,strlen(newchannel->originateprofile->uuid));
 	
 		// We still need to check if this is originated or not
 		if(originated == 0)
 		{
-			if(newchannel->callerprofile->destination_number != 0)
-				strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
-			if(newchannel->callerprofile->caller_id_number != 0)
-				strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
-			if(newchannel->originateprofile->chan_name != 0)
+			if (newchannel->callerprofile) {
+				if(newchannel->callerprofile->destination_number != 0)
+					strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
+				if(newchannel->callerprofile->caller_id_number != 0)
+					strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
+			}
+			if(newchannel->originateprofile && newchannel->originateprofile->chan_name != 0)
 				strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
 		}
 		else
 		{
-			if(newchannel->callerprofile->caller_id_number != 0)
-				strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
-			if(newchannel->callerprofile->destination_number != 0)
-				strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
-			if(newchannel->originateprofile->chan_name != 0)
+			if (newchannel->callerprofile) {
+				if(newchannel->callerprofile->caller_id_number != 0)
+					strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
+				if(newchannel->callerprofile->destination_number != 0)
+					strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
+			}
+			if(newchannel->originateprofile && newchannel->originateprofile->chan_name != 0)
 				strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
 		}
 		

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp	Sun Aug 13 02:21:25 2006
@@ -65,7 +65,7 @@
 		
 		// Format the times
 		apr_size_t retsizecsd, retsizecad, retsizeced;  //csd == callstartdate, cad == callanswerdate, ced == callenddate, ceff == callenddate_forfile
-		char format[] = "%F %T";
+		char format[] = "%Y-%m-%d-%H-%M-%S";
 		switch_strftime(formattedcallstartdate,&retsizecsd,sizeof(formattedcallstartdate),format,&tempcallstart);
 		switch_strftime(formattedcallanswerdate,&retsizecad,sizeof(formattedcallanswerdate),format,&tempcallanswer);
 		switch_strftime(formattedcallenddate,&retsizeced,sizeof(formattedcallenddate),format,&tempcallend);
@@ -193,7 +193,7 @@
 	switch_time_exp_lt(&now_converted,now);
 		
 	apr_size_t retsize;		
-	char format[] = "%F %T";
+	char format[] = "%Y-%m-%d-%H-%M-%S";
 	char formatteddate[100];
 	memset(formatteddate,0,100);
 	switch_strftime(formatteddate,&retsize,100,format,&now_converted);

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp	Sun Aug 13 02:21:25 2006
@@ -433,7 +433,7 @@
 	
 	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++)
 	{
-		int mysql_ping_result = mysql_ping(conn);
+		mysql_ping_result = mysql_ping(conn);
 		if(mysql_ping_result)
 		{
 			switch(mysql_ping_result)

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/pddcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/pddcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/pddcdr.cpp	Sun Aug 13 02:21:25 2006
@@ -60,7 +60,7 @@
 		
 		// Format the times
 		size_t retsizecsd, retsizecad, retsizeced; //csd == callstartdate, cad == callanswerdate, ced == callenddate, ceff == callenddate_forfile
-		char format[] = "%F %T";
+		char format[] = "%Y-%m-%d-%H-%M-%S";
 		switch_strftime(formattedcallstartdate,&retsizecsd,sizeof(formattedcallstartdate),format,&tempcallstart);
 		switch_strftime(formattedcallanswerdate,&retsizecad,sizeof(formattedcallanswerdate),format,&tempcallanswer);
 		switch_strftime(formattedcallenddate,&retsizeced,sizeof(formattedcallenddate),format,&tempcallend);

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Sun Aug 13 02:21:25 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";
 
@@ -244,15 +244,17 @@
 		mlen = 1;
 		status = switch_socket_recv(listener->sock, ptr, &mlen);
 
-		if (status != SWITCH_STATUS_BREAK && status != SWITCH_STATUS_SUCCESS) {
-			return status;
+		if (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS) {
+			return SWITCH_STATUS_FALSE;
 		}
 
-		if (status != SWITCH_STATUS_BREAK && mlen) {
+		if (mlen) {
 			bytes++;
+			do_sleep = 0;
 
 			if (*mbuf == '\r' || *mbuf == '\n') { /* bah */
 				ptr = mbuf;
+				mbuf[0] = '\0';
 				continue;
 			}
 
@@ -303,7 +305,7 @@
 				return SWITCH_STATUS_FALSE;
 			}
 		}
-
+		
 		if (!*mbuf) {
 			if (switch_test_flag(listener, LFLAG_LOG)) {
 				if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
@@ -459,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");
@@ -518,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);

Modified: freeswitch/branches/mishehu/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/mishehu/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Sun Aug 13 02:21:25 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;
 				}
 			}
 
@@ -1839,6 +1843,8 @@
 		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;
@@ -1850,9 +1856,7 @@
 			}
 		}
 		
-		switch_stream_handle_t stream = {0};
-		char retbuf[2048] = "";
-
+		
 		stream.data = retbuf;
 		stream.end = stream.data;
 		stream.data_size = sizeof(retbuf);

Modified: freeswitch/branches/mishehu/src/switch.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch.c	(original)
+++ freeswitch/branches/mishehu/src/switch.c	Sun Aug 13 02:21:25 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/mishehu/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_ivr.c	(original)
+++ freeswitch/branches/mishehu/src/switch_ivr.c	Sun Aug 13 02:21:25 2006
@@ -453,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",
@@ -492,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 
@@ -590,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);
 
@@ -1203,7 +1206,7 @@
 			break;
 		}
 		
-		if ((time(NULL) - start) > timelimit) {
+		if ((time(NULL) - start) > (time_t)timelimit) {
 			break;
 		}
 		switch_yield(1000);
@@ -1216,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/mishehu/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_rtp.c	(original)
+++ freeswitch/branches/mishehu/src/switch_rtp.c	Sun Aug 13 02:21:25 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/mishehu/src/switch_xml.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_xml.c	(original)
+++ freeswitch/branches/mishehu/src/switch_xml.c	Sun Aug 13 02:21:25 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/mishehu/w32/vsnet/Freeswitch.sln
==============================================================================
--- freeswitch/branches/mishehu/w32/vsnet/Freeswitch.sln	(original)
+++ freeswitch/branches/mishehu/w32/vsnet/Freeswitch.sln	Sun Aug 13 02:21:25 2006
@@ -384,8 +384,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/mishehu/w32/vsnet/GetLibs.vbs
==============================================================================
--- freeswitch/branches/mishehu/w32/vsnet/GetLibs.vbs	(original)
+++ freeswitch/branches/mishehu/w32/vsnet/GetLibs.vbs	Sun Aug 13 02:21:25 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
@@ -251,10 +253,10 @@
 	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
-	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
 	If FSO.FolderExists(LibDestDir & "apr-util") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr-util\xml\expat\lib\LibD\xml.lib") Then 
@@ -282,12 +284,12 @@
 End Sub
 
 Sub BuildLibs_apriconv(BuildDebug, BuildRelease)
-	If Not FSO.FolderExists(LibDestDir & "apr-iconv-1.1.1") Then
+	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
-	RenameFolder LibDestDir & "apr-iconv-1.1.1", "apr-iconv"
-	FSO.CopyFile Utilsdir & "apr\libapriconv.vcproj", LibDestDir & "apr-iconv\", True
 	If FSO.FolderExists(LibDestDir & "apr-iconv") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr-iconv\Debug\libapriconv-1.lib") Then 
@@ -312,10 +314,10 @@
 	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
-	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
 	If FSO.FolderExists(LibDestDir & "apr") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "apr\Debug\libapr-1.lib") Then 
@@ -415,10 +417,10 @@
 		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_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_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;"
 	If FSO.FolderExists(LibDestDir & "sqlite") Then 
 		If BuildDebug Then
 			If Not FSO.FileExists(LibDestDir & "sqlite\Debug DLL\sqlite.lib") Then 
@@ -916,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)
@@ -973,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