1 /* ndir.c - portable directory routines 2 Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 1, or (at your option) 7 any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. */ 13 14 /* Everything non trivial in this code is taken from: @(#)msd_dir.c 1.4 15 87/11/06. A public domain implementation of BSD directory routines 16 for MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), 17 August 1897 */ 18 19 #include <sys/types.h> /* ino_t definition */ 20 21 #define rewinddir(dirp) seekdir(dirp, 0L) 22 23 /* 255 is said to be big enough for Windows NT. The more elegant 24 solution would be declaring d_name as one byte long and allocating 25 it to the actual size needed. */ 26 #define MAXNAMLEN 255 27 28 struct direct 29 { 30 ino_t d_ino; /* a bit of a farce */ 31 int d_reclen; /* more farce */ 32 int d_namlen; /* length of d_name */ 33 char d_name[MAXNAMLEN + 1]; /* garentee null termination */ 34 }; 35 36 struct _dircontents 37 { 38 char *_d_entry; 39 struct _dircontents *_d_next; 40 }; 41 42 typedef struct _dirdesc 43 { 44 int dd_id; /* uniquely identify each open directory */ 45 long dd_loc; /* where we are in directory entry is this */ 46 struct _dircontents *dd_contents; /* pointer to contents of dir */ 47 struct _dircontents *dd_cp; /* pointer to current position */ 48 } DIR; 49 50 extern void seekdir (DIR *, long); 51 extern long telldir (DIR *); 52 extern DIR *opendir (const char *); 53 extern void closedir (DIR *); 54 extern struct direct *readdir (DIR *); 55 56 /* 57 * Local Variables: 58 * mode:C 59 * ChangeLog:ChangeLog 60 * compile-command:make 61 * End: 62 */ 63