From ee67c1412b6d98465453dbe50741702cb707bb45 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 20 Jun 2007 06:14:57 +0000 Subject: [PATCH] add dialplan interfaces to new module loader, add dialplan function helper macro. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5402 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_types.h | 2 ++ src/mod/applications/mod_enum/mod_enum.c | 2 +- .../mod_dialplan_directory.c | 21 ++++-------------- .../mod_dialplan_xml/mod_dialplan_xml.c | 22 ++++--------------- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 0064180b78..fa54220b52 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1040,6 +1040,8 @@ typedef void (*switch_application_function_t) (switch_core_session_t *, char *); typedef void (*switch_event_callback_t) (switch_event_t *); typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *); +#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t * name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) + typedef struct switch_scheduler_task switch_scheduler_task_t; diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index 09f8d578e2..72fd62b0f3 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -514,7 +514,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** result } -static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) +SWITCH_STANDARD_DIALPLAN(enum_dialplan_hunt) { switch_caller_extension_t *extension = NULL; enum_record_t *results, *rp; diff --git a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c index 9257ce4985..f11a4d5ada 100644 --- a/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c +++ b/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c @@ -83,7 +83,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_directory_name, globals.directory_n switch_xml_free(xml); } -static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) +SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt) { switch_caller_extension_t *extension = NULL; switch_channel_t *channel; @@ -151,27 +151,14 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t } -static switch_dialplan_interface_t directory_dialplan_interface = { - /*.interface_name = */ "directory", - /*.hunt_function = */ directory_dialplan_hunt - /*.next = NULL */ -}; - -static switch_loadable_module_interface_t directory_dialplan_module_interface = { - /*.module_name = */ modname, - /*.endpoint_interface = */ NULL, - /*.timer_interface = */ NULL, - /*.dialplan_interface = */ &directory_dialplan_interface, - /*.codec_interface = */ NULL, - /*.application_interface = */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_directory_load) { + switch_dialplan_interface_t *dp_interface; load_config(); /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &directory_dialplan_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_DIALPLAN(dp_interface, "directory", directory_dialplan_hunt); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c index 476647cba7..b36a7be0a1 100644 --- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c +++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c @@ -292,7 +292,7 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switc return status; } -static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) +SWITCH_STANDARD_DIALPLAN(dialplan_hunt) { switch_caller_extension_t *extension = NULL; switch_channel_t *channel; @@ -377,27 +377,13 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session, return extension; } - -static switch_dialplan_interface_t dialplan_interface = { - /*.interface_name = */ "XML", - /*.hunt_function = */ dialplan_hunt - /*.next = NULL */ -}; - -static switch_loadable_module_interface_t dialplan_module_interface = { - /*.module_name = */ modname, - /*.endpoint_interface = */ NULL, - /*.timer_interface = */ NULL, - /*.dialplan_interface = */ &dialplan_interface, - /*.codec_interface = */ NULL, - /*.application_interface = */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_xml_load) { + switch_dialplan_interface_t *dp_interface; /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &dialplan_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + SWITCH_ADD_DIALPLAN(dp_interface, "XML", dialplan_hunt); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS;