Path: utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!udel!princeton!cs!samadams!tr From: tr@samadams.princeton.edu (Tom Reingold) Newsgroups: comp.lang.c Subject: Re: question on opendir, readdir, etc. Message-ID: <4776@rossignol.Princeton.EDU> Date: 29 Nov 90 22:01:35 GMT References: <4767@rossignol.Princeton.EDU> <14611@smoke.brl.mil> Sender: news@cs.Princeton.EDU Organization: Noo Joizy -- The Cultural Mecca Lines: 49 In article <14611@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: $ In article <4767@rossignol.Princeton.EDU> tr@samadams.princeton.edu $ (Tom Reingold) writes: $ >To use opendir, readdir, etc. on BSD, you include . This $ >lets you use a struct defined as direct. The member d_name is a $ >character array of size MAXNAMLEN+1 (256). $ $ That is obsolete. Which is obsolete? ? $ >To use these functions on System V, you include . This lets $ >you use a struct defined as dirent. Confusingly close. The member $ >d_name is a character array of size 1! Is this for real? I have a $ >sample program which works, but I think I'm lucky that trashing the $ >area after my structure doesn't kill anything vital. $ $ UNIX System (as of release 3.0) included IEEE Std 1003.1 (POSIX)- $ compatible directory access functions and the corresponding header. $ The code actually originated with my independent implementation; $ Kirk McKusick of UCB had earlier provided an implementation of the $ BSD "struct direct" flavor of these functions, which inspired the $ POSIX specification. There were good reasons for the slight changes $ made by IEEE P1003, which I won't go into here. $ $ >Am I not supposed to use these functions in System V? If I am, do they $ >normally work? $ $ Yes, they had BETTER work. The [1] kludge is deliberate, and from $ time to time argument rages about whether the C standard requires that $ an implementation make it work or whether it could ever fail. I have $ yet to hear of any commercial UNIX implementation where it doesn't $ work. How can it work? And why was this kludge put there? $ You can also obtain my current implementation simply by requesting it $ in an e-mail message to me . I have it already, thank you. Now I know I should use it. Is this POSIX standard found in System V Release 4? -- Tom Reingold tr@samadams.princeton.edu OR ...!princeton!samadams!tr "Warning: Do not drive with Auto-Shade in place. Remove from windshield before starting ignition."