Annotation of 40BSD/libc/stdio/fdopen.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Unix routine to do an "fopen" on file descriptor
                      3:  * The mode has to be repeated because you can't query its
                      4:  * status
                      5:  */
                      6: 
                      7: #include       <stdio.h>
                      8: #include       <errno.h>
                      9: 
                     10: FILE *
                     11: fdopen(fd, mode)
                     12: register char *mode;
                     13: {
                     14:        extern int errno;
                     15:        register FILE *iop;
                     16:        extern FILE *_lastbuf;
                     17: 
                     18:        for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
                     19:                if (iop >= _lastbuf)
                     20:                        return(NULL);
                     21:        iop->_cnt = 0;
                     22:        iop->_file = fd;
                     23:        if (*mode != 'r') {
                     24:                iop->_flag |= _IOWRT;
                     25:                if (*mode == 'a')
                     26:                        lseek(fd, 0L, 2);
                     27:        } else
                     28:                iop->_flag |= _IOREAD;
                     29:        return(iop);
                     30: }

unix.superglobalmegacorp.com

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