static int parse_cfg_object(const char *cfg_file, struct cfg_line *cfg, int level, int strict) { #ifdef _WINDOWS return __parse_cfg_file(cfg_file, cfg, level, ZBX_CFG_FILE_REQUIRED, strict); #else DIR *dir; struct stat sb; struct dirent *d; char *incl_file = NULL; int result = SUCCEED; if (-1 == stat(cfg_file, &sb)) { zbx_error("%s: %s\n", cfg_file, zbx_strerror(errno)); return FAIL; } if (!S_ISDIR(sb.st_mode)) return __parse_cfg_file(cfg_file, cfg, level, ZBX_CFG_FILE_REQUIRED, strict); if (NULL == (dir = opendir(cfg_file))) { zbx_error("%s: %s\n", cfg_file, zbx_strerror(errno)); return FAIL; } while (NULL != (d = readdir(dir))) { incl_file = zbx_dsprintf(incl_file, "%s/%s", cfg_file, d->d_name); if (-1 == stat(incl_file, &sb) || !S_ISREG(sb.st_mode)) continue; if (FAIL == __parse_cfg_file(incl_file, cfg, level, ZBX_CFG_FILE_REQUIRED, strict)) { result = FAIL; break; } } zbx_free(incl_file); if (-1 == closedir(dir)) { zbx_error("%s: %s\n", cfg_file, zbx_strerror(errno)); return FAIL; } return result; #endif }
int parse_cfg_file(const char *cfg_file, struct cfg_line *cfg, int optional, int strict) { return __parse_cfg_file(cfg_file, cfg, 0, optional, strict); }
int parse_opt_cfg_file(const char *cfg_file, struct cfg_line *cfg) { return __parse_cfg_file(cfg_file, cfg, 0, 1); }