diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2001-10-09 14:54:42 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2001-10-09 14:54:42 +0000 |
commit | 0ba96ffdcfc00286c49cee816d136ee0e89ba312 (patch) | |
tree | 36435ab21523aedb02c5d3fdfad504d4d82c3178 /config.c | |
parent | 18fb4c760525822e15dc2630129426eec4ac6528 (diff) |
Version 0.1.9 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@365 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'config.c')
-rwxr-xr-x | config.c | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -90,6 +90,12 @@ struct ast_variable *ast_variable_browse(struct ast_config *config, char *catego struct ast_category *cat; cat = config->root; while(cat) { + if (cat->name == category) + return cat->root; + cat = cat->next; + } + cat = config->root; + while(cat) { if (!strcasecmp(cat->name, category)) return cat->root; cat = cat->next; @@ -103,6 +109,12 @@ char *ast_variable_retrieve(struct ast_config *config, char *category, char *val 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); + while (v) { if (!strcasecmp(value, v->name)) return v->value; v=v->next; @@ -186,6 +198,7 @@ struct ast_config *ast_load(char *configfile) c = strchr(cur, ']'); if (c) { *c = 0; +#if 0 /* * Check category duplicity before structure * allocation @@ -199,7 +212,7 @@ struct ast_config *ast_load(char *configfile) fclose(f); return NULL; } - +#endif tmpc = malloc(sizeof(struct ast_category)); if (!tmpc) { ast_destroy(tmp); @@ -216,18 +229,12 @@ struct ast_config *ast_load(char *configfile) } else { ast_log(LOG_WARNING, "parse error: no closing ']', line %d\n", lineno); - ast_destroy(tmp); - fclose(f); - return NULL; } } else { /* Just a line (variable = value) */ if (!tmpc) { ast_log(LOG_WARNING, "parse error: No category context for line %d\n", lineno); - ast_destroy(tmp); - fclose(f); - return NULL; } c = strchr(cur, '='); if (c) { @@ -248,14 +255,13 @@ struct ast_config *ast_load(char *configfile) tmpc->root = v; last = v; } else { + ast_destroy(tmp); ast_log(LOG_WARNING, "Out of memory, line %d\n", lineno); fclose(f); - ast_destroy(tmp); + return NULL; } } else { - ast_log(LOG_WARNING, "No = in line %d\n", lineno); - fclose(f); - ast_destroy(tmp); + ast_log(LOG_WARNING, "No '=' (equal sign) in line %d\n", lineno); } } @@ -283,6 +289,16 @@ char *ast_category_browse(struct ast_config *config, char *prev) } 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) { if (!strcasecmp(cat->name, prev)) { if (cat->next) return cat->next->name; |