Merge config updates (bug #3406)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4889 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer 2005-01-25 06:10:20 +00:00
parent a611ce04f1
commit 5f726ad8c7
49 changed files with 881 additions and 856 deletions

View File

@ -1 +1 @@
2
3

View File

@ -231,7 +231,7 @@ OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o \
dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
utils.o
utils.o config_old.o
ifeq (${OSARCH},Darwin)
OBJS+=poll.o dlfcn.o
ASTLINK=-Wl,-dynamic
@ -597,4 +597,3 @@ cleantest:
if ! cmp -s .cleancount .lastclean ; then \
$(MAKE) clean; cp -f .cleancount .lastclean;\
fi

View File

@ -747,7 +747,7 @@ static int load_config(void)
/* Read in the config file */
cfg = ast_load(ALMRCV_CONFIG);
cfg = ast_config_load(ALMRCV_CONFIG);
if(!cfg){
@ -817,7 +817,7 @@ static int load_config(void)
strncpy(db_family, p, sizeof(db_family) - 1);
db_family[sizeof(db_family) - 1] = '\0';
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
return 0;

View File

@ -351,7 +351,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "directory requires an argument (context[,dialcontext])\n");
return -1;
}
cfg = ast_load(DIRECTORY_CONFIG);
cfg = ast_config_load(DIRECTORY_CONFIG);
if (!cfg) {
ast_log(LOG_WARNING, "Unable to open directory configuration %s\n", DIRECTORY_CONFIG);
return -1;
@ -400,7 +400,7 @@ top:
}
}
}
ast_destroy(cfg);
ast_config_destroy(cfg);
LOCAL_USER_REMOVE(u);
return res;
}

View File

@ -145,14 +145,14 @@ static int load_config(void)
struct ast_config *cfg;
char *s;
cfg = ast_load(ENUM_CONFIG);
cfg = ast_config_load(ENUM_CONFIG);
if (cfg) {
if (!(s=ast_variable_retrieve(cfg, "general", "h323driver"))) {
strncpy(h323driver, H323DRIVERDEFAULT, sizeof(h323driver) - 1);
} else {
strncpy(h323driver, s, sizeof(h323driver) - 1);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
ast_log(LOG_NOTICE, "No ENUM Config file, using defaults\n");

View File

@ -282,7 +282,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
char *intstr;
struct ast_config *cfg;
cfg = ast_load(FESTIVAL_CONFIG);
cfg = ast_config_load(FESTIVAL_CONFIG);
if (!cfg) {
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
return -1;
@ -308,7 +308,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
}
if (!vdata || ast_strlen_zero(vdata)) {
ast_log(LOG_WARNING, "festival requires an argument (text)\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
strncpy(data, vdata, sizeof(data) - 1);
@ -326,7 +326,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (fd < 0) {
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
memset(&serv_addr, 0, sizeof(serv_addr));
@ -335,7 +335,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
serverhost = ast_gethostbyname(host, &ahp);
if (serverhost == (struct hostent *)0) {
ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
@ -345,7 +345,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
ast_log(LOG_WARNING,"festival_client: connect to server failed\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
@ -448,7 +448,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
}
} while (strcmp(ack,"OK\n") != 0);
close(fd);
ast_destroy(cfg);
ast_config_destroy(cfg);
LOCAL_USER_REMOVE(u);
return res;

View File

@ -1187,7 +1187,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
}
} else {
/* Check the config */
cfg = ast_load("meetme.conf");
cfg = ast_config_load("meetme.conf");
if (!cfg) {
ast_log(LOG_WARNING, "No meetme.conf file :(\n");
return NULL;
@ -1215,7 +1215,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
if (!var) {
ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
} else if (dynamic_pin) {
/* Correct for the user selecting 'D' instead of 'd' to have
@ -1373,7 +1373,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
/* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */
if ((empty_no_pin) || (!dynamic)) {
cfg = ast_load("meetme.conf");
cfg = ast_config_load("meetme.conf");
if (cfg) {
var = ast_variable_browse(cfg, "rooms");
while(var) {
@ -1421,7 +1421,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
}
var = var->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
}
/* Select first conference number not in use */

View File

@ -82,7 +82,7 @@ privacy_exec (struct ast_channel *chan, void *data)
}
}
/*Read in the config file*/
cfg = ast_load(PRIV_CONFIG);
cfg = ast_config_load(PRIV_CONFIG);
/*Play unidentified call*/
@ -144,7 +144,7 @@ privacy_exec (struct ast_channel *chan, void *data)
chan->priority+=100;
}
if (cfg)
ast_destroy(cfg);
ast_config_destroy(cfg);
}
LOCAL_USER_REMOVE (u);

View File

@ -2388,7 +2388,7 @@ static void reload_queues(void)
int new;
char *general_val = NULL;
cfg = ast_load("queues.conf");
cfg = ast_config_load("queues.conf");
if (!cfg) {
ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
return;
@ -2578,7 +2578,7 @@ static void reload_queues(void)
}
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
q = queues;
ql = NULL;
while(q) {

View File

@ -185,7 +185,7 @@ static int realtime_exec(struct ast_channel *chan, void *data)
pbx_builtin_setvar_helper(chan, vname, itt->value);
}
ast_destroy_realtime(var);
ast_variables_destroy(var);
} else if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4"No Realtime Matches Found.\n");
}

View File

@ -3856,7 +3856,7 @@ pthread_attr_t attr;
/* start with blank config */
memset(&rpt_vars,0,sizeof(rpt_vars));
cfg = ast_load("rpt.conf");
cfg = ast_config_load("rpt.conf");
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n");
pthread_exit(NULL);

View File

