[Freeswitch-svn] [commit] r1626 - in freeswitch/branches/mishehu/src: . mod/applications/mod_rss mod/loggers/mod_cdr

mishehu at freeswitch.org mishehu at freeswitch.org
Wed Jun 14 21:11:40 EDT 2006


Author: mishehu
Date: Wed Jun 14 21:11:40 2006
New Revision: 1626

Modified:
   freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mod_cdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h
   freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql
   freeswitch/branches/mishehu/src/switch_channel.c
   freeswitch/branches/mishehu/src/switch_console.c

Log:
AnthmCDR and MysqlCDR function, though chanvars have not yet been tested.  Code could use to be cleaned up a little bit as well.  Merged up to trunk r1625.

Modified: freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c	(original)
+++ freeswitch/branches/mishehu/src/mod/applications/mod_rss/mod_rss.c	Wed Jun 14 21:11:40 2006
@@ -53,6 +53,8 @@
 #define TTS_DEFAULT_ENGINE "cepstral"
 #define TTS_DEFAULT_VOICE "david"
 
+#define MATCH_COUNT
+
 struct rss_entry {
 	uint8_t inuse;
 	char *title_txt;
@@ -66,7 +68,7 @@
 {
 	char tstr[80] = "";
 	uint32_t matches = 0, x = 0;
-	uint32_t len = strlen(str);
+	uint32_t len = (uint32_t)strlen(str);
 	printf("%s\n", str);
 	for (x = 0; x < max ; x++) {
 		snprintf(tstr, sizeof(tstr), "%u", x);
@@ -293,14 +295,21 @@
 			snprintf(cmd, sizeof(cmd), "%d", jumpto);
 		} else {
 			switch_core_speech_flush_tts(&sh);
+#ifdef MATCH_COUNT
 			snprintf(buf + len, sizeof(buf) - len, 
 					 "Main Menu. <break time=\"600ms\"/> "
-					 "Choose one of the following Feeds followed by the pound key or press 0 to exit. "
+					 "Select one of the following news sources, or press 0 to exit. "
 					 "<break time=\"600ms\"/>");
+#else
+			snprintf(buf + len, sizeof(buf) - len, 
+					 "Main Menu. <break time=\"600ms\"/> "
+					 "Select one of the following news sources, followed by the pound key or press 0 to exit. "
+					 "<break time=\"600ms\"/>");
+#endif
 			len = (int32_t)strlen(buf);
 
 			for (idx = 0; idx < feed_index; idx++) {
-				snprintf(buf + len, sizeof(buf) - len, "Feed Number %d %s. <break time=\"600ms\"/>", idx + 1, feed_names[idx]);
+				snprintf(buf + len, sizeof(buf) - len, "%d: %s. <break time=\"600ms\"/>", idx + 1, feed_names[idx]);
 				len = (int32_t)strlen(buf);
 			}
 
@@ -471,7 +480,7 @@
 			char cmd[5] = "";
 
 			switch_time_exp_lt(&tm, switch_time_now());
-			switch_strftime(date, &retsize, sizeof(date), "%A, %B %d, %Y. %I:%M %p", &tm);
+			switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
 
 
 			snprintf(buf, sizeof(buf), "%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ", 
@@ -537,7 +546,7 @@
 					if (switch_test_flag(&dtb, SFLAG_INFO)) {
 						switch_clear_flag(&dtb, SFLAG_INFO);
 						snprintf(buf + len, sizeof(buf) - len,
-								 "Hello my name is %s %s. I am speaking at %u words per minute. ",
+								 "%s %s. I am speaking at %u words per minute. ",
 								 sh.engine,
 								 sh.voice,
 								 dtb.speed

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.cpp	Wed Jun 14 21:11:40 2006
@@ -1,20 +1,18 @@
 #include <switch.h>
 #include "anthmcdr.h"
-#include <iostream>
-#include <ofstream>
 
 AnthmCDR::AnthmCDR() : BaseCDR()
 {
 	memset(formattedcallstartdate,0,100);
 	memset(formattedcallanswerdate,0,100);
-	memset(formattedcallendate,0,100);
+	memset(formattedcallenddate,0,100);
 }
 
 AnthmCDR::AnthmCDR(switch_mod_cdr_newchannel_t *newchannel) : BaseCDR(newchannel)
 {
 	memset(formattedcallstartdate,0,100);
 	memset(formattedcallanswerdate,0,100);
-	memset(formattedcallendate,0,100);
+	memset(formattedcallenddate,0,100);
 	
 	if(newchannel != 0)
 	{
@@ -32,16 +30,16 @@
 		switch_strftime(formattedcallstartdate,&retsizecsd,sizeof(formattedcallstartdate),format,&tempcallstart);
 		switch_strftime(formattedcallanswerdate,&retsizecad,sizeof(formattedcallanswerdate),format,&tempcallanswer);
 		switch_strftime(formattedcallenddate,&retsizeced,sizeof(formattedcallenddate),format,&tempcallend);
-	}
 	
-	outputfile_name = outputfile_path;
-	outputfile_name.append("/");
-	outputfile_name.append(myuuid);  // The goal is to have a resulting filename of "/path/to/myuuid"
-	outputfile_name.append(".atm");  // The extension is in honor of anthm
+		outputfile_name = outputfile_path;
+		outputfile_name.append("/");
+		outputfile_name.append(myuuid);  // The goal is to have a resulting filename of "/path/to/myuuid"
+		outputfile_name.append(".atm");  // The extension is in honor of anthm
 	
-	outputfile.open(outputfile_name);
+		outputfile.open(outputfile_name.c_str());
 	
-	process_channel_variables(chanvars_list,newchannel->channel);
+		process_channel_variables(chanvars_list,newchannel->channel);
+	}
 }
 
 AnthmCDR::~AnthmCDR()
@@ -55,19 +53,19 @@
 std::string AnthmCDR::outputfile_path;
 std::list<std::string> AnthmCDR::chanvars_list;
 
-void AnthmCDR::connect(switch_xml_t *cfg, switch_xml_t *xml, switch_xml_t *settings, switch_xml_t *param)
+void AnthmCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AnthmCDR::connect() - Loading configuration file.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "AnthmCDR::connect() - Loading configuration file.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	
-	if ((*settings = switch_xml_child(*cfg, "anthmcdr"))) 
+	if ((settings = switch_xml_child(cfg, "anthmcdr"))) 
 	{
 		int tempcount = 0;
-		for (param = switch_xml_child(*settings, "param"); *param; *param = (*param)->next) 
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) 
 		{
-			char *var = (char *) switch_xml_attr_soft(*param, "name");
-			char *val = (char *) switch_xml_attr_soft(*param, "value");
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
 
 			if (!strcmp(var, "path"))
 			{
@@ -86,8 +84,8 @@
 			}
 		}
 		
-		if(tmpcount > 0)
-			activated = 1;
+		//if(tmpcount > 0)
+		activated = 1;
 	}
 }
 
@@ -95,33 +93,33 @@
 {
 	bool retval = 0;
 	if(!outputfile)
-		switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AnthmCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
+		switch_console_printf(SWITCH_CHANNEL_LOG, "AnthmCDR::process_record():  Unable to open file  %s to commit the call record to.  Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
 	else
 	{
 		// Format the call record and proceed from here...
 		outputfile << "$VAR1 = {" << std::endl;
 		outputfile << "\t\'callstartdate\' = \'" << callstartdate << "\'," << std::endl;
-		outputfile << "\t\'callanswerdate\' = " << callanswerdate << "\'," << std::endl;
-		outputfile << "\t\'callenddate\' = " << callenddate << "\'," << std::endl;
-		outputfile << "\t\'hangupcause\' = " << hangupcause_text << "\'," << std::endl;
-		outputfile << "\t\'hangupcausecode\' = " << hangcause << "\'," << std::endl;
-		outputfile << "\t\'clid\' = " << clid << "\'," << std::endl;
-		outputfile << "\t\'originated\' = " << originated << "\'," << std::endl;
-		outputfile << "\t\'dialplan\' = " << dialplan << "\'," << std::endl;
-		outputfile << "\t\'myuuid\' = " << myuuid << "\'," << std::endl;
-		outputfile << "\t\'destuuid\' = " << destuuid << "\'," << std::endl;
-		outputfile << "\t\'src\' = " << src << "\'," << std::endl;
-		outputfile << "\t\'dst\' = " << dst << "\'," << std::endl;
-		outputfile << "\t\'srcchannel\' = " << srcchannel << "\'," << std::endl;
-		outputfile << "\t\'dstchannel\' = " << dstchannel << "\'," << std::endl;
-		outputfile << "\t\'ani\' = " << ani << "\'," << std::endl;
-		outputfile << "\t\'ani2\' = " << ani2 << "\'," << std::endl;
-		outputfile << "\t\'network_addr\' = " << network_addr << "\'," << std::endl;
-		outputfile << "\t\'lastapp\' = " << lastapp << "\'," << std::endl;
-		outputfile << "\t\'lastdata\' = " << lastdata << "\'," << std::endl;
-		outputfile << "\t\'billusec\' = " << billusec << "\'," << std::endl;
-		outputfile << "\t\'disposition\' = " << disposition << "\'," << std::endl;
-		outputfile << "\t\'amaflags\' = " << amaflags << "\'," << std::endl;
+		outputfile << "\t\'callanswerdate\' = \'" << callanswerdate << "\'," << std::endl;
+		outputfile << "\t\'callenddate\' = \'" << callenddate << "\'," << std::endl;
+		outputfile << "\t\'hangupcause\' = \'" << hangupcause_text << "\'," << std::endl;
+		outputfile << "\t\'hangupcausecode\' = \'" << hangupcause << "\'," << std::endl;
+		outputfile << "\t\'clid\' = \'" << clid << "\'," << std::endl;
+		outputfile << "\t\'originated\' = \'" << originated << "\'," << std::endl;
+		outputfile << "\t\'dialplan\' = \'" << dialplan << "\'," << std::endl;
+		outputfile << "\t\'myuuid\' = \'" << myuuid << "\'," << std::endl;
+		outputfile << "\t\'destuuid\' = \'" << destuuid << "\'," << std::endl;
+		outputfile << "\t\'src\' = \'" << src << "\'," << std::endl;
+		outputfile << "\t\'dst\' = \'" << dst << "\'," << std::endl;
+		outputfile << "\t\'srcchannel\' = \'" << srcchannel << "\'," << std::endl;
+		outputfile << "\t\'dstchannel\' = \'" << dstchannel << "\'," << std::endl;
+		outputfile << "\t\'ani\' = \'" << ani << "\'," << std::endl;
+		outputfile << "\t\'ani2\' = \'" << ani2 << "\'," << std::endl;
+		outputfile << "\t\'network_addr\' = \'" << network_addr << "\'," << std::endl;
+		outputfile << "\t\'lastapp\' = \'" << lastapp << "\'," << std::endl;
+		outputfile << "\t\'lastdata\' = \'" << lastdata << "\'," << std::endl;
+		outputfile << "\t\'billusec\' = \'" << billusec << "\'," << std::endl;
+		outputfile << "\t\'disposition\' = \'" << disposition << "\'," << std::endl;
+		outputfile << "\t\'amaflags\' = \'" << amaflags << "\'," << std::endl;
 		
 		// Now to process chanvars
 		outputfile << "\t\'chanvars\' => {" << std::endl;
@@ -134,7 +132,30 @@
 				outputfile << "\t\t\'" << iItr->first << "\' = \'" << iItr->second << "\'," << std::endl;
 		}
 		outputfile << "\t}," << std::endl << "};" << std::endl << std::endl;
+		retval = 1;
 	}
+	
+	return retval;
+}
+
+bool AnthmCDR::is_activated()
+{
+	return activated;
+}
+
+void AnthmCDR::tempdump_record()
+{
+
+}
+
+void AnthmCDR::reread_tempdumped_records()
+{
+
+}
+
+void AnthmCDR::disconnect()
+{
+	switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down AnthmCDR...  Done!");	
 }
 
 AUTO_REGISTER_BASECDR(AnthmCDR);

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/anthmcdr.h	Wed Jun 14 21:11:40 2006
@@ -4,7 +4,7 @@
 // #include <sys/stat.h>
 // #include <fcntl.h>
 #include <iostream>
-#include <ofstream>
+#include <fstream>
 #include <list>
 
 #ifndef ANTHMCDR
@@ -17,7 +17,7 @@
 		//AnthmCDR(const AnthmCDR& copyFrom);
 		virtual ~AnthmCDR();
 		virtual bool process_record();
-		virtual void connect(switch_xml_t *cfg, switch_xml_t *xml, switch_xml_t *settings, switch_xml_t *param); // connect and disconnect need to be static because we're persisting connections until shutdown
+		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
 		virtual void disconnect();
 		virtual bool is_activated();
 		virtual void tempdump_record();

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp	Wed Jun 14 21:11:40 2006
@@ -30,7 +30,8 @@
 		memset(destuuid,0,37);
 		memset(dialplan,0,80);
 		memset(&hangupcause,0,sizeof(hangupcause));
-		memset(hangupcause_text,0,80);
+		//memset(hangupcause_text,0,80);
+		hangupcause_text = 0;
 		memset(src,0,80);
 		memset(dst,0,80);
 		memset(srcchannel,0,80);
@@ -45,96 +46,96 @@
 		memset(uniqueid,0,32);
 		memset(userfield,0,255);
 		*/
-	}
 
-	callstartdate= newchannel->timetable->created;
-	callanswerdate = newchannel->timetable->answered;
-	callenddate = newchannel->timetable->hungup;
+		coresession = newchannel->session;
+		callstartdate= newchannel->timetable->created;
+		callanswerdate = newchannel->timetable->answered;
+		callenddate = newchannel->timetable->hungup;
 	
-	if(newchannel->callerprofile->caller_id_name != 0)
-	{
-		strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
-		strncat(clid," ",1);
-		if(newchannel->callerprofile->caller_id_number != 0 )
-			strncat(clid,newchannel->callerprofile->caller_id_number,strlen(clid)+strlen(newchannel->callerprofile->caller_id_number));
-	}
+		if(newchannel->callerprofile->caller_id_name != 0)
+		{
+			strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
+			strncat(clid," ",1);
+			if(newchannel->callerprofile->caller_id_number != 0 )
+				strncat(clid,newchannel->callerprofile->caller_id_number,strlen(clid)+strlen(newchannel->callerprofile->caller_id_number));
+		}
 		
 		// Get the ANI information if it's set
-	if(newchannel->callerprofile->ani != 0)
-		strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
-	if(newchannel->callerprofile->ani2 != 0)
-		strncpy(ani2,newchannel->callerprofile->ani2,strlen(newchannel->callerprofile->ani2));
+		if(newchannel->callerprofile->ani != 0)
+			strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani));
+		if(newchannel->callerprofile->ani2 != 0)
+			strncpy(ani2,newchannel->callerprofile->ani2,strlen(newchannel->callerprofile->ani2));
 	
