xref: /openbsd/gnu/usr.bin/cvs/windows-NT/ndir.h (revision 2286d8ed)
11e72d8d2Sderaadt /*  ndir.c - portable directory routines
21e72d8d2Sderaadt     Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
31e72d8d2Sderaadt 
41e72d8d2Sderaadt     This program is free software; you can redistribute it and/or modify
51e72d8d2Sderaadt     it under the terms of the GNU General Public License as published by
61e72d8d2Sderaadt     the Free Software Foundation; either version 1, or (at your option)
71e72d8d2Sderaadt     any later version.
81e72d8d2Sderaadt 
91e72d8d2Sderaadt     This program is distributed in the hope that it will be useful,
101e72d8d2Sderaadt     but WITHOUT ANY WARRANTY; without even the implied warranty of
111e72d8d2Sderaadt     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*2286d8edStholo     GNU General Public License for more details.  */
131e72d8d2Sderaadt 
141e72d8d2Sderaadt /* Everything non trivial in this code is taken from: @(#)msd_dir.c 1.4
151e72d8d2Sderaadt    87/11/06.  A public domain implementation of BSD directory routines
161e72d8d2Sderaadt    for MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
171e72d8d2Sderaadt    August 1897 */
181e72d8d2Sderaadt 
191e72d8d2Sderaadt #include <sys/types.h>	/* ino_t definition */
201e72d8d2Sderaadt 
211e72d8d2Sderaadt #define	rewinddir(dirp)	seekdir(dirp, 0L)
221e72d8d2Sderaadt 
2313571821Stholo /* 255 is said to be big enough for Windows NT.  The more elegant
2413571821Stholo    solution would be declaring d_name as one byte long and allocating
2513571821Stholo    it to the actual size needed.  */
2613571821Stholo #define	MAXNAMLEN	255
271e72d8d2Sderaadt 
281e72d8d2Sderaadt struct direct
291e72d8d2Sderaadt {
301e72d8d2Sderaadt   ino_t d_ino;			/* a bit of a farce */
311e72d8d2Sderaadt   int d_reclen;			/* more farce */
321e72d8d2Sderaadt   int d_namlen;			/* length of d_name */
331e72d8d2Sderaadt   char d_name[MAXNAMLEN + 1];	/* garentee null termination */
341e72d8d2Sderaadt };
351e72d8d2Sderaadt 
361e72d8d2Sderaadt struct _dircontents
371e72d8d2Sderaadt {
381e72d8d2Sderaadt   char *_d_entry;
391e72d8d2Sderaadt   struct _dircontents *_d_next;
401e72d8d2Sderaadt };
411e72d8d2Sderaadt 
421e72d8d2Sderaadt typedef struct _dirdesc
431e72d8d2Sderaadt {
441e72d8d2Sderaadt   int dd_id;			/* uniquely identify each open directory */
451e72d8d2Sderaadt   long dd_loc;			/* where we are in directory entry is this */
461e72d8d2Sderaadt   struct _dircontents *dd_contents;	/* pointer to contents of dir */
471e72d8d2Sderaadt   struct _dircontents *dd_cp;	/* pointer to current position */
481e72d8d2Sderaadt } DIR;
491e72d8d2Sderaadt 
501e72d8d2Sderaadt extern void seekdir (DIR *, long);
511e72d8d2Sderaadt extern long telldir (DIR *);
521e72d8d2Sderaadt extern DIR *opendir (const char *);
531e72d8d2Sderaadt extern void closedir (DIR *);
541e72d8d2Sderaadt extern struct direct *readdir (DIR *);
551e72d8d2Sderaadt 
561e72d8d2Sderaadt /*
571e72d8d2Sderaadt  * Local Variables:
581e72d8d2Sderaadt  * mode:C
591e72d8d2Sderaadt  * ChangeLog:ChangeLog
601e72d8d2Sderaadt  * compile-command:make
611e72d8d2Sderaadt  * End:
621e72d8d2Sderaadt  */
63