From: Adam Dickmeiss Date: Mon, 25 Jan 2010 15:30:14 +0000 (+0100) Subject: Start work on file_glob . X-Git-Tag: v4.0.1~6 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=39c353b281dd91c145e122110d516fce7bbde8c6 Start work on file_glob . --- diff --git a/src/Makefile.am b/src/Makefile.am index 7cff54e..2208c7f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -103,7 +103,7 @@ libyaz_la_SOURCES=version.c options.c log.c \ 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 + json.c xml_include.c file_glob.c libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO) diff --git a/src/file_glob.c b/src/file_glob.c new file mode 100644 index 0000000..2f3ff7f --- /dev/null +++ b/src/file_glob.c @@ -0,0 +1,55 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data + * See the file LICENSE for details. + */ + +/** \file + \brief File globbing (ala POSIX glob) +*/ +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +struct res_entry { + struct res_entry *next; +}; + +struct glob_res { + struct res_entry *entries; +}; + +typedef struct glob_res *yaz_glob_res_t; + +static void glob_r(const char *pattern, yaz_glob_res_t res, size_t off) +{ + size_t i = off; + while (pattern[i] && !strchr("/\\", pattern[i])) + i++; +} + +int yaz_file_glob(const char *pattern, yaz_glob_res_t *res) +{ + *res = xmalloc(sizeof(**res)); + (*res)->entries = 0; + glob_r(pattern, *res, 0); + return 0; +} + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +