static void update_master_conf_vars(ACL_CFG_PARSER *parser) { int i, n = acl_cfg_parser_size(parser); ACL_CFG_LINE *item; for (i = 0; i < n; i++) { item = acl_cfg_parser_index(parser, i); if (item == NULL) break; if (item->ncount < 2) continue; update_int_vars(int_tab, item->value[0], item->value[1]); } for (i = 0; i < n; i++) { item = acl_cfg_parser_index(parser, i); if (item == NULL) break; if (item->ncount < 2) continue; update_str_vars(str_tab, item->value[0], item); } for (i = 0; i < n; i++) { item = acl_cfg_parser_index(parser, i); if (item == NULL) break; if (item->ncount < 2) continue; update_bool_vars(bool_tab, item->value[0], item->value[1]); } }
static void __update_master_conf_vars(ACL_CFG_PARSER *parser) { int i, n; ACL_CFG_LINE *cfg_line; n = acl_cfg_parser_size(parser); for (i = 0; i < n; i++) { cfg_line = acl_cfg_parser_index(parser, i); if (cfg_line == NULL) break; if (cfg_line->ncount < 2) continue; if (acl_msg_verbose) acl_msg_info("%s = [%s]", cfg_line->value[0], cfg_line->value[1]); __update_conf_int_vars(__conf_int_tab, cfg_line->value[0], cfg_line->value[1]); } for (i = 0; i < n; i++) { cfg_line = acl_cfg_parser_index(parser, i); if (cfg_line == NULL) break; if (cfg_line->ncount < 2) continue; if (acl_msg_verbose) acl_msg_info("%s = [%s]", cfg_line->value[0], cfg_line->value[1]); __update_conf_str_vars(__conf_str_tab, cfg_line->value[0], cfg_line->value[1]); } for (i = 0; i < n; i++) { cfg_line = acl_cfg_parser_index(parser, i); if (cfg_line == NULL) break; if (cfg_line->ncount < 2) continue; if (acl_msg_verbose) acl_msg_info("%s = [%s]", cfg_line->value[0], cfg_line->value[1]); __update_conf_bool_vars(__conf_bool_tab, cfg_line->value[0], cfg_line->value[1]); } }
/* 将配置文件读入内存并进行分解 */ int aut_cfg_parse(const char *pathname) { const char *myname = "aut_cfg_parse"; ACL_CFG_PARSER *cfg_parser; ACL_CFG_LINE *cfg_line; int i, n; if (pathname == NULL || *pathname == 0) { aut_log_error("%s: invalid configure name", myname); return (-1); } __init(); cfg_parser = acl_cfg_parser_load(pathname, "|"); if (cfg_parser == NULL) { char tbuf[256]; aut_log_fatal("%s: open cfg_file(%s) error(%s)", myname, pathname, acl_last_strerror(tbuf, sizeof(tbuf))); } n = acl_cfg_parser_size(cfg_parser); for (i = 0; i < n; i++) { cfg_line = (ACL_CFG_LINE *) acl_cfg_parser_index(cfg_parser, i); if (cfg_line == NULL) break; if (cfg_line->ncount == 0) continue; __parse_cfg_line(cfg_line); } acl_cfg_parser_free(cfg_parser); return (0); }