diff -Nru zabbix-1.8.5-orig/src/libs/zbxconf/cfg.c zabbix-1.8.5-include/src/libs/zbxconf/cfg.c --- zabbix-1.8.5-orig/src/libs/zbxconf/cfg.c 2011-04-15 22:17:29.000000000 +0300 +++ zabbix-1.8.5-include/src/libs/zbxconf/cfg.c 2011-06-29 17:06:10.023362400 +0300 @@ -34,11 +34,16 @@ static int parse_cfg_object(const char *cfg_file, struct cfg_line *cfg, int level) { #ifdef _WINDOWS - return __parse_cfg_file(cfg_file, cfg, level, 0); + WIN32_FIND_DATAA FindFileData; + HANDLE hFind = NULL; + char cFileName[MAX_PATH] = {0}; + int iPathLen = 0; #else DIR *dir; - struct stat sb; struct dirent *d; +#endif + + struct stat sb; char *incl_file = NULL; int result = SUCCEED; @@ -51,6 +56,49 @@ if (!S_ISDIR(sb.st_mode)) return __parse_cfg_file(cfg_file, cfg, level, 0); +#ifdef _WINDOWS + + zabbix_log(LOG_LEVEL_DEBUG, "parse_cfg_object: %s", cfg_file); + + iPathLen = strlen(cfg_file); + if(iPathLen > MAX_PATH - 3 ) + { + zbx_error("%s: path to long", cfg_file); + return FAIL; // overflow protection + } + + zbx_snprintf(cFileName, sizeof(cFileName), "%s\\*", cfg_file); + + zabbix_log(LOG_LEVEL_DEBUG, "FindFirstFile: %s", cFileName); + + hFind = FindFirstFileA(cFileName, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) { + return FAIL; + } + + while(FindNextFileA( hFind, &FindFileData )) + { + if( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + continue; + + if(strlen(FindFileData.cFileName) + iPathLen > MAX_PATH ) { + zbx_error("%s: Skipping, path to long", FindFileData.cFileName); + continue; + } + + zbx_snprintf(cFileName, sizeof(cFileName), "%s\\%s", cfg_file, FindFileData.cFileName); + + zabbix_log(LOG_LEVEL_DEBUG, "parse_cfg_object: Include=%s", cFileName); + + if( FAIL == __parse_cfg_file(cFileName, cfg, level, 0)) { + FindClose(hFind); + return FAIL; + } + } + + FindClose(hFind); + return SUCCEED; +#else if (NULL == (dir = opendir(cfg_file))) { zbx_error("%s: %s\n", cfg_file, strerror(errno));