1: /* Copyright (c) 1982 Regents of the University of California */
   2: 
   3: static char sccsid[] = "@(#)readdir.c 4.3 8/8/82";
   4: 
   5: #include <sys/types.h>
   6: #include <dir.h>
   7: 
   8: /*
   9:  * read an old stlye directory entry and present it as a new one
  10:  */
  11: #define ODIRSIZ 14
  12: 
  13: struct  olddirect {
  14:     ino_t   od_ino;
  15:     char    od_name[ODIRSIZ];
  16: };
  17: 
  18: /*
  19:  * get next entry in a directory.
  20:  */
  21: struct direct *
  22: readdir(dirp)
  23:     register DIR *dirp;
  24: {
  25:     register struct olddirect *dp;
  26:     static struct direct dir;
  27: 
  28:     for (;;) {
  29:         if (dirp->dd_loc == 0) {
  30:             dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
  31:                 DIRBLKSIZ);
  32:             if (dirp->dd_size <= 0)
  33:                 return NULL;
  34:         }
  35:         if (dirp->dd_loc >= dirp->dd_size) {
  36:             dirp->dd_loc = 0;
  37:             continue;
  38:         }
  39:         dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
  40:         dirp->dd_loc += sizeof(struct olddirect);
  41:         if (dp->od_ino == 0)
  42:             continue;
  43:         dir.d_ino = dp->od_ino;
  44:         strncpy(dir.d_name, dp->od_name, ODIRSIZ);
  45:         dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
  46:         dir.d_namlen = strlen(dir.d_name);
  47:         dir.d_reclen = DIRBLKSIZ;
  48:         return (&dir);
  49:     }
  50: }

Defined functions

Defined variables

sccsid defined in line 3; never used

Defined struct's

olddirect defined in line 13; used 6 times

Defined macros

ODIRSIZ defined in line 11; used 3 times
Last modified: 1983-01-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 836
Valid CSS Valid XHTML 1.0 Strict