[Freeswitch-svn] [commit] r4926 - in freeswitch/trunk/src: . include mod/applications/mod_bridgecall mod/applications/mod_commands mod/applications/mod_conference mod/endpoints/mod_sofia mod/languages/mod_perl mod/languages/mod_spidermonkey

Freeswitch SVN anthm at freeswitch.org
Fri Apr 13 18:15:59 EDT 2007


Author: anthm
Date: Fri Apr 13 18:15:58 2007
New Revision: 4926

Modified:
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/trunk/src/mod/languages/mod_perl/fs_perl.pm
   freeswitch/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_ivr_originate.c
   freeswitch/trunk/src/switch_swig.c

Log:
refactor to avoid some potential issues with channels that are hungup instantly after being answered

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Fri Apr 13 18:15:58 2007
@@ -283,6 +283,7 @@
   \param cid_num_override override the caller id number
   \param caller_profile_override override the entire calling caller profile
   \return SWITCH_STATUS_SUCCESS if bleg is a running session.
+  \note bleg will be read locked which must be unlocked with switch_core_session_rwunlock() before losing scope
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
 													 switch_core_session_t **bleg,

Modified: freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c	Fri Apr 13 18:15:58 2007
@@ -39,7 +39,7 @@
 static void audio_bridge_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *caller_channel;
-	switch_core_session_t *peer_session;
+	switch_core_session_t *peer_session = NULL;
 	unsigned int timelimit = 60;
 	char *var;
 	uint8_t no_media_bridge = 0;
@@ -98,7 +98,7 @@
 				if (bad) {
 					switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 					switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-					return;
+					goto end;
 				}
 			}
 
@@ -113,6 +113,10 @@
 				switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
 			}
 		}
+	end:
+		if (peer_session) {
+			switch_core_session_rwunlock(peer_session);
+		}
 	}
 }
 

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Fri Apr 13 18:15:58 2007
@@ -590,7 +590,7 @@
 static switch_status_t originate_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_channel_t *caller_channel;
-	switch_core_session_t *caller_session;
+	switch_core_session_t *caller_session = NULL;
 	char *argv[7] = { 0 };
 	int i = 0, x, argc = 0;
 	char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
@@ -684,6 +684,10 @@
 		stream->write_function(stream, "Created Session: %s\n", switch_core_session_get_uuid(caller_session));
 	}
 
+	if (caller_session) {
+		switch_core_session_rwunlock(caller_session);
+	}
+
 	return SWITCH_STATUS_SUCCESS;;
 }
 

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Fri Apr 13 18:15:58 2007
@@ -3476,12 +3476,12 @@
 										  switch_core_session_t *session,
 										  char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
 {
-	switch_core_session_t *peer_session;
+	switch_core_session_t *peer_session = NULL;
 	switch_channel_t *peer_channel;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_channel_t *caller_channel = NULL;
 	char appdata[512];
-
+	int rdlock = 0;
 
 	*cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
@@ -3498,7 +3498,7 @@
 
 		peer_channel = switch_core_session_get_channel(peer_session);
 		assert(peer_channel != NULL);
-
+		rdlock = 1;
 		goto callup;
 	}
 
@@ -3534,7 +3534,7 @@
 		goto done;
 	}
 
-
+	rdlock = 1;
 	peer_channel = switch_core_session_get_channel(peer_session);
 	assert(peer_channel != NULL);
 
@@ -3585,6 +3585,10 @@
 	if (conference) {
 		switch_thread_rwlock_unlock(conference->rwlock);
 	}
+	if (rdlock && peer_session) {
+		switch_core_session_rwunlock(peer_session);
+	}
+
 	return status;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Apr 13 18:15:58 2007
@@ -242,11 +242,6 @@
 
 	switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 
-	if (tech_pvt->home) {
-		su_home_unref(tech_pvt->home);
-		tech_pvt->home = NULL;
-	}
-
 	if (tech_pvt->sofia_private) {
 		*tech_pvt->sofia_private->uuid = '\0';
 	}
@@ -847,6 +842,7 @@
 		sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
 		goto done;
 	}
+	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
 
 	data = switch_core_session_strdup(nsession, outbound_profile->destination_number);
 	profile_name = data;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Fri Apr 13 18:15:58 2007
@@ -54,11 +54,6 @@
 typedef struct sofia_profile sofia_profile_t;
 #define NUA_MAGIC_T sofia_profile_t
 
-struct sofia_private {
-	char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
-	outbound_reg_t *gateway;
-};
-
 typedef struct sofia_private sofia_private_t;
 
 struct private_object;
@@ -85,6 +80,13 @@
 #include <sofia-sip/nea.h>
 #include <sofia-sip/msg_addr.h>
 
+struct sofia_private {
+	char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
+	outbound_reg_t *gateway;
+	su_home_t *home;
+};
+
+
 
 #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
 #define set_anchor(t,m) if (t->Anchor) {delete t->Anchor;} t->Anchor = new SipMessage(m);
@@ -305,7 +307,6 @@
 	switch_payload_t bcng_pt;
 	nua_handle_t *nh;
 	nua_handle_t *nh2;
-	su_home_t *home;
 	sip_contact_t *contact;
 };
 
@@ -330,95 +331,95 @@
 /*************************************************************************************************************************************************************/
 
 
-switch_status_t sofia_glue_activate_rtp(private_object_t * tech_pvt);
+switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt);
 
-void sofia_glue_deactivate_rtp(private_object_t * tech_pvt);
+void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);
 
-void sofia_glue_set_local_sdp(private_object_t * tech_pvt, char *ip, uint32_t port, char *sr, int force);
+void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force);
 
-void sofia_glue_sofia_glue_tech_set_codecs(private_object_t * tech_pvt);
+void sofia_glue_sofia_glue_tech_set_codecs(private_object_t *tech_pvt);
 
-void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame);
+void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame);
 
 void sofia_glue_terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line);
 
-switch_status_t sofia_glue_tech_choose_port(private_object_t * tech_pvt);
+switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt);
 
 switch_status_t sofia_glue_do_invite(switch_core_session_t *session);
 
-uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t * sdp);
+uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
 
-void sofia_presence_establish_presence(sofia_profile_t * profile);
+void sofia_presence_establish_presence(sofia_profile_t *profile);
 
 void sofia_handle_sip_i_state(int status,
 				 char const *phrase,
-				 nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+				 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 
 
-void sofia_handle_sip_i_refer(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
+void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 
-void sofia_handle_sip_i_info(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
+void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 
-void sofia_handle_sip_i_invite(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 
-void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 
 void sofia_event_callback(nua_event_t event,
 					int status,
 					char const *phrase,
-					nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+					nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 
 
-void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t * thread, void *obj);
+void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj);
 
-void launch_sofia_profile_thread(sofia_profile_t * profile);
+void launch_sofia_profile_thread(sofia_profile_t *profile);
 
 switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
-void sofia_glue_tech_absorb_sdp(private_object_t * tech_pvt);
-switch_status_t sofia_glue_tech_media(private_object_t * tech_pvt, char *r_sdp);
-char *sofia_reg_find_reg_url(sofia_profile_t * profile, const char *user, const char *host, char *val, switch_size_t len);
+void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt);
+switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp);
+char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len);
 void event_handler(switch_event_t *event);
 void sofia_presence_event_handler(switch_event_t *event);
 void sofia_presence_mwi_event_handler(switch_event_t *event);
 void sofia_presence_cancel(void);
 switch_status_t config_sofia(int reload);
-auth_res_t parse_auth(sofia_profile_t * profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen);
+auth_res_t parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen);
 void sofia_reg_handle_sip_r_challenge(int status,
 					 char const *phrase,
-					 nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
+					 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
 void sofia_reg_handle_sip_r_register(int status,
 					char const *phrase,
-					nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+					nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 void sofia_handle_sip_i_options(int status,
 				   char const *phrase,
-				   nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_presence_handle_sip_i_publish(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+				   nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
+void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 void sofia_presence_handle_sip_i_message(int status,
 				   char const *phrase,
-				   nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+				   nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 void sofia_presence_handle_sip_r_subscribe(int status,
 					 char const *phrase,
-					 nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+					 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 void sofia_presence_handle_sip_i_subscribe(int status,
 					 char const *phrase,
-					 nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[]);
+					 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
 
 sofia_profile_t *sofia_glue_find_profile(char *key);
-void sofia_glue_add_profile(char *key, sofia_profile_t * profile);
+void sofia_glue_add_profile(char *key, sofia_profile_t *profile);
 void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char *sql, switch_mutex_t *mutex);
-void sofia_reg_check_expire(sofia_profile_t * profile, time_t now);
-void sofia_reg_check_gateway(sofia_profile_t * profile, time_t now);
-void sofia_reg_unregister(sofia_profile_t * profile);
+void sofia_reg_check_expire(sofia_profile_t *profile, time_t now);
+void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
+void sofia_reg_unregister(sofia_profile_t *profile);
 switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool);
 outbound_reg_t *sofia_reg_find_gateway(char *key);
-void sofia_reg_add_gateway(char *key, outbound_reg_t * gateway);
-void sofia_glue_pass_sdp(private_object_t * tech_pvt, char *sdp);
+void sofia_reg_add_gateway(char *key, outbound_reg_t *gateway);
+void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
 int sofia_glue_get_user_host(char *in, char **user, char **host);
 switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
 void sofia_glue_do_xfer_invite(switch_core_session_t *session);
-uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sip_t const *sip, sofia_regtype_t regtype, char *key, uint32_t keylen);
+uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_regtype_t regtype, char *key, uint32_t keylen);
 const switch_endpoint_interface_t sofia_endpoint_interface;
-void sofia_presence_set_chat_hash(private_object_t * tech_pvt, sip_t const *sip);
+void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
 switch_status_t sofia_on_hangup(switch_core_session_t *session);
 char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup);
 void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Fri Apr 13 18:15:58 2007
@@ -40,7 +40,7 @@
 void sofia_event_callback(nua_event_t event,
 						   int status,
 						   char const *phrase,
-						   nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+						   nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	struct private_object *tech_pvt = NULL;
 	auth_res_t auth_res = AUTH_FORBIDDEN;
@@ -231,7 +231,7 @@
 
 
 
-void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t * thread, void *obj)
+void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj)
 {
 	sofia_profile_t *profile = (sofia_profile_t *) obj;
 	switch_memory_pool_t *pool;
@@ -357,7 +357,7 @@
 	return NULL;
 }
 
