[Freeswitch-svn] [commit] r5404 - in freeswitch/trunk/src: include mod/event_handlers/mod_cdr mod/event_handlers/mod_event_multicast mod/event_handlers/mod_event_socket mod/event_handlers/mod_event_test mod/event_handlers/mod_xmpp_event mod/event_handlers/mod_zeroconf mod/formats/mod_native_file mod/formats/mod_sndfile mod/loggers/mod_console
Freeswitch SVN
mikej at freeswitch.org
Wed Jun 20 03:53:33 EDT 2007
Author: mikej
Date: Wed Jun 20 03:53:33 2007
New Revision: 5404
Modified:
freeswitch/trunk/src/include/switch_loadable_module.h
freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c
freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c
freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c
Log:
add more modules to new mod loader macros/api.
Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h (original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h Wed Jun 20 03:53:33 2007
@@ -267,7 +267,7 @@
#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 @@
#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 @@
#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 @@
#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; \
Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.cpp (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_cdr/mod_cdr.cpp Wed Jun 20 03:53:33 2007
@@ -68,56 +68,6 @@
/*.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 @@
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
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c Wed Jun 20 03:53:33 2007
@@ -176,25 +176,12 @@
}
-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 @@
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) {
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Wed Jun 20 03:53:33 2007
@@ -161,7 +161,7 @@
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 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 @@
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;
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c Wed Jun 20 03:53:33 2007
@@ -71,20 +71,8 @@
}
}
-
-
-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_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;
}
Modified: freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c Wed Jun 20 03:53:33 2007
@@ -391,19 +391,10 @@
}
-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;
Modified: freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c Wed Jun 20 03:53:33 2007
@@ -237,16 +237,6 @@
}
-
-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 @@
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 @@
}
/* 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;
Modified: freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c Wed Jun 20 03:53:33 2007
@@ -138,34 +138,10 @@
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 @@
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;
Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c Wed Jun 20 03:53:33 2007
@@ -253,30 +253,6 @@
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 @@
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 @@
}
/* 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;
Modified: freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c
==============================================================================
--- freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c (original)
+++ freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c Wed Jun 20 03:53:33 2007
@@ -56,19 +56,6 @@
};
#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 @@
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);
More information about the Freeswitch-svn
mailing list