mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 07:18:15 +00:00
Version 0.1.9 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
38
config.c
38
config.c
@@ -89,6 +89,12 @@ struct ast_variable *ast_variable_browse(struct ast_config *config, char *catego
|
|||||||
{
|
{
|
||||||
struct ast_category *cat;
|
struct ast_category *cat;
|
||||||
cat = config->root;
|
cat = config->root;
|
||||||
|
while(cat) {
|
||||||
|
if (cat->name == category)
|
||||||
|
return cat->root;
|
||||||
|
cat = cat->next;
|
||||||
|
}
|
||||||
|
cat = config->root;
|
||||||
while(cat) {
|
while(cat) {
|
||||||
if (!strcasecmp(cat->name, category))
|
if (!strcasecmp(cat->name, category))
|
||||||
return cat->root;
|
return cat->root;
|
||||||
@@ -101,6 +107,12 @@ char *ast_variable_retrieve(struct ast_config *config, char *category, char *val
|
|||||||
{
|
{
|
||||||
struct ast_variable *v;
|
struct ast_variable *v;
|
||||||
if (category) {
|
if (category) {
|
||||||
|
v = ast_variable_browse(config, category);
|
||||||
|
while (v) {
|
||||||
|
if (value == v->name)
|
||||||
|
return v->value;
|
||||||
|
v=v->next;
|
||||||
|
}
|
||||||
v = ast_variable_browse(config, category);
|
v = ast_variable_browse(config, category);
|
||||||
while (v) {
|
while (v) {
|
||||||
if (!strcasecmp(value, v->name))
|
if (!strcasecmp(value, v->name))
|
||||||
@@ -186,6 +198,7 @@ struct ast_config *ast_load(char *configfile)
|
|||||||
c = strchr(cur, ']');
|
c = strchr(cur, ']');
|
||||||
if (c) {
|
if (c) {
|
||||||
*c = 0;
|
*c = 0;
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Check category duplicity before structure
|
* Check category duplicity before structure
|
||||||
* allocation
|
* allocation
|
||||||
@@ -199,7 +212,7 @@ struct ast_config *ast_load(char *configfile)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
tmpc = malloc(sizeof(struct ast_category));
|
tmpc = malloc(sizeof(struct ast_category));
|
||||||
if (!tmpc) {
|
if (!tmpc) {
|
||||||
ast_destroy(tmp);
|
ast_destroy(tmp);
|
||||||
@@ -216,18 +229,12 @@ struct ast_config *ast_load(char *configfile)
|
|||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING,
|
ast_log(LOG_WARNING,
|
||||||
"parse error: no closing ']', line %d\n", lineno);
|
"parse error: no closing ']', line %d\n", lineno);
|
||||||
ast_destroy(tmp);
|
|
||||||
fclose(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Just a line (variable = value) */
|
/* Just a line (variable = value) */
|
||||||
if (!tmpc) {
|
if (!tmpc) {
|
||||||
ast_log(LOG_WARNING,
|
ast_log(LOG_WARNING,
|
||||||
"parse error: No category context for line %d\n", lineno);
|
"parse error: No category context for line %d\n", lineno);
|
||||||
ast_destroy(tmp);
|
|
||||||
fclose(f);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
c = strchr(cur, '=');
|
c = strchr(cur, '=');
|
||||||
if (c) {
|
if (c) {
|
||||||
@@ -248,14 +255,13 @@ struct ast_config *ast_load(char *configfile)
|
|||||||
tmpc->root = v;
|
tmpc->root = v;
|
||||||
last = v;
|
last = v;
|
||||||
} else {
|
} else {
|
||||||
|
ast_destroy(tmp);
|
||||||
ast_log(LOG_WARNING, "Out of memory, line %d\n", lineno);
|
ast_log(LOG_WARNING, "Out of memory, line %d\n", lineno);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
ast_destroy(tmp);
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "No = in line %d\n", lineno);
|
ast_log(LOG_WARNING, "No '=' (equal sign) in line %d\n", lineno);
|
||||||
fclose(f);
|
|
||||||
ast_destroy(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -282,6 +288,16 @@ char *ast_category_browse(struct ast_config *config, char *prev)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cat = config->root;
|
cat = config->root;
|
||||||
|
while(cat) {
|
||||||
|
if (cat->name == prev) {
|
||||||
|
if (cat->next)
|
||||||
|
return cat->next->name;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
cat = cat->next;
|
||||||
|
}
|
||||||
|
cat = config->root;
|
||||||
while(cat) {
|
while(cat) {
|
||||||
if (!strcasecmp(cat->name, prev)) {
|
if (!strcasecmp(cat->name, prev)) {
|
||||||
if (cat->next)
|
if (cat->next)
|
||||||
|
|||||||
Reference in New Issue
Block a user