X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fxml_include.c;h=8008610e25f2fe2fec0ee931c33f6be1b7e62963;hp=574ee854d51ea3bb611c663fbf7fc9901d0c373d;hb=323805b6779bcf1befdc7cdd7f10c23b06885e0d;hpb=77c5a4fca8b516fd39b8ba213daed17a465a6b2a diff --git a/src/xml_include.c b/src/xml_include.c index 574ee85..8008610 100644 --- a/src/xml_include.c +++ b/src/xml_include.c @@ -1,17 +1,15 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2012 Index Data + * Copyright (C) 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 -#include - #include #include #include @@ -29,6 +27,7 @@ struct yaz_xml_include_s { const char *confdir; + unsigned glob_flags; }; typedef struct yaz_xml_include_s *yaz_xml_include_t; @@ -101,8 +100,7 @@ static int config_include_src(yaz_xml_include_t config, xmlNode **np, int glob_ret; yaz_glob_res_t glob_res; - glob_ret = yaz_file_glob(wrbuf_cstr(w), &glob_res); - + glob_ret = yaz_file_glob2(wrbuf_cstr(w), &glob_res, config->glob_flags); if (glob_ret == 0) { size_t i; @@ -116,7 +114,7 @@ static int config_include_src(yaz_xml_include_t config, xmlNode **np, 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; @@ -133,12 +131,13 @@ static int process_config_includes(yaz_xml_include_t config, xmlNode *n) xmlChar *src = xmlGetProp(n, (xmlChar *) "src"); if (src) { + /* src must be preserved, because n is destroyed */ int ret = config_include_src(config, &n, (const char *) src); xmlFree(src); if (ret) return ret; - + } } else @@ -151,15 +150,22 @@ static int process_config_includes(yaz_xml_include_t config, xmlNode *n) return 0; } -int yaz_xml_include_simple(xmlNode *n, const char *base_path) +int yaz_xml_include_glob(xmlNode *n, const char *base_path, + unsigned glob_flags) { struct yaz_xml_include_s s; s.confdir = base_path; - process_config_includes(&s, n); - return 0; + s.glob_flags = glob_flags; + return process_config_includes(&s, n); } +int yaz_xml_include_simple(xmlNode *n, const char *base_path) +{ + return yaz_xml_include_glob(n, base_path, 0); +} + + /* YAZ_HAVE_XML2 */ #endif