home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / mthreads / part01 / ndir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-20  |  2.0 KB  |  77 lines

  1. /* $Id: ndir.h,v 3.0 1991/09/09 20:23:31 davison Trn $
  2.  */
  3. /* This software is Copyright 1991 by Stan Barber. 
  4.  *
  5.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  6.  * use this software as long as: there is no monetary profit gained
  7.  * specifically from the use or reproduction of this software, it is not
  8.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  9.  * included prominently in any copy made. 
  10.  *
  11.  * The authors make no claims as to the fitness or correctness of this software
  12.  * for any use whatsoever, and it is provided as is. Any use of this software
  13.  * is at the user's own risk. 
  14.  */
  15.  
  16. #ifdef I_NDIR
  17. #include <ndir.h>
  18. #else
  19. #ifdef I_DIRENT
  20. #include <dirent.h>
  21. #ifndef direct
  22. #define direct dirent
  23. #endif
  24. #else
  25. #ifdef I_SYS_NDIR
  26. #include <sys/ndir.h>
  27. #else
  28. #ifdef I_SYS_DIR
  29. #include <sys/dir.h>
  30. #else
  31.  
  32. #ifndef DEV_BSIZE
  33. #define    DEV_BSIZE    512
  34. #endif
  35. #define DIRBLKSIZ    DEV_BSIZE
  36. #define    MAXNAMLEN    255
  37.  
  38. struct    direct {
  39.     long    d_ino;            /* inode number of entry */
  40.     short    d_reclen;        /* length of this record */
  41.     short    d_namlen;        /* length of string in d_name */
  42.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  43. };
  44.  
  45. /*
  46.  * The DIRSIZ macro gives the minimum record length which will hold
  47.  * the directory entry.  This requires the amount of space in struct direct
  48.  * without the d_name field, plus enough space for the name with a terminating
  49.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  50.  */
  51. #undef DIRSIZ
  52. #define DIRSIZ(dp)     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  53.  
  54. /*
  55.  * Definitions for library routines operating on directories.
  56.  */
  57. typedef struct _dirdesc {
  58.     int    dd_fd;
  59.     long    dd_loc;
  60.     long    dd_size;
  61.     char    dd_buf[DIRBLKSIZ];
  62. } DIR;
  63. #ifndef NULL
  64. #define NULL 0
  65. #endif
  66. extern    DIR *opendir _((char*));
  67. extern    struct direct *readdir _((DIR*));
  68. extern    long telldir _((DIR*));
  69. extern    void seekdir _((DIR*));
  70. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  71. extern    void closedir _((DIR*));
  72.  
  73. #endif
  74. #endif
  75. #endif
  76. #endif
  77.