This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | cfg_get(grp, varname) cfg_get_real(grp, varname, __FILE__, __LINE__, __func__) |
Typedefs | |
| typedef Cfg | Cfg |
| typedef CfgLoc | CfgLoc |
| typedef CfgGroup | CfgGroup |
Functions | |
| Cfg * | cfg_create (Octstr *filename) |
| void | cfg_destroy (Cfg *cfg) |
| int | cfg_read (Cfg *cfg) |
| void | cfg_add_hooks (void *allowed, void *single) |
| CfgGroup * | cfg_get_single_group (Cfg *cfg, Octstr *name) |
| List * | cfg_get_multi_group (Cfg *cfg, Octstr *name) |
| Octstr * | cfg_get_group_name (CfgGroup *grp) |
| Octstr * | cfg_get_configfile (CfgGroup *grp) |
| Octstr * | cfg_get_real (CfgGroup *grp, Octstr *varname, const char *file, long line, const char *func) |
| int | cfg_get_integer (long *n, CfgGroup *grp, Octstr *varname) |
| int | cfg_get_bool (int *n, CfgGroup *grp, Octstr *varname) |
| List * | cfg_get_list (CfgGroup *grp, Octstr *varname) |
| void | cfg_set (CfgGroup *grp, Octstr *varname, Octstr *value) |
| void | grp_dump (CfgGroup *grp) |
| void | cfg_dump (Cfg *cfg) |
| void | cfg_init (void) |
| void | cfg_shutdown (void) |
| void | cfg_dump_all (void) |
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 237 of file cfg.c. References allowed_hooks, gwlist_append(), and single_hooks. 00238 {
00239 gwlist_append(allowed_hooks, allowed);
00240 gwlist_append(single_hooks, single);
00241 }
|
Here is the call graph for this function:

|
|
Definition at line 302 of file cfg.c. References destroy_group(), destroy_group_list(), dict_create(), filename, Cfg::filename, and octstr_duplicate. Referenced by at2_read_modems(), config_reload(), main(), and read_test_ppg_config(). 00303 {
00304 Cfg *cfg;
00305
00306 cfg = gw_malloc(sizeof(*cfg));
00307 cfg->filename = octstr_duplicate(filename);
00308 cfg->single_groups = dict_create(64, destroy_group);
00309 cfg->multi_groups = dict_create(64, destroy_group_list);
00310
00311 return cfg;
00312 }
|
Here is the call graph for this function:

|
|
Definition at line 315 of file cfg.c. References dict_destroy(), Cfg::filename, Cfg::multi_groups, octstr_destroy(), and Cfg::single_groups. Referenced by at2_read_modems(), config_reload(), init_wapbox(), main(), read_ppg_config(), and read_test_ppg_config(). 00316 {
00317 if (cfg != NULL) {
00318 octstr_destroy(cfg->filename);
00319 dict_destroy(cfg->single_groups);
00320 dict_destroy(cfg->multi_groups);
00321 gw_free(cfg);
00322 }
00323 }
|
Here is the call graph for this function:

|
|
Definition at line 761 of file cfg.c. References cfg_get_multi_group(), cfg_get_single_group(), debug(), dict_keys(), grp_dump(), gwlist_destroy(), gwlist_extract_first(), name, octstr_destroy(), and octstr_get_cstr. Referenced by init_wapbox(), main(), and read_test_ppg_config(). 00762 {
00763 CfgGroup *grp;
00764 List *list;
00765 List *names;
00766 Octstr *name;
00767
00768 debug("gwlib.cfg", 0, "Dumping Cfg %p", (void *) cfg);
00769 debug("gwlib.cfg", 0, " filename = <%s>",
00770 octstr_get_cstr(cfg->filename));
00771
00772 names = dict_keys(cfg->single_groups);
00773 while ((name = gwlist_extract_first(names)) != NULL) {
00774 grp = cfg_get_single_group(cfg, name);
00775 if (grp != NULL)
00776 grp_dump(grp);
00777 octstr_destroy(name);
00778 }
00779 gwlist_destroy(names, NULL);
00780
00781 names = dict_keys(cfg->multi_groups);
00782 while ((name = gwlist_extract_first(names)) != NULL) {
00783 list = cfg_get_multi_group(cfg, name);
00784 while ((grp = gwlist_extract_first(list)) != NULL)
00785 grp_dump(grp);
00786 gwlist_destroy(list, NULL);
00787 octstr_destroy(name);
00788 }
00789 gwlist_destroy(names, NULL);
00790
00791 debug("gwlib.cfg", 0, "Dump ends.");
00792 }
|
Here is the call graph for this function:

