1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
15 #include <yaz/file_glob.h>
18 #include <yaz/wrbuf.h>
20 void tst_with_path(const char *tpath)
22 yaz_glob_res_t glob_res;
23 int ret = yaz_file_glob(tpath, &glob_res);
26 size_t n = yaz_file_glob_get_num(glob_res);
28 for (i = 0; i < n; i++)
30 yaz_log(YLOG_LOG, "match %s", yaz_file_glob_get_file(glob_res, i));
33 yaz_file_globfree(&glob_res);
38 yaz_glob_res_t glob_res;
40 WRBUF tpath = wrbuf_alloc();
41 const char *srcdir = getenv("srcdir");
45 wrbuf_puts(tpath, srcdir);
46 wrbuf_puts(tpath, "/");
48 wrbuf_puts(tpath, "Make*.am");
49 ret = yaz_file_glob(wrbuf_cstr(tpath), &glob_res);
52 YAZ_CHECK_EQ(1, yaz_file_glob_get_num(glob_res));
53 if (yaz_file_glob_get_num(glob_res) == 1)
55 const char *f = yaz_file_glob_get_file(glob_res, 0);
56 size_t l_match = strlen("Makefile.am");
57 YAZ_CHECK(f && strlen(f) >= l_match);
58 if (f && strlen(f) >= l_match)
60 YAZ_CHECK(!strcmp(f + strlen(f) - l_match, "Makefile.am"));
64 yaz_file_globfree(&glob_res);
67 int main (int argc, char **argv)
69 YAZ_CHECK_INIT(argc, argv);
71 tst_with_path(argv[1]);
79 * c-file-style: "Stroustrup"
80 * indent-tabs-mode: nil
82 * vim: shiftwidth=4 tabstop=8 expandtab