home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / trn / part13 / ndir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-22  |  1.6 KB  |  66 lines

  1. /* $Header: ndir.h,v 4.3.3.1 91/01/16 03:18:04 davison Trn $
  2.  *
  3.  * $Log:    ndir.h,v $
  4.  * Revision 4.3.3.1  91/01/16  03:18:04  davison
  5.  * Added optional prototyping.
  6.  * 
  7.  * Revision 4.3.2.1  90/04/17  15:28:13  sob
  8.  * Altered to include correct directory include file.
  9.  * 
  10.  * Revision 4.3  85/05/01  11:43:00  lwall
  11.  * Baseline for release with 4.3bsd.
  12.  * 
  13.  */
  14.  
  15. #ifdef LIBNDIR
  16. #   include <ndir.h>
  17. #else
  18. #   ifndef USENDIR
  19. #    include DIRINC
  20. #   else
  21.  
  22. #ifndef DEV_BSIZE
  23. #define    DEV_BSIZE    512
  24. #endif
  25. #define DIRBLKSIZ    DEV_BSIZE
  26. #define    MAXNAMLEN    255
  27.  
  28. struct    direct {
  29.     long    d_ino;            /* inode number of entry */
  30.     short    d_reclen;        /* length of this record */
  31.     short    d_namlen;        /* length of string in d_name */
  32.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  33. };
  34.  
  35. /*
  36.  * The DIRSIZ macro gives the minimum record length which will hold
  37.  * the directory entry.  This requires the amount of space in struct direct
  38.  * without the d_name field, plus enough space for the name with a terminating
  39.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  40.  */
  41. #undef DIRSIZ
  42. #define DIRSIZ(dp) \
  43.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  44.  
  45. /*
  46.  * Definitions for library routines operating on directories.
  47.  */
  48. typedef struct _dirdesc {
  49.     int    dd_fd;
  50.     long    dd_loc;
  51.     long    dd_size;
  52.     char    dd_buf[DIRBLKSIZ];
  53. } DIR;
  54. #ifndef NULL
  55. #define NULL 0
  56. #endif
  57. extern    DIR *opendir ANSI((char *));
  58. extern    struct direct *readdir ANSI((DIR *));
  59. extern    long telldir ANSI((DIR *));
  60. extern    void seekdir ANSI((DIR *));
  61. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  62. extern    void closedir ANSI((DIR *));
  63.  
  64. #   endif
  65. #endif
  66.