X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fxml_include.c;h=3ddc570dccfa5ce434daa12a2b1ecd629c9ab704;hp=add66d939d3e286cffa4a011591cd89a29bee542;hb=48b7a077523d1a86c16c9f536c56d6439fe90f42;hpb=f51b5b23754da0f2446ade88c176939baffc64f9 diff --git a/src/xml_include.c b/src/xml_include.c index add66d9..3ddc570 100644 --- a/src/xml_include.c +++ b/src/xml_include.c @@ -1,24 +1,16 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2012 Index Data * See the file LICENSE for details. */ -/** \file +/** \file \brief XML Include (not to be confused with W3C XInclude) */ #if HAVE_CONFIG_H #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,27 +97,26 @@ 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); - - for (i = 0; ret == 0 && i < glob_res.gl_pathc; i++) + int glob_ret; + yaz_glob_res_t glob_res; + + glob_ret = yaz_file_glob(wrbuf_cstr(w), &glob_res); + + 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)); sib = xmlAddNextSibling(sib, c); - + *np = sib; wrbuf_destroy(w); return ret; @@ -147,7 +138,7 @@ static int process_config_includes(yaz_xml_include_t config, xmlNode *n) xmlFree(src); if (ret) return ret; - + } } else @@ -165,8 +156,7 @@ int yaz_xml_include_simple(xmlNode *n, const char *base_path) struct yaz_xml_include_s s; s.confdir = base_path; - process_config_includes(&s, n); - return 0; + return process_config_includes(&s, n); } /* YAZ_HAVE_XML2 */