-void launch_sofia_profile_thread(sofia_profile_t * profile)
+void launch_sofia_profile_thread(sofia_profile_t *profile)
 {
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr = NULL;
@@ -798,7 +798,7 @@
 
 void sofia_handle_sip_i_state(int status,
 						char const *phrase,
-						nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+						nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	const char *l_sdp = NULL, *r_sdp = NULL;
 	int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
@@ -838,6 +838,8 @@
 		tech_pvt = switch_core_session_get_private(session);
 		assert(tech_pvt != NULL);
 		assert(tech_pvt->nh != NULL);
+		
+
 
 		if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
 			switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
@@ -935,7 +937,7 @@
 					switch_core_session_thread_launch(session);
 					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
 
@@ -958,7 +960,7 @@
 
 						switch_core_session_thread_launch(session);
 
-						if (replaces_str && (replaces = sip_replaces_make(tech_pvt->home, replaces_str))
+						if (replaces_str && (replaces = sip_replaces_make(tech_pvt->sofia_private->home, replaces_str))
 							&& (bnh = nua_handle_by_replaces(nua, replaces))) {
 							sofia_private_t *b_private;
 
@@ -1016,7 +1018,7 @@
 				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
 					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
 
@@ -1084,7 +1086,7 @@
 					}
 					goto done;
 				} else {
-					sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
+					sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
 					sdp_session_t *sdp;
 					uint8_t match = 0;
 
@@ -1121,7 +1123,7 @@
 	case nua_callstate_terminated:
 		if (session) {
 			if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
-
+				
 				switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 				if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
 					switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
@@ -1131,13 +1133,19 @@
 					sofia_glue_terminate_session(&session, sofia_glue_sip_cause_to_freeswitch(status), __LINE__);
 				}
 			}
-
+			
 			if (tech_pvt->sofia_private) {
+				if (sofia_private->home) {
+					su_home_unref(sofia_private->home);
+				}
 				free(tech_pvt->sofia_private);
 				tech_pvt->sofia_private = NULL;
 			}
 			tech_pvt->nh = NULL;
 		} else if (sofia_private) {
+			if (sofia_private->home) {
+				su_home_unref(sofia_private->home);
+			}
 			free(sofia_private);
 		}
 
@@ -1157,7 +1165,7 @@
 
 
 /*---------------------------------------*/
-void sofia_handle_sip_i_refer(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
+void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
 {
 	/* Incoming refer */
 	sip_from_t const *from;
@@ -1213,7 +1221,7 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
 					goto done;
 				}
-				if ((replaces = sip_replaces_make(tech_pvt->home, rep))
+				if ((replaces = sip_replaces_make(tech_pvt->sofia_private->home, rep))
 					&& (bnh = nua_handle_by_replaces(nua, replaces))) {
 					sofia_private_t *b_private = NULL;
 					private_object_t *b_tech_pvt = NULL;
@@ -1319,6 +1327,7 @@
 							switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 							nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 									   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
+							switch_core_session_rwunlock(tsession);
 						} else {
 							goto error;
 						}
@@ -1396,7 +1405,7 @@
 }
 
 
-void sofia_handle_sip_i_info(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
+void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
 {
 
 	//placeholder for string searching
@@ -1449,7 +1458,7 @@
 }
 
 #define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri")
-const char *_url_set_chanvars(switch_core_session_t *session, url_t * url, const char *user_var,
+const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
 									 const char *host_var, const char *port_var, const char *uri_var)
 {
 	const char *user = NULL, *host = NULL, *port = NULL;
@@ -1484,7 +1493,7 @@
 	return uri;
 }
 
-void process_rpid(sip_unknown_t * un, private_object_t * tech_pvt)
+void process_rpid(sip_unknown_t *un, private_object_t *tech_pvt)
 {
 	int argc, x, screen = 1;
 	char *mydata, *argv[10] = { 0 };
@@ -1530,7 +1539,7 @@
 	}
 }
 
-void sofia_handle_sip_i_invite(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	switch_core_session_t *session = NULL;
 	char key[128] = "";
@@ -1575,6 +1584,7 @@
 		sofia_glue_terminate_session(&session, SWITCH_CAUSE_SWITCH_CONGESTION, __LINE__);
 		return;
 	}
+	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 
 	if (!switch_strlen_zero(key)) {
 		tech_pvt->key = switch_core_session_strdup(session, key);
@@ -1723,6 +1733,8 @@
 		abort();
 	}
 	memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
+	tech_pvt->sofia_private->home = su_home_new(sizeof(*tech_pvt->sofia_private->home));
+	
 	switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
 	nua_handle_bind(nh, tech_pvt->sofia_private);
 	tech_pvt->nh = nh;
@@ -1730,7 +1742,7 @@
 
 void sofia_handle_sip_i_options(int status,
 						  char const *phrase,
-						  nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+						  nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	nua_respond(nh, SIP_200_OK,
 				//SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Fri Apr 13 18:15:58 2007
@@ -139,7 +139,7 @@
 	tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
 }
 
-void sofia_glue_sofia_glue_tech_set_codecs(private_object_t * tech_pvt)
+void sofia_glue_sofia_glue_tech_set_codecs(private_object_t *tech_pvt)
 {
 	switch_channel_t *channel;
 	char *abs, *codec_string = NULL;
@@ -195,7 +195,7 @@
 }
 
 
-void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * profile, private_object_t * tech_pvt, const char *channame)
+void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame)
 {
 	switch_channel_t *channel;
 	char name[256];
@@ -209,7 +209,7 @@
 
 	//switch_channel_set_flag(channel, CF_ACCEPT_CNG);
 
-	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+
 	switch_mutex_lock(tech_pvt->flag_mutex);
 	tech_pvt->flags = profile->flags;
 	switch_mutex_unlock(tech_pvt->flag_mutex);
@@ -227,8 +227,6 @@
 	}
 
 	tech_pvt->session = session;
-	tech_pvt->home = su_home_new(sizeof(*tech_pvt->home));
-
 	switch_core_session_set_private(session, tech_pvt);
 
 
@@ -288,7 +286,7 @@
 }
 
 
-switch_status_t sofia_glue_tech_choose_port(private_object_t * tech_pvt)
+switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
 {
 	char *ip = tech_pvt->profile->rtpip;
 	switch_channel_t *channel;
@@ -428,6 +426,7 @@
 			abort();
 		}
 		memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
+		tech_pvt->sofia_private->home = su_home_new(sizeof(*tech_pvt->sofia_private->home));
 		switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
 		nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);
 
@@ -530,7 +529,7 @@
 
 }
 
-void sofia_glue_tech_absorb_sdp(private_object_t * tech_pvt)
+void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
 {
 	switch_channel_t *channel;
 	char *sdp_str;
@@ -544,7 +543,7 @@
 		sdp_media_t *m;
 		sdp_connection_t *connection;
 
-		if ((parser = sdp_parse(tech_pvt->home, sdp_str, (int) strlen(sdp_str), 0))) {
+		if ((parser = sdp_parse(tech_pvt->sofia_private->home, sdp_str, (int) strlen(sdp_str), 0))) {
 			if ((sdp = sdp_session(parser))) {
 				for (m = sdp->sdp_media; m; m = m->m_next) {
 					if (m->m_type != sdp_media_audio) {
@@ -571,7 +570,7 @@
 	}
 }
 
-void sofia_glue_deactivate_rtp(private_object_t * tech_pvt)
+void sofia_glue_deactivate_rtp(private_object_t *tech_pvt)
 {
 	int loops = 0;				//, sock = -1;
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {
@@ -583,7 +582,7 @@
 	}
 }
 
-switch_status_t sofia_glue_tech_set_codec(private_object_t * tech_pvt, int force)
+switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
 {
 	switch_channel_t *channel;
 
@@ -654,7 +653,7 @@
 }
 
 
-switch_status_t sofia_glue_activate_rtp(private_object_t * tech_pvt)
+switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt)
 {
 	int bw, ms;
 	switch_channel_t *channel;
@@ -773,9 +772,9 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-switch_status_t sofia_glue_tech_media(private_object_t * tech_pvt, char *r_sdp)
+switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp)
 {
-	sdp_parser_t *parser = sdp_parse(tech_pvt->home, r_sdp, (int) strlen(r_sdp), 0);
+	sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
 	sdp_session_t *sdp;
 	uint8_t match = 0;
 	switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
@@ -812,7 +811,7 @@
 
 
 
-uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t * sdp)
+uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
 {
 	uint8_t match = 0;
 	switch_payload_t te = 0, cng_pt = 0;
@@ -1062,7 +1061,7 @@
 }
 
 
-void sofia_glue_pass_sdp(private_object_t * tech_pvt, char *sdp)
+void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
 {
 	char *val;
 	switch_channel_t *channel;
@@ -1120,7 +1119,7 @@
 	return profile;
 }
 
-void sofia_glue_add_profile(char *key, sofia_profile_t * profile)
+void sofia_glue_add_profile(char *key, sofia_profile_t *profile)
 {
 	switch_mutex_lock(mod_sofia_globals.hash_mutex);
 	switch_core_hash_insert(mod_sofia_globals.profile_hash, key, profile);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Fri Apr 13 18:15:58 2007
@@ -128,7 +128,7 @@
 	}
 }
 
-void sofia_presence_establish_presence(sofia_profile_t * profile)
+void sofia_presence_establish_presence(sofia_profile_t *profile)
 {
 
 	if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, 
@@ -612,7 +612,7 @@
 
 void sofia_presence_handle_sip_i_subscribe(int status,
 							char const *phrase,
-							nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+							nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sip) {
 		long exp, exp_raw;
@@ -792,12 +792,12 @@
 
 void sofia_presence_handle_sip_r_subscribe(int status,
 							char const *phrase,
-							nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+							nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 
 }
 
-void sofia_presence_handle_sip_i_publish(nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sip) {
 		sip_from_t const *from = sip->sip_from;
@@ -917,7 +917,7 @@
 
 void sofia_presence_handle_sip_i_message(int status,
 						  char const *phrase,
-						  nua_t * nua, sofia_profile_t * profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
+						  nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	if (sip) {
 		sip_from_t const *from = sip->sip_from;
@@ -1028,7 +1028,7 @@
 	}
 }
 
-void sofia_presence_set_chat_hash(private_object_t * tech_pvt, sip_t const *sip)
+void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
 {
 	char hash_key[256] = "";
 	char buf[512];
@@ -1038,7 +1038,7 @@
 	}
 
 	if (sofia_reg_find_reg_url(tech_pvt->profile, sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host, buf, sizeof(buf))) {
-		tech_pvt->chat_from = sip_header_as_string(tech_pvt->home, (const sip_header_t *) sip->sip_to);
+		tech_pvt->chat_from = sip_header_as_string(tech_pvt->sofia_private->home, (const sip_header_t *) sip->sip_to);
 		tech_pvt->chat_to = switch_core_session_strdup(tech_pvt->session, buf);
 		sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
 	} else {

Modified: freeswitch/trunk/src/mod/languages/mod_perl/fs_perl.pm
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/fs_perl.pm	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/fs_perl.pm	Fri Apr 13 18:15:58 2007
@@ -76,4 +76,8 @@
 
 package fs_perl;
 
+*FREESWITCH_PEN = *fs_perlc::FREESWITCH_PEN;
+*FREESWITCH_OID_PREFIX = *fs_perlc::FREESWITCH_OID_PREFIX;
+*FREESWITCH_ITAD = *fs_perlc::FREESWITCH_ITAD;
+*__EXTENSIONS__ = *fs_perlc::__EXTENSIONS__;
 1;

Modified: freeswitch/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c	Fri Apr 13 18:15:58 2007
@@ -15,8 +15,7 @@
  * clashes if multiple interpreters are included
  *
  ************************************************************************/
-#include <switch.h>
-
+#include "switch.h"
 #define SWIG_TypeRegister    SWIG_Perl_TypeRegister
 #define SWIG_TypeCheck       SWIG_Perl_TypeCheck
 #define SWIG_TypeCast        SWIG_Perl_TypeCast
@@ -24,8 +23,8 @@
 #define SWIG_TypeName        SWIG_Perl_TypeName
 #define SWIG_TypeQuery       SWIG_Perl_TypeQuery
 #define SWIG_TypeClientData  SWIG_Perl_TypeClientData
-#define SWIG_PackData        SWIG_Perl_PackData
-#define SWIG_UnpackData      SWIG_Perl_UnpackData
+#define SWIG_PackData        SWIG_Perl_PackData 
+#define SWIG_UnpackData      SWIG_Perl_UnpackData 
 
 
 /***********************************************************************
@@ -78,205 +77,194 @@
 extern "C" {
 #endif
 
-	typedef void *(*swig_converter_func) (void *);
-	typedef struct swig_type_info *(*swig_dycast_func) (void **);
+typedef void *(*swig_converter_func)(void *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
 
-	typedef struct swig_type_info {
-		const char *name;
-		swig_converter_func converter;
-		const char *str;
-		void *clientdata;
-		swig_dycast_func dcast;
-		struct swig_type_info *next;
-		struct swig_type_info *prev;
-	} swig_type_info;
+typedef struct swig_type_info {
+  const char             *name;
+  swig_converter_func     converter;
+  const char             *str;
+  void                   *clientdata;
+  swig_dycast_func        dcast;
+  struct swig_type_info  *next;
+  struct swig_type_info  *prev;
+} swig_type_info;
 
 #ifdef SWIG_NOINCLUDE
 
-	               SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
-	               SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
-	     SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
-	     SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
-	     SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *);
-	      SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
-	     SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
-	     SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
-	    SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
+SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
+SWIGIMPORT(void *)           SWIG_TypeCast(swig_type_info *, void *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
+SWIGIMPORT(const char *)     SWIG_TypeName(const swig_type_info *);
+SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
+SWIGIMPORT(void)             SWIG_TypeClientData(swig_type_info *, void *);
+SWIGIMPORT(char *)           SWIG_PackData(char *, void *, int);
+SWIGIMPORT(char *)           SWIG_UnpackData(char *, void *, int);
 
 #else
 
-	static swig_type_info *swig_type_list = 0;
+static swig_type_info *swig_type_list = 0;
 
 /* Register a type mapping with the type-checking */
-	               SWIGRUNTIME(swig_type_info *)
-	               SWIG_TypeRegister(swig_type_info * ti) {
-		swig_type_info *tc, *head, *ret, *next;
-		/* Check to see if this type has already been registered */
-		               tc = swig_type_list;
-		while          (tc) {
-			if (strcmp(tc->name, ti->name) == 0) {
-				/* Already exists in the table.  Just add additional types to the list */
-				if (tc->clientdata)
-					ti->clientdata = tc->clientdata;
-				head = tc;
-				next = tc->next;
-				goto l1;
-			}
-			tc = tc->prev;
-		}
-		head = ti;
-		next = 0;
-
-		/* Place in list */
-		ti->prev = swig_type_list;
-		swig_type_list = ti;
-
-		/* Build linked lists */
-	  l1:
-		ret = head;
-		tc = ti + 1;
-		/* Patch up the rest of the links */
-		while (tc->name) {
-			head->next = tc;
-			tc->prev = head;
-			head = tc;
-			tc++;
-		}
-		if (next)
-			next->prev = head;
-		head->next = next;
-		return ret;
-	}
+SWIGRUNTIME(swig_type_info *)
+SWIG_TypeRegister(swig_type_info *ti) {
+  swig_type_info *tc, *head, *ret, *next;
+  /* Check to see if this type has already been registered */
+  tc = swig_type_list;
+  while (tc) {
+    if (strcmp(tc->name, ti->name) == 0) {
+      /* Already exists in the table.  Just add additional types to the list */
+      if (tc->clientdata) ti->clientdata = tc->clientdata;
+      head = tc;
+      next = tc->next;
+      goto l1;
+    }
+    tc = tc->prev;
+  }
+  head = ti;
+  next = 0;
+
+  /* Place in list */
+  ti->prev = swig_type_list;
+  swig_type_list = ti;
+
+  /* Build linked lists */
+  l1:
+  ret = head;
+  tc = ti + 1;
+  /* Patch up the rest of the links */
+  while (tc->name) {
+    head->next = tc;
+    tc->prev = head;
+    head = tc;
+    tc++;
+  }
+  if (next) next->prev = head;
+  head->next = next;
+  return ret;
+}
 
 /* Check the typename */
-	SWIGRUNTIME(swig_type_info *)
-		SWIG_TypeCheck(char *c, swig_type_info * ty) {
-		swig_type_info *s;
-		if (!ty)
-			return 0;			/* Void pointer */
-		s = ty->next;			/* First element always just a name */
-		do {
-			if (strcmp(s->name, c) == 0) {
-				if (s == ty->next)
-					return s;
-				/* Move s to the top of the linked list */
-				s->prev->next = s->next;
-				if (s->next) {
-					s->next->prev = s->prev;
-				}
-				/* Insert s as second element in the list */
-				s->next = ty->next;
-				if (ty->next)
-					ty->next->prev = s;
-				ty->next = s;
-				s->prev = ty;
-				return s;
-			}
-			s = s->next;
-		} while (s && (s != ty->next));
-		return 0;
-	}
+SWIGRUNTIME(swig_type_info *) 
+SWIG_TypeCheck(char *c, swig_type_info *ty) {
+  swig_type_info *s;
+  if (!ty) return 0;        /* Void pointer */
+  s = ty->next;             /* First element always just a name */
+  do {
+    if (strcmp(s->name,c) == 0) {
+      if (s == ty->next) return s;
+      /* Move s to the top of the linked list */
+      s->prev->next = s->next;
+      if (s->next) {
+        s->next->prev = s->prev;
+      }
+      /* Insert s as second element in the list */
+      s->next = ty->next;
+      if (ty->next) ty->next->prev = s;
+      ty->next = s;
+      s->prev = ty;
+      return s;
+    }
+    s = s->next;
+  } while (s && (s != ty->next));
+  return 0;
+}
 
 /* Cast a pointer up an inheritance hierarchy */
-	SWIGRUNTIME(void *)
-		SWIG_TypeCast(swig_type_info * ty, void *ptr) {
-		if ((!ty) || (!ty->converter))
-			return ptr;
-		return (*ty->converter) (ptr);
-	}
+SWIGRUNTIME(void *) 
+SWIG_TypeCast(swig_type_info *ty, void *ptr) {
+  if ((!ty) || (!ty->converter)) return ptr;
+  return (*ty->converter)(ptr);
+}
 
 /* Dynamic pointer casting. Down an inheritance hierarchy */
-	SWIGRUNTIME(swig_type_info *)
-		SWIG_TypeDynamicCast(swig_type_info * ty, void **ptr) {
-		swig_type_info *lastty = ty;
-		if (!ty || !ty->dcast)
-			return ty;
-		while (ty && (ty->dcast)) {
-			ty = (*ty->dcast) (ptr);
-			if (ty)
-				lastty = ty;
-		}
-		return lastty;
-	}
+SWIGRUNTIME(swig_type_info *) 
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+  swig_type_info *lastty = ty;
+  if (!ty || !ty->dcast) return ty;
+  while (ty && (ty->dcast)) {
+    ty = (*ty->dcast)(ptr);
+    if (ty) lastty = ty;
+  }
+  return lastty;
+}
 
 /* Return the name associated with this type */
-	SWIGRUNTIME(const char *)
-		SWIG_TypeName(const swig_type_info * ty) {
-		return ty->name;
-	}
+SWIGRUNTIME(const char *)
+SWIG_TypeName(const swig_type_info *ty) {
+  return ty->name;
+}
 
 /* Search for a swig_type_info structure */
-	SWIGRUNTIME(swig_type_info *)
-		SWIG_TypeQuery(const char *name) {
-		swig_type_info *ty = swig_type_list;
-		while (ty) {
-			if (ty->str && (strcmp(name, ty->str) == 0))
-				return ty;
-			if (ty->name && (strcmp(name, ty->name) == 0))
-				return ty;
-			ty = ty->prev;
-		}
-		return 0;
-	}
+SWIGRUNTIME(swig_type_info *)
+SWIG_TypeQuery(const char *name) {
+  swig_type_info *ty = swig_type_list;
+  while (ty) {
+    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
+    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
+    ty = ty->prev;
+  }
+  return 0;
+}
 
 /* Set the clientdata field for a type */
-	SWIGRUNTIME(void)
-		SWIG_TypeClientData(swig_type_info * ti, void *clientdata) {
-		swig_type_info *tc, *equiv;
-		if (ti->clientdata == clientdata)
-			return;
-		ti->clientdata = clientdata;
-		equiv = ti->next;
-		while (equiv) {
-			if (!equiv->converter) {
-				tc = swig_type_list;
-				while (tc) {
-					if ((strcmp(tc->name, equiv->name) == 0))
-						SWIG_TypeClientData(tc, clientdata);
-					tc = tc->prev;
-				}
-			}
-			equiv = equiv->next;
-		}
-	}
+SWIGRUNTIME(void)
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+  swig_type_info *tc, *equiv;
+  if (ti->clientdata == clientdata) return;
+  ti->clientdata = clientdata;
+  equiv = ti->next;
+  while (equiv) {
+    if (!equiv->converter) {
+      tc = swig_type_list;
+      while (tc) {
+        if ((strcmp(tc->name, equiv->name) == 0))
+          SWIG_TypeClientData(tc,clientdata);
+        tc = tc->prev;
+      }
+    }
+    equiv = equiv->next;
+  }
+}
 
 /* Pack binary data into a string */
-	SWIGRUNTIME(char *)
-	     SWIG_PackData(char *c, void *ptr, int sz) {
-		static char hex[17] = "0123456789abcdef";
-		int i;
-		unsigned char *u = (unsigned char *) ptr;
-		register unsigned char uu;
-		for (i = 0; i < sz; i++, u++) {
-			uu = *u;
-			*(c++) = hex[(uu & 0xf0) >> 4];
-			*(c++) = hex[uu & 0xf];
-		}
-		return c;
-	}
+SWIGRUNTIME(char *)
+SWIG_PackData(char *c, void *ptr, int sz) {
+  static char hex[17] = "0123456789abcdef";
+  int i;
+  unsigned char *u = (unsigned char *) ptr;
+  register unsigned char uu;
+  for (i = 0; i < sz; i++,u++) {
+    uu = *u;
+    *(c++) = hex[(uu & 0xf0) >> 4];
+    *(c++) = hex[uu & 0xf];
+  }
+  return c;
+}
 
 /* Unpack binary data from a string */
-	SWIGRUNTIME(char *)
-		SWIG_UnpackData(char *c, void *ptr, int sz) {
-		register unsigned char uu = 0;
-		register int d;
-		unsigned char *u = (unsigned char *) ptr;
-		int i;
-		for (i = 0; i < sz; i++, u++) {
-			d = *(c++);
-			if ((d >= '0') && (d <= '9'))
-				uu = ((d - '0') << 4);
-			else if ((d >= 'a') && (d <= 'f'))
-				uu = ((d - ('a' - 10)) << 4);
-			d = *(c++);
-			if ((d >= '0') && (d <= '9'))
-				uu |= (d - '0');
-			else if ((d >= 'a') && (d <= 'f'))
-				uu |= (d - ('a' - 10));
-			*u = uu;
-		}
-		return c;
-	}
+SWIGRUNTIME(char *)
+SWIG_UnpackData(char *c, void *ptr, int sz) {
+  register unsigned char uu = 0;
+  register int d;
+  unsigned char *u = (unsigned char *) ptr;
+  int i;
+  for (i = 0; i < sz; i++, u++) {
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu = ((d - '0') << 4);
+    else if ((d >= 'a') && (d <= 'f'))
+      uu = ((d - ('a'-10)) << 4);
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu |= (d - '0');
+    else if ((d >= 'a') && (d <= 'f'))
+      uu |= (d - ('a'-10));
+    *u = uu;
+  }
+  return c;
+}
 
 #endif
 
@@ -315,30 +303,37 @@
 #ifdef __cplusplus
 }
 #endif
+
 /* Macro to call an XS function */
-#ifdef PERL_OBJECT
-#  define SWIG_CALLXS(_name) _name(cv,pPerl)
-#else
-#  ifndef MULTIPLICITY
-#    define SWIG_CALLXS(_name) _name(cv)
-#  else
-#    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
-#  endif
-#endif
+
+#ifdef PERL_OBJECT 
+#  define SWIG_CALLXS(_name) _name(cv,pPerl) 
+#else 
+#  ifndef MULTIPLICITY 
+#    define SWIG_CALLXS(_name) _name(cv) 
+#  else 
+#    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) 
+#  endif 
+#endif 
+
 /* Contract support */
+
 #define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else
+
 /* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
+
 #ifdef PERL_OBJECT
 #define MAGIC_PPERL  CPerlObj *pPerl = (CPerlObj *) this;
-typedef int (CPerlObj::*SwigMagicFunc) (SV *, MAGIC *);
+typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-	typedef int (CPerlObj::*SwigMagicFuncHack) (SV *, MAGIC *);
+typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
+
 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
 #define SWIGCLASS_STATIC
 #else
@@ -346,31 +341,37 @@
 #define SWIGCLASS_STATIC static
 #ifndef MULTIPLICITY
 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc) (SV *, MAGIC *);
+typedef int (*SwigMagicFunc)(SV *, MAGIC *);
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-	typedef int (*SwigMagicFuncHack) (SV *, MAGIC *);
+typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
+
+
 #else
 #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc) (struct interpreter *, SV *, MAGIC *);
+typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
 #ifdef __cplusplus
 extern "C" {
 #endif
-	typedef int (*SwigMagicFuncHack) (struct interpreter *, SV *, MAGIC *);
+typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
 #ifdef __cplusplus
 }
 #endif
+
 #endif
 #endif
+
 #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
 #define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
 #endif
+
 /* Modifications for newer Perl 5.005 releases */
+
 #if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
 #  ifndef PL_sv_yes
 #    define PL_sv_yes sv_yes
@@ -382,7 +383,9 @@
 #    define PL_na na
 #  endif
 #endif
+
 #include <stdlib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -443,195 +446,187 @@
 
 #ifdef SWIG_NOINCLUDE
 
-	SWIGIMPORT(int) SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *, void **, swig_type_info *, int flags);
-	    SWIGIMPORT(void) SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *, void *, swig_type_info *, int flags);
-	    SWIGIMPORT(SV *) SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *, swig_type_info *, int flags);
-	    SWIGIMPORT(void) SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *);
-	    SWIGIMPORT(int) SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *, int flags);
-	    SWIGIMPORT(swig_type_info *) SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV * rv, swig_type_info * ty);
-	    SWIGIMPORT(SV *) SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT char *);
+SWIGIMPORT(int)               SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *, void **, swig_type_info *, int flags);
+SWIGIMPORT(void)              SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *, void *, swig_type_info *, int flags);
+SWIGIMPORT(SV *)              SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *, swig_type_info *, int flags);
+SWIGIMPORT(void)              SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *);
+SWIGIMPORT(int)               SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *, void *, int, swig_type_info *, int flags);
+SWIGIMPORT(swig_type_info *)  SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty);
+SWIGIMPORT(SV *)              SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT char *);
 
 #else
 
-	     SWIGRUNTIME(swig_type_info *)
-	     SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV * rv, swig_type_info * ty) {
-		swig_type_info *s;
-		if             (!ty)
-			               return 0;	/* Void pointer */
-		               s = ty->next;	/* First element always just a name */
-		do {
-			if (sv_derived_from(rv, (char *) s->name)) {
-				if (s == ty->next)
-					return s;
-				/* Move s to the top of the linked list */
-				s->prev->next = s->next;
-				if (s->next) {
-					s->next->prev = s->prev;
-				}
-				/* Insert s as second element in the list */
-				s->    next = ty->next;
-				if (ty->next)
-					ty->next->prev = s;
-				ty->next = s;
-				s->prev = ty;
-				return s;
-			}
-			s = s->next;
-		} while (s && (s != ty->next));
-		return 0;
-	}
+SWIGRUNTIME(swig_type_info *)
+SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
+  swig_type_info *s;
+  if (!ty) return 0;        /* Void pointer */
+  s = ty->next;             /* First element always just a name */
+  do {
+    if (sv_derived_from(rv, (char *) s->name)) {
+      if (s == ty->next) return s;
+      /* Move s to the top of the linked list */
+      s->prev->next = s->next;
+      if (s->next) {
+        s->next->prev = s->prev;
+      }
+      /* Insert s as second element in the list */
+      s->next = ty->next;
+      if (ty->next) ty->next->prev = s;
+      ty->next = s;
+      s->prev = ty;
+      return s;
+    }
+    s = s->next;
+  } while (s && (s != ty->next));
+  return 0;
+}
 
 /* Function for getting a pointer value */
 
