YAZ_DOC
dnl
dnl
-AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h glob.h sys/un.h sys/wait.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h],[],[],[])
+AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h],[],[],[])
AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
z-grs.h z-mterm2.h z-opac.h z-rrf1.h z-rrf2.h z-sum.h z-sutrs.h z-uifr1.h \
z-univ.h z-oclcui.h zes-expi.h zes-exps.h zes-order.h zes-pquery.h \
zes-psched.h zes-admin.h zes-pset.h zes-update.h zes-update0.h \
- zoom.h z-charneg.h charneg.h soap.h srw.h zgdu.h matchstr.h json.h file_glob.h
+ zoom.h z-charneg.h charneg.h soap.h srw.h zgdu.h matchstr.h json.h \
+ file_glob.h dirent.h
EXTRA_DIST = yaz-version.h.in
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data.
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Index Data nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** \file
+ \brief wrapper for dirent.h or our own for Windows
+*/
+
+#ifdef WIN32
+/* make WIN32 version of dirent */
+#include <windows.h>
+
+#include <yaz/yconfig.h>
+
+YAZ_BEGIN_CDECL
+
+struct dirent {
+ char d_name[MAX_PATH];
+};
+
+typedef struct DIR DIR;
+
+DIR *opendir (const char *path);
+struct dirent *readdir (DIR *dd);
+void closedir (DIR *dd);
+
+YAZ_END_CDECL
+
+#else
+/* include UNIX version */
+#include <sys/types.h>
+#include <dirent.h>
+#endif
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
copy_types.c match_glob.c poll.c daemon.c \
iconv_encode_marc8.c iconv_encode_iso_8859_1.c iconv_encode_wchar.c \
iconv_decode_marc8.c iconv_decode_iso5426.c iconv_decode_danmarc.c sc.c \
- json.c xml_include.c file_glob.c
+ json.c xml_include.c file_glob.c dirent.c
libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO)
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
+ * See the file LICENSE for details.
+ */
+
+/** \file
+ \brief Implement opendir/readdir/closedir on Windows
+*/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#ifdef WIN32
+#include <io.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+
+#include <yaz/dirent.h>
+
+#ifdef WIN32
+
+struct DIR {
+ HANDLE handle;
+ WIN32_FIND_DATA find_data;
+ struct dirent entry;
+};
+
+DIR *opendir (const char *name)
+{
+ char fullName[MAX_PATH+1];
+ DIR *dd = malloc (sizeof(*dd));
+
+ if (!dd)
+ return NULL;
+ strcpy (fullName, name);
+ strcat (fullName, "\\*.*");
+ dd->handle = FindFirstFile(fullName, &dd->find_data);
+ return dd;
+}
+
+struct dirent *readdir (DIR *dd)
+{
+ if (dd->handle == INVALID_HANDLE_VALUE)
+ return NULL;
+ strcpy (dd->entry.d_name, dd->find_data.cFileName);
+ if (!FindNextFile(dd->handle, &dd->find_data))
+ {
+ FindClose (dd->handle);
+ dd->handle = INVALID_HANDLE_VALUE;
+ }
+ return &dd->entry;
+}
+
+void closedir(DIR *dd)
+{
+ if (dd->handle != INVALID_HANDLE_VALUE)
+ FindClose (dd->handle);
+ if (dd)
+ free (dd);
+}
+
+#endif
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
#include <yaz/wrbuf.h>
#include <yaz/tpath.h>
#include <yaz/log.h>
-#include <dirent.h>
+#include <yaz/dirent.h>
#include <yaz/nmem.h>
#include <yaz/file_glob.h>
#include <yaz/match_glob.h>
#include <config.h>
#endif
-#if HAVE_GLOB_H
-#define USE_POSIX_GLOB 1
-#else
-#define USE_POSIX_GLOB 0
-#endif
-
-#if USE_POSIX_GLOB
-#include <glob.h>
-#endif
+#include <yaz/file_glob.h>
#include <sys/types.h>
#include <sys/stat.h>
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));
const char *srcdir = getenv("srcdir");
xmlDocPtr doc;
xmlNodePtr node;
- const char *xml_in = "<x><include src=\"tst_xml_include.xml\"/></x>";
+ const char *xml_in = "<x><include src=\"tst_xml_inc*.xml\"/></x>";
if (srcdir == 0)
srcdir = ".";
{
const char *expect =
"<?xml version=\"1.0\"?>\n"
- "<x><!-- begin include src=\"tst_xml_include.xml\" -->"
+ "<x><!-- begin include src=\"tst_xml_inc*.xml\" -->"
"<y>some</y>"
- "<!-- end include src=\"tst_xml_include.xml\" --></x>\n";
+ "<!-- end include src=\"tst_xml_inc*.xml\" --></x>\n";
xmlChar *xml_out;
int len_out;
$(OBJDIR)\mutex.obj \
$(OBJDIR)\json.obj \
$(OBJDIR)\sc.obj \
- $(OBJDIR)\xml_include.obj
+ $(OBJDIR)\xml_include.obj \
+ $(OBJDIR)\file_glob.obj \
+ $(OBJDIR)\dirent.obj
Z3950_OBJS= \
$(OBJDIR)\z-date.obj\