From 8b0c007ad990aa27d9868da49215fd1076ac77cc Mon Sep 17 00:00:00 2001 From: kpfleming Date: Mon, 21 Aug 2006 02:11:39 +0000 Subject: merge new_loader_completion branch, including (at least): - restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40722 f38db490-d61c-443f-a65b-d21fe96a405b --- funcs/Makefile | 9 +++++++-- funcs/func_base64.c | 18 ++++-------------- funcs/func_callerid.c | 18 +++--------------- funcs/func_cdr.c | 19 ++++--------------- funcs/func_channel.c | 18 +++--------------- funcs/func_curl.c | 28 +++++++--------------------- funcs/func_cut.c | 35 ++++++++++++----------------------- funcs/func_db.c | 19 ++++--------------- funcs/func_enum.c | 35 ++++++++++------------------------- funcs/func_env.c | 20 +++----------------- funcs/func_global.c | 19 +++---------------- funcs/func_groupcount.c | 18 +++--------------- funcs/func_language.c | 19 ++++--------------- funcs/func_logic.c | 19 ++++--------------- funcs/func_math.c | 19 +++---------------- funcs/func_md5.c | 19 ++++--------------- funcs/func_moh.c | 19 ++++--------------- funcs/func_odbc.c | 24 ++++++++---------------- funcs/func_rand.c | 28 ++++++---------------------- funcs/func_realtime.c | 45 ++++++++++++++++----------------------------- funcs/func_sha1.c | 19 ++++--------------- funcs/func_strings.c | 19 +++---------------- funcs/func_timeout.c | 18 +++--------------- funcs/func_uri.c | 17 +++-------------- 24 files changed, 125 insertions(+), 396 deletions(-) (limited to 'funcs') diff --git a/funcs/Makefile b/funcs/Makefile index 7da134236..eb087f432 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -9,7 +9,7 @@ # the GNU General Public License # -ifneq ($(wildcard ../menuselect.makeopts),) +ifneq ($(wildcard $(ASTTOPDIR)/menuselect.makeopts),) include ../menuselect.makeopts include ../menuselect.makedeps endif @@ -17,7 +17,12 @@ endif C_MODS:=$(filter-out $(MENUSELECT_FUNCS),$(patsubst %.c,%,$(wildcard func_*.c))) CC_MODS:=$(filter-out $(MENUSELECT_FUNCS),$(patsubst %.cc,%,$(wildcard func_*.cc))) -SELECTED_MODS:=$(C_MODS) $(CC_MODS) +LOADABLE_MODS:=$(C_MODS) $(CC_MODS) + +ifneq ($(findstring funcs,$(MENUSELECT_EMBED)),) + EMBEDDED_MODS:=$(LOADABLE_MODS) + LOADABLE_MODS:= +endif all: _all diff --git a/funcs/func_base64.c b/funcs/func_base64.c index 6c9c469cd..463e6dd87 100644 --- a/funcs/func_base64.c +++ b/funcs/func_base64.c @@ -25,6 +25,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -78,27 +79,16 @@ static struct ast_custom_function base64_decode_function = { .read = base64_decode, }; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&base64_encode_function) | ast_custom_function_unregister(&base64_decode_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&base64_encode_function) | ast_custom_function_register(&base64_decode_function); } -static const char *description(void) -{ - return "base64 encode/decode dialplan functions"; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "base64 encode/decode dialplan functions"); diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c index 7c2591a39..21f13ceaa 100644 --- a/funcs/func_callerid.c +++ b/funcs/func_callerid.c @@ -143,26 +143,14 @@ static struct ast_custom_function callerid_function = { .write = callerid_write, }; -static char *tdesc = "Caller ID related dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&callerid_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&callerid_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Caller ID related dialplan function"); diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index f3606662b..039e45ca7 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -27,6 +27,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -131,26 +132,14 @@ static struct ast_custom_function cdr_function = { " integral values.\n", }; -static char *tdesc = "CDR dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&cdr_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&cdr_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "CDR dialplan function"); diff --git a/funcs/func_channel.c b/funcs/func_channel.c index b4f1ec771..2a377b52f 100644 --- a/funcs/func_channel.c +++ b/funcs/func_channel.c @@ -171,26 +171,14 @@ static struct ast_custom_function channel_function = { .write = func_channel_write, }; -static char *tdesc = "Channel information dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&channel_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&channel_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel information dialplan function"); diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 64210eb33..fc5ad79cb 100644 --- a/funcs/func_curl.c +++ b/funcs/func_curl.c @@ -52,10 +52,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/utils.h" -static char *tdesc = "Load external URL"; - -LOCAL_USER_DECL; - struct MemoryStruct { char *memory; size_t size; @@ -113,7 +109,7 @@ static int curl_internal(struct MemoryStruct *chunk, char *url, char *post) static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char *buf, size_t len) { - struct localuser *u; + struct ast_module_user *u; struct MemoryStruct chunk = { NULL, 0 }; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(url); @@ -127,7 +123,7 @@ static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char * return -1; } - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); AST_STANDARD_APP_ARGS(args, info); @@ -144,7 +140,7 @@ static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char * ast_log(LOG_ERROR, "Cannot allocate curl structure\n"); } - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); return 0; } @@ -159,18 +155,18 @@ struct ast_custom_function acf_curl = { .read = acf_curl_exec, }; -static int unload_module(void *mod) +static int unload_module(void) { int res; res = ast_custom_function_unregister(&acf_curl); - STANDARD_HANGUP_LOCALUSERS; + ast_module_user_hangup_all(); return res; } -static int load_module(void *mod) +static int load_module(void) { int res; @@ -179,15 +175,5 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Load external URL"); diff --git a/funcs/func_cut.c b/funcs/func_cut.c index 3df16de18..a8b8c8152 100644 --- a/funcs/func_cut.c +++ b/funcs/func_cut.c @@ -44,9 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") /* Maximum length of any variable */ #define MAXRESULT 1024 - -LOCAL_USER_DECL; - struct sortable_keys { char *key; float value; @@ -213,10 +210,10 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size static int acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { - struct localuser *u; + struct ast_module_user *u; int ret = -1; - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); switch (sort_internal(chan, data, buf, len)) { case ERROR_NOARG: @@ -231,7 +228,8 @@ static int acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char * default: ast_log(LOG_ERROR, "Unknown internal error\n"); } - LOCAL_USER_REMOVE(u); + + ast_module_user_remove(u); return ret; } @@ -239,9 +237,9 @@ static int acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char * static int acf_cut_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { int ret = -1; - struct localuser *u; + struct ast_module_user *u; - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); switch (cut_internal(chan, data, buf, len)) { case ERROR_NOARG: @@ -259,7 +257,8 @@ static int acf_cut_exec(struct ast_channel *chan, char *cmd, char *data, char *b default: ast_log(LOG_ERROR, "Unknown internal error\n"); } - LOCAL_USER_REMOVE(u); + + ast_module_user_remove(u); return ret; } @@ -288,19 +287,19 @@ struct ast_custom_function acf_cut = { .read = acf_cut_exec, }; -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; res |= ast_custom_function_unregister(&acf_cut); res |= ast_custom_function_unregister(&acf_sort); - STANDARD_HANGUP_LOCALUSERS; + ast_module_user_hangup_all(); return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -310,14 +309,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return "Cut out information from a string"; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Cut out information from a string"); diff --git a/funcs/func_db.c b/funcs/func_db.c index 1fefa5cc9..13932d27d 100644 --- a/funcs/func_db.c +++ b/funcs/func_db.c @@ -29,6 +29,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -205,9 +206,7 @@ static struct ast_custom_function db_delete_function = { .read = function_db_delete, }; -static char *tdesc = "Database (astdb) related dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -218,7 +217,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -229,14 +228,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Database (astdb) related dialplan functions"); diff --git a/funcs/func_enum.c b/funcs/func_enum.c index 94610d304..f37a15fd1 100644 --- a/funcs/func_enum.c +++ b/funcs/func_enum.c @@ -50,8 +50,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static char *synopsis = "Syntax: ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])\n"; -LOCAL_USER_DECL; - static int function_enum(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { @@ -65,7 +63,7 @@ static int function_enum(struct ast_channel *chan, char *cmd, char *data, int res = 0; char tech[80]; char dest[256] = "", tmp[2] = "", num[AST_MAX_EXTENSION] = ""; - struct localuser *u; + struct ast_module_user *u; char *s, *p; buf[0] = '\0'; @@ -82,7 +80,7 @@ static int function_enum(struct ast_channel *chan, char *cmd, char *data, return -1; } - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); ast_copy_string(tech, args.tech ? args.tech : "sip", sizeof(tech)); @@ -110,7 +108,7 @@ static int function_enum(struct ast_channel *chan, char *cmd, char *data, else ast_copy_string(buf, dest, len); - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); return 0; } @@ -137,7 +135,7 @@ static int function_txtcidname(struct ast_channel *chan, char *cmd, char tech[80]; char txt[256] = ""; char dest[80]; - struct localuser *u; + struct ast_module_user *u; buf[0] = '\0'; @@ -147,7 +145,7 @@ static int function_txtcidname(struct ast_channel *chan, char *cmd, return -1; } - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt)); @@ -155,7 +153,7 @@ static int function_txtcidname(struct ast_channel *chan, char *cmd, if (!ast_strlen_zero(txt)) ast_copy_string(buf, txt, len); - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); return 0; } @@ -171,21 +169,19 @@ static struct ast_custom_function txtcidname_function = { .read = function_txtcidname, }; -static char *tdesc = "ENUM related dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; res |= ast_custom_function_unregister(&enum_function); res |= ast_custom_function_unregister(&txtcidname_function); - STANDARD_HANGUP_LOCALUSERS; + ast_module_user_hangup_all(); return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -195,15 +191,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ENUM related dialplan functions"); diff --git a/funcs/func_env.c b/funcs/func_env.c index e7a4510c2..6747d4f29 100644 --- a/funcs/func_env.c +++ b/funcs/func_env.c @@ -135,10 +135,7 @@ static struct ast_custom_function stat_function = { " M - Returns the epoch at which the file was last modified\n", }; - -static char *tdesc = "Environment/filesystem dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -148,7 +145,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -158,15 +155,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Environment/filesystem dialplan functions"); diff --git a/funcs/func_global.c b/funcs/func_global.c index d05d88114..50a84afde 100644 --- a/funcs/func_global.c +++ b/funcs/func_global.c @@ -65,9 +65,7 @@ static struct ast_custom_function global_function = { .write = global_write, }; -static char *tdesc = "Global variable dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -76,7 +74,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -85,15 +83,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Global variable dialplan functions"); diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c index 8988ec739..ed96e34b0 100644 --- a/funcs/func_groupcount.c +++ b/funcs/func_groupcount.c @@ -195,9 +195,7 @@ static struct ast_custom_function group_list_function = { .write = NULL, }; -static char *tdesc = "Channel group dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -209,7 +207,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -221,14 +219,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel group dialplan functions"); diff --git a/funcs/func_language.c b/funcs/func_language.c index 2cca3772f..af6f9d0a9 100644 --- a/funcs/func_language.c +++ b/funcs/func_language.c @@ -24,6 +24,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -76,26 +77,14 @@ static struct ast_custom_function language_function = { .write = language_write, }; -static char *tdesc = "Channel language dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&language_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&language_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel language dialplan function"); diff --git a/funcs/func_logic.c b/funcs/func_logic.c index dee61e82e..9fe23b20b 100644 --- a/funcs/func_logic.c +++ b/funcs/func_logic.c @@ -26,6 +26,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -174,9 +175,7 @@ static struct ast_custom_function if_time_function = { .read = iftime, }; -static char *tdesc = "Logical dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -189,7 +188,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -202,14 +201,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Logical dialplan functions"); diff --git a/funcs/func_math.c b/funcs/func_math.c index c5b4bff0c..608135c53 100644 --- a/funcs/func_math.c +++ b/funcs/func_math.c @@ -247,27 +247,14 @@ static struct ast_custom_function math_function = { .read = math }; -static char *tdesc = "Mathematical dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&math_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&math_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); - +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mathematical dialplan function"); diff --git a/funcs/func_md5.c b/funcs/func_md5.c index d2b2ee294..db6be8f7b 100644 --- a/funcs/func_md5.c +++ b/funcs/func_md5.c @@ -28,6 +28,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -104,28 +105,16 @@ static struct ast_custom_function checkmd5_function = { .read = checkmd5, }; -static char *tdesc = "MD5 digest dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&md5_function) | ast_custom_function_unregister(&checkmd5_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&md5_function) | ast_custom_function_register(&checkmd5_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions"); diff --git a/funcs/func_moh.c b/funcs/func_moh.c index 9230988de..c8e29a747 100644 --- a/funcs/func_moh.c +++ b/funcs/func_moh.c @@ -27,6 +27,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include "asterisk/module.h" @@ -72,26 +73,14 @@ static struct ast_custom_function moh_function = { .write = moh_write, }; -static char *tdesc = "Music-on-hold dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&moh_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&moh_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Music-on-hold dialplan function"); diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index 3ea531957..b380c1b40 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -49,8 +49,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/res_odbc.h" #include "asterisk/app.h" -static char *tdesc = "ODBC lookups"; - static char *config = "func_odbc.conf"; enum { @@ -533,7 +531,7 @@ static int odbc_unload_module(void) return 0; } -static int reload(void *mod) +static int reload(void) { int res = 0; struct ast_config *cfg; @@ -573,27 +571,21 @@ reload_out: return res; } -static int unload_module(void *mod) +static int unload_module(void) { return odbc_unload_module(); } -static int load_module(void *mod) +static int load_module(void) { return odbc_load_module(); } -static const char *description(void) -{ - return tdesc; -} - /* XXX need to revise usecount - set if query_lock is set */ -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1, reload, NULL, NULL); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ODBC lookups", + .load = load_module, + .unload = unload_module, + .reload = reload, + ); diff --git a/funcs/func_rand.c b/funcs/func_rand.c index 73da134ae..a216754ac 100644 --- a/funcs/func_rand.c +++ b/funcs/func_rand.c @@ -39,19 +39,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/utils.h" #include "asterisk/app.h" -LOCAL_USER_DECL; - static int acf_rand_exec(struct ast_channel *chan, char *cmd, char *parse, char *buffer, size_t buflen) { - struct localuser *u; + struct ast_module_user *u; int min_int, response_int, max_int; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(min); AST_APP_ARG(max); ); - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); AST_STANDARD_APP_ARGS(args, parse); @@ -74,7 +72,7 @@ static int acf_rand_exec(struct ast_channel *chan, char *cmd, response_int, min_int, max_int); snprintf(buffer, buflen, "%d", response_int); - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); return 0; } @@ -91,30 +89,16 @@ static struct ast_custom_function acf_rand = { .read = acf_rand_exec, }; - -static char *tdesc = "Random number dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { ast_custom_function_unregister(&acf_rand); return 0; } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&acf_rand); } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Random number dialplan function"); diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index 8952311d6..9610c0c2a 100644 --- a/funcs/func_realtime.c +++ b/funcs/func_realtime.c @@ -43,20 +43,14 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/lock.h" #include "asterisk/logger.h" #include "asterisk/utils.h" -#include "asterisk/module.h" #include "asterisk/app.h" -LOCAL_USER_DECL; - -static char *tdesc = "Read/Write values from a RealTime repository"; - static int function_realtime_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct ast_variable *var, *head; - struct localuser *u; + struct ast_module_user *u; char *results; size_t resultslen = 0; - AST_DECLARE_APP_ARGS(args, AST_APP_ARG(family); AST_APP_ARG(fieldmatch); @@ -70,7 +64,9 @@ static int function_realtime_read(struct ast_channel *chan, char *cmd, char *dat ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch[|value[|delim1[|delim2]]]) - missing argument!\n"); return -1; } - LOCAL_USER_ADD(u); + + u = ast_module_user_add(chan); + AST_STANDARD_APP_ARGS(args, data); if (!args.delim1) @@ -81,7 +77,7 @@ static int function_realtime_read(struct ast_channel *chan, char *cmd, char *dat head = ast_load_realtime(args.family, args.fieldmatch, args.value, NULL); if (!head) { - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); return -1; } for (var = head; var; var = var->next) @@ -92,16 +88,15 @@ static int function_realtime_read(struct ast_channel *chan, char *cmd, char *dat ast_build_string(&results, &resultslen, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); ast_copy_string(buf, results, len); - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); + return 0; } static int function_realtime_write(struct ast_channel *chan, char *cmd, char *data, const char *value) { - struct localuser *u; + struct ast_module_user *u; int res = 0; - - AST_DECLARE_APP_ARGS(args, AST_APP_ARG(family); AST_APP_ARG(fieldmatch); @@ -114,7 +109,8 @@ static int function_realtime_write(struct ast_channel *chan, char *cmd, char *da return -1; } - LOCAL_USER_ADD(u); + u = ast_module_user_add(chan); + AST_STANDARD_APP_ARGS(args, data); res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, NULL); @@ -123,7 +119,8 @@ static int function_realtime_write(struct ast_channel *chan, char *cmd, char *da ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); } - LOCAL_USER_REMOVE(u); + ast_module_user_remove(u); + return 0; } @@ -145,30 +142,20 @@ struct ast_custom_function realtime_function = { .write = function_realtime_write, }; -static int unload_module(void *mod) +static int unload_module(void) { int res = ast_custom_function_unregister(&realtime_function); - STANDARD_HANGUP_LOCALUSERS; + ast_module_user_hangup_all(); return res; } -static int load_module(void *mod) +static int load_module(void) { int res = ast_custom_function_register(&realtime_function); return res; } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Read/Write values from a RealTime repository"); diff --git a/funcs/func_sha1.c b/funcs/func_sha1.c index 65f5d6fbe..01c7eb023 100644 --- a/funcs/func_sha1.c +++ b/funcs/func_sha1.c @@ -26,6 +26,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include #include #include #include @@ -69,26 +70,14 @@ static struct ast_custom_function sha1_function = { " which is known as his hash\n", }; -static char *tdesc = "SHA-1 computation dialplan function"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&sha1_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&sha1_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SHA-1 computation dialplan function"); diff --git a/funcs/func_strings.c b/funcs/func_strings.c index fcecb77fd..86063185a 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -570,9 +570,7 @@ static struct ast_custom_function keypadhash_function = { .desc = "Example: ${KEYPADHASH(Les)} returns \"537\"\n", }; -static char *tdesc = "String handling dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { int res = 0; @@ -591,7 +589,7 @@ static int unload_module(void *mod) return res; } -static int load_module(void *mod) +static int load_module(void) { int res = 0; @@ -610,15 +608,4 @@ static int load_module(void *mod) return res; } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} - -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "String handling dialplan functions"); diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c index 116aef802..206ba9482 100644 --- a/funcs/func_timeout.c +++ b/funcs/func_timeout.c @@ -173,26 +173,14 @@ static struct ast_custom_function timeout_function = { .write = timeout_write, }; -static char *tdesc = "Channel timeout dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&timeout_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&timeout_function); } -static const char *description(void) -{ - return tdesc; -} - - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel timeout dialplan functions"); diff --git a/funcs/func_uri.c b/funcs/func_uri.c index 8d4979b3b..557fea191 100644 --- a/funcs/func_uri.c +++ b/funcs/func_uri.c @@ -86,27 +86,16 @@ static struct ast_custom_function urlencode_function = { .read = uriencode, }; -static char *tdesc = "URI encode/decode dialplan functions"; - -static int unload_module(void *mod) +static int unload_module(void) { return ast_custom_function_unregister(&urldecode_function) || ast_custom_function_unregister(&urlencode_function); } -static int load_module(void *mod) +static int load_module(void) { return ast_custom_function_register(&urldecode_function) || ast_custom_function_register(&urlencode_function); } -static const char *description(void) -{ - return tdesc; -} - -static const char *key(void) -{ - return ASTERISK_GPL_KEY; -} -STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "URI encode/decode dialplan functions"); -- cgit v1.2.3