-	SWIGRUNTIME(int)
-		SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV * sv, void **ptr, swig_type_info * _t, int flags) {
-		swig_type_info *tc;
-		void *voidptr = (void *) 0;
-
-		/* If magical, apply more magic */
-		if (SvGMAGICAL(sv))
-			mg_get(sv);
-
-		/* Check to see if this is an object */
-		if (sv_isobject(sv)) {
-			SV *tsv = (SV *) SvRV(sv);
-			IV tmp = 0;
-			if ((SvTYPE(tsv) == SVt_PVHV)) {
-				MAGIC *mg;
-				if (SvMAGICAL(tsv)) {
-					mg = mg_find(tsv, 'P');
-					if (mg) {
-						SV *rsv = mg->mg_obj;
-						if (sv_isobject(rsv)) {
-							tmp = SvIV((SV *) SvRV(rsv));
-						}
-					}
-				} else {
-					return -1;
-				}
-			} else {
-				tmp = SvIV((SV *) SvRV(sv));
-			}
-			voidptr = (void *) tmp;
-			if (!_t) {
-				*(ptr) = voidptr;
-				return 0;
-			}
-		} else if (!SvOK(sv)) {	/* Check for undef */
-			*(ptr) = (void *) 0;
-			return 0;
-		} else if (SvTYPE(sv) == SVt_RV) {	/* Check for NULL pointer */
-			*(ptr) = (void *) 0;
-			if (!SvROK(sv))
-				return 0;
-			else
-				return -1;
-		} else {				/* Don't know what it is */
-			*(ptr) = (void *) 0;
-			return -1;
-		}
-		if (_t) {
-			/* Now see if the types match */
-			tc = SWIG_TypeCheckRV(sv, _t);
-			if (!tc) {
-				*ptr = voidptr;
-				return -1;
-			}
-			*ptr = SWIG_TypeCast(tc, voidptr);
-			return 0;
-		}
-		*ptr = voidptr;
-		return 0;
-	}
-
-	SWIGRUNTIME(void)
-		SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV * sv, void *ptr, swig_type_info * t, int flags) {
-		if (ptr && (flags & SWIG_SHADOW)) {
-			SV *self;
-			SV *obj = newSV(0);
-			HV *hash = newHV();
-			HV *stash;
-			sv_setref_pv(obj, (char *) t->name, ptr);
-			stash = SvSTASH(SvRV(obj));
-			if (flags & SWIG_OWNER) {
-				HV *hv;
-				GV *gv = *(GV **) hv_fetch(stash, "OWNER", 5, TRUE);
-				if (!isGV(gv))
-					gv_init(gv, stash, "OWNER", 5, FALSE);
-				hv = GvHVn(gv);
-				hv_store_ent(hv, obj, newSViv(1), 0);
-			}
-			sv_magic((SV *) hash, (SV *) obj, 'P', Nullch, 0);
-			SvREFCNT_dec(obj);
-			self = newRV_noinc((SV *) hash);
-			sv_setsv(sv, self);
-			SvREFCNT_dec((SV *) self);
-			sv_bless(sv, stash);
-		} else {
-			sv_setref_pv(sv, (char *) t->name, ptr);
-		}
-	}
-
-	SWIGRUNTIME(SV *)
-		SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info * t, int flags) {
-		SV *result = sv_newmortal();
-		SWIG_MakePtr(result, ptr, t, flags);
-		return result;
-	}
-
-	SWIGRUNTIME(void)
-		SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV * sv, void *ptr, int sz, swig_type_info * type) {
-		char result[1024];
-		char *r = result;
-		if ((2 * sz + 1 + strlen(type->name)) > 1000)
-			return;
-		*(r++) = '_';
-		r = SWIG_PackData(r, ptr, sz);
-		strcpy(r, type->name);
-		sv_setpv(sv, result);
-	}
+SWIGRUNTIME(int) 
+SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
+  swig_type_info *tc;
+  void *voidptr = (void *)0;
+
+  /* If magical, apply more magic */
+  if (SvGMAGICAL(sv))
+    mg_get(sv);
+
+  /* Check to see if this is an object */
+  if (sv_isobject(sv)) {
+    SV *tsv = (SV*) SvRV(sv);
+    IV tmp = 0;
+    if ((SvTYPE(tsv) == SVt_PVHV)) {
+      MAGIC *mg;
+      if (SvMAGICAL(tsv)) {
+        mg = mg_find(tsv,'P');
+        if (mg) {
+          SV *rsv = mg->mg_obj;
+          if (sv_isobject(rsv)) {
+            tmp = SvIV((SV*)SvRV(rsv));
+          }
+        }
+      } else {
+        return -1;
+      }
+    } else {
+      tmp = SvIV((SV*)SvRV(sv));
+    }
+    voidptr = (void *)tmp;
+    if (!_t) {
+      *(ptr) = voidptr;
+      return 0;
+    }
+  } else if (! SvOK(sv)) {            /* Check for undef */
+    *(ptr) = (void *) 0;
+    return 0;
+  } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
+    *(ptr) = (void *) 0;
+    if (!SvROK(sv))
+      return 0;
+    else
+      return -1;
+  } else {                            /* Don't know what it is */
+    *(ptr) = (void *) 0;
+    return -1;
+  }
+  if (_t) {
+    /* Now see if the types match */
+    tc = SWIG_TypeCheckRV(sv,_t);
+    if (!tc) {
+      *ptr = voidptr;
+      return -1;
+    }
+    *ptr = SWIG_TypeCast(tc,voidptr);
+    return 0;
+  }
+  *ptr = voidptr;
+  return 0;
+}
+
+SWIGRUNTIME(void)
+SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
+  if (ptr && (flags & SWIG_SHADOW)) {
+    SV *self;
+    SV *obj=newSV(0);
+    HV *hash=newHV();
+    HV *stash;
+    sv_setref_pv(obj, (char *) t->name, ptr);
+    stash=SvSTASH(SvRV(obj));
+    if (flags & SWIG_OWNER) {
+      HV *hv;
+      GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
+      if (!isGV(gv))
+        gv_init(gv, stash, "OWNER", 5, FALSE);
+      hv=GvHVn(gv);
+      hv_store_ent(hv, obj, newSViv(1), 0);
+    }
+    sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0);
+    SvREFCNT_dec(obj);
+    self=newRV_noinc((SV *)hash);
+    sv_setsv(sv, self);
+    SvREFCNT_dec((SV *)self);
+    sv_bless(sv, stash);
+  }
+  else {
+    sv_setref_pv(sv, (char *) t->name, ptr);
+  }
+}
+
+SWIGRUNTIME(SV *)
+SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
+  SV *result = sv_newmortal();
+  SWIG_MakePtr(result, ptr, t, flags);
+  return result;
+}
+
+SWIGRUNTIME(void)
+  SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
+  char result[1024];
+  char *r = result;
+  if ((2*sz + 1 + strlen(type->name)) > 1000) return;
+  *(r++) = '_';
+  r = SWIG_PackData(r,ptr,sz);
+  strcpy(r,type->name);
+  sv_setpv(sv, result);
+}
 
 /* Convert a packed value value */
-	SWIGRUNTIME(int)
-		SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV * obj, void *ptr, int sz, swig_type_info * ty, int flags) {
-		swig_type_info *tc;
-		char *c = 0;
-
-		if ((!obj) || (!SvOK(obj)))
-			return -1;
-		c = SvPV(obj, PL_na);
-		/* Pointer values must start with leading underscore */
-		if (*c != '_')
-			return -1;
-		c++;
-		c = SWIG_UnpackData(c, ptr, sz);
-		if (ty) {
-			tc = SWIG_TypeCheck(c, ty);
-			if (!tc)
-				return -1;
-		}
-		return 0;
-	}
-
-	SWIGRUNTIME(void)
-		SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
-		if (error)
-			sv_setpv(perl_get_sv("@", TRUE), error);
-	}
-
-	SWIGRUNTIME(void)
-	     SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV * error) {
-		if (error)
-			sv_setsv(perl_get_sv("@", TRUE), error);
-	}
-
-	SWIGRUNTIME(void)
-	     SWIG_Perl_SetErrorf(const char *fmt, ...) {
-		va_list args;
-		va_start(args, fmt);
-		sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV **), 0, Null(bool *));
-		va_end(args);
-	}
+SWIGRUNTIME(int)
+SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+  swig_type_info *tc;
+  char  *c = 0;
+
+  if ((!obj) || (!SvOK(obj))) return -1;
+  c = SvPV(obj, PL_na);
+  /* Pointer values must start with leading underscore */
+  if (*c != '_') return -1;
+  c++;
+  c = SWIG_UnpackData(c,ptr,sz);
+  if (ty) {
+    tc = SWIG_TypeCheck(c,ty);
+    if (!tc) return -1;
+  }
+  return 0;
+}
+
+SWIGRUNTIME(void)
+SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
+  if (error) sv_setpv(perl_get_sv("@", TRUE), error);
+}
+
+SWIGRUNTIME(void)
+SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) {
+  if (error) sv_setsv(perl_get_sv("@", TRUE), error);
+}
+
+SWIGRUNTIME(void)
+SWIG_Perl_SetErrorf(const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*));
+  va_end(args);
+}
 
 #endif
 
@@ -643,14 +638,14 @@
 /* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */
 
 
-	typedef XS(SwigPerlWrapper);
-	typedef SwigPerlWrapper *SwigPerlWrapperPtr;
+typedef XS(SwigPerlWrapper);
+typedef SwigPerlWrapper *SwigPerlWrapperPtr;
 
 /* Structure for command table */
-	typedef struct {
-		const char *name;
-		SwigPerlWrapperPtr wrapper;
-	} swig_command_info;
+typedef struct {
+  const char         *name;
+  SwigPerlWrapperPtr  wrapper;
+} swig_command_info;
 
 /* Information for constant table */
 
@@ -661,14 +656,14 @@
 #define SWIG_BINARY  5
 
 /* Constant information structure */
-	typedef struct swig_constant_info {
-		int type;
-		const char *name;
-		long lvalue;
-		double dvalue;
-		void *pvalue;
-		swig_type_info **ptype;
-	} swig_constant_info;
+typedef struct swig_constant_info {
+    int              type;
+    const char      *name;
+    long             lvalue;
+    double           dvalue;
+    void            *pvalue;
+    swig_type_info **ptype;
+} swig_constant_info;
 
 #ifdef __cplusplus
 }
@@ -676,36 +671,33 @@
 
 /* Structure for variable table */
 typedef struct {
-	const char *name;
-	SwigMagicFunc set;
-	SwigMagicFunc get;
-	swig_type_info **type;
+  const char   *name;
+  SwigMagicFunc   set;
+  SwigMagicFunc   get;
+  swig_type_info  **type;
 } swig_variable_info;
 
 /* Magic variable code */
 #ifndef PERL_OBJECT
 #define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
