00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "asterisk.h"
00030
00031 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 93000 $")
00032
00033 #include <stdio.h>
00034 #include <unistd.h>
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <errno.h>
00038 #include <time.h>
00039 #include <sys/stat.h>
00040 #define AST_INCLUDE_GLOB 1
00041 #ifdef AST_INCLUDE_GLOB
00042 #if defined(__Darwin__) || defined(__CYGWIN__)
00043 #define GLOB_ABORTED GLOB_ABEND
00044 #endif
00045 # include <glob.h>
00046 #endif
00047
00048 #include "asterisk/config.h"
00049 #include "asterisk/cli.h"
00050 #include "asterisk/lock.h"
00051 #include "asterisk/options.h"
00052 #include "asterisk/logger.h"
00053 #include "asterisk/utils.h"
00054 #include "asterisk/channel.h"
00055 #include "asterisk/app.h"
00056
00057 #define MAX_NESTED_COMMENTS 128
00058 #define COMMENT_START ";--"
00059 #define COMMENT_END "--;"
00060 #define COMMENT_META ';'
00061 #define COMMENT_TAG '-'
00062
00063 static char *extconfig_conf = "extconfig.conf";
00064
00065
00066
00067 struct ast_comment {
00068 struct ast_comment *next;
00069 char cmt[0];
00070 };
00071
00072 #define CB_INCR 250
00073
00074 static void CB_INIT(char **comment_buffer, int *comment_buffer_size, char **lline_buffer, int *lline_buffer_size)
00075 {
00076 if (!(*comment_buffer)) {
00077 *comment_buffer = ast_malloc(CB_INCR);
00078 if (!(*comment_buffer))
00079 return;
00080 (*comment_buffer)[0] = 0;
00081 *comment_buffer_size = CB_INCR;
00082 *lline_buffer = ast_malloc(CB_INCR);
00083 if (!(*lline_buffer))
00084 return;
00085 (*lline_buffer)[0] = 0;
00086 *lline_buffer_size = CB_INCR;
00087 } else {
00088 (*comment_buffer)[0] = 0;
00089 (*lline_buffer)[0] = 0;
00090 }
00091 }
00092
00093 static void CB_ADD(char **comment_buffer, int *comment_buffer_size, char *str)
00094 {
00095 int rem = *comment_buffer_size - strlen(*comment_buffer) - 1;
00096 int siz = strlen(str);
00097 if (rem < siz+1) {
00098 *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + siz + 1);
00099 if (!(*comment_buffer))
00100 return;
00101 *comment_buffer_size += CB_INCR+siz+1;
00102 }
00103 strcat(*comment_buffer,str);
00104 }
00105
00106 static void CB_ADD_LEN(char **comment_buffer, int *comment_buffer_size, char *str, int len)
00107 {
00108 int cbl = strlen(*comment_buffer) + 1;
00109 int rem = *comment_buffer_size - cbl;
00110 if (rem < len+1) {
00111 *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + len + 1);
00112 if (!(*comment_buffer))
00113 return;
00114 *comment_buffer_size += CB_INCR+len+1;
00115 }
00116 strncat(*comment_buffer,str,len);
00117 (*comment_buffer)[cbl+len-1] = 0;
00118 }
00119
00120 static void LLB_ADD(char **lline_buffer, int *lline_buffer_size, char *str)
00121 {
00122 int rem = *lline_buffer_size - strlen(*lline_buffer) - 1;
00123 int siz = strlen(str);
00124 if (rem < siz+1) {
00125 *lline_buffer = ast_realloc(*lline_buffer, *lline_buffer_size + CB_INCR + siz + 1);
00126 if (!(*lline_buffer))
00127 return;
00128 *lline_buffer_size += CB_INCR + siz + 1;
00129 }
00130 strcat(*lline_buffer,str);
00131 }
00132
00133 static void CB_RESET(char **comment_buffer, char **lline_buffer)
00134 {
00135 (*comment_buffer)[0] = 0;
00136 (*lline_buffer)[0] = 0;
00137 }
00138
00139
00140 static struct ast_comment *ALLOC_COMMENT(const char *buffer)
00141 {
00142 struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
00143 strcpy(x->cmt, buffer);
00144 return x;
00145 }
00146
00147
00148 static struct ast_config_map {
00149 struct ast_config_map *next;
00150 char *name;
00151 char *driver;
00152 char *database;
00153 char *table;
00154 char stuff[0];
00155 } *config_maps = NULL;
00156
00157 AST_MUTEX_DEFINE_STATIC(config_lock);
00158 static struct ast_config_engine *config_engine_list;
00159
00160 #define MAX_INCLUDE_LEVEL 10
00161
00162 struct ast_category_template_instance {
00163 char name[80];
00164 const struct ast_category *inst;
00165 AST_LIST_ENTRY(ast_category_template_instance) next;
00166 };
00167
00168 struct ast_category {
00169 char name[80];
00170 int ignored;
00171 int include_level;
00172 AST_LIST_HEAD_NOLOCK(template_instance_list, ast_category_template_instance) template_instances;
00173 struct ast_comment *precomments;
00174 struct ast_comment *sameline;
00175 struct ast_variable *root;
00176 struct ast_variable *last;
00177 struct ast_category *next;
00178 };
00179
00180 struct ast_config {
00181 struct ast_category *root;
00182 struct ast_category *last;
00183 struct ast_category *current;
00184 struct ast_category *last_browse;
00185 int include_level;
00186 int max_include_level;
00187 };
00188
00189 struct ast_variable *ast_variable_new(const char *name, const char *value)
00190 {
00191 struct ast_variable *variable;
00192 int name_len = strlen(name) + 1;
00193
00194 if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + sizeof(*variable)))) {
00195 variable->name = variable->stuff;
00196 variable->value = variable->stuff + name_len;
00197 strcpy(variable->name,name);
00198 strcpy(variable->value,value);
00199 }
00200
00201 return variable;
00202 }
00203
00204 void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
00205 {
00206 if (!variable)
00207 return;
00208 if (category->last)
00209 category->last->next = variable;
00210 else
00211 category->root = variable;
00212 category->last = variable;
00213 while (category->last->next)
00214 category->last = category->last->next;
00215 }
00216
00217 void ast_variables_destroy(struct ast_variable *v)
00218 {
00219 struct ast_variable *vn;
00220
00221 while(v) {
00222 vn = v;
00223 v = v->next;
00224 free(vn);
00225 }
00226 }
00227
00228 struct ast_variable *ast_variable_browse(const struct ast_config *config, const char *category)
00229 {
00230 struct ast_category *cat = NULL;
00231
00232 if (category && config->last_browse && (config->last_browse->name == category))
00233 cat = config->last_browse;
00234 else
00235 cat = ast_category_get(config, category);
00236
00237 return (cat) ? cat->root : NULL;
00238 }
00239
00240 const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
00241 {
00242 const char *tmp;
00243 tmp = ast_variable_retrieve(cfg, cat, var);
00244 if (!tmp)
00245 tmp = ast_variable_retrieve(cfg, "general", var);
00246 return tmp;
00247 }
00248
00249
00250 const char *ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
00251 {
00252 struct ast_variable *v;
00253
00254 if (category) {
00255 for (v = ast_variable_browse(config, category); v; v = v->next) {
00256 if (!strcasecmp(variable, v->name))
00257 return v->value;
00258 }
00259 } else {
00260 struct ast_category *cat;
00261
00262 for (cat = config->root; cat; cat = cat->next)
00263 for (v = cat->root; v; v = v->next)
00264 if (!strcasecmp(variable, v->name))
00265 return v->value;
00266 }
00267
00268 return NULL;
00269 }
00270
00271 static struct ast_variable *variable_clone(const struct ast_variable *old)
00272 {
00273 struct ast_variable *new = ast_variable_new(old->name, old->value);
00274
00275 if (new) {
00276 new->lineno = old->lineno;
00277 new->object = old->object;
00278 new->blanklines = old->blanklines;
00279
00280 }
00281
00282 return new;
00283 }
00284
00285 static void move_variables(struct ast_category *old, struct ast_category *new)
00286 {
00287 struct ast_variable *var = old->root;
00288 old->root = NULL;
00289 #if 1
00290
00291 ast_variable_append(new, var);
00292 #else
00293 while (var) {
00294 struct ast_variable *next = var->next;
00295 var->next = NULL;
00296 ast_variable_append(new, var);
00297 var = next;
00298 }
00299 #endif
00300 }
00301
00302 struct ast_category *ast_category_new(const char *name)
00303 {
00304 struct ast_category *category;
00305
00306 if ((category = ast_calloc(1, sizeof(*category))))
00307 ast_copy_string(category->name, name, sizeof(category->name));
00308 return category;
00309 }
00310
00311 static struct ast_category *category_get(const struct ast_config *config, const char *category_name, int ignored)
00312 {
00313 struct ast_category *cat;
00314
00315
00316 for (cat = config->root; cat; cat = cat->next) {
00317 if (cat->name == category_name && (ignored || !cat->ignored))
00318 return cat;
00319 }
00320
00321 for (cat = config->root; cat; cat = cat->next) {
00322 if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
00323 return cat;
00324 }
00325
00326 return NULL;
00327 }
00328
00329 struct ast_category *ast_category_get(const struct ast_config *config, const char *category_name)
00330 {
00331 return category_get(config, category_name, 0);
00332 }
00333
00334 int ast_category_exist(const struct ast_config *config, const char *category_name)
00335 {
00336 return !!ast_category_get(config, category_name);
00337 }
00338
00339 void ast_category_append(struct ast_config *config, struct ast_category *category)
00340 {
00341 if (config->last)
00342 config->last->next = category;
00343 else
00344 config->root = category;
00345 category->include_level = config->include_level;
00346 config->last = category;
00347 config->current = category;
00348 }
00349
00350 static void ast_destroy_comments(struct ast_category *cat)
00351 {
00352 struct ast_comment *n, *p;
00353 for (p=cat->precomments; p; p=n) {
00354 n = p->next;
00355 free(p);
00356 }
00357 for (p=cat->sameline; p; p=n) {
00358 n = p->next;
00359 free(p);
00360 }
00361 cat->precomments = NULL;
00362 cat->sameline = NULL;
00363 }
00364
00365 static void ast_destroy_template_list(struct ast_category *cat)
00366 {
00367 struct ast_category_template_instance *x;
00368 AST_LIST_TRAVERSE_SAFE_BEGIN(&cat->template_instances, x, next) {
00369 AST_LIST_REMOVE_CURRENT(&cat->template_instances, next);
00370 free(x);
00371 }
00372 AST_LIST_TRAVERSE_SAFE_END;
00373 }
00374
00375 void ast_category_destroy(struct ast_category *cat)
00376 {
00377 ast_variables_destroy(cat->root);
00378 ast_destroy_comments(cat);
00379 ast_destroy_template_list(cat);
00380 free(cat);
00381 }
00382
00383 static struct ast_category *next_available_category(struct ast_category *cat)
00384 {
00385 for (; cat && cat->ignored; cat = cat->next);
00386
00387 return cat;
00388 }
00389
00390 struct ast_variable *ast_category_root(struct ast_config *config, char *cat)
00391 {
00392 struct ast_category *category = ast_category_get(config, cat);
00393 if (category)
00394 return category->root;
00395 return NULL;
00396 }
00397
00398 char *ast_category_browse(struct ast_config *config, const char *prev)
00399 {
00400 struct ast_category *cat = NULL;
00401
00402 if (prev && config->last_browse && (config->last_browse->name == prev))
00403 cat = config->last_browse->next;
00404 else if (!prev && config->root)
00405 cat = config->root;
00406 else if (prev) {
00407 for (cat = config->root; cat; cat = cat->next) {
00408 if (cat->name == prev) {
00409 cat = cat->next;
00410 break;
00411 }
00412 }
00413 if (!cat) {
00414 for (cat = config->root; cat; cat = cat->next) {
00415 if (!strcasecmp(cat->name, prev)) {
00416 cat = cat->next;
00417 break;
00418 }
00419 }
00420 }
00421 }
00422
00423 if (cat)
00424 cat = next_available_category(cat);
00425
00426 config->last_browse = cat;
00427 return (cat) ? cat->name : NULL;
00428 }
00429
00430 struct ast_variable *ast_category_detach_variables(struct ast_category *cat)
00431 {
00432 struct ast_variable *v;
00433
00434 v = cat->root;
00435 cat->root = NULL;
00436 cat->last = NULL;
00437
00438 return v;
00439 }
00440
00441 void ast_category_rename(struct ast_category *cat, const char *name)
00442 {
00443 ast_copy_string(cat->name, name, sizeof(cat->name));
00444 }
00445
00446 static void inherit_category(struct ast_category *new, const struct ast_category *base)
00447 {
00448 struct ast_variable *var;
00449 struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance));
00450 strcpy(x->name, base->name);
00451 x->inst = base;
00452 AST_LIST_INSERT_TAIL(&new->template_instances, x, next);
00453 for (var = base->root; var; var = var->next)
00454 ast_variable_append(new, variable_clone(var));
00455 }
00456
00457 struct ast_config *ast_config_new(void)
00458 {
00459 struct ast_config *config;
00460
00461 if ((config = ast_calloc(1, sizeof(*config))))
00462 config->max_include_level = MAX_INCLUDE_LEVEL;
00463 return config;
00464 }
00465
00466 int ast_variable_delete(struct ast_category *category, char *variable, char *match)
00467 {
00468 struct ast_variable *cur, *prev=NULL, *curn;
00469 int res = -1;
00470 cur = category->root;
00471 while (cur) {
00472 if (cur->name == variable) {
00473 if (prev) {
00474 prev->next = cur->next;
00475 if (cur == category->last)
00476 category->last = prev;
00477 } else {
00478 category->root = cur->next;
00479 if (cur == category->last)
00480 category->last = NULL;
00481 }
00482 cur->next = NULL;
00483 ast_variables_destroy(cur);
00484 return 0;
00485 }
00486 prev = cur;
00487 cur = cur->next;
00488 }
00489
00490 prev = NULL;
00491 cur = category->root;
00492 while (cur) {
00493 curn = cur->next;
00494 if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
00495 if (prev) {
00496 prev->next = cur->next;
00497 if (cur == category->last)
00498 category->last = prev;
00499 } else {
00500 category->root = cur->next;
00501 if (cur == category->last)
00502 category->last = NULL;
00503 }
00504 cur->next = NULL;
00505 ast_variables_destroy(cur);
00506 res = 0;
00507 } else
00508 prev = cur;
00509
00510 cur = curn;
00511 }
00512 return res;
00513 }
00514
00515 int ast_variable_update(struct ast_category *category, const char *variable,
00516 const char *value, const char *match, unsigned int object)
00517 {
00518 struct ast_variable *cur, *prev=NULL, *newer;
00519
00520 if (!(newer = ast_variable_new(variable, value)))
00521 return -1;
00522
00523 newer->object = object;
00524
00525 for (cur = category->root; cur; prev = cur, cur = cur->next) {
00526 if (strcasecmp(cur->name, variable) ||
00527 (!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
00528 continue;
00529
00530 newer->next = cur->next;
00531 newer->object = cur->object || object;
00532 if (prev)
00533 prev->next = newer;
00534 else
00535 category->root = newer;
00536 if (category->last == cur)
00537 category->last = newer;
00538
00539 cur->next = NULL;
00540 ast_variables_destroy(cur);
00541
00542 return 0;
00543 }
00544
00545 if (prev)
00546 prev->next = newer;
00547 else
00548 category->root = newer;
00549
00550 return 0;
00551 }
00552
00553 int ast_category_delete(struct ast_config *cfg, char *category)
00554 {
00555 struct ast_category *prev=NULL, *cat;
00556 cat = cfg->root;
00557 while(cat) {
00558 if (cat->name == category) {
00559 if (prev) {
00560 prev->next = cat->next;
00561 if (cat == cfg->last)
00562 cfg->last = prev;
00563 } else {
00564 cfg->root = cat->next;
00565 if (cat == cfg->last)
00566 cfg->last = NULL;
00567 }
00568 ast_category_destroy(cat);
00569 return 0;
00570 }
00571 prev = cat;
00572 cat = cat->next;
00573 }
00574
00575 prev = NULL;
00576 cat = cfg->root;
00577 while(cat) {
00578 if (!strcasecmp(cat->name, category)) {
00579 if (prev) {
00580 prev->next = cat->next;
00581 if (cat == cfg->last)
00582 cfg->last = prev;
00583 } else {
00584 cfg->root = cat->next;
00585 if (cat == cfg->last)
00586 cfg->last = NULL;
00587 }
00588 ast_category_destroy(cat);
00589 return 0;
00590 }
00591 prev = cat;
00592 cat = cat->next;
00593 }
00594 return -1;
00595 }
00596
00597 void ast_config_destroy(struct ast_config *cfg)
00598 {
00599 struct ast_category *cat, *catn;
00600
00601 if (!cfg)
00602 return;
00603
00604 cat = cfg->root;
00605 while(cat) {
00606 catn = cat;
00607 cat = cat->next;
00608 ast_category_destroy(catn);
00609 }
00610 free(cfg);
00611 }
00612
00613 struct ast_category *ast_config_get_current_category(const struct ast_config *cfg)
00614 {
00615 return cfg->current;
00616 }
00617
00618 void ast_config_set_current_category(struct ast_config *cfg, const struct ast_category *cat)
00619 {
00620
00621 cfg->current = (struct ast_category *) cat;
00622 }
00623
00624 static int process_text_line(struct ast_config *cfg, struct ast_category **cat, char *buf, int lineno, const char *configfile, int withcomments,
00625 char **comment_buffer, int *comment_buffer_size, char **lline_buffer, int *lline_buffer_size)
00626 {
00627 char *c;
00628 char *cur = buf;
00629 struct ast_variable *v;
00630 char cmd[512], exec_file[512];
00631 int object, do_exec, do_include;
00632
00633
00634 if (cur[0] == '[') {
00635 struct ast_category *newcat = NULL;
00636 char *catname;
00637
00638
00639 c = strchr(cur, ']');
00640 if (!c) {
00641 ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile);
00642 return -1;
00643 }
00644 *c++ = '\0';
00645 cur++;
00646 if (*c++ != '(')
00647 c = NULL;
00648 catname = cur;
00649 if (!(*cat = newcat = ast_category_new(catname))) {
00650 return -1;
00651 }
00652
00653 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) {
00654 newcat->precomments = ALLOC_COMMENT(*comment_buffer);
00655 }
00656 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) {
00657 newcat->sameline = ALLOC_COMMENT(*lline_buffer);
00658 }
00659 if( withcomments )
00660 CB_RESET(comment_buffer, lline_buffer);
00661
00662
00663 if (c) {
00664 if (!(cur = strchr(c, ')'))) {
00665 ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
00666 return -1;
00667 }
00668 *cur = '\0';
00669 while ((cur = strsep(&c, ","))) {
00670 if (!strcasecmp(cur, "!")) {
00671 (*cat)->ignored = 1;
00672 } else if (!strcasecmp(cur, "+")) {
00673 *cat = category_get(cfg, catname, 1);
00674 if (!(*cat)) {
00675 if (newcat)
00676 ast_category_destroy(newcat);
00677 ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile);
00678 return -1;
00679 }
00680 if (newcat) {
00681 move_variables(newcat, *cat);
00682 ast_category_destroy(newcat);
00683 newcat = NULL;
00684 }
00685 } else {
00686 struct ast_category *base;
00687
00688 base = category_get(cfg, cur, 1);
00689 if (!base) {
00690 ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
00691 return -1;
00692 }
00693 inherit_category(*cat, base);
00694 }
00695 }
00696 }
00697 if (newcat)
00698 ast_category_append(cfg, *cat);
00699 } else if (cur[0] == '#') {
00700
00701 cur++;
00702 c = cur;
00703 while(*c && (*c > 32)) c++;
00704 if (*c) {
00705 *c = '\0';
00706
00707 c = ast_skip_blanks(c + 1);
00708 if (!(*c))
00709 c = NULL;
00710 } else
00711 c = NULL;
00712 do_include = !strcasecmp(cur, "include");
00713 if(!do_include)
00714 do_exec = !strcasecmp(cur, "exec");
00715 else
00716 do_exec = 0;
00717 if (do_exec && !ast_opt_exec_includes) {
00718 ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
00719 do_exec = 0;
00720 }
00721 if (do_include || do_exec) {
00722 if (c) {
00723
00724 while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
00725
00726 cur = c;
00727 while (!ast_strlen_zero(cur)) {
00728 c = cur + strlen(cur) - 1;
00729 if ((*c == '>') || (*c == '<') || (*c == '\"'))
00730 *c = '\0';
00731 else
00732 break;
00733 }
00734
00735
00736 if (do_exec) {
00737 snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
00738 snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
00739 ast_safe_system(cmd);
00740 cur = exec_file;
00741 } else
00742 exec_file[0] = '\0';
00743
00744 do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0;
00745 if(!ast_strlen_zero(exec_file))
00746 unlink(exec_file);
00747 if (!do_include) {
00748 ast_log(LOG_ERROR, "*********************************************************\n");
00749 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n");
00750 ast_log(LOG_ERROR, "Future versions of Asterisk will treat a #include of a "
00751 "file that does not exist as an error, and will fail to "
00752 "load that configuration file. Please ensure that the "
00753 "file '%s' exists, even if it is empty.\n", cur);
00754 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n");
00755 ast_log(LOG_ERROR, "*********************************************************\n");
00756 return 0;
00757 }
00758
00759 } else {
00760 ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
00761 do_exec ? "exec" : "include",
00762 do_exec ? "/path/to/executable" : "filename",
00763 lineno,
00764 configfile);
00765 }
00766 }
00767 else
00768 ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
00769 } else {
00770
00771 if (!(*cat)) {
00772 ast_log(LOG_WARNING,
00773 "parse error: No category context for line %d of %s\n", lineno, configfile);
00774 return -1;
00775 }
00776 c = strchr(cur, '=');
00777 if (c) {
00778 *c = 0;
00779 c++;
00780
00781 if (*c== '>') {
00782 object = 1;
00783 c++;
00784 } else
00785 object = 0;
00786 if ((v = ast_variable_new(ast_strip(cur), ast_strip(c)))) {
00787 v->lineno = lineno;
00788 v->object = object;
00789
00790 v->blanklines = 0;
00791 ast_variable_append(*cat, v);
00792
00793 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) {
00794 v->precomments = ALLOC_COMMENT(*comment_buffer);
00795 }
00796 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) {
00797 v->sameline = ALLOC_COMMENT(*lline_buffer);
00798 }
00799 if( withcomments )
00800 CB_RESET(comment_buffer, lline_buffer);
00801
00802 } else {
00803 return -1;
00804 }
00805 } else {
00806 ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile);
00807 }
00808 }
00809 return 0;
00810 }
00811
00812 static struct ast_config *config_text_file_load(const char *database, const char *table, const char *filename, struct ast_config *cfg, int withcomments)
00813 {
00814 char fn[256];
00815 char buf[8192];
00816 char *new_buf, *comment_p, *process_buf;
00817 FILE *f;
00818 int lineno=0;
00819 int comment = 0, nest[MAX_NESTED_COMMENTS];
00820 struct ast_category *cat = NULL;
00821 int count = 0;
00822 struct stat statbuf;
00823
00824 char *comment_buffer=0;
00825 int comment_buffer_size=0;
00826
00827 char *lline_buffer=0;
00828 int lline_buffer_size=0;
00829
00830
00831 cat = ast_config_get_current_category(cfg);
00832
00833 if (filename[0] == '/') {
00834 ast_copy_string(fn, filename, sizeof(fn));
00835 } else {
00836 snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename);
00837 }
00838
00839 if (withcomments) {
00840 CB_INIT(&comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size);
00841 if (!lline_buffer || !comment_buffer) {
00842 ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n");
00843 return NULL;
00844 }
00845 }
00846 #ifdef AST_INCLUDE_GLOB
00847 {
00848 int glob_ret;
00849 glob_t globbuf;
00850 globbuf.gl_offs = 0;
00851 #ifdef SOLARIS
00852 glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf);
00853 #else
00854 glob_ret = glob(fn, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
00855 #endif
00856 if (glob_ret == GLOB_NOSPACE)
00857 ast_log(LOG_WARNING,
00858 "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
00859 else if (glob_ret == GLOB_ABORTED)
00860 ast_log(LOG_WARNING,
00861 "Glob Expansion of pattern '%s' failed: Read error\n", fn);
00862 else {
00863
00864 int i;
00865 for (i=0; i<globbuf.gl_pathc; i++) {
00866 ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
00867 #endif
00868 do {
00869 if (stat(fn, &statbuf))
00870 continue;
00871
00872 if (!S_ISREG(statbuf.st_mode)) {
00873 ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
00874 continue;
00875 }
00876 if (option_verbose > 1) {
00877 ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
00878 fflush(stdout);
00879 }
00880 if (!(f = fopen(fn, "r"))) {
00881 if (option_debug)
00882 ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
00883 if (option_verbose > 1)
00884 ast_verbose( "Not found (%s)\n", strerror(errno));
00885 continue;
00886 }
00887 count++;
00888 if (option_debug)
00889 ast_log(LOG_DEBUG, "Parsing %s\n", fn);
00890 if (option_verbose > 1)
00891 ast_verbose("Found\n");
00892 while(!feof(f)) {
00893 lineno++;
00894 if (fgets(buf, sizeof(buf), f)) {
00895 if ( withcomments ) {
00896 CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer);
00897 lline_buffer[0] = 0;
00898 }
00899
00900 new_buf = buf;
00901 if (comment)
00902 process_buf = NULL;
00903 else
00904 process_buf = buf;
00905
00906 while ((comment_p = strchr(new_buf, COMMENT_META))) {
00907 if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
00908
00909 new_buf = comment_p + 1;
00910 } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
00911
00912 if (comment < MAX_NESTED_COMMENTS) {
00913 *comment_p = '\0';
00914 new_buf = comment_p + 3;
00915 comment++;
00916 nest[comment-1] = lineno;
00917 } else {
00918 ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS);
00919 }
00920 } else if ((comment_p >= new_buf + 2) &&
00921 (*(comment_p - 1) == COMMENT_TAG) &&
00922 (*(comment_p - 2) == COMMENT_TAG)) {
00923
00924 comment--;
00925 new_buf = comment_p + 1;
00926 if (!comment) {
00927
00928 if (process_buf) {
00929
00930 char *oldptr;
00931 oldptr = process_buf + strlen(process_buf);
00932 if ( withcomments ) {
00933 CB_ADD(&comment_buffer, &comment_buffer_size, ";");
00934 CB_ADD_LEN(&comment_buffer, &comment_buffer_size, oldptr+1, new_buf-oldptr-1);
00935 }
00936
00937 memmove(oldptr, new_buf, strlen(new_buf) + 1);
00938 new_buf = oldptr;
00939 } else
00940 process_buf = new_buf;
00941 }
00942 } else {
00943 if (!comment) {
00944
00945
00946 if ( withcomments ) {
00947 LLB_ADD(&lline_buffer, &lline_buffer_size, comment_p);
00948 }
00949 *comment_p = '\0';
00950 new_buf = comment_p;
00951 } else
00952 new_buf = comment_p + 1;
00953 }
00954 }
00955 if( withcomments && comment && !process_buf )
00956 {
00957 CB_ADD(&comment_buffer, &comment_buffer_size, buf);
00958 }
00959
00960 if (process_buf) {
00961 char *buf = ast_strip(process_buf);
00962 if (!ast_strlen_zero(buf)) {
00963 if (process_text_line(cfg, &cat, buf, lineno, fn, withcomments, &comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size)) {
00964 cfg = NULL;
00965 break;
00966 }
00967 }
00968 }
00969 }
00970 }
00971 fclose(f);
00972 } while(0);
00973 if (comment) {
00974 ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]);
00975 }
00976 #ifdef AST_INCLUDE_GLOB
00977 if (!cfg)
00978 break;
00979 }
00980 globfree(&globbuf);
00981 }
00982 }
00983 #endif
00984
00985 if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
00986 free(comment_buffer);
00987 free(lline_buffer);
00988 comment_buffer = NULL;
00989 lline_buffer = NULL;
00990 comment_buffer_size = 0;
00991 lline_buffer_size = 0;
00992 }
00993
00994 if (count == 0)
00995 return NULL;
00996
00997 return cfg;
00998 }
00999
01000 int config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
01001 {
01002 FILE *f = NULL;
01003 int fd = -1;
01004 char fn[256], fntmp[256];
01005 char date[256]="";
01006 time_t t;
01007 struct ast_variable *var;
01008 struct ast_category *cat;
01009 struct ast_comment *cmt;
01010 struct stat s;
01011 int blanklines = 0;
01012
01013 if (configfile[0] == '/') {
01014 snprintf(fntmp, sizeof(fntmp), "%s.XXXXXX", configfile);
01015 ast_copy_string(fn, configfile, sizeof(fn));
01016 } else {
01017 snprintf(fntmp, sizeof(fntmp), "%s/%s.XXXXXX", ast_config_AST_CONFIG_DIR, configfile);
01018 snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
01019 }
01020 time(&t);
01021 ast_copy_string(date, ctime(&t), sizeof(date));
01022 if ((fd = mkstemp(fntmp)) > 0 && (f = fdopen(fd, "w")) != NULL) {
01023 if (option_verbose > 1)
01024 ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn);
01025 fprintf(f, ";!\n");
01026 fprintf(f, ";! Automatically generated configuration file\n");
01027 if (strcmp(configfile, fn))
01028 fprintf(f, ";! Filename: %s (%s)\n", configfile, fn);
01029 else
01030 fprintf(f, ";! Filename: %s\n", configfile);
01031 fprintf(f, ";! Generator: %s\n", generator);
01032 fprintf(f, ";! Creation Date: %s", date);
01033 fprintf(f, ";!\n");
01034 cat = cfg->root;
01035 while(cat) {
01036
01037 for (cmt = cat->precomments; cmt; cmt=cmt->next)
01038 {
01039 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
01040 fprintf(f,"%s", cmt->cmt);
01041 }
01042 if (!cat->precomments)
01043 fprintf(f,"\n");
01044 fprintf(f, "[%s]", cat->name);
01045 if (cat->ignored)
01046 fprintf(f, "(!)");
01047 if (!AST_LIST_EMPTY(&cat->template_instances)) {
01048 struct ast_category_template_instance *x;
01049 fprintf(f, "(");
01050 AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
01051 fprintf(f,"%s",x->name);
01052 if (x != AST_LIST_LAST(&cat->template_instances))
01053 fprintf(f,",");
01054 }
01055 fprintf(f, ")");
01056 }
01057 for(cmt = cat->sameline; cmt; cmt=cmt->next)
01058 {
01059 fprintf(f,"%s", cmt->cmt);
01060 }
01061 if (!cat->sameline)
01062 fprintf(f,"\n");
01063 var = cat->root;
01064 while(var) {
01065 struct ast_category_template_instance *x;
01066 int found = 0;
01067 AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
01068 const char *pvalue = ast_variable_retrieve(cfg, x->name, var->name);
01069 if (pvalue && !strcmp(pvalue, var->value)) {
01070 found = 1;
01071 break;
01072 }
01073 }
01074 if (found) {
01075 var = var->next;
01076 continue;
01077 }
01078 for (cmt = var->precomments; cmt; cmt=cmt->next)
01079 {
01080 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
01081 fprintf(f,"%s", cmt->cmt);
01082 }
01083 if (var->sameline)
01084 fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
01085 else
01086 fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
01087 if (var->blanklines) {
01088 blanklines = var->blanklines;
01089 while (blanklines--)
01090 fprintf(f, "\n");
01091 }
01092
01093 var = var->next;
01094 }
01095 #if 0
01096
01097 fprintf(f, "\n");
01098 #endif
01099 cat = cat->next;
01100 }
01101 if ((option_verbose > 1) && !option_debug)
01102 ast_verbose("Saved\n");
01103 } else {
01104 if (option_debug)
01105 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno));
01106 if (option_verbose > 1)
01107 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
01108 if (fd > -1)
01109 close(fd);
01110 return -1;
01111 }
01112 stat(fn, &s);
01113 fchmod(fd, s.st_mode);
01114 fclose(f);
01115 if (unlink(fn) || link(fntmp, fn)) {
01116 if (option_debug)
01117 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno));
01118 if (option_verbose > 1)
01119 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
01120 unlink(fntmp);
01121 return -1;
01122 }
01123 unlink(fntmp);
01124 return 0;
01125 }
01126
01127 static void clear_config_maps(void)
01128 {
01129 struct ast_config_map *map;
01130
01131 ast_mutex_lock(&config_lock);
01132
01133 while (config_maps) {
01134 map = config_maps;
01135 config_maps = config_maps->next;
01136 free(map);
01137 }
01138
01139 ast_mutex_unlock(&config_lock);
01140 }
01141
01142 static int append_mapping(char *name, char *driver, char *database, char *table)
01143 {
01144 struct ast_config_map *map;
01145 int length;
01146
01147 length = sizeof(*map);
01148 length += strlen(name) + 1;
01149 length += strlen(driver) + 1;
01150 length += strlen(database) + 1;
01151 if (table)
01152 length += strlen(table) + 1;
01153
01154 if (!(map = ast_calloc(1, length)))
01155 return -1;
01156
01157 map->name = map->stuff;
01158 strcpy(map->name, name);
01159 map->driver = map->name + strlen(map->name) + 1;
01160 strcpy(map->driver, driver);
01161 map->database = map->driver + strlen(map->driver) + 1;
01162 strcpy(map->database, database);
01163 if (table) {
01164 map->table = map->database + strlen(map->database) + 1;
01165 strcpy(map->table, table);
01166 }
01167 map->next = config_maps;
01168
01169 if (option_verbose > 1)
01170 ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n",
01171 map->name, map->driver, map->database, map->table ? map->table : map->name);
01172
01173 config_maps = map;
01174 return 0;
01175 }
01176
01177 int read_config_maps(void)
01178 {
01179 struct ast_config *config, *configtmp;
01180 struct ast_variable *v;
01181 char *driver, *table, *database, *stringp, *tmp;
01182
01183 clear_config_maps();
01184
01185 configtmp = ast_config_new();
01186 configtmp->max_include_level = 1;
01187 config = ast_config_internal_load(extconfig_conf, configtmp, 0);
01188 if (!config) {
01189 ast_config_destroy(configtmp);
01190 return 0;
01191 }
01192
01193 for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
01194 stringp = v->value;
01195 driver = strsep(&stringp, ",");
01196
01197 if ((tmp = strchr(stringp, '\"')))
01198 stringp = tmp;
01199
01200
01201 if (*stringp == '"') {
01202 stringp++;
01203 database = strsep(&stringp, "\"");
01204 strsep(&stringp, ",");
01205 } else {
01206
01207 database = strsep(&stringp, ",");
01208 }
01209
01210 table = strsep(&stringp, ",");
01211
01212 if (!strcmp(v->name, extconfig_conf)) {
01213 ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf);
01214 continue;
01215 }
01216
01217 if (!strcmp(v->name, "asterisk.conf")) {
01218 ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n");
01219 continue;
01220 }
01221
01222 if (!strcmp(v->name, "logger.conf")) {
01223 ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n");
01224 continue;
01225 }
01226
01227 if (!driver || !database)
01228 continue;
01229 if (!strcasecmp(v->name, "sipfriends")) {
01230 ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sipusers and sippeers, though they can point to the same table.\n");
01231 append_mapping("sipusers", driver, database, table ? table : "sipfriends");
01232 append_mapping("sippeers", driver, database, table ? table : "sipfriends");
01233 } else if (!strcasecmp(v->name, "iaxfriends")) {
01234 ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
01235 append_mapping("iaxusers", driver, database, table ? table : "iaxfriends");
01236 append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends");
01237 } else
01238 append_mapping(v->name, driver, database, table);
01239 }
01240
01241 ast_config_destroy(config);
01242 return 0;
01243 }
01244
01245 int ast_config_engine_register(struct ast_config_engine *new)
01246 {
01247 struct ast_config_engine *ptr;
01248
01249 ast_mutex_lock(&config_lock);
01250
01251 if (!config_engine_list) {
01252 config_engine_list = new;
01253 } else {
01254 for (ptr = config_engine_list; ptr->next; ptr=ptr->next);
01255 ptr->next = new;
01256 }
01257
01258 ast_mutex_unlock(&config_lock);
01259 ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name);
01260
01261 return 1;
01262 }
01263
01264 int ast_config_engine_deregister(struct ast_config_engine *del)
01265 {
01266 struct ast_config_engine *ptr, *last=NULL;
01267
01268 ast_mutex_lock(&config_lock);
01269
01270 for (ptr = config_engine_list; ptr; ptr=ptr->next) {
01271 if (ptr == del) {
01272 if (last)
01273 last->next = ptr->next;
01274 else
01275 config_engine_list = ptr->next;
01276 break;
01277 }
01278 last = ptr;
01279 }
01280
01281 ast_mutex_unlock(&config_lock);
01282
01283 return 0;
01284 }
01285
01286
01287 static struct ast_config_engine *find_engine(const char *family, char *database, int dbsiz, char *table, int tabsiz)
01288 {
01289 struct ast_config_engine *eng, *ret = NULL;
01290 struct ast_config_map *map;
01291
01292 ast_mutex_lock(&config_lock);
01293
01294 for (map = config_maps; map; map = map->next) {
01295 if (!strcasecmp(family, map->name)) {
01296 if (database)
01297 ast_copy_string(database, map->database, dbsiz);
01298 if (table)
01299 ast_copy_string(table, map->table ? map->table : family, tabsiz);
01300 break;
01301 }
01302 }
01303
01304
01305 if (map) {
01306 for (eng = config_engine_list; !ret && eng; eng = eng->next) {
01307 if (!strcasecmp(eng->name, map->driver))
01308 ret = eng;
01309 }
01310 }
01311
01312 ast_mutex_unlock(&config_lock);
01313
01314
01315 if (map && !ret)
01316 ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
01317
01318 return ret;
01319 }
01320
01321 static struct ast_config_engine text_file_engine = {
01322 .name = "text",
01323 .load_func = config_text_file_load,
01324 };
01325
01326 struct ast_config *ast_config_internal_load(const char *filename, struct ast_config *cfg, int withcomments)
01327 {
01328 char db[256];
01329 char table[256];
01330 struct ast_config_engine *loader = &text_file_engine;
01331 struct ast_config *result;
01332
01333 if (cfg->include_level == cfg->max_include_level) {
01334 ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
01335 return NULL;
01336 }
01337
01338 cfg->include_level++;
01339
01340 if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
01341 struct ast_config_engine *eng;
01342
01343 eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
01344
01345
01346 if (eng && eng->load_func) {
01347 loader = eng;
01348 } else {
01349 eng = find_engine("global", db, sizeof(db), table, sizeof(table));
01350 if (eng && eng->load_func)
01351 loader = eng;
01352 }
01353 }
01354
01355 result = loader->load_func(db, table, filename, cfg, withcomments);
01356
01357 if (result)
01358 result->include_level--;
01359 else
01360 cfg->include_level--;
01361
01362 return result;
01363 }
01364
01365 struct ast_config *ast_config_load(const char *filename)
01366 {
01367 struct ast_config *cfg;
01368 struct ast_config *result;
01369
01370 cfg = ast_config_new();
01371 if (!cfg)
01372 return NULL;
01373
01374 result = ast_config_internal_load(filename, cfg, 0);
01375 if (!result)
01376 ast_config_destroy(cfg);
01377
01378 return result;
01379 }
01380
01381 struct ast_config *ast_config_load_with_comments(const char *filename)
01382 {
01383 struct ast_config *cfg;
01384 struct ast_config *result;
01385
01386 cfg = ast_config_new();
01387 if (!cfg)
01388 return NULL;
01389
01390 result = ast_config_internal_load(filename, cfg, 1);
01391 if (!result)
01392 ast_config_destroy(cfg);
01393
01394 return result;
01395 }
01396
01397 struct ast_variable *ast_load_realtime(const char *family, ...)
01398 {
01399 struct ast_config_engine *eng;
01400 char db[256]="";
01401 char table[256]="";
01402 struct ast_variable *res=NULL;
01403 va_list ap;
01404
01405 va_start(ap, family);
01406 eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01407 if (eng && eng->realtime_func)
01408 res = eng->realtime_func(db, table, ap);
01409 va_end(ap);
01410
01411 return res;
01412 }
01413
01414
01415 int ast_check_realtime(const char *family)
01416 {
01417 struct ast_config_engine *eng;
01418
01419 eng = find_engine(family, NULL, 0, NULL, 0);
01420 if (eng)
01421 return 1;
01422 return 0;
01423
01424 }
01425
01426 struct ast_config *ast_load_realtime_multientry(const char *family, ...)
01427 {
01428 struct ast_config_engine *eng;
01429 char db[256]="";
01430 char table[256]="";
01431 struct ast_config *res=NULL;
01432 va_list ap;
01433
01434 va_start(ap, family);
01435 eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01436 if (eng && eng->realtime_multi_func)
01437 res = eng->realtime_multi_func(db, table, ap);
01438 va_end(ap);
01439
01440 return res;
01441 }
01442
01443 int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...)
01444 {
01445 struct ast_config_engine *eng;
01446 int res = -1;
01447 char db[256]="";
01448 char table[256]="";
01449 va_list ap;
01450
01451 va_start(ap, lookup);
01452 eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01453 if (eng && eng->update_func)
01454 res = eng->update_func(db, table, keyfield, lookup, ap);
01455 va_end(ap);
01456
01457 return res;
01458 }
01459
01460 static int config_command(int fd, int argc, char **argv)
01461 {
01462 struct ast_config_engine *eng;
01463 struct ast_config_map *map;
01464
01465 ast_mutex_lock(&config_lock);
01466
01467 ast_cli(fd, "\n\n");
01468 for (eng = config_engine_list; eng; eng = eng->next) {
01469 ast_cli(fd, "\nConfig Engine: %s\n", eng->name);
01470 for (map = config_maps; map; map = map->next)
01471 if (!strcasecmp(map->driver, eng->name)) {
01472 ast_cli(fd, "===> %s (db=%s, table=%s)\n", map->name, map->database,
01473 map->table ? map->table : map->name);
01474 }
01475 }
01476 ast_cli(fd,"\n\n");
01477
01478 ast_mutex_unlock(&config_lock);
01479
01480 return 0;
01481 }
01482
01483 static char show_config_help[] =
01484 "Usage: core show config mappings\n"
01485 " Shows the filenames to config engines.\n";
01486
01487 static struct ast_cli_entry cli_show_config_mappings_deprecated = {
01488 { "show", "config", "mappings", NULL },
01489 config_command, NULL,
01490 NULL };
01491
01492 static struct ast_cli_entry cli_config[] = {
01493 { { "core", "show", "config", "mappings", NULL },
01494 config_command, "Display config mappings (file names to config engines)",
01495 show_config_help, NULL, &cli_show_config_mappings_deprecated },
01496 };
01497
01498 int register_config_cli()
01499 {
01500 ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry));
01501 return 0;
01502 }