BSD 4_3_Reno release
[unix-history] / usr / src / lib / libc / gen / directory.3
index 43e0d0c..f0f1a53 100644 (file)
@@ -1,63 +1,54 @@
 .\" Copyright (c) 1983 Regents of the University of California.
 .\" Copyright (c) 1983 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)directory.3 6.3 (Berkeley) %G%
+.\" Redistribution and use in source and binary forms are permitted provided
+.\" that: (1) source distributions retain this entire copyright notice and
+.\" comment, and (2) distributions including binaries display the following
+.\" acknowledgement:  ``This product includes software developed by the
+.\" University of California, Berkeley and its contributors'' in the
+.\" documentation or other materials provided with the distribution and in
+.\" all advertising materials mentioning features or use of this software.
+.\" Neither the name of the University nor the names of its contributors may
+.\" be used to endorse or promote products derived from this software without
+.\" specific prior written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\"
-.TH DIRECTORY 3 ""
+.\"    @(#)directory.3 6.6 (Berkeley) 6/23/90
+.\"
+.TH DIRECTORY 3 "June 23, 1990"
 .UC 5
 .SH NAME
 opendir, readdir, telldir, seekdir, rewinddir, closedir, dirfd \- directory operations
 .SH SYNOPSIS
 .UC 5
 .SH NAME
 opendir, readdir, telldir, seekdir, rewinddir, closedir, dirfd \- directory operations
 .SH SYNOPSIS
-.B #include <sys/types.h>
-.br
-.B #include <sys/dir.h>
-.PP
-.SM
-.B DIR
-.B *opendir(filename)
-.br
-.B char *filename;
-.PP
-.B struct direct
-.B *readdir(dirp)
-.br
-.SM
-.B DIR
-.B *dirp;
-.PP
-.B long
-.B telldir(dirp)
-.br
-.SM
-.B DIR
-.B *dirp;
-.PP
-.B seekdir(dirp, loc)
-.br
-.SM
-.B DIR
-.B *dirp;
-.br
-.B long loc;
-.PP
-.B rewinddir(dirp)
-.br
-.SM
-.B DIR
-.B *dirp;
-.PP
-.B closedir(dirp)
-.br
-.SM
-.B DIR
-.B *dirp;
-.PP
-.B dirfd(dirp)
-.br
-.SM
-.B DIR
-.B *dirp;
+.nf
+.ft B
+#include <sys/types.h>
+#include <dirent.h>
+
+DIR *
+opendir(const char *filename);
+
+struct direct
+*readdir(DIR * dirp);
+
+long
+telldir(const DIR *dirp);
+
+void
+seekdir(DIR *dirp, long loc);
+
+void
+rewinddir(DIR *dirp);
+
+int
+closedir(DIR *dirp);
+
+int
+dirfd(DIR *dirp)
+.ft R
+.fi
 .SH DESCRIPTION
 .I Opendir
 opens the directory named by
 .SH DESCRIPTION
 .I Opendir
 opens the directory named by
@@ -118,7 +109,9 @@ to the beginning of the directory.
 .I Closedir
 closes the named
 .I directory stream
 .I Closedir
 closes the named
 .I directory stream
-and frees the structure associated with the DIR pointer.
+and frees the structure associated with the DIR pointer,
+returning 0 on success.
+On failure, -1 is returned and errno is set to indicate the error.
 .PP
 .I Dirfd
 returns the integer file descriptor associated with the named
 .PP
 .I Dirfd
 returns the integer file descriptor associated with the named
@@ -127,27 +120,18 @@ see open(2).
 .PP
 Sample code which searchs a directory for entry ``name'' is:
 .PP
 .PP
 Sample code which searchs a directory for entry ``name'' is:
 .PP
-.br
-       len = strlen(name);
-.br
-       dirp = opendir(".");
-.br
-       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
-.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;
+.nf
+.RS
+len = strlen(name);
+dirp = opendir(".");
+for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
+       if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
+               (void)closedir(dirp);
+               return FOUND;
+       }
+(void)closedir(dirp);
+return NOT_FOUND;
+.RE
+.fi
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-open(2),
-close(2),
-read(2),
-lseek(2),
-dir(5)
+open(2), close(2), read(2), lseek(2), dir(5)