[asterisk-commits] mogorman: trunk r41633 - in /trunk: apps/ cdr/
channels/ funcs/ pbx/ res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Aug 31 14:00:21 MST 2006
Author: mogorman
Date: Thu Aug 31 16:00:20 2006
New Revision: 41633
URL: http://svn.digium.com/view/asterisk?rev=41633&view=rev
Log:
everything that loads a config that needs a config file to run
now reports AST_MODULE_LOAD_DECLINE when loading if config file
is not there, also fixed an error in res_config_pgsql where it
had a non static function when it should.
Modified:
trunk/apps/app_alarmreceiver.c
trunk/apps/app_festival.c
trunk/apps/app_followme.c
trunk/apps/app_osplookup.c
trunk/apps/app_queue.c
trunk/apps/app_rpt.c
trunk/cdr/cdr_csv.c
trunk/cdr/cdr_custom.c
trunk/cdr/cdr_manager.c
trunk/cdr/cdr_odbc.c
trunk/cdr/cdr_pgsql.c
trunk/cdr/cdr_radius.c
trunk/cdr/cdr_tds.c
trunk/channels/chan_agent.c
trunk/channels/chan_h323.c
trunk/channels/chan_iax2.c
trunk/channels/chan_jingle.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_misdn.c
trunk/channels/chan_oss.c
trunk/channels/chan_phone.c
trunk/channels/chan_sip.c
trunk/channels/chan_skinny.c
trunk/channels/chan_vpb.cc
trunk/channels/chan_zap.c
trunk/funcs/func_odbc.c
trunk/pbx/pbx_config.c
trunk/pbx/pbx_dundi.c
trunk/res/res_config_pgsql.c
trunk/res/res_features.c
trunk/res/res_indications.c
trunk/res/res_jabber.c
trunk/res/res_odbc.c
trunk/res/res_smdi.c
trunk/res/res_snmp.c
Modified: trunk/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_alarmreceiver.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Thu Aug 31 16:00:20 2006
@@ -743,6 +743,7 @@
if(option_verbose >= 4)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: No config file\n");
+ return 0;
}
else{
@@ -809,7 +810,7 @@
}
ast_config_destroy(cfg);
}
- return 0;
+ return 1;
}
@@ -831,8 +832,10 @@
static int load_module(void)
{
- load_config();
- return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
+ if(load_config())
+ return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
+ else
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Alarm Receiver for Asterisk");
Modified: trunk/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_festival.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_festival.c (original)
+++ trunk/apps/app_festival.c Thu Aug 31 16:00:20 2006
@@ -533,6 +533,12 @@
static int load_module(void)
{
+ struct ast_config *cfg = ast_config_load(FESTIVAL_CONFIG);
+ if (!cfg) {
+ ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_config_destroy(cfg);
return ast_register_application(app, festival_exec, synopsis, descrip);
}
Modified: trunk/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_followme.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Thu Aug 31 16:00:20 2006
@@ -1098,7 +1098,8 @@
static int load_module(void)
{
- reload_followme();
+ if(!reload_followme())
+ return AST_MODULE_LOAD_DECLINE;
return ast_register_application(app, app_exec, synopsis, descrip);
}
Modified: trunk/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_osplookup.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_osplookup.c (original)
+++ trunk/apps/app_osplookup.c Thu Aug 31 16:00:20 2006
@@ -1431,10 +1431,11 @@
ast_config_destroy(cfg);
} else {
ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
+ return 0;
}
ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
- return 0;
+ return 1;
}
static int osp_unload(void)
@@ -1606,7 +1607,9 @@
{
int res;
- osp_load();
+ if(!osp_load())
+ return AST_MODULE_LOAD_DECLINE;
+
res = ast_cli_register(&osp_cli);
res |= ast_register_application(app1, ospauth_exec, synopsis1, descrip1);
res |= ast_register_application(app2, osplookup_exec, synopsis2, descrip2);
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Aug 31 16:00:20 2006
@@ -3642,7 +3642,7 @@
.read = queue_function_queuememberlist,
};
-static void reload_queues(void)
+static int reload_queues(void)
{
struct call_queue *q;
struct ast_config *cfg;
@@ -3656,7 +3656,7 @@
if (!(cfg = ast_config_load("queues.conf"))) {
ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
- return;
+ return 0;
}
memset(interface, 0, sizeof(interface));
AST_LIST_LOCK(&queues);
@@ -3794,6 +3794,7 @@
}
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&queues);
+ return 1;
}
static int __queues_show(struct mansession *s, int manager, int fd, int argc, char **argv, int queue_show)
@@ -4359,7 +4360,10 @@
static int load_module(void)
{
int res;
-
+ if(!reload_queues())
+ return AST_MODULE_LOAD_DECLINE;
+ if (queue_persistent_members)
+ reload_queue_members();
res = ast_register_application(app, queue_exec, synopsis, descrip);
res |= ast_cli_register(&cli_show_queue);
res |= ast_cli_register(&cli_show_queues);
@@ -4381,12 +4385,6 @@
res |= ast_custom_function_register(&queuewaitingcount_function);
res |= ast_devstate_add(statechange_queue, NULL);
- if (!res) {
- reload_queues();
- if (queue_persistent_members)
- reload_queue_members();
- }
-
return res;
}
Modified: trunk/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_rpt.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/apps/app_rpt.c (original)
+++ trunk/apps/app_rpt.c Thu Aug 31 16:00:20 2006
@@ -7150,7 +7150,7 @@
}
-static void *rpt_master(void *ignore)
+static void *rpt_master(void *config)
{
int i,n;
pthread_attr_t attr;
@@ -7160,7 +7160,7 @@
/* go thru all the specified repeaters */
this = NULL;
n = 0;
- rpt_vars[n].cfg = ast_config_load("rpt.conf");
+ rpt_vars[n].cfg = config;
cfg = rpt_vars[n].cfg;
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n");
@@ -8030,7 +8030,12 @@
static int load_module(void)
{
- ast_pthread_create(&rpt_master_thread,NULL,rpt_master,NULL);
+ struct ast_config *cfg = ast_config_load("rpt.conf");
+ if (!cfg) {
+ ast_log(LOG_WARNING, "No such configuration file rpt.conf\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_pthread_create(&rpt_master_thread,NULL,rpt_master,cfg);
/* Register cli extensions */
ast_cli_register(&cli_debug);
Modified: trunk/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_csv.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_csv.c (original)
+++ trunk/cdr/cdr_csv.c Thu Aug 31 16:00:20 2006
@@ -108,13 +108,13 @@
if (!cfg) {
ast_log(LOG_WARNING, "unable to load config: %s\n", config);
- return -1;
+ return 0;
}
var = ast_variable_browse(cfg, "csv");
if (!var) {
ast_config_destroy(cfg);
- return -1;
+ return 0;
}
tmp = ast_variable_retrieve(cfg, "csv", "usegmtime");
@@ -142,7 +142,7 @@
}
ast_config_destroy(cfg);
- return 0;
+ return 1;
}
static int append_string(char *buf, char *s, size_t bufsize)
@@ -321,7 +321,8 @@
{
int res;
- load_config();
+ if(!load_config())
+ return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, ast_module_info->description, csv_log);
if (res) {
Modified: trunk/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_custom.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_custom.c (original)
+++ trunk/cdr/cdr_custom.c Thu Aug 31 16:00:20 2006
@@ -153,8 +153,9 @@
ast_log(LOG_ERROR, "Unable to register custom CDR handling\n");
if (mf)
fclose(mf);
- }
- return res;
+ return res;
+ } else
+ return AST_MODULE_LOAD_DECLINE;
}
static int reload(void)
Modified: trunk/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_manager.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_manager.c (original)
+++ trunk/cdr/cdr_manager.c Thu Aug 31 16:00:20 2006
@@ -49,7 +49,7 @@
static int enablecdr = 0;
-static void loadconfigurationfile(void)
+static int loadconfigurationfile(void)
{
char *cat;
struct ast_config *cfg;
@@ -59,7 +59,7 @@
if (!cfg) {
/* Standard configuration */
enablecdr = 0;
- return;
+ return 0;
}
cat = ast_category_browse(cfg, NULL);
@@ -80,6 +80,7 @@
}
ast_config_destroy(cfg);
+ return 1;
}
static int manager_log(struct ast_cdr *cdr)
@@ -145,7 +146,8 @@
int res;
/* Configuration file */
- loadconfigurationfile();
+ if(loadconfigurationfile())
+ return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
if (res) {
Modified: trunk/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_odbc.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_odbc.c (original)
+++ trunk/cdr/cdr_odbc.c Thu Aug 31 16:00:20 2006
@@ -253,6 +253,7 @@
cfg = ast_config_load(config);
if (!cfg) {
ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
+ res = AST_MODULE_LOAD_DECLINE;
goto out;
}
Modified: trunk/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Thu Aug 31 16:00:20 2006
@@ -289,7 +289,7 @@
if (!(cfg = ast_config_load(config))) {
ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
res = process_my_load_module(cfg);
Modified: trunk/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_radius.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_radius.c (original)
+++ trunk/cdr/cdr_radius.c Thu Aug 31 16:00:20 2006
@@ -247,7 +247,8 @@
if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
ast_config_destroy(cfg);
- }
+ } else
+ return AST_MODULE_LOAD_DECLINE;
/* start logging */
rc_openlog("asterisk");
Modified: trunk/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_tds.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/cdr/cdr_tds.c (original)
+++ trunk/cdr/cdr_tds.c Thu Aug 31 16:00:20 2006
@@ -504,8 +504,11 @@
}
static int load_module(void)
-{
- return tds_load_module();
+
+ if(!tds_load_module())
+ return AST_MODULE_LOAD_DECLINE;
+ else
+ return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Thu Aug 31 16:00:20 2006
@@ -1113,7 +1113,7 @@
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&agents);
ast_config_destroy(cfg);
- return 0;
+ return 1;
}
static int check_availability(struct agent_pvt *newlyavailable, int needlock)
@@ -2547,6 +2547,11 @@
ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
return -1;
}
+ /* Read in the config */
+ if (!read_agent_config())
+ return AST_MODULE_LOAD_DECLINE;
+ if (persistent_agents)
+ reload_agents();
/* Dialplan applications */
ast_register_application(app, login_exec, synopsis, descrip);
ast_register_application(app2, callback_exec, synopsis2, descrip2);
@@ -2565,10 +2570,6 @@
/* Dialplan Functions */
ast_custom_function_register(&agent_function);
- /* Read in the config */
- read_agent_config();
- if (persistent_agents)
- reload_agents();
return 0;
}
Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Thu Aug 31 16:00:20 2006
@@ -2389,7 +2389,7 @@
}
res = reload_config();
if (res) {
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
} else {
/* Make sure we can register our channel type */
if (ast_channel_register(&oh323_tech)) {
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Aug 31 16:00:20 2006
@@ -9798,7 +9798,8 @@
ast_manager_register( "IAXpeers", 0, manager_iax2_show_peers, "List IAX Peers" );
ast_manager_register( "IAXnetstats", 0, manager_iax2_show_netstats, "Show IAX Netstats" );
- set_config(config, 0);
+ if(set_config(config, 0) == -1)
+ return AST_MODULE_LOAD_DECLINE;
if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Thu Aug 31 16:00:20 2006
@@ -1668,7 +1668,7 @@
ASTOBJ_CONTAINER_INIT(&jingles);
if (!jingle_load_config()) {
ast_log(LOG_ERROR, "Unable to read config file %s. Not loading module.\n", JINGLE_CONFIG);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
sched = sched_context_create();
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Thu Aug 31 16:00:20 2006
@@ -4262,7 +4262,8 @@
/* And start the monitor for the first time */
restart_monitor();
- }
+ } else
+ return AST_MODULE_LOAD_DECLINE;
return res;
}
Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Thu Aug 31 16:00:20 2006
@@ -4499,7 +4499,7 @@
if (misdn_cfg_init(max_ports)) {
ast_log(LOG_ERROR, "Unable to initialize misdn_config.\n");
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
g_config_initialized=1;
Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Thu Aug 31 16:00:20 2006
@@ -1551,7 +1551,7 @@
ast_config_destroy(cfg);
} else {
ast_log(LOG_NOTICE, "Unable to load config oss.conf\n");
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
if (find_desc(oss_active) == NULL) {
ast_log(LOG_NOTICE, "Device %s not found\n", oss_active);
Modified: trunk/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_phone.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_phone.c (original)
+++ trunk/channels/chan_phone.c Thu Aug 31 16:00:20 2006
@@ -1353,7 +1353,7 @@
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_mutex_lock(&iflock)) {
/* It's a little silly to lock it, but we mind as well just to be sure */
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Aug 31 16:00:20 2006
@@ -16533,8 +16533,8 @@
ast_log(LOG_WARNING, "Unable to create I/O context\n");
}
sip_reloadreason = CHANNEL_MODULE_LOAD;
- reload_config(sip_reloadreason); /* Load the configuration from sip.conf */
-
+ if(reload_config(sip_reloadreason)) /* Load the configuration from sip.conf */
+ return AST_MODULE_LOAD_DECLINE;
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Thu Aug 31 16:00:20 2006
@@ -4377,7 +4377,9 @@
}
/* load and parse config */
res = reload_config();
-
+ if(!res) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
ast_rtp_proto_register(&skinny_rtp);
ast_cli_register(&cli_show_devices);
ast_cli_register(&cli_show_lines);
Modified: trunk/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_vpb.cc?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_vpb.cc (original)
+++ trunk/channels/chan_vpb.cc Thu Aug 31 16:00:20 2006
@@ -2872,7 +2872,7 @@
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
vpb_seterrormode(VPB_ERROR_CODE);
Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Thu Aug 31 16:00:20 2006
@@ -11145,7 +11145,7 @@
res = setup_zap(0);
/* Make sure we can register our Zap channel type */
if (res)
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
if (ast_channel_register(&zap_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Zap'\n");
__unload_module();
Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Thu Aug 31 16:00:20 2006
@@ -486,7 +486,7 @@
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to load config for func_odbc: %s\n", config);
AST_LIST_UNLOCK(&queries);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
for (catg = ast_category_browse(cfg, NULL);
Modified: trunk/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_config.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/pbx/pbx_config.c (original)
+++ trunk/pbx/pbx_config.c Thu Aug 31 16:00:20 2006
@@ -1336,7 +1336,7 @@
return 0;
}
-static void pbx_load_config(const char *config_file)
+static int pbx_load_config(const char *config_file)
{
struct ast_config *cfg;
char *end;
@@ -1349,7 +1349,7 @@
cfg = ast_config_load(config_file);
if (!cfg)
- return;
+ return 0;
/* Use existing config to populate the PBX table */
static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
@@ -1491,13 +1491,15 @@
}
}
ast_config_destroy(cfg);
+ return 1;
}
static int pbx_load_module(void)
{
struct ast_context *con;
- pbx_load_config(config);
+ if(!pbx_load_config(config))
+ return AST_MODULE_LOAD_DECLINE;
ast_merge_contexts_and_delete(&local_contexts, registrar);
for (con = NULL; (con = ast_walk_contexts(con));)
@@ -1511,7 +1513,7 @@
static int load_module(void)
{
if (pbx_load_module())
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
ast_cli_register(&context_remove_extension_cli);
ast_cli_register(&context_dont_include_cli);
Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Thu Aug 31 16:00:20 2006
@@ -4488,7 +4488,8 @@
return -1;
}
- set_config("dundi.conf",&sin);
+ if(set_config("dundi.conf",&sin))
+ return AST_MODULE_LOAD_DECLINE;
netsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
Modified: trunk/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_pgsql.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/res/res_config_pgsql.c (original)
+++ trunk/res/res_config_pgsql.c Thu Aug 31 16:00:20 2006
@@ -553,7 +553,8 @@
static int load_module(void)
{
- parse_config();
+ if(!parse_config())
+ return AST_MODULE_LOAD_DECLINE;
ast_mutex_lock(&pgsql_lock);
@@ -624,61 +625,63 @@
return 0;
}
-int parse_config(void)
+static int parse_config(void)
{
struct ast_config *config;
char *s;
config = ast_config_load(RES_CONFIG_PGSQL_CONF);
- if (config) {
- if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
- strcpy(dbuser, "asterisk");
- } else {
- ast_copy_string(dbuser, s, sizeof(dbuser));
- }
-
- if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
- strcpy(dbpass, "asterisk");
- } else {
- ast_copy_string(dbpass, s, sizeof(dbpass));
- }
-
- if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database host found, using localhost via socket.\n");
- dbhost[0] = '\0';
- } else {
- ast_copy_string(dbhost, s, sizeof(dbhost));
- }
-
- if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
- strcpy(dbname, "asterisk");
- } else {
- ast_copy_string(dbname, s, sizeof(dbname));
- }
-
- if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database port found, using 5432 as default.\n");
- dbport = 5432;
- } else {
- dbport = atoi(s);
- }
-
- if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
- strcpy(dbsock, "/tmp/pgsql.sock");
- } else {
- ast_copy_string(dbsock, s, sizeof(dbsock));
- }
+ if (!config) {
+ ast_log(LOG_WARNING, "Unable to load config %s\n",RES_CONFIG_PGSQL_CONF);
+ return 0;
+ }
+ if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
+ strcpy(dbuser, "asterisk");
+ } else {
+ ast_copy_string(dbuser, s, sizeof(dbuser));
+ }
+
+ if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
+ strcpy(dbpass, "asterisk");
+ } else {
+ ast_copy_string(dbpass, s, sizeof(dbpass));
+ }
+
+ if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database host found, using localhost via socket.\n");
+ dbhost[0] = '\0';
+ } else {
+ ast_copy_string(dbhost, s, sizeof(dbhost));
+ }
+
+ if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
+ strcpy(dbname, "asterisk");
+ } else {
+ ast_copy_string(dbname, s, sizeof(dbname));
+ }
+
+ if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database port found, using 5432 as default.\n");
+ dbport = 5432;
+ } else {
+ dbport = atoi(s);
+ }
+
+ if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
+ strcpy(dbsock, "/tmp/pgsql.sock");
+ } else {
+ ast_copy_string(dbsock, s, sizeof(dbsock));
}
ast_config_destroy(config);
Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Thu Aug 31 16:00:20 2006
@@ -2113,153 +2113,155 @@
atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
cfg = ast_config_load("features.conf");
- if (cfg) {
- for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
- if (!strcasecmp(var->name, "parkext")) {
- ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
- } else if (!strcasecmp(var->name, "context")) {
- ast_copy_string(parking_con, var->value, sizeof(parking_con));
- } else if (!strcasecmp(var->name, "parkingtime")) {
- if ((sscanf(var->value, "%d", &parkingtime) != 1) || (parkingtime < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value);
- parkingtime = DEFAULT_PARK_TIME;
- } else
- parkingtime = parkingtime * 1000;
- } else if (!strcasecmp(var->name, "parkpos")) {
- if (sscanf(var->value, "%d-%d", &start, &end) != 2) {
- ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of parking.conf\n", var->lineno);
- } else {
- parking_start = start;
- parking_stop = end;
- }
- } else if (!strcasecmp(var->name, "findslot")) {
- parkfindnext = (!strcasecmp(var->value, "next"));
- } else if (!strcasecmp(var->name, "parkinghints")) {
- parkaddhints = ast_true(var->value);
- } else if (!strcasecmp(var->name, "adsipark")) {
- adsipark = ast_true(var->value);
- } else if (!strcasecmp(var->name, "transferdigittimeout")) {
- if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
- transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
- } else
- transferdigittimeout = transferdigittimeout * 1000;
- } else if (!strcasecmp(var->name, "featuredigittimeout")) {
- if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
- featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
- }
- } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
- if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
- atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
- } else
- atxfernoanswertimeout = atxfernoanswertimeout * 1000;
- } else if (!strcasecmp(var->name, "courtesytone")) {
- ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
- } else if (!strcasecmp(var->name, "parkedplay")) {
- if (!strcasecmp(var->value, "both"))
- parkedplay = 2;
- else if (!strcasecmp(var->value, "parked"))
- parkedplay = 1;
- else
- parkedplay = 0;
- } else if (!strcasecmp(var->name, "xfersound")) {
- ast_copy_string(xfersound, var->value, sizeof(xfersound));
- } else if (!strcasecmp(var->name, "xferfailsound")) {
- ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
- } else if (!strcasecmp(var->name, "pickupexten")) {
- ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
- } else if (!strcasecmp(var->name, "parkedmusicclass")) {
- ast_copy_string(parkmohclass, var->value, sizeof(parkmohclass));
+ if (!cfg) {
+ ast_log(LOG_WARNING,"Could not load features.conf\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+ if (!strcasecmp(var->name, "parkext")) {
+ ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
+ } else if (!strcasecmp(var->name, "context")) {
+ ast_copy_string(parking_con, var->value, sizeof(parking_con));
+ } else if (!strcasecmp(var->name, "parkingtime")) {
+ if ((sscanf(var->value, "%d", &parkingtime) != 1) || (parkingtime < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value);
+ parkingtime = DEFAULT_PARK_TIME;
+ } else
+ parkingtime = parkingtime * 1000;
+ } else if (!strcasecmp(var->name, "parkpos")) {
+ if (sscanf(var->value, "%d-%d", &start, &end) != 2) {
+ ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of parking.conf\n", var->lineno);
+ } else {
+ parking_start = start;
+ parking_stop = end;
}
- }
-
- unmap_features();
- for (var = ast_variable_browse(cfg, "featuremap"); var; var = var->next) {
- if (remap_feature(var->name, var->value))
- ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
- }
-
- /* Map a key combination to an application*/
- ast_unregister_features();
- for (var = ast_variable_browse(cfg, "applicationmap"); var; var = var->next) {
- char *tmp_val = ast_strdupa(var->value);
- char *exten, *activateon, *activatedby, *app, *app_args, *moh_class;
- struct ast_call_feature *feature;
-
- /* strsep() sets the argument to NULL if match not found, and it
- * is safe to use it with a NULL argument, so we don't check
- * between calls.
- */
- exten = strsep(&tmp_val,",");
- activatedby = strsep(&tmp_val,",");
- app = strsep(&tmp_val,",");
- app_args = strsep(&tmp_val,",");
- moh_class = strsep(&tmp_val,",");
-
- activateon = strsep(&activatedby, "/");
-
- /*! \todo XXX var_name or app_args ? */
- if (ast_strlen_zero(app) || ast_strlen_zero(exten) || ast_strlen_zero(activateon) || ast_strlen_zero(var->name)) {
- ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
- app, exten, activateon, var->name);
- continue;
+ } else if (!strcasecmp(var->name, "findslot")) {
+ parkfindnext = (!strcasecmp(var->value, "next"));
+ } else if (!strcasecmp(var->name, "parkinghints")) {
+ parkaddhints = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "adsipark")) {
+ adsipark = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "transferdigittimeout")) {
+ if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
+ transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
+ } else
+ transferdigittimeout = transferdigittimeout * 1000;
+ } else if (!strcasecmp(var->name, "featuredigittimeout")) {
+ if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
+ featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
}
-
- if ((feature = find_feature(var->name))) {
- ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
- continue;
- }
-
- if (!(feature = ast_calloc(1, sizeof(*feature))))
- continue;
-
- ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
- ast_copy_string(feature->app, app, FEATURE_APP_LEN);
- ast_copy_string(feature->exten, exten, FEATURE_EXTEN_LEN);
+ } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
+ if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
+ atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
+ } else
+ atxfernoanswertimeout = atxfernoanswertimeout * 1000;
+ } else if (!strcasecmp(var->name, "courtesytone")) {
+ ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
+ } else if (!strcasecmp(var->name, "parkedplay")) {
+ if (!strcasecmp(var->value, "both"))
+ parkedplay = 2;
+ else if (!strcasecmp(var->value, "parked"))
+ parkedplay = 1;
+ else
+ parkedplay = 0;
+ } else if (!strcasecmp(var->name, "xfersound")) {
+ ast_copy_string(xfersound, var->value, sizeof(xfersound));
+ } else if (!strcasecmp(var->name, "xferfailsound")) {
+ ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
+ } else if (!strcasecmp(var->name, "pickupexten")) {
+ ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
+ } else if (!strcasecmp(var->name, "parkedmusicclass")) {
+ ast_copy_string(parkmohclass, var->value, sizeof(parkmohclass));
+ }
+ }
+
+ unmap_features();
+ for (var = ast_variable_browse(cfg, "featuremap"); var; var = var->next) {
+ if (remap_feature(var->name, var->value))
+ ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
+ }
+
+ /* Map a key combination to an application*/
+ ast_unregister_features();
+ for (var = ast_variable_browse(cfg, "applicationmap"); var; var = var->next) {
+ char *tmp_val = ast_strdupa(var->value);
+ char *exten, *activateon, *activatedby, *app, *app_args, *moh_class;
+ struct ast_call_feature *feature;
+
+ /* strsep() sets the argument to NULL if match not found, and it
+ * is safe to use it with a NULL argument, so we don't check
+ * between calls.
+ */
+ exten = strsep(&tmp_val,",");
+ activatedby = strsep(&tmp_val,",");
+ app = strsep(&tmp_val,",");
+ app_args = strsep(&tmp_val,",");
+ moh_class = strsep(&tmp_val,",");
+
+ activateon = strsep(&activatedby, "/");
+
+ /*! \todo XXX var_name or app_args ? */
+ if (ast_strlen_zero(app) || ast_strlen_zero(exten) || ast_strlen_zero(activateon) || ast_strlen_zero(var->name)) {
+ ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
+ app, exten, activateon, var->name);
+ continue;
+ }
+
+ if ((feature = find_feature(var->name))) {
+ ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
+ continue;
+ }
+
+ if (!(feature = ast_calloc(1, sizeof(*feature))))
+ continue;
+
+ ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
+ ast_copy_string(feature->app, app, FEATURE_APP_LEN);
+ ast_copy_string(feature->exten, exten, FEATURE_EXTEN_LEN);
+
+ if (app_args)
+ ast_copy_string(feature->app_args, app_args, FEATURE_APP_ARGS_LEN);
+
+ if (moh_class)
+ ast_copy_string(feature->moh_class, moh_class, FEATURE_MOH_LEN);
- if (app_args)
- ast_copy_string(feature->app_args, app_args, FEATURE_APP_ARGS_LEN);
-
- if (moh_class)
- ast_copy_string(feature->moh_class, moh_class, FEATURE_MOH_LEN);
-
- ast_copy_string(feature->exten, exten, sizeof(feature->exten));
- feature->operation = feature_exec_app;
- ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
-
- /* Allow caller and calle to be specified for backwards compatability */
- if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller"))
- ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
- else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee"))
- ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
- else {
- ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
- " must be 'self', or 'peer'\n", var->name);
- continue;
- }
-
- if (ast_strlen_zero(activatedby))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- else if (!strcasecmp(activatedby, "caller"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
- else if (!strcasecmp(activatedby, "callee"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
- else if (!strcasecmp(activatedby, "both"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- else {
- ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
- " must be 'caller', or 'callee', or 'both'\n", var->name);
- continue;
- }
-
- ast_register_feature(feature);
-
- if (option_verbose >= 1)
- ast_verbose(VERBOSE_PREFIX_2 "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n", var->name, app, app_args, exten);
- }
- }
+ ast_copy_string(feature->exten, exten, sizeof(feature->exten));
+ feature->operation = feature_exec_app;
+ ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
+
+ /* Allow caller and calle to be specified for backwards compatability */
+ if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
+ else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
+ else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
+ " must be 'self', or 'peer'\n", var->name);
+ continue;
+ }
+
+ if (ast_strlen_zero(activatedby))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ else if (!strcasecmp(activatedby, "caller"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
+ else if (!strcasecmp(activatedby, "callee"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
+ else if (!strcasecmp(activatedby, "both"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
+ " must be 'caller', or 'callee', or 'both'\n", var->name);
+ continue;
+ }
+
+ ast_register_feature(feature);
+
+ if (option_verbose >= 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n", var->name, app, app_args, exten);
+ }
ast_config_destroy(cfg);
/* Remove the old parking extension */
Modified: trunk/res/res_indications.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_indications.c?rev=41633&r1=41632&r2=41633&view=diff
==============================================================================
--- trunk/res/res_indications.c (original)
[... 914 lines stripped ...]
More information about the asterisk-commits
mailing list