home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / dirstuff.h < prev    next >
C/C++ Source or Header  |  1996-11-06  |  3KB  |  132 lines

  1. /*
  2.  *    dirstuff.h
  3.  *
  4.  *    Definitions to interface to unix-like DIRECTORY(3) procedures.
  5.  *    Include this after "estruct.h"
  6.  *
  7.  * $Header: /usr/build/vile/vile/RCS/dirstuff.h,v 1.23 1996/11/07 02:00:25 tom Exp $
  8.  *
  9.  */
  10.  
  11. #ifndef DIRSTUFF_H
  12. #define DIRSTUFF_H
  13.  
  14. #if ! SYS_VMS
  15.  
  16. #define USE_LS_FOR_DIRS 0
  17. #define OLD_STYLE_DIRS 0    /* e.g., pre-SysV.2 14-char names */
  18.  
  19. #if DIRNAMES_NOT_NULL_TERMINATED
  20. /* rumor has it that some early readdir implementations didn't null-terminate
  21.    the d_name array, and on those you _have_ to use d_namlen to get
  22.    the length.  most modern dirent structs are null-terminated, however. */
  23. #define USE_D_NAMLEN 1
  24. #endif
  25.  
  26. #if _POSIX_VERSION || HAVE_DIRENT_H || CC_TURBO || CC_WATCOM || CC_DJGPP || SYS_OS2
  27. # if CC_WATCOM || CC_CSETPP
  28. #   include <direct.h>
  29. # else
  30. #   include <dirent.h>
  31. # endif
  32. # define    DIRENT    struct dirent
  33. #else    /* apollo & other old bsd's */
  34. # define    DIRENT    struct direct
  35. # define USE_D_NAMLEN 1
  36. # if HAVE_SYS_NDIR_H
  37. #  include <sys/ndir.h>
  38. # else
  39. #  if HAVE_SYS_DIR_H
  40. #   include <sys/dir.h>
  41. #  else
  42. #   if HAVE_NDIR_H
  43. #    include <ndir.h>
  44. #   else
  45. #    if SYS_WINNT
  46. #     if CC_MSVC
  47. #      include <direct.h>
  48. #     else
  49. #      include <dirent.h>
  50. #     endif
  51. #     undef USE_D_NAMLEN
  52. #     define USE_D_NAMELEN 0
  53.       struct direct {
  54.     char *d_name;
  55.       };
  56.       struct _dirdesc {
  57.     HANDLE hFindFile;
  58.     WIN32_FIND_DATA ffd;
  59.     int first;
  60.     struct direct de;
  61.       };
  62.  
  63.       typedef struct _dirdesc DIR;
  64.  
  65. #    else /* SYS_WINNT */
  66. #     undef USE_LS_FOR_DIRS
  67. #     define USE_LS_FOR_DIRS 1
  68. #     undef USE_D_NAMLEN
  69. #     define USE_D_NAMELEN 1
  70. #    endif /* SYS_WINNT */
  71. #   endif
  72. #  endif
  73. # endif
  74. #endif
  75.  
  76. #else /* SYS_VMS */
  77.  
  78. #include    <rms.h>
  79. #include    <descrip.h>
  80.  
  81. #define USE_D_NAMLEN 1
  82.  
  83. typedef struct    {
  84.     ULONG    d_ino;
  85.     short    d_reclen;
  86.     short    d_namlen;
  87.     char    d_name[NAM$C_MAXRSS];        /* result: SYS$SEARCH */
  88.     } DIRENT;
  89.  
  90. typedef    struct    {
  91.     DIRENT        dd_ret;
  92.     struct    FAB    dd_fab;
  93.     struct    NAM    dd_nam;
  94.     char        dd_esa[NAM$C_MAXRSS];    /* expanded: SYS$PARSE */
  95.     } DIR;
  96.  
  97. #endif    /* SYS_VMS */
  98.  
  99. #if USE_LS_FOR_DIRS
  100. #define    DIR    FILE
  101. typedef    struct    {
  102.     char    d_name[NFILEN];
  103.     } DIRENT;
  104. #endif
  105.  
  106. #if SYS_WINNT && !CC_TURBO || SYS_VMS || USE_LS_FOR_DIRS
  107.     /* rename these, just in case there's a shared-library around */
  108. #define opendir  vile_opendir
  109. #define readdir  vile_readdir
  110. #define closedir vile_closedir
  111.  
  112. extern    DIR *    opendir ( char *path );
  113. extern    DIRENT *readdir ( DIR *dp );
  114. extern    int    closedir ( DIR *dp );
  115. #endif
  116.  
  117. #if OLD_STYLE_DIRS
  118.     this ifdef is untested
  119. #define USE_D_NAMLEN 1
  120. #define    DIR    FILE
  121. #define    DIRENT    struct direct
  122. #define    opendir(n)    fopen(n,"r")
  123. extern    DIRENT *readdir ( DIR *dp );
  124. #define    closedir(dp)    fclose(dp)
  125. #endif
  126.  
  127. #ifndef USE_D_NAMLEN
  128. #define USE_D_NAMLEN 0
  129. #endif
  130.  
  131. #endif /* DIRSTUFF_H */
  132.