mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 22:08:33 +00:00
add more modules to new mod loader macros/api.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5404 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
008777e95e
commit
ae02cbef83
10 files changed
+55
-214
No files matched your search
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 */ "<ip>[:<port>]",
|
||||
/* 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, "<ip>[:<port>]", SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user