|
YAZ 5.35.1
|
File globbing (ala POSIX glob, but simpler) More...
#include <sys/types.h>#include <sys/stat.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <assert.h>#include <yaz/wrbuf.h>#include <yaz/tpath.h>#include <yaz/log.h>#include <yaz/dirent.h>#include <yaz/nmem.h>#include <yaz/file_glob.h>#include <yaz/match_glob.h>Go to the source code of this file.
Data Structures | |
| struct | res_entry |
| struct | glob_res |
Functions | |
| static void | add_entry (yaz_glob_res_t res, const char *str) |
| static void | glob_r (yaz_glob_res_t res, const char *pattern, size_t off, char *prefix) |
| static int | cmp_entry (const void *a, const void *b) |
| static void | sort_them (yaz_glob_res_t res) |
| int | yaz_file_glob (const char *pattern, yaz_glob_res_t *res) |
| perform glob | |
| int | yaz_file_glob2 (const char *pattern, yaz_glob_res_t *res, unsigned flags) |
| perform glob (with flags) | |
| void | yaz_file_globfree (yaz_glob_res_t *res) |
| release glob result | |
| const char * | yaz_file_glob_get_file (yaz_glob_res_t res, size_t idx) |
| return resulting matching file | |
| size_t | yaz_file_glob_get_num (yaz_glob_res_t res) |
| return number of matching files | |
File globbing (ala POSIX glob, but simpler)
Definition in file file_glob.c.
|
static |
Definition at line 40 of file file_glob.c.
References res_entry::file, glob_res::last_entry, res_entry::next, glob_res::nmem, nmem_malloc(), nmem_strdup(), and glob_res::number_of_entries.
Referenced by glob_r().
|
static |
|
static |
Definition at line 51 of file file_glob.c.
References add_entry(), glob_res::flags, glob_r(), YAZ_FILE_GLOB_FAIL_NOTEXIST, and yaz_match_glob().
Referenced by glob_r(), and yaz_file_glob2().
|
static |
Definition at line 120 of file file_glob.c.
References cmp_entry(), glob_res::entries, res_entry::next, glob_res::nmem, nmem_malloc(), and glob_res::number_of_entries.
Referenced by yaz_file_glob2().
| int yaz_file_glob | ( | const char * | pattern, |
| yaz_glob_res_t * | res | ||
| ) |
perform glob
| pattern | glob pattern file spec |
| res | returned glob result |
| 0 | OK |
| -1 | ERROR |
Definition at line 141 of file file_glob.c.
References yaz_file_glob2().
| int yaz_file_glob2 | ( | const char * | pattern, |
| yaz_glob_res_t * | res, | ||
| unsigned | flags | ||
| ) |
perform glob (with flags)
| pattern | glob pattern file spec |
| res | returned glob result |
| flags | YAZ_FILE_GLOB_.. flags |
| 0 | OK |
| -1 | ERROR |
Definition at line 146 of file file_glob.c.
References glob_r(), nmem_create(), nmem_malloc(), and sort_them().
Referenced by config_include_src(), and yaz_file_glob().
| const char * yaz_file_glob_get_file | ( | yaz_glob_res_t | res, |
| size_t | idx | ||
| ) |
return resulting matching file
| res | glob result |
| idx | index 0=first, .. N-1 (where N is yaz_file_glob_get_num) |
Definition at line 173 of file file_glob.c.
References glob_res::entries, res_entry::file, and res_entry::next.
Referenced by config_include_src().
| size_t yaz_file_glob_get_num | ( | yaz_glob_res_t | res | ) |
return number of matching files
| res | glob result |
Definition at line 186 of file file_glob.c.
References glob_res::number_of_entries.
| void yaz_file_globfree | ( | yaz_glob_res_t * | res | ) |
release glob result
| res | pointer to glob result |
A value of *res == NULL is allowed. If *res != NULL, then res is set to NULL
Definition at line 163 of file file_glob.c.
References nmem_destroy().
Referenced by config_include_src().