home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / cutils / Sys / H / Dir next >
Encoding:
Text File  |  1991-10-20  |  1.2 KB  |  52 lines

  1. /* H.Dir: Directory handling */
  2.  
  3. #ifndef __sys_dir_h
  4. #define __sys_dir_h
  5.  
  6. #define MAXNAMELEN      10      /* Name must be no longer than this */
  7.  
  8. struct direct
  9. {
  10.         long    d_ino;                  /* inode number of entry */
  11.         short   d_reclen;               /* length of this record */
  12.         short   d_namlen;               /* length of d_name string */
  13.         char    d_name[MAXNAMELEN + 1]; /* directory name */
  14. };
  15.  
  16. #define DIRSIZ(dp) \
  17.                 ((sizeof (struct direct) - (MAXNAMELEN+1)) \
  18.                 + (((dp)->d_namlen+1 + 3) & ~3))
  19.  
  20. typedef struct
  21. {
  22.     int    dd_pos;            /* current directory entry */
  23.     int    dd_num;            /* number of directory entries */
  24.         char    *dd_loc;        /* current position in the cache */
  25.         char    *dd_cache;        /* cache of directory names */
  26. }
  27. DIR;
  28.  
  29. #ifdef __STDC__
  30.  
  31. extern DIR *opendir (char *name);
  32. extern struct direct *readdir (DIR *dirp);
  33. extern void closedir (DIR *dirp);
  34. extern int seekdir (DIR *dirp, int pos);
  35.  
  36. #else
  37.  
  38. extern DIR *opendir();
  39. extern struct direct *readdir();
  40. extern void closedir();
  41. extern int seekdir();
  42.  
  43. #endif
  44.  
  45. #define telldir(dirp) \
  46.     ((dirp)->dd_pos)
  47.  
  48. #define rewinddir(dirp)    \
  49.     (void)((dirp)->dd_pos = 0, (dirp)->dd_loc = (dirp)->dd_cache)
  50.  
  51. #endif
  52.