#include "gwlib/gwlib.h"#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <dirent.h>#include "cfg.def"Include dependency graph for cfg.c:

Go to the source code of this file.
Data Structures | |
| struct | CfgGroup |
| struct | CfgLoc |
| struct | Cfg |
Defines | |
| #define | OCTSTR(name) |
| #define | SINGLE_GROUP(name, fields) |
| #define | MULTI_GROUP(name, fields) |
| #define | OCTSTR(name) |
| #define | SINGLE_GROUP(name, fields) |
| #define | MULTI_GROUP(name, fields) |
| #define | OCTSTR(name) printf("%s = <please consult user doc>\n", #name); |
| #define | SINGLE_GROUP(name, fields) |
| #define | MULTI_GROUP(name, fields) |
Functions | |
| CfgGroup * | create_group (void) |
| void | destroy_group (void *arg) |
| CfgLoc * | cfgloc_create (Octstr *filename) |
| void | cfgloc_destroy (CfgLoc *cfgloc) |
| void | destroy_group_list (void *arg) |
| void | set_group_name (CfgGroup *grp, Octstr *name) |
| int | core_is_allowed_in_group (Octstr *group, Octstr *variable) |
| int | core_is_single_group (Octstr *query) |
| int | is_allowed_in_group (Octstr *group, Octstr *variable) |
| int | is_single_group (Octstr *query) |
| void | cfg_add_hooks (void *allowed, void *single) |
| int | add_group (Cfg *cfg, CfgGroup *grp) |
| Cfg * | cfg_create (Octstr *filename) |
| void | cfg_destroy (Cfg *cfg) |
| void | parse_value (Octstr *value) |
| List * | expand_file (Octstr *file, int forward) |
| int | cfg_read (Cfg *cfg) |
| 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_dump_all (void) |
| void | cfg_init (void) |
| void | cfg_shutdown (void) |
Variables | |
| List * | allowed_hooks |
| List * | single_hooks |
|
|
Value: printf("#\n# Multi Group\n#\n"); \ printf("group = %s\n", #name); \ fields; \ printf("\n\n"); |
|
|
Value: if (octstr_compare(octstr_imm(#name), query) == 0) \ return 0; |
|
|
Value: if (octstr_compare(octstr_imm(#name), group) == 0) { \ if (octstr_compare(groupstr, variable) == 0) \ return 1; \ fields \ return 0; \ } |
|
|
|
|
|
|
|
|
Value: if (octstr_compare(octstr_imm(#name), variable) == 0) \ return 1; |
|
|
Value: printf("#\n# Single Group\n#\n"); \ printf("group = %s\n", #name); \ fields; \ printf("\n\n"); |
|
|
Value: if (octstr_compare(octstr_imm(#name), query) == 0) \ return 1; |
|
|
Value: if (octstr_compare(octstr_imm(#name), group) == 0) { \ if (octstr_compare(groupstr, variable) == 0) \ return 1; \ fields \ return 0; \ } |
|
||||||||||||
|
Definition at line 244 of file cfg.c. References cfg_get, dict_get(), dict_keys(), dict_put(), error(), gwlist_append(), gwlist_create, gwlist_destroy(), gwlist_extract_first(), is_allowed_in_group(), is_single_group(), Cfg::multi_groups, name, octstr_destroy(), octstr_destroy_item(), octstr_get_cstr, octstr_imm(), set_group_name(), Cfg::single_groups, and CfgGroup::vars. Referenced by cfg_read(). 00245 {
00246 Octstr *groupname;
00247 Octstr *name;
00248 List *names;
00249 List *list;
00250
00251 groupname = cfg_get(grp, octstr_imm("group"));
00252 if (groupname == NULL) {
00253 error(0, "Group does not contain variable 'group'.");
00254 return -1;
00255 }
00256 set_group_name(grp, groupname);
00257
00258 names = dict_keys(grp->vars);
00259
00260 while ((name = gwlist_extract_first(names)) != NULL) {
00261 int a = is_allowed_in_group(groupname, name);
00262 switch (a) {
00263 case 0:
00264 error(0, "Group '%s' may not contain field '%s'.",
00265 octstr_get_cstr(groupname), octstr_get_cstr(name));
00266 octstr_destroy(name);
00267 octstr_destroy(groupname);
00268 gwlist_destroy(names, octstr_destroy_item);
00269 return -1;
00270 break;
00271 case -1:
00272 error(0, "Group '%s' is no valid group identifier.",
00273 octstr_get_cstr(groupname));
00274 octstr_destroy(name);
00275 octstr_destroy(groupname);
00276 gwlist_destroy(names, octstr_destroy_item);
00277 return -1;
00278 break;
00279 default:
00280 octstr_destroy(name);
00281 break;
00282 }
00283 }
00284 gwlist_destroy(names, NULL);
00285
00286 if (is_single_group(groupname)) {
00287 dict_put(cfg->single_groups, groupname, grp);
00288 } else {
00289 list = dict_get(cfg->multi_groups, groupname);
00290 if (list == NULL) {
00291 list = gwlist_create();
00292 dict_put(cfg->multi_groups, groupname, list);
00293 }
00294 gwlist_append(list, grp);
00295 }
00296
00297 octstr_destroy(groupname);
00298 return 0;
00299 }
|
Here is the call graph for this function:

|
||||||||||||
|
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(), Cfg::filename, 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, Cfg::filename, CfgLoc::filename, 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 113 of file cfg.c. References filename, CfgLoc::filename, and octstr_duplicate. Referenced by expand_file(). 00114 {
00115 CfgLoc *cfgloc;
00116
00117 cfgloc = gw_malloc(sizeof(*cfgloc));
00118 cfgloc->filename = octstr_duplicate(filename);
00119 cfgloc->line_no = 0;
00120 cfgloc->line = NULL;
00121 return cfgloc;
00122 }
|
|
|
Definition at line 125 of file cfg.c. References CfgLoc::filename, CfgLoc::line, and octstr_destroy(). Referenced by cfg_read(). 00126 {
00127 if (cfgloc != NULL) {
00128 octstr_destroy(cfgloc->filename);
00129 octstr_destroy(cfgloc->line);
00130 gw_free(cfgloc);
00131 }
00132 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 164 of file cfg.c. References octstr_imm(). Referenced by cfg_init(). 00165 {
00166 Octstr *groupstr;
00167
00168 groupstr = octstr_imm("group");
00169
00170 #define OCTSTR(name) \
00171 if (octstr_compare(octstr_imm(#name), variable) == 0) \
00172 return 1;
00173 #define SINGLE_GROUP(name, fields) \
00174 if (octstr_compare(octstr_imm(#name), group) == 0) { \
00175 if (octstr_compare(groupstr, variable) == 0) \
00176 return 1; \
00177 fields \
00178 return 0; \
00179 }
00180 #define MULTI_GROUP(name, fields) \
00181 if (octstr_compare(octstr_imm(#name), group) == 0) { \
00182 if (octstr_compare(groupstr, variable) == 0) \
00183 return 1; \
00184 fields \
00185 return 0; \
00186 }
00187 #include "cfg.def"
00188
00189 /* unknown group identifier */
00190 return -1;
00191 }
|
Here is the call graph for this function:

|
|
Definition at line 194 of file cfg.c. Referenced by cfg_init(). 00195 {
00196 #define OCTSTR(name)
00197 #define SINGLE_GROUP(name, fields) \
00198 if (octstr_compare(octstr_imm(#name), query) == 0) \
00199 return 1;
00200 #define MULTI_GROUP(name, fields) \
00201 if (octstr_compare(octstr_imm(#name), query) == 0) \
00202 return 0;
00203 #include "cfg.def"
00204 return 0;
00205 }
|
|
|
Definition at line 80 of file cfg.c. References dict_create(), CfgGroup::name, and octstr_destroy_item(). Referenced by cfg_read(). 00081 {
00082 CfgGroup *grp;
00083
00084 grp = gw_malloc(sizeof(*grp));
00085 grp->name = NULL;
00086 grp->vars = dict_create(64, octstr_destroy_item);
00087 grp->configfile = NULL;
00088 grp->line = 0;
00089 return grp;
00090 }
|
Here is the call graph for this function:

|
|
Definition at line 92 of file cfg.c. References CfgGroup::configfile, dict_destroy(), CfgGroup::name, octstr_destroy(), and CfgGroup::vars. Referenced by cfg_create(), cfg_read(), and destroy_group_list(). 00093 {
00094 CfgGroup *grp;
00095
00096 if (arg != NULL) {
00097 grp = arg;
00098 octstr_destroy(grp->name);
00099 octstr_destroy(grp->configfile);
00100 dict_destroy(grp->vars);
00101 gw_free(grp);
00102 }
00103 }
|
Here is the call graph for this function:

|
|
Definition at line 135 of file cfg.c. References destroy_group(), and gwlist_destroy(). Referenced by cfg_create(). 00136 {
00137 gwlist_destroy(arg, destroy_group);
00138 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 373 of file cfg.c. References cfgloc_create(), file, gwlist_append(), gwlist_create, gwlist_destroy(), gwlist_extract_first(), gwlist_insert(), CfgLoc::line, CfgLoc::line_no, octstr_append(), octstr_create, octstr_delete(), octstr_destroy(), octstr_destroy_item(), octstr_get_char(), octstr_get_cstr, octstr_imm(), octstr_len(), octstr_read_file(), and octstr_split(). Referenced by cfg_read(). 00374 {
00375 Octstr *os;
00376 Octstr *line;
00377 List *lines;
00378 List *expand;
00379 long lineno;
00380 CfgLoc *loc = NULL;
00381
00382 os = octstr_read_file(octstr_get_cstr(file));
00383 if (os == NULL)
00384 return NULL;
00385
00386 lines = octstr_split(os, octstr_imm("\n"));
00387 lineno = 0;
00388 expand = gwlist_create();
00389
00390 while ((line = gwlist_extract_first(lines)) != NULL) {
00391 if (loc == NULL) {
00392 ++lineno;
00393 loc = cfgloc_create(file);
00394 loc->line_no = lineno;
00395 loc->line = octstr_create("");
00396 if (forward)
00397 gwlist_append(expand, loc);
00398 else
00399 gwlist_insert(expand, 0, loc);
00400 }
00401 /* check for escape and then add to existing loc */
00402 if (octstr_get_char(line, octstr_len(line) - 1) == '\\') {
00403 octstr_delete(line, octstr_len(line) - 1, 1);
00404 octstr_append(loc->line, line);
00405 /* check for second escape */
00406 if (octstr_get_char(line, octstr_len(line) - 1) == '\\')
00407 loc = NULL;
00408 } else {
00409 octstr_append(loc->line, line);
00410 loc = NULL;
00411 }
00412 octstr_destroy(line);
00413 }
00414
00415 /*
00416 * add newline at each end of included files to avoid
00417 * concatenating different groups by mistake
00418 */
00419 if (lineno > 0) {
00420 loc = cfgloc_create(file);
00421 loc->line_no = lineno;
00422 loc->line = octstr_create("\n");
00423 if (forward)
00424 gwlist_append(expand, loc);
00425 else
00426 gwlist_insert(expand, 0, loc);
00427 }
00428
00429 gwlist_destroy(lines, octstr_destroy_item);
00430 octstr_destroy(os);
00431
00432 return expand;
00433 }
|
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(), CfgGroup::name, 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:

|
||||||||||||
|
Definition at line 208 of file cfg.c. References allowed_hooks, gwlist_get(), and gwlist_len(). Referenced by add_group(), and cfg_get_real(). 00209 {
00210 long i;
00211 int x, r = -1;
00212
00213 for (i = 0; i < gwlist_len(allowed_hooks); ++i) {
00214 x = ((int(*)(Octstr *, Octstr *))
00215 gwlist_get(allowed_hooks, i))(group, variable);
00216 r = (x == -1 ? (r == -1 ? x : r) : (r == -1 ? x : r + x));
00217 }
00218
00219 return r;
00220 }
|
Here is the call graph for this function:

|
|
Definition at line 223 of file cfg.c. References gwlist_get(), gwlist_len(), and single_hooks. Referenced by add_group(). 00224 {
00225 long i;
00226 int r = 0;
00227
00228 for (i = 0; i < gwlist_len(single_hooks); ++i) {
00229 r += ((int(*)(Octstr *))
00230 gwlist_get(single_hooks, i))(query);
00231 }
00232
00233 return (r > 0);
00234 }
|
Here is the call graph for this function:

|
|
Definition at line 326 of file cfg.c. References octstr_append_char(), octstr_delete(), octstr_destroy(), octstr_duplicate, octstr_get_char(), octstr_len(), octstr_strip_blanks(), and octstr_truncate(). 00327 {
00328 Octstr *temp;
00329 long len;
00330 int c;
00331
00332 octstr_strip_blanks(value);
00333
00334 len = octstr_len(value);
00335 if (octstr_get_char(value, 0) != '"' ||
00336 octstr_get_char(value, len - 1) != '"')
00337 return;
00338
00339 octstr_delete(value, len - 1, 1);
00340 octstr_delete(value, 0, 1);
00341
00342 temp = octstr_duplicate(value);
00343 octstr_truncate(value, 0);
00344
00345 while (octstr_len(temp) > 0) {
00346 c = octstr_get_char(temp, 0);
00347 octstr_delete(temp, 0, 1);
00348
00349 if (c != '\\' || octstr_len(temp) == 0)
00350 octstr_append_char(value, c);
00351 else {
00352 c = octstr_get_char(temp, 0);
00353 octstr_delete(temp, 0, 1);
00354
00355 switch (c) {
00356 case '\\':
00357 case '"':
00358 octstr_append_char(value, c);
00359 break;
00360
00361 default:
00362 octstr_append_char(value, '\\');
00363 octstr_append_char(value, c);
00364 break;
00365 }
00366 }
00367 }
00368
00369 octstr_destroy(temp);
00370 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 141 of file cfg.c. References name, CfgGroup::name, octstr_destroy(), and octstr_duplicate. Referenced by add_group(). 00142 {
00143 octstr_destroy(grp->name);
00144 grp->name = octstr_duplicate(name);
00145 }
|
Here is the call graph for this function:

|
|
Definition at line 161 of file cfg.c. Referenced by cfg_add_hooks(), cfg_init(), cfg_shutdown(), and is_allowed_in_group(). |
|
|
Definition at line 162 of file cfg.c. Referenced by cfg_add_hooks(), cfg_init(), cfg_shutdown(), and is_single_group(). |