# 2.11BSD#431 - /usr/src/lib/libc/stdio/fdopen.c

##### Functions

    fdopen            X

       1: /*
       2:  * Copyright (c) 1980 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[] = "@(#)fdopen.c	5.2 (Berkeley) 3/9/86";
       9: #endif LIBC_SCCS and not lint
      10:
      11: /*
      12:  * Unix routine to do an "fopen" on file descriptor
      13:  * The mode has to be repeated because you can't query its
      14:  * status
      15:  */
      16:
      17: #include <sys/types.h>
      18: #include <sys/file.h>
      19: #include <stdio.h>
      20:
      21: FILE *
      22: fdopen(fd, mode)
      23:     register char *mode;
      24: {
      25:     extern FILE *_findiop();
      26:     static int nofile = -1;
      27:     register FILE *iop;
      28:
      29:     if (nofile < 0)
      30:         nofile = getdtablesize();
      31:
      32:     if (fd < 0 || fd >= nofile)
      33:         return (NULL);
      34:
      35:     iop = _findiop();
      36:     if (iop == NULL)
      37:         return (NULL);
      38:
      39:     iop->_cnt = 0;
      40:     iop->_file = fd;
      41:     iop->_bufsiz = 0;
      42:     iop->_base = iop->_ptr = NULL;
      43:
      44:     switch (*mode) {
      45:     case 'r':
      46:         iop->_flag = _IOREAD;
      47:         break;
      48:     case 'a':
      49:         lseek(fd, (off_t)0, L_XTND);
      50:         /* fall into ... */
      51:     case 'w':
      52:         iop->_flag = _IOWRT;
      53:         break;
      54:     default:
      55:         return (NULL);
      56:     }
      57:
      58:     if (mode[1] == '+')
      59:         iop->_flag = _IORW;
      60:
      61:     return (iop);
      62: }

#### Defined functions

fdopen defined in line 21; used 109 times

- in /usr/include/stdio.h line 69
- in /usr/src/bin/chpass/chpass.c line 151, 241
- in /usr/src/bin/ld/ld.c line 1949
- in /usr/src/bin/mail.c line 77, 309, 620
- in /usr/src/bin/passwd/passwd.c line 98
- in /usr/src/bin/rcp.c line 840
- in /usr/src/games/atc/log.c line 78
- in /usr/src/games/hunt/answer.c line 69
- in /usr/src/games/hunt/playit.c line 59
- in /usr/src/include/stdio.h line 56
- in /usr/src/lib/libc/gen/getpass.c line 22
- in /usr/src/lib/libc/gen/popen.c line 95-98(2)
- in /usr/src/libexec/acctd/acctd.c line 436
- in /usr/src/libexec/fingerd/fingerd.c line 154
- in /usr/src/libexec/ftpd/ftpd.c line 633, 653, 691, 697
- in /usr/src/libexec/ftpd/popen.c line 117-120(2)
- in /usr/src/libexec/identd/testdir/test1.c line 102-103(2)
- in /usr/src/libexec/popper/pop_dropcopy.c line 148
- in /usr/src/libexec/popper/pop_init.c line 161, 168
- in /usr/src/libexec/popper/pop_updt.c line 68
- in /usr/src/libexec/tcpd/rfc931.c line 52
- in /usr/src/libexec/tftpd/tftpd.c line 281
- in /usr/src/new/PORT/B/src/bed/comm.c line 196-197(2)
- in /usr/src/new/kermit5.188/ckcmdb.c line 323
- in /usr/src/new/kermit5.188/ckufio.c line 1424, 1430
- in /usr/src/new/kermit5.188/ckuusx.c line 1853
- in /usr/src/new/nntp/common/clientlib.c line 138, 144
- in /usr/src/new/nntp/server/spawn.c line 174
- in /usr/src/new/nntp/xmit/remote.c line 220, 228
- in /usr/src/sbin/mkpasswd/mkpasswd.c line 102
- in /usr/src/sbin/savecore/savecore.c line 171
- in /usr/src/ucb/Mail/popen.c line 70, 110
- in /usr/src/ucb/finger/net.c line 103
- in /usr/src/ucb/ftp/ftp.c line 160-161(2), 1176
- in /usr/src/ucb/rdist/server.c line 1388, 1419
- in /usr/src/ucb/sendbug/bugfiler.c line 229
- in /usr/src/ucb/tftp/tftp.c line 88, 189
- in /usr/src/ucb/whois.c line 76-77(2)
- in /usr/src/usr.bin/learn/getlesson.c line 49
- in /usr/src/usr.bin/ranlib/build.c line 79
- in /usr/src/usr.bin/uucp/condevs.c line 547
- in /usr/src/usr.bin/uucp/mailst.c line 82
- in /usr/src/usr.lib/libF77/mkvers.c line 26
- in /usr/src/usr.lib/libI77/mkvers.c line 26
- in /usr/src/usr.lib/libU77/mkvers.c line 26
- in /usr/src/usr.sbin/cron/crontab.c line 309
- in /usr/src/usr.sbin/cron/do_command.c line 237, 299
- in /usr/src/usr.sbin/cron/misc.c line 255
- in /usr/src/usr.sbin/cron/popen.c line 125-128(2)
- in /usr/src/usr.sbin/cron/user.c line 57
- in /usr/src/usr.sbin/edquota/edquota.c line 363, 398
- in /usr/src/usr.sbin/gettable/gettable.c line 88-89(2)
- in /usr/src/usr.sbin/named/named/ns_req.c line 1278
- in /usr/src/usr.sbin/named/tools/nslookup/list.c line 891
- in /usr/src/usr.sbin/sendmail.MX/aux/bbn_daemon.c line 126-127(2), 258-259(2)
- in /usr/src/usr.sbin/sendmail.MX/aux/mconnect.c line 117, 127
- in /usr/src/usr.sbin/sendmail.MX/src/daemon.c line 239-240(2), 435-436(2)
- in /usr/src/usr.sbin/sendmail.MX/src/deliver.c line 732, 943-947(2)
- in /usr/src/usr.sbin/sendmail/aux/4.1a_daemon.c line 102-103(2), 367-368(2)
- in /usr/src/usr.sbin/sendmail/aux/bbn_daemon.c line 126-127(2), 258-259(2)
- in /usr/src/usr.sbin/sendmail/aux/mconnect.c line 128, 141
- in /usr/src/usr.sbin/sendmail/src/daemon.c line 239-240(2), 435-436(2)
- in /usr/src/usr.sbin/sendmail/src/deliver.c line 674, 885-889(2)
- in /usr/src/usr.sbin/vipw/vipw.c line 84

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1986-03-10 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 539 |