home *** CD-ROM | disk | FTP | other *** search
/ ftp.freefriends.org / ftp.freefriends.org.tar / ftp.freefriends.org / arnold / Source / mush.rstevens.tar.gz / mush.tar / glob.h < prev    next >
C/C++ Source or Header  |  1990-05-23  |  2KB  |  77 lines

  1. #ifdef BSD
  2. #define DIRECTORY
  3. #endif /* BSD */
  4.  
  5. #ifdef DIRECTORY
  6. #ifdef SYSV /* Some SysV 3.0 or higher */
  7. #include <dirent.h>
  8. #else /* SYSV */
  9. #include <sys/dir.h>
  10. #define dirent direct
  11. #endif
  12. #else /* !DIRECTORY */
  13.  
  14. /*
  15.  *  4.2BSD directory access emulation for non-4.2 systems.
  16.  *  Based upon routines in appendix D of Portable C and Unix System
  17.  *  Programming by J. E. Lapin (Rabbit Software).
  18.  *
  19.  *  No responsibility is taken for any error in accuracies inherent
  20.  *  either to the comments or the code of this program, but if
  21.  *  reported to me then an attempt will be made to fix them.
  22.  */
  23.  
  24. #ifndef  DEV_BSIZE
  25. #define  DEV_BSIZE  512           /* Device block size. */
  26. #endif
  27.  
  28. #define  DIRBLKSIZ  DEV_BSIZE
  29. #define  MAXNAMLEN  255           /* Name must be no longer than this. */
  30.  
  31. struct dirent
  32. {
  33.   long  d_fileno ;                /* Inode number of entry. */
  34.   short d_reclen ;                /* Length of this record. */
  35.   short d_namlen ;                /* Length of d_name string. */
  36.   char  d_name[MAXNAMLEN + 1] ;   /* Directory name. */
  37. } ;
  38.  
  39. /*  The DIRSIZ macro gives the minimum record length that will hold the
  40.  *  directory entry. This requires the amount of space in struct direct
  41.  *  without the d_name field, plus enough space for the name with a
  42.  *  terminating null byte (dp->d_namlen+1), rounded up to a 4 byte
  43.  *  boundary.
  44.  */
  45.  
  46. #undef   DIRSIZ
  47. #define  DIRSIZ(dp)                                \
  48.          ((sizeof (struct dirent) - (MAXNAMLEN+1)) \
  49.          + (((dp)->d_namlen+1 + 3) &~ 3))
  50.  
  51. /*  Definitions for library routines operating on directories. */
  52.  
  53. typedef struct _dirdesc
  54. {
  55.   int    dd_fd ;
  56.   long   dd_loc ;
  57.   long   dd_size ;
  58.   char   dd_buf[DIRBLKSIZ] ;
  59. } DIR ;
  60.  
  61. #ifndef  NULL
  62. #define  NULL  0
  63. #endif
  64.  
  65. extern  DIR              *opendir() ;
  66. extern  struct dirent    *readdir() ;
  67. extern  long             telldir() ;
  68. extern  void             seekdir() ;
  69. #define rewinddir(dirp)  seekdir((dirp), (long) 0)
  70. extern  void             closedir() ;
  71.  
  72. #endif /* DIRECTORY */
  73.  
  74. #define DELIM " \t;|"
  75. #define META "/?*[{"
  76. #define FMETA "?*[{"
  77.