2 * Copyright (C) 1984-2007 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 about less, or for information on how to
8 * contact the author, see the README file.
13 * Macros to define the method of doing filename "globbing".
14 * There are three possible mechanisms:
16 * This defines a function that returns a list of matching filenames.
18 * This defines a function that steps thru the list of matching
19 * filenames, returning one name each time it is called.
21 * This defines a function that returns the complete list of
22 * matching filenames as a single space-separated string.
27 #define DECL_GLOB_LIST(list) char **list; char **pp;
28 #define GLOB_LIST(filename,list) list = _fnexplode(filename)
29 #define GLOB_LIST_FAILED(list) list == NULL
30 #define SCAN_GLOB_LIST(list,p) pp = list; *pp != NULL; pp++
31 #define INIT_GLOB_LIST(list,p) p = *pp
32 #define GLOB_LIST_DONE(list) _fnexplodefree(list)
35 #if MSDOS_COMPILER==DJGPPC
37 #define DECL_GLOB_LIST(list) glob_t list; int i;
38 #define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list)
39 #define GLOB_LIST_FAILED(list) 0
40 #define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++
41 #define INIT_GLOB_LIST(list,p) p = list.gl_pathv[i]
42 #define GLOB_LIST_DONE(list) globfree(&list)
45 #if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
47 #define GLOB_FIRST_NAME(filename,fndp,h) h = _dos_findfirst(filename, ~_A_VOLID, fndp)
48 #define GLOB_FIRST_FAILED(handle) ((handle) != 0)
49 #define GLOB_NEXT_NAME(handle,fndp) _dos_findnext(fndp)
50 #define GLOB_NAME_DONE(handle)
51 #define GLOB_NAME name
52 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
54 char drive[_MAX_DRIVE]; \
56 char fname[_MAX_FNAME]; \
60 #if MSDOS_COMPILER==WIN32C && defined(_MSC_VER)
62 #define GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp)
63 #define GLOB_FIRST_FAILED(handle) ((handle) == -1)
64 #define GLOB_NEXT_NAME(handle,fndp) _findnext(handle, fndp)
65 #define GLOB_NAME_DONE(handle) _findclose(handle)
66 #define GLOB_NAME name
67 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
68 struct _finddata_t fnd; \
69 char drive[_MAX_DRIVE]; \
71 char fname[_MAX_FNAME]; \
76 #if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */
78 #define GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL)
79 #define GLOB_FIRST_FAILED(handle) ((handle) != 0)
80 #define GLOB_NEXT_NAME(handle,fndp) findnext(fndp)
81 #define GLOB_NAME_DONE(handle)
82 #define GLOB_NAME ff_name
83 #define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
85 char drive[MAXDRIVE]; \
87 char fname[MAXFILE]; \