home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / trn / part02 / ndir.h.SH < prev    next >
Encoding:
Text File  |  1991-12-02  |  2.2 KB  |  84 lines

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