home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / editor / man / src / include / sys / dirent.h next >
Encoding:
C/C++ Source or Header  |  1993-12-01  |  1.5 KB  |  53 lines

  1. /* <sys/dirent.h> -- file system independent directory entry (SVR3) */
  2. #ifndef _SYS_DIRENT_H
  3. #define _SYS_DIRENT_H
  4.  
  5. #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__)
  6. #  if defined (OS2) || defined (__OS2__)
  7. #    define MAXNAMLEN    255    /* maximum filename length        */
  8. #  else
  9. #    define MAXNAMLEN    13    /* maximum filename length        */
  10. #  endif
  11. #else
  12. #define    MAXNAMLEN    512    /* maximum filename length        */
  13. #endif
  14.  
  15. #ifndef NAME_MAX
  16. #define    NAME_MAX    (MAXNAMLEN - 1)
  17. #endif
  18.  
  19. struct dirent            /* data from getdents()/readdir()    */
  20. {
  21.     ino_t    d_ino;        /* inode number of entry        */
  22.     off_t    d_off;        /* offset of disk directory entry    */
  23.     ushort    d_reclen;    /* length of this record        */
  24. #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__)
  25.     char    d_name[MAXNAMLEN + 1];
  26. #else
  27.     char    d_name[1];    /* name of file                */
  28. #endif
  29. };
  30.  
  31. #ifdef BSD_SYSV            /* (e.g., when compiling getdents.c)    */
  32. extern struct dirent    __dirent;    /* (not actually used) */
  33.  
  34.                 /* The following is portable, although    */
  35.                 /* rather silly.            */
  36. #define    DIRENTBASESIZ        (__dirent.d_name - (char *)&__dirent.d_ino)
  37.  
  38. #else
  39.  
  40. /* The following nonportable ugliness could have been avoided by defining
  41.  * DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments.
  42.  * There shouldn't be any problem if you avoid using the DIRENTSIZ() macro.
  43.  */
  44.  
  45. #define    DIRENTBASESIZ        (((struct dirent *)0)->d_name \
  46.                 - (char *)&((struct dirent *)0)->d_ino)
  47. #endif
  48.  
  49. #define    DIRENTSIZ(namlen)    ((DIRENTBASESIZ + sizeof(long) + (namlen)) \
  50.                 / sizeof(long) * sizeof(long))
  51.  
  52. #endif
  53.