Start work on file_glob .
[yaz-moved-to-github.git] / src / file_glob.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /** \file 
7     \brief File globbing (ala POSIX glob)
8 */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <stdio.h>
16 #include <string.h>
17 #include <assert.h>
18 #include <yaz/wrbuf.h>
19 #include <yaz/tpath.h>
20 #include <yaz/log.h>
21
22 struct res_entry {
23     struct res_entry *next;
24 };
25
26 struct glob_res {
27     struct res_entry *entries;
28 };
29
30 typedef struct glob_res *yaz_glob_res_t;
31
32 static void glob_r(const char *pattern, yaz_glob_res_t res, size_t off)
33 {
34     size_t i = off;
35     while (pattern[i] && !strchr("/\\", pattern[i]))
36         i++;
37 }
38
39 int yaz_file_glob(const char *pattern, yaz_glob_res_t *res)
40 {
41     *res = xmalloc(sizeof(**res));
42     (*res)->entries = 0;
43     glob_r(pattern, *res, 0);
44     return 0;
45 }
46
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * c-file-style: "Stroustrup"
51  * indent-tabs-mode: nil
52  * End:
53  * vim: shiftwidth=4 tabstop=8 expandtab
54  */
55