2012-07-23 21:31:53 +00:00
|
|
|
/*
|
2021-04-19 01:15:19 +00:00
|
|
|
* Copyright (C) 1984-2021 Mark Nudelman
|
2012-07-23 21:31:53 +00:00
|
|
|
*
|
|
|
|
* You may distribute under the terms of either the GNU General Public
|
|
|
|
* License or the Less License, as specified in the README file.
|
|
|
|
*
|
|
|
|
* For more information, see the README file.
|
|
|
|
*/
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros to define the method of doing filename "globbing".
|
|
|
|
* There are three possible mechanisms:
|
2021-04-19 01:15:19 +00:00
|
|
|
* 1. GLOB_LIST
|
|
|
|
* This defines a function that returns a list of matching filenames.
|
2000-05-22 09:53:22 +00:00
|
|
|
* 2. GLOB_NAME
|
2021-04-19 01:15:19 +00:00
|
|
|
* This defines a function that steps thru the list of matching
|
|
|
|
* filenames, returning one name each time it is called.
|
2000-05-22 09:53:22 +00:00
|
|
|
* 3. GLOB_STRING
|
2021-04-19 01:15:19 +00:00
|
|
|
* This defines a function that returns the complete list of
|
|
|
|
* matching filenames as a single space-separated string.
|
2000-05-22 09:53:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if OS2
|
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define DECL_GLOB_LIST(list) char **list; char **pp;
|
|
|
|
#define GLOB_LIST(filename,list) list = _fnexplode(filename)
|
|
|
|
#define GLOB_LIST_FAILED(list) list == NULL
|
|
|
|
#define SCAN_GLOB_LIST(list,p) pp = list; *pp != NULL; pp++
|
|
|
|
#define INIT_GLOB_LIST(list,p) p = *pp
|
|
|
|
#define GLOB_LIST_DONE(list) _fnexplodefree(list)
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
#if MSDOS_COMPILER==DJGPPC
|
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define DECL_GLOB_LIST(list) glob_t list; int i;
|
|
|
|
#define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list)
|
|
|
|
#define GLOB_LIST_FAILED(list) 0
|
|
|
|
#define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++
|
|
|
|
#define INIT_GLOB_LIST(list,p) p = list.gl_pathv[i]
|
|
|
|
#define GLOB_LIST_DONE(list) globfree(&list)
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
|
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define GLOB_FIRST_NAME(filename,fndp,h) h = _dos_findfirst(filename, ~_A_VOLID, fndp)
|
|
|
|
#define GLOB_FIRST_FAILED(handle) ((handle) != 0)
|
|
|
|
#define GLOB_NEXT_NAME(handle,fndp) _dos_findnext(fndp)
|
|
|
|
#define GLOB_NAME_DONE(handle)
|
|
|
|
#define GLOB_NAME name
|
|
|
|
#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
|
|
|
|
struct find_t fnd; \
|
|
|
|
char drive[_MAX_DRIVE]; \
|
|
|
|
char dir[_MAX_DIR]; \
|
|
|
|
char fname[_MAX_FNAME]; \
|
|
|
|
char ext[_MAX_EXT]; \
|
|
|
|
int handle;
|
2000-05-22 09:53:22 +00:00
|
|
|
#else
|
2019-06-29 04:39:01 +00:00
|
|
|
#if MSDOS_COMPILER==WIN32C && (defined(_MSC_VER) || defined(MINGW))
|
2000-05-22 09:53:22 +00:00
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp)
|
|
|
|
#define GLOB_FIRST_FAILED(handle) ((handle) == -1)
|
|
|
|
#define GLOB_NEXT_NAME(handle,fndp) _findnext(handle, fndp)
|
|
|
|
#define GLOB_NAME_DONE(handle) _findclose(handle)
|
|
|
|
#define GLOB_NAME name
|
|
|
|
#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
|
|
|
|
struct _finddata_t fnd; \
|
|
|
|
char drive[_MAX_DRIVE]; \
|
|
|
|
char dir[_MAX_DIR]; \
|
|
|
|
char fname[_MAX_FNAME]; \
|
|
|
|
char ext[_MAX_EXT]; \
|
|
|
|
intptr_t handle;
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */
|
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL)
|
|
|
|
#define GLOB_FIRST_FAILED(handle) ((handle) != 0)
|
|
|
|
#define GLOB_NEXT_NAME(handle,fndp) findnext(fndp)
|
|
|
|
#define GLOB_NAME_DONE(handle)
|
|
|
|
#define GLOB_NAME ff_name
|
|
|
|
#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
|
|
|
|
struct ffblk fnd; \
|
|
|
|
char drive[MAXDRIVE]; \
|
|
|
|
char dir[MAXDIR]; \
|
|
|
|
char fname[MAXFILE]; \
|
|
|
|
char ext[MAXEXT]; \
|
|
|
|
int handle;
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|