aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-21 02:11:39 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-21 02:11:39 +0000
commit8b0c007ad990aa27d9868da49215fd1076ac77cc (patch)
tree270b9c46c1e644483d6d2a35b509f43218ba3252 /res
parenta42edc84034f91932a3e12d503e07f76a6eb498a (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/Makefile11
-rw-r--r--res/res_adsi.c22
-rw-r--r--res/res_agi.c27
-rw-r--r--res/res_clioriginate.c29
-rw-r--r--res/res_config_odbc.c23
-rw-r--r--res/res_config_pgsql.c28
-rw-r--r--res/res_convert.c30
-rw-r--r--res/res_crypto.c26
-rw-r--r--res/res_features.c63
-rw-r--r--res/res_indications.c22
-rw-r--r--res/res_jabber.c24
-rw-r--r--res/res_monitor.c20
-rw-r--r--res/res_musiconhold.c23
-rw-r--r--res/res_odbc.c24
-rw-r--r--res/res_smdi.c28
-rw-r--r--res/res_snmp.c22
-rw-r--r--res/res_speech.c19
17 files changed, 163 insertions, 278 deletions
diff --git a/res/Makefile b/res/Makefile
index 178130820..d7f347900 100644
--- a/res/Makefile
+++ b/res/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,13 +17,18 @@ endif
C_MODS:=$(filter-out $(MENUSELECT_RES),$(patsubst %.c,%,$(wildcard res_*.c)))
CC_MODS:=$(filter-out $(MENUSELECT_RES),$(patsubst %.cc,%,$(wildcard res_*.cc)))
-SELECTED_MODS:=$(C_MODS) $(CC_MODS)
+LOADABLE_MODS:=$(C_MODS) $(CC_MODS)
+
+ifneq ($(findstring res,$(MENUSELECT_EMBED)),)
+ EMBEDDED_MODS:=$(LOADABLE_MODS)
+ LOADABLE_MODS:=
+endif
all: _all
include $(ASTTOPDIR)/Makefile.moddir_rules
-res_snmp.so: snmp/agent.o
+$(res_snmp): snmp/agent.o
clean::
rm -f snmp/*.o
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 2d6273876..b252bb8b2 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -1105,32 +1105,26 @@ static void adsi_load(void)
}
}
-static int reload(void *mod)
+static int reload(void)
{
adsi_load();
return 0;
}
-static int load_module(void *mod)
+static int load_module(void)
{
adsi_load();
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* Can't unload this once we're loaded */
return -1;
}
-static const char *description(void)
-{
- return "ADSI Resource";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "ADSI Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_agi.c b/res/res_agi.c
index 571e25279..99d1d0c6a 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -102,8 +102,6 @@ static char *descrip =
static int agidebug = 0;
-struct module_symbols *me;
-
#define TONE_BLOCK_SIZE 200
/* Max time to connect to an AGI remote host */
@@ -1980,7 +1978,7 @@ static int handle_dumpagihtml(int fd, int argc, char *argv[])
static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int dead)
{
enum agi_result res;
- struct localuser *u;
+ struct ast_module_user *u;
char *argv[MAX_ARGS];
char buf[2048]="";
char *tmp = (char *)buf;
@@ -2002,7 +2000,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
argv[argc++] = stringp;
argv[argc] = NULL;
- u = ast_localuser_add(me, chan);
+ u = ast_module_user_add(chan);
#if 0
/* Answer if need be */
if (chan->_state != AST_STATE_UP) {
@@ -2027,7 +2025,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
close(efd);
ast_unreplace_sigchld();
}
- ast_localuser_remove(me, u);
+ ast_module_user_remove(u);
switch (res) {
case AGI_RESULT_SUCCESS:
@@ -2094,9 +2092,9 @@ static struct ast_cli_entry showagi =
static struct ast_cli_entry dumpagihtml =
{ { "dump", "agihtml", NULL }, handle_dumpagihtml, "Dumps a list of agi command in html format", dumpagihtml_help };
-static int unload_module(void *mod)
+static int unload_module(void)
{
- ast_hangup_localusers(mod);
+ ast_module_user_hangup_all();
ast_cli_unregister(&showagi);
ast_cli_unregister(&dumpagihtml);
ast_cli_unregister(&cli_debug);
@@ -2106,9 +2104,8 @@ static int unload_module(void *mod)
return ast_unregister_application(app);
}
-static int load_module(void *mod)
+static int load_module(void)
{
- me = mod;
ast_cli_register(&showagi);
ast_cli_register(&dumpagihtml);
ast_cli_register(&cli_debug);
@@ -2118,14 +2115,4 @@ static int load_module(void *mod)
return ast_register_application(app, agi_exec, synopsis, descrip);
}
-static const char *description(void)
-{
- return "Asterisk Gateway Interface (AGI)";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0, NULL, NULL, NULL);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Asterisk Gateway Interface (AGI)");
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 7303d4b67..454dc7815 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -43,8 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
/*! The timeout for originated calls, in seconds */
#define TIMEOUT 30
-static struct module_symbols *me;
-
static char orig_help[] =
" There are two ways to use this command. A call can be originated between a\n"
"channel and a specific application, or between a channel and an extension in\n"
@@ -127,7 +125,8 @@ static int handle_orig(int fd, int argc, char *argv[])
if (ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2]))
return RESULT_SHOWUSAGE;
- ast_atomic_fetchadd_int(&me->usecnt, +1);
+ /* ugly, can be removed when CLI entries have ast_module pointers */
+ ast_module_ref(ast_module_info->self);
if (!strcasecmp("application", argv[2])) {
res = orig_app(fd, argv[1], argv[3], argv[4]);
@@ -136,7 +135,7 @@ static int handle_orig(int fd, int argc, char *argv[])
} else
res = RESULT_SHOWUSAGE;
- ast_atomic_fetchadd_int(&me->usecnt, -1);
+ ast_module_unref(ast_module_info->self);
return res;
}
@@ -149,32 +148,22 @@ static char *complete_orig(const char *line, const char *word, int pos, int stat
if (pos != 2)
return NULL;
- ast_atomic_fetchadd_int(&me->usecnt, +1);
+ /* ugly, can be removed when CLI entries have ast_module pointers */
+ ast_module_ref(ast_module_info->self);
ret = ast_cli_complete(word, choices, state);
- ast_atomic_fetchadd_int(&me->usecnt, -1);
+ ast_module_unref(ast_module_info->self);
return ret;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
return ast_cli_unregister(&cli_orig);
}
-static int load_module(void *mod)
+static int load_module(void)
{
- me = mod;
return ast_cli_register(&cli_orig);
}
-static const char *description(void)
-{
- return "Call origination from the CLI";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT, NULL, NULL, NULL);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call origination from the CLI");
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index a964ee75f..0c1ff713a 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -52,8 +52,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/res_odbc.h"
#include "asterisk/utils.h"
-LOCAL_USER_DECL;
-
static struct ast_variable *realtime_odbc(const char *database, const char *table, va_list ap)
{
struct odbc_obj *obj;
@@ -574,16 +572,16 @@ static struct ast_config_engine odbc_engine = {
.update_func = update_odbc
};
-static int unload_module (void *mod)
+static int unload_module (void)
{
- ast_hangup_localusers(mod);
+ ast_module_user_hangup_all();
ast_config_engine_deregister(&odbc_engine);
if (option_verbose)
ast_verbose("res_config_odbc unloaded.\n");
return 0;
}
-static int load_module (void *mod)
+static int load_module (void)
{
ast_config_engine_register(&odbc_engine);
if (option_verbose)
@@ -591,14 +589,7 @@ static int load_module (void *mod)
return 0;
}
-static const char *description(void)
-{
- return "ODBC Configuration";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "ODBC Configuration",
+ .load = load_module,
+ .unload = unload_module,
+ );
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 02b067bc0..f004bfd13 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -66,8 +66,6 @@ static int parse_config(void);
static int pgsql_reconnect(const char *database);
static int realtime_pgsql_status(int fd, int argc, char **argv);
-LOCAL_USER_DECL;
-
static char cli_realtime_pgsql_status_usage[] =
"Usage: realtime pgsql status\n"
" Shows connection information for the Postgresql RealTime driver\n";
@@ -553,7 +551,7 @@ static struct ast_config_engine pgsql_engine = {
.update_func = update_pgsql
};
-static int load_module(void *mod)
+static int load_module(void)
{
parse_config();
@@ -577,7 +575,7 @@ static int load_module(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* Aquire control before doing anything to the module itself. */
ast_mutex_lock(&pgsql_lock);
@@ -592,7 +590,7 @@ static int unload_module(void *mod)
ast_verbose("Postgresql RealTime unloaded.\n");
}
- STANDARD_HANGUP_LOCALUSERS;
+ ast_module_user_hangup_all();
/* Unlock so something else can destroy the lock. */
ast_mutex_unlock(&pgsql_lock);
@@ -600,7 +598,7 @@ static int unload_module(void *mod)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
/* Aquire control before doing anything to the module itself. */
ast_mutex_lock(&pgsql_lock);
@@ -697,17 +695,6 @@ int parse_config(void)
return 1;
}
-static const char *description(void)
-{
- return "Postgresql RealTime Configuration Driver";
-
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
static int pgsql_reconnect(const char *database)
{
char my_database[50];
@@ -799,4 +786,9 @@ static int realtime_pgsql_status(int fd, int argc, char **argv)
}
}
-STD_MOD(MOD_0, reload, NULL, NULL);
+/* needs usecount semantics defined */
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "PostgreSQL RealTime Configuration Driver",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload
+ );
diff --git a/res/res_convert.c b/res/res_convert.c
index c62aba4d5..0f46cf14d 100644
--- a/res/res_convert.c
+++ b/res/res_convert.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2005, Digium, Inc.
+ * Copyright (C) 2005, 2006, Digium, Inc.
*
* redice li <redice_li@yahoo.com>
* Russell Bryant <russell@digium.com>
@@ -40,8 +40,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
#include "asterisk/file.h"
-struct module_symbols *me;
-
/*! \brief Split the filename to basename and extension */
static int split_ext(char *filename, char **name, char **ext)
{
@@ -66,8 +64,9 @@ static int cli_audio_convert(int fd, int argc, char *argv[])
char *file_in = NULL, *file_out = NULL;
char *name_in, *ext_in, *name_out, *ext_out;
- ast_atomic_fetchadd_int(&me->usecnt, +1);
-
+ /* ugly, can be removed when CLI entries have ast_module pointers */
+ ast_module_ref(ast_module_info->self);
+
if (argc != 3 || ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2])) {
ret = RESULT_SHOWUSAGE;
goto fail_out;
@@ -117,8 +116,8 @@ fail_out:
if (fs_in)
ast_closestream(fs_in);
- ast_atomic_fetchadd_int(&me->usecnt, -1);
-
+ ast_module_unref(ast_module_info->self);
+
return ret;
}
@@ -133,25 +132,14 @@ static struct ast_cli_entry audio_convert_cli={
{ "convert" , NULL }, cli_audio_convert, "Convert audio files", usage_audio_convert
};
-static int unload_module(void *mod)
+static int unload_module(void)
{
return ast_cli_unregister(&audio_convert_cli);
}
-static int load_module(void *mod)
+static int load_module(void)
{
- me = mod;
return ast_cli_register(&audio_convert_cli);
}
-static const char *description(void)
-{
- return "File format conversion CLI command";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD1;
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "File format conversion CLI command");
diff --git a/res/res_crypto.c b/res/res_crypto.c
index b9b973eea..3fab770e6 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -585,13 +585,13 @@ static int crypto_init(void)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
crypto_load(-1, -1);
return 0;
}
-static int load_module(void *mod)
+static int load_module(void)
{
crypto_init();
if (ast_opt_init_keys)
@@ -601,21 +601,15 @@ static int load_module(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* Can't unload this once we're loaded */
return -1;
}
-static const char *description(void)
-{
- return "Cryptographic Digital Signatures";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
-
+/* needs usecount semantics defined */
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Cryptographic Digital Signatures",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload
+ );
diff --git a/res/res_features.c b/res/res_features.c
index af714f559..0a7883c16 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -497,10 +497,10 @@ static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer,
{
struct ast_channel *parker;
struct ast_channel *parkee;
+ int res = 0;
+ struct ast_module_user *u;
- int res=0;
- struct localuser *u;
- LOCAL_USER_ADD(u);
+ u = ast_module_user_add(chan);
set_peers(&parker, &parkee, peer, chan, sense);
/* Setup the exten/priority to be s/1 since we don't know
@@ -513,7 +513,9 @@ static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer,
res = ast_safe_sleep(chan, 1000);
if (!res)
res = ast_park_call(parkee, parker, 0, NULL);
- LOCAL_USER_REMOVE(u);
+
+ ast_module_user_remove(u);
+
if (!res) {
if (sense == FEATURE_SENSE_CHAN)
res = AST_PBX_NO_HANGUP_PEER;
@@ -1671,9 +1673,11 @@ static int park_call_exec(struct ast_channel *chan, void *data)
{
/* Data is unused at the moment but could contain a parking
lot context eventually */
- int res=0;
- struct localuser *u;
- LOCAL_USER_ADD(u);
+ int res = 0;
+ struct ast_module_user *u;
+
+ u = ast_module_user_add(chan);
+
/* Setup the exten/priority to be s/1 since we don't know
where this call should return */
strcpy(chan->exten, "s");
@@ -1687,17 +1691,17 @@ static int park_call_exec(struct ast_channel *chan, void *data)
/* Park the call */
if (!res)
res = ast_park_call(chan, chan, 0, NULL);
- LOCAL_USER_REMOVE(u);
- if (!res)
- res = AST_PBX_KEEPALIVE;
- return res;
+
+ ast_module_user_remove(u);
+
+ return !res ? AST_PBX_KEEPALIVE : res;
}
/*! \brief Pickup parked call */
static int park_exec(struct ast_channel *chan, void *data)
{
- int res=0;
- struct localuser *u;
+ int res = 0;
+ struct ast_module_user *u;
struct ast_channel *peer=NULL;
struct parkeduser *pu, *pl=NULL;
struct ast_context *con;
@@ -1708,7 +1712,9 @@ static int park_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Parkedcall requires an argument (extension number)\n");
return -1;
}
- LOCAL_USER_ADD(u);
+
+ u = ast_module_user_add(chan);
+
park = atoi((char *)data);
ast_mutex_lock(&parking_lock);
pu = parkinglot;
@@ -1813,7 +1819,9 @@ static int park_exec(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3 "Channel %s tried to talk to nonexistent parked call %d\n", chan->name, park);
res = -1;
}
- LOCAL_USER_REMOVE(u);
+
+ ast_module_user_remove(u);
+
return res;
}
@@ -2250,16 +2258,15 @@ static int load_config(void)
}
-static int reload(void *mod)
+static int reload(void)
{
return load_config();
}
-static int load_module(void *mod)
+static int load_module(void)
{
int res;
- __mod_desc = mod;
memset(parking_ext, 0, sizeof(parking_ext));
memset(parking_con, 0, sizeof(parking_con));
@@ -2283,9 +2290,9 @@ static int load_module(void *mod)
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
- STANDARD_HANGUP_LOCALUSERS;
+ ast_module_user_hangup_all();
ast_manager_unregister("ParkedCalls");
ast_manager_unregister("Park");
@@ -2296,14 +2303,8 @@ static int unload_module(void *mod)
return ast_unregister_application(parkedcall);
}
-static const char *description(void)
-{
- return "Call Features Resource";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_UNLOAD, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Call Features Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_indications.c b/res/res_indications.c
index 3e248a1b4..18e79e2de 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -363,7 +363,7 @@ static struct ast_cli_entry show_indications_cli =
/*
* Standard module functions ...
*/
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* remove the registed indications... */
ast_unregister_indication_country(NULL);
@@ -378,7 +378,7 @@ static int unload_module(void *mod)
}
-static int load_module(void *mod)
+static int load_module(void)
{
if (ind_load_module())
return -1;
@@ -392,7 +392,7 @@ static int load_module(void *mod)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
/* remove the registed indications... */
ast_unregister_indication_country(NULL);
@@ -400,14 +400,8 @@ static int reload(void *mod)
return ind_load_module();
}
-static const char *description(void)
-{
- return "Indications Configuration";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Indications Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 65064170e..ed6d37321 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -120,8 +120,6 @@ static struct ast_cli_entry aji_cli[] = {
{{ "jabber", "test", NULL}, aji_test, "Shows roster, but is genearlly used for mog's debugging.", test_usage },
};
-static const char *tdesc = "AJI - Asterisk Jabber Interface";
-
static char *app_ajisend = "JabberSend";
static char *ajisend_synopsis = "JabberSend(jabber,screenname,message)";
@@ -2284,7 +2282,7 @@ static void aji_reload()
}
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
ast_cli_unregister_multiple(aji_cli, sizeof(aji_cli) / sizeof(aji_cli[0]));
ast_unregister_application(app_ajisend);
@@ -2306,7 +2304,7 @@ static int unload_module(void *mod)
return 0;
}
-static int load_module(void *mod)
+static int load_module(void)
{
ASTOBJ_CONTAINER_INIT(&clients);
aji_reload();
@@ -2320,20 +2318,14 @@ static int load_module(void *mod)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
aji_reload();
return 0;
}
-static const char *description(void)
-{
- return tdesc;
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "AJI - Asterisk Jabber Interface",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 8340a6a59..86d6021af 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -632,7 +632,7 @@ static int unpause_monitor_action(struct mansession *s, struct message *m)
}
-static int load_module(void *mod)
+static int load_module(void)
{
ast_register_application("Monitor", start_monitor_exec, monitor_synopsis, monitor_descrip);
ast_register_application("StopMonitor", stop_monitor_exec, stopmonitor_synopsis, stopmonitor_descrip);
@@ -648,7 +648,7 @@ static int load_module(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
ast_unregister_application("Monitor");
ast_unregister_application("StopMonitor");
@@ -664,14 +664,8 @@ static int unload_module(void *mod)
return 0;
}
-static const char *description(void)
-{
- return "Call Monitoring Resource";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL); /* MOD_0 because it exports some symbols */
+/* usecount semantics need to be defined */
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Call Monitoring Resource",
+ .load = load_module,
+ .unload = unload_module,
+ );
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index c0d29acd3..8bcb62511 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1206,7 +1206,7 @@ static int init_classes(int reload)
return 1;
}
-static int load_module(void *mod)
+static int load_module(void)
{
int res;
@@ -1233,7 +1233,7 @@ static int load_module(void *mod)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
if (init_classes(1))
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
@@ -1241,20 +1241,13 @@ static int reload(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
return -1;
}
-static const char *description(void)
-{
- return "Music On Hold Resource";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
-
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Music On Hold Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_odbc.c b/res/res_odbc.c
index b597b2339..3d927b9a3 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -513,9 +513,7 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
return ODBC_SUCCESS;
}
-LOCAL_USER_DECL;
-
-static int reload(void *mod)
+static int reload(void)
{
static char *cfg = "res_odbc.conf";
struct ast_config *config;
@@ -658,13 +656,13 @@ static int reload(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* Prohibit unloading */
return -1;
}
-static int load_module(void *mod)
+static int load_module(void)
{
load_odbc_config();
ast_cli_register(&odbc_show_struct);
@@ -672,14 +670,8 @@ static int load_module(void *mod)
return 0;
}
-static const char *description(void)
-{
- return "ODBC Resource";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "ODBC Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 324556e40..5bb213bca 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -501,7 +501,7 @@ void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
ASTOBJ_CONTAINER_DESTROY(&iface->mwi_q);
free(iface);
- ast_atomic_fetchadd_int(&me->usecnt, -1);
+ ast_module_unref(ast_module_info->self);
}
/*!
@@ -686,7 +686,7 @@ static int smdi_load(int reload)
ASTOBJ_CONTAINER_LINK(&smdi_ifaces, iface);
ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
- ast_atomic_fetchadd_int(&me->usecnt, +1);
+ ast_module_ref(ast_module_info->self);
} else {
ast_log(LOG_NOTICE, "Ignoring unknown option %s in %s\n", v->name, config_file);
}
@@ -706,17 +706,10 @@ static int smdi_load(int reload)
return res;
}
-
-static const char *description(void)
-{
- return "Asterisk Simplified Message Desk Interface (SMDI) Module";
-}
-
-static int load_module(void *mod)
+static int load_module(void)
{
int res;
- me = mod;
/* initialize our containers */
memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
@@ -732,7 +725,7 @@ static int load_module(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* this destructor stops any running smdi_read threads */
ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
@@ -741,7 +734,7 @@ static int unload_module(void *mod)
return 0;
}
-static int reload(void *mod)
+static int reload(void)
{
int res;
@@ -756,9 +749,8 @@ static int reload(void *mod)
return 0;
}
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Simplified Message Desk Interface (SMDI) Resource",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_snmp.c b/res/res_snmp.c
index b11c88d5b..d52329372 100644
--- a/res/res_snmp.c
+++ b/res/res_snmp.c
@@ -86,7 +86,7 @@ static int load_config(void)
return 0;
}
-static int load_module(void *mod)
+static int load_module(void)
{
load_config();
@@ -99,7 +99,7 @@ static int load_module(void *mod)
return 0;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
ast_verbose(VERBOSE_PREFIX_1 "Unloading [Sub]Agent Module\n");
@@ -107,7 +107,7 @@ static int unload_module(void *mod)
return pthread_join(thread, NULL);
}
-static int reload(void *mod)
+static int reload(void)
{
ast_verbose(VERBOSE_PREFIX_1 "Reloading [Sub]Agent Module\n");
@@ -124,14 +124,8 @@ static int reload(void *mod)
return 0;
}
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
- return MODULE_DESCRIPTION;
-}
-
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "SNMP [Sub]Agent for Asterisk",
+ .load = load_module,
+ .unload = unload_module,
+ .reload = reload,
+ );
diff --git a/res/res_speech.c b/res/res_speech.c
index f99c352b9..d0af877cd 100644
--- a/res/res_speech.c
+++ b/res/res_speech.c
@@ -348,13 +348,13 @@ int ast_speech_unregister(char *engine_name)
return res;
}
-static int unload_module(void *mod)
+static int unload_module(void)
{
/* We can not be unloaded */
return -1;
}
-static int load_module(void *mod)
+static int load_module(void)
{
int res = 0;
@@ -364,14 +364,7 @@ static int load_module(void *mod)
return res;
}
-static const char *description(void)
-{
- return "Generic Speech Recognition API";
-}
-
-static const char *key(void)
-{
- return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Generic Speech Recognition API",
+ .load = load_module,
+ .unload = unload_module,
+ );