Annotation of coherent/b/lib/libc/ndir/telldir.c, revision 1.1.1.1

1.1       root        1: /*
                      2:        telldir -- report directory stream position
                      3: 
                      4:        last edit:      25-Apr-1987     D A Gwyn
                      5: 
                      6:        NOTE:   4.nBSD directory compaction makes seekdir() & telldir()
                      7:                practically impossible to do right.  Avoid using them!
                      8: */
                      9: 
                     10: #ifdef COHERENT
                     11: #include       <errno.h>
                     12: #else
                     13: #include       <sys/errno.h>
                     14: #endif
                     15: 
                     16: #include <stddef.h>
                     17: 
                     18: #include       <sys/types.h>
                     19: #include       "dirent.h"
                     20: 
                     21: extern off_t   lseek();
                     22: 
                     23: extern int     errno;
                     24: 
                     25: #ifndef SEEK_CUR
                     26: #define        SEEK_CUR        1
                     27: #endif
                     28: 
                     29: off_t
                     30: telldir( dirp )                                /* return offset of next entry */
                     31:        DIR     *dirp;                  /* stream from opendir() */
                     32:        {
                     33:        if ( dirp == NULL || dirp->dd_buf == NULL )
                     34:                {
                     35:                errno = EFAULT;
                     36:                return -1;              /* invalid pointer */
                     37:                }
                     38: 
                     39:        if ( dirp->dd_loc < dirp->dd_size )     /* valid index */
                     40:                return ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off;
                     41:        else                            /* beginning of next directory block */
                     42:                return lseek( dirp->dd_fd, (off_t)0, SEEK_CUR );
                     43:        }

unix.superglobalmegacorp.com

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