[Freeswitch-branches] [commit] r4322 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr
Author: mishehu Date: Mon Feb 19 00:21:40 2007 New Revision: 4322 Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp Log: Fixed basecdr.cpp to use switch_strlen_zero() in order to properly check whether the char*'s contain any strings. This reflects changes by MikeJ to the core. Still need to test. Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp ============================================================================== --- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp (original) +++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp Mon Feb 19 00:21:40 2007 @@ -89,25 +89,19 @@ calltransferdate = newchannel->callerprofile->times->transferred; callenddate = newchannel->callerprofile->times->hungup; - if(newchannel->callerprofile->caller_id_name != 0) - { + if(!switch_strlen_zero(newchannel->callerprofile->caller_id_name)) strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name)); - strncat(clid," <",2); - if(newchannel->callerprofile->caller_id_number != 0 ) - strncat(clid,newchannel->callerprofile->caller_id_number,strlen(clid)+strlen(newchannel->callerprofile->caller_id_number)); - strncat(clid,">",1); - } // Get the ANI information if it's set - if(newchannel->callerprofile->ani != 0) + if(!switch_strlen_zero(newchannel->callerprofile->ani)) strncpy(ani,newchannel->callerprofile->ani,strlen(newchannel->callerprofile->ani)); - if(newchannel->callerprofile->aniii != 0) + if(!switch_strlen_zero(newchannel->callerprofile->aniii)) strncpy(aniii,newchannel->callerprofile->aniii,strlen(newchannel->callerprofile->aniii)); - if(newchannel->callerprofile->dialplan != 0) + if(!switch_strlen_zero(newchannel->callerprofile->dialplan)) strncpy(dialplan,newchannel->callerprofile->dialplan,strlen(newchannel->callerprofile->dialplan)); - if(newchannel->callerprofile->network_addr != 0) + if(!switch_strlen_zero(newchannel->callerprofile->network_addr)) strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr)); } @@ -117,13 +111,13 @@ if(newchannel->callerprofile->originator_caller_profile) { originated = 0; - if(newchannel->callerprofile->originator_caller_profile->uuid != 0) + if(!switch_strlen_zero(newchannel->callerprofile->originator_caller_profile->uuid)) strncpy(destuuid,newchannel->callerprofile->originator_caller_profile->uuid,strlen(newchannel->callerprofile->originator_caller_profile->uuid)); if(newchannel->callerprofile) { - if(newchannel->callerprofile->destination_number) + if(!switch_strlen_zero(newchannel->callerprofile->destination_number)) strncpy(src,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number)); - if(newchannel->callerprofile->caller_id_number != 0) + if(!switch_strlen_zero(newchannel->callerprofile->caller_id_number)) strncpy(dst,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number)); } } @@ -133,19 +127,23 @@ // Or were we maybe we were the caller? if(newchannel->callerprofile->originatee_caller_profile) { - if (newchannel->callerprofile) { - if(newchannel->callerprofile->caller_id_number != 0) + if (newchannel->callerprofile) + { + if(!switch_strlen_zero(newchannel->callerprofile->caller_id_number)) strncpy(src,newchannel->callerprofile->caller_id_number,strlen(newchannel->callerprofile->caller_id_number)); - if(newchannel->callerprofile->destination_number != 0) + if(!switch_strlen_zero(newchannel->callerprofile->destination_number)) strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number)); } - if(newchannel->callerprofile->originatee_caller_profile->chan_name != 0) + if(!switch_strlen_zero(newchannel->callerprofile->originatee_caller_profile->chan_name)) strncpy(dstchannel,newchannel->callerprofile->originatee_caller_profile->chan_name,strlen(newchannel->callerprofile->originatee_caller_profile->chan_name)); } } - strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid)); - strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name)); + if(!switch_strlen_zero(newchannel->callerprofile->uuid)) + strncpy(myuuid,newchannel->callerprofile->uuid,strlen(newchannel->callerprofile->uuid)); + + if(!switch_strlen_zero(newchannel->callerprofile->chan_name)) + strncpy(srcchannel,newchannel->callerprofile->chan_name,strlen(newchannel->callerprofile->chan_name)); if(switch_channel_test_flag(newchannel->channel,CF_ANSWERED)) { @@ -174,12 +172,12 @@ hangupcause = switch_channel_get_cause(newchannel->channel); hangupcause_text = switch_channel_cause2str(hangupcause); - if(newchannel->callerextension != 0) - if(newchannel->callerextension->last_application != 0) + if(newchannel->callerextension) + if(!switch_strlen_zero(newchannel->callerextension->last_application)) { - if(newchannel->callerextension->last_application->application_name != 0) + if(!switch_strlen_zero(newchannel->callerextension->last_application->application_name)) strncpy(lastapp,newchannel->callerextension->last_application->application_name,strlen(newchannel->callerextension->last_application->application_name)); - if(newchannel->callerextension->last_application->application_data != 0) + if(!switch_strlen_zero(newchannel->callerextension->last_application->application_data)) strncpy(lastdata,newchannel->callerextension->last_application->application_data,strlen(newchannel->callerextension->last_application->application_data)); } @@ -324,7 +322,7 @@ std::pair<std::string,std::string> temppair; temppair.first = *iItr; - if(tempvariable != 0) + if(!switch_strlen_zero(tempvariable)) temppair.second = tempvariable; chanvars_fixed.push_back(temppair); @@ -363,7 +361,7 @@ char *tempvariable; tempvariable = switch_channel_get_variable(channel,tempstring); - if(tempvariable != 0) + if(!switch_strlen_zero(tempvariable)) chanvars_supp[*iItr] = tempvariable; } }
participants (1)
-
Freeswitch SVN