diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 9442d1828c..a85a24357c 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -384,6 +384,7 @@ typedef apr_socket_t switch_socket_t; /** Freeswitch's socket address type, used to ensure protocol independence */ typedef apr_sockaddr_t switch_sockaddr_t; +typedef apr_port_t switch_port_t; /* function definitions */ /** diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index b33d2980e2..a23d7e5f3a 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -39,7 +39,9 @@ extern "C" { #endif #ifdef _MSC_VER -#pragma warning(disable:4152 4054 4100) +// C4200 Non standard extension C zero sized array +// C4204: nonstandard extension used : non-constant aggregate initializer +#pragma warning(disable:4152 4054 4100 4142 4200 4204) #endif #if (_MSC_VER >= 1400) // VC8+ diff --git a/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c b/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c index 611d149d95..c6c42efe3e 100644 --- a/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c +++ b/src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c @@ -69,7 +69,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) memset(app, 0, sizeof(app)); strncpy(app, val, sizeof(app)); - if ((data = strchr(app, ' '))) { + if ((data = strchr(app, ' ')) != 0) { *data = '\0'; data++; } else { @@ -77,10 +77,9 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) continue; } if (!extension) { - if (! - (extension = + if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, - caller_profile->destination_number))) { + caller_profile->destination_number)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); break; } diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c index 3c7dba8bd3..d08d5298d4 100644 --- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c +++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c @@ -124,14 +124,14 @@ switch_caller_extension *directory_dialplan_hunt(switch_core_session *session) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DIRECTORY VALUE [%s]=[%s]\n", var, val); if(!strcasecmp(var, "callflow")) { if (!extension) { - if (!(extension = switch_caller_extension_new(session, caller_profile->destination_number, - caller_profile->destination_number))) { + if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, + caller_profile->destination_number)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); goto out; } } switch_copy_string(app, val, sizeof(app)); - if ((data = strchr(app, ' '))) { + if ((data = strchr(app, ' ')) != 0) { *data++ = '\0'; } switch_caller_extension_add_application(session, extension, app, data); diff --git a/src/mod/dialplans/mod_pcre/mod_pcre.c b/src/mod/dialplans/mod_pcre/mod_pcre.c index 0ab6e89ed6..593edf7b92 100644 --- a/src/mod/dialplans/mod_pcre/mod_pcre.c +++ b/src/mod/dialplans/mod_pcre/mod_pcre.c @@ -144,15 +144,14 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session) memset(app, 0, sizeof(app)); switch_copy_string(app, newval, sizeof(app)); - if ((data = strchr(app, ' '))) { + if ((data = strchr(app, ' ')) != 0) { *data = '\0'; data++; } if (!extension) { - if (! - (extension = - switch_caller_extension_new(session, exten_name, caller_profile->destination_number))) { + if ((extension = + switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); break; } diff --git a/src/mod/directories/mod_ldap/mod_ldap.c b/src/mod/directories/mod_ldap/mod_ldap.c index 301267d7a9..ce974b42a8 100644 --- a/src/mod/directories/mod_ldap/mod_ldap.c +++ b/src/mod/directories/mod_ldap/mod_ldap.c @@ -63,7 +63,7 @@ static switch_status mod_ldap_open(switch_directory_handle *dh, char *source, ch int auth_method = LDAP_AUTH_SIMPLE; int desired_version = LDAP_VERSION3; - if (!(context = switch_core_alloc(dh->memory_pool, sizeof(*context)))) { + if ((context = switch_core_alloc(dh->memory_pool, sizeof(*context))) == 0) { return SWITCH_STATUS_MEMERR; } @@ -188,7 +188,7 @@ switch_status mod_ldap_next_pair(switch_directory_handle *dh, char **var, char * context->attr = ldap_next_attribute(context->ld, context->entry, context->ber); } context->vitt++; - if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr))) { + if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) { goto itter; } } diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index 03d4d19d90..995abdc89b 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -70,9 +70,6 @@ typedef enum { #define PACKET_LEN 160 #define DEFAULT_BYTES_PER_FRAME 160 - -static const switch_endpoint_interface exosip_endpoint_interface; - static struct { int debug; int bytes_per_frame; @@ -288,9 +285,8 @@ static switch_status exosip_on_init(switch_core_session *session) } /* Setup our INVITE */ eXosip_lock(); - if (! - (dest_uri = - (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) { + if ((dest_uri = + (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n"); assert(dest_uri != NULL); } @@ -380,51 +376,6 @@ static switch_status exosip_on_transmit(switch_core_session *session) return SWITCH_STATUS_SUCCESS; } -static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, - switch_core_session **new_session) -{ - if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) { - struct private_object *tech_pvt; - switch_channel *channel; - - switch_core_session_add_stream(*new_session, NULL); - if ((tech_pvt = - (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) { - memset(tech_pvt, 0, sizeof(*tech_pvt)); - channel = switch_core_session_get_channel(*new_session); - switch_core_session_set_private(*new_session, tech_pvt); - switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session)); - tech_pvt->session = *new_session; - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (outbound_profile) { - char name[128]; - switch_caller_profile *caller_profile; - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - snprintf(name, sizeof(name), "Exosip/%s-%04x", caller_profile->destination_number, rand() & 0xffff); - switch_channel_set_name(channel, name); - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_GENERR; -} - static void deactivate_rtp(struct private_object *tech_pvt) { @@ -751,6 +702,51 @@ static const switch_loadable_module_interface exosip_module_interface = { /*.application_interface */ NULL }; +static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, + switch_core_session **new_session) +{ + if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) { + struct private_object *tech_pvt; + switch_channel *channel; + + switch_core_session_add_stream(*new_session, NULL); + if ((tech_pvt = + (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) { + memset(tech_pvt, 0, sizeof(*tech_pvt)); + channel = switch_core_session_get_channel(*new_session); + switch_core_session_set_private(*new_session, tech_pvt); + switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session)); + tech_pvt->session = *new_session; + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if (outbound_profile) { + char name[128]; + switch_caller_profile *caller_profile; + + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + snprintf(name, sizeof(name), "Exosip/%s-%04x", caller_profile->destination_number, rand() & 0xffff); + switch_channel_set_name(channel, name); + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_GENERR; +} + #if 1 SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) { @@ -792,13 +788,13 @@ static switch_status exosip_create_call(eXosip_event_t * event) char *dpayload, *dname, *drate; char *remote_sdp_str = NULL; - if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL))) { + if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) { struct private_object *tech_pvt; switch_codec_interface *codecs[SWITCH_MAX_CODECS]; int num_codecs = 0; switch_core_session_add_stream(session, NULL); - if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) { + if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) { memset(tech_pvt, 0, sizeof(*tech_pvt)); channel = switch_core_session_get_channel(session); switch_core_session_set_private(session, tech_pvt); @@ -815,7 +811,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) event->request->from->displayname, event->request->from->url->username, event->request->from->url->host, - NULL, NULL, event->request->req_uri->username))) { + NULL, NULL, event->request->req_uri->username)) != 0) { switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } @@ -827,7 +823,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) snprintf(name, sizeof(name), "Exosip/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff); switch_channel_set_name(channel, name); - if (!(remote_sdp = eXosip_get_sdp_info(event->request))) { + if ((remote_sdp = eXosip_get_sdp_info(event->request)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Remote SDP!\n"); exosip_on_hangup(session); switch_core_session_destroy(&session); @@ -915,7 +911,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) switch_channel_set_state(channel, CS_INIT); - if (1) { + { int rate = atoi(drate); if (switch_core_codec_init(&tech_pvt->read_codec, @@ -975,7 +971,7 @@ static void destroy_call_by_event(eXosip_event_t * event) struct private_object *tech_pvt; switch_channel *channel = NULL; - if (!(tech_pvt = get_pvt_by_call_id(event->cid))) { + if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n", event->cid); return; @@ -1001,12 +997,12 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d attr = (sdp_attribute_t *) osip_list_get(media->a_attributes, pos); if (attr != NULL && strcasecmp(attr->a_att_field, "rtpmap") == 0) { payload = attr->a_att_value; - if ((name = strchr(payload, ' '))) { + if ((name = strchr(payload, ' ')) != 0) { *(name++) = '\0'; /* Name and payload are required */ *dpayload = strdup(payload); status = SWITCH_STATUS_SUCCESS; - if ((rate = strchr(name, '/'))) { + if ((rate = strchr(name, '/')) != 0) { *(rate++) = '\0'; *drate = strdup(rate); *dname = strdup(name); @@ -1041,7 +1037,7 @@ static void handle_answer(eXosip_event_t * event) switch_channel *channel; - if (!(tech_pvt = get_pvt_by_call_id(event->cid))) { + if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt!\n"); return; } @@ -1056,7 +1052,7 @@ static void handle_answer(eXosip_event_t * event) } /* Get all of the remote SDP elements... stuff */ - if (!(remote_sdp = eXosip_get_sdp_info(event->response))) { + if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cant Find SDP?\n"); switch_channel_hangup(channel); return; @@ -1080,7 +1076,7 @@ static void handle_answer(eXosip_event_t * event) tech_pvt->tid = event->tid; - if (1) { + { int rate = atoi(drate); @@ -1348,7 +1344,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) globals.running = 1; while (globals.running > 0) { - if (!(event = eXosip_event_wait(0, 100))) { + if ((event = eXosip_event_wait(0, 100)) == 0) { switch_yield(1000); continue; } diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.vcproj b/src/mod/endpoints/mod_exosip/mod_exosip.vcproj index 41a323015f..c546b2afc5 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.vcproj +++ b/src/mod/endpoints/mod_exosip/mod_exosip.vcproj @@ -201,6 +201,22 @@ + + + + + + session), + if ((num_codecs = switch_loadable_module_get_codecs_sorted(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS, globals.codec_order, - globals.codec_order_last)) > 0) { + globals.codec_order_last)) <= 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n"); return SWITCH_STATUS_GENERR; } } else - if (! - (num_codecs = - switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, - SWITCH_MAX_CODECS)) > 0) { + if (((num_codecs = + switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n"); return SWITCH_STATUS_GENERR; } @@ -389,9 +387,6 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s return SWITCH_STATUS_SUCCESS; } - -static const switch_endpoint_interface channel_endpoint_interface; - static switch_status channel_on_init(switch_core_session *session); static switch_status channel_on_hangup(switch_core_session *session); static switch_status channel_on_ring(switch_core_session *session); @@ -555,75 +550,6 @@ static switch_status channel_on_transmit(switch_core_session *session) return SWITCH_STATUS_SUCCESS; } - -/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines -that allocate memory or you will have 1 channel with memory allocated from another channel's pool! -*/ -static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, - switch_core_session **new_session) -{ - if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) { - struct private_object *tech_pvt; - switch_channel *channel; - switch_caller_profile *caller_profile; - unsigned int req = 0, cap = 0; - unsigned short samprate = 0; - - switch_core_session_add_stream(*new_session, NULL); - if ((tech_pvt = - (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) { - memset(tech_pvt, 0, sizeof(*tech_pvt)); - channel = switch_core_session_get_channel(*new_session); - switch_core_session_set_private(*new_session, tech_pvt); - tech_pvt->session = *new_session; - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (outbound_profile) { - char name[128]; - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - snprintf(name, sizeof(name), "IAX/%s-%04x", caller_profile->destination_number, rand() & 0xffff); - switch_channel_set_name(channel, name); - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (!(tech_pvt->iax_session = iax_session_new())) { - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - - if (iax_set_codec(tech_pvt, tech_pvt->iax_session, &req, &cap, &samprate, IAX_QUERY) != SWITCH_STATUS_SUCCESS) { - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (samprate) { - iax_set_samplerate(tech_pvt->iax_session, samprate); - } - - iax_call(tech_pvt->iax_session, - caller_profile->caller_id_number, - caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap); - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_GENERR; - -} - static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id) { struct private_object *tech_pvt = NULL; @@ -779,6 +705,74 @@ static const switch_loadable_module_interface channel_module_interface = { }; +/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines +that allocate memory or you will have 1 channel with memory allocated from another channel's pool! +*/ +static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, + switch_core_session **new_session) +{ + if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { + struct private_object *tech_pvt; + switch_channel *channel; + switch_caller_profile *caller_profile; + unsigned int req = 0, cap = 0; + unsigned short samprate = 0; + + switch_core_session_add_stream(*new_session, NULL); + if ((tech_pvt = + (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) { + memset(tech_pvt, 0, sizeof(*tech_pvt)); + channel = switch_core_session_get_channel(*new_session); + switch_core_session_set_private(*new_session, tech_pvt); + tech_pvt->session = *new_session; + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if (outbound_profile) { + char name[128]; + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + snprintf(name, sizeof(name), "IAX/%s-%04x", caller_profile->destination_number, rand() & 0xffff); + switch_channel_set_name(channel, name); + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if ((tech_pvt->iax_session = iax_session_new()) == 0) { + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + + if (iax_set_codec(tech_pvt, tech_pvt->iax_session, &req, &cap, &samprate, IAX_QUERY) != SWITCH_STATUS_SUCCESS) { + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if (samprate) { + iax_set_samplerate(tech_pvt->iax_session, samprate); + } + + iax_call(tech_pvt->iax_session, + caller_profile->caller_id_number, + caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap); + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_GENERR; + +} + SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { @@ -866,7 +860,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) if (globals.debug) { iax_enable_debug(); } - if ((res = iax_init(globals.port) < 0)) { + if (((res = iax_init(globals.port) < 0)) != 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Binding Port!\n"); return SWITCH_STATUS_TERM; } @@ -936,7 +930,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) // the other side answered our call if (tech_pvt) { switch_channel *channel; - if ((channel = switch_core_session_get_channel(tech_pvt->session))) { + if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) { if (switch_channel_test_flag(channel, CF_ANSWERED)) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel)); @@ -962,14 +956,14 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name); - if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) { + if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { struct private_object *tech_pvt; switch_channel *channel; switch_core_session_add_stream(session, NULL); if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, - sizeof(struct private_object)))) { + sizeof(struct private_object))) != 0) { memset(tech_pvt, 0, sizeof(*tech_pvt)); channel = switch_core_session_get_channel(session); switch_core_session_set_private(session, tech_pvt); @@ -987,7 +981,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) iaxevent->ies.calling_number, iax_get_peer_ip(iaxevent->session), iaxevent->ies.calling_ani, - NULL, iaxevent->ies.called_number))) { + NULL, iaxevent->ies.called_number)) != 0) { char name[128]; switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, @@ -1021,7 +1015,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_VOICE); - if ((channel = switch_core_session_get_channel(tech_pvt->session))) { + if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hangup %s\n", switch_channel_get_name(channel)); switch_set_flag(tech_pvt, TFLAG_HANGUP); switch_channel_hangup(channel); @@ -1038,9 +1032,9 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sending silence\n"); break; case IAX_EVENT_VOICE: - if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) { + if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen) != 0) { switch_channel *channel; - if ((channel = switch_core_session_get_channel(tech_pvt->session)) + if (((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) && switch_channel_get_state(channel) <= CS_HANGUP) { int bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame; int frames = (int) (tech_pvt->read_frame.datalen / bytes); @@ -1059,8 +1053,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) case IAX_EVENT_DTMF: if (tech_pvt) { switch_channel *channel; - if ((channel = switch_core_session_get_channel(tech_pvt->session))) { - char str[2] = { iaxevent->subclass }; + if ((channel = switch_core_session_get_channel(tech_pvt->session)) != 0) { + char str[2] = { (char)iaxevent->subclass }; if (globals.debug) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s DTMF %s\n", str, switch_channel_get_name(channel)); diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 555311d519..7bd82e88d1 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -98,9 +98,6 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num) - - static const switch_endpoint_interface channel_endpoint_interface; - static switch_status channel_on_init(switch_core_session *session); static switch_status channel_on_hangup(switch_core_session *session); static switch_status channel_on_ring(switch_core_session *session); @@ -294,55 +291,6 @@ static switch_status channel_on_transmit(switch_core_session *session) } -/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines - that allocate memory or you will have 1 channel with memory allocated from another channel's pool! -*/ -static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, - switch_core_session **new_session) -{ - if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) { - struct private_object *tech_pvt; - switch_channel *channel; - switch_caller_profile *caller_profile; - - switch_core_session_add_stream(*new_session, NULL); - if ((tech_pvt = - (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) { - memset(tech_pvt, 0, sizeof(*tech_pvt)); - channel = switch_core_session_get_channel(*new_session); - switch_core_session_set_private(*new_session, tech_pvt); - tech_pvt->session = *new_session; - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (outbound_profile) { - char name[128]; - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - snprintf(name, sizeof(name), "PortAudio/%s-%04x", - caller_profile->destination_number ? caller_profile->destination_number : modname, - rand() & 0xffff); - switch_channel_set_name(channel, name); - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_GENERR; - -} - static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id) { struct private_object *tech_pvt = NULL; @@ -399,7 +347,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra if (tech_pvt->audio_in && (samples = ReadAudioStream(tech_pvt->audio_in, tech_pvt->read_frame.data, - tech_pvt->read_codec.implementation->samples_per_frame))) { + tech_pvt->read_codec.implementation->samples_per_frame)) != 0) { tech_pvt->read_frame.datalen = samples * 2; tech_pvt->read_frame.samples = samples; *frame = &tech_pvt->read_frame; @@ -524,7 +472,54 @@ static const switch_loadable_module_interface channel_module_interface = { /*.api_interface */ &channel_api_interface }; +/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines + that allocate memory or you will have 1 channel with memory allocated from another channel's pool! +*/ +static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, + switch_core_session **new_session) +{ + if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { + struct private_object *tech_pvt; + switch_channel *channel; + switch_caller_profile *caller_profile; + switch_core_session_add_stream(*new_session, NULL); + if ((tech_pvt = + (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) { + memset(tech_pvt, 0, sizeof(*tech_pvt)); + channel = switch_core_session_get_channel(*new_session); + switch_core_session_set_private(*new_session, tech_pvt); + tech_pvt->session = *new_session; + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if (outbound_profile) { + char name[128]; + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + snprintf(name, sizeof(name), "PortAudio/%s-%04x", + caller_profile->destination_number ? caller_profile->destination_number : modname, + rand() & 0xffff); + switch_channel_set_name(channel, name); + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_GENERR; + +} SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) @@ -796,12 +791,12 @@ static switch_status place_call(char *dest, char *out, size_t outlen) strncpy(out, "FAIL", outlen - 1); - if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) { + if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { struct private_object *tech_pvt; switch_channel *channel; switch_core_session_add_stream(session, NULL); - if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) { + if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) { memset(tech_pvt, 0, sizeof(*tech_pvt)); channel = switch_core_session_get_channel(session); switch_core_session_set_private(session, tech_pvt); @@ -815,7 +810,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen) if ((tech_pvt->caller_profile = switch_caller_profile_new(session, globals.dialplan, globals.cid_name, - globals.cid_num, NULL, NULL, NULL, dest))) { + globals.cid_num, NULL, NULL, NULL, dest)) != 0) { char name[128]; switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); snprintf(name, sizeof(name), "PortAudio/%s-%04x", @@ -863,7 +858,7 @@ static switch_status hup_call(char *callid, char *out, size_t outlen) return SWITCH_STATUS_SUCCESS; } - if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { + if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) { channel = switch_core_session_get_channel(tech_pvt->session); assert(channel != NULL); @@ -884,13 +879,13 @@ static switch_status send_dtmf(char *callid, char *out, size_t outlen) switch_channel *channel = NULL; char *dtmf; - if ((dtmf = strchr(callid, ' '))) { + if ((dtmf = strchr(callid, ' ')) != 0) { *dtmf++ = '\0'; } else { dtmf = ""; } - if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { + if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) { channel = switch_core_session_get_channel(tech_pvt->session); assert(channel != NULL); switch_channel_queue_dtmf(channel, dtmf); @@ -907,7 +902,7 @@ static switch_status answer_call(char *callid, char *out, size_t outlen) struct private_object *tech_pvt = NULL; switch_channel *channel = NULL; - if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { + if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) { channel = switch_core_session_get_channel(tech_pvt->session); assert(channel != NULL); switch_set_flag(tech_pvt, TFLAG_ANSWER); @@ -945,7 +940,7 @@ static switch_status call_info(char *callid, char *out, size_t outlen) tech_pvt = val; print_info(tech_pvt, out + strlen(out), outlen - strlen(out)); } - } else if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { + } else if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) { print_info(tech_pvt, out, outlen); } else { strncpy(out, "NO SUCH CALL", outlen - 1); diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index ec49b89b30..b590b14710 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -104,7 +104,7 @@ struct woomera_message { static struct { - int next_woomera_port; + switch_port_t next_woomera_port; int debug; int panic; int rtpmode; @@ -119,10 +119,9 @@ struct woomera_profile { switch_socket_t *woomera_socket; apr_thread_mutex_t *iolock; char woomera_host[WOOMERA_STRLEN]; - int woomera_port; + switch_port_t woomera_port; char audio_ip[WOOMERA_STRLEN]; char dialplan[WOOMERA_STRLEN]; -// pthread_t thread; unsigned int flags; int thread_running; struct woomera_event_queue event_queue; @@ -138,7 +137,7 @@ struct private_object { switch_pollfd_t read_poll; switch_pollfd_t write_poll; switch_pollfd_t command_poll; - unsigned char databuf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + char databuf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; switch_mutex_t *iolock; switch_sockaddr_t *udpread; switch_sockaddr_t *udpwrite; @@ -149,7 +148,7 @@ struct private_object { struct woomera_message call_info; struct woomera_profile *profile; char dest[WOOMERA_STRLEN]; - int port; + switch_port_t port; switch_time_t started; int timeout; char dtmfbuf[WOOMERA_STRLEN]; @@ -164,8 +163,6 @@ typedef struct woomera_event_queue woomera_event_queue; static woomera_profile default_profile; -static const switch_endpoint_interface woomerachan_endpoint_interface; - static switch_status woomerachan_on_init(switch_core_session *session); static switch_status woomerachan_on_hangup(switch_core_session *session); static switch_status woomerachan_on_ring(switch_core_session *session); @@ -351,56 +348,6 @@ static switch_status woomerachan_on_transmit(switch_core_session *session) return SWITCH_STATUS_SUCCESS; } - -/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines - that allocate memory or you will have 1 channel with memory allocated from another channel's pool! -*/ -static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, - switch_core_session **new_session) -{ - if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL))) { - struct private_object *tech_pvt; - switch_channel *channel; - - switch_core_session_add_stream(*new_session, NULL); - if ((tech_pvt = - (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) { - memset(tech_pvt, 0, sizeof(*tech_pvt)); - tech_pvt->profile = &default_profile; - channel = switch_core_session_get_channel(*new_session); - switch_core_session_set_private(*new_session, tech_pvt); - tech_pvt->session = *new_session; - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - if (outbound_profile) { - char name[128]; - switch_caller_profile *caller_profile; - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - snprintf(name, sizeof(name), "Woomera/%s-%04x", caller_profile->destination_number, rand() & 0xffff); - switch_channel_set_name(channel, name); - } else { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_STATUS_GENERR; - } - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_GENERR; - -} - static switch_status woomerachan_waitfor_read(switch_core_session *session, int ms, int stream_id) { struct private_object *tech_pvt = NULL; @@ -419,7 +366,7 @@ static switch_status woomerachan_waitfor_write(switch_core_session *session, int assert(tech_pvt != NULL); return SWITCH_STATUS_SUCCESS; - return switch_socket_waitfor(&tech_pvt->write_poll, ms); +// return switch_socket_waitfor(&tech_pvt->write_poll, ms); } static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, @@ -515,6 +462,55 @@ static const switch_loadable_module_interface woomerachan_module_interface = { }; +/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines + that allocate memory or you will have 1 channel with memory allocated from another channel's pool! +*/ +static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, + switch_core_session **new_session) +{ + if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL)) != 0) { + struct private_object *tech_pvt; + switch_channel *channel; + + switch_core_session_add_stream(*new_session, NULL); + if ((tech_pvt = + (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) { + memset(tech_pvt, 0, sizeof(*tech_pvt)); + tech_pvt->profile = &default_profile; + channel = switch_core_session_get_channel(*new_session); + switch_core_session_set_private(*new_session, tech_pvt); + tech_pvt->session = *new_session; + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + if (outbound_profile) { + char name[128]; + switch_caller_profile *caller_profile; + + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + snprintf(name, sizeof(name), "Woomera/%s-%04x", caller_profile->destination_number, rand() & 0xffff); + switch_channel_set_name(channel, name); + } else { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_STATUS_GENERR; + } + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_GENERR; + +} + static void tech_destroy(private_object * tech_pvt) { woomera_message wmsg; @@ -585,7 +581,7 @@ static int woomera_enqueue_event(woomera_event_queue * event_queue, woomera_mess { woomera_message *new, *mptr; - if ((new = malloc(sizeof(woomera_message)))) { + if ((new = malloc(sizeof(woomera_message))) != 0) { memcpy(new, wmsg, sizeof(woomera_message)); new->next = NULL; @@ -646,7 +642,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in ptr = buf; bytes = 0; - while (!(eor = strstr(buf, WOOMERA_RECORD_SEPERATOR))) { + while ((eor = strstr(buf, WOOMERA_RECORD_SEPERATOR)) == 0) { size_t len = 1; if (!profile->thread_running) { @@ -667,8 +663,8 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf); } - while ((cur = next)) { - if ((cr = strstr(cur, WOOMERA_LINE_SEPERATOR))) { + while ((cur = next) != 0) { + if ((cr = strstr(cur, WOOMERA_LINE_SEPERATOR)) != 0) { *cr = '\0'; next = cr + (sizeof(WOOMERA_LINE_SEPERATOR) - 1); if (!strcmp(next, WOOMERA_RECORD_SEPERATOR)) { @@ -686,13 +682,13 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in cur += 6; switch_set_flag(wmsg, WFLAG_EVENT); - if (cur && (cr = strchr(cur, ' '))) { + if (cur && (cr = strchr(cur, ' ')) != 0) { char *id; *cr = '\0'; cr++; id = cr; - if (cr && (cr = strchr(cr, ' '))) { + if (cr && (cr = strchr(cr, ' ')) != 0) { *cr = '\0'; cr++; strncpy(wmsg->command_args, cr, WOOMERA_STRLEN); @@ -702,7 +698,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in } } } else { - if (cur && (cur = strchr(cur, ' '))) { + if (cur && (cur = strchr(cur, ' ')) != 0) { *cur = '\0'; cur++; wmsg->mval = atoi(buf); @@ -720,7 +716,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in } else { char *name, *val; name = cur; - if ((val = strchr(name, ':'))) { + if ((val = strchr(name, ':')) != 0) { *val = '\0'; val++; while (*val == ' ') { @@ -1019,8 +1015,8 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) break; } /* Check for events */ - if ((res = woomera_dequeue_event(&tech_pvt->event_queue, &wmsg)) || - (res = woomera_message_parse(tech_pvt->command_channel, &wmsg, 100, tech_pvt->profile, NULL))) { + if ((res = woomera_dequeue_event(&tech_pvt->event_queue, &wmsg)) != 0 || + (res = woomera_message_parse(tech_pvt->command_channel, &wmsg, 100, tech_pvt->profile, NULL)) != 0) { if (res < 0 || !strcasecmp(wmsg.command, "HANGUP")) { switch_set_flag(tech_pvt, TFLAG_ABORT); @@ -1055,11 +1051,11 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) exten = "s"; } - if ((p = woomera_message_header(&wmsg, "Remote-Name"))) { + if ((p = woomera_message_header(&wmsg, "Remote-Name")) != 0) { strncpy(cid_name, p, sizeof(cid_name)); } - if ((cid_num = strchr(cid_name, '!'))) { + if ((cid_num = strchr(cid_name, '!')) != 0) { *cid_num = '\0'; cid_num++; } else { @@ -1069,7 +1065,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) if ((tech_pvt->caller_profile = switch_caller_profile_new(session, tech_pvt->profile->dialplan, - cid_name, cid_num, ip, NULL, NULL, exten))) { + cid_name, cid_num, ip, NULL, NULL, exten)) != 0) { char name[128]; switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, @@ -1099,16 +1095,16 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) } else if (!strcasecmp(wmsg.command, "MEDIA")) { char *raw_audio_header; - if ((raw_audio_header = woomera_message_header(&wmsg, "Raw-Audio"))) { + if ((raw_audio_header = woomera_message_header(&wmsg, "Raw-Audio")) != 0) { char ip[25]; char *ptr; - int port = 0; + switch_port_t port = 0; strncpy(ip, raw_audio_header, sizeof(ip) - 1); - if ((ptr = strchr(ip, '/'))) { + if ((ptr = strchr(ip, '/')) != 0) { *ptr = '\0'; ptr++; - port = atoi(ptr); + port = (switch_port_t)atoi(ptr); } /* Move Channel's State Machine to RING */ switch_channel_answer(channel); @@ -1192,10 +1188,10 @@ static void *woomera_thread_run(void *obj) continue; } - if ((res = woomera_dequeue_event(&profile->event_queue, &wmsg) || - (res = woomera_message_parse(profile->woomera_socket, &wmsg, + if ((((res = woomera_dequeue_event(&profile->event_queue, &wmsg)) != 0) || + ((res = woomera_message_parse(profile->woomera_socket, &wmsg, /* if we are not stingy with threads we can block forever */ - 0, profile, NULL)))) { + 0, profile, NULL))) != 0)) { if (res < 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! I lost my connection to woomera!\n", profile->name); @@ -1205,7 +1201,8 @@ static void *woomera_thread_run(void *obj) globals.panic = 1; continue; - if (profile->woomera_socket) { + /* Can't get to the following code --Commented out for now.*/ +/* if (profile->woomera_socket) if (switch_test_flag(profile, PFLAG_INBOUND)) { woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR); if (woomera_message_parse(profile->woomera_socket, @@ -1220,7 +1217,7 @@ static void *woomera_thread_run(void *obj) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Woomera Thread Up {%s} %s/%d\n", profile->name, profile->woomera_host, profile->woomera_port); } - } + }*/ continue; } @@ -1228,19 +1225,19 @@ static void *woomera_thread_run(void *obj) char *name; switch_core_session *session; - if (!(name = woomera_message_header(&wmsg, "Remote-Address"))) { + if ((name = woomera_message_header(&wmsg, "Remote-Address")) == 0) { name = woomera_message_header(&wmsg, "Channel-Name"); } switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n", name); - if ((session = switch_core_session_request(&woomerachan_endpoint_interface, NULL))) { + if ((session = switch_core_session_request(&woomerachan_endpoint_interface, NULL)) != 0) { struct private_object *tech_pvt; switch_channel *channel; switch_core_session_add_stream(session, NULL); if ((tech_pvt = - (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) { + (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) { memset(tech_pvt, 0, sizeof(*tech_pvt)); tech_pvt->profile = &default_profile; channel = switch_core_session_get_channel(session); @@ -1331,7 +1328,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul } else if (!strcmp(var, "host")) { strncpy(profile->woomera_host, val, sizeof(profile->woomera_host) - 1); } else if (!strcmp(var, "port")) { - profile->woomera_port = atoi(val); + profile->woomera_port = (switch_port_t)atoi(val); } else if (!strcmp(var, "disabled")) { if (atoi(val) > 0) { switch_set_flag(profile, PFLAG_DISABLED); diff --git a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c index 58f3d24314..f33a3fc9f2 100644 --- a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c +++ b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c @@ -37,7 +37,7 @@ static switch_memory_pool *module_pool; static struct { char *address; - int port; + switch_port_t port; switch_sockaddr_t *addr; switch_socket_t *udp_socket; int running; @@ -70,7 +70,7 @@ static switch_status load_config(void) if (!strcasecmp(var, "address")) { set_global_address(val); } else if (!strcasecmp(var, "port")) { - globals.port = atoi(val); + globals.port = (switch_port_t)atoi(val); } } } @@ -205,13 +205,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes"); var = buf; while(*var) { - if ((val = strchr(var, ':'))) { + if ((val = strchr(var, ':')) != 0) { char varname[512]; *val++ = '\0'; while(*val == ' ') { val++; } - if ((term = strchr(val, '\r')) || (term=strchr(val, '\n'))) { + if ((term = strchr(val, '\r')) != 0 || (term=strchr(val, '\n')) != 0) { *term = '\0'; while(*term == '\r' || *term == '\n') { term++; diff --git a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c index e5bbebd9a8..4dc52b3dc8 100644 --- a/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c +++ b/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c @@ -223,13 +223,13 @@ int on_msg(void *user_data, ikspak * pak) char retbuf[1024] = ""; char *p; - if ((p = strchr(cmd, '\r'))) { + if ((p = strchr(cmd, '\r')) != 0) { *p++ = '\0'; - } else if ((p = strchr(cmd, '\n'))) { + } else if ((p = strchr(cmd, '\n')) != 0) { *p++ = '\0'; } - if ((arg = strchr(cmd, ' '))) { + if ((arg = strchr(cmd, ' ')) != 0) { *arg++ = '\0'; } diff --git a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c index d2b13dbecf..c4fd74bd89 100644 --- a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c +++ b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c @@ -135,9 +135,9 @@ static void event_handler(switch_event *event) switch_event_header *hp; char *service = switch_event_get_header(event, "service"); char *port = switch_event_get_header(event, "port"); - int porti = 0; + sw_port porti = 0; for (hp = event->headers; hp; hp = hp->next) { - int len = strlen(hp->name) + strlen(hp->value) + 2; + size_t len = strlen(hp->name) + strlen(hp->value) + 2; char *data = malloc(len); if (!data) { @@ -156,7 +156,7 @@ static void event_handler(switch_event *event) service = "_freeswitch._tcp"; } if (port) { - porti = atoi(port); + porti = (sw_port)atoi(port); } switch_mutex_lock(globals.zc_lock); @@ -208,7 +208,7 @@ static switch_status load_config(void) while (switch_config_next_pair(&cfg, &var, &val)) { if (!strcasecmp(cfg.category, "settings")) { if (!strcmp(var, "browse")) { - if ((oid = switch_core_alloc(module_pool, sizeof(*oid)))) { + if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bind browser to to %s\n", val); switch_mutex_lock(globals.zc_lock); sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid); @@ -308,7 +308,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) RUNNING = 1; while(RUNNING == 1) { - unsigned int ms; + sw_uint32 ms; ms = 100; sw_discovery_step(globals.discovery, &ms); switch_yield(1000); diff --git a/src/switch_core.c b/src/switch_core.c index 51c8a68b6d..5c2bf0313d 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -425,14 +425,14 @@ SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void { assert(fh != NULL); - return fh->file_interface->file_read(fh, data, (unsigned int *) len); + return fh->file_interface->file_read(fh, data, len); } SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len) { assert(fh != NULL); - return fh->file_interface->file_write(fh, data, (unsigned int *) len); + return fh->file_interface->file_write(fh, data, len); } SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples,