--- freeswitch-tip/src/switch_xml.cpp 2008-06-27 15:33:09.000000000 -0700 +++ freeswitch/src/switch_xml.c 2008-06-27 15:48:08.000000000 -0700 @@ -56,6 +56,7 @@ #include #ifndef WIN32 #include +#include #endif #undef HAVE_MMAP #ifdef HAVE_MMAP @@ -67,7 +68,6 @@ #define SWITCH_XML_WS "\t\r\n " // whitespace #define SWITCH_XML_ERRL 128 // maximum error string length -#include "SimpleGlob.h" static int preprocess(const char *cwd, const char *file, int write_fd, int rlevel); @@ -986,42 +986,37 @@ static int preprocess_glob(const char *cwd, const char *pattern, int write_fd, int rlevel) { - char *argv[1] = {0}; - int argc = 1; char *full_path = NULL; char *dir_path = NULL, *e = NULL; + glob_t glob_data; if (!switch_is_file_path(pattern)) { full_path = switch_mprintf("%s%s%s", cwd, SWITCH_PATH_SEPARATOR, pattern); pattern = full_path; } - argv[0] = (char *)pattern; - - CSimpleGlob glob(SG_GLOB_NODOT|SG_GLOB_NOCHECK); - - if (SG_SUCCESS != glob.Add(argc, argv)) { + if(glob(pattern, GLOB_NOCHECK, NULL, &glob_data) != 0) { if (stderr) { - fprintf(stderr, "Error including %s\n", argv[0]); + fprintf(stderr, "Error including %s\n", pattern); } goto end; } - for (int n = 0; n < glob.FileCount(); ++n) { - dir_path = strdup(glob.File(n)); + for (int n = 0; n < glob_data.gl_pathc; ++n) { + dir_path = strdup(glob_data.gl_pathv[n]); switch_assert(dir_path); if ((e = strrchr(dir_path, *SWITCH_PATH_SEPARATOR))) { *e = '\0'; } - if (preprocess(dir_path, glob.File(n), write_fd, rlevel) < 0) { + if (preprocess(dir_path, glob_data.gl_pathv[n], write_fd, rlevel) < 0) { const char *reason = strerror(errno); if (rlevel > 100) { reason = "Maximum recursion limit reached"; } - fprintf(stderr, "Error including %s (%s)\n", argv[0], reason); + fprintf(stderr, "Error including %s (%s)\n", pattern, reason); } - free(dir_path); } + globfree(&glob_data); end: