160786Sps/* 2240121Sdelphij * Copyright (C) 1984-2012 Mark Nudelman 360786Sps * 460786Sps * You may distribute under the terms of either the GNU General Public 560786Sps * License or the Less License, as specified in the README file. 660786Sps * 7240121Sdelphij * For more information, see the README file. 860786Sps */ 960786Sps 1060786Sps 1160786Sps/* 1260786Sps * Macros to define the method of doing filename "globbing". 1360786Sps * There are three possible mechanisms: 1460786Sps * 1. GLOB_LIST 1560786Sps * This defines a function that returns a list of matching filenames. 1660786Sps * 2. GLOB_NAME 1760786Sps * This defines a function that steps thru the list of matching 1860786Sps * filenames, returning one name each time it is called. 1960786Sps * 3. GLOB_STRING 2060786Sps * This defines a function that returns the complete list of 2160786Sps * matching filenames as a single space-separated string. 2260786Sps */ 2360786Sps 2460786Sps#if OS2 2560786Sps 2660786Sps#define DECL_GLOB_LIST(list) char **list; char **pp; 2760786Sps#define GLOB_LIST(filename,list) list = _fnexplode(filename) 2860786Sps#define GLOB_LIST_FAILED(list) list == NULL 2960786Sps#define SCAN_GLOB_LIST(list,p) pp = list; *pp != NULL; pp++ 3060786Sps#define INIT_GLOB_LIST(list,p) p = *pp 3160786Sps#define GLOB_LIST_DONE(list) _fnexplodefree(list) 3260786Sps 3360786Sps#else 3460786Sps#if MSDOS_COMPILER==DJGPPC 3560786Sps 3660786Sps#define DECL_GLOB_LIST(list) glob_t list; int i; 3760786Sps#define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list) 3860786Sps#define GLOB_LIST_FAILED(list) 0 3960786Sps#define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++ 4060786Sps#define INIT_GLOB_LIST(list,p) p = list.gl_pathv[i] 4160786Sps#define GLOB_LIST_DONE(list) globfree(&list) 4260786Sps 4360786Sps#else 4460786Sps#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC 4560786Sps 4660786Sps#define GLOB_FIRST_NAME(filename,fndp,h) h = _dos_findfirst(filename, ~_A_VOLID, fndp) 4760786Sps#define GLOB_FIRST_FAILED(handle) ((handle) != 0) 4860786Sps#define GLOB_NEXT_NAME(handle,fndp) _dos_findnext(fndp) 4960786Sps#define GLOB_NAME_DONE(handle) 5060786Sps#define GLOB_NAME name 5160786Sps#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \ 5260786Sps struct find_t fnd; \ 5360786Sps char drive[_MAX_DRIVE]; \ 5460786Sps char dir[_MAX_DIR]; \ 5560786Sps char fname[_MAX_FNAME]; \ 5660786Sps char ext[_MAX_EXT]; \ 5760786Sps int handle; 5860786Sps#else 5960786Sps#if MSDOS_COMPILER==WIN32C && defined(_MSC_VER) 6060786Sps 6160786Sps#define GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp) 6260786Sps#define GLOB_FIRST_FAILED(handle) ((handle) == -1) 6360786Sps#define GLOB_NEXT_NAME(handle,fndp) _findnext(handle, fndp) 6460786Sps#define GLOB_NAME_DONE(handle) _findclose(handle) 6560786Sps#define GLOB_NAME name 6660786Sps#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \ 6760786Sps struct _finddata_t fnd; \ 6860786Sps char drive[_MAX_DRIVE]; \ 6960786Sps char dir[_MAX_DIR]; \ 7060786Sps char fname[_MAX_FNAME]; \ 7160786Sps char ext[_MAX_EXT]; \ 7260786Sps long handle; 7360786Sps 7460786Sps#else 7560786Sps#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */ 7660786Sps 7760786Sps#define GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL) 7860786Sps#define GLOB_FIRST_FAILED(handle) ((handle) != 0) 7960786Sps#define GLOB_NEXT_NAME(handle,fndp) findnext(fndp) 8060786Sps#define GLOB_NAME_DONE(handle) 8160786Sps#define GLOB_NAME ff_name 8260786Sps#define DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \ 8360786Sps struct ffblk fnd; \ 8460786Sps char drive[MAXDRIVE]; \ 8560786Sps char dir[MAXDIR]; \ 8660786Sps char fname[MAXFILE]; \ 8760786Sps char ext[MAXEXT]; \ 8860786Sps int handle; 8960786Sps 9060786Sps#endif 9160786Sps#endif 9260786Sps#endif 9360786Sps#endif 9460786Sps#endif 95