|
|
Definition at line 795 of file cfg.c. Referenced by get_and_set_debugs(). 00796 {
00797 #define OCTSTR(name) \
00798 printf("%s = <please consult user doc>\n", #name);
00799 #define SINGLE_GROUP(name, fields) \
00800 printf("#\n# Single Group\n#\n"); \
00801 printf("group = %s\n", #name); \
00802 fields; \
00803 printf("\n\n");
00804 #define MULTI_GROUP(name, fields) \
00805 printf("#\n# Multi Group\n#\n"); \
00806 printf("group = %s\n", #name); \
00807 fields; \
00808 printf("\n\n");
00809 #include "cfg.def"
00810 }
|
|
||||||||||||||||
Here is the call graph for this function:

|
|
Definition at line 642 of file cfg.c. References CfgGroup::configfile, and octstr_duplicate. Referenced by smsc_at2_create(). 00643 {
00644 return octstr_duplicate(grp->configfile);
00645 }
|
|
|
Definition at line 637 of file cfg.c. References CfgGroup::name, and octstr_duplicate. Referenced by create_onetrans(). 00638 {
00639 return octstr_duplicate(grp->name);
00640 }
|
|
||||||||||||||||
|
Definition at line 668 of file cfg.c. References cfg_get, octstr_destroy(), and octstr_parse_long(). Referenced by at2_read_modems(), check_config(), config_reload(), create_onetrans(), dlr_init_mysql(), dlr_init_pgsql(), httpadmin_start(), init_bearerbox(), init_configuration(), init_smsbox(), init_wapbox(), radius_acct_init(), read_ppg_config(), read_test_ppg_config(), smsbox_start(), smsc2_start(), smsc_at2_create(), smsc_cgw_create(), smsc_cimd2_create(), smsc_emi2_create(), smsc_fake_create(), smsc_http_create(), smsc_oisd_create(), smsc_open(), smsc_smpp_create(), smsc_soap_create(), smscconn_create(), and wapbox_start(). 00669 {
00670 Octstr *os;
00671 int ret;
00672
00673 os = cfg_get(grp, varname);
00674 if (os == NULL)
00675 return -1;
00676 if (octstr_parse_long(n, os, 0, 0) == -1)
00677 ret = -1;
00678 else
00679 ret = 0;
00680 octstr_destroy(os);
00681 return ret;
00682 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 716 of file cfg.c. References cfg_get, octstr_destroy(), and octstr_split_words(). Referenced by config_reload(), and init_smsbox(). 00717 {
00718 Octstr *os;
00719 List *list;
00720
00721 os = cfg_get(grp, varname);
00722 if (os == NULL)
00723 return NULL;
00724
00725 list = octstr_split_words(os);
00726 octstr_destroy(os);
00727 return list;
00728 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 621 of file cfg.c. References dict_get(), gwlist_append(), gwlist_create, gwlist_get(), gwlist_len(), Cfg::multi_groups, and name. Referenced by at2_read_modems(), cfg_dump(), config_reload(), dlr_init_mysql(), dlr_init_pgsql(), init_bearerbox(), init_smsbox_routes(), read_ppg_config(), smsbox_req_sendota(), smsc2_start(), and urltrans_add_cfg(). 00622 {
00623 List *list, *copy;
00624 long i;
00625
00626 list = dict_get(cfg->multi_groups, name);
00627 if (list == NULL)
00628 return NULL;
00629
00630 copy = gwlist_create();
00631 for (i = 0; i < gwlist_len(list); ++i)
00632 gwlist_append(copy, gwlist_get(list, i));
00633 return copy;
00634 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 648 of file cfg.c. References dict_get(), file, is_allowed_in_group(), CfgGroup::name, octstr_duplicate, octstr_get_cstr, panic, and CfgGroup::vars. 00650 {
00651 Octstr *os;
00652
00653 if(grp == NULL)
00654 panic(0, "Trying to fetch variable `%s' in non-existing group",
00655 octstr_get_cstr(varname));
00656
00657 if (grp->name != NULL && !is_allowed_in_group(grp->name, varname))
00658 panic(0, "Trying to fetch variable `%s' in group `%s', not allowed.",
00659 octstr_get_cstr(varname), octstr_get_cstr(grp->name));
00660
00661 os = dict_get(grp->vars, varname);
00662 if (os == NULL)
00663 return NULL;
00664 return gw_claim_area_for(octstr_duplicate(os), file, line, func);
00665 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 615 of file cfg.c. References dict_get(), name, and Cfg::single_groups. Referenced by cfg_dump(), check_config(), config_reload(), dlr_init(), dlr_init_mysql(), dlr_init_pgsql(), httpadmin_start(), init_bearerbox(), init_smsbox(), init_wapbox(), read_ppg_config(), read_test_ppg_config(), smsbox_start(), smsc2_start(), udp_start(), and wapbox_start(). 00616 {
00617 return dict_get(cfg->single_groups, name);
00618 }
|
Here is the call graph for this function:

|
|
Definition at line 813 of file cfg.c. References allowed_hooks, core_is_allowed_in_group(), core_is_single_group(), gwlist_append(), gwlist_create, and single_hooks. Referenced by gwlib_init(). 00814 {
00815 /* make sure we put our own core hooks into the lists */
00816 allowed_hooks = gwlist_create();
00817 single_hooks = gwlist_create();
00818
00819 gwlist_append(allowed_hooks, &core_is_allowed_in_group);
00820 gwlist_append(single_hooks, &core_is_single_group);
00821 }
|
Here is the call graph for this function:

|
|
Definition at line 436 of file cfg.c. References add_group(), cfg_set(), cfgloc_destroy(), CfgGroup::configfile, create_group(), debug(), destroy_group(), error(), expand_file(), file, filename, CfgLoc::filename, Cfg::filename, gwlist_create, gwlist_destroy(), gwlist_extract_first(), gwlist_insert(), gwlist_search(), CfgLoc::line, CfgLoc::line_no, name, octstr_append_cstr(), octstr_copy, octstr_destroy(), octstr_destroy_item(), octstr_duplicate, octstr_get_char(), octstr_get_cstr, octstr_imm(), octstr_item_match(), octstr_len(), octstr_search(), octstr_search_char(), octstr_strip_blanks(), panic, and parse_value(). Referenced by at2_read_modems(), config_reload(), main(), and read_test_ppg_config(). 00437 {
00438 CfgLoc *loc;
00439 CfgLoc *loc_inc;
00440 List *lines;
00441 List *expand;
00442 List *stack;
00443 Octstr *name;
00444 Octstr *value;
00445 Octstr *filename;
00446 CfgGroup *grp;
00447 long equals;
00448 long lineno;
00449 long error_lineno;
00450
00451 loc = loc_inc = NULL;
00452
00453 /*
00454 * expand initial main config file and add it to the recursion
00455 * stack to protect against cycling
00456 */
00457 if ((lines = expand_file(cfg->filename, 1)) == NULL) {
00458 panic(0, "Failed to load main configuration file `%s'. Aborting!",
00459 octstr_get_cstr(cfg->filename));
00460 }
00461 stack = gwlist_create();
00462 gwlist_insert(stack, 0, octstr_duplicate(cfg->filename));
00463
00464 grp = NULL;
00465 lineno = 0;
00466 error_lineno = 0;
00467 while (error_lineno == 0 && (loc = gwlist_extract_first(lines)) != NULL) {
00468 octstr_strip_blanks(loc->line);
00469 if (octstr_len(loc->line) == 0) {
00470 if (grp != NULL && add_group(cfg, grp) == -1) {
00471 error_lineno = loc->line_no;
00472 destroy_group(grp);
00473 }
00474 grp = NULL;
00475 } else if (octstr_get_char(loc->line, 0) != '#') {
00476 equals = octstr_search_char(loc->line, '=', 0);
00477 if (equals == -1) {
00478 error(0, "An equals sign ('=') is missing on line %ld of file %s.",
00479 loc->line_no, octstr_get_cstr(loc->filename));
00480 error_lineno = loc->line_no;
00481 } else
00482
00483 /*
00484 * check for special config directives, like include or conditional
00485 * directives here
00486 */
00487 if (octstr_search(loc->line, octstr_imm("include"), 0) != -1) {
00488 filename = octstr_copy(loc->line, equals + 1, octstr_len(loc->line));
00489 parse_value(filename);
00490
00491 /* check if we are cycling */
00492 if (gwlist_search(stack, filename, octstr_item_match) != NULL) {
00493 panic(0, "Recursive include for config file `%s' detected "
00494 "(on line %ld of file %s).",
00495 octstr_get_cstr(filename), loc->line_no,
00496 octstr_get_cstr(loc->filename));
00497 } else {
00498 List *files = gwlist_create();
00499 Octstr *file;
00500 struct stat filestat;
00501
00502 /* check if included file is a directory */
00503 lstat(octstr_get_cstr(filename), &filestat);
00504
00505 /*
00506 * is a directory, create a list with files of
00507 * this directory and load all as part of the
00508 * whole configuration.
00509 */
00510 if (S_ISDIR(filestat.st_mode)) {
00511 DIR *dh;
00512 struct dirent *diritem;
00513
00514 debug("gwlib.cfg", 0, "Loading include dir `%s' "
00515 "(on line %ld of file %s).",
00516 octstr_get_cstr(filename), loc->line_no,
00517 octstr_get_cstr(loc->filename));
00518
00519 dh = opendir(octstr_get_cstr(filename));
00520 while ((diritem = readdir(dh))) {
00521 Octstr *fileitem;
00522
00523 fileitem = octstr_duplicate(filename);
00524 octstr_append_cstr(fileitem, "/");
00525 octstr_append_cstr(fileitem, diritem->d_name);
00526
00527 lstat(octstr_get_cstr(fileitem), &filestat);
00528 if (!S_ISDIR(filestat.st_mode)) {
00529 gwlist_insert(files, 0, fileitem);
00530 } else {
00531 octstr_destroy(fileitem);
00532 }
00533 }
00534 closedir(dh);
00535 }
00536
00537 /* is a file, create a list with it */
00538 else {
00539 gwlist_insert(files, 0, octstr_duplicate(filename));
00540 }
00541
00542 /* include files */
00543 while ((file = gwlist_extract_first(files)) != NULL) {
00544
00545 gwlist_insert(stack, 0, octstr_duplicate(file));
00546 debug("gwlib.cfg", 0, "Loading include file `%s' (on line %ld of file %s).",
00547 octstr_get_cstr(file), loc->line_no,
00548 octstr_get_cstr(loc->filename));
00549
00550 /*
00551 * expand the given include file and add it to the current
00552 * processed main while loop
00553 */
00554 if ((expand = expand_file(file, 0)) != NULL) {
00555 while ((loc_inc = gwlist_extract_first(expand)) != NULL)
00556 gwlist_insert(lines, 0, loc_inc);
00557 } else {
00558 panic(0, "Failed to load whole configuration. Aborting!");
00559 }
00560
00561 gwlist_destroy(expand, NULL);
00562 cfgloc_destroy(loc_inc);
00563 octstr_destroy(file);
00564 }
00565 gwlist_destroy(files, octstr_destroy_item);
00566 }
00567 octstr_destroy(filename);
00568 }
00569
00570 /*
00571 * this is a "normal" line, so process it accodingly
00572 */
00573 else {
00574 name = octstr_copy(loc->line, 0, equals);
00575 octstr_strip_blanks(name);
00576 value = octstr_copy(loc->line, equals + 1, octstr_len(loc->line));
00577 parse_value(value);
00578
00579 if (grp == NULL)
00580 grp = create_group();
00581
00582 if (grp->configfile != NULL) {
00583 octstr_destroy(grp->configfile);
00584 grp->configfile = NULL;
00585 }
00586 grp->configfile = octstr_duplicate(cfg->filename);
00587
00588 cfg_set(grp, name, value);
00589 octstr_destroy(name);
00590 octstr_destroy(value);
00591 }
00592 }
00593
00594 cfgloc_destroy(loc);
00595 }
00596
00597 if (grp != NULL && add_group(cfg, grp) == -1) {
00598 error_lineno = 1;
00599 destroy_group(grp);
00600 }
00601
00602 gwlist_destroy(lines, NULL);
00603 gwlist_destroy(stack, octstr_destroy_item);
00604
00605 if (error_lineno != 0) {
00606 error(0, "Error found on line %ld of file `%s'.",
00607 error_lineno, octstr_get_cstr(cfg->filename));
00608 return -1;
00609 }
00610
00611 return 0;
00612 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 731 of file cfg.c. References dict_put(), octstr_duplicate, and CfgGroup::vars. Referenced by cfg_read(). 00732 {
00733 dict_put(grp->vars, varname, octstr_duplicate(value));
00734 }
|
Here is the call graph for this function:

|
|
Definition at line 824 of file cfg.c. References allowed_hooks, gwlist_destroy(), and single_hooks. Referenced by gwlib_shutdown(). 00825 {
00826 gwlist_destroy(allowed_hooks, NULL);
00827 gwlist_destroy(single_hooks, NULL);
00828 allowed_hooks = single_hooks = NULL;
00829 }
|
Here is the call graph for this function:

|
|
Definition at line 737 of file cfg.c. References cfg_get, debug(), dict_keys(), gwlist_destroy(), gwlist_extract_first(), name, CfgGroup::name, octstr_destroy(), octstr_get_cstr, and CfgGroup::vars. Referenced by cfg_dump(), create_onetrans(), and init_smsbox_routes(). 00738 {
00739 List *names;
00740 Octstr *name;
00741 Octstr *value;
00742
00743 if (grp->name == NULL)
00744 debug("gwlib.cfg", 0, " dumping group (name not set):");
00745 else
00746 debug("gwlib.cfg", 0, " dumping group (%s):",
00747 octstr_get_cstr(grp->name));
00748 names = dict_keys(grp->vars);
00749 while ((name = gwlist_extract_first(names)) != NULL) {
00750 value = cfg_get(grp, name);
00751 debug("gwlib.cfg", 0, " <%s> = <%s>",
00752 octstr_get_cstr(name),
00753 octstr_get_cstr(value));
00754 octstr_destroy(value);
00755 octstr_destroy(name);
00756 }
00757 gwlist_destroy(names, NULL);
00758 }
|
Here is the call graph for this function:
