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 149 times
- in /usr/include/stdio.h line
56
- in /usr/src/bin/mail.c line
89,
325,
657
- in /usr/src/bin/passwd.c line
144
- in /usr/src/etc/fingerd.c line
75
- in /usr/src/etc/ftpd/ftpd.c line
377,
390,
427,
433,
902
- in /usr/src/etc/gettable.c line
88-89(2)
- in /usr/src/etc/named/ns_req.c line
287
- in /usr/src/etc/named/tools/ns.lookup/src/list.c line
632
- in /usr/src/etc/quotacheck.c line
258
- in /usr/src/etc/savecore.c line
255
- in /usr/src/etc/tftpd/tftpd.c line
248
- in /usr/src/etc/vipw.c line
60
- in /usr/src/games/hunt/answer.c line
66
- 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
61
- in /usr/src/new/B/src/bed/comm.c line
196-197(2)
- in /usr/src/new/emacs/src/lread.c line
201
- in /usr/src/new/help/help.c line
1119,
1134
- in /usr/src/new/icon/iconx/init.c line
252
- in /usr/src/new/icon/pilib/init.c line
252
- in /usr/src/new/kermit/ckufio.c line
540
- in /usr/src/new/kermit/ckutio.c line
621
- in /usr/src/new/mh/mts/sendmail/smail.c line
160-161(2),
227-228(2)
- in /usr/src/new/mh/sbr/m_getdefs.c line
207
- in /usr/src/new/mh/support/bboards/mmdfI/bboards/bb_wtmail.c line
487,
502,
597
- in /usr/src/new/mh/support/bboards/mmdfII/bboards/bb_wtmail.c line
735
- in /usr/src/new/mh/support/bboards/mmdfII/bboards/dropsbr.c line
371,
425,
555
- in /usr/src/new/mh/support/bboards/mmdfII/bboards/lock.c line
230
- in /usr/src/new/mh/support/pop/mmdfII/pop/dropsbr.c line
371,
425,
555
- in /usr/src/new/mh/support/pop/mmdfII/pop/lock.c line
230
- in /usr/src/new/mh/support/pop/mmdfII/pop/po_wtmail.c line
735
- in /usr/src/new/mh/support/pop/popsbr.c line
97-98(2)
- in /usr/src/new/mh/support/pop/popser.c line
237-238(2)
- in /usr/src/new/mh/support/pop/popwrd.c line
150
- in /usr/src/new/mh/uip/conflict.c line
368
- in /usr/src/new/mh/uip/distsbr.c line
156,
191
- in /usr/src/new/mh/uip/dropsbr.c line
371,
425,
555
- in /usr/src/new/mh/uip/inc.c line
495
- in /usr/src/new/mh/uip/msh.c line
902,
1195
- in /usr/src/new/mh/uip/popsbr.c line
97-98(2)
- in /usr/src/new/mh/uip/rmail.c line
107-111(2),
250,
277,
484,
527,
572
- in /usr/src/new/mh/uip/sbboards.c line
177
- in /usr/src/new/mh/uip/sendsbr.c line
333
- in /usr/src/new/mh/uip/slocal.c line
293,
571,
1083,
1094
- in /usr/src/new/mh/uip/spop.c line
177
- in /usr/src/new/mh/uip/umhook.c line
259,
298,
367
- in /usr/src/new/mh/zotnet/mf/mmdfI/src/uucp/qu2uu_send.c line
283
- in /usr/src/new/mh/zotnet/mf/mmdfI/src/uucp/rmail.c line
134,
143,
653,
695,
712
- in /usr/src/new/mh/zotnet/mf/mmuu.c line
64-65(2),
131,
151,
161,
214,
276
- in /usr/src/new/mh/zotnet/mf/uumm.c line
64-65(2),
135,
156,
166
- in /usr/src/new/mh/zotnet/mts/lock.c line
230
- in /usr/src/new/news/src/control.c line
673
- in /usr/src/new/nntp/common/clientlib.c line
44,
50
- in /usr/src/new/nntp/xmit/remote.c line
135,
142
- in /usr/src/new/spms/src/lib/pgrep/grep.c line
95,
111
- in /usr/src/new/xns/examples/auth/getXNSpass.c line
23
- in /usr/src/new/xns/examples/authchtest/getXNSpass.c line
23
- in /usr/src/new/xns/morexnslib/auth/getXNSpass.c line
39
- in /usr/src/ucb/Mail/fio.c line
524,
531
- in /usr/src/ucb/Mail/popen.c line
51
- in /usr/src/ucb/finger.c line
1057
- in /usr/src/ucb/ftp/ftp.c line
109-110(2),
965
- in /usr/src/ucb/ftp/pclose.c line
63
- in /usr/src/ucb/lisp/franz/fpipe.c line
26,
32,
111
- in /usr/src/ucb/lisp/franz/lam1.c line
384
- in /usr/src/ucb/lisp/franz/lam7.c line
81
- in /usr/src/ucb/lisp/franz/vax/totxtfile.c line
30,
43
- in /usr/src/ucb/sendbug/bugfiler.c line
231
- in /usr/src/ucb/tftp/tftp.c line
75,
176
- 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/uucp/condevs.c line
551
- 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.lib/sendmail/aux/4.1a_daemon.c line
102-103(2),
367-368(2)
- in /usr/src/usr.lib/sendmail/aux/bbn_daemon.c line
126-127(2),
258-259(2)
- in /usr/src/usr.lib/sendmail/aux/mconnect.c line
128,
141
Defined variables
sccsid
defined in line
8;
never used