home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / h / filepat.h < prev    next >
C/C++ Source or Header  |  2001-12-12  |  2KB  |  78 lines

  1. /*
  2.  * Typedefs and macros for filename wildcard expansion on some systems.
  3.  *  The definitions provided here are:
  4.  *
  5.  *    typedef ... FINDFILE_T;
  6.  *    // Current state of the filename wildcard expansion
  7.  *
  8.  *    int FINDFIRST ( char *pattern, FINDFILE_T *pfd );
  9.  *    // Initializes *pfd and returns 1 if a file is found that matches the
  10.  *    // pattern, 0 otherwise
  11.  *
  12.  *    int FINDNEXT ( FINDFILE_T *pfd );
  13.  *    // Assuming that the last FINDFIRST/FINDNEXT call was successful,
  14.  *    // updates *pfd and returns whether another match can be made.
  15.  *
  16.  *    char *FILENAME ( FINDFILE_T *pfd );
  17.  *    // Assuming that the last FINDFIRST/FINDNEXT call was successful,
  18.  *    // returns pointer to last found file name.
  19.  *
  20.  *    void FINDCLOSE ( FINDFILE_T *pfd );
  21.  *    // Does any cleanup required after doing filenaame wildcard expansion.
  22.  *
  23.  * Also, the macro WildCards will be defined to be 1 if there is file
  24.  * pattern matching is supported, 0 otherwise.  If !WildCards, then a
  25.  * default set of typedef/macros will be provided that will return only one
  26.  * match, the original pattern.
  27.  */
  28.  
  29. #if WildCards
  30.  
  31. #if NT
  32.  
  33. #include <io.h>
  34.  
  35. typedef struct _FINDFILE_TAG {
  36.    long            handle;
  37.    struct _finddata_t    fileinfo;
  38.    } FINDDATA_T;
  39.  
  40. #define FINDFIRST(pattern, pfd)    \
  41.    ( ( (pfd)->handle = _findfirst ( (pattern), &(pfd)->fileinfo ) ) != -1L )
  42. #define FINDNEXT(pfd) ( _findnext ( (pfd)->handle, &(pfd)->fileinfo ) != -1 )
  43. #define FILENAME(pfd)    ( (pfd)->fileinfo.name )
  44. #define FINDCLOSE(pfd)    _findclose( (pfd)->handle )
  45.  
  46. #endif                    /* NT */
  47.  
  48. #if BORLAND_286 || BORLAND_386
  49.  
  50. #include <dos.h>
  51.  
  52. typedef struct ffblk FINDDATA_T;
  53.  
  54. #define FINDFIRST(pattern, pfd)    ( !findfirst ( (pattern), (pfd), FA_NORMAL ) )
  55. #define FINDNEXT(pfd)    ( !findnext ( (pfd) ) )
  56. #define FILENAME(pfd)    ( (pfd)->ff_name )
  57. #define FINDCLOSE(pfd)    ( (void) 0 )
  58.  
  59. #endif                        /* BORLAND_286 || BORLAND_386 */
  60.  
  61. #if MICROSOFT || SCCX_MX
  62.  
  63. #include <dos.h>
  64.  
  65. typedef struct _find_t FINDDATA_T;
  66.  
  67. #define FINDFIRST(pattern, pfd)    (!_dos_findfirst ((pattern), _A_NORMAL, (pfd)))
  68. #define FINDNEXT(pfd)    ( !_dos_findnext ( (pfd) ) )
  69. #define FILENAME(pfd)    ( (pfd)->name )
  70. #define FINDCLOSE(pfd)    ( (void) 0 )
  71.  
  72. #endif                    /* MICROSOFT || SCCX_MX */
  73.  
  74. #if PORT
  75. Deliberate Syntax Error                 /* Give it some thought */
  76. #endif                                  /* PORT */
  77. #endif                    /* WildCards */
  78.