提交 e85eefe7 authored 作者: Anthony Minessale's avatar Anthony Minessale

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
上级 e6cdee48
...@@ -258,7 +258,7 @@ static const switch_loadable_module_interface mod_bridgecall_module_interface = ...@@ -258,7 +258,7 @@ static const switch_loadable_module_interface mod_bridgecall_module_interface =
/*.application_interface*/ &bridge_application_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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &mod_bridgecall_module_interface; *interface = &mod_bridgecall_module_interface;
......
...@@ -114,7 +114,7 @@ static const switch_loadable_module_interface demo_dialplan_module_interface = { ...@@ -114,7 +114,7 @@ static const switch_loadable_module_interface demo_dialplan_module_interface = {
/*.application_interface =*/ NULL /*.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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &demo_dialplan_module_interface; *interface = &demo_dialplan_module_interface;
......
...@@ -754,7 +754,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -754,7 +754,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
return SWITCH_STATUS_SUCCESS; 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 */ /* 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) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
......
...@@ -738,7 +738,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -738,7 +738,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
return SWITCH_STATUS_SUCCESS; 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 */ /* 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) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
......
...@@ -805,7 +805,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -805,7 +805,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
return SWITCH_STATUS_SUCCESS; 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 */ /* 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) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
......
...@@ -281,7 +281,7 @@ static switch_loadable_module_interface g711_module_interface = { ...@@ -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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &g711_module_interface; *interface = &g711_module_interface;
......
...@@ -710,7 +710,7 @@ static const switch_loadable_module_interface channel_module_interface = { ...@@ -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) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
...@@ -785,7 +785,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -785,7 +785,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
int netfd; int netfd;
int refresh; int refresh;
struct iax_event *iaxevent = 0; struct iax_event *iaxevent = 0;
struct private_object *tech_pvt = NULL;
load_config(); load_config();
...@@ -810,6 +809,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -810,6 +809,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
if (!(iaxevent = iax_get_event(0))) { if (!(iaxevent = iax_get_event(0))) {
switch_yield(100); switch_yield(100);
} else { } else {
struct private_object *tech_pvt = iax_get_private(iaxevent->session);
if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) { if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Event %d [%s]!\n", switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Event %d [%s]!\n",
iaxevent->etype, IAXNAMES[iaxevent->etype]); iaxevent->etype, IAXNAMES[iaxevent->etype]);
...@@ -825,7 +826,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -825,7 +826,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
case IAX_EVENT_TIMEOUT: case IAX_EVENT_TIMEOUT:
break; break;
case IAX_EVENT_ACCEPT: 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 cap = iax_session_get_capability(iaxevent->session);
unsigned int format = iaxevent->ies.format; unsigned int format = iaxevent->ies.format;
...@@ -845,7 +846,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -845,7 +846,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
break; break;
case IAX_EVENT_ANSWER: case IAX_EVENT_ANSWER:
// the other side answered our call // the other side answered our call
if ((tech_pvt = iax_get_private(iaxevent->session))) { if (tech_pvt) {
switch_channel *channel; switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) { if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n", switch_channel_get_name(channel)); 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) ...@@ -916,7 +917,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
break; break;
case IAX_EVENT_BUSY: case IAX_EVENT_BUSY:
case IAX_EVENT_HANGUP: case IAX_EVENT_HANGUP:
if ((tech_pvt = iax_get_private(iaxevent->session))) { if (tech_pvt) {
switch_channel *channel; switch_channel *channel;
switch_clear_flag(tech_pvt, TFLAG_IO); switch_clear_flag(tech_pvt, TFLAG_IO);
...@@ -937,8 +938,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -937,8 +938,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sending silence\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sending silence\n");
break; break;
case IAX_EVENT_VOICE: case IAX_EVENT_VOICE:
if ((tech_pvt = iax_get_private(iaxevent->session)) && if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) {
(tech_pvt->read_frame.datalen = iaxevent->datalen)) {
memcpy(tech_pvt->read_frame.data, iaxevent->data, 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) ...@@ -955,7 +955,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n");
break; break;
case IAX_EVENT_DTMF: case IAX_EVENT_DTMF:
if ((tech_pvt = iax_get_private(iaxevent->session))) { if (tech_pvt) {
switch_channel *channel; switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) { if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
char str[2] = {iaxevent->subclass}; char str[2] = {iaxevent->subclass};
...@@ -989,6 +989,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -989,6 +989,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
running = -1; running = -1;
iax_shutdown();
while (running) { while (running) {
if (x++ > 1000) { if (x++ > 1000) {
break; break;
......
...@@ -337,7 +337,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -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; switch_config cfg;
char *var, *val; char *var, *val;
......
...@@ -160,7 +160,7 @@ static const switch_loadable_module_interface mod_playback_module_interface = { ...@@ -160,7 +160,7 @@ static const switch_loadable_module_interface mod_playback_module_interface = {
/*.application_interface*/ &playback_application_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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &mod_playback_module_interface; *interface = &mod_playback_module_interface;
......
...@@ -171,7 +171,7 @@ static switch_loadable_module_interface raw_module_interface = { ...@@ -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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &raw_module_interface; *interface = &raw_module_interface;
......
...@@ -42,7 +42,7 @@ static switch_loadable_module_interface skel_module_interface = { ...@@ -42,7 +42,7 @@ static switch_loadable_module_interface skel_module_interface = {
/*.application_interface*/ NULL /*.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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &skel_module_interface; *interface = &skel_module_interface;
......
...@@ -113,7 +113,7 @@ static const switch_loadable_module_interface mod_timers_module_interface = { ...@@ -113,7 +113,7 @@ static const switch_loadable_module_interface mod_timers_module_interface = {
/*.switch_application_interface*/ NULL /*.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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &mod_timers_module_interface; *interface = &mod_timers_module_interface;
......
...@@ -329,7 +329,7 @@ static switch_loadable_module_interface speex_module_interface = { ...@@ -329,7 +329,7 @@ static switch_loadable_module_interface speex_module_interface = {
/*.application_interface*/ NULL /*.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 */ /* connect my internal structure to the blank pointer passed to me */
*interface = &speex_module_interface; *interface = &speex_module_interface;
......
...@@ -385,7 +385,7 @@ static const switch_loadable_module_interface wanchan_module_interface = { ...@@ -385,7 +385,7 @@ static const switch_loadable_module_interface wanchan_module_interface = {
/*.application_interface*/ NULL /*.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) { if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
......
...@@ -1304,7 +1304,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) ...@@ -1304,7 +1304,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
return SWITCH_STATUS_SUCCESS; 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; switch_config cfg;
char *var, *val; char *var, *val;
......
...@@ -43,7 +43,7 @@ struct switch_loadable_module { ...@@ -43,7 +43,7 @@ struct switch_loadable_module {
char *filename; char *filename;
const switch_loadable_module_interface *interface; const switch_loadable_module_interface *interface;
void *lib; 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_reload) (void);
switch_status (*switch_module_pause) (void); switch_status (*switch_module_pause) (void);
switch_status (*switch_module_resume) (void); switch_status (*switch_module_resume) (void);
...@@ -87,7 +87,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem ...@@ -87,7 +87,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem
apr_dso_handle_t *dso = NULL; apr_dso_handle_t *dso = NULL;
apr_status_t status; apr_status_t status;
apr_dso_handle_sym_t function_handle = NULL; 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; int loading = 1;
const char *err = NULL; const char *err = NULL;
switch_loadable_module_interface *interface = NULL; switch_loadable_module_interface *interface = NULL;
...@@ -113,7 +113,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem ...@@ -113,7 +113,7 @@ static switch_status switch_loadable_module_load_file(char *filename, switch_mem
break; 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"; err = "Module load routine returned an error";
interface = NULL; interface = NULL;
break; break;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论