-#ifndef MULTIPLICITY
-static void _swig_create_magic(SV * sv, char *name, int (*set) (SV *, MAGIC *), int (*get) (SV *, MAGIC *))
-{
-#else
-static void _swig_create_magic(SV * sv, char *name, int (*set) (struct interpreter *, SV *, MAGIC *), int (*get) (struct interpreter *, SV *, MAGIC *))
-{
-#endif
+  #ifndef MULTIPLICITY
+     static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
+  #else
+     static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) {
+  #endif
 #else
 #  define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-static void _swig_create_magic(CPerlObj * pPerl, SV * sv, const char *name, int (CPerlObj::*set) (SV *, MAGIC *), int (CPerlObj::*get) (SV *, MAGIC *))
-{
+static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
 #endif
-	MAGIC *mg;
-	sv_magic(sv, sv, 'U', (char *) name, strlen(name));
-	mg = mg_find(sv, 'U');
-	mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
-	mg->mg_virtual->svt_get = (SwigMagicFuncHack) get;
-	mg->mg_virtual->svt_set = (SwigMagicFuncHack) set;
-	mg->mg_virtual->svt_len = 0;
-	mg->mg_virtual->svt_clear = 0;
-	mg->mg_virtual->svt_free = 0;
+  MAGIC *mg;
+  sv_magic(sv,sv,'U',(char *) name,strlen(name));
+  mg = mg_find(sv,'U');
+  mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
+  mg->mg_virtual->svt_get = (SwigMagicFuncHack) get;
+  mg->mg_virtual->svt_set = (SwigMagicFuncHack) set;
+  mg->mg_virtual->svt_len = 0;
+  mg->mg_virtual->svt_clear = 0;
+  mg->mg_virtual->svt_free = 0;
 }
 
 
@@ -714,69 +706,69 @@
 
 
 #ifdef do_open
-#undef do_open
+  #undef do_open
 #endif
 #ifdef do_close
-#undef do_close
+  #undef do_close
 #endif
 #ifdef scalar
-#undef scalar
+  #undef scalar
 #endif
 #ifdef list
-#undef list
+  #undef list
 #endif
 #ifdef apply
-#undef apply
+  #undef apply
 #endif
 #ifdef convert
-#undef convert
+  #undef convert
 #endif
 #ifdef Error
-#undef Error
+  #undef Error
 #endif
 #ifdef form
-#undef form
+  #undef form
 #endif
 #ifdef vform
-#undef vform
+  #undef vform
 #endif
 #ifdef LABEL
-#undef LABEL
+  #undef LABEL
 #endif
 #ifdef METHOD
-#undef METHOD
+  #undef METHOD
 #endif
 #ifdef Move
-#undef Move
+  #undef Move
 #endif
 #ifdef yylex
-#undef yylex
+  #undef yylex
 #endif
 #ifdef yyparse
-#undef yyparse
+  #undef yyparse
 #endif
 #ifdef yyerror
-#undef yyerror
+  #undef yyerror
 #endif
 #ifdef invert
-#undef invert
+  #undef invert
 #endif
 #ifdef ref
-#undef ref
+  #undef ref
 #endif
 #ifdef ENTER
-#undef ENTER
+  #undef ENTER
 #endif
 
 
 /* -------- TYPES TABLE (BEGIN) -------- */
 
-#define  SWIGTYPE_p_switch_channel_t swig_types[0]
-#define  SWIGTYPE_p_switch_file_handle_t swig_types[1]
-#define  SWIGTYPE_p_switch_core_session_t swig_types[2]
-#define  SWIGTYPE_p_p_switch_core_session_t swig_types[3]
-#define  SWIGTYPE_p_uint32_t swig_types[4]
-#define  SWIGTYPE_p_switch_input_callback_function_t swig_types[5]
+#define  SWIGTYPE_p_switch_channel_t swig_types[0] 
+#define  SWIGTYPE_p_switch_file_handle_t swig_types[1] 
+#define  SWIGTYPE_p_switch_core_session_t swig_types[2] 
+#define  SWIGTYPE_p_p_switch_core_session_t swig_types[3] 
+#define  SWIGTYPE_p_uint32_t swig_types[4] 
+#define  SWIGTYPE_p_switch_input_args_t swig_types[5] 
 static swig_type_info *swig_types[7];
 
 /* -------- TYPES TABLE (END) -------- */
@@ -791,57 +783,55 @@
 #endif
 #ifndef PERL_OBJECT
 #ifndef MULTIPLICITY
-SWIGEXPORT(void) SWIG_init(CV * cv);
+SWIGEXPORT(void) SWIG_init (CV* cv);
 #else
-SWIGEXPORT(void) SWIG_init(pTHXo_ CV * cv);
+SWIGEXPORT(void) SWIG_init (pTHXo_ CV* cv);
 #endif
 #else
-SWIGEXPORT(void) SWIG_init(CV * cv, CPerlObj *);
+SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *);
 #endif
 
-	 extern void fs_core_set_globals(void);
-	 extern int fs_core_init(char *);
-	 extern int fs_core_destroy(void);
-	 extern int fs_loadable_module_init(void);
-	 extern int fs_loadable_module_shutdown(void);
-	 extern int fs_console_loop(void);
-	 extern void fs_consol_log(char *, char *);
-	 extern void fs_consol_clean(char *);
-	 extern switch_core_session_t *fs_core_session_locate(char *);
-	 extern void fs_channel_answer(switch_core_session_t *);
-	 extern void fs_channel_pre_answer(switch_core_session_t *);
-	 extern void fs_channel_hangup(switch_core_session_t *, char *);
-	 extern void fs_channel_set_variable(switch_core_session_t *, char *, char *);
-	 extern void fs_channel_get_variable(switch_core_session_t *, char *);
-	 extern void fs_channel_set_state(switch_core_session_t *, char *);
-	 extern int fs_ivr_play_file(switch_core_session_t *, char *);
-	 extern int fs_switch_ivr_record_file(switch_core_session_t *, switch_file_handle_t *, char *,
-										  switch_input_callback_function_t, void *, unsigned int, unsigned int);
-	 extern int fs_switch_ivr_sleep(switch_core_session_t *, uint32_t);
-	 extern int fs_ivr_play_file2(switch_core_session_t *, char *);
-	 extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *, switch_input_callback_function_t, void *, unsigned int, unsigned int);
-	 extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *, char *, unsigned int, unsigned int, char const *, char *, unsigned int);
-	 extern int fs_switch_ivr_originate(switch_core_session_t *, switch_core_session_t **, char *, uint32_t);
-	 extern int fs_switch_ivr_session_transfer(switch_core_session_t *, char *, char *, char *);
-	 extern int fs_switch_ivr_speak_text(switch_core_session_t *, char *, char *, uint32_t, char *);
-	 extern char *fs_switch_channel_get_variable(switch_channel_t *, char *);
-	 extern int fs_switch_channel_set_variable(switch_channel_t *, char *, char *);
+extern void fs_core_set_globals(void);
+extern int fs_core_init(char *);
+extern int fs_core_destroy(void);
+extern int fs_loadable_module_init(void);
+extern int fs_loadable_module_shutdown(void);
+extern int fs_console_loop(void);
+extern void fs_consol_log(char *,char *);
+extern void fs_consol_clean(char *);
+extern switch_core_session_t *fs_core_session_locate(char *);
+extern void fs_channel_answer(switch_core_session_t *);
+extern void fs_channel_pre_answer(switch_core_session_t *);
+extern void fs_channel_hangup(switch_core_session_t *,char *);
+extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
+extern void fs_channel_get_variable(switch_core_session_t *,char *);
+extern void fs_channel_set_state(switch_core_session_t *,char *);
+extern int fs_ivr_play_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_args_t *);
+extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_args_t *,unsigned int);
+extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
+extern int fs_ivr_play_file2(switch_core_session_t *,char *);
+extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_args_t *,unsigned int);
+extern int fs_switch_ivr_collect_digits_count(switch_core_session_t *,char *,unsigned int,unsigned int,char const *,char *,unsigned int);
+extern int fs_switch_ivr_originate(switch_core_session_t *,switch_core_session_t **,char *,uint32_t);
+extern int fs_switch_ivr_session_transfer(switch_core_session_t *,char *,char *,char *);
+extern int fs_switch_ivr_speak_text(switch_core_session_t *,char *,char *,uint32_t,char *);
+extern char *fs_switch_channel_get_variable(switch_channel_t *,char *);
+extern int fs_switch_channel_set_variable(switch_channel_t *,char *,char *);
+
 
-#include "switch.h"
 
 #ifdef PERL_OBJECT
 #define MAGIC_CLASS _wrap_fs_perl_var::
