This rather large commit changes the way modules are loaded.

As partly documented in loader.c and include/asterisk/module.h,
modules are now expected to return all of their methods and flags
into a structure 'mod_data', and are normally loaded with RTLD_NOW
| RTLD_LOCAL, so symbols are resolved immediately and conflicts
should be less likely.  Only in a small number of cases (res_*,
typically) modules are loaded RTLD_GLOBAL, so they can export
symbols.
 
The core of the change is only the two files loader.c and
include/asterisk/module.h, all the rest is simply adaptation of the
existing modules to the new API, a rather mechanical (but believe
me, time and finger-consuming!) process whose detail you can figure
out by svn diff'ing any single module.

Expect some minor compilation issue after this change, please
report it on mantis http://bugs.digium.com/view.php?id=6968
so we collect all the feedback in one place.

I am just sorry that this change missed SVN version number 20000!



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20003 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-14 14:08:19 +00:00
parent 33a3a7375a
commit e43bc6634d
162 changed files with 1273 additions and 2386 deletions

View File

@@ -78,31 +78,27 @@ static struct ast_custom_function base64_decode_function = {
.read = base64_decode,
};
static char *tdesc = "base64 encode/decode dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&base64_encode_function) |
ast_custom_function_unregister(&base64_decode_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&base64_encode_function) |
ast_custom_function_register(&base64_decode_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
return "base64 encode/decode dialplan functions";
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -143,27 +143,24 @@ static struct ast_custom_function callerid_function = {
static char *tdesc = "Caller ID related dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&callerid_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&callerid_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -124,27 +124,24 @@ static struct ast_custom_function cdr_function = {
static char *tdesc = "CDR dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&cdr_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&cdr_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -138,27 +138,24 @@ static struct ast_custom_function channel_function = {
static char *tdesc = "Channel information dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&channel_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&channel_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -155,7 +155,7 @@ struct ast_custom_function acf_curl = {
.read = acf_curl_exec,
};
int unload_module(void)
static int unload_module(void *mod)
{
int res;
@@ -166,7 +166,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res;
@@ -175,19 +175,14 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
int res;
STANDARD_USECOUNT(res);
return res;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -303,7 +303,7 @@ struct ast_custom_function acf_cut = {
.read = acf_cut_exec,
};
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -315,7 +315,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -325,19 +325,14 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
int res;
STANDARD_USECOUNT(res);
return res;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1, NULL, NULL, NULL);

View File

@@ -161,7 +161,7 @@ static struct ast_custom_function db_exists_function = {
static char *tdesc = "Database (astdb) related dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -171,7 +171,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -181,17 +181,14 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -173,7 +173,7 @@ static struct ast_custom_function txtcidname_function = {
static char *tdesc = "ENUM related dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -185,7 +185,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -195,21 +195,15 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
int res;
STANDARD_USECOUNT(res);
return res;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1, NULL, NULL, NULL);

View File

@@ -138,7 +138,7 @@ static struct ast_custom_function stat_function = {
static char *tdesc = "Environment/filesystem dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -148,7 +148,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -158,17 +158,15 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -197,7 +197,7 @@ static struct ast_custom_function group_list_function = {
static char *tdesc = "Channel group dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -209,7 +209,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -221,17 +221,14 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -78,27 +78,24 @@ static struct ast_custom_function language_function = {
static char *tdesc = "Channel language dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&language_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&language_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -176,7 +176,7 @@ static struct ast_custom_function if_time_function = {
static char *tdesc = "Logical dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -189,7 +189,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -202,17 +202,14 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -249,27 +249,25 @@ static struct ast_custom_function math_function = {
static char *tdesc = "Mathematical dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&math_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&math_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -106,29 +106,26 @@ static struct ast_custom_function checkmd5_function = {
static char *tdesc = "MD5 digest dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&md5_function) |
ast_custom_function_unregister(&checkmd5_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&md5_function) |
ast_custom_function_register(&checkmd5_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -74,27 +74,24 @@ static struct ast_custom_function moh_function = {
static char *tdesc = "Music-on-hold dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&moh_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&moh_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -646,32 +646,25 @@ reload_out:
return res;
}
int unload_module(void)
static int unload_module(void *mod)
{
return odbc_unload_module();
}
int load_module(void)
static int load_module(void *mod)
{
return odbc_load_module();
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
if (! ast_mutex_trylock(&query_lock)) {
ast_mutex_unlock(&query_lock);
return 0;
} else {
return 1;
}
}
/* XXX need to revise usecount - set if query_lock is set */
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1, NULL, NULL, NULL);

View File

@@ -94,29 +94,27 @@ static struct ast_custom_function acf_rand = {
static char *tdesc = "Random number dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
ast_custom_function_unregister(&acf_rand);
return 0;
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&acf_rand);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -71,27 +71,24 @@ static struct ast_custom_function sha1_function = {
static char *tdesc = "SHA-1 computation dialplan function";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&sha1_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&sha1_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -424,7 +424,7 @@ static struct ast_custom_function keypadhash_function = {
static char *tdesc = "String handling dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
int res = 0;
@@ -442,7 +442,7 @@ int unload_module(void)
return res;
}
int load_module(void)
static int load_module(void *mod)
{
int res = 0;
@@ -460,17 +460,15 @@ int load_module(void)
return res;
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -175,27 +175,24 @@ static struct ast_custom_function timeout_function = {
static char *tdesc = "Channel timeout dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&timeout_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&timeout_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);

View File

@@ -88,29 +88,25 @@ static struct ast_custom_function urlencode_function = {
static char *tdesc = "URI encode/decode dialplan functions";
int unload_module(void)
static int unload_module(void *mod)
{
return ast_custom_function_unregister(&urldecode_function)
|| ast_custom_function_unregister(&urlencode_function);
}
int load_module(void)
static int load_module(void *mod)
{
return ast_custom_function_register(&urldecode_function)
|| ast_custom_function_register(&urlencode_function);
}
const char *description(void)
static const char *description(void)
{
return tdesc;
}
int usecount(void)
{
return 0;
}
const char *key()
static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);