-	if(newchannel->callerprofile->dialplan != 0)
-		strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
+		if(newchannel->callerprofile->dialplan != 0)
+			strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan));
 	
-	if(newchannel->callerprofile->network_addr != 0)
-		strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
+		if(newchannel->callerprofile->network_addr != 0)
+			strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
 		
-	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Channel caller_profile loaded.\n");
+		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Channel caller_profile loaded.\n");
 		
-	originated = newchannel->originate;
+		originated = newchannel->originate;
 	
-	if(newchannel->originateprofile->uuid != 0)
-		strncpy(destuuid,newchannel->originateprofile->uuid,strlen(newchannel->originateprofile->uuid));
+		if(newchannel->originateprofile->uuid != 0)
+			strncpy(destuuid,newchannel->originateprofile->uuid,strlen(newchannel->originateprofile->uuid));
 	
-	// We still need to check if this is originated or not
-	if(originated == 0)
-	{
-		if(newchannel->callerprofile->destination_number != 0)
-			strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
-		if(newchannel->callerprofile->caller_id_number != 0)
-			strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
-		if(newchannel->originateprofile->chan_name != 0)
-			strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
-	}
-	else
-	{
-		if(newchannel->callerprofile->caller_id_number != 0)
-			strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
-		if(newchannel->callerprofile->destination_number != 0)
-			strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
-		if(newchannel->originateprofile->chan_name != 0)
-			strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
-	}
+		// We still need to check if this is originated or not
+		if(originated == 0)
+		{
+			if(newchannel->callerprofile->destination_number != 0)
+				strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
+			if(newchannel->callerprofile->caller_id_number != 0)
+				strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
+			if(newchannel->originateprofile->chan_name != 0)
+				strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
+		}
+		else
+		{
+			if(newchannel->callerprofile->caller_id_number != 0)
+				strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number));
+			if(newchannel->callerprofile->destination_number != 0)
+				strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
+			if(newchannel->originateprofile->chan_name != 0)
+				strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
+		}
 		
