X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fxml_include.c;h=1e64b548a7357c2a5e58fac59f5bba501865a728;hp=db5f13e0d6bb299ace1c38c9e78dbec44779aac7;hb=43a9d38d20c1b1bcd1a03b2445a501d27526bd35;hpb=bc34bd42eb228125be6ff9143d9f98dbe11889a0 diff --git a/src/xml_include.c b/src/xml_include.c index db5f13e..1e64b54 100644 --- a/src/xml_include.c +++ b/src/xml_include.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ @@ -10,15 +10,7 @@ #include #endif -#if HAVE_GLOB_H -#define USE_POSIX_GLOB 1 -#else -#define USE_POSIX_GLOB 0 -#endif - -#if USE_POSIX_GLOB -#include -#endif +#include #include #include @@ -105,22 +97,21 @@ static int config_include_src(yaz_xml_include_t config, xmlNode **np, wrbuf_rewind(w); conf_dir_path(config, w, src); -#if USE_POSIX_GLOB { - size_t i; - glob_t glob_res; - glob(wrbuf_cstr(w), 0 /* flags */, 0 /* errfunc */, &glob_res); + int glob_ret; + yaz_glob_res_t glob_res; + + glob_ret = yaz_file_glob(wrbuf_cstr(w), &glob_res); - for (i = 0; ret == 0 && i < glob_res.gl_pathc; i++) + if (glob_ret == 0) { - const char *path = glob_res.gl_pathv[i]; - ret = config_include_one(config, &sib, path); + size_t i; + const char *path; + for (i = 0; (path = yaz_file_glob_get_file(glob_res, i)); i++) + ret = config_include_one(config, &sib, path); + yaz_file_globfree(&glob_res); } - globfree(&glob_res); } -#else - ret = config_include_one(config, &sib, wrbuf_cstr(w)); -#endif wrbuf_rewind(w); wrbuf_printf(w, " end include src=\"%s\" ", src); c = xmlNewComment((const xmlChar *) wrbuf_cstr(w)); @@ -133,7 +124,7 @@ static int config_include_src(yaz_xml_include_t config, xmlNode **np, static int process_config_includes(yaz_xml_include_t config, xmlNode *n) { - for (; n; n = n->next) + for (n = n->children; n; n = n->next) { if (n->type == XML_ELEMENT_NODE) { @@ -152,7 +143,7 @@ static int process_config_includes(yaz_xml_include_t config, xmlNode *n) } else { - if (process_config_includes(config, n->children)) + if (process_config_includes(config, n)) return -1; } }