diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index e957dde468..e010461135 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -267,7 +267,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); #define SWITCH_ADD_API(api_int, int_name, descript, funcptr, syntax_string) \ for (;;) { \ - api_int = switch_loadable_module_create_interface(*module_interface, SWITCH_API_INTERFACE); \ + api_int = (switch_api_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_API_INTERFACE); \ api_int->interface_name = int_name; \ api_int->desc = descript; \ api_int->function = funcptr; \ @@ -277,7 +277,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); #define SWITCH_ADD_CHAT(chat_int, int_name, funcptr) \ for (;;) { \ - chat_int = switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \ + chat_int = (switch_chat_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \ chat_int->chat_send = funcptr; \ chat_int->interface_name = int_name; \ break; \ @@ -285,7 +285,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); #define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \ for (;;) { \ - app_int = switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \ + app_int = (switch_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \ app_int->interface_name = int_name; \ app_int->application_function = funcptr; \ app_int->short_desc = short_descript; \ @@ -297,7 +297,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); #define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \ for (;;) { \ - dp_int = switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \ + dp_int = (switch_dialplan_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \ dp_int->hunt_function = funcptr; \ dp_int->interface_name = int_name; \ break; \ diff --git a/src/mod/event_handlers/mod_cdr/mod_cdr.cpp b/src/mod/event_handlers/mod_cdr/mod_cdr.cpp index 090ee4705a..80767f0b40 100644 --- a/src/mod/event_handlers/mod_cdr/mod_cdr.cpp +++ b/src/mod/event_handlers/mod_cdr/mod_cdr.cpp @@ -68,56 +68,6 @@ static const switch_state_handler_table_t state_handlers = { /*.on_transmit */ NULL }; -static switch_api_interface_t modcdr_show_available_api = { - /*.interface_name */ "modcdr_show_available", - /*.desc */ "Displays the currently compiled-in mod_cdr backend loggers.", - /*.function */ modcdr_show_available, - /*.syntax */ "modcdr_queue_show_available", - /*.next */ 0 -}; - -static switch_api_interface_t modcdr_show_active_api = { - /*.interface_name */ "modcdr_show_active", - /*.desc */ "Displays the currently active mod_cdr backend loggers.", - /*.function */ modcdr_show_active, - /*.syntax */ "modcdr_queue_show_active", - /*.next */ &modcdr_show_available_api -}; - -static switch_api_interface_t modcdr_queue_resume_api = { - /*.interface_name */ "modcdr_queue_resume", - /*.desc */ "Manually resumes the popping of objects from the queue.", - /*.function */ modcdr_queue_resume, - /*.syntax */ "modcdr_queue_resume", - /*.next */ &modcdr_show_active_api -}; - -static switch_api_interface_t modcdr_queue_pause_api = { - /*.interface_name */ "modcdr_queue_pause", - /*.desc */ "Manually pauses the popping of objects from the queue. (DANGER: Can suck your memory away rather quickly.)", - /*.function */ modcdr_queue_pause, - /*.syntax */ "modcdr_queue_pause", - /*.next */ &modcdr_queue_resume_api -}; - -static switch_api_interface_t modcdr_reload_interface_api = { - /*.interface_name */ "modcdr_reload", - /*.desc */ "Reload mod_cdr's configuration", - /*.function */ modcdr_reload, - /*.syntax */ "modcdr_reload", - /*.next */ &modcdr_queue_pause_api -}; - -static switch_loadable_module_interface_t cdr_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /* api_interface */ &modcdr_reload_interface_api -}; - static switch_status_t my_on_hangup(switch_core_session_t *session) { switch_thread_rwlock_rdlock(cdr_rwlock); @@ -126,18 +76,25 @@ static switch_status_t my_on_hangup(switch_core_session_t *session) return SWITCH_STATUS_SUCCESS; } +#define AVAIL_DESCR "Displays the currently compiled-in mod_cdr backend loggers." +#define ACTIVE_DESCR "Displays the currently active mod_cdr backend loggers." +#define RESUME_DESCR "Manually resumes the popping of objects from the queue." +#define PAUSE_DESCR "Manually pauses the popping of objects from the queue. (DANGER: Can suck your memory away rather quickly.)" SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_load) { + switch_api_interface_t *api_interface; + /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &cdr_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_API(api_interface, "modcdr_reload", "Reload mod_cdr's configuration", modcdr_reload, ""); + SWITCH_ADD_API(api_interface, "modcdr_queue_pause", PAUSE_DESCR, modcdr_queue_pause, ""); + SWITCH_ADD_API(api_interface, "modcdr_queue_resume", RESUME_DESCR, modcdr_queue_resume, ""); + SWITCH_ADD_API(api_interface, "modcdr_show_active", ACTIVE_DESCR, modcdr_show_active, ""); + SWITCH_ADD_API(api_interface, "modcdr_show_available", AVAIL_DESCR, modcdr_show_available, ""); switch_core_add_state_handler(&state_handlers); - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH - Can't swim, no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; switch_thread_rwlock_create(&cdr_rwlock,module_pool); newcdrcontainer = new CDRContainer(module_pool); // Instantiates the new object, automatically loads config 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 7fce2a0a86..da85092f19 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 @@ -176,25 +176,12 @@ static void event_handler(switch_event_t *event) } -static switch_loadable_module_interface_t event_test_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL -}; - - SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load) { memset(&globals, 0, sizeof(globals)); - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; switch_core_hash_init(&globals.event_hash, module_pool); @@ -231,10 +218,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load) return SWITCH_STATUS_TERM; } - - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &event_test_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index d8d067f5b9..5eefb40317 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -161,7 +161,7 @@ static void event_handler(switch_event_t *event) switch_mutex_unlock(listen_list.mutex); } -static void socket_function(switch_core_session_t *session, char *data) +SWITCH_STANDARD_APP(socket_function) { char *host, *port_name; switch_socket_t *new_sock; @@ -251,28 +251,6 @@ static void socket_function(switch_core_session_t *session, char *data) } -static switch_application_interface_t socket_application_interface = { - /*.interface_name */ "socket", - /*.application_function */ socket_function, - /* long_desc */ "Connect to a socket", - /* short_desc */ "Connect to a socket", - /* syntax */ "[:]", - /* flags */ SAF_SUPPORT_NOMEDIA, - /*.next */ NULL -}; - - - -static switch_loadable_module_interface_t event_socket_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ &socket_application_interface -}; - - static void close_socket(switch_socket_t ** sock) { switch_mutex_lock(listen_list.sock_mutex); @@ -303,11 +281,13 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown) return SWITCH_STATUS_SUCCESS; } - SWITCH_MODULE_LOAD_FUNCTION(mod_event_socket_load) { + switch_application_interface_t *app_interface; + /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &event_socket_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_APP(app_interface, "socket", "Connect to a socket", "Connect to a socket", socket_function, "[:]", SAF_SUPPORT_NOMEDIA); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/event_handlers/mod_event_test/mod_event_test.c b/src/mod/event_handlers/mod_event_test/mod_event_test.c index 98b502d060..10ca5bd7f0 100644 --- a/src/mod/event_handlers/mod_event_test/mod_event_test.c +++ b/src/mod/event_handlers/mod_event_test/mod_event_test.c @@ -71,20 +71,8 @@ static void event_handler(switch_event_t *event) } } - - -static switch_loadable_module_interface_t event_test_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL -}; - #define MY_EVENT_COOL "test::cool" - #ifdef TORTURE_ME #define TTHREADS 500 static int THREADS = 0; @@ -128,14 +116,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void) SWITCH_MODULE_LOAD_FUNCTION(mod_event_test_load) { /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &event_test_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); if (switch_event_reserve_subclass(MY_EVENT_COOL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } 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 b83d56b698..0825aed093 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 @@ -391,19 +391,10 @@ static void xmpp_connect(char *jabber_id, char *pass) } -static switch_loadable_module_interface_t xmpp_event_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_xmpp_event_load) { /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &xmpp_event_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); if (load_config() != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; diff --git a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c index 3f12329f8e..53ee24da93 100644 --- a/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c +++ b/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c @@ -237,16 +237,6 @@ static switch_status_t load_config(void) } - -static switch_loadable_module_interface_t zeroconf_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL -}; - #define MY_EVENT_PUBLISH "zeroconf::broadcast" #define MY_EVENT_UNPUBLISH "zeroconf::unbroadcast" @@ -266,10 +256,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_zeroconf_load) memset(&globals, 0, sizeof(globals)); - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; switch_mutex_init(&globals.zc_lock, SWITCH_MUTEX_NESTED, module_pool); @@ -293,7 +280,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_zeroconf_load) } /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &zeroconf_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/formats/mod_native_file/mod_native_file.c b/src/mod/formats/mod_native_file/mod_native_file.c index b48e013e67..db22600e4f 100644 --- a/src/mod/formats/mod_native_file/mod_native_file.c +++ b/src/mod/formats/mod_native_file/mod_native_file.c @@ -138,34 +138,10 @@ static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, static char *supported_formats[SWITCH_MAX_CODECS] = { 0 }; -static switch_file_interface_t native_file_file_interface = { - /*.interface_name */ modname, - /*.file_open */ native_file_file_open, - /*.file_close */ native_file_file_close, - /*.file_read */ native_file_file_read, - /*.file_write */ native_file_file_write, - /*.file_seek */ native_file_file_seek, - /*.file_set_string */ native_file_file_set_string, - /*.file_get_string */ native_file_file_get_string, - /*.extens */ NULL, - /*.next */ NULL, -}; - -static switch_loadable_module_interface_t native_file_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ &native_file_file_interface -}; - - SWITCH_MODULE_LOAD_FUNCTION(mod_native_file_load) { + switch_file_interface_t *file_interface; const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS]; uint32_t num_codecs = switch_loadable_module_get_codecs(NULL, codecs, sizeof(codecs) / sizeof(codecs[0])); @@ -175,9 +151,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_native_file_load) supported_formats[x] = codecs[x]->iananame; } - /* connect my internal structure to the blank pointer passed to me */ - native_file_file_interface.extens = supported_formats; - *module_interface = &native_file_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); + file_interface->interface_name = modname; + file_interface->extens = supported_formats; + file_interface->file_open = native_file_file_open; + file_interface->file_close = native_file_file_close; + file_interface->file_read = native_file_file_read; + file_interface->file_write = native_file_file_write; + file_interface->file_seek = native_file_file_seek; + file_interface->file_set_string = native_file_file_set_string; + file_interface->file_get_string = native_file_file_get_string; /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/formats/mod_sndfile/mod_sndfile.c b/src/mod/formats/mod_sndfile/mod_sndfile.c index 52978985e2..79094dbeda 100644 --- a/src/mod/formats/mod_sndfile/mod_sndfile.c +++ b/src/mod/formats/mod_sndfile/mod_sndfile.c @@ -253,30 +253,6 @@ static switch_status_t sndfile_file_get_string(switch_file_handle_t *handle, swi static char **supported_formats; -static switch_file_interface_t sndfile_file_interface = { - /*.interface_name */ modname, - /*.file_open */ sndfile_file_open, - /*.file_close */ sndfile_file_close, - /*.file_read */ sndfile_file_read, - /*.file_write */ sndfile_file_write, - /*.file_seek */ sndfile_file_seek, - /*.file_set_string */ sndfile_file_set_string, - /*.file_get_string */ sndfile_file_get_string, - /*.extens */ NULL, - /*.next */ NULL, -}; - -static switch_loadable_module_interface_t sndfile_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ &sndfile_file_interface -}; - static switch_status_t setup_formats(void) { SF_FORMAT_INFO info; @@ -364,6 +340,7 @@ static switch_status_t setup_formats(void) SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load) { + switch_file_interface_t *file_interface; if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); @@ -377,8 +354,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load) } /* connect my internal structure to the blank pointer passed to me */ - sndfile_file_interface.extens = supported_formats; - *module_interface = &sndfile_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); + file_interface->interface_name = modname; + file_interface->extens = supported_formats; + file_interface->file_open = sndfile_file_open; + file_interface->file_close = sndfile_file_close; + file_interface->file_read = sndfile_file_read; + file_interface->file_write = sndfile_file_write; + file_interface->file_seek = sndfile_file_seek; + file_interface->file_set_string = sndfile_file_set_string; + file_interface->file_get_string = sndfile_file_get_string; /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/loggers/mod_console/mod_console.c b/src/mod/loggers/mod_console/mod_console.c index 0b69aec025..0af0157315 100644 --- a/src/mod/loggers/mod_console/mod_console.c +++ b/src/mod/loggers/mod_console/mod_console.c @@ -56,19 +56,6 @@ static const char *COLORS[] = { SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRE }; #endif -static switch_loadable_module_interface_t console_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL -}; - static switch_memory_pool_t *module_pool = NULL; static switch_hash_t *log_hash = NULL; static switch_hash_t *name_hash = NULL; @@ -192,14 +179,10 @@ static switch_status_t switch_console_logger(const switch_log_node_t *node, swit SWITCH_MODULE_LOAD_FUNCTION(mod_console_load) { - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } - + module_pool = pool; /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &console_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); /* setup my logger function */ switch_log_bind_logger(switch_console_logger, SWITCH_LOG_DEBUG);