From e85eefe7f2d89f40ed33ef6c3a27088413affc01 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 8 Dec 2005 18:31:49 +0000 Subject: [PATCH] let modules see the filename they were called as git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@94 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/mod_bridgecall/mod_bridgecall.c | 2 +- src/mod/mod_dialplan_demo/mod_dialplan_demo.c | 2 +- src/mod/mod_exosip/mod_exosip.c | 2 +- src/mod/mod_exosip/mod_exosip_ccrtp.c | 2 +- src/mod/mod_exosip/mod_exosip_ucl.c | 2 +- src/mod/mod_g711codec/mod_g711codec.c | 2 +- src/mod/mod_iaxchan/mod_iaxchan.c | 20 ++++++++++--------- src/mod/mod_opalchan/mod_opalchan.c | 2 +- src/mod/mod_playback/mod_playback.c | 2 +- src/mod/mod_rawaudio/mod_rawaudio.c | 2 +- src/mod/mod_skel/mod_skel.c | 2 +- src/mod/mod_softtimer/mod_softtimer.c | 2 +- src/mod/mod_speexcodec/mod_speexcodec.c | 2 +- src/mod/mod_wanchan/mod_wanchan.c | 2 +- src/mod/mod_woomerachan/mod_woomerachan.c | 2 +- src/switch_loadable_module.c | 8 ++++---- 16 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/mod/mod_bridgecall/mod_bridgecall.c b/src/mod/mod_bridgecall/mod_bridgecall.c index 3cb8faec85..2ea72d50dd 100644 --- a/src/mod/mod_bridgecall/mod_bridgecall.c +++ b/src/mod/mod_bridgecall/mod_bridgecall.c @@ -258,7 +258,7 @@ static const switch_loadable_module_interface mod_bridgecall_module_interface = /*.application_interface*/ &bridge_application_interface }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &mod_bridgecall_module_interface; diff --git a/src/mod/mod_dialplan_demo/mod_dialplan_demo.c b/src/mod/mod_dialplan_demo/mod_dialplan_demo.c index 2cd50132e0..27742716f2 100644 --- a/src/mod/mod_dialplan_demo/mod_dialplan_demo.c +++ b/src/mod/mod_dialplan_demo/mod_dialplan_demo.c @@ -114,7 +114,7 @@ static const switch_loadable_module_interface demo_dialplan_module_interface = { /*.application_interface =*/ NULL }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &demo_dialplan_module_interface; diff --git a/src/mod/mod_exosip/mod_exosip.c b/src/mod/mod_exosip/mod_exosip.c index 128fb38130..07bda55065 100644 --- a/src/mod/mod_exosip/mod_exosip.c +++ b/src/mod/mod_exosip/mod_exosip.c @@ -754,7 +754,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) return SWITCH_STATUS_SUCCESS; } -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */ if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/mod_exosip/mod_exosip_ccrtp.c b/src/mod/mod_exosip/mod_exosip_ccrtp.c index 00dad1cda4..4d895ca0fc 100644 --- a/src/mod/mod_exosip/mod_exosip_ccrtp.c +++ b/src/mod/mod_exosip/mod_exosip_ccrtp.c @@ -738,7 +738,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) return SWITCH_STATUS_SUCCESS; } -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */ if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/mod_exosip/mod_exosip_ucl.c b/src/mod/mod_exosip/mod_exosip_ucl.c index 567a94bdbe..54c3b0364c 100644 --- a/src/mod/mod_exosip/mod_exosip_ucl.c +++ b/src/mod/mod_exosip/mod_exosip_ucl.c @@ -805,7 +805,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) return SWITCH_STATUS_SUCCESS; } -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **_interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **_interface, char *filename) { /* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */ if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/mod_g711codec/mod_g711codec.c b/src/mod/mod_g711codec/mod_g711codec.c index c9fca24574..5ce8d8000a 100644 --- a/src/mod/mod_g711codec/mod_g711codec.c +++ b/src/mod/mod_g711codec/mod_g711codec.c @@ -281,7 +281,7 @@ static switch_loadable_module_interface g711_module_interface = { }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &g711_module_interface; diff --git a/src/mod/mod_iaxchan/mod_iaxchan.c b/src/mod/mod_iaxchan/mod_iaxchan.c index b2a598f640..2a64a386a0 100644 --- a/src/mod/mod_iaxchan/mod_iaxchan.c +++ b/src/mod/mod_iaxchan/mod_iaxchan.c @@ -710,7 +710,7 @@ static const switch_loadable_module_interface channel_module_interface = { }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n"); @@ -785,8 +785,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) int netfd; int refresh; struct iax_event *iaxevent = 0; - struct private_object *tech_pvt = NULL; - + load_config(); if ((res = iax_init(globals.port) < 0)) { @@ -810,6 +809,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) if (!(iaxevent = iax_get_event(0))) { switch_yield(100); } else { + struct private_object *tech_pvt = iax_get_private(iaxevent->session); + if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Event %d [%s]!\n", iaxevent->etype, IAXNAMES[iaxevent->etype]); @@ -825,7 +826,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) case IAX_EVENT_TIMEOUT: break; case IAX_EVENT_ACCEPT: - if ((tech_pvt = iax_get_private(iaxevent->session))) { + if (tech_pvt) { unsigned int cap = iax_session_get_capability(iaxevent->session); unsigned int format = iaxevent->ies.format; @@ -845,7 +846,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) break; case IAX_EVENT_ANSWER: // the other side answered our call - if ((tech_pvt = iax_get_private(iaxevent->session))) { + if (tech_pvt) { switch_channel *channel; if ((channel = switch_core_session_get_channel(tech_pvt->session))) { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n", switch_channel_get_name(channel)); @@ -916,7 +917,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) break; case IAX_EVENT_BUSY: case IAX_EVENT_HANGUP: - if ((tech_pvt = iax_get_private(iaxevent->session))) { + if (tech_pvt) { switch_channel *channel; switch_clear_flag(tech_pvt, TFLAG_IO); @@ -937,8 +938,7 @@ 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 = iax_get_private(iaxevent->session)) && - (tech_pvt->read_frame.datalen = iaxevent->datalen)) { + if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) { memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen); @@ -955,7 +955,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n"); break; case IAX_EVENT_DTMF: - if ((tech_pvt = iax_get_private(iaxevent->session))) { + if (tech_pvt) { switch_channel *channel; if ((channel = switch_core_session_get_channel(tech_pvt->session))) { char str[2] = {iaxevent->subclass}; @@ -989,6 +989,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) running = -1; + iax_shutdown(); + while (running) { if (x++ > 1000) { break; diff --git a/src/mod/mod_opalchan/mod_opalchan.c b/src/mod/mod_opalchan/mod_opalchan.c index 33e889db46..8aae7ecb7d 100644 --- a/src/mod/mod_opalchan/mod_opalchan.c +++ b/src/mod/mod_opalchan/mod_opalchan.c @@ -337,7 +337,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) } */ -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { switch_config cfg; char *var, *val; diff --git a/src/mod/mod_playback/mod_playback.c b/src/mod/mod_playback/mod_playback.c index 4f2f83d1d9..b5220043e8 100644 --- a/src/mod/mod_playback/mod_playback.c +++ b/src/mod/mod_playback/mod_playback.c @@ -160,7 +160,7 @@ static const switch_loadable_module_interface mod_playback_module_interface = { /*.application_interface*/ &playback_application_interface }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &mod_playback_module_interface; diff --git a/src/mod/mod_rawaudio/mod_rawaudio.c b/src/mod/mod_rawaudio/mod_rawaudio.c index fa9e5cb2df..13bf549eeb 100644 --- a/src/mod/mod_rawaudio/mod_rawaudio.c +++ b/src/mod/mod_rawaudio/mod_rawaudio.c @@ -171,7 +171,7 @@ static switch_loadable_module_interface raw_module_interface = { }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &raw_module_interface; diff --git a/src/mod/mod_skel/mod_skel.c b/src/mod/mod_skel/mod_skel.c index 289d07215f..21126d1f3e 100644 --- a/src/mod/mod_skel/mod_skel.c +++ b/src/mod/mod_skel/mod_skel.c @@ -42,7 +42,7 @@ static switch_loadable_module_interface skel_module_interface = { /*.application_interface*/ NULL }; -switch_status switch_module_load(switch_loadable_module_interface **interface) { +switch_status switch_module_load(switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &skel_module_interface; diff --git a/src/mod/mod_softtimer/mod_softtimer.c b/src/mod/mod_softtimer/mod_softtimer.c index d63ab444a2..c379436ab3 100644 --- a/src/mod/mod_softtimer/mod_softtimer.c +++ b/src/mod/mod_softtimer/mod_softtimer.c @@ -113,7 +113,7 @@ static const switch_loadable_module_interface mod_timers_module_interface = { /*.switch_application_interface*/ NULL }; -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &mod_timers_module_interface; diff --git a/src/mod/mod_speexcodec/mod_speexcodec.c b/src/mod/mod_speexcodec/mod_speexcodec.c index 71439ef319..28e2ab9d50 100644 --- a/src/mod/mod_speexcodec/mod_speexcodec.c +++ b/src/mod/mod_speexcodec/mod_speexcodec.c @@ -329,7 +329,7 @@ static switch_loadable_module_interface speex_module_interface = { /*.application_interface*/ NULL }; -switch_status switch_module_load(switch_loadable_module_interface **interface) { +switch_status switch_module_load(switch_loadable_module_interface **interface, char *filename) { /* connect my internal structure to the blank pointer passed to me */ *interface = &speex_module_interface; diff --git a/src/mod/mod_wanchan/mod_wanchan.c b/src/mod/mod_wanchan/mod_wanchan.c index a034b147d4..3fd8080084 100644 --- a/src/mod/mod_wanchan/mod_wanchan.c +++ b/src/mod/mod_wanchan/mod_wanchan.c @@ -385,7 +385,7 @@ static const switch_loadable_module_interface wanchan_module_interface = { /*.application_interface*/ NULL }; -Public switch_status switch_module_load(const switch_loadable_module_interface **interface) { +Public switch_status switch_module_load(const switch_loadable_module_interface **interface, chanr *filename) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/mod_woomerachan/mod_woomerachan.c b/src/mod/mod_woomerachan/mod_woomerachan.c index c4d029b98c..0985162ea2 100644 --- a/src/mod/mod_woomerachan/mod_woomerachan.c +++ b/src/mod/mod_woomerachan/mod_woomerachan.c @@ -1304,7 +1304,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) return SWITCH_STATUS_SUCCESS; } -SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) { +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) { switch_config cfg; char *var, *val; diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 1d0ea912c6..a8e473dea2 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -43,7 +43,7 @@ struct switch_loadable_module { char *filename; const switch_loadable_module_interface *interface; void *lib; - switch_status (*switch_module_load) (switch_loadable_module_interface **); + switch_status (*switch_module_load) (switch_loadable_module_interface **, char *); switch_status (*switch_module_reload) (void); switch_status (*switch_module_pause) (void); switch_status (*switch_module_resume) (void); @@ -87,7 +87,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem apr_dso_handle_t *dso = NULL; apr_status_t status; apr_dso_handle_sym_t function_handle = NULL; - switch_status (*load_func_ptr) (switch_loadable_module_interface **) = NULL; + switch_status (*load_func_ptr) (switch_loadable_module_interface **, char *) = NULL; int loading = 1; const char *err = NULL; switch_loadable_module_interface *interface = NULL; @@ -113,7 +113,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem break; } - if (load_func_ptr(&interface) != SWITCH_STATUS_SUCCESS) { + if (load_func_ptr(&interface, filename) != SWITCH_STATUS_SUCCESS) { err = "Module load routine returned an error"; interface = NULL; break; @@ -243,7 +243,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init() (void *) ptr); } } - + if (new_module->interface->codec_interface) { const switch_codec_implementation *impl; const switch_codec_interface *ptr;