erict@flatline.UUCP (Lemmy Caution) (03/09/89)
AAUUUUUGGGGH.. What's dirent.h, and is there a pd package that does whatever dirent.h is supposed to help do? Is this something that can be fixed with 3.51 OS+DEV? Grr. -- J. Eric Townsend | "Texas: It's like another country, uunet!sugar!flatline!erict | but a lot closer." Texas TV travel ad. bellcore!texbell!/ 511 Parker #2 |EastEnders Mailing List: BITNET: cosc5fa@uhnix1.BITNET Houston,Tx,77007 |eastender@flatline.UUCP
dsueme@chinet.chi.il.us (dave sueme) (03/10/89)
I am having the dirent.h probelm (with smail) with 3.51(a) and 3.51 dev set.
ditto@cbmvax.UUCP (Michael "Ford" Ditto) (03/11/89)
A few people have asked about <dirent.h>. This is the header file used by programs using the directory(3) directory-reading package. These routines come with SVR3, but for us Unix PC (SVR2) users, there are a few ways to get a package that works. Possibly the best thing to do is to get Doug Gwyn's complete portable directory(3) implementation. It has been posted in various news groups and should be easy to find. What I did is to use the one I wrote a long time ago. It is very simple, and supports opendir, readdir, rewinddir, and closedir (but not seekdir). It only works on "normal" (i.e. fixed-length-directory-entry) file systems, such as those in SVR2. You might want to delete the last two lines in my "dirent.h" - they allow programs to use the 4BSD name for struct dirent, but the #define is a bit dangerous. Just "make directory.o" and either install it as /usr/lib/libndir.a or, if you really trust it, ar it into /lib/libc.a. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # directory.c # dirent.h # This archive created: Fri Mar 10 18:59:47 1989 export PATH; PATH=/bin:$PATH echo shar: extracting "'directory.c'" '(1458 characters)' if test -f 'directory.c' then echo shar: will not over-write existing file "'directory.c'" else cat << \SHAR_EOF > 'directory.c' #include <stdio.h> #include <fcntl.h> #include <sys/dir.h> #include <dirent.h> #undef direct extern long lseek(); extern char *malloc(), *strncpy(); extern void free(); DIR *opendir(name) char *name; { DIR *dirp; int fd; if ((fd=open(name, O_RDONLY)) < 0) return NULL; if ( (dirp=(DIR *)malloc(sizeof (*dirp))) == NULL ) { (void)close(fd); return NULL; } dirp->dd_fd = fd; dirp->dd_ptr = dirp->dd_block + sizeof (dirp->dd_block); return dirp; } void rewinddir(dirp) DIR *dirp; { (void)lseek(dirp->dd_fd, 0L, 0); dirp->dd_ptr = dirp->dd_block + sizeof (dirp->dd_block); } struct dirent *readdir(dirp) DIR *dirp; { register int nbytes; register struct direct *directp; do { if (dirp->dd_ptr >= dirp->dd_block + sizeof (dirp->dd_block)) { nbytes = read(dirp->dd_fd, dirp->dd_block, sizeof dirp->dd_block); if ( nbytes <= 0 ) return NULL; while (nbytes<sizeof (dirp->dd_block)) dirp->dd_block[nbytes++] = 0; dirp->dd_ptr = dirp->dd_block; } directp = (struct direct *)dirp->dd_ptr; dirp->dd_ptr += sizeof (*directp); } while (directp->d_ino == 0); dirp->dd_ent.d_ino = directp->d_ino; (void)sprintf(dirp->dd_ent.d_name, "%.*s", sizeof (directp->d_name), directp->d_name); dirp->dd_ent.d_namlen = strlen(dirp->dd_ent.d_name); return &dirp->dd_ent; } void closedir(dirp) DIR *dirp; { (void)close(dirp->dd_fd); free(dirp); } SHAR_EOF if test 1458 -ne "`wc -c < 'directory.c'`" then echo shar: error transmitting "'directory.c'" '(should have been 1458 characters)' fi fi # end of overwriting check echo shar: extracting "'dirent.h'" '(477 characters)' if test -f 'dirent.h' then echo shar: will not over-write existing file "'dirent.h'" else cat << \SHAR_EOF > 'dirent.h' #include <sys/types.h> #define DIRBLKSIZ 1024 #define MAXNAMLEN 15 struct dirent { ino_t d_ino; char d_name[MAXNAMLEN+1]; short d_namlen; }; typedef struct _dirdesc { int dd_fd; char *dd_ptr; struct dirent dd_ent; char dd_block[DIRBLKSIZ]; } DIR; extern DIR *opendir(); extern struct dirent *readdir(); extern void rewinddir(), closedir(); /* for BSD-ish programs that think they are directly reading 'struct direct's */ #define direct dirent SHAR_EOF if test 477 -ne "`wc -c < 'dirent.h'`" then echo shar: error transmitting "'dirent.h'" '(should have been 477 characters)' fi fi # end of overwriting check # End of shell archive exit 0 -- -=] Ford [=- "The number of Unix installations (In Real Life: Mike Ditto) has grown to 10, with more expected." ford@kenobi.cts.com - The Unix Programmer's Manual, ...!sdcsvax!crash!kenobi!ford 2nd Edition, June, 1972. ditto@cbmvax.commodore.com
dave@galaxia.Newport.RI.US (David H. Brierley) (03/11/89)
In article <7906@chinet.chi.il.us> dsueme@chinet.chi.il.us (dave sueme) writes: >I am having the dirent.h probelm (with smail) with 3.51(a) and >3.51 dev set. The best resolution to the "dirent.h nonsense" is to install the directory reading library package written by Doug Gwyn. I posted this to unix-pc.sources within the last month. If you dont still have it online, and didn't squirrel it away somewhere, and dont have access to any archive sites, let me know and I will send you a copy. -- David H. Brierley Home: dave@galaxia.Newport.RI.US {rayssd,xanth,lazlo,jclyde}!galaxia!dave Work: dhb@rayssd.ray.com {sun,decuac,gatech,necntc,ukma}!rayssd!dhb
hartman@abacab.UUCP (Mark A. Hartman) (03/11/89)
In article <391@flatline.UUCP>, erict@flatline.UUCP (Lemmy Caution) writes: >AAUUUUUGGGGH.. What's dirent.h, and is there a pd package that >does whatever dirent.h is supposed to help do? > >Is this something that can be fixed with 3.51 OS+DEV? In article <7906@chinet.chi.il.us>, dsueme@chinet.chi.il.us (dave sueme) writes: > I am having the dirent.h probelm (with smail) with 3.51(a) and > 3.51 dev set. Dirent.h is part of Doug Gwyn's (gwyn@BRL.MIL) POSIX-compatible directory-access routines. They have been posted as part of several packages, although maybe not in any of the unix-pc groups recently. Send mail if you still need it, and I will send you the package. -- Mark Hartman {att,obdient}!abacab!hartman