Sync with 4.4 lite

This commit is contained in:
jtc 1994-07-27 05:37:08 +00:00
parent 409e85d379
commit ad1d3832de
3 changed files with 20 additions and 22 deletions

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1983, 1991 Regents of the University of California.
.\" All rights reserved.
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -29,10 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)directory.3 6.7 (Berkeley) 4/19/91
.\" $Id: directory.3,v 1.5 1994/01/10 23:32:23 jtc Exp $
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
.\"
.Dd April 19, 1991
.Dd June 4, 1993
.Dt DIRECTORY 3
.Os BSD 4.2
.Sh NAME
@ -152,11 +151,11 @@ returns the integer file descriptor associated with the named
see
.Xr open 2 .
.Pp
Sample code which searches a directory for entry ``name'' is:
Sample code which searchs a directory for entry ``name'' is:
.Bd -literal -offset indent
len = strlen(name);
dirp = opendir(".");
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
while ((dp = readdir(dirp)) != NULL)
if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
(void)closedir(dirp);
return FOUND;

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1983, 1991 Regents of the University of California.
.\" All rights reserved.
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -29,10 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)scandir.3 6.8 (Berkeley) 4/19/91
.\" $Id: scandir.3,v 1.2 1993/07/30 08:38:24 mycroft Exp $
.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93
.\"
.Dd April 19, 1991
.Dd June 4, 1993
.Dt SCANDIR 3
.Os BSD 4.2
.Sh NAME

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -32,8 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)scandir.c 5.10 (Berkeley) 2/23/91";*/
static char *rcsid = "$Id: scandir.c,v 1.3 1993/08/26 00:45:00 jtc Exp $";
static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
#endif /* LIBC_SCCS and not lint */
/*
@ -50,14 +49,15 @@ static char *rcsid = "$Id: scandir.c,v 1.3 1993/08/26 00:45:00 jtc Exp $";
#include <string.h>
/*
* The DIRSIZ macro gives the minimum record length which will hold
* the directory entry. This requires the amount of space in struct dirent
* without the d_name field, plus enough space for the name with a terminating
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
* The DIRSIZ macro is the minimum record length which will hold the directory
* entry. This requires the amount of space in struct dirent without the
* d_name field, plus enough space for the name and a terminating nul byte
* (dp->d_namlen + 1), rounded up to a 4 byte boundary.
*/
#undef DIRSIZ
#define DIRSIZ(dp) \
((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
#define DIRSIZ(dp) \
((sizeof(struct dirent) - sizeof(dp)->d_name) + \
(((dp)->d_namlen + 1 + 3) &~ 3))
int
scandir(dirname, namelist, select, dcomp)