xref: /csrg-svn/lib/libc/gen/opendir.c (revision 9142)
15750Smckusick /* Copyright (c) 1982 Regents of the University of California */
25750Smckusick 
3*9142Smckusick static char sccsid[] = "@(#)opendir.c 4.4 11/12/82";
45750Smckusick 
5*9142Smckusick #include <sys/param.h>
6*9142Smckusick #include <dir.h>
75750Smckusick 
85750Smckusick /*
95750Smckusick  * open a directory.
105750Smckusick  */
115750Smckusick DIR *
125750Smckusick opendir(name)
135750Smckusick 	char *name;
145750Smckusick {
156097Smckusic 	register DIR *dirp;
167659Smckusick 	register int fd;
175750Smckusick 
187659Smckusick 	if ((fd = open(name, 0)) == -1)
195750Smckusick 		return NULL;
20*9142Smckusick 	if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
217659Smckusick 		close (fd);
226097Smckusic 		return NULL;
236097Smckusic 	}
247659Smckusick 	dirp->dd_fd = fd;
255750Smckusick 	dirp->dd_loc = 0;
265750Smckusick 	return dirp;
275750Smckusick }
28