-	strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid));
-	strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name));
+		strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid));
+		strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name));
 		
-	if(switch_channel_test_flag(newchannel->channel,CF_ANSWERED))
-	{
-		disposition=1;
-		billusec = newchannel->timetable->hungup - newchannel->timetable->answered;
-	}
-	else
-	{
-		disposition=0;
-		billusec = 0;
-	}
+		if(switch_channel_test_flag(newchannel->channel,CF_ANSWERED))
+		{
+			disposition=1;
+			billusec = newchannel->timetable->hungup - newchannel->timetable->answered;
+		}
+		else
+		{
+			disposition=0;
+			billusec = 0;
+		}
 		
-	// What was the hangup cause?
-	hangupcause = switch_channel_get_cause(newchannel->channel);
-	hangupcause_text = switch_channel_cause2str(hangupcause);
+		// What was the hangup cause?
+		hangupcause = switch_channel_get_cause(newchannel->channel);
+		hangupcause_text = switch_channel_cause2str(hangupcause);
 	
-	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Call state & length calculated.\n");
+		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Call state & length calculated.\n");
 		
-	if(newchannel->callerextension != 0)
-		if(newchannel->callerextension->last_application != 0)
-		{
-			if(newchannel->callerextension->last_application->application_name != 0)
-				strncpy(lastapp,newchannel->callerextension->last_application->application_name,strlen(newchannel->callerextension->last_application->application_name));
-			if(newchannel->callerextension->last_application->application_data != 0)
-				strncpy(lastdata,newchannel->callerextension->last_application->application_data,strlen(newchannel->callerextension->last_application->application_data));
-		}
+		if(newchannel->callerextension != 0)
+			if(newchannel->callerextension->last_application != 0)
+			{
+				if(newchannel->callerextension->last_application->application_name != 0)
+					strncpy(lastapp,newchannel->callerextension->last_application->application_name,strlen(newchannel->callerextension->last_application->application_name));
+				if(newchannel->callerextension->last_application->application_data != 0)
+					strncpy(lastdata,newchannel->callerextension->last_application->application_data,strlen(newchannel->callerextension->last_application->application_data));
+			}
 		
