/* -> h.dir
 *      Cosmos Nicolaou 14/6/87
 *
 *      4.2 BSD style directory operations.
 *      
 */

/*
 * osgbpb with r0==9 is used to read directory names;
 * the data returned is copied into a struct dirent.
 */
#define        MAXNAMLEN       255

struct dirent {
       unsigned int d_reclen;               /* length of this record */
       unsigned int d_namlen;               /* length of string in d_name */
       char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */
};

/*
 * This macro calculates the amount of storage required for
 * the directory entry.
 */
#undef DIRSIZ
#define DIRSIZ(dp) \
    ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))

/*
 * Definitions for library routines operating on directories.
 */
typedef struct _dirdesc {
       long    dd_pos; /* current position in directory. */
       struct dirent *dd_dirent;
       char    dd_name[MAXNAMLEN+1]; /* osgbpb needs a name */
       char    dd_buf[MAXNAMLEN+1]; /* osgbpb needs a buffer */
} DIR;

extern DIR *opendir( char * );
extern struct dirent *readdir( DIR * );
extern long telldir( DIR * );
extern void seekdir( DIR *, long );
#define rewinddir(dirp)        seekdir((dirp), (long)0)
extern void closedir( DIR *);
