1: /* @(#)fseek.c 2.1 SCCS id keyword */
2: /*
3: * Seek for standard library. Coordinates with buffering.
4: */
5:
6: #include <stdio.h>
7:
8: long lseek();
9:
10: fseek(iop, offset, ptrname)
11: register FILE *iop;
12: long offset;
13: {
14: register int c;
15: long p;
16:
17: iop->_flag &= ~_IOEOF;
18: if (iop->_flag & _IOREAD) {
19: if (ptrname < 2 && iop->_base && !(iop->_flag&_IONBF)) {
20: c = iop->_cnt;
21: p = offset;
22: if (ptrname == 0)
23: p += c - lseek(fileno(iop), 0L, 1);
24: else
25: offset -= c;
26: if (!(iop->_flag&_IORW) && c > 0 && p <= c
27: && p >= iop->_base - iop->_ptr){
28: iop->_ptr += (int) p;
29: iop->_cnt -= (int) p;
30: return(0);
31: }
32: }
33: if (iop->_flag & _IORW) {
34: iop->_ptr = iop->_base;
35: iop->_flag &= ~_IOREAD;
36: }
37: p = lseek(fileno(iop), offset, ptrname);
38: iop->_cnt = 0;
39: } else if(iop->_flag & (_IOWRT|_IORW)) {
40: fflush(iop);
41: if (iop->_flag & _IORW) {
42: iop->_cnt = 0;
43: iop->_flag &= ~_IOWRT;
44: iop->_ptr = iop->_base;
45: }
46: p = lseek(fileno(iop), offset, ptrname);
47: }
48: return(p==-1? -1: 0);
49: }
Defined functions
fseek
defined in line
10; used 142 times
- in /usr/src/cmd/512dumpdir.c line
378
- in /usr/src/cmd/at.c line
136
- in /usr/src/cmd/diff/diffreg.c line
656
- in /usr/src/cmd/diff3.c line
379,
412
- in /usr/src/cmd/dumpdir.c line
340
- in /usr/src/cmd/grep.c line
457
- in /usr/src/cmd/join.c line
119,
127-131(2)
- in /usr/src/cmd/look.c line
57-61(2),
84
- in /usr/src/cmd/mail.c line
282-285(2),
330,
483
- in /usr/src/cmd/make/files.c line
188,
431,
450
- in /usr/src/cmd/nm.c line
96,
123,
129,
281
- in /usr/src/cmd/od.c line
263
- in /usr/src/cmd/prof.c line
111,
194
- in /usr/src/cmd/ps/ps.c line
633-638(2)
- in /usr/src/cmd/ranlib.c line
41,
58,
105
- in /usr/src/cmd/reboot.c line
156
- in /usr/src/cmd/refer/refer/hunt2.c line
26,
42
- in /usr/src/cmd/refer/refer/hunt5.c line
21
- in /usr/src/cmd/refer/refer/hunt6.c line
17
- in /usr/src/cmd/refer/refer/hunt7.c line
70
- in /usr/src/cmd/refer/util/deliv1.c line
39
- in /usr/src/cmd/refer/util/hunt1.c line
119
- in /usr/src/cmd/refer/util/hunt2.c line
66,
108
- in /usr/src/cmd/refer/util/hunt5.c line
17
- in /usr/src/cmd/refer/util/hunt6.c line
34,
104
- in /usr/src/cmd/refer/util/hunt7.c line
95
- in /usr/src/cmd/refer/util/inv5.c line
44
- in /usr/src/cmd/refer/util/mkey2.c line
88
- in /usr/src/cmd/remind/delrem.c line
89,
269
- in /usr/src/cmd/savecore.c line
192,
199,
209-212(2),
378
- in /usr/src/cmd/shutdown.c line
353
- in /usr/src/cmd/struct/1.form.c line
197
- in /usr/src/cmd/tar.c line
1013,
1098
- in /usr/src/cmd/uucp/4.2/condevs.c line
379,
488
- in /usr/src/cmd/uucp/DIALUP/condevs.c line
380,
489
- in /usr/src/cmd/uucp/condevs.c line
380,
489
- in /usr/src/games/fortune/fortune.c line
69-73(2)
- in /usr/src/games/fortune/strfile.c line
93,
128
- in /usr/src/lib/c/stdio/getpwent.c line
98
- in /usr/src/lib/libI77/backspace.c line
43-49(3)
- in /usr/src/lib/libI77/dfe.c line
50,
61,
71,
78
- in /usr/src/lib/libI77/due.c line
50,
65
- in /usr/src/lib/libI77/endfile.c line
48,
55
- in /usr/src/lib/libI77/ioprim.c line
153
- in /usr/src/lib/libI77/open.c line
78
- in /usr/src/lib/libI77/rdfe.c line
52
- in /usr/src/lib/libI77/sfe.c line
66-71(2)
- in /usr/src/lib/libI77/sue.c line
38,
69-71(2),
77
- in /usr/src/lib/libI77/util.c line
59,
65,
101
- in /usr/src/lib/libI77/wdfe.c line
41
- in /usr/src/lib/libI77/wsfe.c line
61,
67
- in /usr/src/lib/libU77/fseek_.c line
31
- in /usr/src/ucb/Mail/aux.c line
262
- in /usr/src/ucb/Mail/edit.c line
188
- in /usr/src/ucb/Mail/fio.c line
217,
340
- in /usr/src/ucb/Mail/quit.c line
66
- in /usr/src/ucb/berknet/netdaemon.c line
149,
981
- in /usr/src/ucb/berknet/setup.c line
222
- in /usr/src/ucb/ctags.c line
476-481(2)
- in /usr/src/ucb/delivermail/vax-mail.c line
325-328(2),
373
- in /usr/src/ucb/ex/ex3/ex_cmdsub.c line
552
- in /usr/src/ucb/eyacc/ey5.c line
20
- in /usr/src/ucb/l11/pass2.c line
77,
95,
741,
747,
849,
868,
878
- in /usr/src/ucb/lpr/src/lpd.c line
354
- in /usr/src/ucb/m11/macxrf.c line
107
- in /usr/src/ucb/mkstr.c line
230
- in /usr/src/ucb/more.c line
30,
88
- in /usr/src/ucb/msgs/msgs.c line
374,
518,
533,
608,
636,
706,
716,
767,
795
- in /usr/src/ucb/pascal/pi/yyput.c line
160
- in /usr/src/ucb/pwhash/src/libc/stdio/getpwent.c line
98
- in /usr/src/ucb/sendmail/aux/syslog.c line
716
- in /usr/src/ucb/strings.c line
74-78(2),
88
- in /usr/src/ucb/sysline.c line
819
- in /usr/src/ucb/what.c line
28
- in /usr/src/ucb/xstr.c line
307