-	amaflags=0; // For future use I guess?  I don't see anything in the docs about this
-	/*
-	strncpy(accountcode," ",1); // Also for future use I guess?
-	strncpy(uniqueid," ",1);  // I don't see any of the user stuff in the docs yet
-	strncpy(userfield," ",1); // So we can't add these yet
-	*/
-	switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Processing completed.\n");
-
+		amaflags=0; // For future use I guess?  I don't see anything in the docs about this
+		/*
+		strncpy(accountcode," ",1); // Also for future use I guess?
+		strncpy(uniqueid," ",1);  // I don't see any of the user stuff in the docs yet
+		strncpy(userfield," ",1); // So we can't add these yet
+		*/
+		switch_console_printf(SWITCH_CHANNEL_LOG, "BaseCDR::BaseCDR(switch_mod_cdr_newchannel*) - Processing completed.\n");
+	}
 }
 
 BaseCDR::~BaseCDR()
@@ -186,11 +187,13 @@
 	if(stringlist.front() == "*")
 	{
 		switch_hash_index_t *hi;
-		void *var,*val;
-
-		for (hi = switch_hash_first(0, channel->variables); hi; hi = switch_hash_next(hi)) 
+		void *val;
+		const void *var;
+		switch_memory_pool_t *sessionpool;
+		sessionpool = switch_core_session_get_pool(coresession);
+		for (hi = switch_channel_variable_first(channel,sessionpool); hi; hi = switch_hash_next(hi)) 
 		{
-			switch_hash_this(hi, &var, NULL, &val);
+			switch_hash_this(hi, &var, 0, &val);
 			std::string tempstring_first, tempstring_second;
 			tempstring_first = (char *) var;
 			tempstring_second = (char *) val;
@@ -199,15 +202,19 @@
 	}
 	else
 	{
-		std::list<std::string>::iterator iBeg,iItr,iEnd;
+		std::list<std::string>::const_iterator iBeg,iItr,iEnd;
 		iBeg = stringlist.begin();
 		iEnd = stringlist.end();
-	
+			
 		for(iItr = stringlist.begin(); iItr != iEnd; iItr++)
 		{
-			std::string tempstring = switch_channel_get_variable(channel,iItr->c_str());
-			if(tempstring.size() > 0)
-				chanvars[*iItr] = tempstring;
+			std::vector<char> tempstringvector(iItr->begin(), iItr->end());
+			tempstringvector.push_back('\0');
+			char* tempstring= &tempstringvector[0];
+
+			std::string tempstring_formap = switch_channel_get_variable(channel,tempstring);
+			if(tempstring_formap.size() > 0)
+				chanvars[*iItr] = tempstring_formap;
 		}
 	}
 }

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h	Wed Jun 14 21:11:40 2006
@@ -16,6 +16,7 @@
 #ifdef __cplusplus
 #include <vector>
 #include <list>
+#include <vector>
 #include <map>
 #include <switch.h>
 #include <sys/types.h>
@@ -24,6 +25,7 @@
 
 struct switch_mod_cdr_newchannel_t 
 {
+	switch_core_session_t *session;
 	switch_channel_t *channel;
 	switch_channel_timetable_t *timetable;
 	switch_caller_extension_t *callerextension;
@@ -39,7 +41,7 @@
 		virtual ~BaseCDR();
 		BaseCDR(switch_mod_cdr_newchannel_t *newchannel);
 		//BaseCDR(const BaseCDR& copyFrom);
-		virtual void connect(switch_xml_t *cfg, switch_xml_t *xml, switch_xml_t *settings, switch_xml_t *param) = 0;
+		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) = 0;
 		virtual void disconnect() = 0;
 		virtual bool process_record() = 0;
 		virtual bool is_activated() = 0;
@@ -48,7 +50,6 @@
 	protected:
 		std::list<std::string> parse_channel_variables_xconfig(std::string& unparsed);
 		void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel);
-		//switch_channel_t *tempchannel;
 		switch_time_t callstartdate;
 		switch_time_t callanswerdate;
 		switch_time_t callenddate;
@@ -71,6 +72,7 @@
 		switch_time_t billusec; // Yes, you heard me, we're measuring in microseconds
 		int disposition; // Currently 0 = Busy/Unanswered, 1 = Answered
 		int amaflags;
+		switch_core_session_t *coresession;
 		std::map<std::string,std::string> chanvars;
 		/*
 		This is what happens when you base the ideas off of Asterisk...  you end up with an inconvenient asteriskism.

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.cpp	Wed Jun 14 21:11:40 2006
@@ -15,12 +15,12 @@
 	char *configfile = "mod_cdr.conf";
 	switch_xml_t cfg, xml, settings, param;
 	
-	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
-	memset(newchannel,0,sizeof(*newchannel));
+	switch_mod_cdr_newchannel_t *newchannel; // = new switch_mod_cdr_newchannel_t;
+	//memset(newchannel,0,sizeof(*newchannel));
+	newchannel = 0;
 	
-	
 	if (!(xml = switch_xml_open_cfg(configfile, &cfg, NULL))) 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", configfile);
+		switch_console_printf(SWITCH_CHANNEL_LOG,"open of %s failed\n", configfile);
 	else
 	{	
 		BaseRegistry& registry(BaseRegistry::get());
@@ -29,13 +29,13 @@
 			basecdr_creator func = *it;
 			BaseCDR* _ptr = func(newchannel);
 			std::auto_ptr<BaseCDR> ptr(_ptr);
-			ptr->connect(&cfg,&xml,&settings,&param);
+			ptr->connect(cfg,xml,settings,param);
 		}
 	}
 
 	switch_xml_free(xml);
 	
-	delete newchannel;
+	//delete newchannel;
 }
 
 CDRContainer::~CDRContainer()
@@ -43,8 +43,9 @@
 	if(switch_queue_size(cdrqueue) > 0)
 		process_records();
 	
-	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
-	memset(newchannel,0,sizeof(*newchannel));
+	switch_mod_cdr_newchannel_t *newchannel; //= new switch_mod_cdr_newchannel_t;
+	//memset(newchannel,0,sizeof(*newchannel));
+	newchannel = 0;
 	
 	BaseRegistry& registry(BaseRegistry::get());
 	for(BaseRegistry::iterator it = registry.begin(); it != registry.end(); ++it)
@@ -55,20 +56,26 @@
 		ptr->disconnect();
 	}
 		
-	switch_console_printf(SWITCH_CHANNEL_LOG, "mod_cdr shutdown gracefully.");
-	delete newchannel;
+	switch_console_printf(SWITCH_CHANNEL_LOG,"mod_cdr shutdown gracefully.");
+	// delete newchannel;
 }
 
-void CDRContainer::add_cdr(switch_channel_t *channel)
+void CDRContainer::add_cdr(switch_core_session_t *session)
 {
+	//switch_channel_t *channel;
 	switch_mod_cdr_newchannel_t *newchannel = new switch_mod_cdr_newchannel_t;
 	memset(newchannel,0,sizeof(*newchannel));
 	
-	newchannel->timetable = switch_channel_get_timetable(channel);
-	newchannel->callerextension = switch_channel_get_caller_extension(channel);
-	newchannel->callerprofile = switch_channel_get_caller_profile(channel);
-	newchannel->originateprofile = switch_channel_get_originator_caller_profile(channel);	
+	newchannel->channel = switch_core_session_get_channel(session);
+	assert(newchannel->channel != 0);
+
 	
+	newchannel->session = session;
+	newchannel->timetable = switch_channel_get_timetable(newchannel->channel);
+	newchannel->callerextension = switch_channel_get_caller_extension(newchannel->channel);
+	newchannel->callerprofile = switch_channel_get_caller_profile(newchannel->channel);
+	newchannel->originateprofile = switch_channel_get_originator_caller_profile(newchannel->channel);	
+	
 	BaseRegistry& registry(BaseRegistry::get());
 	for(BaseRegistry::iterator it = registry.begin(); it != registry.end(); ++it)
 	{
@@ -82,22 +89,22 @@
 		if(newchannel->originateprofile != 0 )
 		{
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG,"Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 			
 			if(newchannel->timetable->next != 0)
 			{
-				newchannel->originateprofile = switch_channel_get_originatee_caller_profile(channel);
+				newchannel->originateprofile = switch_channel_get_originatee_caller_profile(newchannel->channel);
 				newchannel->originate = 1;
 			}	
 		}
 		else
 		{
-			newchannel->originateprofile = switch_channel_get_originatee_caller_profile(channel);
+			newchannel->originateprofile = switch_channel_get_originatee_caller_profile(newchannel->channel);
 			newchannel->originate = 1;
 			
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG,"Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 		}
 		
@@ -109,7 +116,7 @@
 			newchannel->originateprofile = newchannel->originateprofile->next;
 			
 			BaseCDR* newloggerobject = func(newchannel);
-			switch_console_printf(SWITCH_CHANNEL_LOG, "Adding a new logger object to the queue.\n");
+			switch_console_printf(SWITCH_CHANNEL_LOG,"Adding a new logger object to the queue.\n");
 			switch_queue_push(cdrqueue,newloggerobject);
 		}
 	}

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/cdrcontainer.h	Wed Jun 14 21:11:40 2006
@@ -36,7 +36,7 @@
 		CDRContainer();
 		CDRContainer(switch_memory_pool_t *module_pool);
 		~CDRContainer();
-		void add_cdr(switch_channel_t *channel);
+		void add_cdr(switch_core_session_t *session);
 		void process_records();
 	protected:
 	private:

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mod_cdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mod_cdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mod_cdr.cpp	Wed Jun 14 21:11:40 2006
@@ -7,17 +7,17 @@
 static const char modname[] = "mod_cdr - CDR Engine";
 static int RUNNING = 0;
 static CDRContainer *newcdrcontainer;
-static switch_memory_pool *module_pool;
+static switch_memory_pool_t *module_pool;
 /*
 static switch_thread_cond_t *cond;
 static switch_mutex_t *mutex;
 */
-static switch_status my_on_hangup(switch_core_session *session);
+static switch_status_t my_on_hangup(switch_core_session_t *session);
 
 /* Now begins the glue that will tie this into the system.
 */
 
-static const switch_state_handler_table state_handlers = {
+static const switch_state_handler_table_t state_handlers = {
 	/*.on_init */ NULL,
 	/*.on_ring */ NULL,
 	/*.on_execute */ NULL,
@@ -26,7 +26,7 @@
 	/*.on_transmit */ NULL
 };
 
-static const switch_loadable_module_interface cdr_module_interface = {
+static const switch_loadable_module_interface_t cdr_module_interface = {
 	/*.module_name */ modname,
 	/*.endpoint_interface */ NULL,
 	/*.timer_interface */ NULL,
@@ -35,21 +35,16 @@
 	/*.application_interface */ NULL
 };
 
-static switch_status my_on_hangup(switch_core_session *session)
+static switch_status_t my_on_hangup(switch_core_session_t *session)
 {
-	switch_channel *channel;
-
-	channel = switch_core_session_get_channel(session);
-	assert(channel != NULL);
+	newcdrcontainer->add_cdr(session);
 	
-	newcdrcontainer->add_cdr(channel);
-	
 	//switch_thread_cond_signal(cond);
 	
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*interface = &cdr_module_interface;
@@ -58,7 +53,7 @@
 	
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) 
 	{
-		switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH - Can't swim, no pool\n");
+		switch_console_printf(SWITCH_CHANNEL_LOG, "OH OH - Can't swim, no pool\n");
 		return SWITCH_STATUS_TERM;
 	}
 
@@ -73,18 +68,18 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	RUNNING = 1;
 	//switch_mutex_lock(mutex);
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "mod_cdr made it to runtime.  Wee!\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG, "mod_cdr made it to runtime.  Wee!\n");
 	newcdrcontainer->process_records();
 	//switch_thread_cond_wait(cond, mutex);
 	
 	return RUNNING ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TERM;
 }
 
-SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	delete newcdrcontainer;
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp	Wed Jun 14 21:11:40 2006
@@ -11,18 +11,21 @@
 
 MysqlCDR::MysqlCDR(switch_mod_cdr_newchannel_t *newchannel) : BaseCDR(newchannel)
 {
-	clid_length = strlen(clid);
-	src_length = strlen(src);
-	dst_length = strlen(dst);
-	ani_length = strlen(ani);
-	ani2_length = strlen(ani2);
-	dialplan_length = strlen(dialplan);
-	myuuid_length = strlen(myuuid);
-	destuuid_length = strlen(destuuid);
-	srcchannel_length = strlen(srcchannel);
-	dstchannel_length = strlen(dstchannel);
-	lastapp_length = strlen(lastapp);
-	lastdata_length = strlen(lastdata);
+	if(newchannel != 0)
+	{
+		clid_length = strlen(clid);
+		src_length = strlen(src);
+		dst_length = strlen(dst);
+		ani_length = strlen(ani);
+		ani2_length = strlen(ani2);
+		dialplan_length = strlen(dialplan);
+		myuuid_length = strlen(myuuid);
+		destuuid_length = strlen(destuuid);
+		srcchannel_length = strlen(srcchannel);
+		dstchannel_length = strlen(dstchannel);
+		lastapp_length = strlen(lastapp);
+		lastdata_length = strlen(lastdata);
+	}
 }
 
 MysqlCDR::~MysqlCDR()
@@ -45,9 +48,9 @@
 char MysqlCDR::password[255] = "";
 //fstream MysqlCDR::tmpfile;
 
-void MysqlCDR::connect(switch_xml_t *cfg, switch_xml_t *xml, switch_xml_t *settings, switch_xml_t *param)
+void MysqlCDR::connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param)
 {
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::connect() - Trying to connect to the server.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::connect() - Trying to connect to the server.\n");
 	activated = 0; // Set it as inactive initially
 	connectionstate = 0; // Initialize it to false to show that we aren't yet connected.
 	char tmpsql_query[] = "INSERT INTO freeswitchcdr  (callstartdate,callanswerdate,callenddate,originated,clid,src,dst,ani,ani2,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
@@ -58,12 +61,12 @@
 	memset(sql_query_chanvars,0,1024);
 	strncpy(sql_query_chanvars,tempsql_query_chanvars,strlen(tempsql_query_chanvars));
 	
-	if ((*settings = switch_xml_child(*cfg, "mysqlcdr"))) 
+	if ((settings = switch_xml_child(cfg, "mysqlcdr"))) 
 	{
-		for (param = switch_xml_child(*settings, "param"); *param; *param = (*param)->next) 
+		for (param = switch_xml_child(settings, "param"); param; param = param->next) 
 		{
-			char *var = (char *) switch_xml_attr_soft(*param, "name");
-			char *val = (char *) switch_xml_attr_soft(*param, "value");
+			char *var = (char *) switch_xml_attr_soft(param, "name");
+			char *val = (char *) switch_xml_attr_soft(param, "value");
 
 			if (!strcmp(var, "hostname"))
 				strncpy(hostname,val,strlen(val));
@@ -73,7 +76,7 @@
 				strncpy(password,val,strlen(val));
 			else if(!strcmp(var,"dbname"))
 				strncpy(dbname,val,strlen(val));
-			else if(!strcmp(var,"chanvars")
+			else if(!strcmp(var,"chanvars"))
 			{
 				std::string unparsed;
 				unparsed = val;
@@ -86,7 +89,7 @@
 		}
 		
 		activated = 1;
-		switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::connect() - Trying to init the MYSQL *conn pointer.\n");
+		switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::connect() - Trying to init the MYSQL *conn pointer.\n");
 		conn = mysql_init(NULL);
 		mysql_options(conn, MYSQL_READ_DEFAULT_FILE, "");
 		if(mysql_real_connect(conn,hostname,username,password,dbname,0,NULL,0) == NULL)
@@ -94,17 +97,22 @@
 			char *error1 = "Cannot connect to MySQL Server.  The error was: ";
 			const char *error2 = mysql_error(conn);
 			strncat(error1,error2,strlen(error2));
-			switch_console_printf(SWITCH_CHANNEL_CONSOLE,error1);
+			switch_console_printf(SWITCH_CHANNEL_LOG,error1);
 		}
 		else
 			connectionstate = 1;
 
 		mysql_autocommit(conn,0);
 		stmt = mysql_stmt_init(conn);
+		
 		mysql_stmt_prepare(stmt,sql_query,strlen(sql_query));
+		
+		// Temporary commenting out for debugging
 		if(logchanvars)
+		{
+			stmt_chanvars = mysql_stmt_init(conn);
 			mysql_stmt_prepare(stmt_chanvars,sql_query_chanvars,strlen(sql_query_chanvars));
-	
+		}
 	}
 }
 
@@ -191,18 +199,23 @@
 	add_parameter(hangupcause,MYSQL_TYPE_LONG,0);
 	add_parameter(amaflags,MYSQL_TYPE_TINY,0);
 	
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::process_record() - Trying to process, bindme has %d elements.\n",bindme.size());
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to process, bindme has %d elements.\n",bindme.size());
 	
 	MYSQL_BIND *bindmetemp;
 	bindmetemp = new MYSQL_BIND[bindme.size()];
 	copy(bindme.begin(), bindme.end(), bindmetemp);
 	
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::process_record() - Trying to bind the parameters.\n");
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to bind the parameters.\n");
 	mysql_stmt_bind_param(stmt,bindmetemp);
-	switch_console_printf(SWITCH_CHANNEL_CONSOLE, "MysqlCDR::process_record() - Trying to execute the statement.\n");
-	mysql_stmt_execute(stmt);
-	long long insertid = mysql_stmt_insert_id();
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Trying to execute the statement.\n");
+	int bah = mysql_stmt_execute(stmt);
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",bah);
 	
+	const char* bah2 = mysql_stmt_error(stmt);
+	switch_console_printf(SWITCH_CHANNEL_LOG,"MySQL encountered error: %s\n",bah2);
+	
+	long long insertid = mysql_stmt_insert_id(stmt);
+	
 	if(logchanvars && chanvars.size() > 0)
 	{
 		std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
@@ -216,25 +229,37 @@
 			bindme_chanvars[0].buffer_type = MYSQL_TYPE_LONGLONG;
 			bindme_chanvars[0].buffer = &insertid;
 			
+			std::vector<char> tempfirstvector(iItr->first.begin(), iItr->first.end());
+			tempfirstvector.push_back('\0');
+			char* varname_temp = &tempfirstvector[0];
+
 			bindme_chanvars[1].buffer_type = MYSQL_TYPE_VAR_STRING;
 			long unsigned int varname_length = iItr->first.size();
 			bindme_chanvars[1].length = &varname_length;
 			bindme_chanvars[1].buffer_length = varname_length;
-			char varname_temp[] = iItr->first.c_str();
 			bindme_chanvars[1].buffer = varname_temp;
 			
+			std::vector<char> tempsecondvector(iItr->second.begin(), iItr->second.end());
+			tempsecondvector.push_back('\0');
+			char* varvalue_temp = &tempsecondvector[0];
+			
 			bindme_chanvars[2].buffer_type = MYSQL_TYPE_VAR_STRING;
-			long unsigned int varvalue_length = iItr->second.size();
-			bindme_chanvars[2].length = &varvalue_length;
-			bindme_chanvars[2].buffer_length = varvalue_length;
-			char varvalue_temp[] = iItr->second.c_str();
-			bindme_chanvars[1].buffer = varvalue_temp;
+			if(iItr->second.size() == 0)
+				bindme_chanvars[2].is_null = (my_bool*)1;
+			else
+			{
+				long unsigned int varvalue_length = iItr->second.size();
+				bindme_chanvars[2].length = &varvalue_length;
+				bindme_chanvars[2].buffer_length = varvalue_length;
+				bindme_chanvars[2].buffer = varvalue_temp;
+			}
 			
 			mysql_stmt_bind_param(stmt_chanvars,bindme_chanvars);
 			mysql_stmt_execute(stmt_chanvars);
 		}
 	}
 	
