update to use new module loader api
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@301 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
916bd148ff
commit
97ef2be934
|
@ -34,7 +34,10 @@
|
||||||
#include "zap_analog.h"
|
#include "zap_analog.h"
|
||||||
#include "zap_isdn.h"
|
#include "zap_isdn.h"
|
||||||
|
|
||||||
static const char modname[] = "mod_openzap";
|
SWITCH_MODULE_LOAD_FUNCTION(mod_openzap_load);
|
||||||
|
SWITCH_MODULE_DEFINITION(mod_openzap, mod_openzap_load, NULL, NULL);
|
||||||
|
|
||||||
|
static switch_endpoint_interface_t *channel_endpoint_interface;
|
||||||
|
|
||||||
static switch_memory_pool_t *module_pool = NULL;
|
static switch_memory_pool_t *module_pool = NULL;
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
|
@ -654,7 +657,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_state_handler_table_t channel_event_handlers = {
|
static switch_state_handler_table_t channel_state_handlers = {
|
||||||
/*.on_init */ channel_on_init,
|
/*.on_init */ channel_on_init,
|
||||||
/*.on_ring */ channel_on_ring,
|
/*.on_ring */ channel_on_ring,
|
||||||
/*.on_execute */ channel_on_execute,
|
/*.on_execute */ channel_on_execute,
|
||||||
|
@ -674,24 +677,6 @@ static switch_io_routines_t channel_io_routines = {
|
||||||
/*.receive_message*/ channel_receive_message
|
/*.receive_message*/ channel_receive_message
|
||||||
};
|
};
|
||||||
|
|
||||||
static switch_endpoint_interface_t channel_endpoint_interface = {
|
|
||||||
/*.interface_name */ "openzap",
|
|
||||||
/*.io_routines */ &channel_io_routines,
|
|
||||||
/*.event_handlers */ &channel_event_handlers,
|
|
||||||
/*.private */ NULL,
|
|
||||||
/*.next */ NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static switch_loadable_module_interface_t channel_module_interface = {
|
|
||||||
/*.module_name */ modname,
|
|
||||||
/*.endpoint_interface */ &channel_endpoint_interface,
|
|
||||||
/*.timer_interface */ NULL,
|
|
||||||
/*.dialplan_interface */ NULL,
|
|
||||||
/*.codec_interface */ NULL,
|
|
||||||
/*.application_interface */ NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||||
*/
|
*/
|
||||||
|
@ -1205,13 +1190,10 @@ static switch_status_t load_config(void)
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
SWITCH_MODULE_LOAD_FUNCTION(mod_openzap_load)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
module_pool = pool;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
|
|
||||||
return SWITCH_STATUS_TERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
zap_global_set_logger(zap_logger);
|
zap_global_set_logger(zap_logger);
|
||||||
|
|
||||||
|
@ -1225,8 +1207,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* connect my internal structure to the blank pointer passed to me */
|
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||||
*module_interface = &channel_module_interface;
|
channel_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||||
|
channel_endpoint_interface->interface_name = "openzap";
|
||||||
|
channel_endpoint_interface->io_routines = &channel_io_routines;
|
||||||
|
channel_endpoint_interface->state_handler = &channel_state_handlers;
|
||||||
|
|
||||||
|
|
||||||
/* indicate that the module should continue to be loaded */
|
/* indicate that the module should continue to be loaded */
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue