BSD 4_3_Tahoe development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 9 Mar 1983 02:03:37 +0000 (18:03 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 9 Mar 1983 02:03:37 +0000 (18:03 -0800)
Work on file usr/src/usr.bin/uucp/LIBNDIR/directory.3s

Synthesized-from: CSRG/cd2/4.3tahoe

usr/src/usr.bin/uucp/LIBNDIR/directory.3s [new file with mode: 0644]

diff --git a/usr/src/usr.bin/uucp/LIBNDIR/directory.3s b/usr/src/usr.bin/uucp/LIBNDIR/directory.3s
new file mode 100644 (file)
index 0000000..6301983
--- /dev/null
@@ -0,0 +1,158 @@
+..TH DIRECTORY 3  "OGC Revision  8/02/82"
+.TH DIRECTORY 3X 8/1/82
+.UC 4.1b Compatability
+.SH NAME
+opendir, readdir, telldir, seekdir, rewinddir, closedir \- flexible length directory operations
+.SH SYNOPSIS
+.B #include <ndir.h>
+.PP
+.SM
+.B DIR
+.B *opendir(filename)
+.br
+.B char *filename;
+.PP
+.SM
+.B struct direct
+.B *readdir(dirp)
+.br
+.B DIR *dirp;
+.PP
+.SM
+.B long
+.B telldir(dirp)
+.br
+.B DIR *dirp;
+.PP
+.SM
+.B seekdir(dirp, loc)
+.br
+.B DIR *dirp;
+.br
+.B long loc;
+.PP
+.SM
+.B rewinddir(dirp)
+.br
+.B DIR *dirp;
+.PP
+.SM
+.B closedir(dirp)
+.br
+.B DIR *dirp;
+.PP
+.SM
+.B cc ... -lndir
+.SH DESCRIPTION
+The purpose of this library is to simulate
+the new flexible length directory names of 4.2bsd Unix
+on top of the old directory structure of 4.1bsd.
+It allows programs to be converted immediately
+to the new directory access interface,
+so that they need only be relinked
+when 4.2bsd becomes available.
+.PP
+.I opendir
+opens the directory named by
+.I filename
+and associates a
+.I directory stream
+with it.
+.I opendir
+returns a pointer to be used to identify the
+.I directory stream
+in subsequent operations.
+The pointer
+.SM
+.B NULL
+is returned if
+.I filename
+cannot be accessed or is not a directory.
+.PP
+.I readdir
+returns a pointer to the next directory entry.
+It returns
+.B NULL
+upon reaching the end of the directory or detecting
+an invalid
+.I seekdir
+operation.
+.PP
+.I telldir
+returns the current location associated with the named
+.I directory stream.
+.PP
+.I seekdir
+sets the position of the next
+.I readdir
+operation on the
+.I directory stream.
+The new position reverts to the one associated with the
+.I directory stream
+when the
+.I telldir
+operation was performed.
+Values returned by
+.I telldir
+are good only for the lifetime of the DIR pointer from
+which they are derived.
+If the directory is closed and then reopened,
+the
+.I telldir
+value may be invalidated
+due to undetected directory compaction.
+It is safe to use a previous
+.I telldir
+value immediately after a call to
+.I opendir
+and before any calls to
+.I readdir.
+.PP
+.I rewinddir
+resets the position of the named
+.I directory stream
+to the beginning of the directory.
+.PP
+.I closedir
+causes the named
+.I directory stream
+to be closed,
+and the structure associated with the DIR pointer to be freed.
+.PP
+See /usr/include/ndir.h for a description of the fields available in
+a directory entry.
+The preferred way to search the current directory for entry "name" is:
+.br
+.sp
+       len = strlen(name);
+.br
+       dirp = opendir(".");
+.br
+       for (dp = readdir(dirp); dp != NULL; dp = readdir(dir))
+.br
+               if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
+.br
+                       closedir(dirp);
+.br
+                       return FOUND;
+.br
+               }
+.br
+       closedir(dirp);
+.br
+       return NOT_FOUND;
+.SH LINKING
+This library is accessed by specifying "-lndir" as the
+last argument to the compile line, e.g.:
+.br
+.sp
+       cc -o prog prog.c -lndir
+.SH "SEE ALSO"
+/usr/include/ndir.h,
+open(2),
+close(2),
+read(2),
+lseek(2)
+.SH AUTHOR
+Kirk McKusick.
+Report problems to mckusick@berkeley or ucbvax!mckusick.