+	
 	mysql_commit(conn);
 	
 	/* For future use
@@ -272,14 +297,15 @@
 	MYSQL_BIND temp_bind;
 	memset(&temp_bind,0,sizeof(temp_bind));
 	temp_bind.buffer_type = type;
-	if(is_null)
+	if(is_null || param == 0)
 		temp_bind.is_null = (my_bool*)1;
-	
-	temp_bind.length = &param_length;
-	temp_bind.buffer_length = param_length;
-	temp_bind.buffer = param;
-	
-	std::cout << "String added is: " << temp_bind.buffer << " and is " << temp_bind.length << " characters long." << std::endl;
+	else
+	{
+		temp_bind.length = &param_length;
+		temp_bind.buffer_length = param_length;
+		temp_bind.buffer = param;
+	}
+	//std::cout << "String added is: " << temp_bind.buffer << " and is " << temp_bind.length << " characters long." << std::endl;
 	
 	bindme.push_back(temp_bind);
 }

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h	Wed Jun 14 21:11:40 2006
@@ -12,7 +12,7 @@
 		//MysqlCDR(const MysqlCDR& copyFrom);
 		virtual ~MysqlCDR();
 		virtual bool process_record();
-		virtual void connect(switch_xml_t *cfg, switch_xml_t *xml, switch_xml_t *settings, switch_xml_t *param);
+		virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
 		virtual void disconnect();
 		virtual bool is_activated();
 		virtual void tempdump_record();

Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql	(original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/schema.sql	Wed Jun 14 21:11:40 2006
@@ -14,7 +14,7 @@
 	destuuid char(36) NOT NULL,
 	srcchannel varchar(80) NOT NULL,
 	dstchannel varchar(80) NOT NULL, /* Need to decide - this might be redundant as you can link the records via uuid */
