aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_adsiprog.c23
-rw-r--r--apps/app_alarmreceiver.c20
-rw-r--r--apps/app_amd.c22
-rw-r--r--apps/app_authenticate.c22
-rw-r--r--apps/app_cdr.c17
-rw-r--r--apps/app_chanisavail.c18
-rw-r--r--apps/app_channelredirect.c20
-rw-r--r--apps/app_chanspy.c18
-rw-r--r--apps/app_controlplayback.c22
-rw-r--r--apps/app_db.c20
-rw-r--r--apps/app_dial.c17
-rw-r--r--apps/app_dictate.c24
-rw-r--r--apps/app_directed_pickup.c25
-rw-r--r--apps/app_directory.c25
-rw-r--r--apps/app_disa.c21
-rw-r--r--apps/app_dumpchan.c19
-rw-r--r--apps/app_echo.c17
-rw-r--r--apps/app_exec.c17
-rw-r--r--apps/app_externalivr.c22
-rw-r--r--apps/app_festival.c21
-rw-r--r--apps/app_flash.c21
-rw-r--r--apps/app_forkcdr.c20
-rw-r--r--apps/app_getcpeid.c21
-rw-r--r--apps/app_hasnewvoicemail.c20
-rw-r--r--apps/app_ices.c21
-rw-r--r--apps/app_image.c17
-rw-r--r--apps/app_ivrdemo.c17
-rw-r--r--apps/app_lookupblacklist.c17
-rw-r--r--apps/app_lookupcidname.c25
-rw-r--r--apps/app_macro.c17
-rw-r--r--apps/app_meetme.c23
-rw-r--r--apps/app_milliwatt.c21
-rw-r--r--apps/app_mixmonitor.c28
-rw-r--r--apps/app_morsecode.c17
-rw-r--r--apps/app_mp3.c17
-rw-r--r--apps/app_nbscat.c17
-rw-r--r--apps/app_osplookup.c23
-rw-r--r--apps/app_page.c23
-rw-r--r--apps/app_parkandannounce.c19
-rw-r--r--apps/app_playback.c17
-rw-r--r--apps/app_privacy.c25
-rw-r--r--apps/app_queue.c21
-rw-r--r--apps/app_random.c17
-rw-r--r--apps/app_read.c17
-rw-r--r--apps/app_readfile.c17
-rw-r--r--apps/app_realtime.c16
-rw-r--r--apps/app_record.c22
-rw-r--r--apps/app_rpt.c16
-rw-r--r--apps/app_sayunixtime.c17
-rw-r--r--apps/app_senddtmf.c17
-rw-r--r--apps/app_sendtext.c23
-rw-r--r--apps/app_setcallerid.c17
-rw-r--r--apps/app_setcdruserfield.c17
-rw-r--r--apps/app_settransfercapability.c17
-rw-r--r--apps/app_skel.c33
-rw-r--r--apps/app_sms.c17
-rw-r--r--apps/app_softhangup.c17
-rw-r--r--apps/app_speech_utils.c24
-rw-r--r--apps/app_stack.c22
-rw-r--r--apps/app_system.c17
-rw-r--r--apps/app_talkdetect.c17
-rw-r--r--apps/app_test.c17
-rw-r--r--apps/app_transfer.c23
-rw-r--r--apps/app_url.c17
-rw-r--r--apps/app_userevent.c17
-rw-r--r--apps/app_verbose.c17
-rw-r--r--apps/app_voicemail.c23
-rw-r--r--apps/app_waitforring.c17
-rw-r--r--apps/app_waitforsilence.c16
-rw-r--r--apps/app_while.c16
-rw-r--r--apps/app_zapateller.c17
-rw-r--r--apps/app_zapbarge.c17
-rw-r--r--apps/app_zapras.c17
-rw-r--r--apps/app_zapscan.c16
-rw-r--r--asterisk.c2
-rw-r--r--cdr.c2
-rw-r--r--cdr/cdr_csv.c17
-rw-r--r--cdr/cdr_custom.c18
-rw-r--r--cdr/cdr_manager.c17
-rw-r--r--channels/chan_agent.c34
-rw-r--r--channels/chan_features.c23
-rw-r--r--channels/chan_iax2.c20
-rw-r--r--channels/chan_local.c36
-rw-r--r--channels/chan_mgcp.c31
-rw-r--r--channels/chan_oss.c15
-rw-r--r--channels/chan_phone.c15
-rw-r--r--channels/chan_sip.c17
-rw-r--r--channels/chan_skinny.c17
-rw-r--r--channels/chan_zap.c34
-rw-r--r--cli.c1
-rw-r--r--codecs/codec_a_mu.c27
-rw-r--r--codecs/codec_adpcm.c30
-rw-r--r--codecs/codec_alaw.c29
-rw-r--r--codecs/codec_g723_1.c27
-rw-r--r--codecs/codec_g726.c28
-rw-r--r--codecs/codec_gsm.c29
-rw-r--r--codecs/codec_ilbc.c27
-rw-r--r--codecs/codec_lpc10.c32
-rw-r--r--codecs/codec_speex.c37
-rw-r--r--codecs/codec_ulaw.c32
-rw-r--r--file.c25
-rw-r--r--formats/format_g723.c19
-rw-r--r--formats/format_g726.c24
-rw-r--r--formats/format_g729.c19
-rw-r--r--formats/format_gsm.c19
-rw-r--r--formats/format_h263.c19
-rw-r--r--formats/format_h264.c19
-rw-r--r--formats/format_ilbc.c20
-rw-r--r--formats/format_jpeg.c17
-rw-r--r--formats/format_ogg_vorbis.c20
-rw-r--r--formats/format_pcm.c23
-rw-r--r--formats/format_sln.c19
-rw-r--r--formats/format_vox.c19
-rw-r--r--formats/format_wav.c19
-rw-r--r--formats/format_wav_gsm.c19
-rw-r--r--funcs/func_base64.c18
-rw-r--r--funcs/func_callerid.c15
-rw-r--r--funcs/func_cdr.c15
-rw-r--r--funcs/func_channel.c15
-rw-r--r--funcs/func_curl.c17
-rw-r--r--funcs/func_cut.c17
-rw-r--r--funcs/func_db.c15
-rw-r--r--funcs/func_enum.c18
-rw-r--r--funcs/func_env.c14
-rw-r--r--funcs/func_groupcount.c15
-rw-r--r--funcs/func_language.c15
-rw-r--r--funcs/func_logic.c15
-rw-r--r--funcs/func_math.c16
-rw-r--r--funcs/func_md5.c15
-rw-r--r--funcs/func_moh.c15
-rw-r--r--funcs/func_odbc.c19
-rw-r--r--funcs/func_rand.c14
-rw-r--r--funcs/func_sha1.c15
-rw-r--r--funcs/func_strings.c14
-rw-r--r--funcs/func_timeout.c13
-rw-r--r--funcs/func_uri.c14
-rw-r--r--include/asterisk.h24
-rw-r--r--include/asterisk/file.h2
-rw-r--r--include/asterisk/module.h312
-rw-r--r--include/asterisk/translate.h6
-rw-r--r--loader.c168
-rw-r--r--pbx/pbx_ael.c20
-rw-r--r--pbx/pbx_config.c23
-rw-r--r--pbx/pbx_dundi.c27
-rw-r--r--pbx/pbx_loopback.c18
-rw-r--r--pbx/pbx_realtime.c17
-rw-r--r--pbx/pbx_spool.c18
-rw-r--r--res/res_adsi.c18
-rw-r--r--res/res_agi.c26
-rw-r--r--res/res_clioriginate.c28
-rw-r--r--res/res_config_odbc.c19
-rw-r--r--res/res_config_pgsql.c17
-rw-r--r--res/res_convert.c24
-rw-r--r--res/res_crypto.c17
-rw-r--r--res/res_features.c29
-rw-r--r--res/res_indications.c24
-rw-r--r--res/res_monitor.c25
-rw-r--r--res/res_musiconhold.c25
-rw-r--r--res/res_odbc.c20
-rw-r--r--res/res_smdi.c33
-rw-r--r--res/res_speech.c25
-rw-r--r--translate.c24
162 files changed, 1272 insertions, 2385 deletions
diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c
index 0ac46181f..ff3817032 100644
--- a/apps/app_adsiprog.c
+++ b/apps/app_adsiprog.c
@@ -59,8 +59,6 @@ static char *descrip =
" ADSIProg(script): This application programs an ADSI Phone with the given\n"
"script. If nothing is specified, the default script (asterisk.adsi) is used.\n";
-LOCAL_USER_DECL;
-
struct adsi_event {
int id;
char *name;
@@ -1568,35 +1566,32 @@ static int adsi_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
+ STANDARD_HANGUP_LOCALUSERS;
+
res = ast_unregister_application(app);
- STANDARD_HANGUP_LOCALUSERS;
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, adsi_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Asterisk ADSI Programming Application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index e26845886..2754be4f4 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -97,8 +97,6 @@ static char time_stamp_format[128] = {"%a %b %d, %Y @ %H:%M:%S %Z"};
static char event_file[14] = "/event-XXXXXX";
-LOCAL_USER_DECL;
-
/*
* Attempt to access a database variable and increment it,
* provided that the user defined db-family in alarmreceiver.conf
@@ -818,7 +816,7 @@ static int load_config(void)
*/
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -829,25 +827,21 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
load_config();
return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Alarm Receiver for Asterisk";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_amd.c b/apps/app_amd.c
index c054b2abf..16fc6bf64 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -72,9 +72,6 @@ static char *descrip =
" MAXWORDS-<%d wordsCount>-<%d maximumNumberOfWords>\n"
" LONGGREETING-<%d voiceDuration>-<%d greeting>\n";
-
-LOCAL_USER_DECL;
-
#define STATE_IN_WORD 1
#define STATE_IN_SILENCE 2
@@ -392,38 +389,33 @@ static void load_config(void)
return;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
STANDARD_HANGUP_LOCALUSERS;
return ast_unregister_application(app);
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
load_config();
return ast_register_application(app, amd_exec, synopsis, descrip);
}
-int reload(void)
+static int reload(void *mod)
{
load_config();
return 0;
}
-const char *description(void)
+static const char *description(void)
{
return "Answering Machine Detection Application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index 259789747..eb3b7184d 100644
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -91,8 +91,6 @@ static char *descrip =
" Defaults to 0 - no limit - wait for the user press the '#' key.\n"
;
-LOCAL_USER_DECL;
-
static int auth_exec(struct ast_channel *chan, void *data)
{
int res=0;
@@ -235,35 +233,31 @@ static int auth_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
+ STANDARD_HANGUP_LOCALUSERS;
+
res = ast_unregister_application(app);
- STANDARD_HANGUP_LOCALUSERS;
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, auth_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Authentication Application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/apps/app_cdr.c b/apps/app_cdr.c
index 0364bb4d9..ebf44bfe5 100644
--- a/apps/app_cdr.c
+++ b/apps/app_cdr.c
@@ -28,8 +28,6 @@
#include <sys/types.h>
#include <stdlib.h>
-#define STATIC_MODULE
-
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -63,7 +61,7 @@ static int nocdr_exec(struct ast_channel *chan, void *data)
return 0;
}
-STATIC_MODULE int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -74,24 +72,17 @@ STATIC_MODULE int unload_module(void)
return res;
}
-STATIC_MODULE int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(nocdr_app, nocdr_exec, nocdr_synopsis, nocdr_descrip);
}
-STATIC_MODULE const char *description(void)
+static const char *description(void)
{
return "Tell Asterisk to not maintain a CDR for the current call";
}
-STATIC_MODULE int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-STATIC_MODULE const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c
index 847cfc114..3cba77c4a 100644
--- a/apps/app_chanisavail.c
+++ b/apps/app_chanisavail.c
@@ -155,7 +155,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res = 0;
@@ -166,24 +166,20 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, chanavail_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Check channel availability";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_channelredirect.c b/apps/app_channelredirect.c
index f527b7d38..4817ec222 100644
--- a/apps/app_channelredirect.c
+++ b/apps/app_channelredirect.c
@@ -120,7 +120,7 @@ static int asyncgoto_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -131,26 +131,20 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, asyncgoto_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Channel Redirect";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 27ca2d3c3..37daa8162 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -554,7 +554,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
ALL_DONE(u, res);
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -565,24 +565,20 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, chanspy_exec, synopsis, desc);
}
-const char *description(void)
+static const char *description(void)
{
return (char *) synopsis;
}
-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);
diff --git a/apps/app_controlplayback.c b/apps/app_controlplayback.c
index 5d70cc452..4d47b3e88 100644
--- a/apps/app_controlplayback.c
+++ b/apps/app_controlplayback.c
@@ -154,36 +154,26 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
-
res = ast_unregister_application(app);
-
- STANDARD_HANGUP_LOCALUSERS;
-
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, controlplayback_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Control Playback Application";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/apps/app_db.c b/apps/app_db.c
index 38b7c6ade..bb4bcbd9c 100644
--- a/apps/app_db.c
+++ b/apps/app_db.c
@@ -143,41 +143,35 @@ static int del_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int retval;
retval = ast_unregister_application(dt_app);
retval |= ast_unregister_application(d_app);
- STANDARD_HANGUP_LOCALUSERS;
-
return retval;
}
-int load_module(void)
+static int load_module(void *mod)
{
int retval;
+ __mod_desc = mod;
retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
return retval;
}
-const char *description(void)
+static const char *description(void)
{
return "Database Access Functions";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 5f9e55ab6..58e3c3e0e 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -35,7 +35,6 @@
#include <sys/signal.h>
#include <netinet/in.h>
-#define STATIC_MODULE
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -1729,7 +1728,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
}
-STATIC_MODULE int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -1741,30 +1740,24 @@ STATIC_MODULE int unload_module(void)
return res;
}
-STATIC_MODULE int load_module(void)
+static int load_module(void *mod)
{
int res;
+ __mod_desc = mod;
res = ast_register_application(app, dial_exec, synopsis, descrip);
res |= ast_register_application(rapp, retrydial_exec, rsynopsis, rdescrip);
return res;
}
-STATIC_MODULE const char *description(void)
+static const char *description(void)
{
return "Dialing Application";
}
-STATIC_MODULE int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-STATIC_MODULE const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 871fc5a33..95f814096 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -46,7 +46,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/app.h"
-static char *tdesc = "Virtual Dictation Machine";
static char *app = "Dictate";
static char *synopsis = "Virtual Dictation Machine";
static char *desc = " Dictate([<base_dir>[|<filename>]])\n"
@@ -336,36 +335,27 @@ static int dictate_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
-
res = ast_unregister_application(app);
-
- STANDARD_HANGUP_LOCALUSERS;
-
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, dictate_exec, synopsis, desc);
}
-const char *description(void)
-{
- return tdesc;
-}
-
-int usecount(void)
+static const char *description(void)
{
- int res;
- STANDARD_USECOUNT(res);
- return res;
+ return "Virtual Dictation Machine";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index a8ef0e1c0..e75e34a26 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -42,7 +42,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/app.h"
-static const char *tdesc = "Directed Call Pickup Application";
static const char *app = "Pickup";
static const char *synopsis = "Directed Call Pickup";
static const char *descrip =
@@ -134,37 +133,29 @@ static int pickup_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
res = ast_unregister_application(app);
- STANDARD_HANGUP_LOCALUSERS;
-
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, pickup_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Directed Call Pickup Application";
}
-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);
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 88399897b..316720088 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -45,7 +45,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/app.h"
-static char *tdesc = "Extension Directory";
static char *app = "Directory";
static char *synopsis = "Provide directory of voicemail extensions";
@@ -517,35 +516,27 @@ static int directory_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
-
res = ast_unregister_application(app);
-
- STANDARD_HANGUP_LOCALUSERS;
-
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
+ __mod_desc = mod;
return ast_register_application(app, directory_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Extension Directory";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 29b115789..d7c3a5872 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -49,8 +49,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/callerid.h"
#include "asterisk/stringfields.h"
-static char *tdesc = "DISA (Direct Inward System Access) Application";
-
static char *app = "DISA";
static char *synopsis = "DISA (Direct Inward System Access)";
@@ -376,7 +374,7 @@ reorder:
return -1;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -387,24 +385,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, disa_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "DISA (Direct Inward System Access) Application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index e6968c89b..aa8854620 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -46,7 +46,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/utils.h"
-static char *tdesc = "Dump Info About The Calling Channel";
static char *app = "DumpChan";
static char *synopsis = "Dump Info About The Calling Channel";
static char *desc =
@@ -157,7 +156,7 @@ static int dumpchan_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -168,25 +167,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, dumpchan_exec, synopsis, desc);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Dump Info About The Calling Channel";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD1;
diff --git a/apps/app_echo.c b/apps/app_echo.c
index 803c1b592..183f843fe 100644
--- a/apps/app_echo.c
+++ b/apps/app_echo.c
@@ -95,7 +95,7 @@ static int echo_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -106,24 +106,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, echo_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_exec.c b/apps/app_exec.c
index 3f8c18b0e..33775ea72 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -160,7 +160,7 @@ static int tryexec_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -172,26 +172,21 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res = ast_register_application(app_exec, exec_exec, exec_synopsis, exec_descrip);
res |= ast_register_application(app_tryexec, tryexec_exec, tryexec_synopsis, tryexec_descrip);
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_MOD1;
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 1c378fcf2..ef35637c9 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -51,7 +51,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/utils.h"
-static const char *tdesc = "External IVR Interface Application";
static const char *app = "ExternalIVR";
@@ -551,7 +550,7 @@ static int app_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -562,26 +561,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, app_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "External IVR Interface Application";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_festival.c b/apps/app_festival.c
index ca65130fc..f06cbaef3 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -58,8 +58,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define FESTIVAL_CONFIG "festival.conf"
-static char *tdesc = "Simple Festival Interface";
-
static char *app = "Festival";
static char *synopsis = "Say text to the user";
@@ -501,7 +499,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -512,25 +510,20 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
-
return ast_register_application(app, festival_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
-}
+ return "Simple Festival Interface";
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_flash.c b/apps/app_flash.c
index e056b723e..0e3eba4dd 100644
--- a/apps/app_flash.c
+++ b/apps/app_flash.c
@@ -50,8 +50,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/image.h"
#include "asterisk/options.h"
-static char *tdesc = "Flash zap trunk application";
-
static char *app = "Flash";
static char *synopsis = "Flashes a Zap Trunk";
@@ -107,7 +105,7 @@ static int flash_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -118,24 +116,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, flash_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Flash zap trunk application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_forkcdr.c b/apps/app_forkcdr.c
index 08aca6aac..68951b038 100644
--- a/apps/app_forkcdr.c
+++ b/apps/app_forkcdr.c
@@ -42,7 +42,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cdr.h"
#include "asterisk/module.h"
-static char *tdesc = "Fork The CDR into 2 separate entities.";
static char *app = "ForkCDR";
static char *synopsis =
"Forks the Call Data Record";
@@ -98,7 +97,7 @@ static int forkcdr_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -109,24 +108,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, forkcdr_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Fork The CDR into 2 separate entities.";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_getcpeid.c b/apps/app_getcpeid.c
index e9ada0b6f..5baab8676 100644
--- a/apps/app_getcpeid.c
+++ b/apps/app_getcpeid.c
@@ -43,8 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/adsi.h"
#include "asterisk/options.h"
-static char *tdesc = "Get ADSI CPE ID";
-
static char *app = "GetCPEID";
static char *synopsis = "Get ADSI CPE ID";
@@ -133,7 +131,7 @@ static int cpeid_exec(struct ast_channel *chan, void *idata)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -144,24 +142,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, cpeid_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Get ADSI CPE ID";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c
index 96b67072e..f21bd7ae6 100644
--- a/apps/app_hasnewvoicemail.c
+++ b/apps/app_hasnewvoicemail.c
@@ -53,7 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/options.h"
-static char *tdesc = "Indicator for whether a voice mailbox has messages in a given folder.";
static char *app_hasvoicemail = "HasVoicemail";
static char *hasvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set";
static char *hasvoicemail_descrip =
@@ -219,7 +218,7 @@ struct ast_custom_function acf_vmcount = {
.read = acf_vmcount_exec,
};
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -232,7 +231,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -243,19 +242,14 @@ int load_module(void)
return res;
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Indicator for whether a voice mailbox has messages in a given folder.";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_ices.c b/apps/app_ices.c
index ae48cbb67..3a8130ab6 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -50,8 +50,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define ICES "/usr/bin/ices"
#define LOCAL_ICES "/usr/local/bin/ices"
-static char *tdesc = "Encode and Stream via icecast and ices";
-
static char *app = "ICES";
static char *synopsis = "Encode and stream using 'ices'";
@@ -191,7 +189,7 @@ static int ices_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -202,24 +200,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, ices_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Encode and Stream via icecast and ices";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_image.c b/apps/app_image.c
index 63c588e17..9e69bd4cd 100644
--- a/apps/app_image.c
+++ b/apps/app_image.c
@@ -112,7 +112,7 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -123,24 +123,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, sendimage_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_ivrdemo.c b/apps/app_ivrdemo.c
index 4147efe73..1ceedf6a7 100644
--- a/apps/app_ivrdemo.c
+++ b/apps/app_ivrdemo.c
@@ -110,7 +110,7 @@ static int skel_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -121,24 +121,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, skel_exec, tdesc, synopsis);
}
-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_MOD1;
diff --git a/apps/app_lookupblacklist.c b/apps/app_lookupblacklist.c
index 87db8f3ba..9db3d450b 100644
--- a/apps/app_lookupblacklist.c
+++ b/apps/app_lookupblacklist.c
@@ -107,7 +107,7 @@ lookupblacklist_exec (struct ast_channel *chan, void *data)
return 0;
}
-int unload_module (void)
+static int unload_module(void *mod)
{
int res;
@@ -118,24 +118,19 @@ int unload_module (void)
return res;
}
-int load_module (void)
+static int load_module(void *mod)
{
return ast_register_application (app, lookupblacklist_exec, synopsis,descrip);
}
-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_MOD1;
diff --git a/apps/app_lookupcidname.c b/apps/app_lookupcidname.c
index f279b3b69..a4af9eb96 100644
--- a/apps/app_lookupcidname.c
+++ b/apps/app_lookupcidname.c
@@ -80,8 +80,7 @@ lookupcidname_exec (struct ast_channel *chan, void *data)
return 0;
}
-int
-unload_module (void)
+static int unload_module(void *mod)
{
int res;
@@ -92,27 +91,19 @@ unload_module (void)
return res;
}
-int
-load_module (void)
+static int load_module(void *mod)
{
- return ast_register_application (app, lookupcidname_exec, synopsis,
- descrip);
+ return ast_register_application (app, lookupcidname_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return tdesc;
}
-int
-usecount (void)
+static const char *key(void)
{
- int res;
- STANDARD_USECOUNT (res);
- return res;
+ return ASTERISK_GPL_KEY;
}
-const char *key()
-{
- return ASTERISK_GPL_KEY;
-}
+STD_MOD1;
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 28674a9b6..fb3290fc1 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -343,7 +343,7 @@ static int macro_exit_exec(struct ast_channel *chan, void *data)
return MACRO_EXIT_RESULT;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -356,7 +356,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -367,19 +367,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_MOD1;
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 0a1681a3d..6ca35a241 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -60,7 +60,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h"
#include "asterisk/ulaw.h"
-static const char *tdesc = "MeetMe conference bridge";
static const char *app = "MeetMe";
static const char *app2 = "MeetMeCount";
@@ -2425,7 +2424,7 @@ static void load_config(void)
ast_config_destroy(cfg);
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -2440,7 +2439,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -2455,29 +2454,21 @@ int load_module(void)
return res;
}
-int reload(void)
+static int reload(void *mod)
{
load_config();
return 0;
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "MeetMe conference bridge";
}
-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, reload, NULL, NULL);
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c
index f40b40161..215fcb6bf 100644
--- a/apps/app_milliwatt.c
+++ b/apps/app_milliwatt.c
@@ -43,8 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/utils.h"
-static char *tdesc = "Digital Milliwatt (mu-law) Test Application";
-
static char *app = "Milliwatt";
static char *synopsis = "Generate a Constant 1000Hz tone at 0dbm (mu-law)";
@@ -140,7 +138,7 @@ static int milliwatt_exec(struct ast_channel *chan, void *data)
return -1;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -151,24 +149,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, milliwatt_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Digital Milliwatt (mu-law) Test Application";
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 43b5f7b95..d4e374a4b 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -57,7 +57,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
-static const char *tdesc = "Mixed Audio Monitoring Application";
static const char *app = "MixMonitor";
static const char *synopsis = "Record a call and mix the audio during the recording";
static const char *desc = ""
@@ -88,7 +87,7 @@ static const char *stop_desc = ""
"on the current channel.\n"
"";
-LOCAL_USER_DECL;
+struct module_symbols *me;
static const char *mixmonitor_spy_type = "MixMonitor";
@@ -169,7 +168,7 @@ static void *mixmonitor_thread(void *obj)
struct ast_frame *f;
char post_process[1024] = "";
- STANDARD_INCREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
name = ast_strdupa(mixmonitor->chan->name);
@@ -282,7 +281,7 @@ out2:
out:
free(mixmonitor);
- STANDARD_DECREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
return NULL;
}
@@ -461,7 +460,7 @@ static struct ast_cli_entry cli_mixmonitor = {
complete_mixmonitor_cli
};
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -474,7 +473,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -485,21 +484,14 @@ int load_module(void)
return res;
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Mixed Audio Monitoring Application";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_morsecode.c b/apps/app_morsecode.c
index c21fd51fb..81fe6a321 100644
--- a/apps/app_morsecode.c
+++ b/apps/app_morsecode.c
@@ -162,7 +162,7 @@ static int morsecode_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -173,24 +173,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app_morsecode, morsecode_exec, morsecode_synopsis, morsecode_descrip);
}
-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_MOD1;
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 36131784b..bfb0eb9ad 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -226,7 +226,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -237,24 +237,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, mp3_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index 36ad54db9..a557f2dfa 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -207,7 +207,7 @@ static int NBScat_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -218,24 +218,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, NBScat_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 4be14f94a..bc12f5ba0 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -596,7 +596,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
return(res);
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -610,7 +610,7 @@ int load_module(void)
return(res);
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -626,25 +626,14 @@ int unload_module(void)
return(res);
}
-int reload(void)
+static const char *description(void)
{
- return(0);
+ return "Open Settlement Protocol Applications";
}
-const char *description(void)
-{
- return("Open Settlement Protocol Applications");
-}
-
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return(res);
-}
-
-const char *key()
+static const char *key(void)
{
return(ASTERISK_GPL_KEY);
}
+STD_MOD1;
diff --git a/apps/app_page.c b/apps/app_page.c
index 720c7abb7..0dee1611f 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -45,8 +45,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/chanvars.h"
#include "asterisk/utils.h"
-static const char *tdesc = "Page Multiple Phones";
-
static const char *app_page= "Page";
static const char *page_synopsis = "Pages phones";
@@ -205,7 +203,7 @@ static int page_exec(struct ast_channel *chan, void *data)
return -1;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -216,26 +214,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app_page, page_exec, page_synopsis, page_descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Page Multiple Phones";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index 1f7393930..26f661464 100644
--- a/apps/app_parkandannounce.c
+++ b/apps/app_parkandannounce.c
@@ -255,9 +255,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
return res;
}
-
-
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -268,25 +266,20 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
/* return ast_register_application(app, park_exec); */
return ast_register_application(app, parkandannounce_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_playback.c b/apps/app_playback.c
index a9ce353ea..fc5dcf20a 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -135,7 +135,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -146,24 +146,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, playback_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_privacy.c b/apps/app_privacy.c
index 6ce7d1fb8..eb722e5a3 100644
--- a/apps/app_privacy.c
+++ b/apps/app_privacy.c
@@ -210,8 +210,7 @@ static int privacy_exec (struct ast_channel *chan, void *data)
return 0;
}
-int
-unload_module (void)
+static int unload_module(void *mod)
{
int res;
@@ -222,27 +221,19 @@ unload_module (void)
return res;
}
-int
-load_module (void)
+static int load_module(void *mod)
{
- return ast_register_application (app, privacy_exec, synopsis,
- descrip);
+ return ast_register_application (app, privacy_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return tdesc;
}
-int
-usecount (void)
+static const char *key(void)
{
- int res;
- STANDARD_USECOUNT (res);
- return res;
+ return ASTERISK_GPL_KEY;
}
-const char *key()
-{
- return ASTERISK_GPL_KEY;
-}
+STD_MOD1;
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 043d9797d..1642cf6f1 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3852,7 +3852,7 @@ static struct ast_cli_entry cli_remove_queue_member = {
{ "remove", "queue", "member", NULL }, handle_remove_queue_member,
"Removes a channel from a specified queue", rqm_cmd_usage, complete_remove_queue_member };
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -3880,7 +3880,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -3912,26 +3912,21 @@ int load_module(void)
return res;
}
-
-int reload(void)
+static int reload(void *mod)
{
reload_queues();
return 0;
}
-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, reload, NULL, NULL);
+
diff --git a/apps/app_random.c b/apps/app_random.c
index 9e42c7f28..c8a7f8287 100644
--- a/apps/app_random.c
+++ b/apps/app_random.c
@@ -95,7 +95,7 @@ static int random_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -106,24 +106,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app_random, random_exec, random_synopsis, random_descrip);
}
-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_MOD1;
diff --git a/apps/app_read.c b/apps/app_read.c
index 94afc523d..fa1c01c92 100644
--- a/apps/app_read.c
+++ b/apps/app_read.c
@@ -221,7 +221,7 @@ static int read_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -232,24 +232,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, read_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_readfile.c b/apps/app_readfile.c
index 833ae9c7c..f0c1215ae 100644
--- a/apps/app_readfile.c
+++ b/apps/app_readfile.c
@@ -107,7 +107,7 @@ static int readfile_exec(struct ast_channel *chan, void *data)
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -118,24 +118,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app_readfile, readfile_exec, readfile_synopsis, readfile_descrip);
}
-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_MOD1;
diff --git a/apps/app_realtime.c b/apps/app_realtime.c
index 9cce38ca7..dacc6c328 100644
--- a/apps/app_realtime.c
+++ b/apps/app_realtime.c
@@ -232,7 +232,7 @@ static int realtime_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -246,7 +246,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -258,20 +258,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_MOD1;
diff --git a/apps/app_record.c b/apps/app_record.c
index 864714f56..38d6437e7 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -29,8 +29,6 @@
#include <stdio.h>
#include <string.h>
-#define STATIC_MODULE
-
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -46,7 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/options.h"
-static char *tdesc = "Trivial Record Application";
static char *app = "Record";
@@ -343,7 +340,7 @@ static int record_exec(struct ast_channel *chan, void *data)
return res;
}
-STATIC_MODULE int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -354,26 +351,19 @@ STATIC_MODULE int unload_module(void)
return res;
}
-STATIC_MODULE int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, record_exec, synopsis, descrip);
}
-STATIC_MODULE const char *description(void)
-{
- return tdesc;
-}
-
-STATIC_MODULE int usecount(void)
+static const char *description(void)
{
- int res;
- STANDARD_USECOUNT(res);
- return res;
+ return "Trivial Record Application";
}
-STATIC_MODULE const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-STD_MOD(MOD_1, NULL, NULL, NULL);
+STD_MOD1;
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index d4e817799..d919fc23e 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -7023,7 +7023,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int i;
@@ -7041,7 +7041,7 @@ int unload_module(void)
return i;
}
-int load_module(void)
+static int load_module(void *mod)
{
ast_pthread_create(&rpt_master_thread,NULL,rpt_master,NULL);
@@ -7052,20 +7052,14 @@ int load_module(void)
return ast_register_application(app, rpt_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c
index b70d074bc..9b208ca2e 100644
--- a/apps/app_sayunixtime.c
+++ b/apps/app_sayunixtime.c
@@ -107,7 +107,7 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -119,7 +119,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -129,19 +129,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_MOD1;
diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index 10c803a27..9ba21d2f3 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -93,7 +93,7 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -104,24 +104,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, senddtmf_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c
index e6bb80e79..87f0f0bec 100644
--- a/apps/app_sendtext.c
+++ b/apps/app_sendtext.c
@@ -46,8 +46,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/options.h"
#include "asterisk/app.h"
-static const char *tdesc = "Send Text Applications";
-
static const char *app = "SendText";
static const char *synopsis = "Send a Text Message";
@@ -118,7 +116,7 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -129,26 +127,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, sendtext_exec, synopsis, descrip);
}
-const char *description(void)
-{
- return (char *) tdesc;
-}
-
-int usecount(void)
+static const char *description(void)
{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
+ return "Send Text Applications";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c
index d1c0c0aa4..5d34859fc 100644
--- a/apps/app_setcallerid.c
+++ b/apps/app_setcallerid.c
@@ -136,7 +136,7 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -148,7 +148,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -158,19 +158,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_MOD1;
diff --git a/apps/app_setcdruserfield.c b/apps/app_setcdruserfield.c
index 80d56d2f3..165f2c60c 100644
--- a/apps/app_setcdruserfield.c
+++ b/apps/app_setcdruserfield.c
@@ -137,7 +137,7 @@ static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -150,7 +150,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -161,19 +161,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_MOD1;
diff --git a/apps/app_settransfercapability.c b/apps/app_settransfercapability.c
index 7b07ad0f6..2bf4e01f8 100644
--- a/apps/app_settransfercapability.c
+++ b/apps/app_settransfercapability.c
@@ -111,7 +111,7 @@ static int settransfercapability_exec(struct ast_channel *chan, void *data)
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -122,24 +122,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, settransfercapability_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return synopsis;
}
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_skel.c b/apps/app_skel.c
index 25a431182..598170d2e 100644
--- a/apps/app_skel.c
+++ b/apps/app_skel.c
@@ -43,7 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/app.h"
-static char *tdesc = "Trivial skeleton Application";
static char *app = "Skel";
static char *synopsis =
"Skeleton application.";
@@ -119,44 +118,26 @@ static int app_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
-
res = ast_unregister_application(app);
-
- STANDARD_HANGUP_LOCALUSERS;
-
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, app_exec, synopsis, descrip);
}
-int reload(void)
-{
- /* This function will be called if a 'reload' is requested */
-
- return 0;
-}
-
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Trivial skeleton Application";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_sms.c b/apps/app_sms.c
index 373ca8906..c3488b911 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1511,7 +1511,7 @@ static int sms_exec (struct ast_channel *chan, void *data)
return (h.err);
}
-int unload_module (void)
+static int unload_module(void *mod)
{
int res;
@@ -1522,7 +1522,7 @@ int unload_module (void)
return res;
}
-int load_module (void)
+static int load_module(void *mod)
{
#ifdef OUTALAW
{
@@ -1536,19 +1536,14 @@ int load_module (void)
return ast_register_application (app, sms_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_softhangup.c b/apps/app_softhangup.c
index a651dce63..a987f317a 100644
--- a/apps/app_softhangup.c
+++ b/apps/app_softhangup.c
@@ -105,7 +105,7 @@ static int softhangup_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -116,24 +116,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, softhangup_exec, synopsis, desc);
}
-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_MOD1;
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index babf39b5d..8cd6046e4 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -723,7 +723,7 @@ static int speech_destroy(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res = 0;
@@ -746,7 +746,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res = 0;
@@ -767,26 +767,14 @@ int load_module(void)
return res;
}
-int reload(void)
-{
- return 0;
-}
-
-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_MOD1;
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 87a7bf177..1734f0311 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -44,7 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define STACKVAR "~GOSUB~STACK~"
-static const char *tdesc = "Stack Routines";
static const char *app_gosub = "Gosub";
static const char *app_gosubif = "GosubIf";
@@ -152,7 +151,7 @@ static int gosubif_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
ast_unregister_application(app_return);
ast_unregister_application(app_pop);
@@ -164,7 +163,7 @@ int unload_module(void)
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
ast_register_application(app_pop, pop_exec, pop_synopsis, pop_descrip);
ast_register_application(app_return, return_exec, return_synopsis, return_descrip);
@@ -174,21 +173,14 @@ int load_module(void)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Stack Routines";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_system.c b/apps/app_system.c
index 12e46c828..6a13f6b49 100644
--- a/apps/app_system.c
+++ b/apps/app_system.c
@@ -136,7 +136,7 @@ static int trysystem_exec(struct ast_channel *chan, void *data)
return system_exec_helper(chan, data, 0);
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -148,7 +148,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -158,19 +158,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_MOD1;
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 012893b47..dadde6a02 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -214,7 +214,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -225,24 +225,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, background_detect_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_test.c b/apps/app_test.c
index 04e1d5377..db822b6c6 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -490,7 +490,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -502,7 +502,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -512,19 +512,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(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_transfer.c b/apps/app_transfer.c
index 67f67fe8a..8bd046097 100644
--- a/apps/app_transfer.c
+++ b/apps/app_transfer.c
@@ -47,8 +47,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
LOCAL_USER_DECL;
-static const char *tdesc = "Transfer";
-
static const char *app = "Transfer";
static const char *synopsis = "Transfer caller to remote extension";
@@ -144,7 +142,7 @@ static int transfer_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -155,26 +153,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, transfer_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Transfer";
}
-int usecount(void)
-{
- int res;
-
- STANDARD_USECOUNT(res);
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/apps/app_url.c b/apps/app_url.c
index eb59bf513..7d34d9d9b 100644
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -161,7 +161,7 @@ out:
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -172,24 +172,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, sendurl_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_userevent.c b/apps/app_userevent.c
index ddcec710e..c476c71fe 100644
--- a/apps/app_userevent.c
+++ b/apps/app_userevent.c
@@ -99,7 +99,7 @@ static int userevent_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -110,24 +110,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, userevent_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_verbose.c b/apps/app_verbose.c
index 4d2e8fcc2..eb698f0b8 100644
--- a/apps/app_verbose.c
+++ b/apps/app_verbose.c
@@ -150,7 +150,7 @@ static int log_exec(struct ast_channel *chan, void *data)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -162,7 +162,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -172,19 +172,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_MOD1;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index ae061de3c..d64c4963e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6389,12 +6389,12 @@ static int load_config(void)
}
}
-int reload(void)
+static int reload(void *mod)
{
return(load_config());
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -6411,7 +6411,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
res = ast_register_application(app, vm_exec, synopsis_vm, descrip_vm);
@@ -6443,11 +6443,6 @@ int load_module(void)
return res;
}
-const char *description(void)
-{
- return tdesc;
-}
-
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
{
int cmd = 0;
@@ -6860,18 +6855,16 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
if (cmd == 't')
cmd = 0;
return cmd;
- }
+}
-
-int usecount(void)
+static const char *description(void)
{
- int res;
- STANDARD_USECOUNT(res);
- return res;
+ return tdesc;
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/apps/app_waitforring.c b/apps/app_waitforring.c
index 35784502d..466061f7f 100644
--- a/apps/app_waitforring.c
+++ b/apps/app_waitforring.c
@@ -120,7 +120,7 @@ static int waitforring_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -131,24 +131,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, waitforring_exec, synopsis, desc);
}
-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_MOD1;
diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c
index f00516b29..17ffd8985 100644
--- a/apps/app_waitforsilence.c
+++ b/apps/app_waitforsilence.c
@@ -175,7 +175,7 @@ static int waitforsilence_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -186,25 +186,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, waitforsilence_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_while.c b/apps/app_while.c
index b3b520fb3..075a5276a 100644
--- a/apps/app_while.c
+++ b/apps/app_while.c
@@ -325,7 +325,7 @@ static int while_end_exec(struct ast_channel *chan, void *data) {
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -338,7 +338,7 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -349,20 +349,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_MOD1;
diff --git a/apps/app_zapateller.c b/apps/app_zapateller.c
index e5f49777a..39c9f701b 100644
--- a/apps/app_zapateller.c
+++ b/apps/app_zapateller.c
@@ -104,7 +104,7 @@ static int zapateller_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -115,24 +115,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, zapateller_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_zapbarge.c b/apps/app_zapbarge.c
index d71095f5b..ad77a6e4b 100644
--- a/apps/app_zapbarge.c
+++ b/apps/app_zapbarge.c
@@ -302,7 +302,7 @@ out:
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -313,24 +313,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, conf_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_zapras.c b/apps/app_zapras.c
index 3cf46a631..d918b7d24 100644
--- a/apps/app_zapras.c
+++ b/apps/app_zapras.c
@@ -240,7 +240,7 @@ static int zapras_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -251,24 +251,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, zapras_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c
index 55a629422..affa16d6a 100644
--- a/apps/app_zapscan.c
+++ b/apps/app_zapscan.c
@@ -363,7 +363,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
@@ -374,25 +374,19 @@ int unload_module(void)
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
return ast_register_application(app, conf_exec, synopsis, descrip);
}
-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_MOD1;
diff --git a/asterisk.c b/asterisk.c
index ad3218aac..642f1b5d8 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -101,7 +101,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/callerid.h"
-#include "asterisk/module.h"
+// XXX #include "asterisk/module.h"
#include "asterisk/image.h"
#include "asterisk/tdd.h"
#include "asterisk/term.h"
diff --git a/cdr.c b/cdr.c
index d9d5fb70c..707a1a55a 100644
--- a/cdr.c
+++ b/cdr.c
@@ -53,7 +53,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/sched.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
-#include "asterisk/module.h"
+// XXX #include "asterisk/module.h"
#include "asterisk/stringfields.h"
/*! Default AMA flag for billing records (CDR's) */
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 3ce99ec12..9150e5773 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -311,12 +311,12 @@ static int csv_log(struct ast_cdr *cdr)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
return desc;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
if (mf)
fclose(mf);
@@ -324,7 +324,7 @@ int unload_module(void)
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -339,18 +339,15 @@ int load_module(void)
return res;
}
-int reload(void)
+static int reload(void *mod)
{
load_config();
return 0;
}
-int usecount(void)
-{
- return 0;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index 100db6c07..6aad620d8 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -137,12 +137,12 @@ static int custom_log(struct ast_cdr *cdr)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
return desc;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
if (mf)
fclose(mf);
@@ -150,7 +150,7 @@ int unload_module(void)
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res = 0;
@@ -164,17 +164,15 @@ int load_module(void)
return res;
}
-int reload(void)
+static int reload(void *mod)
{
return load_config(1);
}
-int usecount(void)
-{
- return 0;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
+
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index ed99a5690..c24130df7 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -135,18 +135,18 @@ static int manager_log(struct ast_cdr *cdr)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
return desc;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
ast_cdr_unregister(name);
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -161,18 +161,15 @@ int load_module(void)
return res;
}
-int reload(void)
+static int reload(void *mod)
{
loadconfigurationfile();
return 0;
}
-int usecount(void)
-{
- return 0;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index d5b565f55..46cce1f87 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -73,7 +73,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/monitor.h"
#include "asterisk/stringfields.h"
-static const char desc[] = "Agent Proxy Channel";
static const char tdesc[] = "Call Agent Proxy Channel";
static const char config[] = "agents.conf";
@@ -163,9 +162,6 @@ static int autologoffunavail = 0;
static int maxlogintries = 3;
static char agentgoodbye[AST_MAX_FILENAME_LEN] = "vm-goodbye";
-static int usecnt =0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
static int recordagentcalls = 0;
static char recordformat[AST_MAX_BUF] = "";
static char recordformatext[AST_MAX_BUF] = "";
@@ -727,9 +723,8 @@ static int agent_hangup(struct ast_channel *ast)
* as in apps/app_chanisavail.c:chanavail_exec()
*/
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
+ /* XXX do we need ast_update_use_count(); */
ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
if (p->start && (ast->_state != AST_STATE_UP)) {
@@ -931,9 +926,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
ast_setstate(tmp, state);
tmp->tech_pvt = p;
p->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
ast_update_use_count();
tmp->priority = 1;
/* Wake up and wait for other applications (by definition the login app)
@@ -1651,8 +1644,6 @@ static struct ast_cli_entry cli_agent_logoff = {
{ "agent", "logoff", NULL }, agent_logoff_cmd,
"Sets an agent offline", agent_logoff_usage, complete_agent_logoff_cmd };
-LOCAL_USER_DECL;
-
/*!
* \brief Log in agent application.
*
@@ -2484,8 +2475,9 @@ struct ast_custom_function agent_function = {
*
* @returns int Always 0.
*/
-int load_module()
+static int load_module(void *mod)
{
+ __mod_desc = mod;
/* Make sure we can register our agent channel type */
if (ast_channel_register(&agent_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
@@ -2511,7 +2503,7 @@ int load_module()
return 0;
}
-int reload()
+static int reload(void *mod)
{
read_agent_config();
if (persistent_agents)
@@ -2519,7 +2511,7 @@ int reload()
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
struct agent_pvt *p;
/* First, take us out of the channel loop */
@@ -2553,18 +2545,14 @@ int unload_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description()
+static const char *description(void)
{
- return (char *) desc;
+ return "Agent Proxy Channel";
}
+STD_MOD(MOD_0, reload, NULL, NULL);
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 7dacc2e2c..a1eb195ab 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -63,7 +63,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/manager.h"
#include "asterisk/stringfields.h"
-static const char desc[] = "Feature Proxy Channel";
static const char tdesc[] = "Feature Proxy Channel Driver";
static int usecnt =0;
@@ -535,7 +534,7 @@ static struct ast_cli_entry cli_show_features = {
{ "feature", "show", "channels", NULL }, features_show,
"Show status of feature channels", show_features_usage, NULL };
-int load_module()
+static int load_module(void *mod)
{
/* Make sure we can register our sip channel type */
if (ast_channel_register(&features_tech)) {
@@ -546,12 +545,7 @@ int load_module()
return 0;
}
-int reload()
-{
- return 0;
-}
-
-int unload_module()
+static int unload_module(void *mod)
{
struct feature_pvt *p;
@@ -574,18 +568,15 @@ int unload_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description()
+static const char *description(void)
{
- return (char *) desc;
+ return "Feature Proxy Channel";
}
+STD_MOD(MOD_1, NULL, NULL, NULL);
+
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 56ae4c03e..27270868e 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -152,7 +152,6 @@ static int nochecksums = 0;
static struct ast_codec_pref prefs;
-static const char desc[] = "Inter Asterisk eXchange (Ver 2)";
static const char tdesc[] = "Inter Asterisk eXchange Driver (Ver 2)";
static char context[80] = "default";
@@ -9358,7 +9357,7 @@ static int iax2_reload(int fd, int argc, char *argv[])
return reload_config();
}
-int reload(void)
+static int reload(void *mod)
{
return reload_config();
}
@@ -10054,7 +10053,7 @@ static int __unload_module(void)
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
ast_mutex_destroy(&iaxq.lock);
ast_mutex_destroy(&userl.lock);
@@ -10066,7 +10065,7 @@ int unload_module()
/*! \brief Load IAX2 module, load configuraiton ---*/
-int load_module(void)
+static int load_module(void *mod)
{
char *config = "iax.conf";
int res = 0;
@@ -10158,17 +10157,14 @@ int load_module(void)
return res;
}
-const char *description()
+static const char *description(void)
{
- return (char *) desc;
+ return "Inter Asterisk eXchange (Ver 2)";
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/channels/chan_local.c b/channels/chan_local.c
index d994fb908..5705dc905 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -61,12 +61,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/manager.h"
#include "asterisk/stringfields.h"
-static const char desc[] = "Local Proxy Channel";
static const char tdesc[] = "Local Proxy Channel Driver";
-static int usecnt =0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
#define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
static struct ast_channel *local_request(const char *type, int format, void *data, int *cause);
@@ -395,9 +391,7 @@ static int local_hangup(struct ast_channel *ast)
p->owner = NULL;
ast->tech_pvt = NULL;
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
if (!p->owner && !p->chan) {
/* Okay, done with the private part now, too. */
@@ -510,9 +504,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
tmp2->tech_pvt = p;
p->owner = tmp;
p->chan = tmp2;
- ast_mutex_lock(&usecnt_lock);
- usecnt += 2; /* we allocate 2 new channels */
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, +2); /* we allocate 2 new channels */
ast_update_use_count();
ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
ast_copy_string(tmp2->context, p->context, sizeof(tmp2->context));
@@ -564,8 +556,10 @@ static struct ast_cli_entry cli_show_locals = {
"Show status of local channels", show_locals_usage, NULL };
/*! \brief Load module into PBX, register channel */
-int load_module()
+static int load_module(void *mod)
{
+ __mod_desc = mod;
+
/* Make sure we can register our channel type */
if (ast_channel_register(&local_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
@@ -575,14 +569,8 @@ int load_module()
return 0;
}
-/*! \brief Reload module */
-int reload()
-{
- return 0;
-}
-
/*! \brief Unload the local proxy channel from Asterisk */
-int unload_module()
+static int unload_module(void *mod)
{
struct local_pvt *p;
@@ -604,18 +592,14 @@ int unload_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description()
+static const char *description(void)
{
- return (char *) desc;
+ return "Local Proxy Channel";
}
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 6fda77a48..ffba65f70 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -137,7 +137,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define INADDR_NONE (in_addr_t)(-1)
#endif
-static const char desc[] = "Media Gateway Control Protocol (MGCP)";
static const char tdesc[] = "Media Gateway Control Protocol (MGCP)";
static const char config[] = "mgcp.conf";
@@ -242,8 +241,6 @@ static int amaflags = 0;
static int adsi = 0;
-static int usecnt =0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* SC: transaction id should always be positive */
static unsigned int oseq;
@@ -1057,9 +1054,7 @@ static int mgcp_hangup(struct ast_channel *ast)
}
/* SC: Decrement use count */
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
ast_update_use_count();
/* SC: Decrement use count */
@@ -1480,9 +1475,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
if (i->amaflags)
tmp->amaflags = i->amaflags;
sub->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
ast_update_use_count();
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
@@ -4323,10 +4316,11 @@ static int reload_config(void)
}
/*! \brief load_module: PBX load module - initialization ---*/
-int load_module()
+static int load_module(void *mod)
{
int res;
+ __mod_desc = mod;
sched = sched_context_create();
if (!sched) {
ast_log(LOG_WARNING, "Unable to create schedule context\n");
@@ -4377,13 +4371,13 @@ static int mgcp_reload(int fd, int argc, char *argv[])
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
mgcp_reload(0, 0, NULL);
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
struct mgcp_endpoint *e;
struct mgcp_gateway *g;
@@ -4455,17 +4449,14 @@ int unload_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description()
+static const char *description(void)
{
- return (char *) desc;
+ return "Media Gateway Control Protocol (MGCP)";
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 140ed21bd..8ee16dc33 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1462,7 +1462,7 @@ error:
return NULL;
}
-int load_module(void)
+static int load_module(void *mod)
{
int i;
struct ast_config *cfg;
@@ -1497,7 +1497,7 @@ int load_module(void)
}
-int unload_module()
+static int unload_module(void *mod)
{
struct chan_oss_pvt *o;
@@ -1521,17 +1521,14 @@ int unload_module()
return 0;
}
-const char *description()
+static const char *description(void)
{
return (char *)oss_tech.description;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index b556aa820..15c87dad1 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -1303,12 +1303,12 @@ static int __unload_module(void)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
return __unload_module();
}
-int load_module()
+static int load_module(void *mod)
{
struct ast_config *cfg;
struct ast_variable *v;
@@ -1415,17 +1415,14 @@ int load_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return (char *) desc;
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8bef7aa74..2f123918d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -13675,7 +13675,7 @@ static int sip_reload(int fd, int argc, char *argv[])
}
/*! \brief reload: Part of Asterisk module interface */
-int reload(void)
+static int reload(void *mod)
{
return sip_reload(0, 0, NULL);
}
@@ -13711,7 +13711,7 @@ static struct ast_cli_entry my_clis[] = {
};
/*! \brief load_module: PBX load module - initialization */
-int load_module()
+static int load_module(void *mod)
{
ASTOBJ_CONTAINER_INIT(&userl); /* User object list */
ASTOBJ_CONTAINER_INIT(&peerl); /* Peer object list */
@@ -13766,7 +13766,7 @@ int load_module()
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
struct sip_pvt *p, *pl;
@@ -13852,19 +13852,14 @@ int unload_module()
return 0;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description()
+static const char *description(void)
{
return (char *) desc;
}
-
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index e47864824..411215397 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -3259,7 +3259,7 @@ static void delete_devices(void)
ast_mutex_unlock(&devicelock);
}
-int reload(void)
+static int reload(void *mod)
{
delete_devices();
reload_config();
@@ -3268,7 +3268,7 @@ int reload(void)
}
-int load_module()
+static int load_module(void *mod)
{
int res = 0;
@@ -3305,7 +3305,7 @@ int load_module()
return res;
}
-int unload_module()
+static int unload_module(void *mod)
{
#if 0
struct skinny_session *session, s;
@@ -3360,17 +3360,14 @@ int unload_module()
return -1;
}
-int usecount()
-{
- return usecnt;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-const char *description(void)
+static const char *description(void)
{
return "Skinny Client Control Protocol (Skinny)";
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index ce0bcd461..c7341d29c 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -148,14 +148,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
/*! \brief Signaling types that need to use MF detection should be placed in this macro */
#define NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB))
-static const char desc[] = "Zapata Telephony"
-#ifdef ZAPATA_PRI
- " w/PRI"
-#endif
-#ifdef ZAPATA_R2
- " w/R2"
-#endif
-;
static const char tdesc[] = "Zapata Telephony Driver"
#ifdef ZAPATA_PRI
@@ -10367,7 +10359,7 @@ static int __unload_module(void)
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
#ifdef ZAPATA_PRI
int y;
@@ -11225,7 +11217,7 @@ static int setup_zap(int reload)
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -11374,7 +11366,7 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
}
-int reload(void)
+static int reload(void *mod)
{
int res = 0;
@@ -11386,18 +11378,20 @@ int reload(void)
return 0;
}
-int usecount()
+static const char *description(void)
{
- return usecnt;
-}
-
-const char *description()
-{
- return (char *) desc;
+ return "Zapata Telephony"
+#ifdef ZAPATA_PRI
+ " w/PRI"
+#endif
+#ifdef ZAPATA_R2
+ " w/R2"
+#endif
+ ;
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/cli.c b/cli.c
index 40d1cd59c..c61f5a5c8 100644
--- a/cli.c
+++ b/cli.c
@@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/options.h"
#include "asterisk/cli.h"
#include "asterisk/linkedlists.h"
+#define MOD_LOADER
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/channel.h"
diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c
index 2f5400de6..51e38e9cf 100644
--- a/codecs/codec_a_mu.c
+++ b/codecs/codec_a_mu.c
@@ -111,8 +111,6 @@ static struct ast_frame *ulawtoalaw_sample(void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator alawtoulaw = {
.name = "alawtoulaw",
.srcfmt = AST_FORMAT_ALAW,
@@ -121,7 +119,6 @@ static struct ast_translator alawtoulaw = {
.sample = alawtoulaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
static struct ast_translator ulawtoalaw = {
@@ -132,24 +129,19 @@ static struct ast_translator ulawtoalaw = {
.sample = ulawtoalaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
/*! \brief standard module glue */
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&ulawtoalaw);
res |= ast_unregister_translator(&alawtoulaw);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
int x;
@@ -157,25 +149,22 @@ int load_module(void)
mu2a[x] = AST_LIN2A(AST_MULAW(x));
a2mu[x] = AST_LIN2MU(AST_ALAW(x));
}
- res = ast_register_translator(&alawtoulaw);
+ res = ast_register_translator(&alawtoulaw, mod);
if (!res)
- res = ast_register_translator(&ulawtoalaw);
+ res = ast_register_translator(&ulawtoalaw, mod);
else
ast_unregister_translator(&alawtoulaw);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "A-law and Mulaw direct Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c
index 83ff54fba..e9ee5b35d 100644
--- a/codecs/codec_adpcm.c
+++ b/codecs/codec_adpcm.c
@@ -27,6 +27,7 @@
* \ingroup codecs
*/
+
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
@@ -326,8 +327,6 @@ static struct ast_frame *lintoadpcm_sample(void)
return &f;
}
-struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator adpcmtolin = {
.name = "adpcmtolin",
.srcfmt = AST_FORMAT_ADPCM,
@@ -338,7 +337,6 @@ static struct ast_translator adpcmtolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintoadpcm = {
@@ -351,7 +349,6 @@ static struct ast_translator lintoadpcm = {
.desc_size = sizeof (struct adpcm_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/ 2, /* 2 samples per byte */
- .lockp = &me,
};
static void parse_config(void)
@@ -371,47 +368,40 @@ static void parse_config(void)
}
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoadpcm);
res |= ast_unregister_translator(&adpcmtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&adpcmtolin);
+ res = ast_register_translator(&adpcmtolin, mod);
if (!res)
- res = ast_register_translator(&lintoadpcm);
+ res = ast_register_translator(&lintoadpcm, mod);
else
ast_unregister_translator(&adpcmtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "Adaptive Differential PCM Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_alaw.c b/codecs/codec_alaw.c
index 1178f1416..d654e21e4 100644
--- a/codecs/codec_alaw.c
+++ b/codecs/codec_alaw.c
@@ -109,8 +109,6 @@ static struct ast_frame *lintoalaw_sample(void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator alawtolin = {
.name = "alawtolin",
.srcfmt = AST_FORMAT_ALAW,
@@ -120,7 +118,6 @@ static struct ast_translator alawtolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintoalaw = {
@@ -131,7 +128,6 @@ static struct ast_translator lintoalaw = {
.sample = lintoalaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
- .lockp = &me,
};
static void parse_config(void)
@@ -152,47 +148,40 @@ static void parse_config(void)
/*! \brief standard module stuff */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoalaw);
res |= ast_unregister_translator(&alawtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&alawtolin);
+ res = ast_register_translator(&alawtolin, mod);
if (!res)
- res = ast_register_translator(&lintoalaw);
+ res = ast_register_translator(&lintoalaw, mod);
else
ast_unregister_translator(&alawtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "A-law Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_g723_1.c b/codecs/codec_g723_1.c
index d6e1d1b22..00a5ca635 100644
--- a/codecs/codec_g723_1.c
+++ b/codecs/codec_g723_1.c
@@ -265,8 +265,6 @@ static struct ast_frame *lintog723_frameout(void *pvt)
return ast_trans_frameout(pvt, cnt, samples);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator g723tolin = {
.name =
#ifdef ANNEX_B
@@ -280,7 +278,6 @@ static struct ast_translator g723tolin = {
.framein = g723tolin_framein,
.sample = g723tolin_sample,
.desc_size = sizeof(struct ...),
- .lockp = &me,
};
static struct ast_translator lintog723 = {
@@ -297,36 +294,31 @@ static struct ast_translator lintog723 = {
.frameout = lintog723_frameout,
.destroy = g723_destroy,
.sample = lintog723_sample,
- .lockp = &me,
.desc_size = sizeof(struct ...),
};
/*! \brief standard module glue */
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintog723);
res |= ast_unregister_translator(&g723tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
- res=ast_register_translator(&g723tolin);
+ res=ast_register_translator(&g723tolin, mod);
if (!res)
- res=ast_register_translator(&lintog723);
+ res=ast_register_translator(&lintog723, mod);
else
ast_unregister_translator(&g723tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
#ifdef ANNEX_B
return "Annex B (floating point) G.723.1/PCM16 Codec Translator";
@@ -336,12 +328,9 @@ const char *description(void)
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c
index e3e766b47..3b979eb63 100644
--- a/codecs/codec_g726.c
+++ b/codecs/codec_g726.c
@@ -775,8 +775,6 @@ static struct ast_frame *lintog726_sample (void)
return &f;
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator g726tolin = {
.name = "g726tolin",
.srcfmt = AST_FORMAT_G726,
@@ -788,7 +786,6 @@ static struct ast_translator g726tolin = {
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
- .lockp = &me,
};
static struct ast_translator lintog726 = {
@@ -801,7 +798,6 @@ static struct ast_translator lintog726 = {
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/2,
- .lockp = &me,
};
static void parse_config(void)
@@ -823,47 +819,39 @@ static void parse_config(void)
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module (void)
+static int unload_module (void *mod)
{
int res;
- ast_mutex_lock (&me.lock);
res = ast_unregister_translator (&lintog726);
res |= ast_unregister_translator (&g726tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock (&me.lock);
return res;
}
-int load_module (void)
+static int load_module (void *mod)
{
int res;
parse_config();
- res = ast_register_translator (&g726tolin);
+ res = ast_register_translator (&g726tolin, mod);
if (!res)
- res = ast_register_translator (&lintog726);
+ res = ast_register_translator (&lintog726, mod);
else
ast_unregister_translator (&g726tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "ITU G.726-32kbps G726 Transcoder";
}
-int usecount (void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c
index df20d9b2a..e9a85bc38 100644
--- a/codecs/codec_gsm.c
+++ b/codecs/codec_gsm.c
@@ -203,8 +203,6 @@ static void gsm_destroy_stuff(struct ast_trans_pvt *pvt)
gsm_destroy(tmp->gsm);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator gsmtolin = {
.name = "gsmtolin",
.srcfmt = AST_FORMAT_GSM,
@@ -213,7 +211,6 @@ static struct ast_translator gsmtolin = {
.framein = gsmtolin_framein,
.destroy = gsm_destroy_stuff,
.sample = gsmtolin_sample,
- .lockp = &me,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.desc_size = sizeof (struct gsm_translator_pvt ),
@@ -229,7 +226,6 @@ static struct ast_translator lintogsm = {
.frameout = lintogsm_frameout,
.destroy = gsm_destroy_stuff,
.sample = lintogsm_sample,
- .lockp = &me,
.desc_size = sizeof (struct gsm_translator_pvt ),
.buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
};
@@ -252,48 +248,41 @@ static void parse_config(void)
}
/*! \brief standard module glue */
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintogsm);
if (!res)
res = ast_unregister_translator(&gsmtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&gsmtolin);
+ res = ast_register_translator(&gsmtolin, mod);
if (!res)
- res=ast_register_translator(&lintogsm);
+ res=ast_register_translator(&lintogsm, mod);
else
ast_unregister_translator(&gsmtolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "GSM/PCM16 (signed linear) Codec Translator";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_ilbc.c b/codecs/codec_ilbc.c
index 1c9339403..cc4f88307 100644
--- a/codecs/codec_ilbc.c
+++ b/codecs/codec_ilbc.c
@@ -190,8 +190,6 @@ static struct ast_frame *lintoilbc_frameout(struct ast_trans_pvt *pvt)
return ast_trans_frameout(pvt, datalen, samples);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator ilbctolin = {
.name = "ilbctolin",
.srcfmt = AST_FORMAT_ILBC,
@@ -201,7 +199,6 @@ static struct ast_translator ilbctolin = {
.sample = ilbctolin_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = BUFFER_SAMPLES * 2,
- .lockp = &me,
};
static struct ast_translator lintoilbc = {
@@ -214,43 +211,35 @@ static struct ast_translator lintoilbc = {
.sample = lintoilbc_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = (BUFFER_SAMPLES * ILBC_FRAME_LEN + ILBC_SAMPLES - 1) / ILBC_SAMPLES,
- .lockp = &me,
};
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoilbc);
res |= ast_unregister_translator(&ilbctolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
- res=ast_register_translator(&ilbctolin);
+ res = ast_register_translator(&ilbctolin, mod);
if (!res)
- res=ast_register_translator(&lintoilbc);
+ res=ast_register_translator(&lintoilbc, mod);
else
ast_unregister_translator(&ilbctolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return tdesc;
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, NULL, NULL, NULL);
diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c
index 192c94c87..1904368b9 100644
--- a/codecs/codec_lpc10.c
+++ b/codecs/codec_lpc10.c
@@ -240,8 +240,6 @@ static void lpc10_destroy(struct ast_trans_pvt *arg)
free(pvt->lpc10.enc);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator lpc10tolin = {
.name = "lpc10tolin",
.srcfmt = AST_FORMAT_LPC10,
@@ -250,7 +248,6 @@ static struct ast_translator lpc10tolin = {
.framein = lpc10tolin_framein,
.destroy = lpc10_destroy,
.sample = lpc10tolin_sample,
- .lockp = &me,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.plc_samples = LPC10_SAMPLES_PER_FRAME,
@@ -266,7 +263,6 @@ static struct ast_translator lintolpc10 = {
.frameout = lintolpc10_frameout,
.destroy = lpc10_destroy,
.sample = lintolpc10_sample,
- .lockp = &me,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME),
@@ -289,49 +285,41 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintolpc10);
- if (!res)
- res = ast_unregister_translator(&lpc10tolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&lpc10tolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&lpc10tolin);
+ res=ast_register_translator(&lpc10tolin, mod);
if (!res)
- res=ast_register_translator(&lintolpc10);
+ res=ast_register_translator(&lintolpc10, mod);
else
ast_unregister_translator(&lpc10tolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "LPC10 2.4kbps (signed linear) Voice Coder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c
index 86d20b52b..2f31fb4d5 100644
--- a/codecs/codec_speex.c
+++ b/codecs/codec_speex.c
@@ -337,8 +337,6 @@ static void lintospeex_destroy(struct ast_trans_pvt *arg)
speex_bits_destroy(&pvt->bits);
}
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator speextolin = {
.name = "speextolin",
.srcfmt = AST_FORMAT_SPEEX,
@@ -350,7 +348,6 @@ static struct ast_translator speextolin = {
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
- .lockp = &me,
};
static struct ast_translator lintospeex = {
@@ -365,10 +362,8 @@ static struct ast_translator lintospeex = {
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */
- .lockp = &me,
};
-
static void parse_config(void)
{
struct ast_config *cfg = ast_config_load("codecs.conf");
@@ -479,7 +474,7 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
/*
* XXX reloading while there are active sessions is
@@ -487,48 +482,40 @@ int reload(void)
* wouldn't work anymore...
* maybe we shuld do a standard hangup localusers ?
*/
- ast_mutex_lock(&me.lock);
+ ast_mutex_lock(&__mod_desc->lock);
parse_config();
- ast_mutex_lock(&me.lock);
+ ast_mutex_lock(&__mod_desc->lock);
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintospeex);
- if (!res)
- res = ast_unregister_translator(&speextolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&speextolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res=ast_register_translator(&speextolin);
+ res=ast_register_translator(&speextolin, mod);
if (!res)
- res=ast_register_translator(&lintospeex);
+ res=ast_register_translator(&lintospeex, mod);
else
ast_unregister_translator(&speextolin);
return res;
}
-const char *description(void)
+static const char *description(void)
{
return "Speex/PCM16 (signed linear) Codec Translator";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c
index d1fba8247..0db01de7c 100644
--- a/codecs/codec_ulaw.c
+++ b/codecs/codec_ulaw.c
@@ -118,15 +118,12 @@ static struct ast_frame *lintoulaw_sample(void)
* \brief The complete translator for ulawToLin.
*/
-static struct ast_module_lock me = { .usecnt = -1 };
-
static struct ast_translator ulawtolin = {
.name = "ulawtolin",
.srcfmt = AST_FORMAT_ULAW,
.dstfmt = AST_FORMAT_SLINEAR,
.framein = ulawtolin_framein,
.sample = ulawtolin_sample,
- .lockp = &me,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
@@ -142,7 +139,6 @@ static struct ast_translator lintoulaw = {
.dstfmt = AST_FORMAT_ULAW,
.framein = lintoulaw_framein,
.sample = lintoulaw_sample,
- .lockp = &me,
.buf_size = BUFFER_SAMPLES,
.buffer_samples = BUFFER_SAMPLES,
};
@@ -163,32 +159,27 @@ static void parse_config(void)
ast_config_destroy(cfg);
}
-int reload(void)
+static int reload(void *mod)
{
parse_config();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
int res;
- ast_mutex_lock(&me.lock);
res = ast_unregister_translator(&lintoulaw);
- if (!res)
- res = ast_unregister_translator(&ulawtolin);
- if (me.usecnt)
- res = -1;
- ast_mutex_unlock(&me.lock);
+ res |= ast_unregister_translator(&ulawtolin);
return res;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
parse_config();
- res = ast_register_translator(&ulawtolin);
+ res = ast_register_translator(&ulawtolin, mod);
if (!res)
- res = ast_register_translator(&lintoulaw);
+ res = ast_register_translator(&lintoulaw, mod);
else
ast_unregister_translator(&ulawtolin);
return res;
@@ -198,17 +189,14 @@ int load_module(void)
* Return a description of this module.
*/
-const char *description(void)
+static const char *description(void)
{
return "Mu-law Coder/Decoder";
}
-int usecount(void)
-{
- return me.usecnt;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1, reload, NULL, NULL);
diff --git a/file.c b/file.c
index b55c9546e..aba90813b 100644
--- a/file.c
+++ b/file.c
@@ -51,6 +51,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/pbx.h"
#include "asterisk/linkedlists.h"
+#define MOD_LOADER
#include "asterisk/module.h" /* ast_update_use_count() */
/*
@@ -69,8 +70,8 @@ int ast_format_register(const struct ast_format *f)
{
struct ast_format *tmp;
- if (f->lockp == NULL) {
- ast_log(LOG_WARNING, "Missing lock pointer, you need to supply one\n");
+ if (f->module == NULL) {
+ ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n");
return -1;
}
if (AST_LIST_LOCK(&formats)) {
@@ -101,10 +102,6 @@ int ast_format_register(const struct ast_format *f)
}
memset(&tmp->list, 0, sizeof(tmp->list));
- if (tmp->lockp->usecnt < 0) {
- ast_mutex_init(&tmp->lockp->lock);
- tmp->lockp->usecnt = 0;
- }
AST_LIST_INSERT_HEAD(&formats, tmp, list);
AST_LIST_UNLOCK(&formats);
@@ -319,12 +316,7 @@ static int fn_wrapper(struct ast_filestream *s, const char *comment, enum wrap_f
ast_log(LOG_WARNING, "Unable to rewrite format %s\n", f->name);
else {
/* preliminary checks succeed. update usecount */
- if (ast_mutex_lock(&f->lockp->lock)) {
- ast_log(LOG_WARNING, "Unable to lock format %s\n", f->name);
- return -1;
- }
- f->lockp->usecnt++;
- ast_mutex_unlock(&f->lockp->lock);
+ ast_atomic_fetchadd_int(&f->module->usecnt, +1);
ret = 0;
ast_update_use_count();
}
@@ -749,13 +741,8 @@ int ast_closestream(struct ast_filestream *f)
fclose(f->f);
if (f->vfs)
ast_closestream(f->vfs);
- if (ast_mutex_lock(&f->fmt->lockp->lock)) {
- ast_log(LOG_WARNING, "Unable to lock format %s\n", f->fmt->name);
- } else {
- f->fmt->lockp->usecnt--;
- ast_mutex_unlock(&f->fmt->lockp->lock);
- ast_update_use_count();
- }
+ ast_atomic_fetchadd_int(&f->fmt->module->usecnt, -1);
+ ast_update_use_count();
free(f);
return 0;
}
diff --git a/formats/format_g723.c b/formats/format_g723.c
index 4beba0c64..5de56d86c 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -138,8 +138,6 @@ static off_t g723_tell(struct ast_filestream *fs)
return -1;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format g723_1_f = {
.name = "g723sf",
.exts = "g723|g723sf",
@@ -150,30 +148,27 @@ static const struct ast_format g723_1_f = {
.tell = g723_tell,
.read = g723_read,
.buf_size = G723_MAX_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&g723_1_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(g723_1_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "G.723.1 Simple Timestamp File Format";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_g726.c b/formats/format_g726.c
index d72f48991..61b06b47e 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -190,8 +190,6 @@ static off_t g726_tell(struct ast_filestream *fs)
return -1;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format f[] = {
{
.name = "g726-40",
@@ -206,7 +204,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
},
{
.name = "g726-32",
@@ -221,7 +219,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
},
{
.name = "g726-24",
@@ -236,7 +234,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
},
{
.name = "g726-16",
@@ -251,7 +249,7 @@ static const struct ast_format f[] = {
.read = g726_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
},
{ .format = 0 } /* terminator */
};
@@ -259,7 +257,7 @@ static const struct ast_format f[] = {
/*
* Module interface (load_module, unload_module, usecount, description, key)
*/
-int load_module()
+static int load_module(void *mod)
{
int i;
@@ -272,7 +270,7 @@ int load_module()
return 0;
}
-int unload_module()
+static int unload_module(void *mod)
{
int i;
@@ -283,18 +281,14 @@ int unload_module()
return(0);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw G.726 (16/24/32/40kbps) data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD1;
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 1719e3a5c..387641e7a 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -134,8 +134,6 @@ static off_t g729_tell(struct ast_filestream *fs)
return (offset/BUF_SIZE)*G729A_SAMPLES;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format g729_f = {
.name = "g729",
.exts = "g729",
@@ -146,30 +144,27 @@ static const struct ast_format g729_f = {
.tell = g729_tell,
.read = g729_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&g729_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(g729_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw G729 data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index 423088c17..46d943394 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -156,8 +156,6 @@ static off_t gsm_tell(struct ast_filestream *fs)
return (offset/GSM_FRAME_SIZE)*GSM_SAMPLES;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format gsm_f = {
.name = "gsm",
.exts = "gsm",
@@ -168,30 +166,27 @@ static const struct ast_format gsm_f = {
.tell = gsm_tell,
.read = gsm_read,
.buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, /* 2 gsm frames */
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&gsm_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(gsm_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw GSM data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_h263.c b/formats/format_h263.c
index c64e001fd..602943dbc 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -163,8 +163,6 @@ static off_t h263_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format h263_f = {
.name = "h263",
.exts = "h264",
@@ -177,30 +175,27 @@ static const struct ast_format h263_f = {
.read = h263_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct h263_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&h263_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(h263_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw h263 data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_h264.c b/formats/format_h264.c
index 26db782e5..5c4ddf8f0 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -156,8 +156,6 @@ static off_t h264_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format h264_f = {
.name = "h264",
.exts = "h264",
@@ -170,30 +168,27 @@ static const struct ast_format h264_f = {
.read = h264_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct h264_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&h264_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(h264_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw h264 data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 940abf25f..154dc17ab 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -132,8 +132,6 @@ static off_t ilbc_tell(struct ast_filestream *fs)
return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format ilbc_f = {
.name = "iLBC",
.exts = "ilbc",
@@ -144,31 +142,27 @@ static const struct ast_format ilbc_f = {
.tell = ilbc_tell,
.read = ilbc_read,
.buf_size = ILBC_BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&ilbc_f);
}
-
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(ilbc_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw iLBC data";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 01f4d929a..a66b21fbc 100644
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -115,30 +115,25 @@ static struct ast_imager jpeg_format = {
jpeg_write_image,
};
-int load_module()
+static int load_module(void *mod)
{
return ast_image_register(&jpeg_format);
}
-int unload_module()
+static int unload_module(void *mod)
{
ast_image_unregister(&jpeg_format);
return 0;
}
-int usecount()
-{
- /* We never really have any users */
- return 0;
-}
-
-const char *description()
+static const char *description(void)
{
return desc;
}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT, NULL, NULL, NULL);
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index ee12e6a8f..69a43f0fd 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -523,8 +523,6 @@ static off_t ogg_vorbis_tell(struct ast_filestream *s)
return -1;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format vorbis_f = {
.name = "ogg_vorbis",
.exts = "ogg",
@@ -539,31 +537,27 @@ static const struct ast_format vorbis_f = {
.close = ogg_vorbis_close,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct vorbis_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&vorbis_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(vorbis_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "OGG/Vorbis audio";
}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 889e7afc2..c2b626240 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -414,8 +414,6 @@ static off_t au_tell(struct ast_filestream *fs)
return offset - AU_HEADER_SIZE;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format alaw_f = {
.name = "alaw",
.exts = "alaw|al",
@@ -426,7 +424,7 @@ static const struct ast_format alaw_f = {
.tell = pcm_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
#ifdef REALTIME_WRITE
.open = pcma_open,
.rewrite = pcma_rewrite,
@@ -444,7 +442,7 @@ static const struct ast_format pcm_f = {
.tell = pcm_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
static const struct ast_format au_f = {
@@ -459,10 +457,10 @@ static const struct ast_format au_f = {
.tell = au_tell,
.read = pcm_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, /* this many shorts */
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
int index;
@@ -476,23 +474,20 @@ int load_module()
|| ast_format_register(&au_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(pcm_f.name) || ast_format_unregister(alaw_f.name)
|| ast_format_unregister(au_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw/Sun uLaw/ALaw 8khz Audio support (PCM,PCMA,AU)";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 3e4d2e0c9..4a78aa900 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -116,8 +116,6 @@ static off_t slinear_tell(struct ast_filestream *fs)
return ftello(fs->f) / 2;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format slin_f = {
.name = "sln",
.exts = "sln|raw",
@@ -128,30 +126,27 @@ static const struct ast_format slin_f = {
.tell = slinear_tell,
.read = slinear_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&slin_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(slin_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Raw Signed Linear Audio support (SLN)";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_vox.c b/formats/format_vox.c
index b1f7e688a..8e5220143 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -121,8 +121,6 @@ static off_t vox_tell(struct ast_filestream *fs)
return offset;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format vox_f = {
.name = "vox",
.exts = "vox",
@@ -133,30 +131,27 @@ static const struct ast_format vox_f = {
.tell = vox_tell,
.read = vox_read,
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&vox_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(vox_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Dialogic VOX (ADPCM) File Format";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_wav.c b/formats/format_wav.c
index eb3b2d5ad..cc610ef53 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -498,8 +498,6 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - 44)/2;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format wav_f = {
.name = "wav",
.exts = "wav",
@@ -514,30 +512,27 @@ static const struct ast_format wav_f = {
.close = wav_close,
.buf_size = WAV_BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct wav_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&wav_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(wav_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Microsoft WAV format (8000hz Signed Linear)";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index dedc8f9d9..d3abbd2f0 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -541,8 +541,6 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES;
}
-static struct ast_format_lock me = { .usecnt = -1 };
-
static const struct ast_format wav49_f = {
.name = "wav49",
.exts = "WAV|wav49",
@@ -557,30 +555,27 @@ static const struct ast_format wav49_f = {
.close = wav_close,
.buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct wavg_desc),
- .lockp = &me,
+ .module = &mod_data, /* XXX */
};
-int load_module()
+static int load_module(void *mod)
{
return ast_format_register(&wav49_f);
}
-int unload_module()
+static int unload_module(void *mod)
{
return ast_format_unregister(wav49_f.name);
}
-int usecount()
-{
- return me.usecnt;
-}
-
-const char *description()
+static const char *description(void)
{
return "Microsoft WAV format (Proprietary GSM)";
}
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD1;
diff --git a/funcs/func_base64.c b/funcs/func_base64.c
index 872416e96..3353078fa 100644
--- a/funcs/func_base64.c
+++ b/funcs/func_base64.c
@@ -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);
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index b277df1c5..e87ed11a7 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -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);
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 20373ec8d..26fb045bd 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -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);
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 8d60f4ccd..16aebb4c2 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -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);
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 0260b9bbe..7d55f9b08 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -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);
diff --git a/funcs/func_cut.c b/funcs/func_cut.c
index 434a2f940..69f4ac123 100644
--- a/funcs/func_cut.c
+++ b/funcs/func_cut.c
@@ -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);
diff --git a/funcs/func_db.c b/funcs/func_db.c
index 492389e58..f7439302b 100644
--- a/funcs/func_db.c
+++ b/funcs/func_db.c
@@ -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);
diff --git a/funcs/func_enum.c b/funcs/func_enum.c
index 542eb04e1..2a409ffee 100644
--- a/funcs/func_enum.c
+++ b/funcs/func_enum.c
@@ -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);
diff --git a/funcs/func_env.c b/funcs/func_env.c
index 4d8564803..d89927775 100644
--- a/funcs/func_env.c
+++ b/funcs/func_env.c
@@ -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);
diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c
index 88bf0572a..d3bf627a5 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -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);
diff --git a/funcs/func_language.c b/funcs/func_language.c
index 268038862..a3a47d5ef 100644
--- a/funcs/func_language.c
+++ b/funcs/func_language.c
@@ -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);
diff --git a/funcs/func_logic.c b/funcs/func_logic.c
index 9f3e78cd9..aebcb4c17 100644
--- a/funcs/func_logic.c
+++ b/funcs/func_logic.c
@@ -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);
diff --git a/funcs/func_math.c b/funcs/func_math.c
index 0928a2da4..3ad32fdac 100644
--- a/funcs/func_math.c
+++ b/funcs/func_math.c
@@ -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);
+
diff --git a/funcs/func_md5.c b/funcs/func_md5.c
index 5455694d8..e05e0141d 100644
--- a/funcs/func_md5.c
+++ b/funcs/func_md5.c
@@ -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);
diff --git a/funcs/func_moh.c b/funcs/func_moh.c
index 029b715df..61c19bb4a 100644
--- a/funcs/func_moh.c
+++ b/funcs/func_moh.c
@@ -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);
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index c76937fb4..56332e970 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -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);
diff --git a/funcs/func_rand.c b/funcs/func_rand.c
index 053bcf524..2c0818b3d 100644
--- a/funcs/func_rand.c
+++ b/funcs/func_rand.c
@@ -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);
diff --git a/funcs/func_sha1.c b/funcs/func_sha1.c
index d2b5ad882..8a9fabfd0 100644
--- a/funcs/func_sha1.c
+++ b/funcs/func_sha1.c
@@ -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);
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index 5da638ce0..7445b64a5 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -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);
diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c
index 75b328e80..e1133865e 100644
--- a/funcs/func_timeout.c
+++ b/funcs/func_timeout.c
@@ -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);
diff --git a/funcs/func_uri.c b/funcs/func_uri.c
index e39ee6001..dbef5608d 100644
--- a/funcs/func_uri.c
+++ b/funcs/func_uri.c
@@ -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);
diff --git a/include/asterisk.h b/include/asterisk.h
index 7e63f608c..8e8683211 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -74,16 +74,32 @@ void dnsmgr_start_refresh(void);
int dnsmgr_reload(void);
/*!
+ * \brief Reload asterisk modules.
+ * \param name the name of the module to reload
+ *
+ * This function reloads the specified module, or if no modules are specified,
+ * it will reload all loaded modules.
+ *
+ * \note Modules are reloaded using their reload() functions, not unloading
+ * them and loading them again.
+ *
+ * \return Zero if the specified module was not found, 1 if the module was
+ * found but cannot be reloaded, -1 if a reload operation is already in
+ * progress, and 2 if the specfied module was found and reloaded.
+ */
+int ast_module_reload(const char *name);
+
+/*!
* \brief Register a function to be executed before Asterisk exits.
* \param func The callback function to use.
- *
+ *
* \return Zero on success, -1 on error.
*/
int ast_register_atexit(void (*func)(void));
-
-/*!
+
+/*!
* \brief Unregister a function registered with ast_register_atexit().
- * \param func The callback function to unregister.
+ * \param func The callback function to unregister.
*/
void ast_unregister_atexit(void (*func)(void));
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index 905ea0a0d..f8ac14b04 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -106,7 +106,7 @@ struct ast_format {
int buf_size; /*! size of frame buffer, if any, aligned to 8 bytes. */
int desc_size; /*! size of private descriptor, if any */
- struct ast_format_lock *lockp;
+ struct module_symbols *module;
};
/*
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index dfee1b1a3..1b1e434a6 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -26,7 +26,11 @@
#ifndef _ASTERISK_MODULE_H
#define _ASTERISK_MODULE_H
-#include "asterisk/linkedlists.h" /* XXX needed here */
+#ifdef STATIC_MODULE
+#error STATIC_MODULE should not be defined
+#endif
+#define STATIC_MODULE --- this is an error
+#define LOCAL_USER_DECL /* --- this is an error --- */
#include "asterisk/utils.h"
@@ -34,83 +38,6 @@
extern "C" {
#endif
-#ifdef STATIC_MODULE /* symbols are static */
-#define _HAVE_STATIC_MODULE
-#undef STATIC_MODULE
-#define STATIC_MODULE static /* symbols are static */
-#else /* !STATIC_MODULE, symbols are global */
-#define STATIC_MODULE /* empty - symbols are global */
-
-/*! \note Every module should provide these functions */
-/*!
- * \brief Initialize the module.
- *
- * This function is called at module load time. Put all code in here
- * that needs to set up your module's hardware, software, registrations,
- * etc.
- *
- * \return This function should return 0 on success and non-zero on failure.
- * If the module is not loaded successfully, Asterisk will call its
- * unload_module() function.
- */
-int load_module(void);
-
-/*!
- * \brief Cleanup all module structures, sockets, etc.
- *
- * This is called at exit. Any registrations and memory allocations need to be
- * unregistered and free'd here. Nothing else will do these for you (until
- * exit).
- *
- * \return Zero on success, or non-zero on error.
- */
-int unload_module(void);
-
-/*!
- * \brief Provides a usecount.
- *
- * This function will be called by various parts of asterisk. Basically, all
- * it has to do is to return a usecount when called. You will need to maintain
- * your usecount within the module somewhere. The usecount should be how many
- * channels provided by this module are in use.
- *
- * \return The module's usecount.
- */
-int usecount(void); /* How many channels provided by this module are in use? */
-
-/*! \brief Provides a description of the module.
- *
- * \return a short description of your module
- */
-const char *description(void); /* Description of this module */
-
-/*!
- * \brief Returns the ASTERISK_GPL_KEY
- *
- * This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of
- * the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does
- * not return the EXACT message:
- *
- * \code
- * char *key(void) {
- * return ASTERISK_GPL_KEY;
- * }
- * \endcode
- *
- * \return ASTERISK_GPL_KEY
- */
-const char *key(void); /* Return the below mentioned key, unmodified */
-
-/*!
- * \brief Reload stuff.
- *
- * This function is where any reload routines take place. Re-read config files,
- * change signalling, whatever is appropriate on a reload.
- *
- * \return The return value is not used.
- */
-int reload(void); /* reload configs */
-#endif /* !STATIC_MODULE case */
/*! \brief The text the key() function should return. */
#define ASTERISK_GPL_KEY \
@@ -128,32 +55,12 @@ express written permission of Digium, Inc. is prohibited.\n"
#define AST_MODULE_CONFIG "modules.conf" /*!< \brief Module configuration file */
-/*!
- * \brief Softly unload a module.
- *
- * This flag signals ast_unload_resource() to unload a module only if it is not
- * in use, according to the module's usecount.
- */
-#define AST_FORCE_SOFT 0
-
-/*!
- * \brief Firmly unload a module.
- *
- * This flag signals ast_unload_resource() to attempt to unload a module even
- * if it is in use. It will attempt to use the module's unload_module
- * function.
- */
-#define AST_FORCE_FIRM 1
-
-/*!
- * \brief Unconditionally unload a module.
- *
- * This flag signals ast_unload_resource() to first attempt to unload a module
- * using the module's unload_module function, then if that fails to unload the
- * module using dlclose. The module will be unloaded even if it is still in
- * use. Use of this flag is not recommended.
- */
-#define AST_FORCE_HARD 2
+enum unload_mode {
+ AST_FORCE_SOFT = 0, /*! Softly unload a module, only if not in use */
+ AST_FORCE_FIRM = 1, /*! Firmly unload a module, even if in use */
+ AST_FORCE_HARD = 2, /*! as FIRM, plus dlclose() on the module. Not recommended
+ as it may cause crashes */
+};
/*!
* \brief Load a module.
@@ -180,7 +87,7 @@ int ast_load_resource(const char *resource_name);
*
* \return Zero on success, -1 on error.
*/
-int ast_unload_resource(const char *resource_name, int force);
+int ast_unload_resource(const char *resource_name, enum unload_mode);
/*!
* \brief Notify when usecount has been changed.
@@ -227,22 +134,6 @@ int ast_loader_register(int (*updater)(void));
int ast_loader_unregister(int (*updater)(void));
/*!
- * \brief Reload asterisk modules.
- * \param name the name of the module to reload
- *
- * This function reloads the specified module, or if no modules are specified,
- * it will reload all loaded modules.
- *
- * \note Modules are reloaded using their reload() functions, not unloading
- * them and loading them again.
- *
- * \return Zero if the specified module was not found, 1 if the module was
- * found but cannot be reloaded, -1 if a reload operation is already in
- * progress, and 2 if the specfied module was found and reloaded.
- */
-int ast_module_reload(const char *name);
-
-/*!
* \brief Match modules names for the Asterisk cli.
* \param line Unused by this function, but this should be the line we are
* matching.
@@ -265,114 +156,19 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
they're in use at the time they have been requested to be removed */
struct localuser {
+ struct localuser *next;
struct ast_channel *chan;
- AST_LIST_ENTRY(localuser) next;
-};
-
-/*! \brief structure used for lock and refcount of module users.
- * \note The mutex protects the usecnt field and whatever needs to be
- * protected (typically, a list of struct localuser).
- * As a trick, if usecnt is initialized with -1,
- * ast_format_register will init the mutex for you.
- */
-struct ast_module_lock {
- ast_mutex_t lock;
- AST_LIST_HEAD_NOLOCK(localuser_head, localuser) u;
- int usecnt; /* number of active clients */
};
-struct localuser *ast_localuser_add(struct ast_module_lock *m, struct ast_channel *chan);
-void ast_localuser_remove(struct ast_module_lock *m, struct localuser *u);
-void ast_hangup_localusers(struct ast_module_lock *m);
-
-/*!
- * \brief create a localuser mutex and several other variables used for keeping the
- * use count.
- *
- * <b>Sample Usage:</b>
- * \code
- * LOCAL_USER_DECL;
- * \endcode
- */
-#define LOCAL_USER_DECL \
- static struct ast_module_lock me = { \
- .u = AST_LIST_HEAD_NOLOCK_INIT_VALUE, \
- .usecnt = 0, \
- .lock = AST_MUTEX_INIT_VALUE }
-
-#define STANDARD_USECOUNT_DECL LOCAL_USER_DECL /* XXX lock remains unused */
-
-/*! \brief run 'x' protected by lock, then call ast_update_use_count() */
-#define __MOD_PROTECT(x) do { \
- ast_mutex_lock(&me.lock); \
- x; \
- ast_mutex_unlock(&me.lock); \
- ast_update_use_count(); \
- } while (0)
-
-#define STANDARD_INCREMENT_USECOUNT __MOD_PROTECT(me.usecnt++)
-#define STANDARD_DECREMENT_USECOUNT __MOD_PROTECT(me.usecnt--)
-
-/*!
- * \brief Add a localuser.
- * \param u a pointer to a localuser struct
- *
- * This macro adds a localuser to the list of users and increments the
- * usecount. It expects a variable named \p chan of type \p ast_channel in the
- * current scope.
- *
- * \note This function dynamically allocates memory. If this operation fails
- * it will cause your function to return -1 to the caller.
- */
-#define LOCAL_USER_ADD(u) do { \
- u = ast_localuser_add(&me, chan); \
- if (!u) \
- return -1; \
- } while (0)
-
-/*!
- * \brief Remove a localuser.
- * \param u the user to add, should be of type struct localuser
- *
- * This macro removes a localuser from the list of users and decrements the
- * usecount.
- */
-#define LOCAL_USER_REMOVE(u) ast_localuser_remove(&me, u)
-
-/*!
- * \brief Hangup all localusers.
- *
- * This macro hangs up on all current localusers and sets the usecount to zero
- * when finished.
- */
-#define STANDARD_HANGUP_LOCALUSERS ast_hangup_localusers(&me)
+struct module_symbols; /* forward declaration */
+struct localuser *ast_localuser_add(struct module_symbols *, struct ast_channel *);
+void ast_localuser_remove(struct module_symbols *, struct localuser *);
+void ast_hangup_localusers(struct module_symbols *);
-/*!
- * \brief Set the specfied integer to the current usecount.
- * \param res the integer variable to set.
- *
- * This macro sets the specfied integer variable to the local usecount.
- *
- * <b>Sample Usage:</b>
- * \code
- * int usecount(void)
- * {
- * int res;
- * STANDARD_USECOUNT(res);
- * return res;
- * }
- * \endcode
- */
-#define STANDARD_USECOUNT(res) do { res = me.usecnt; } while (0)
-
-/*! \brief Old usecount macro
- * \note XXX The following macro is deprecated, and only used by modules
- * in codecs/ and a few other places which do their own manipulation
- * of the usecount variable.
- * Its use is supposed to be gradually phased away as those modules
- * are updated to use the standard mechanism.
- */
-#define OLD_STANDARD_USECOUNT(res) do { res = localusecnt; } while (0)
+/* XXX deprecated macros, only for backward compatibility */
+#define LOCAL_USER_ADD(u) do { u = ast_localuser_add(__mod_desc, chan); } while (0)
+#define LOCAL_USER_REMOVE(u) ast_localuser_remove(__mod_desc, u)
+#define STANDARD_HANGUP_LOCALUSERS ast_hangup_localusers(__mod_desc)
/*! \page ModMngmnt The Asterisk Module management interface
* \par The following is part of the new module management code.
@@ -388,7 +184,7 @@ void ast_hangup_localusers(struct ast_module_lock *m);
*
* Functions should be added with MOD_FUNC(name),
* data structures with MOD_DATA(_name).
- * The array in turn is referenced by struct module_symbol.
+ * The array in turn is referenced by struct module_symbols.
* (Typically, a module will export only a single symbol, which points
* to a record containing all the methods. This is the API of the module,
* and should be known to the module's clients as well.
@@ -403,7 +199,7 @@ void ast_hangup_localusers(struct ast_module_lock *m);
* to figure out if there is a mismatch (not terribly useful because most
* objects are a single word, but still... )
* The symbol can be added to the array with MOD_WANT(symbol) macro.
- * required_symbols is also pointed by through struct module_symbol.
+ * required_symbols is also pointed by through struct module_symbols.
*
* Typically, the whole interface exported by a module should be
* in a single structure named after the module, as follows.
@@ -501,25 +297,50 @@ struct ast_registry {
};
struct module_symbols {
- int (*load_module)(void);
- int (*unload_module)(void);
- int (*usecount)(void);
- const char *(*description)(void);
- const char *(*key)(void);
- int (*reload)(void);
- enum module_type {
- MOD_0, /* old module style */
- MOD_1, /* old style, but symbols here */
- MOD_2, /* new style, exported symbols */
- } type;
- struct ast_registry *reg;
+ /* load, reload and unload receive as argument a pointer to a module descriptor
+ * to be stored locally and used for local calls and so on.
+ * They all return 0 on success, non zero (-1) on failure.
+ */
+
+ int (*load_module)(void *); /* register stuff etc. Optional. */
+
+ int (*reload)(void *); /* reload config etc. Optional. */
+
+ int (*unload_module)(void *); /* unload. called with the module locked */
+
+ const char *(*description)(void); /* textual id of the module. */
+
+ /*!
+ * This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of
+ * the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does
+ * not return the EXACT message:
+ */
+ const char *(*key)(void); /*! the asterisk key */
+
+ enum module_flags {
+ MOD_0 = 0x0, /* old module style */
+ MOD_1 = 0x1, /* old style, but symbols here */
+ MOD_2 = 0x2, /* new style, exported symbols */
+ MOD_MASK = 0xf, /* mask for module types */
+ NO_USECOUNT = 0x10, /* do not track usecount */
+ NO_UNLOAD = 0x20, /* only forced unload allowed */
+ DO_LOCALUSERS = 0x40, /* track localusers */
+ } flags;
+ /* the following two fields should go in the astobj. */
+ ast_mutex_t lock;
+ int usecnt; /* number of active clients */
+
+ /* list of clients */
+ struct localuser *lu_head;
+ struct ast_registry *reg; /* list of things to register. */
struct symbol_entry *exported_symbols;
struct symbol_entry *required_symbols;
};
-#ifndef _HAVE_STATIC_MODULE
-#define STD_MOD(t, reload_fn, exp, req)
-#else
+#ifndef MOD_LOADER /* the loader does not use these */
+struct module_symbols mod_data; /* forward declaration */
+static struct module_symbols *__mod_desc __attribute__ ((__unused__)) = &mod_data; /* used by localuser */
+
#define STD_MOD(t, reload_fn, exp, req) \
struct module_symbols mod_data = { \
.load_module = load_module, \
@@ -527,12 +348,13 @@ struct module_symbols mod_data = { \
.description = description, \
.key = key, \
.reload = reload_fn, \
- .usecount = usecount, \
- .type = t, \
+ .flags = t, \
.exported_symbols = exp, \
.required_symbols = req \
};
-#endif /* _HAVE_STATIC_MODULE */
+
+#define STD_MOD1 STD_MOD(MOD_1, NULL, NULL, NULL)
+#endif
#if defined(__cplusplus) || defined(c_plusplus)
}
diff --git a/include/asterisk/translate.h b/include/asterisk/translate.h
index 8f1a86759..a83cfa41e 100644
--- a/include/asterisk/translate.h
+++ b/include/asterisk/translate.h
@@ -33,7 +33,7 @@ extern "C" {
#include "asterisk/frame.h"
#include "asterisk/plc.h"
#include "asterisk/linkedlists.h"
-#include "asterisk/module.h"
+// XXX #include "asterisk/module.h"
#endif
struct ast_trans_pvt; /* declared below */
@@ -98,7 +98,7 @@ struct ast_translator {
int plc_samples; /* set to the plc block size if used, 0 otherwise */
int useplc; /* current status of plc, changed at runtime */
- struct ast_module_lock *lockp;
+ void *module; /* opaque reference to the parent module */
int cost; /*! Cost in milliseconds for encoding/decoding 1 second of sound */
AST_LIST_ENTRY(ast_translator) list; /*! link field */
@@ -147,7 +147,7 @@ struct ast_trans_pvt;
* This registers a codec translator with asterisk
* Returns 0 on success, -1 on failure
*/
-int ast_register_translator(struct ast_translator *t);
+int ast_register_translator(struct ast_translator *t, void *module);
/*!
* \brief Unregister a translator
diff --git a/loader.c b/loader.c
index b423084b7..d6a0496cc 100644
--- a/loader.c
+++ b/loader.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
+#define MOD_LOADER /* prevent some module-specific stuff from being compiled */
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -94,7 +95,7 @@ enum st_t { /* possible states of a module */
*/
struct module {
AST_LIST_ENTRY(module) next;
- struct module_symbols cb;
+ struct module_symbols *cb;
void *lib; /* the shared lib */
char resource[256];
@@ -118,43 +119,53 @@ AST_MUTEX_DEFINE_STATIC(reloadlock);
* the extra function call will be totally negligible in all cases.
*/
-struct localuser *ast_localuser_add(struct ast_module_lock *m,
+struct localuser *ast_localuser_add(struct module_symbols *me,
struct ast_channel *chan)
{
struct localuser *u = ast_calloc(1, sizeof(*u));
if (u == NULL)
return NULL;
u->chan = chan;
- ast_mutex_lock(&m->lock);
- AST_LIST_INSERT_HEAD(&m->u, u, next);
- m->usecnt++;
- ast_mutex_unlock(&m->lock);
+ ast_mutex_lock(&me->lock);
+ u->next = me->lu_head;
+ me->lu_head = u;
+ ast_mutex_unlock(&me->lock);
+ ast_atomic_fetchadd_int(&me->usecnt, +1);
ast_update_use_count();
return u;
}
-void ast_localuser_remove(struct ast_module_lock *m, struct localuser *u)
+void ast_localuser_remove(struct module_symbols *me, struct localuser *u)
{
- ast_mutex_lock(&m->lock);
- AST_LIST_REMOVE(&m->u, u, next);
- m->usecnt--;
+ struct localuser *x, *prev = NULL;
+ ast_mutex_lock(&me->lock);
+ /* unlink from the list */
+ for (x = me->lu_head; x; prev = x, x = x->next) {
+ if (x == u) {
+ if (prev)
+ prev->next = x->next;
+ else
+ me->lu_head = x->next;
+ break;
+ }
+ }
+ ast_mutex_unlock(&me->lock);
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
free(u);
- ast_mutex_unlock(&m->lock);
ast_update_use_count();
}
-void ast_hangup_localusers(struct ast_module_lock *m)
+void ast_hangup_localusers(struct module_symbols *me)
{
- struct localuser *u;
- ast_mutex_lock(&m->lock);
- AST_LIST_TRAVERSE_SAFE_BEGIN(&m->u, u, next) {
+ struct localuser *u, *next;
+ ast_mutex_lock(&me->lock);
+ for (u = me->lu_head; u; u = next) {
+ next = u->next;
ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD);
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
free(u);
- AST_LIST_REMOVE_CURRENT(&m->u, next);
}
- AST_LIST_TRAVERSE_SAFE_END
- m->usecnt = 0;
- ast_mutex_unlock(&m->lock);
+ ast_mutex_unlock(&me->lock);
ast_update_use_count();
}
@@ -169,8 +180,7 @@ void ast_hangup_localusers(struct ast_module_lock *m)
* RTLD_GLOBAL to make symbols visible to other modules, and
* to avoid load failures due to cross dependencies.
*
- * MOD_1 almost as above, but the generic callbacks are all into a
- * a structure, mod_data. Same load requirements as above.
+ * MOD_1 The generic callbacks are all into a structure, mod_data.
*
* MOD_2 this is the 'new style' format for modules. The module must
* explictly declare which simbols are exported and which
@@ -221,7 +231,7 @@ static void *module_symbol_helper(const char *name,
struct symbol_entry *es;
if (delta > 0 && m->state == MS_FAILED)
continue; /* cannot 'get' a symbol from a failed module */
- for (es = m->cb.exported_symbols; ret == NULL && es && es->name; es++) {
+ for (es = m->cb->exported_symbols; ret == NULL && es && es->name; es++) {
if (!strcmp(es->name, name)) {
ret = es->value;
m->export_refcount += delta;
@@ -256,7 +266,7 @@ static void release_module(struct module *m)
{
struct symbol_entry *s;
- for (s = m->cb.required_symbols; s && s->name != NULL; s++) {
+ for (s = m->cb->required_symbols; s && s->name != NULL; s++) {
if (s->value != NULL) {
release_module_symbol(s->name);
s->value = NULL;
@@ -268,7 +278,7 @@ static void release_module(struct module *m)
/*! \brief check that no NULL symbols are exported - the algorithms rely on that. */
static int check_exported(struct module *m)
{
- struct symbol_entry *es = m->cb.exported_symbols;
+ struct symbol_entry *es = m->cb->exported_symbols;
int errors = 0;
if (es == NULL)
@@ -311,7 +321,7 @@ static int resolve(struct module *m)
* resolve and verify symbols, and downgrade as appropriate.
*/
m->state = MS_CANLOAD;
- for (s = m->cb.required_symbols; s && s->name != NULL; s++) {
+ for (s = m->cb->required_symbols; s && s->name != NULL; s++) {
void **p = (void **)(s->value);
if (*p == NULL) /* symbol not resolved yet */
@@ -369,11 +379,11 @@ static int fixup(const char *caller)
new++;
/* print some debugging info for new modules */
if (m->state == MS_NEW &&
- (m->cb.exported_symbols || m->cb.required_symbols))
+ (m->cb->exported_symbols || m->cb->required_symbols))
ast_log(LOG_NOTICE,
"module %-30s exports %p requires %p state %s(%d)\n",
- m->resource, m->cb.exported_symbols,
- m->cb.required_symbols,
+ m->resource, m->cb->exported_symbols,
+ m->cb->required_symbols,
st_name(m->state), m->state);
}
ast_log(LOG_DEBUG, "---- fixup (%s): %d modules, %d new ---\n",
@@ -388,7 +398,7 @@ static int fixup(const char *caller)
if (m->state != MS_CANLOAD) /* for now, done with this module */
continue;
/* try to run the load routine */
- if (m->cb.load_module()) { /* error */
+ if (m->cb->load_module(m)) { /* error */
ast_log(LOG_WARNING, "load_module %s fail\n",
m->resource);
release_module(m); /* and set to MS_FAIL */
@@ -498,7 +508,7 @@ static int verify_key(const unsigned char *key)
return -1;
}
-int ast_unload_resource(const char *resource_name, int force)
+int ast_unload_resource(const char *resource_name, enum unload_mode force)
{
struct module *cur;
int res = -1;
@@ -506,11 +516,11 @@ int ast_unload_resource(const char *resource_name, int force)
if (AST_LIST_LOCK(&module_list)) /* XXX should fail here ? */
ast_log(LOG_WARNING, "Failed to lock\n");
AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, cur, next) {
- struct module_symbols *m = &cur->cb;
+ struct module_symbols *m = cur->cb;
if (strcasecmp(cur->resource, resource_name)) /* not us */
continue;
- if ((res = m->usecount()) > 0) {
+ if (m->usecnt > 0 || m->flags & NO_UNLOAD) {
if (force)
ast_log(LOG_WARNING, "Warning: Forcing removal of module %s with use count %d\n", resource_name, res);
else {
@@ -519,7 +529,8 @@ int ast_unload_resource(const char *resource_name, int force)
break;
}
}
- res = m->unload_module();
+ ast_hangup_localusers(m);
+ res = m->unload_module(m);
if (res) {
ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name);
if (force <= AST_FORCE_FIRM) {
@@ -553,7 +564,7 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
return NULL;
AST_LIST_LOCK(&module_list);
AST_LIST_TRAVERSE(&module_list, cur, next) {
- if (!strncasecmp(word, cur->resource, l) && (cur->cb.reload || !needsreload) &&
+ if (!strncasecmp(word, cur->resource, l) && (cur->cb->reload || !needsreload) &&
++which > state) {
ret = strdup(cur->resource);
break;
@@ -574,7 +585,6 @@ int ast_module_reload(const char *name)
struct module *cur;
int res = 0; /* return value. 0 = not found, others, see below */
int i, oldversion;
- int (*reload)(void);
if (ast_mutex_trylock(&reloadlock)) {
ast_verbose("The previous reload command didn't finish yet\n");
@@ -592,11 +602,10 @@ int ast_module_reload(const char *name)
AST_LIST_LOCK(&module_list);
oldversion = modlistver;
AST_LIST_TRAVERSE(&module_list, cur, next) {
- struct module_symbols *m = &cur->cb;
+ struct module_symbols *m = cur->cb;
if (name && strcasecmp(name, cur->resource)) /* not ours */
continue;
- reload = m->reload;
- if (!reload) { /* cannot be reloaded */
+ if (!m->reload) { /* cannot be reloaded */
if (res < 1) /* store result if possible */
res = 1; /* 1 = no reload() method */
continue;
@@ -606,7 +615,7 @@ int ast_module_reload(const char *name)
res = 2;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, m->description());
- reload();
+ m->reload(m);
AST_LIST_LOCK(&module_list);
if (oldversion != modlistver) /* something changed, abort */
break;
@@ -659,7 +668,7 @@ static struct module * __load_resource(const char *resource_name,
int errors=0;
int res;
struct module *cur;
- struct module_symbols *m, *m1;
+ struct module_symbols *m = NULL;
int flags = RTLD_NOW;
unsigned char *key;
char tmp[80];
@@ -687,7 +696,6 @@ static struct module * __load_resource(const char *resource_name,
AST_LIST_UNLOCK(&module_list);
return NULL;
}
- m = &cur->cb;
ast_copy_string(cur->resource, resource_name, sizeof(cur->resource));
if (resource_name[0] == '/')
ast_copy_string(fn, resource_name, sizeof(fn));
@@ -697,11 +705,13 @@ static struct module * __load_resource(const char *resource_name,
/* open in a sane way */
cur->lib = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
if (cur->lib) {
- if ((m1 = find_symbol(cur, "mod_data", 0)) == NULL || m1->type == MOD_0) {
+ if ((m = find_symbol(cur, "mod_data", 0)) == NULL ||
+ (m->flags & MOD_MASK) == MOD_0) {
/* old-style module, close and reload with standard flags */
dlclose(cur->lib);
cur->lib = NULL;
}
+ m = NULL;
}
if (cur->lib == NULL) /* try reopen with the old style */
cur->lib = dlopen(fn, flags);
@@ -712,26 +722,21 @@ static struct module * __load_resource(const char *resource_name,
AST_LIST_UNLOCK(&module_list);
return NULL;
}
- m1 = find_symbol(cur, "mod_data", 0);
- if (m1 != NULL) { /* new style module */
- ast_log(LOG_WARNING, "new style %s (%d) loaded RTLD_LOCAL\n",
- resource_name, m1->type);
+ if (m == NULL) /* MOD_0 modules may still have a mod_data entry */
+ m = find_symbol(cur, "mod_data", 0);
+ if (m != NULL) { /* new style module */
+ ast_log(LOG_WARNING, "new style %s (0x%x) loaded RTLD_LOCAL\n",
+ resource_name, m->flags);
+ cur->cb = m; /* use the mod_data from the module itself */
errors = check_exported(cur);
- *m = *m1;
} else {
- m->type = MOD_0;
- m->load_module = find_symbol(cur, "load_module", 1);
- m->unload_module = find_symbol(cur, "unload_module", 1);
- m->usecount = find_symbol(cur, "usecount", 1);
- m->description = find_symbol(cur, "description", 1);
- m->key = find_symbol(cur, "key", 1);
- m->reload = find_symbol(cur, "reload", 0);
+ ast_log(LOG_WARNING, "misstng mod_data for %s\n",
+ resource_name);
+ errors++;
}
if (!m->load_module)
errors++;
- if (!m->unload_module)
- errors++;
- if (!m->usecount)
+ if (!m->unload_module && !(m->flags & NO_UNLOAD) )
errors++;
if (!m->description)
errors++;
@@ -753,6 +758,10 @@ static struct module * __load_resource(const char *resource_name,
AST_LIST_UNLOCK(&module_list);
return NULL;
}
+ /* init mutex and usecount */
+ ast_mutex_init(&cur->cb->lock);
+ cur->cb->lu_head = NULL;
+
if (!ast_fully_booted) {
if (option_verbose)
ast_verbose( " => (%s)\n", term_color(tmp, m->description(), COLOR_BROWN, COLOR_BLACK, sizeof(tmp)));
@@ -768,7 +777,7 @@ static struct module * __load_resource(const char *resource_name,
so reload commands will be issued in same order modules were loaded */
modlistver++;
- if (m->type == MOD_2) {
+ if ( (m->flags & MOD_MASK) == MOD_2) {
ast_log(LOG_WARNING, "new-style module %s, deferring load()\n",
resource_name);
cur->state = MS_NEW;
@@ -777,7 +786,7 @@ static struct module * __load_resource(const char *resource_name,
/* XXX make sure the usecount is 1 before releasing the lock */
AST_LIST_UNLOCK(&module_list);
- if (cur->state == MS_CANLOAD && (res = m->load_module())) {
+ if (cur->state == MS_CANLOAD && (res = m->load_module(m))) {
ast_log(LOG_WARNING, "%s: load_module failed, returning %d\n", resource_name, res);
ast_unload_resource(resource_name, 0);
return NULL;
@@ -808,22 +817,22 @@ int ast_load_resource(const char *resource_name)
}
#if 0
-+/*
-+ * load a single module (API call).
-+ * (recursive calls from load_module() succeed.
-+ */
-+int ast_load_resource(const char *resource_name)
-+{
-+ struct module *m;
-+ int ret;
-+
-+ ast_mutex_lock(&modlock);
-+ m = __load_resource(resource_name, 0);
-+ fixup(resource_name);
-+ ret = (m->state == MS_FAILED) ? -1 : 0;
-+ ast_mutex_unlock(&modlock);
-+ return ret;
-+}
+/*
+ * load a single module (API call).
+ * (recursive calls from load_module() succeed.
+ */
+int ast_load_resource(const char *resource_name)
+{
+ struct module *m;
+ int ret;
+
+ ast_mutex_lock(&modlock);
+ m = __load_resource(resource_name, 0);
+ fixup(resource_name);
+ ret = (m->state == MS_FAILED) ? -1 : 0;
+ ast_mutex_unlock(&modlock);
+ return ret;
+}
#endif
/*! \brief if enabled, log and output on console the module's name, and try load it */
@@ -947,13 +956,15 @@ done:
return 0;
}
+#include <errno.h> /* for errno... */
+
void ast_update_use_count(void)
{
/* Notify any module monitors that the use count for a
resource has changed */
struct loadupdate *m;
if (AST_LIST_LOCK(&module_list))
- ast_log(LOG_WARNING, "Failed to lock\n");
+ ast_log(LOG_WARNING, "Failed to lock, errno %d\n", errno);
AST_LIST_TRAVERSE(&updaters, m, next)
m->updater();
AST_LIST_UNLOCK(&module_list);
@@ -968,8 +979,9 @@ int ast_update_module_list(int (*modentry)(const char *module, const char *descr
if (ast_mutex_trylock(&module_list.lock))
unlock = 0;
- AST_LIST_TRAVERSE(&module_list, cur, next)
- total_mod_loaded += modentry(cur->resource, cur->cb.description(), cur->cb.usecount(), like);
+ AST_LIST_TRAVERSE(&module_list, cur, next) {
+ total_mod_loaded += modentry(cur->resource, cur->cb->description(), cur->cb->usecnt, like);
+ }
if (unlock)
AST_LIST_UNLOCK(&module_list);
diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index d6617d5b8..e16b7f694 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -71,7 +71,6 @@ static void FREE(void *ptr)
static int aeldebug = 0;
-static char *dtext = "Asterisk Extension Language Compiler";
static char *config = "extensions.ael";
static char *registrar = "pbx_ael";
@@ -1248,7 +1247,7 @@ static struct ast_cli_entry ael_cli[] = {
/*
* Standard module functions ...
*/
-int unload_module(void)
+static int unload_module(void *mod)
{
ast_context_destroy(NULL, registrar);
ast_cli_unregister_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
@@ -1256,29 +1255,26 @@ int unload_module(void)
}
-int load_module(void)
+static int load_module(void *mod)
{
ast_cli_register_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
return (pbx_load_module());
}
-int reload(void)
+static int reload(void *mod)
{
ast_context_destroy(NULL, registrar);
return pbx_load_module();
}
-int usecount(void)
+static const char *description(void)
{
- return 0;
+ return "Asterisk Extension Language Compiler";
}
-const char *description(void)
-{
- return dtext;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 21316deb0..2fc9fcd63 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -30,8 +30,6 @@
#include <ctype.h>
#include <errno.h>
-#define STATIC_MODULE
-
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -53,7 +51,6 @@ static void FREE(void *ptr)
#define FREE free
#endif
-static char *dtext = "Text Extension Configuration";
static char *config = "extensions.conf";
static char *registrar = "pbx_config";
@@ -1326,7 +1323,7 @@ static struct ast_cli_entry reload_extensions_cli =
/*!
* Standard module functions ...
*/
-STATIC_MODULE int unload_module(void)
+static int unload_module(void *mod)
{
ast_cli_unregister(&context_add_extension_cli);
if (static_config && !write_protect_config)
@@ -1515,7 +1512,7 @@ static int pbx_load_module(void)
return 0;
}
-STATIC_MODULE int load_module(void)
+static int load_module(void *mod)
{
if (pbx_load_module())
return -1;
@@ -1533,7 +1530,7 @@ STATIC_MODULE int load_module(void)
return 0;
}
-STATIC_MODULE int reload(void)
+static int reload(void *mod)
{
if (clearglobalvars_config)
pbx_builtin_clear_globals();
@@ -1541,19 +1538,15 @@ STATIC_MODULE int reload(void)
return 0;
}
-STATIC_MODULE int usecount(void)
-{
- return 0;
-}
-
-STATIC_MODULE const char *description(void)
+static const char *description(void)
{
- return dtext;
+ return "Text Extension Configuration";
}
-STATIC_MODULE const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-STD_MOD(MOD_1, reload, NULL, NULL);
+/* XXX really no usecount ? */
+STD_MOD(MOD_1 | NO_USECOUNT, reload, NULL, NULL);
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 9e30b8654..88fa3d7d1 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -77,7 +77,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
extern char ast_config_AST_KEY_DIR[];
-static char *tdesc = "Distributed Universal Number Discovery (DUNDi)";
#define DUNDI_MODEL_INBOUND (1 << 0)
#define DUNDI_MODEL_OUTBOUND (1 << 1)
@@ -4603,7 +4602,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
STANDARD_HANGUP_LOCALUSERS;
@@ -4629,19 +4628,20 @@ int unload_module(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
struct sockaddr_in sin;
set_config("dundi.conf",&sin);
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res = 0;
struct sockaddr_in sin;
char iabuf[INET_ADDRSTRLEN];
-
+
+ __mod_desc = mod;
dundi_set_output(dundi_debug_output);
dundi_set_error(dundi_error_output);
@@ -4709,21 +4709,14 @@ int load_module(void)
return res;
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Distributed Universal Number Discovery (DUNDi)";
}
-int usecount(void)
-{
- int res;
- /* XXX DUNDi cannot be unloaded XXX */
- return 1;
- STANDARD_USECOUNT(res);
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index cadd73a14..a88f20e9f 100644
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -52,7 +52,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/crypto.h"
#include "asterisk/astdb.h"
-static char *tdesc = "Loopback Switch";
/* Loopback switch substitutes ${EXTEN}, ${CONTEXT}, and ${PRIORITY} into
the data passed to it to try to get a string of the form:
@@ -169,30 +168,27 @@ static struct ast_switch loopback_switch =
matchmore: loopback_matchmore,
};
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Loopback Switch";
}
-int usecount(void)
-{
- return 1;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
ast_unregister_switch(&loopback_switch);
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
ast_register_switch(&loopback_switch);
return 0;
}
+/* XXX really no unload ? */
+STD_MOD(MOD_1 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 04d6fd0bd..1d9e803ed 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -61,7 +61,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define EXT_DATA_SIZE 256
-static char *tdesc = "Realtime Switch";
/* Realtime switch looks up extensions in the supplied realtime table.
@@ -246,30 +245,26 @@ static struct ast_switch realtime_switch =
matchmore: realtime_matchmore,
};
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Realtime Switch";
}
-int usecount(void)
-{
- return 1;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
ast_unregister_switch(&realtime_switch);
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
ast_register_switch(&realtime_switch);
return 0;
}
+STD_MOD(MOD_1 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 122b2e5aa..e7136aa44 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -53,7 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
* The spool file contains a header
*/
-static char *tdesc = "Outgoing Spool Support";
static char qdir[255];
struct outgoing {
@@ -404,12 +403,12 @@ static void *scan_thread(void *unused)
return NULL;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
return -1;
}
-int load_module(void)
+static int load_module(void *mod)
{
pthread_t thread;
pthread_attr_t attr;
@@ -428,17 +427,14 @@ int load_module(void)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "Outgoing Spool Support";
}
-int usecount(void)
-{
- return 1;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_1 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
diff --git a/res/res_adsi.c b/res/res_adsi.c
index ca0da1f36..730b336d1 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -1107,36 +1107,32 @@ static void adsi_load(void)
}
}
-int reload(void)
+static int reload(void *mod)
{
adsi_load();
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
adsi_load();
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
/* Can't unload this once we're loaded */
return -1;
}
-const char *description(void)
+static const char *description(void)
{
return "ADSI Resource";
}
-int usecount(void)
-{
- /* We should never be unloaded */
- return 1;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
diff --git a/res/res_agi.c b/res/res_agi.c
index 9f16c9faa..c00715783 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -95,7 +95,7 @@ static char *descrip =
static int agidebug = 0;
-LOCAL_USER_DECL;
+struct module_symbols *me;
#define TONE_BLOCK_SIZE 200
@@ -1952,7 +1952,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
argv[argc++] = stringp;
argv[argc] = NULL;
- LOCAL_USER_ADD(u);
+ u = ast_localuser_add(me, chan);
#if 0
/* Answer if need be */
if (chan->_state != AST_STATE_UP) {
@@ -1972,7 +1972,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
if (efd > -1)
close(efd);
}
- LOCAL_USER_REMOVE(u);
+ ast_localuser_remove(me, u);
return res;
}
@@ -2026,9 +2026,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 };
-int unload_module(void)
+static int unload_module(void *mod)
{
- STANDARD_HANGUP_LOCALUSERS;
+ ast_hangup_localusers(mod);
ast_cli_unregister(&showagi);
ast_cli_unregister(&dumpagihtml);
ast_cli_unregister(&cli_debug);
@@ -2038,8 +2038,9 @@ int unload_module(void)
return ast_unregister_application(app);
}
-int load_module(void)
+static int load_module(void *mod)
{
+ me = mod;
ast_cli_register(&showagi);
ast_cli_register(&dumpagihtml);
ast_cli_register(&cli_debug);
@@ -2049,21 +2050,14 @@ int load_module(void)
return ast_register_application(app, agi_exec, synopsis, descrip);
}
-const char *description(void)
+static const char *description(void)
{
return "Asterisk Gateway Interface (AGI)";
-
-}
-
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
}
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_0, NULL, NULL, NULL);
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 6a26bc23c..a9ebb3647 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -42,7 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
/*! The timeout for originated calls, in seconds */
#define TIMEOUT 30
-STANDARD_USECOUNT_DECL;
+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"
@@ -132,7 +132,7 @@ static int handle_orig(int fd, int argc, char *argv[])
if (ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2]))
return RESULT_SHOWUSAGE;
- STANDARD_INCREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, +1);
if (!strcasecmp("application", argv[2])) {
res = orig_app(argv[1], argv[3], argv[4]);
@@ -141,7 +141,7 @@ static int handle_orig(int fd, int argc, char *argv[])
} else
res = RESULT_SHOWUSAGE;
- STANDARD_DECREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
return res;
}
@@ -154,38 +154,32 @@ static char *complete_orig(const char *line, const char *word, int pos, int stat
if (pos != 2)
return NULL;
- STANDARD_INCREMENT_USECOUNT;
-
+ ast_atomic_fetchadd_int(&me->usecnt, +1);
ret = ast_cli_complete(word, choices, state);
-
- STANDARD_DECREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
return ret;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
return ast_cli_unregister(&cli_orig);
}
-int load_module(void)
+static int load_module(void *mod)
{
+ me = mod;
return ast_cli_register(&cli_orig);
}
-const char *description(void)
+static const char *description(void)
{
return "Call origination from the CLI";
-
-}
-
-int usecount(void)
-{
- return 0;
}
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_0 | NO_USECOUNT, NULL, NULL, NULL);
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index b28059db5..f2634a93c 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -506,16 +506,16 @@ static struct ast_config_engine odbc_engine = {
.update_func = update_odbc
};
-int unload_module (void)
+static int unload_module (void *mod)
{
+ ast_hangup_localusers(mod);
ast_config_engine_deregister(&odbc_engine);
if (option_verbose)
ast_verbose("res_config_odbc unloaded.\n");
- STANDARD_HANGUP_LOCALUSERS;
return 0;
}
-int load_module (void)
+static int load_module (void *mod)
{
ast_config_engine_register(&odbc_engine);
if (option_verbose)
@@ -523,19 +523,14 @@ int load_module (void)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
return "ODBC Configuration";
-
}
-int usecount (void)
-{
- /* never unload a config module */
- return 1;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index cf3838654..ecdce4dd1 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -547,7 +547,7 @@ static struct ast_config_engine pgsql_engine = {
.update_func = update_pgsql
};
-int load_module(void)
+static int load_module(void *mod)
{
parse_config();
@@ -571,7 +571,7 @@ int load_module(void)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
/* Aquire control before doing anything to the module itself. */
ast_mutex_lock(&pgsql_lock);
@@ -594,7 +594,7 @@ int unload_module(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
/* Aquire control before doing anything to the module itself. */
ast_mutex_lock(&pgsql_lock);
@@ -691,14 +691,15 @@ int parse_config(void)
return 1;
}
-const char *description(void)
+static const char *description(void)
{
return "Postgresql RealTime Configuration Driver";
}
-int usecount(void)
+static int usecount(void)
{
+ /* XXX check this... */
/* Try and get a lock. If unsuccessful, than that means another thread is using the pgsql object. */
if (ast_mutex_trylock(&pgsql_lock)) {
ast_log(LOG_DEBUG, "Postgresql RealTime: Module usage count is 1.\n");
@@ -708,11 +709,17 @@ int usecount(void)
return 0;
}
+<<<<<<< .mine
+static const char *key(void)
+=======
const char *key(void)
+>>>>>>> .r19220
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_0, NULL, NULL, NULL);
+
static int pgsql_reconnect(const char *database)
{
char my_database[50];
diff --git a/res/res_convert.c b/res/res_convert.c
index be441bc4b..553075874 100644
--- a/res/res_convert.c
+++ b/res/res_convert.c
@@ -39,7 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
#include "asterisk/file.h"
-STANDARD_USECOUNT_DECL;
+struct module_symbols *me;
/*! \brief Split the filename to basename and extension */
static int split_ext(char *filename, char **name, char **ext)
@@ -65,7 +65,7 @@ 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;
- STANDARD_INCREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, +1);
if (argc != 3 || ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2])) {
ret = RESULT_SHOWUSAGE;
@@ -116,7 +116,7 @@ fail_out:
if (fs_in)
ast_closestream(fs_in);
- STANDARD_DECREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
return ret;
}
@@ -132,31 +132,25 @@ static struct ast_cli_entry audio_convert_cli={
{ "convert" , NULL }, cli_audio_convert, "Convert audio files", usage_audio_convert
};
-int unload_module(void)
+static int unload_module(void *mod)
{
return ast_cli_unregister(&audio_convert_cli);
}
-int load_module(void)
+static int load_module(void *mod)
{
+ me = mod;
return ast_cli_register(&audio_convert_cli);
}
-const char *description(void)
+static const char *description(void)
{
return "File format conversion CLI command";
-
-}
-
-int usecount(void)
-{
- int res;
- STANDARD_USECOUNT(res);
- return res;
}
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD1;
diff --git a/res/res_crypto.c b/res/res_crypto.c
index ea0f05ae6..d7c74d79f 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -581,13 +581,13 @@ static int crypto_init(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
crypto_load(-1, -1);
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
crypto_init();
if (ast_opt_init_keys)
@@ -597,24 +597,19 @@ int load_module(void)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
/* Can't unload this once we're loaded */
return -1;
}
-const char *description(void)
+static const char *description(void)
{
return "Cryptographic Digital Signatures";
}
-int usecount(void)
-{
- /* We should never be unloaded */
- return 1;
-}
-
-const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
diff --git a/res/res_features.c b/res/res_features.c
index b114d23c0..f29ec9d45 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -142,8 +142,6 @@ AST_MUTEX_DEFINE_STATIC(parking_lock);
static pthread_t parking_thread;
-LOCAL_USER_DECL;
-
char *ast_parking_ext(void)
{
return parking_ext;
@@ -2201,14 +2199,16 @@ static int load_config(void)
return ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), FREE, registrar);
}
-int reload(void) {
+static int reload(void *mod)
+{
return load_config();
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
+ __mod_desc = mod;
AST_LIST_HEAD_INIT(&feature_list);
memset(parking_ext, 0, sizeof(parking_ext));
memset(parking_con, 0, sizeof(parking_con));
@@ -2230,7 +2230,7 @@ int load_module(void)
}
-int unload_module(void)
+static int unload_module(void *mod)
{
STANDARD_HANGUP_LOCALUSERS;
@@ -2242,25 +2242,14 @@ int unload_module(void)
return ast_unregister_application(parkedcall);
}
-const char *description(void)
+static const char *description(void)
{
return "Call Features Resource";
}
-int usecount(void)
-{
- /* Never allow parking to be unloaded because it will
- unresolve needed symbols in the dialer */
-#if 0
- int res;
- STANDARD_USECOUNT(res);
- return res;
-#else
- return 1;
-#endif
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_UNLOAD, reload, NULL, NULL);
diff --git a/res/res_indications.c b/res/res_indications.c
index 8e468c38a..f4777e3c9 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -50,7 +50,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
/* Globals */
-static const char dtext[] = "Indications Configuration";
static const char config[] = "indications.conf";
/*
@@ -364,7 +363,7 @@ static struct ast_cli_entry show_indications_cli =
/*
* Standard module functions ...
*/
-int unload_module(void)
+static int unload_module(void *mod)
{
/* remove the registed indications... */
ast_unregister_indication_country(NULL);
@@ -379,9 +378,10 @@ int unload_module(void)
}
-int load_module(void)
+static int load_module(void *mod)
{
- if (ind_load_module()) return -1;
+ if (ind_load_module())
+ return -1;
ast_cli_register(&add_indication_cli);
ast_cli_register(&remove_indication_cli);
@@ -392,7 +392,7 @@ int load_module(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
/* remove the registed indications... */
ast_unregister_indication_country(NULL);
@@ -400,18 +400,14 @@ int reload(void)
return ind_load_module();
}
-const char *description(void)
+static const char *description(void)
{
- /* that the following cast is needed, is yuk! */
- return (char*)dtext;
+ return "Indications Configuration";
}
-int usecount(void)
-{
- return 0;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_USECOUNT, reload, NULL, NULL);
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 6c00c593c..e570e726b 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -31,8 +31,6 @@
#include <sys/stat.h>
#include <libgen.h> /* dirname() */
-#define STATIC_MODULE
-
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -647,7 +645,7 @@ static int unpause_monitor_action(struct mansession *s, struct message *m)
}
-STATIC_MODULE int load_module(void)
+static int load_module(void *mod)
{
ast_register_application("Monitor", start_monitor_exec, monitor_synopsis, monitor_descrip);
ast_register_application("StopMonitor", stop_monitor_exec, stopmonitor_synopsis, stopmonitor_descrip);
@@ -663,7 +661,7 @@ STATIC_MODULE int load_module(void)
return 0;
}
-STATIC_MODULE int unload_module(void)
+static int unload_module(void *mod)
{
ast_unregister_application("Monitor");
ast_unregister_application("StopMonitor");
@@ -679,27 +677,14 @@ STATIC_MODULE int unload_module(void)
return 0;
}
-STATIC_MODULE const char *description(void)
+static const char *description(void)
{
return "Call Monitoring Resource";
}
-STATIC_MODULE int usecount(void)
-{
- /* Never allow monitor to be unloaded because it will
- unresolve needed symbols in the channel */
-#if 0
- int res;
- STANDARD_USECOUNT(res);
- return res;
-#else
- return 1;
-#endif
-}
-
-STATIC_MODULE const char *key(void)
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
-STD_MOD(MOD_0, NULL, NULL, NULL); /* MOD_0 because it exports some symbols */
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL); /* MOD_0 because it exports some symbols */
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index e82d6fa19..9b1113a44 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1164,7 +1164,7 @@ static int init_classes(int reload)
return 1;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
@@ -1191,7 +1191,7 @@ int load_module(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
if (init_classes(1))
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
@@ -1199,30 +1199,19 @@ int reload(void)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
return -1;
}
-const char *description(void)
+static const char *description(void)
{
return "Music On Hold Resource";
}
-int usecount(void)
-{
- /* Never allow Music On Hold to be unloaded
- unresolve needed symbols in the dialer */
-#if 0
- int res;
- STANDARD_USECOUNT(res);
- return res;
-#else
- return 1;
-#endif
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, reload, NULL, NULL);
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 3093c1f07..cc255844d 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -106,7 +106,6 @@ static void odbc_init(void)
}
}
-static char *tdesc = "ODBC Resource";
/* internal stuff */
SQLHSTMT odbc_prepare_and_execute(odbc_obj *obj, SQLHSTMT (*prepare_cb)(odbc_obj *obj, void *data), void *data)
@@ -578,7 +577,7 @@ odbc_status odbc_obj_connect(odbc_obj *obj)
LOCAL_USER_DECL;
-int unload_module(void)
+static int unload_module(void *mod)
{
STANDARD_HANGUP_LOCALUSERS;
odbc_destroy();
@@ -589,7 +588,7 @@ int unload_module(void)
return 0;
}
-int load_module(void)
+static int load_module(void *mod)
{
odbc_init();
load_odbc_config();
@@ -600,19 +599,14 @@ int load_module(void)
return 0;
}
-const char *description(void)
+static const char *description(void)
{
- return tdesc;
+ return "ODBC Resource";
}
-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_0, NULL, NULL, NULL);
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 681fd7f41..2f8515440 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -48,7 +48,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
/* Message expiry time in milliseconds */
#define SMDI_MSG_EXPIRY_TIME 30000 /* 30 seconds */
-static const char tdesc[] = "Asterisk Simplified Message Desk Interface (SMDI) Module";
static const char config_file[] = "smdi.conf";
static void ast_smdi_md_message_push(struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg);
@@ -57,9 +56,7 @@ static void ast_smdi_mwi_message_push(struct ast_smdi_interface *iface, struct a
static void *smdi_read(void *iface_p);
static int smdi_load(int reload);
-/* Use count stuff */
-
-LOCAL_USER_DECL;
+struct module_symbols *me; /* initialized in load_module() */
/*! \brief SMDI interface container. */
struct ast_smdi_interface_container {
@@ -504,7 +501,7 @@ void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
ASTOBJ_CONTAINER_DESTROY(&iface->mwi_q);
free(iface);
- STANDARD_DECREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, -1);
}
/*!
@@ -688,7 +685,7 @@ static int smdi_load(int reload)
ASTOBJ_CONTAINER_LINK(&smdi_ifaces, iface);
ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
- STANDARD_INCREMENT_USECOUNT;
+ ast_atomic_fetchadd_int(&me->usecnt, +1);
} else {
ast_log(LOG_NOTICE, "Ignoring unknown option %s in %s\n", v->name, config_file);
}
@@ -709,15 +706,16 @@ static int smdi_load(int reload)
}
-const char *description(void)
+static const char *description(void)
{
- return (char *) tdesc;
+ return "Asterisk Simplified Message Desk Interface (SMDI) Module";
}
-int load_module(void)
+static int load_module(void *mod)
{
int res;
+ me = mod;
/* initialize our containers */
memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
@@ -733,7 +731,7 @@ int load_module(void)
return 0;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
/* this destructor stops any running smdi_read threads */
ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
@@ -742,7 +740,7 @@ int unload_module(void)
return 0;
}
-int reload(void)
+static int reload(void *mod)
{
int res;
@@ -757,16 +755,9 @@ int reload(void)
return 0;
}
-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_0, reload, NULL, NULL);
diff --git a/res/res_speech.c b/res/res_speech.c
index 58ef56447..32b15d79e 100644
--- a/res/res_speech.c
+++ b/res/res_speech.c
@@ -41,7 +41,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
#include "asterisk/options.h"
#include "asterisk/speech.h"
-static char *tdesc = "Generic Speech Recognition API";
static AST_LIST_HEAD_STATIC(engines, ast_speech_engine);
static struct ast_speech_engine *default_engine = NULL;
@@ -337,13 +336,13 @@ int ast_speech_unregister(char *engine_name)
return res;
}
-int unload_module(void)
+static int unload_module(void *mod)
{
/* We can not be unloaded */
return -1;
}
-int load_module(void)
+static int load_module(void *mod)
{
int res = 0;
@@ -353,24 +352,14 @@ int load_module(void)
return res;
}
-int reload(void)
+static const char *description(void)
{
- return 0;
+ return "Generic Speech Recognition API";
}
-const char *description(void)
-{
- return tdesc;
-}
-
-int usecount(void)
-{
- int res = 0;
-
- return res;
-}
-
-const char *key()
+static const char *key(void)
{
return ASTERISK_GPL_KEY;
}
+
+STD_MOD(MOD_0 | NO_USECOUNT | NO_UNLOAD, NULL, NULL, NULL);
diff --git a/translate.c b/translate.c
index 92a3a9753..20da09113 100644
--- a/translate.c
+++ b/translate.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <stdio.h>
+#define MOD_LOADER /* not really a module */
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -39,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/translate.h"
+#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/frame.h"
#include "asterisk/sched.h"
@@ -94,6 +96,8 @@ static void *newpvt(struct ast_translator *t)
int len;
int useplc = t->plc_samples > 0 && t->useplc; /* cache, because it can change on the fly */
char *ofs;
+ struct module_symbols *ms = t->module;
+
/*
* compute the required size adding private descriptor,
* plc, buffer, AST_FRIENDLY_OFFSET.
@@ -123,9 +127,7 @@ static void *newpvt(struct ast_translator *t)
free(pvt);
return NULL;
}
- ast_mutex_lock(&t->lockp->lock);
- t->lockp->usecnt++;
- ast_mutex_unlock(&t->lockp->lock);
+ ast_atomic_fetchadd_int(&ms->usecnt, +1);
ast_update_use_count();
return pvt;
}
@@ -133,13 +135,12 @@ static void *newpvt(struct ast_translator *t)
static void destroy(struct ast_trans_pvt *pvt)
{
struct ast_translator *t = pvt->t;
+ struct module_symbols *ms = t->module;
if (t->destroy)
t->destroy(pvt);
free(pvt);
- ast_mutex_lock(&t->lockp->lock);
- t->lockp->usecnt--;
- ast_mutex_unlock(&t->lockp->lock);
+ ast_atomic_fetchadd_int(&ms->usecnt, -1);
ast_update_use_count();
}
@@ -519,14 +520,15 @@ static char show_trans_usage[] =
static struct ast_cli_entry show_trans =
{ { "show", "translation", NULL }, show_translation, "Display translation matrix", show_trans_usage };
-int ast_register_translator(struct ast_translator *t)
+int ast_register_translator(struct ast_translator *t, void *module)
{
static int added_cli = 0;
- if (t->lockp == NULL) {
- ast_log(LOG_WARNING, "Missing lock pointer, you need to supply one\n");
+ if (module == NULL) {
+ ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n");
return -1;
}
+ t->module = module;
if (t->buf_size == 0) {
ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
return -1;
@@ -561,10 +563,6 @@ int ast_register_translator(struct ast_translator *t)
int align = (char *)&p.b - (char *)&p.a;
t->buf_size = ((t->buf_size + align - 1)/align)*align;
}
- if (t->lockp->usecnt < 0) { /* XXX need to initialize the lock */
- ast_mutex_init(&t->lockp->lock);
- t->lockp->usecnt = 0;
- }
if (t->frameout == NULL)
t->frameout = default_frameout;