2 * Copyright (C) 1984-2015 Mark Nudelman
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
7 * For more information, see the README file.
12 * Macros to define the method of doing filename "globbing".
13 * There are three possible mechanisms:
15 * This defines a function that returns a list of matching filenames.
17 * This defines a function that steps thru the list of matching
18 * filenames, returning one name each time it is called.
20 * This defines a function that returns the complete list of
21 * matching filenames as a single space-separated string.
26 #define DECL_GLOB_LIST(list) char **list; char **pp;
27 #define GLOB_LIST(filename,list) list = _fnexplode(filename)
28 #define GLOB_LIST_FAILED(list) list == NULL
29 #define SCAN_GLOB_LIST(list,p) pp = list; *pp != NULL; pp++
30 #define INIT_GLOB_LIST(list,p) p = *pp
31 #define GLOB_LIST_DONE(list) _fnexplodefree(list)
34 #if MSDOS_COMPILER==DJGPPC
36 #define DECL_GLOB_LIST(list) glob_t list; int i;
37 #define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list)
38 #define GLOB_LIST_FAILED(list) 0
39 #define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++
40 #define INIT_GLOB_LIST(list,p) p = list.gl_pathv[i]
41 #define GLOB_LIST_DONE(list) globfree(&list)
44 #if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
46 #define GLOB_FIRST_NAME(filename,fndp,h) h = _dos_findfirst(filename, ~_A_VOLID, fndp)
47 #define GLOB_FIRST_FAILED(handle) ((handle) != 0)
48 #define GLOB_NEXT_NAME(handle,fndp) _dos_findnext(fndp)
49 #define GLOB_NAME_DONE(handle)
50 #define GLOB_NAME name
51 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
53 char drive[_MAX_DRIVE]; \
55 char fname[_MAX_FNAME]; \
59 #if MSDOS_COMPILER==WIN32C && defined(_MSC_VER)
61 #define GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp)
62 #define GLOB_FIRST_FAILED(handle) ((handle) == -1)
63 #define GLOB_NEXT_NAME(handle,fndp) _findnext(handle, fndp)
64 #define GLOB_NAME_DONE(handle) _findclose(handle)
65 #define GLOB_NAME name
66 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
67 struct _finddata_t fnd; \
68 char drive[_MAX_DRIVE]; \
70 char fname[_MAX_FNAME]; \
75 #if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */
77 #define GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL)
78 #define GLOB_FIRST_FAILED(handle) ((handle) != 0)
79 #define GLOB_NEXT_NAME(handle,fndp) findnext(fndp)
80 #define GLOB_NAME_DONE(handle)
81 #define GLOB_NAME ff_name
82 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
84 char drive[MAXDRIVE]; \
86 char fname[MAXFILE]; \