-	lastapp varchar(80) NOT NULL,
+	lastapp varchar(80) default "",
 	lastdata varchar(255) default "",
 	billusec bigint default 0,
 	disposition tinyint default 0, /* 0 = Busy or Unanswered, 1 = Answered */
@@ -34,7 +34,7 @@
 create table chanvars (
 	callid bigint unsigned default 0,
 	varname varchar(80) NOT NULL,
-	varval varchar(255) NOT NULL
+	varval varchar(255) default ""
 );
 
 create index callid_index on chanvars(callid);
\ No newline at end of file

Modified: freeswitch/branches/mishehu/src/switch_channel.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_channel.c	(original)
+++ freeswitch/branches/mishehu/src/switch_channel.c	Wed Jun 14 21:11:40 2006
@@ -141,11 +141,13 @@
 
 SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel)
 {
+	assert(channel != NULL);
 	return channel->hangup_cause;
 }
 
 SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel_t *channel)
 {
+	assert(channel != NULL);
 	return channel->times;
 }
 
@@ -289,11 +291,13 @@
 
 SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, char *varname)
 {
+	assert(channel != NULL);
 	return switch_core_hash_find(channel->variables, varname);
 }
 
 SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool)
 {
+	assert(channel != NULL);
 	return switch_hash_first(pool, channel->variables);
 }
 
@@ -341,16 +345,19 @@
 
 SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
+	assert(channel != NULL);
 	return switch_test_flag(channel, flags) ? 1 : 0;
 }
 
 SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
+	assert(channel != NULL);
 	switch_set_flag(channel, flags);
 }
 
 SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags)
 {
+	assert(channel != NULL);
 	switch_clear_flag(channel, flags);
 }
 

Modified: freeswitch/branches/mishehu/src/switch_console.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_console.c	(original)
+++ freeswitch/branches/mishehu/src/switch_console.c	Wed Jun 14 21:11:40 2006
@@ -198,7 +198,7 @@
 		}
 
 		memset(&cmd, 0, sizeof(cmd));
-		for (x = 0; x < sizeof(cmd); x++) {
+		for (x = 0; x < (sizeof(cmd)-1); x++) {
 			cmd[x] = (char) getchar();
 			if (cmd[x] == '\n') {
 				cmd[x] = '\0';



More information about the Freeswitch-svn mailing list