home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / c / debug / mnemosyn.spk / !Mnemosyne / sys / H / Dir next >
Text File  |  1991-04-24  |  1KB  |  48 lines

  1. /* H.Dir: Directory handling */
  2.  
  3. #ifndef __sys_dir
  4. #define __sys_dir
  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.         long    dd_loc;
  23.         char    dd_name[1];
  24. }
  25. DIR;
  26.  
  27. /* K&R equivalent definitions */
  28.  
  29. #ifdef PCC
  30.  
  31. extern DIR *opendir();
  32. extern struct direct *readdir();
  33. extern void closedir();
  34.  
  35. #else
  36.  
  37. extern DIR *opendir (char *name);
  38. extern struct direct *readdir (DIR *dirp);
  39. extern void closedir (DIR *dirp);
  40.  
  41. #endif
  42.  
  43. #define seekdir(dirp,pos)       ((dirp)->dd_loc = (pos))
  44. #define telldir(dirp)           ((dirp)->dd_loc)
  45. #define rewinddir(dirp)         ((dirp)->dd_loc = 0)
  46.  
  47. #endif
  48.