1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)readdir.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include <sys/param.h>
  12: #include <sys/dir.h>
  13: 
  14: /*
  15:  * get next entry in a directory.
  16:  */
  17: struct direct *
  18: readdir(dirp)
  19:     register DIR *dirp;
  20: {
  21:     register struct direct *dp;
  22: 
  23:     for (;;) {
  24:         if (dirp->dd_loc == 0) {
  25:             dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
  26:                 DIRBLKSIZ);
  27:             if (dirp->dd_size <= 0)
  28:                 return NULL;
  29:         }
  30:         if (dirp->dd_loc >= dirp->dd_size) {
  31:             dirp->dd_loc = 0;
  32:             continue;
  33:         }
  34:         dp = (struct direct *)(dirp->dd_buf + dirp->dd_loc);
  35:         if (dp->d_reclen <= 0 ||
  36:             dp->d_reclen > DIRBLKSIZ + 1 - dirp->dd_loc)
  37:             return NULL;
  38:         dirp->dd_loc += dp->d_reclen;
  39:         if (dp->d_ino == 0)
  40:             continue;
  41:         return (dp);
  42:     }
  43: }

Defined functions

readdir defined in line 17; used 97 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1990-05-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3482
Valid CSS Valid XHTML 1.0 Strict