-	 class _wrap_fs_perl_var:public CPerlObj {
-	   public:
+class _wrap_fs_perl_var : public CPerlObj {
+public:
 #else
 #define MAGIC_CLASS
 #endif
-	 SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV * sv, MAGIC * mg)
-{
-	MAGIC_PPERL sv = sv;
-	mg = mg;
-	croak("Value is read-only.");
-	return 0;
+SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *sv, MAGIC *mg) {
+    MAGIC_PPERL
+    sv = sv; mg = mg;
+    croak("Value is read-only.");
+    return 0;
 }
 
 
@@ -852,974 +842,913 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-	XS(_wrap_fs_core_set_globals) {
-		{
-			int argvi = 0;
-			    dXSARGS;
-
-			if  ((items < 0) || (items > 0)) {
-				SWIG_croak("Usage: fs_core_set_globals();");
-			}
-			fs_core_set_globals();
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_core_init) {
-		{
-			char *arg1;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 1) || (items > 1)) {
-				SWIG_croak("Usage: fs_core_init(path);");
-			}
-			if (!SvOK((SV *) ST(0)))
-				arg1 = 0;
-			else
-				arg1 = (char *) SvPV(ST(0), PL_na);
-			result = (int) fs_core_init(arg1);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_core_destroy) {
-		{
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 0) || (items > 0)) {
-				SWIG_croak("Usage: fs_core_destroy();");
-			}
-			result = (int) fs_core_destroy();
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_loadable_module_init) {
-		{
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 0) || (items > 0)) {
-				SWIG_croak("Usage: fs_loadable_module_init();");
-			}
-			result = (int) fs_loadable_module_init();
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_loadable_module_shutdown) {
-		{
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 0) || (items > 0)) {
-				SWIG_croak("Usage: fs_loadable_module_shutdown();");
-			}
-			result = (int) fs_loadable_module_shutdown();
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_console_loop) {
-		{
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 0) || (items > 0)) {
-				SWIG_croak("Usage: fs_console_loop();");
-			}
-			result = (int) fs_console_loop();
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_consol_log) {
-		{
-			char *arg1;
-			char *arg2;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_consol_log(level_str,msg);");
-			}
-			if (!SvOK((SV *) ST(0)))
-				arg1 = 0;
-			else
-				arg1 = (char *) SvPV(ST(0), PL_na);
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			fs_consol_log(arg1, arg2);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_consol_clean) {
-		{
-			char *arg1;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 1) || (items > 1)) {
-				SWIG_croak("Usage: fs_consol_clean(msg);");
-			}
-			if (!SvOK((SV *) ST(0)))
-				arg1 = 0;
-			else
-				arg1 = (char *) SvPV(ST(0), PL_na);
-			fs_consol_clean(arg1);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_core_session_locate) {
-		{
-			char *arg1;
-			switch_core_session_t *result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 1) || (items > 1)) {
-				SWIG_croak("Usage: fs_core_session_locate(uuid);");
-			}
-			if (!SvOK((SV *) ST(0)))
-				arg1 = 0;
-			else
-				arg1 = (char *) SvPV(ST(0), PL_na);
-			result = (switch_core_session_t *) fs_core_session_locate(arg1);
-
-			ST(argvi) = sv_newmortal();
-			SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session_t, 0 | 0);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_answer) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 1) || (items > 1)) {
-				SWIG_croak("Usage: fs_channel_answer(session);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session_t");
-				}
-			}
-			fs_channel_answer(arg1);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_pre_answer) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 1) || (items > 1)) {
-				SWIG_croak("Usage: fs_channel_pre_answer(session);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session_t");
-				}
-			}
-			fs_channel_pre_answer(arg1);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_hangup) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_channel_hangup(session,cause);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			fs_channel_hangup(arg1, arg2);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_set_variable) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			char *arg3;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 3) || (items > 3)) {
-				SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			fs_channel_set_variable(arg1, arg2, arg3);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_get_variable) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_channel_get_variable(session,var);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			fs_channel_get_variable(arg1, arg2);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_channel_set_state) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_channel_set_state(session,state);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			fs_channel_set_state(arg1, arg2);
-
-
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_ivr_play_file) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_ivr_play_file(session,file);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			result = (int) fs_ivr_play_file(arg1, arg2);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_record_file) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			switch_file_handle_t *arg2 = (switch_file_handle_t *) 0;
-			char *arg3;
-			switch_input_callback_function_t arg4;
-			void *arg5 = (void *) 0;
-			unsigned int arg6;
-			unsigned int arg7;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 7) || (items > 7)) {
-				SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen,limit);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
-				}
-			}
-			{
-				if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t, 0) < 0) {
-					SWIG_croak("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
-				}
-			}
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			{
-				switch_input_callback_function_t *argp;
-				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
-					SWIG_croak("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_callback_function_t");
-				}
-				arg4 = *argp;
-			}
-			{
-				if (SWIG_ConvertPtr(ST(4), (void **) &arg5, 0, 0) < 0) {
-					SWIG_croak("Type error in argument 5 of fs_switch_ivr_record_file. Expected _p_void");
-				}
-			}
-			arg6 = (unsigned int) SvUV(ST(5));
-			arg7 = (unsigned int) SvUV(ST(6));
-			result = (int) fs_switch_ivr_record_file(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_sleep) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			uint32_t arg2;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_switch_ivr_sleep(session,ms);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_sleep. Expected _p_switch_core_session_t");
-				}
-			}
-			{
-				uint32_t *argp;
-				if (SWIG_ConvertPtr(ST(1), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
-					SWIG_croak("Type error in argument 2 of fs_switch_ivr_sleep. Expected _p_uint32_t");
-				}
-				arg2 = *argp;
-			}
-			result = (int) fs_switch_ivr_sleep(arg1, arg2);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_ivr_play_file2) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_ivr_play_file2(session,file);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_ivr_play_file2. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			result = (int) fs_ivr_play_file2(arg1, arg2);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_collect_digits_callback) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			switch_input_callback_function_t arg2;
-			void *arg3 = (void *) 0;
-			unsigned int arg4;
-			unsigned int arg5;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 5) || (items > 5)) {
-				SWIG_croak("Usage: fs_switch_ivr_collect_digits_callback(session,dtmf_callback,buf,buflen,timeout);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
-				}
-			}
-			{
-				switch_input_callback_function_t *argp;
-				if (SWIG_ConvertPtr(ST(1), (void **) &argp, SWIGTYPE_p_switch_input_callback_function_t, 0) < 0) {
-					SWIG_croak("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_callback_function_t");
-				}
-				arg2 = *argp;
-			}
-			{
-				if (SWIG_ConvertPtr(ST(2), (void **) &arg3, 0, 0) < 0) {
-					SWIG_croak("Type error in argument 3 of fs_switch_ivr_collect_digits_callback. Expected _p_void");
-				}
-			}
-			arg4 = (unsigned int) SvUV(ST(3));
-			arg5 = (unsigned int) SvUV(ST(4));
-			result = (int) fs_switch_ivr_collect_digits_callback(arg1, arg2, arg3, arg4, arg5);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_collect_digits_count) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			unsigned int arg3;
-			unsigned int arg4;
-			char *arg5;
-			char *arg6;
-			unsigned int arg7;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 7) || (items > 7)) {
-				SWIG_croak("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			arg3 = (unsigned int) SvUV(ST(2));
-			arg4 = (unsigned int) SvUV(ST(3));
-			if (!SvOK((SV *) ST(4)))
-				arg5 = 0;
-			else
-				arg5 = (char *) SvPV(ST(4), PL_na);
-			if (!SvOK((SV *) ST(5)))
-				arg6 = 0;
-			else
-				arg6 = (char *) SvPV(ST(5), PL_na);
-			arg7 = (unsigned int) SvUV(ST(6));
-			result = (int) fs_switch_ivr_collect_digits_count(arg1, arg2, arg3, arg4, (char const *) arg5, arg6, arg7);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_originate) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			switch_core_session_t **arg2 = (switch_core_session_t **) 0;
-			char *arg3;
-			uint32_t arg4;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 4) || (items > 4)) {
-				SWIG_croak("Usage: fs_switch_ivr_originate(session,bleg,bridgeto,timelimit_sec);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
-				}
-			}
-			{
-				if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			{
-				uint32_t *argp;
-				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
-					SWIG_croak("Type error in argument 4 of fs_switch_ivr_originate. Expected _p_uint32_t");
-				}
-				arg4 = *argp;
-			}
-			result = (int) fs_switch_ivr_originate(arg1, arg2, arg3, arg4);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_session_transfer) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			char *arg3;
-			char *arg4;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 4) || (items > 4)) {
-				SWIG_croak("Usage: fs_switch_ivr_session_transfer(session,extension,dialplan,context);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			if (!SvOK((SV *) ST(3)))
-				arg4 = 0;
-			else
-				arg4 = (char *) SvPV(ST(3), PL_na);
-			result = (int) fs_switch_ivr_session_transfer(arg1, arg2, arg3, arg4);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_ivr_speak_text) {
-		{
-			switch_core_session_t *arg1 = (switch_core_session_t *) 0;
-			char *arg2;
-			char *arg3;
-			uint32_t arg4;
-			char *arg5;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 5) || (items > 5)) {
-				SWIG_croak("Usage: fs_switch_ivr_speak_text(session,tts_name,voice_name,rate,text);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			{
-				uint32_t *argp;
-				if (SWIG_ConvertPtr(ST(3), (void **) &argp, SWIGTYPE_p_uint32_t, 0) < 0) {
-					SWIG_croak("Type error in argument 4 of fs_switch_ivr_speak_text. Expected _p_uint32_t");
-				}
-				arg4 = *argp;
-			}
-			if (!SvOK((SV *) ST(4)))
-				arg5 = 0;
-			else
-				arg5 = (char *) SvPV(ST(4), PL_na);
-			result = (int) fs_switch_ivr_speak_text(arg1, arg2, arg3, arg4, arg5);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_channel_get_variable) {
-		{
-			switch_channel_t *arg1 = (switch_channel_t *) 0;
-			char *arg2;
-			char *result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 2) || (items > 2)) {
-				SWIG_croak("Usage: fs_switch_channel_get_variable(channel,varname);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			result = (char *) fs_switch_channel_get_variable(arg1, arg2);
-
-			ST(argvi) = sv_newmortal();
-			if (result) {
-				sv_setpv((SV *) ST(argvi++), (char *) result);
-			} else {
-				sv_setsv((SV *) ST(argvi++), &PL_sv_undef);
-			}
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
-
-
-	XS(_wrap_fs_switch_channel_set_variable) {
-		{
-			switch_channel_t *arg1 = (switch_channel_t *) 0;
-			char *arg2;
-			char *arg3;
-			int result;
-			int argvi = 0;
-			dXSARGS;
-
-			if ((items < 3) || (items > 3)) {
-				SWIG_croak("Usage: fs_switch_channel_set_variable(channel,varname,value);");
-			}
-			{
-				if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t, 0) < 0) {
-					SWIG_croak("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
-				}
-			}
-			if (!SvOK((SV *) ST(1)))
-				arg2 = 0;
-			else
-				arg2 = (char *) SvPV(ST(1), PL_na);
-			if (!SvOK((SV *) ST(2)))
-				arg3 = 0;
-			else
-				arg3 = (char *) SvPV(ST(2), PL_na);
-			result = (int) fs_switch_channel_set_variable(arg1, arg2, arg3);
-
-			ST(argvi) = sv_newmortal();
-			sv_setiv(ST(argvi++), (IV) result);
-			XSRETURN(argvi);
-		  fail:
-			;
-		}
-		croak(Nullch);
-	}
+XS(_wrap_fs_core_set_globals) {
+    {
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 0) || (items > 0)) {
+            SWIG_croak("Usage: fs_core_set_globals();");
+        }
+        fs_core_set_globals();
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_core_init) {
+    {
+        char *arg1 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 1) || (items > 1)) {
+            SWIG_croak("Usage: fs_core_init(path);");
+        }
+        if (!SvOK((SV*) ST(0))) arg1 = 0;
+        else arg1 = (char *) SvPV(ST(0), PL_na);
+        result = (int)fs_core_init(arg1);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_core_destroy) {
+    {
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 0) || (items > 0)) {
+            SWIG_croak("Usage: fs_core_destroy();");
+        }
+        result = (int)fs_core_destroy();
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_loadable_module_init) {
+    {
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 0) || (items > 0)) {
+            SWIG_croak("Usage: fs_loadable_module_init();");
+        }
+        result = (int)fs_loadable_module_init();
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_loadable_module_shutdown) {
+    {
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 0) || (items > 0)) {
+            SWIG_croak("Usage: fs_loadable_module_shutdown();");
+        }
+        result = (int)fs_loadable_module_shutdown();
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_console_loop) {
+    {
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 0) || (items > 0)) {
+            SWIG_croak("Usage: fs_console_loop();");
+        }
+        result = (int)fs_console_loop();
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_consol_log) {
+    {
+        char *arg1 ;
+        char *arg2 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_consol_log(level_str,msg);");
+        }
+        if (!SvOK((SV*) ST(0))) arg1 = 0;
+        else arg1 = (char *) SvPV(ST(0), PL_na);
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        fs_consol_log(arg1,arg2);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_consol_clean) {
+    {
+        char *arg1 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 1) || (items > 1)) {
+            SWIG_croak("Usage: fs_consol_clean(msg);");
+        }
+        if (!SvOK((SV*) ST(0))) arg1 = 0;
+        else arg1 = (char *) SvPV(ST(0), PL_na);
+        fs_consol_clean(arg1);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_core_session_locate) {
+    {
+        char *arg1 ;
+        switch_core_session_t *result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 1) || (items > 1)) {
+            SWIG_croak("Usage: fs_core_session_locate(uuid);");
+        }
+        if (!SvOK((SV*) ST(0))) arg1 = 0;
+        else arg1 = (char *) SvPV(ST(0), PL_na);
+        result = (switch_core_session_t *)fs_core_session_locate(arg1);
+        
+        ST(argvi) = sv_newmortal();
+        SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session_t, 0|0);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_answer) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 1) || (items > 1)) {
+            SWIG_croak("Usage: fs_channel_answer(session);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session_t");
+            }
+        }
+        fs_channel_answer(arg1);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_pre_answer) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 1) || (items > 1)) {
+            SWIG_croak("Usage: fs_channel_pre_answer(session);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session_t");
+            }
+        }
+        fs_channel_pre_answer(arg1);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_hangup) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_channel_hangup(session,cause);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        fs_channel_hangup(arg1,arg2);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_set_variable) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        char *arg3 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 3) || (items > 3)) {
+            SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        fs_channel_set_variable(arg1,arg2,arg3);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_get_variable) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_channel_get_variable(session,var);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        fs_channel_get_variable(arg1,arg2);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_channel_set_state) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_channel_set_state(session,state);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        fs_channel_set_state(arg1,arg2);
+        
+        
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_ivr_play_file) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        switch_file_handle_t *arg2 = (switch_file_handle_t *) 0 ;
+        char *arg3 ;
+        switch_input_args_t *arg4 = (switch_input_args_t *) 0 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 4) || (items > 4)) {
+            SWIG_croak("Usage: fs_ivr_play_file(session,fh,file,args);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session_t");
+            }
+        }
+        {
+            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t,0) < 0) {
+                SWIG_croak("Type error in argument 2 of fs_ivr_play_file. Expected _p_switch_file_handle_t");
+            }
+        }
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        {
+            if (SWIG_ConvertPtr(ST(3), (void **) &arg4, SWIGTYPE_p_switch_input_args_t,0) < 0) {
+                SWIG_croak("Type error in argument 4 of fs_ivr_play_file. Expected _p_switch_input_args_t");
+            }
+        }
+        result = (int)fs_ivr_play_file(arg1,arg2,arg3,arg4);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_record_file) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        switch_file_handle_t *arg2 = (switch_file_handle_t *) 0 ;
+        char *arg3 ;
+        switch_input_args_t *arg4 = (switch_input_args_t *) 0 ;
+        unsigned int arg5 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 5) || (items > 5)) {
+            SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,args,limit);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_record_file. Expected _p_switch_core_session_t");
+            }
+        }
+        {
+            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_file_handle_t,0) < 0) {
+                SWIG_croak("Type error in argument 2 of fs_switch_ivr_record_file. Expected _p_switch_file_handle_t");
+            }
+        }
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        {
+            if (SWIG_ConvertPtr(ST(3), (void **) &arg4, SWIGTYPE_p_switch_input_args_t,0) < 0) {
+                SWIG_croak("Type error in argument 4 of fs_switch_ivr_record_file. Expected _p_switch_input_args_t");
+            }
+        }
+        arg5 = (unsigned int) SvUV(ST(4));
+        result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_sleep) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        uint32_t arg2 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_switch_ivr_sleep(session,ms);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_sleep. Expected _p_switch_core_session_t");
+            }
+        }
+        {
+            uint32_t * argp;
+            if (SWIG_ConvertPtr(ST(1),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
+                SWIG_croak("Type error in argument 2 of fs_switch_ivr_sleep. Expected _p_uint32_t");
+            }
+            arg2 = *argp;
+        }
+        result = (int)fs_switch_ivr_sleep(arg1,arg2);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_ivr_play_file2) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_ivr_play_file2(session,file);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_ivr_play_file2. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        result = (int)fs_ivr_play_file2(arg1,arg2);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_collect_digits_callback) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        switch_input_args_t *arg2 = (switch_input_args_t *) 0 ;
+        unsigned int arg3 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 3) || (items > 3)) {
+            SWIG_croak("Usage: fs_switch_ivr_collect_digits_callback(session,args,timeout);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_core_session_t");
+            }
+        }
+        {
+            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_switch_input_args_t,0) < 0) {
+                SWIG_croak("Type error in argument 2 of fs_switch_ivr_collect_digits_callback. Expected _p_switch_input_args_t");
+            }
+        }
+        arg3 = (unsigned int) SvUV(ST(2));
+        result = (int)fs_switch_ivr_collect_digits_callback(arg1,arg2,arg3);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_collect_digits_count) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        unsigned int arg3 ;
+        unsigned int arg4 ;
+        char *arg5 ;
+        char *arg6 ;
+        unsigned int arg7 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 7) || (items > 7)) {
+            SWIG_croak("Usage: fs_switch_ivr_collect_digits_count(session,buf,buflen,maxdigits,terminators,terminator,timeout);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_collect_digits_count. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        arg3 = (unsigned int) SvUV(ST(2));
+        arg4 = (unsigned int) SvUV(ST(3));
+        if (!SvOK((SV*) ST(4))) arg5 = 0;
+        else arg5 = (char *) SvPV(ST(4), PL_na);
+        if (!SvOK((SV*) ST(5))) arg6 = 0;
+        else arg6 = (char *) SvPV(ST(5), PL_na);
+        arg7 = (unsigned int) SvUV(ST(6));
+        result = (int)fs_switch_ivr_collect_digits_count(arg1,arg2,arg3,arg4,(char const *)arg5,arg6,arg7);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_originate) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
+        char *arg3 ;
+        uint32_t arg4 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 4) || (items > 4)) {
+            SWIG_croak("Usage: fs_switch_ivr_originate(session,bleg,bridgeto,timelimit_sec);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_originate. Expected _p_switch_core_session_t");
+            }
+        }
+        {
+            if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 2 of fs_switch_ivr_originate. Expected _p_p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        {
+            uint32_t * argp;
+            if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
+                SWIG_croak("Type error in argument 4 of fs_switch_ivr_originate. Expected _p_uint32_t");
+            }
+            arg4 = *argp;
+        }
+        result = (int)fs_switch_ivr_originate(arg1,arg2,arg3,arg4);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_session_transfer) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        char *arg3 ;
+        char *arg4 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 4) || (items > 4)) {
+            SWIG_croak("Usage: fs_switch_ivr_session_transfer(session,extension,dialplan,context);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_session_transfer. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        if (!SvOK((SV*) ST(3))) arg4 = 0;
+        else arg4 = (char *) SvPV(ST(3), PL_na);
+        result = (int)fs_switch_ivr_session_transfer(arg1,arg2,arg3,arg4);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_ivr_speak_text) {
+    {
+        switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+        char *arg2 ;
+        char *arg3 ;
+        uint32_t arg4 ;
+        char *arg5 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 5) || (items > 5)) {
+            SWIG_croak("Usage: fs_switch_ivr_speak_text(session,tts_name,voice_name,rate,text);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_ivr_speak_text. Expected _p_switch_core_session_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        {
+            uint32_t * argp;
+            if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_uint32_t,0) < 0) {
+                SWIG_croak("Type error in argument 4 of fs_switch_ivr_speak_text. Expected _p_uint32_t");
+            }
+            arg4 = *argp;
+        }
+        if (!SvOK((SV*) ST(4))) arg5 = 0;
+        else arg5 = (char *) SvPV(ST(4), PL_na);
+        result = (int)fs_switch_ivr_speak_text(arg1,arg2,arg3,arg4,arg5);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_channel_get_variable) {
+    {
+        switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+        char *arg2 ;
+        char *result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 2) || (items > 2)) {
+            SWIG_croak("Usage: fs_switch_channel_get_variable(channel,varname);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_channel_get_variable. Expected _p_switch_channel_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        result = (char *)fs_switch_channel_get_variable(arg1,arg2);
+        
+        ST(argvi) = sv_newmortal();
+        if (result) {
+            sv_setpv((SV*)ST(argvi++), (char *) result);
+        } else {
+            sv_setsv((SV*)ST(argvi++), &PL_sv_undef);
+        }
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
+
+
+XS(_wrap_fs_switch_channel_set_variable) {
+    {
+        switch_channel_t *arg1 = (switch_channel_t *) 0 ;
+        char *arg2 ;
+        char *arg3 ;
+        int result;
+        int argvi = 0;
+        dXSARGS;
+        
+        if ((items < 3) || (items > 3)) {
+            SWIG_croak("Usage: fs_switch_channel_set_variable(channel,varname,value);");
+        }
+        {
+            if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_channel_t,0) < 0) {
+                SWIG_croak("Type error in argument 1 of fs_switch_channel_set_variable. Expected _p_switch_channel_t");
+            }
+        }
+        if (!SvOK((SV*) ST(1))) arg2 = 0;
+        else arg2 = (char *) SvPV(ST(1), PL_na);
+        if (!SvOK((SV*) ST(2))) arg3 = 0;
+        else arg3 = (char *) SvPV(ST(2), PL_na);
+        result = (int)fs_switch_channel_set_variable(arg1,arg2,arg3);
+        
+        ST(argvi) = sv_newmortal();
+        sv_setiv(ST(argvi++), (IV) result);
+        XSRETURN(argvi);
+        fail:
+        ;
+    }
+    croak(Nullch);
+}
 
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
-	static swig_type_info _swigt__p_switch_channel_t[] = { {"_p_switch_channel_t", 0, "switch_channel_t *", 0}, {"_p_switch_channel_t"}, {0} };
-	static swig_type_info _swigt__p_switch_file_handle_t[] =
-		{ {"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0}, {"_p_switch_file_handle_t"}, {0} };
-	static swig_type_info _swigt__p_switch_core_session_t[] =
-		{ {"_p_switch_core_session_t", 0, "switch_core_session_t *", 0}, {"_p_switch_core_session_t"}, {0} };
-	static swig_type_info _swigt__p_p_switch_core_session_t[] =
-		{ {"_p_p_switch_core_session_t", 0, "switch_core_session_t **", 0}, {"_p_p_switch_core_session_t"}, {0} };
-	static swig_type_info _swigt__p_uint32_t[] = { {"_p_uint32_t", 0, "uint32_t *", 0}, {"_p_uint32_t"}, {0} };
-	static swig_type_info _swigt__p_switch_input_callback_function_t[] =
-		{ {"_p_switch_input_callback_function_t", 0, "switch_input_callback_function_t *", 0},
-	{"_p_switch_input_callback_function_t"}, {0}
-	};
-
-	static swig_type_info *swig_types_initial[] = {
-		_swigt__p_switch_channel_t,
-		_swigt__p_switch_file_handle_t,
-		_swigt__p_switch_core_session_t,
-		_swigt__p_p_switch_core_session_t,
-		_swigt__p_uint32_t,
-		_swigt__p_switch_input_callback_function_t,
-		0
-	};
+static swig_type_info _swigt__p_switch_channel_t[] = {{"_p_switch_channel_t", 0, "switch_channel_t *", 0},{"_p_switch_channel_t"},{0}};
+static swig_type_info _swigt__p_switch_file_handle_t[] = {{"_p_switch_file_handle_t", 0, "switch_file_handle_t *", 0},{"_p_switch_file_handle_t"},{0}};
+static swig_type_info _swigt__p_switch_core_session_t[] = {{"_p_switch_core_session_t", 0, "switch_core_session_t *", 0},{"_p_switch_core_session_t"},{0}};
+static swig_type_info _swigt__p_p_switch_core_session_t[] = {{"_p_p_switch_core_session_t", 0, "switch_core_session_t **", 0},{"_p_p_switch_core_session_t"},{0}};
+static swig_type_info _swigt__p_uint32_t[] = {{"_p_uint32_t", 0, "uint32_t *", 0},{"_p_uint32_t"},{0}};
+static swig_type_info _swigt__p_switch_input_args_t[] = {{"_p_switch_input_args_t", 0, "switch_input_args_t *", 0},{"_p_switch_input_args_t"},{0}};
+
+static swig_type_info *swig_types_initial[] = {
+_swigt__p_switch_channel_t, 
+_swigt__p_switch_file_handle_t, 
+_swigt__p_switch_core_session_t, 
+_swigt__p_p_switch_core_session_t, 
+_swigt__p_uint32_t, 
+_swigt__p_switch_input_args_t, 
+0
+};
 
 
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
 
-	static swig_constant_info swig_constants[] = {
-		{0}
-	};
+static swig_constant_info swig_constants[] = {
+{ SWIG_STRING,  (char *) SWIG_prefix "FREESWITCH_PEN", 0, 0, (void *)"27880", 0},
+{ SWIG_STRING,  (char *) SWIG_prefix "FREESWITCH_OID_PREFIX", 0, 0, (void *)".1.3.6.1.4.1.27880", 0},
+{ SWIG_STRING,  (char *) SWIG_prefix "FREESWITCH_ITAD", 0, 0, (void *)"543", 0},
+{ SWIG_INT,     (char *) SWIG_prefix "__EXTENSIONS__", (long) 1, 0, 0, 0},
+{0}
+};
 #ifdef __cplusplus
 }
 #endif
 static swig_variable_info swig_variables[] = {
-	{0}
+{0}
 };
 static swig_command_info swig_commands[] = {
-	{"fs_perlc::fs_core_set_globals", _wrap_fs_core_set_globals},
-	{"fs_perlc::fs_core_init", _wrap_fs_core_init},
-	{"fs_perlc::fs_core_destroy", _wrap_fs_core_destroy},
-	{"fs_perlc::fs_loadable_module_init", _wrap_fs_loadable_module_init},
-	{"fs_perlc::fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown},
-	{"fs_perlc::fs_console_loop", _wrap_fs_console_loop},
-	{"fs_perlc::fs_consol_log", _wrap_fs_consol_log},
-	{"fs_perlc::fs_consol_clean", _wrap_fs_consol_clean},
-	{"fs_perlc::fs_core_session_locate", _wrap_fs_core_session_locate},
-	{"fs_perlc::fs_channel_answer", _wrap_fs_channel_answer},
-	{"fs_perlc::fs_channel_pre_answer", _wrap_fs_channel_pre_answer},
-	{"fs_perlc::fs_channel_hangup", _wrap_fs_channel_hangup},
-	{"fs_perlc::fs_channel_set_variable", _wrap_fs_channel_set_variable},
-	{"fs_perlc::fs_channel_get_variable", _wrap_fs_channel_get_variable},
-	{"fs_perlc::fs_channel_set_state", _wrap_fs_channel_set_state},
-	{"fs_perlc::fs_ivr_play_file", _wrap_fs_ivr_play_file},
-	{"fs_perlc::fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file},
-	{"fs_perlc::fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep},
-	{"fs_perlc::fs_ivr_play_file2", _wrap_fs_ivr_play_file2},
-	{"fs_perlc::fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback},
-	{"fs_perlc::fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count},
-	{"fs_perlc::fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate},
-	{"fs_perlc::fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer},
-	{"fs_perlc::fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text},
-	{"fs_perlc::fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable},
-	{"fs_perlc::fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable},
-	{0, 0}
+{"fs_perlc::fs_core_set_globals", _wrap_fs_core_set_globals},
+{"fs_perlc::fs_core_init", _wrap_fs_core_init},
+{"fs_perlc::fs_core_destroy", _wrap_fs_core_destroy},
+{"fs_perlc::fs_loadable_module_init", _wrap_fs_loadable_module_init},
+{"fs_perlc::fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown},
+{"fs_perlc::fs_console_loop", _wrap_fs_console_loop},
+{"fs_perlc::fs_consol_log", _wrap_fs_consol_log},
+{"fs_perlc::fs_consol_clean", _wrap_fs_consol_clean},
+{"fs_perlc::fs_core_session_locate", _wrap_fs_core_session_locate},
+{"fs_perlc::fs_channel_answer", _wrap_fs_channel_answer},
+{"fs_perlc::fs_channel_pre_answer", _wrap_fs_channel_pre_answer},
+{"fs_perlc::fs_channel_hangup", _wrap_fs_channel_hangup},
+{"fs_perlc::fs_channel_set_variable", _wrap_fs_channel_set_variable},
+{"fs_perlc::fs_channel_get_variable", _wrap_fs_channel_get_variable},
+{"fs_perlc::fs_channel_set_state", _wrap_fs_channel_set_state},
+{"fs_perlc::fs_ivr_play_file", _wrap_fs_ivr_play_file},
+{"fs_perlc::fs_switch_ivr_record_file", _wrap_fs_switch_ivr_record_file},
+{"fs_perlc::fs_switch_ivr_sleep", _wrap_fs_switch_ivr_sleep},
+{"fs_perlc::fs_ivr_play_file2", _wrap_fs_ivr_play_file2},
+{"fs_perlc::fs_switch_ivr_collect_digits_callback", _wrap_fs_switch_ivr_collect_digits_callback},
+{"fs_perlc::fs_switch_ivr_collect_digits_count", _wrap_fs_switch_ivr_collect_digits_count},
+{"fs_perlc::fs_switch_ivr_originate", _wrap_fs_switch_ivr_originate},
+{"fs_perlc::fs_switch_ivr_session_transfer", _wrap_fs_switch_ivr_session_transfer},
+{"fs_perlc::fs_switch_ivr_speak_text", _wrap_fs_switch_ivr_speak_text},
+{"fs_perlc::fs_switch_channel_get_variable", _wrap_fs_switch_channel_get_variable},
+{"fs_perlc::fs_switch_channel_set_variable", _wrap_fs_switch_channel_set_variable},
+{0,0}
 };
 
 #ifdef __cplusplus
 extern "C"
 #endif
-XS(SWIG_init)
-{
-	dXSARGS;
-	int i;
-	static int _init = 0;
-	if (!_init) {
-		for (i = 0; swig_types_initial[i]; i++) {
-			swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
-		}
-		_init = 1;
-	}
-
-	/* Install commands */
-	for (i = 0; swig_commands[i].name; i++) {
-		newXS((char *) swig_commands[i].name, swig_commands[i].wrapper, (char *) __FILE__);
-	}
-
-	/* Install variables */
-	for (i = 0; swig_variables[i].name; i++) {
-		SV *sv;
-		sv = perl_get_sv((char *) swig_variables[i].name, TRUE | 0x2);
-		if (swig_variables[i].type) {
-			SWIG_MakePtr(sv, (void *) 1, *swig_variables[i].type, 0);
-		} else {
-			sv_setiv(sv, (IV) 0);
-		}
-		swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
-	}
-
-	/* Install constant */
-	for (i = 0; swig_constants[i].type; i++) {
-		SV *sv;
-		sv = perl_get_sv((char *) swig_constants[i].name, TRUE | 0x2);
-		switch (swig_constants[i].type) {
-		case SWIG_INT:
-			sv_setiv(sv, (IV) swig_constants[i].lvalue);
-			break;
-		case SWIG_FLOAT:
-			sv_setnv(sv, (double) swig_constants[i].dvalue);
-			break;
-		case SWIG_STRING:
-			sv_setpv(sv, (char *) swig_constants[i].pvalue);
-			break;
-		case SWIG_POINTER:
-			SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype), 0);
-			break;
-		case SWIG_BINARY:
-			SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
-			break;
-		default:
-			break;
-		}
-		SvREADONLY_on(sv);
-	}
 
-	ST(0) = &PL_sv_yes;
-	XSRETURN(1);
+XS(SWIG_init) {
+    dXSARGS;
+    int i;
+    static int _init = 0;
+    if (!_init) {
+        for (i = 0; swig_types_initial[i]; i++) {
+            swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
+        }	
+        _init = 1;
+    }
+    
+    /* Install commands */
+    for (i = 0; swig_commands[i].name; i++) {
+        newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
+    }
+    
+    /* Install variables */
+    for (i = 0; swig_variables[i].name; i++) {
+        SV *sv;
+        sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2);
+        if (swig_variables[i].type) {
+            SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
+        } else {
+            sv_setiv(sv,(IV) 0);
+        }
+        swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); 
+    }
+    
+    /* Install constant */
+    for (i = 0; swig_constants[i].type; i++) {
+        SV *sv;
+        sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2);
+        switch(swig_constants[i].type) {
+            case SWIG_INT:
+            sv_setiv(sv, (IV) swig_constants[i].lvalue);
+            break;
+            case SWIG_FLOAT:
+            sv_setnv(sv, (double) swig_constants[i].dvalue);
+            break;
+            case SWIG_STRING:
+            sv_setpv(sv, (char *) swig_constants[i].pvalue);
+            break;
+            case SWIG_POINTER:
+            SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
+            break;
+            case SWIG_BINARY:
+            SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
+            break;
+            default:
+            break;
+        }
+        SvREADONLY_on(sv);
+    }
+    
+    ST(0) = &PL_sv_yes;
+    XSRETURN(1);
 }
+

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Fri Apr 13 18:15:58 2007
@@ -81,7 +81,8 @@
 
 typedef enum {
 	S_HUP = (1 << 0),
-	S_FREE = (1 << 1)
+	S_FREE = (1 << 1),
+	S_RDLOCK = (1 << 2)
 } session_flag_t;
 
 struct input_callback_state {
@@ -2146,7 +2147,7 @@
 		}
 
 		jss->session = peer_session;
-		jss->flags = 0;
+		jss->flags = S_RDLOCK;
 
 		*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
 
@@ -2177,6 +2178,10 @@
 				switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			}
 
+			if (jss->session && switch_test_flag(jss, S_RDLOCK)) {
+				switch_core_session_rwunlock(jss->session);
+			}
+			
 			if (switch_test_flag(jss, S_FREE)) {
 				free(jss);
 			}

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Fri Apr 13 18:15:58 2007
@@ -745,12 +745,12 @@
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", switch_channel_get_name(channel));
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
 
-	if ((codec = switch_core_session_get_read_codec(channel->session))) {
+	if ((codec = switch_core_session_get_read_codec(channel->session)) && codec->implementation) {
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Name", "%s", switch_str_nil(codec->implementation->iananame));
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Rate", "%u", codec->implementation->samples_per_second);
 	}
 
-	if ((codec = switch_core_session_get_write_codec(channel->session))) {
+	if ((codec = switch_core_session_get_write_codec(channel->session)) && codec->implementation) {
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Name", "%s", switch_str_nil(codec->implementation->iananame));
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-Rate", "%u", codec->implementation->samples_per_second);
 	}

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Fri Apr 13 18:15:58 2007
@@ -34,16 +34,20 @@
 
 /* Bridge Related Stuff*/
 /*********************************************************************************/
-struct audio_bridge_data {
-	switch_core_session_t *session_a;
-	switch_core_session_t *session_b;
-	int running;
+struct switch_ivr_bridge_data {
+	switch_core_session_t *session;
+	char *b_uuid;
+	int stream_id;
+	switch_input_callback_function_t input_callback;
+	void *session_data;
 };
+typedef struct switch_ivr_bridge_data switch_ivr_bridge_data_t;
+
+
 
 static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
 {
-	switch_core_thread_session_t *his_thread, *data = obj;
-	int *stream_id_p;
+	switch_ivr_bridge_data_t *data = obj;
 	int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0;
 	switch_input_callback_function_t input_callback;
 	switch_core_session_message_t *message, msg = { 0 };
@@ -53,19 +57,14 @@
 	switch_frame_t *read_frame;
 	switch_core_session_t *session_a, *session_b;
 
-	assert(!thread || thread);
-
-	session_a = data->objs[0];
-	session_b = data->objs[1];
-
-	stream_id_p = data->objs[2];
-	input_callback = data->input_callback;
-	user_data = data->objs[4];
-	his_thread = data->objs[5];
-
-	if (stream_id_p) {
-		stream_id = *stream_id_p;
+	session_a = data->session;
+	if (!(session_b = switch_core_session_locate(data->b_uuid))) {
+		return NULL;
 	}
+	
+	input_callback = data->input_callback;
+	user_data = data->session_data;
+	stream_id = data->stream_id;
 
 	chan_a = switch_core_session_get_channel(session_a);
 	chan_b = switch_core_session_get_channel(session_b);
@@ -75,8 +74,6 @@
 		pre_b = switch_channel_test_flag(chan_a, CF_EARLY_MEDIA);
 		ans_b = switch_channel_test_flag(chan_b, CF_ANSWERED);
 	}
-	switch_core_session_read_lock(session_a);
-	switch_core_session_read_lock(session_b);
 
 	switch_channel_set_flag(chan_a, CF_BRIDGED);
 
@@ -85,10 +82,6 @@
 		switch_status_t status;
 		switch_event_t *event;
 
-		if (!(data->running > 0 && his_thread->running > 0)) {
-			break;
-		}
-
 		/* if you really want to make sure it's not ready, test it twice because it might be just a break */
 		if (!switch_channel_ready(chan_a) && !switch_channel_ready(chan_a)) {
 			break;
@@ -99,10 +92,6 @@
 		switch (b_state) {
 		case CS_HANGUP:
 		case CS_DONE:
-			switch_mutex_lock(data->mutex);
-			data->running = -1;
-			switch_mutex_unlock(data->mutex);
-			continue;
 		default:
 			break;
 		}
@@ -129,9 +118,6 @@
 			if (input_callback) {
 				if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
-					switch_mutex_lock(data->mutex);
-					data->running = -1;
-					switch_mutex_unlock(data->mutex);
 					break;
 				}
 			}
@@ -186,49 +172,40 @@
 				if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "write: %s Bad Frame....[%u] Bubye!\n",
 									  switch_channel_get_name(chan_b), read_frame->datalen);
-					switch_mutex_lock(data->mutex);
-					data->running = -1;
-					switch_mutex_unlock(data->mutex);
+					break;
 				}
 			}
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "read: %s Bad Frame.... Bubye!\n", switch_channel_get_name(chan_a));
-			switch_mutex_lock(data->mutex);
-			data->running = -1;
-			switch_mutex_unlock(data->mutex);
+			break;
 		}
 	}
 
 	switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
-
+	msg.string_arg = data->b_uuid;
 	msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
 	msg.from = __FILE__;
 	switch_core_session_receive_message(session_a, &msg);
 
 	switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
-
 	switch_channel_clear_flag(chan_a, CF_BRIDGED);
-	switch_mutex_lock(data->mutex);
-	data->running = 0;
-	switch_mutex_unlock(data->mutex);
-
-	switch_core_session_rwunlock(session_a);
 	switch_core_session_rwunlock(session_b);
+
 	return NULL;
 }
 
 static switch_status_t audio_bridge_on_loopback(switch_core_session_t *session)
 {
 	switch_channel_t *channel = NULL;
-	void *arg;
+	switch_ivr_bridge_data_t *bd;
 
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	if ((arg = switch_channel_get_private(channel, "_bridge_"))) {
+	if ((bd = (switch_ivr_bridge_data_t *) switch_channel_get_private(channel, "_bridge_"))) {
 		switch_channel_set_private(channel, "_bridge_", NULL);
-		audio_bridge_thread(NULL, (void *) arg);
+		audio_bridge_thread(NULL, (void *) bd);
 	} else {
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 	}
@@ -516,17 +493,16 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-
 SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
 																 switch_core_session_t *peer_session,
 																 switch_input_callback_function_t input_callback, void *session_data,
 																 void *peer_session_data)
 {
-	switch_core_thread_session_t *this_audio_thread, *other_audio_thread;
+	switch_ivr_bridge_data_t *a_leg, *b_leg;
 	switch_channel_t *caller_channel, *peer_channel;
 	int stream_id = 0;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+	
 	caller_channel = switch_core_session_get_channel(session);
 	assert(caller_channel != NULL);
 
@@ -535,26 +511,20 @@
 	peer_channel = switch_core_session_get_channel(peer_session);
 	assert(peer_channel != NULL);
 
-	other_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session_t));
-	this_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session_t));
-
-	other_audio_thread->objs[0] = session;
-	other_audio_thread->objs[1] = peer_session;
-	other_audio_thread->objs[2] = &stream_id;
-	other_audio_thread->input_callback = input_callback;
-	other_audio_thread->objs[4] = session_data;
-	other_audio_thread->objs[5] = this_audio_thread;
-	other_audio_thread->running = 5;
-	switch_mutex_init(&other_audio_thread->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
-
-	this_audio_thread->objs[0] = peer_session;
-	this_audio_thread->objs[1] = session;
-	this_audio_thread->objs[2] = &stream_id;
-	this_audio_thread->input_callback = input_callback;
-	this_audio_thread->objs[4] = peer_session_data;
-	this_audio_thread->objs[5] = other_audio_thread;
-	this_audio_thread->running = 2;
-	switch_mutex_init(&this_audio_thread->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(peer_session));
+	a_leg = switch_core_session_alloc(session, sizeof(*a_leg));
+	b_leg = switch_core_session_alloc(peer_session, sizeof(*b_leg));
+	
+	b_leg->session = peer_session;
+	b_leg->b_uuid = switch_core_session_strdup(peer_session, switch_core_session_get_uuid(session));
+	b_leg->stream_id = stream_id;
+	b_leg->input_callback = input_callback;
+	b_leg->session_data = session_data;
+
+	a_leg->session = session;
+	a_leg->b_uuid = switch_core_session_strdup(session, switch_core_session_get_uuid(peer_session));
+	b_leg->stream_id = stream_id;
+	b_leg->input_callback = input_callback;
+	b_leg->session_data = peer_session_data;
 
 	switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
 
@@ -579,54 +549,34 @@
 
 			msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
 			msg.from = __FILE__;
-			msg.pointer_arg = session;
-
-			switch_core_session_receive_message(peer_session, &msg);
+			msg.string_arg = switch_core_session_strdup(peer_session, switch_core_session_get_uuid(session));
 
-			if (!msg.pointer_arg) {
+			if (switch_core_session_receive_message(peer_session, &msg) != SWITCH_STATUS_SUCCESS) {
 				status = SWITCH_STATUS_FALSE;
 				switch_core_session_rwunlock(peer_session);
 				goto done;
 			}
 
-			msg.pointer_arg = peer_session;
-			switch_core_session_receive_message(session, &msg);
-
-			if (!msg.pointer_arg) {
+			msg.string_arg = switch_core_session_strdup(session, switch_core_session_get_uuid(peer_session));
+			if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
 				status = SWITCH_STATUS_FALSE;
 				switch_core_session_rwunlock(peer_session);
 				goto done;
 			}
 
 
-			switch_channel_set_private(peer_channel, "_bridge_", other_audio_thread);
+			switch_channel_set_private(peer_channel, "_bridge_", b_leg);
 			switch_channel_set_state(peer_channel, CS_LOOPBACK);
-			audio_bridge_thread(NULL, (void *) this_audio_thread);
+			audio_bridge_thread(NULL, (void *) a_leg);
 
 			if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
 				switch_channel_event_set_data(caller_channel, event);
 				switch_event_fire(&event);
 			}
 
-			this_audio_thread->objs[0] = NULL;
-			this_audio_thread->objs[1] = NULL;
-			this_audio_thread->objs[2] = NULL;
-			this_audio_thread->input_callback = NULL;
-			this_audio_thread->objs[4] = NULL;
-			this_audio_thread->objs[5] = NULL;
-			switch_mutex_lock(this_audio_thread->mutex);
-			this_audio_thread->running = 0;
-			switch_mutex_unlock(this_audio_thread->mutex);
-
 			switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
-
-			if (other_audio_thread->running > 0) {
-				switch_mutex_lock(other_audio_thread->mutex);
-				other_audio_thread->running = -1;
-				switch_mutex_unlock(other_audio_thread->mutex);
-				while (other_audio_thread->running) {
-					switch_yield(1000);
-				}
+			while (switch_channel_get_state(peer_channel) == CS_LOOPBACK) {
+				switch_yield(1000);
 			}
 
 			switch_core_session_rwunlock(peer_session);

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Fri Apr 13 18:15:58 2007
@@ -156,7 +156,7 @@
 
 static uint8_t check_channel_status(switch_channel_t **peer_channels,
 									switch_core_session_t **peer_sessions,
-									uint32_t len, int32_t *idx, uint32_t * hups, char *file, char *key, uint8_t early_ok, uint8_t * ring_ready)
+									uint32_t len, int32_t *idx, uint32_t * hups, char *file, char *key, uint8_t early_ok, uint8_t *ring_ready)
 {
 
 	uint32_t i;
@@ -901,9 +901,12 @@
 				if (!peer_channels[i]) {
 					continue;
 				}
+				if (status == SWITCH_STATUS_SUCCESS && bleg && *bleg && *bleg == peer_sessions[i]) {
+					continue;
+				}
 				switch_core_session_rwunlock(peer_sessions[i]);
 			}
-
+			
 			if (status == SWITCH_STATUS_SUCCESS) {
 				goto outer_for;
 			}
@@ -912,5 +915,10 @@
   outer_for:
 	switch_safe_free(loop_data);
 	switch_safe_free(odata);
+
+	if (bleg && status != SWITCH_STATUS_SUCCESS) {
+		*bleg = NULL;
+	}
+
 	return status;
 }

Modified: freeswitch/trunk/src/switch_swig.c
==============================================================================
--- freeswitch/trunk/src/switch_swig.c	(original)
+++ freeswitch/trunk/src/switch_swig.c	Fri Apr 13 18:15:58 2007
@@ -246,6 +246,7 @@
 		return;
 	} else {
 		switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
+        switch_core_session_rwunlock(peer_session);
 	}
 
 



More information about the Freeswitch-svn mailing list