@ -87,14 +87,14 @@ static int load_config(void)
struct ast_config *cfg;
char *s;
cfg = ast_load(ENUM_CONFIG);
cfg = ast_config_load(ENUM_CONFIG);
if (cfg) {
if (!(s=ast_variable_retrieve(cfg, "general", "h323driver"))) {
strncpy(h323driver, H323DRIVERDEFAULT, sizeof(h323driver) - 1);
} else {
strncpy(h323driver, s, sizeof(h323driver) - 1);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
ast_log(LOG_NOTICE, "No ENUM Config file, using defaults\n");

View File

@ -1072,7 +1072,7 @@ static int store_file(char *dir, int msgnum)
else
strncpy(fn, dir, sizeof(fn) - 1);
snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
cfg = ast_load(full_fn);
cfg = ast_config_load(full_fn);
snprintf(full_fn, sizeof(full_fn), "%s.%s", fn, fmt);
fd = open(full_fn, O_RDWR);
if (fd < 0) {
@ -1144,7 +1144,7 @@ static int store_file(char *dir, int msgnum)
ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
yuck:
if (cfg)
ast_destroy(cfg);
ast_config_destroy(cfg);
if (fdm)
munmap(fdm, fdlen);
if (fd > -1)
@ -3091,7 +3091,7 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
/* load the information on the source message so we can send an e-mail like a new message */
snprintf(miffile, sizeof(miffile), "%s/msg%04d.txt", dir, curmsg);
if ((mif=ast_load(miffile))) {
if ((mif=ast_config_load(miffile))) {
/* set callerid and duration variables */
snprintf(callerid, sizeof(callerid), "FWD from: %s from %s", sender->fullname, ast_variable_retrieve(mif, NULL, "callerid"));
@ -3116,7 +3116,7 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, duration, vmtmp);
}
ast_destroy(mif); /* or here */
ast_config_destroy(mif); /* or here */
}
/* Leave voicemail for someone */
manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
@ -3344,7 +3344,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
RETRIEVE(vms->curdir, vms->curmsg);
msg_cfg = ast_load(filename);
msg_cfg = ast_config_load(filename);
if (!msg_cfg) {
ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
return 0;
@ -3375,7 +3375,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
/* Allow pressing '1' to skip envelope / callerid */
if (res == '1')
res = 0;
ast_destroy(msg_cfg);
ast_config_destroy(msg_cfg);
if (!res) {
make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
@ -5139,7 +5139,7 @@ static int load_config(void)
int x;
int tmpadsi[4];
cfg = ast_load(VOICEMAIL_CONFIG);
cfg = ast_config_load(VOICEMAIL_CONFIG);
ast_mutex_lock(&vmlock);
cur = users;
while (cur) {
@ -5475,7 +5475,7 @@ static int load_config(void)
tmpread = tmpwrite+len;
}
}
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&vmlock);
return 0;
} else {
@ -5605,7 +5605,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
msg_cfg = ast_load(filename);
msg_cfg = ast_config_load(filename);
if (!msg_cfg) {
ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
return 0;
@ -5735,7 +5735,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
}
}
ast_destroy(msg_cfg);
ast_config_destroy(msg_cfg);
if (!res) {
make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);

View File

@ -48,7 +48,6 @@
#include "editline/histedit.h"
#include "asterisk.h"
#include <asterisk/config.h>
#include <asterisk/config_pvt.h>
#include <sys/resource.h>
#include <grp.h>
#include <pwd.h>
@ -1498,11 +1497,11 @@ static void ast_readconfig(void) {
char *config = ASTCONFPATH;
if (option_overrideconfig == 1) {
cfg = ast_load((char *)ast_config_AST_CONFIG_FILE);
cfg = ast_config_load((char *)ast_config_AST_CONFIG_FILE);
if (!cfg)
ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using builtin defaults\n", ast_config_AST_CONFIG_FILE);
} else {
cfg = ast_load(config);
cfg = ast_config_load(config);
}
/* init with buildtime config */
@ -1571,7 +1570,7 @@ static void ast_readconfig(void) {
}
v = v->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
int main(int argc, char *argv[])
@ -1742,10 +1741,10 @@ int main(int argc, char *argv[])
ast_readconfig();
if (option_console && !option_verbose)
ast_verbose("[ Initializing Custom Configuration Options]");
ast_verbose("[ Initializing Custom Configuration Options ]");
/* custom config setup */
register_config_cli();
read_ast_cust_config();
read_config_maps();
if (option_console) {

View File

@ -36,7 +36,7 @@ static void loadconfigurationfile(void)
struct ast_config *cfg;
struct ast_variable *v;
cfg = ast_load(CONF_FILE);
cfg = ast_config_load(CONF_FILE);
if (!cfg) {
/* Standard configuration */
enablecdr = 0;
@ -60,7 +60,7 @@ static void loadconfigurationfile(void)
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
static int manager_log(struct ast_cdr *cdr)

View File

@ -231,7 +231,7 @@ static int odbc_load_module(void)
ast_mutex_lock(&odbc_lock);
cfg = ast_load(config);
cfg = ast_config_load(config);
if (!cfg) {
ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
goto out;
@ -331,7 +331,7 @@ static int odbc_load_module(void)
table = "cdr";
}
ast_destroy(cfg);
ast_config_destroy(cfg);
if (option_verbose > 2) {
ast_verbose( VERBOSE_PREFIX_3 "cdr_odbc: dsn is %s\n",dsn);
ast_verbose( VERBOSE_PREFIX_3 "cdr_odbc: username is %s\n",username);

View File

@ -330,13 +330,13 @@ static int my_load_module(void)
{
struct ast_config *cfg;
int res;
cfg = ast_load(config);
cfg = ast_config_load(config);
if (!cfg) {
ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
return 0;
}
res = process_my_load_module(cfg);
ast_destroy(cfg);
ast_config_destroy(cfg);
return res;
}

View File

@ -391,7 +391,7 @@ int load_module(void)
TDS_INT result_type;
#endif
cfg = ast_load(config);
cfg = ast_config_load(config);
if (!cfg)
{
ast_log(LOG_NOTICE, "Unable to load config for MSSQL CDR's: %s\n", config);
@ -462,7 +462,7 @@ int load_module(void)
language = strdupa("us_english");
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* Connect to M$SQL Server */
if (!(login = tds_alloc_login()))

View File

@ -876,7 +876,7 @@ static int read_agent_config(void)
autologoff = 0;
wrapuptime = 0;
ackcall = 1;
cfg = ast_load(config);
cfg = ast_config_load(config);
if (!cfg) {
ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
return 0;
@ -988,7 +988,7 @@ static int read_agent_config(void)
p = pn;
}
ast_mutex_unlock(&agentlock);
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}

View File

@ -990,7 +990,7 @@ int load_module()
int x;
struct ast_config *cfg;
struct ast_variable *v;
if ((cfg = ast_load(config))) {
if ((cfg = ast_config_load(config))) {
v = ast_variable_browse(cfg, "general");
while(v) {
if (!strcasecmp(v->name, "autoanswer"))
@ -1011,7 +1011,7 @@ int load_module()
strncpy(outdevname, v->value, sizeof(outdevname)-1);
v=v->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
res = pipe(sndcmd);
if (res) {

View File

@ -1728,7 +1728,7 @@ int reload_config(void)
char *cat;
char *utype;
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -1867,7 +1867,7 @@ int reload_config(void)
}
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* Register our H.323 aliases if any*/
while (alias) {

View File

@ -15,7 +15,6 @@
#include <asterisk/frame.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/config_pvt.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>
@ -1470,7 +1469,7 @@ retry:
}
if (!owner) {
if (pvt->vars) {
ast_destroy_realtime(pvt->vars);
ast_variables_destroy(pvt->vars);
pvt->vars = NULL;
}
free(pvt);
@ -2170,7 +2169,7 @@ static struct iax2_peer *realtime_peer(const char *peername)
}
}
}
ast_destroy_realtime(var);
ast_variables_destroy(var);
}
return peer;
}
@ -2201,12 +2200,12 @@ static struct iax2_user *realtime_user(const char *username)
tmp = tmp->next;
}
}
ast_destroy_realtime(var);
ast_variables_destroy(var);
}
return user;
}
static void realtime_update(const char *peername, struct sockaddr_in *sin)
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin)
{
char port[10];
char ipaddr[20];
@ -4090,7 +4089,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
/* We found our match (use the first) */
/* copy vars */
for (v = user->vars ; v ; v = v->next) {
if((tmpvar = ast_new_variable(v->name, v->value))) {
if((tmpvar = ast_variable_new(v->name, v->value))) {
tmpvar->next = iaxs[callno]->vars;
iaxs[callno]->vars = tmpvar;
}
@ -4871,7 +4870,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
p = find_peer(name);
if (p) {
if (ast_test_flag(p, IAX_TEMPONLY))
realtime_update(name, sin);
realtime_update_peer(name, sin);
if (inaddrcmp(&p->addr, sin)) {
if (iax2_regfunk)
iax2_regfunk(p->name, 1);
@ -7297,7 +7296,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, in
if (varname && (varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if((tmpvar = ast_new_variable(varname, varval))) {
if((tmpvar = ast_variable_new(varname, varval))) {
tmpvar->next = user->vars;
user->vars = tmpvar;
}
@ -7421,7 +7420,7 @@ static void destroy_user(struct iax2_user *user)
ast_free_ha(user->ha);
free_context(user->contexts);
if(user->vars) {
ast_destroy_realtime(user->vars);
ast_variables_destroy(user->vars);
user->vars = NULL;
}
free(user);
@ -7521,7 +7520,7 @@ static int set_config(char *config_file, int reload)
static unsigned short int last_port=0;
#endif
cfg = ast_load(config_file);
cfg = ast_config_load(config_file);
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
@ -7688,7 +7687,7 @@ static int set_config(char *config_file, int reload)
}
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
set_timing();
return capability;
}

View File

@ -4043,7 +4043,7 @@ static int reload_config(void)
ast_log(LOG_WARNING, "Unable to get hostname, MGCP disabled\n");
return 0;
}
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -4144,7 +4144,7 @@ static int reload_config(void)
hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to get our IP address, MGCP disabled\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
@ -4181,7 +4181,7 @@ static int reload_config(void)
}
}
ast_mutex_unlock(&netlock);
ast_destroy(cfg);
ast_config_destroy(cfg);
/* SC: send audit only to the new endpoints */
g = gateways;

View File

@ -949,7 +949,7 @@ int load_module()
struct ast_variable *v;
struct ast_modem_pvt *tmp;
char driver[80];
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -972,7 +972,7 @@ int load_module()
} else {
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
__unload_module();
return -1;
@ -984,7 +984,7 @@ int load_module()
if (ast_load_resource(driver)) {
ast_log(LOG_ERROR, "Failed to load driver %s\n", driver);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
__unload_module();
return -1;
@ -1055,11 +1055,11 @@ int load_module()
if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
AST_FORMAT_SLINEAR, modem_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_destroy(cfg);
ast_config_destroy(cfg);
__unload_module();
return -1;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* And start the monitor for the first time */
restart_monitor();
return 0;

View File

@ -1026,7 +1026,7 @@ int load_module()
}
for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
ast_cli_register(myclis + x);
if ((cfg = ast_load(config))) {
if ((cfg = ast_config_load(config))) {
v = ast_variable_browse(cfg, "general");
while(v) {
if (!strcasecmp(v->name, "autoanswer"))
@ -1045,7 +1045,7 @@ int load_module()
playbackonly = ast_true(v->value);
v=v->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
ast_pthread_create(&sthread, NULL, sound_thread, NULL);
return 0;

View File

@ -1232,7 +1232,7 @@ int load_module()
struct phone_pvt *tmp;
int mode = MODE_IMMEDIATE;
int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -1255,7 +1255,7 @@ int load_module()
} else {
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
__unload_module();
return -1;
@ -1316,11 +1316,11 @@ int load_module()
AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR |
AST_FORMAT_ULAW : prefformat, phone_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_destroy(cfg);
ast_config_destroy(cfg);
__unload_module();
return -1;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* And start the monitor for the first time */
restart_monitor();
return 0;

View File

@ -18,7 +18,6 @@
#include <asterisk/lock.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/config_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@ -1137,7 +1136,7 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
while(tmp) {
if (!strcasecmp(tmp->name, "type") &&
!strcasecmp(tmp->value, "user")) {
ast_destroy_realtime(var);
ast_variables_destroy(var);
return NULL;
}
tmp = tmp->next;
@ -1146,7 +1145,7 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
peer = build_peer(peername, var, 1);
if (peer)
ast_set_flag(peer, SIP_REALTIME);
ast_destroy_realtime(var);
ast_variables_destroy(var);
return peer;
}
@ -1180,7 +1179,7 @@ static void sip_destroy_user(struct sip_user *user)
{
ast_free_ha(user->ha);
if(user->vars) {
ast_destroy_realtime(user->vars);
ast_variables_destroy(user->vars);
user->vars = NULL;
}
if (ast_test_flag(user, SIP_REALTIME))
@ -1206,7 +1205,7 @@ static struct sip_user *realtime_user(const char *username)
while (tmp) {
if (!strcasecmp(tmp->name, "type") &&
!strcasecmp(tmp->value, "peer")) {
ast_destroy_realtime(var);
ast_variables_destroy(var);
return NULL;
}
tmp = tmp->next;
@ -1220,7 +1219,7 @@ static struct sip_user *realtime_user(const char *username)
/* Add some finishing touches, addresses, etc */
ast_set_flag(user, SIP_REALTIME);
}
ast_destroy_realtime(var);
ast_variables_destroy(var);
return user;
}
@ -1531,7 +1530,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
}
ast_mutex_destroy(&p->lock);
if(p->vars) {
ast_destroy_realtime(p->vars);
ast_variables_destroy(p->vars);
p->vars = NULL;
}
free(p);
@ -2295,7 +2294,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno));
ast_mutex_destroy(&p->lock);
if(p->vars) {
ast_destroy_realtime(p->vars);
ast_variables_destroy(p->vars);
p->vars = NULL;
}
free(p);
@ -5569,7 +5568,7 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, char *cmd
ast_copy_flags(p, user, SIP_TRUSTRPID | SIP_USECLIENTCODE | SIP_NAT | SIP_PROG_INBAND | SIP_OSPAUTH);
/* copy vars */
for (v = user->vars ; v ; v = v->next) {
if((tmpvar = ast_new_variable(v->name, v->value))) {
if((tmpvar = ast_variable_new(v->name, v->value))) {
tmpvar->next = p->vars;
p->vars = tmpvar;
}
@ -8693,7 +8692,7 @@ static struct sip_user *build_user(const char *name, struct ast_variable *v, int
if (varname && (varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if((tmpvar = ast_new_variable(varname, varval))) {
if((tmpvar = ast_variable_new(varname, varval))) {
tmpvar->next = user->vars;
user->vars = tmpvar;
}
@ -9012,7 +9011,7 @@ static int reload_config(void)
ast_log(LOG_WARNING, "Unable to get hostname, SIP disabled\n");
return 0;
}
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -9252,7 +9251,7 @@ static int reload_config(void)
if (!hp) {
ast_log(LOG_WARNING, "Unable to get IP address for %s, SIP disabled\n", ourhost);
if (!__ourip.s_addr) {
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
} else
@ -9297,12 +9296,12 @@ static int reload_config(void)
ast_mutex_unlock(&netlock);
/* Release configuration from memory */
ast_destroy(cfg);
ast_config_destroy(cfg);
/* Load the list of manual NOTIFY types to support */
if (notify_types)
ast_destroy(notify_types);
notify_types = ast_load(notify_config);
ast_config_destroy(notify_types);
notify_types = ast_config_load(notify_config);
return 0;
}
@ -9740,7 +9739,7 @@ int unload_module()
/* Free associated memory */
ast_mutex_destroy(&pl->lock);
if(pl->vars) {
ast_destroy_realtime(pl->vars);
ast_variables_destroy(pl->vars);
pl->vars = NULL;
}
free(pl);

View File

@ -2639,7 +2639,7 @@ static int reload_config(void)
return 0;
}
#endif
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -2690,7 +2690,7 @@ static int reload_config(void)
hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to get our IP address, Skinny disabled\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
@ -2726,7 +2726,7 @@ static int reload_config(void)
skinnysock = socket(AF_INET, SOCK_STREAM, 0);
if(setsockopt(skinnysock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
ast_log(LOG_ERROR, "Set Socket Options failed: errno %d, %s", errno, strerror(errno));
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
@ -2739,7 +2739,7 @@ static int reload_config(void)
strerror(errno));
close(skinnysock);
skinnysock = -1;
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
@ -2749,7 +2749,7 @@ static int reload_config(void)
strerror(errno));
close(skinnysock);
skinnysock = -1;
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}
@ -2763,7 +2763,7 @@ static int reload_config(void)
ast_mutex_unlock(&netlock);
/* and unload the configuration when were done */
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}

View File

@ -2425,7 +2425,7 @@ int load_module()
int bal3 = -1;
char * callerid = NULL;
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -2530,7 +2530,7 @@ int load_module()
done: (void)0;
} ast_mutex_unlock(&iflock);
ast_destroy(cfg);
ast_config_destroy(cfg);
if (!error && ast_channel_register(type, tdesc, prefformat, vpb_request) != 0) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);

View File

@ -9236,7 +9236,7 @@ static int setup_zap(int reload)
struct zt_pri *pri;
#endif
cfg = ast_load(config);
cfg = ast_config_load(config);
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
@ -9321,7 +9321,7 @@ static int setup_zap(int reload)
if (reload == 0) {
if (cur_signalling < 0) {
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9333,13 +9333,13 @@ static int setup_zap(int reload)
if (!strcasecmp(v->name, "crv")) {
if (sscanf(c, "%d:%n", &trunkgroup, &y) != 1) {
ast_log(LOG_WARNING, "CRV must begin with trunkgroup followed by a colon at line %d\n", v->lineno);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
if (trunkgroup < 1) {
ast_log(LOG_WARNING, "CRV trunk group must be a postive number at line %d\n", v->lineno);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9352,7 +9352,7 @@ static int setup_zap(int reload)
}
if (!pri) {
ast_log(LOG_WARNING, "No such trunk group %d at CRV declaration at line %d\n", trunkgroup, v->lineno);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9370,7 +9370,7 @@ static int setup_zap(int reload)
found_pseudo = 1;
} else {
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9401,7 +9401,7 @@ static int setup_zap(int reload)
ast_log(LOG_ERROR, "Unable to reconfigure channel '%s'\n", v->value);
else
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9741,7 +9741,7 @@ static int setup_zap(int reload)
switchtype = PRI_SWITCH_QSIG;
else {
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;
}
@ -9923,7 +9923,7 @@ static int setup_zap(int reload)
}
}
ast_mutex_unlock(&iflock);
ast_destroy(cfg);
ast_config_destroy(cfg);
#ifdef ZAPATA_PRI
if (!reload) {
for (x=0;x<NUM_SPANS;x++) {

View File

@ -483,7 +483,7 @@ int iax_provision_reload(void)
cur->dead = 1;
cur = cur->next;
}
cfg = ast_load("iaxprov.conf");
cfg = ast_config_load("iaxprov.conf");
if (cfg) {
/* Load as appropriate */
cat = ast_category_browse(cfg, NULL);

View File

@ -308,7 +308,7 @@ static void parse_config(void)
struct ast_variable *var;
int res;
if ((cfg = ast_load("codecs.conf"))) {
if ((cfg = ast_config_load("codecs.conf"))) {
if ((var = ast_variable_browse(cfg, "speex"))) {
while (var) {
if (!strcasecmp(var->name, "quality")) {

1077
config.c

File diff suppressed because it is too large Load Diff

4
enum.c
View File

@ -413,7 +413,7 @@ int ast_enum_init(void)
free(sl);
}
toplevs = NULL;
cfg = ast_load("enum.conf");
cfg = ast_config_load("enum.conf");
if (cfg) {
sl = NULL;
v = ast_variable_browse(cfg, "general");
@ -430,7 +430,7 @@ int ast_enum_init(void)
}
v = v->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
} else {
toplevs = enum_newtoplev(TOPLEV);
}

View File

@ -3,9 +3,9 @@
*
* Configuration File Parser
*
* Copyright (C) 1999, Mark Spencer
* Copyright (C) 1999-2005, Mark Spencer
*
* Mark Spencer <markster@linux-support.net>
* Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@ -18,12 +18,11 @@
extern "C" {
#endif
#include <stdarg.h>
struct ast_config;
struct ast_comment {
struct ast_comment *next;
char cmt[0];
};
struct ast_category;
struct ast_variable {
char *name;
@ -37,35 +36,54 @@ struct ast_variable {
char stuff[0];
};
#include <asterisk/config_old.h>
typedef struct ast_config *config_load_func(const char *database, const char *table, const char *configfile, struct ast_config *config);
typedef struct ast_variable *realtime_var_get(const char *database, const char *table, va_list ap);
typedef struct ast_config *realtime_multi_get(const char *database, const char *table, va_list ap);
typedef int realtime_update(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap);
struct ast_config_engine {
char *name;
config_load_func *load_func;
realtime_var_get *realtime_func;
realtime_multi_get *realtime_multi_func;
realtime_update *update_func;
struct ast_config_engine *next;
};
/*! Load a config file */
/*!
* \param configfile path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR
* Create a config structure from a given configuration file.
*
* Returns NULL on error, or an ast_config data structure on success
*/
struct ast_config *ast_load(char *configfile);
struct ast_config *ast_config_load(const char *filename);
/*! Removes a config */
/*! Destroys a config */
/*!
* \param config config data structure associated with the config.
* \param config pointer to config data structure
* Free memory associated with a given config
* Returns nothing
*
*/
void ast_destroy(struct ast_config *config);
void ast_config_destroy(struct ast_config *config);
/*! Goes through categories */
/*!
* \param config Which config file you wish to "browse"
* \param config Which config structure you wish to "browse"
* \param prev A pointer to a previous category.
* This funtion is kind of non-intuitive in it's use. To begin, one passes NULL as the second arguement. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards. Note: If you manually strcpy a string into a character array and pass it thinking it will return your category, it will not; the comparisons are not done doing strcmp, they are done by checking whether the value of the string POINTER is the same.
* This funtion is kind of non-intuitive in it's use. To begin, one passes NULL as the second arguement. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards.
*
* Returns a category on success, or NULL on failure/no-more-categories
*/
char *ast_category_browse(struct ast_config *config, char *prev);
char *ast_category_browse(struct ast_config *config, const char *prev);
/*! Goes through variables */
/*!
* Somewhat similar in intent as the ast_category_browse. The category MUST be an actual pointer to an actual category (such as one obtained by using ast_category_browse()).
* List variables of config file
* Somewhat similar in intent as the ast_category_browse.
* List variables of config file category
*
* Returns ast_variable list on success, or NULL on failure
*/
struct ast_variable *ast_variable_browse(const struct ast_config *config, const char *category);
@ -73,43 +91,51 @@ struct ast_variable *ast_variable_browse(const struct ast_config *config, const
/*! Gets a variable */
/*!
* \param config which (opened) config to use
* \param category category under which the variable lies (must be a pointer to the category, such as one given by ast_category_browse)
* \param category category under which the variable lies
* \param value which variable you wish to get the data for
* Goes through a given config file in the given category and searches for the given variable
*
* Returns the variable value on success, or NULL if unable to find it.
* Retrieve a specific variable */
char *ast_variable_retrieve(const struct ast_config *config, const char *category, const char *value);
*/
char *ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable);
/*! Make sure something is true */
/*!
* Determine affermativeness of a boolean value.
* This function checks to see whether a string passed to it is an indication of an affirmitave value. It checks to see if the string is "yes", "true", "y", "t", and "1".
* Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood.
* Determine if a string containing a boolean value is "true".
* This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
*
* Returns 0 if val is a NULL pointer, -1 if "true", and 0 otherwise.
*/
int ast_true(const char *val);
/*! Make sure something is false */
/*!
* Determine falseness of a boolean value.
* This function checks to see whether a string passed to it is an indication of a negatirve value. It checks to see if the string is "no", "false", "n", "f", and "0".
* Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood.
* Determine if a string containing a boolean value is "false".
* This function checks to see whether a string passed to it is an indication of an "false" value. It checks to see if the string is "no", "false", "n", "f", "off" or "0".
*
* Returns 0 if val is a NULL pointer, -1 if "false", and 0 otherwise.
*/
int ast_false(const char *val);
/*! Retrieve a category if it exists
/*! Retrieve a category if it exists */
/*!
* \param config which config to use
* \param category_name name of the category you're looking for
* This will search through the categories within a given config file and search for a match. The passed category_name can be a regular string.
* Returns pointer to category if found, NULL if not. */
* This will search through the categories within a given config file for a match.
*
* Returns pointer to category if found, NULL if not.
*/
struct ast_category *ast_category_get(const struct ast_config *config, const char *category_name);
/*! Check for category duplicates */
/*!
* \param config which config to use
* \param category_name name of the category you're looking for
* This will search through the categories within a given config file and search for a match. The passed category_name can be a regular string (as opposed to a pointer of an existent string, lol)
* Browse config structure and check for category duplicity Return non-zero if found */
int ast_category_exist(struct ast_config *config, char *category_name);
* This will search through the categories within a given config file for a match.
*
* Return non-zero if found
*/
int ast_category_exist(const struct ast_config *config, const char *category_name);
/*! Retrieve realtime configuration */
/*!
@ -148,18 +174,39 @@ struct ast_config *ast_load_realtime_multientry(const char *family, ...);
*/
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...);
/*! Free realtime configuration */
/*! Free variable list */
/*!
* \param var the linked list of variables to free
* This command free's a list of variables and should ONLY be used
* in conjunction with ast_load_realtime and not with the regular ast_load.
* This function frees a list of variables.
*/
void ast_destroy_realtime(struct ast_variable *var);
void ast_variables_destroy(struct ast_variable *var);
int ast_config_engine_register(struct ast_config_engine *new);
int ast_config_engine_deregister(struct ast_config_engine *del);
int register_config_cli(void);
void read_config_maps(void);
struct ast_config *ast_config_new(void);
struct ast_category *ast_config_get_current_category(const struct ast_config *cfg);
void ast_config_set_current_category(struct ast_config *cfg, const struct ast_category *cat);
struct ast_category *ast_category_new(const char *name);
void ast_category_append(struct ast_config *config, struct ast_category *cat);
int ast_category_delete(struct ast_config *cfg, char *category);
void ast_category_destroy(struct ast_category *cat);
struct ast_variable *ast_category_detach_variables(struct ast_category *cat);
void ast_category_rename(struct ast_category *cat, const char *name);
struct ast_variable *ast_variable_new(const char *name, const char *value);
void ast_variable_append(struct ast_category *category, struct ast_variable *variable);
int ast_variable_delete(struct ast_config *cfg, char *category, char *variable, char *value);
int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
struct ast_config *ast_config_internal_load(const char *configfile, struct ast_config *cfg);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif

View File

@ -19,7 +19,6 @@
#include <asterisk/module.h>
#include <asterisk/options.h>
#include <asterisk/config.h>
#include <asterisk/config_pvt.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/term.h>
@ -169,9 +168,9 @@ char *ast_module_helper(char *line, char *word, int pos, int state, int rpos, in
ret = strdup(m->resource);
} else {
ret = NULL;
if (!strncasecmp(word, "astconfig", strlen(word))) {
if (!strncasecmp(word, "extconfig", strlen(word))) {
if (++which > state)
ret = strdup("astconfig");
ret = strdup("extconfig");
} else if (!strncasecmp(word, "manager", strlen(word))) {
if (++which > state)
ret = strdup("manager");
@ -200,8 +199,8 @@ int ast_module_reload(const char *name)
ast_verbose("The previous reload command didn't finish yet\n");
return -1;
}
if (!name || !strcasecmp(name, "astconfig")) {
read_ast_cust_config();
if (!name || !strcasecmp(name, "extconfig")) {
read_config_maps();
reloaded = 2;
}
if (!name || !strcasecmp(name, "manager")) {
@ -403,11 +402,11 @@ int ast_load_resource(const char *resource_name)
/* Keep the module file parsing silent */
o = option_verbose;
option_verbose = 0;
cfg = ast_load(AST_MODULE_CONFIG);
cfg = ast_config_load(AST_MODULE_CONFIG);
option_verbose = o;
res = __load_resource(resource_name, cfg);
if (cfg)
ast_destroy(cfg);
ast_config_destroy(cfg);
return res;
}
@ -444,7 +443,7 @@ int load_modules()
char tmp[80];
if (option_verbose)
ast_verbose( "Asterisk Dynamic Loader Starting:\n");
cfg = ast_load(AST_MODULE_CONFIG);
cfg = ast_config_load(AST_MODULE_CONFIG);
if (cfg) {
/* Load explicitly defined modules */
v = ast_variable_browse(cfg, "modules");
@ -459,7 +458,7 @@ int load_modules()
if (__load_resource(v->value, cfg)) {
ast_log(LOG_WARNING, "Loading module %s failed!\n", v->value);
if (cfg)
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
}
@ -509,7 +508,7 @@ int load_modules()
if (__load_resource(d->d_name, cfg)) {
ast_log(LOG_WARNING, "Loading module %s failed!\n", d->d_name);
if (cfg)
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
}
@ -521,7 +520,7 @@ int load_modules()
}
}
}
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}

View File

@ -267,7 +267,7 @@ static void init_logger_chain(void)
/* close syslog */
closelog();
cfg = ast_load("logger.conf");
cfg = ast_config_load("logger.conf");
/* If no config file, we're fine */
if (!cfg)
@ -299,7 +299,7 @@ static void init_logger_chain(void)
var = var->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
ast_mutex_unlock(&loglock);
}

View File

@ -398,7 +398,7 @@ static int authenticate(struct mansession *s, struct message *m)
char *key = astman_get_header(m, "Key");
char *events = astman_get_header(m, "Events");
cfg = ast_load("manager.conf");
cfg = ast_config_load("manager.conf");
if (!cfg)
return -1;
cat = ast_category_browse(cfg, NULL);
@ -423,7 +423,7 @@ static int authenticate(struct mansession *s, struct message *m)
if (ha && !ast_apply_ha(ha, &(s->sin))) {
ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_free_ha(ha);
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
} else if (ha)
ast_free_ha(ha);
@ -443,7 +443,7 @@ static int authenticate(struct mansession *s, struct message *m)
if (!strcmp(md5key, key))
break;
else {
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
}
@ -451,7 +451,7 @@ static int authenticate(struct mansession *s, struct message *m)
break;
} else {
ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
}
@ -462,13 +462,13 @@ static int authenticate(struct mansession *s, struct message *m)
strncpy(s->username, cat, sizeof(s->username) - 1);
s->readperm = get_perm(ast_variable_retrieve(cfg, cat, "read"));
s->writeperm = get_perm(ast_variable_retrieve(cfg, cat, "write"));
ast_destroy(cfg);
ast_config_destroy(cfg);
if (events)
set_eventmask(s, events);
return 0;
}
ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
@ -1455,7 +1455,7 @@ int init_manager(void)
}
portno = DEFAULT_MANAGER_PORT;
displayconnects = 1;
cfg = ast_load("manager.conf");
cfg = ast_config_load("manager.conf");
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to open management configuration manager.conf. Call management disabled.\n");
return 0;
@ -1507,7 +1507,7 @@ int init_manager(void)
ast_log(LOG_WARNING, "Unable to change management port / enabled\n");
#endif
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* If not enabled, do nothing */
if (!enabled) {

View File

@ -972,13 +972,13 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
snprintf(filename, sizeof(filename), "%s/%s",
(char *)ast_config_AST_CONFIG_DIR, config);
cfg = ast_load("extensions.conf");
cfg = ast_config_load("extensions.conf");
/* try to lock contexts list */
if (ast_lock_contexts()) {
ast_cli(fd, "Failed to lock contexts list\n");
ast_mutex_unlock(&save_dialplan_lock);
ast_destroy(cfg);
ast_config_destroy(cfg);
return RESULT_FAILURE;
}
@ -988,7 +988,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
filename);
ast_unlock_contexts();
ast_mutex_unlock(&save_dialplan_lock);
ast_destroy(cfg);
ast_config_destroy(cfg);
return RESULT_FAILURE;
}
@ -1006,7 +1006,7 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
fprintf(output, "\n");
}
ast_destroy(cfg);
ast_config_destroy(cfg);
/* walk all contexts */
c = ast_walk_contexts(NULL);
@ -1623,7 +1623,7 @@ static int pbx_load_module(void)
char realvalue[256];
int lastpri = -2;
cfg = ast_load(config);
cfg = ast_config_load(config);
if (cfg) {
/* Use existing config to populate the PBX table */
static_config = ast_true(ast_variable_retrieve(cfg, "general",
@ -1775,7 +1775,7 @@ static int pbx_load_module(void)
}
cxt = ast_category_browse(cfg, cxt);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
ast_merge_contexts_and_delete(&local_contexts,registrar);

View File

@ -4446,7 +4446,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin)
dundi_eid testeid;
dundi_ttl = DUNDI_DEFAULT_TTL;
cfg = ast_load(config_file);
cfg = ast_config_load(config_file);
if (!cfg) {
@ -4569,7 +4569,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin)
cat = ast_category_browse(cfg, cat);
}
prune_peers();
ast_destroy(cfg);
ast_config_destroy(cfg);
load_password();
if (globalpcmodel & DUNDI_MODEL_OUTBOUND)
dundi_precache_full();

View File

@ -13,7 +13,6 @@
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/config.h>
#include <asterisk/config_pvt.h>
#include <asterisk/options.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
@ -92,7 +91,6 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
{
struct ast_variable *var;
struct ast_config *cfg;
struct ast_category *cat;
char pri[20];
char *ematch;
char rexten[AST_MAX_EXTENSION + 20]="";
@ -116,27 +114,27 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
if (!var) {
cfg = ast_load_realtime_multientry(table, "exten LIKE", "\\_%", "context", context, "priority", pri, NULL);
if (cfg) {
cat = cfg->root;
char *cat = ast_category_browse(cfg, NULL);
while(cat) {
switch(mode) {
case MODE_MATCHMORE:
match = ast_extension_close(cat->name, exten, 1);
match = ast_extension_close(cat, exten, 1);
break;
case MODE_CANMATCH:
match = ast_extension_close(cat->name, exten, 0);
match = ast_extension_close(cat, exten, 0);
break;
case MODE_MATCH:
default:
match = ast_extension_match(cat->name, exten);
match = ast_extension_match(cat, exten);
}
if (match) {
var = cat->root;
cat->root = NULL;
var = ast_category_detach_variables(ast_category_get(cfg, cat));
break;
}
cat = cat->next;
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
}
return var;
@ -145,7 +143,7 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
REALTIME_COMMON(MODE_MATCH);
if (var) ast_destroy_realtime(var);
if (var) ast_variables_destroy(var);
if (var)
res = 1;
return res > 0 ? res : 0;
@ -154,7 +152,7 @@ static int realtime_exists(struct ast_channel *chan, const char *context, const
static int realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
REALTIME_COMMON(MODE_CANMATCH);
if (var) ast_destroy_realtime(var);
if (var) ast_variables_destroy(var);
if (var)
res = 1;
return res > 0 ? res : 0;
@ -180,7 +178,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
tmp = ast_strdupa(v->value);
v = v->next;
}
ast_destroy_realtime(var);
ast_variables_destroy(var);
if (!ast_strlen_zero(app)) {
a = pbx_findapp(app);
if (a) {
@ -212,7 +210,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
static int realtime_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
REALTIME_COMMON(MODE_MATCHMORE);
if (var) ast_destroy_realtime(var);
if (var) ast_variables_destroy(var);
if (var)
res = 1;
return res > 0 ? res : 0;

View File

@ -1024,7 +1024,7 @@ static void adsi_load(void)
struct ast_variable *v;
char *name, *sname;
init_state();
conf = ast_load("adsi.conf");
conf = ast_config_load("adsi.conf");
if (conf) {
x=0;
v = ast_variable_browse(conf, "intro");
@ -1067,7 +1067,7 @@ static void adsi_load(void)
}
if (x)
speeds = x;
ast_destroy(conf);
ast_config_destroy(conf);
}
}

View File

@ -14,7 +14,6 @@
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/config.h>
#include <asterisk/config_pvt.h>
#include <asterisk/module.h>
#include <asterisk/lock.h>
#include <asterisk/options.h>
@ -25,8 +24,6 @@
#include <asterisk/utils.h>
static char *tdesc = "ODBC Configuration";
static struct ast_config_reg reg1;
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@ -136,14 +133,14 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
if (var)
ast_destroy_realtime(var);
ast_variables_destroy(var);
return NULL;
}
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
if (var)
ast_destroy_realtime(var);
ast_variables_destroy(var);
return NULL;
}
stringp = rowdata;
@ -151,11 +148,11 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
chunk = strsep(&stringp, ";");
if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
if (prev) {
prev->next = ast_new_variable(coltitle, chunk);
prev->next = ast_variable_new(coltitle, chunk);
if (prev->next)
prev = prev->next;
} else
prev = var = ast_new_variable(coltitle, chunk);
prev = var = ast_variable_new(coltitle, chunk);
}
}
@ -174,7 +171,6 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
char sql[1024];
char coltitle[256];
char rowdata[2048];
char *title=NULL;
const char *initfield=NULL;
char *op;
const char *newparam, *newval;
@ -183,7 +179,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
SQLSMALLINT collen;
int res;
int x;
struct ast_variable *var=NULL, *prev=NULL;
struct ast_variable *var=NULL;
struct ast_config *cfg=NULL;
struct ast_category *cat=NULL;
struct ast_realloca ra;
@ -268,15 +264,25 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
return NULL;
}
cfg = ast_config_new();
if (!cfg) {
ast_log(LOG_WARNING, "Out of memory!\n");
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
while (rowcount--) {
var = NULL;
prev = NULL;
title = NULL;
res = SQLFetch(stmt);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
continue;
}
cat = ast_category_new("");
if (!cat) {
ast_log(LOG_WARNING, "Out of memory!\n");
continue;
}
for (x=0;x<colcount;x++) {
rowdata[0] = '\0';
collen = sizeof(coltitle);
@ -284,48 +290,27 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
&datatype, &colsize, &decimaldigits, &nullable);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
if (var)
ast_destroy_realtime(var);
ast_category_destroy(cat);
continue;
}
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
if (var)
ast_destroy_realtime(var);
ast_category_destroy(cat);
continue;
}
stringp = rowdata;
while(stringp) {
chunk = strsep(&stringp, ";");
if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
if (initfield && !strcmp(initfield, coltitle) && !title)
title = ast_restrdupa(&ra, chunk);
if (prev) {
prev->next = ast_new_variable(coltitle, chunk);
if (prev->next)
prev = prev->next;
} else
prev = var = ast_new_variable(coltitle, chunk);
if (initfield && !strcmp(initfield, coltitle))
ast_category_rename(cat, chunk);
var = ast_variable_new(coltitle, chunk);
ast_variable_append(cat, var);
}
}
}
if (var) {
cat = ast_new_category(title ? title : "");
if (cat) {
cat->root = var;
if (!cfg)
cfg = ast_new_config();
if (cfg)
ast_category_append(cfg, cat);
else
ast_category_destroy(cat);
} else {
ast_log(LOG_WARNING, "Out of memory!\n");
ast_destroy_realtime(var);
}
}
ast_category_append(cfg, cat);
}
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
@ -410,11 +395,10 @@ static int update_odbc(const char *database, const char *table, const char *keyf
return -1;
}
static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *new_config_s, struct ast_category **new_cat_p, int recur)
static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *cfg)
{
struct ast_config *new;
struct ast_variable *cur_v, *new_v;
struct ast_category *cur_cat, *new_cat;
struct ast_variable *new_v;
struct ast_category *cur_cat;
int res = 0;
odbc_obj *obj;
SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0;
@ -422,10 +406,7 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
char sql[255] = "", filename[128], category[128], var_name[128], var_val[512];
SQLSMALLINT rowcount=0;
SQLHSTMT stmt;
char last[80] = "";
int cat_started = 0;
int var_started = 0;
char last[128] = "";
if (!file || !strcmp (file, "res_config_odbc.conf"))
return NULL; /* cant configure myself with myself ! */
@ -434,8 +415,6 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
if (!obj)
return NULL;
last[0] = '\0';
res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
SQLBindCol (stmt, 1, SQL_C_ULONG, &id, sizeof (id), &err);
@ -452,90 +431,63 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log (LOG_WARNING, "SQL select error!\n[%s]\n\n", sql);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
res = SQLNumResultCols (stmt, &rowcount);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log (LOG_WARNING, "SQL select error!\n[%s]\n\n", sql);
return NULL;
}
if (new_config_s) {
new = new_config_s;
cat_started++;
} else {
new = ast_new_config ();
}
if (!new) {
ast_log(LOG_WARNING, "Out of memory!\n");
ast_log (LOG_WARNING, "SQL NumResultCols error!\n[%s]\n\n", sql);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
if (rowcount) {
res = SQLFetch (stmt);
cat_started = 0;
if (!rowcount) {
ast_log (LOG_NOTICE, "found nothing\n");
return cfg;
}
cur_cat = *new_cat_p;
cur_v = NULL;
cur_cat = ast_config_get_current_category(cfg);
if (cur_cat)
cat_started = 1;
if (cur_v)
var_started = 1;
while (res != SQL_NO_DATA) {
if (!strcmp (var_name, "#include") && recur < MAX_INCLUDE_LEVEL) {
config_odbc(database, table, var_val, new, &cur_cat, recur + 1);
} else {
if (strcmp (last, category) || last_cat_metric != cat_metric) {
strncpy(last, category, sizeof(last) - 1);
last_cat_metric = cat_metric;
new_cat = (struct ast_category *) ast_new_category (category);
if (!cat_started) {
cat_started++;
new->root = new_cat;
cur_cat = new->root;
} else {
cur_cat->next = new_cat;
cur_cat = cur_cat->next;
}
var_started = 0;
}
new_v = ast_new_variable (var_name, var_val);
if (!var_started) {
var_started++;
cur_cat->root = new_v;
cur_v = cur_cat->root;
} else {
cur_v->next = new_v;
cur_v = cur_v->next;
}
while ((res = SQLFetch(stmt)) != SQL_NO_DATA) {
if (!strcmp (var_name, "#include")) {
if (!ast_config_internal_load(var_val, cfg)) {
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
/* next row */
res = SQLFetch (stmt);
continue;
}
if (strcmp(last, category) || last_cat_metric != cat_metric) {
cur_cat = ast_category_new(category);
if (!cur_cat) {
ast_log(LOG_WARNING, "Out of memory!\n");
break;
}
strcpy(last, category);
last_cat_metric = cat_metric;
ast_category_append(cfg, cur_cat);
}
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
} else {
ast_log (LOG_NOTICE, "found nothing\n");
new_v = ast_variable_new(var_name, var_val);
ast_variable_append(cur_cat, new_v);
}
return new;
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return cfg;
}
static struct ast_config_engine odbc_engine = {
.name = "odbc",
.load_func = config_odbc,
.realtime_func = realtime_odbc,
.realtime_multi_func = realtime_multi_odbc,
.update_func = update_odbc
};
int unload_module (void)
{
ast_cust_config_deregister (&reg1);
ast_config_engine_deregister(&odbc_engine);
if (option_verbose)
ast_verbose("res_config_odbc unloaded.\n");
STANDARD_HANGUP_LOCALUSERS;
@ -544,13 +496,7 @@ int unload_module (void)
int load_module (void)
{
memset (&reg1, 0, sizeof (struct ast_config_reg));
strncpy(reg1.name, "odbc", sizeof(reg1.name) - 1);
reg1.static_func = config_odbc;
reg1.realtime_func = realtime_odbc;
reg1.realtime_multi_func = realtime_multi_odbc;
reg1.update_func = update_odbc;
ast_cust_config_register (&reg1);
ast_config_engine_register(&odbc_engine);
if (option_verbose)
ast_verbose("res_config_odbc loaded.\n");
return 0;

View File

@ -1444,9 +1444,9 @@ static int load_config(void)
transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
cfg = ast_load("features.conf");
cfg = ast_config_load("features.conf");
if (!cfg) {
cfg = ast_load("parking.conf");
cfg = ast_config_load("parking.conf");
if (cfg)
ast_log(LOG_NOTICE, "parking.conf is deprecated in favor of 'features.conf'. Please rename it.\n");
}
@ -1501,7 +1501,7 @@ static int load_config(void)
ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
var = var->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
if (con)

View File

@ -230,7 +230,7 @@ static int ind_load_module(void)
/* that the following cast is needed, is yuk! */
/* yup, checked it out. It is NOT written to. */
cfg = ast_load((char *)config);
cfg = ast_config_load((char *)config);
if (!cfg)
return 0;
@ -245,7 +245,7 @@ static int ind_load_module(void)
tones = malloc(sizeof(struct tone_zone));
if (!tones) {
ast_log(LOG_WARNING,"Out of memory\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
memset(tones,0,sizeof(struct tone_zone));
@ -269,7 +269,7 @@ static int ind_load_module(void)
tmp = realloc(tones->ringcadance,(tones->nrringcadance+1)*sizeof(int));
if (!tmp) {
ast_log(LOG_WARNING, "Out of memory\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
tones->ringcadance = tmp;
@ -286,7 +286,7 @@ static int ind_load_module(void)
struct tone_zone* azone = malloc(sizeof(struct tone_zone));
if (!azone) {
ast_log(LOG_WARNING,"Out of memory\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
memset(azone,0,sizeof(struct tone_zone));
@ -313,7 +313,7 @@ static int ind_load_module(void)
ts = malloc(sizeof(struct tone_zone_sound));
if (!ts) {
ast_log(LOG_WARNING, "Out of memory\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return -1;
}
ts->next = NULL;
@ -341,7 +341,7 @@ out: v = v->next;
if (!country || !*country || ast_set_indication_country(country))
ast_log(LOG_WARNING,"Unable to set the default country (for indication tones)\n");
ast_destroy(cfg);
ast_config_destroy(cfg);
return 0;
}

View File

@ -865,7 +865,7 @@ static int load_moh_classes(void)
char *args;
int x = 0;
cfg = ast_load("musiconhold.conf");
cfg = ast_config_load("musiconhold.conf");
if (!cfg)
return 0;
@ -897,7 +897,7 @@ static int load_moh_classes(void)
var = var->next;
}
ast_destroy(cfg);
ast_config_destroy(cfg);
return x;
}

View File

@ -93,7 +93,7 @@ static int load_odbc_config(void)
odbc_obj *obj;
config = ast_load(cfg);
config = ast_config_load(cfg);
if (config) {
for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) {
if (!strcmp(cat, "ENV")) {
@ -140,7 +140,7 @@ static int load_odbc_config(void)
}
}
ast_destroy(config);
ast_config_destroy(config);
}
return 0;
}

View File

@ -746,7 +746,7 @@ static int config_load(void)
osp = osp->next;
}
ast_mutex_unlock(&osplock);
cfg = ast_load("osp.conf");
cfg = ast_config_load("osp.conf");
if (cfg) {
if (!initialized) {
cat = ast_variable_retrieve(cfg, "general", "accelerate");
@ -766,7 +766,7 @@ static int config_load(void)
osp_build(cfg, cat);
cat = ast_category_browse(cfg, cat);
}
ast_destroy(cfg);
ast_config_destroy(cfg);
} else
ast_log(LOG_NOTICE, "No OSP configuration found. OSP support disabled\n");
ast_mutex_lock(&osplock);

4
rtp.c
View File

@ -1753,7 +1753,7 @@ void ast_rtp_reload(void)
#ifdef SO_NO_CHECK
checksums = 1;
#endif
cfg = ast_load("rtp.conf");
cfg = ast_config_load("rtp.conf");
if (cfg) {
if ((s = ast_variable_retrieve(cfg, "general", "rtpstart"))) {
rtpstart = atoi(s);
@ -1780,7 +1780,7 @@ void ast_rtp_reload(void)
ast_log(LOG_WARNING, "Disabling RTP checksums is not supported on this operating system!\n");
#endif
}
ast_destroy(cfg);
ast_config_destroy(cfg);
}
if (rtpstart >= rtpend) {
ast_log(LOG_WARNING, "Unreasonable values for RTP start in rtp.conf/end\n");