diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index c2b0f67118..843b43d2ee 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -257,18 +257,24 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir, \return SWITCH_STATUS_SUCCESS on a successful load */ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename); -SWITCH_MOD_DECLARE(switch_status_t) switch_module_reload(void); -SWITCH_MOD_DECLARE(switch_status_t) switch_module_pause(void); -SWITCH_MOD_DECLARE(switch_status_t) switch_module_resume(void); -SWITCH_MOD_DECLARE(switch_status_t) switch_module_status(void); SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void); - /*! \brief Shutdown a module \return SWITCH_STATUS_SUCCESS on a successful shutdown */ 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->interface_name = int_name; \ + api_int->desc = descript; \ + api_int->function = funcptr; \ + api_int->syntax = syntax_string; \ + break; \ + } + ///\} SWITCH_END_EXTERN_C diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 4c1fa0ddf0..e48d9dcb00 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -39,25 +39,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load); SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, NULL, NULL); -static switch_api_interface_t ctl_api_interface; -static switch_api_interface_t uuid_bridge_api_interface; -static switch_api_interface_t session_record_api_interface; -static switch_api_interface_t status_api_interface; -static switch_api_interface_t show_api_interface; -static switch_api_interface_t pause_api_interface; -static switch_api_interface_t transfer_api_interface; -static switch_api_interface_t load_api_interface; -static switch_api_interface_t unload_api_interface; -static switch_api_interface_t reload_api_interface; -static switch_api_interface_t kill_api_interface; -static switch_api_interface_t originate_api_interface; -static switch_api_interface_t media_api_interface; -static switch_api_interface_t hold_api_interface; -static switch_api_interface_t broadcast_api_interface; -static switch_api_interface_t sched_broadcast_api_interface; -static switch_api_interface_t sched_transfer_api_interface; -static switch_api_interface_t sched_hangup_api_interface; - SWITCH_STANDARD_API(status_function) { uint8_t html = 0; @@ -108,6 +89,7 @@ SWITCH_STANDARD_API(status_function) return SWITCH_STATUS_SUCCESS; } +#define CTL_SYNTAX "[hupall|pause|resume|shutdown]" SWITCH_STANDARD_API(ctl_function) { int argc; @@ -115,7 +97,7 @@ SWITCH_STANDARD_API(ctl_function) uint32_t arg = 0; if (switch_strlen_zero(cmd)) { - stream->write_function(stream, "USAGE: %s\n", ctl_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", CTL_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -150,6 +132,7 @@ SWITCH_STANDARD_API(ctl_function) } +#define LOAD_SYNTAX "" SWITCH_STANDARD_API(load_function) { const char *err; @@ -159,7 +142,7 @@ SWITCH_STANDARD_API(load_function) } if (switch_strlen_zero(cmd)) { - stream->write_function(stream, "USAGE: %s\n", load_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", LOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -181,7 +164,7 @@ SWITCH_STANDARD_API(unload_function) } if (switch_strlen_zero(cmd)) { - stream->write_function(stream, "USAGE: %s\n", unload_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", LOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -212,6 +195,7 @@ SWITCH_STANDARD_API(reload_function) return SWITCH_STATUS_SUCCESS; } +#define KILL_SYNTAX "" SWITCH_STANDARD_API(kill_function) { switch_core_session_t *ksession = NULL; @@ -221,7 +205,7 @@ SWITCH_STANDARD_API(kill_function) } if (!cmd) { - stream->write_function(stream, "USAGE: %s\n", kill_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", KILL_SYNTAX); } else if ((ksession = switch_core_session_locate(cmd))) { switch_channel_t *channel = switch_core_session_get_channel(ksession); switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); @@ -234,6 +218,7 @@ SWITCH_STANDARD_API(kill_function) return SWITCH_STATUS_SUCCESS; } +#define TRANSFER_SYNTAX " [] []" SWITCH_STANDARD_API(transfer_function) { switch_core_session_t *tsession = NULL; @@ -269,13 +254,14 @@ SWITCH_STANDARD_API(transfer_function) } } - stream->write_function(stream, "USAGE: %s\n", transfer_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", TRANSFER_SYNTAX); done: switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; } +#define TONE_DETECT_SYNTAX " [ ]" SWITCH_STANDARD_API(tone_detect_session_function) { char *argv[6] = { 0 }; @@ -325,6 +311,7 @@ SWITCH_STANDARD_API(tone_detect_session_function) return SWITCH_STATUS_SUCCESS; } +#define SCHED_TRANSFER_SYNTAX "[+]