Annotation of 43BSD/usr.bin/uucp/LIBNDIR/opendir.c, revision 1.1.1.1

1.1       root        1: static char sccsid[] = "@(#)opendir.c 4.3 8/4/82";
                      2: 
                      3: #include <sys/types.h>
                      4: #include <sys/stat.h>
                      5: #include <ndir.h>
                      6: 
                      7: /*
                      8:  * open a directory.
                      9:  */
                     10: DIR *
                     11: opendir(name)
                     12:        char *name;
                     13: {
                     14:        register DIR *dirp;
                     15:        register int fd;
                     16:        struct stat sbuf;
                     17: 
                     18:        if ((fd = open(name, 0)) == -1)
                     19:                return NULL;
                     20:        fstat(fd, &sbuf);
                     21:        if (((sbuf.st_mode & S_IFDIR) == 0) ||
                     22:            ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL)) {
                     23:                close (fd);
                     24:                return NULL;
                     25:        }
                     26:        dirp->dd_fd = fd;
                     27:        dirp->dd_loc = 0;
                     28:        return dirp;
                     29: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.