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

##### Functions

    fseek             X

       1: #if defined(LIBC_SCCS) && !defined(lint)
       2: static char sccsid[] = "@(#)fseek.c	5.3 (Berkeley) 3/9/86";
       3: #endif LIBC_SCCS and not lint
       4:
       5: /*
       6:  * Seek for standard library.  Coordinates with buffering.
       7:  */
       8:
       9: #include    <stdio.h>
      10:
      11: long lseek();
      12:
      13: fseek(iop, offset, ptrname)
      14:     register FILE *iop;
      15:     long offset;
      16: {
      17:     register resync, c;
      18:     long p = -1;            /* can't happen? */
      19:
      20:     iop->_flag &= ~_IOEOF;
      21:     if (iop->_flag&_IOREAD) {
      22:         if (ptrname<2 && iop->_base &&
      23:             !(iop->_flag&_IONBF)) {
      24:             c = iop->_cnt;
      25:             p = offset;
      26:             if (ptrname==0) {
      27:                 long curpos = lseek(fileno(iop), 0L, 1);
      28:                 if (curpos == -1)
      29:                     return (-1);
      30:                 p += c - curpos;
      31:             } else
      32:                 offset -= c;
      33:             if(!(iop->_flag&_IORW) && c>0&&p<=c
      34:                 && p>=iop->_base-iop->_ptr){
      35:                 iop->_ptr += (int)p;
      36:                 iop->_cnt -= (int)p;
      37:                 return(0);
      38:             }
      39:             resync = offset&01;
      40:         } else
      41:             resync = 0;
      42:         if (iop->_flag & _IORW) {
      43:             iop->_ptr = iop->_base;
      44:             iop->_flag &= ~_IOREAD;
      45:             resync = 0;
      46:         }
      47:         p = lseek(fileno(iop), offset-resync, ptrname);
      48:         iop->_cnt = 0;
      49:         if (resync && p != -1)
      50:             if (getc(iop) == EOF)
      51:                 p = -1;
      52:     }
      53:     else if (iop->_flag & (_IOWRT|_IORW)) {
      54:         p = fflush(iop);
      55:         if (iop->_flag & _IORW) {
      56:             iop->_cnt = 0;
      57:             iop->_flag &= ~_IOWRT;
      58:             iop->_ptr = iop->_base;
      59:         }
      60:         return(lseek(fileno(iop), offset, ptrname) == -1 || p == EOF ?
      61:             -1 : 0);
      62:     }
      63:     return(p==-1?-1:0);
      64: }

#### Defined functions

fseek defined in line 13; used 251 times

- in /usr/src/bin/adb/sym.c line 172, 184, 210, 341
- in /usr/src/bin/diff/diffreg.c line 321, 838, 946
- in /usr/src/bin/grep.c line 497
- in /usr/src/bin/mail.c line 159, 315-321(3), 357
- in /usr/src/bin/make/files.c line 470, 506
- in /usr/src/bin/nm/nm.c line 128, 149, 166, 268
- in /usr/src/bin/od.c line 846
- in /usr/src/bin/ps.c line 657, 671
- in /usr/src/bin/tar.c line 1028, 1109
- in /usr/src/bin/tcsh/mkprstr.c line 255
- in /usr/src/games/battlestar/mkstr.c line 250
- in /usr/src/games/fortune/fortune.c line 79, 85, 113, 130, 229
- in /usr/src/games/fortune/strfile.c line 135-136(2), 191, 324-325(2)
- in /usr/src/games/fortune/unstr.c line 57, 123
- in /usr/src/games/hangman/getword.c line 20
- in /usr/src/games/monop/cards.c line 71
- in /usr/src/games/monop/initdeck.c line 45, 57
- in /usr/src/games/phantasia/func0.c line 416
- in /usr/src/games/phantasia/func1.c line 46, 179, 226, 317, 325, 339
- in /usr/src/games/phantasia/func2.c line 213, 244, 516-518(2), 825
- in /usr/src/games/quiz/quiz.c line 353
- in /usr/src/games/sail/sync.c line 138, 182
- in /usr/src/games/warp/score.c line 639
- in /usr/src/lib/ccom/c11.c line 974
- in /usr/src/lib/ccom/cvopt.c line 343
- in /usr/src/lib/libc/gen/nlist.c line 57, 88
- in /usr/src/libexec/comsat/comsat.c line 204
- in /usr/src/libexec/ftpd/ftpd.c line 600
- in /usr/src/libexec/popper/pop_send.c line 61
- in /usr/src/libexec/popper/pop_updt.c line 127
- in /usr/src/local/mkovmake/mkovmake.c line 516, 552, 563, 576
- in /usr/src/new/OLD/buildcore.c line 67, 153
- in /usr/src/new/PORT/B/src/bint/b3err.c line 84
- in /usr/src/new/PORT/B/src/bint/b3fil.c line 169-171(2)
- in /usr/src/new/PORT/hexdump/display.c line 318
- in /usr/src/new/PORT/perl.1.0.0/arg.c line 501
- in /usr/src/new/PORT/perl.1.0.10/arg.c line 513
- in /usr/src/new/PORT/perl.1.0.16/arg.c line 532
- in /usr/src/new/jove/recover.c line 459, 466
- in /usr/src/new/l11/pass2.c line 77, 95, 741, 747, 849, 868, 878
- in /usr/src/new/m11/macxrf.c line 107
- in /usr/src/new/nntp/server/misc.c line 37, 189
- in /usr/src/new/nntp/server/newnews.c line 269-273(2), 296
- in /usr/src/new/nntp/support/mkgrdates.c line 83
- in /usr/src/new/notes/src/newsinput.c line 324
- in /usr/src/new/rn/addng.c line 109, 149
- in /usr/src/new/rn/art.c line 127, 650, 664
- in /usr/src/new/rn/artio.c line 41, 85, 118
- in /usr/src/new/rn/bits.c line 363
- in /usr/src/new/rn/cheat.c line 132
- in /usr/src/new/rn/common.h line 761
- in /usr/src/new/rn/head.c line 339
- in /usr/src/new/rn/init.c line 218, 226
- in /usr/src/new/rn/kfile.c line 81, 187, 272
- in /usr/src/new/rn/ngdata.c line 66, 160-161(2), 170
- in /usr/src/new/rn/respond.c line 343, 383
- in /usr/src/old/512dumpdir.c line 426
- in /usr/src/old/dump/dumpdir.c line 338
- in /usr/src/sbin/dump/dumpdir.c line 161, 180
- in /usr/src/sbin/quotacheck/quotacheck.c line 314
- in /usr/src/sbin/savecore/savecore.c line 175, 182, 192-195(2), 355
- in /usr/src/share/zoneinfo/zdump.c line 130-134(2)
- in /usr/src/share/zoneinfo/zic.c line 1022
- in /usr/src/sys/conf/netbind.c line 108-112(2), 127-131(2)
- in /usr/src/ucb/Mail/collect.c line 443, 485
- in /usr/src/ucb/Mail/edit.c line 109
- in /usr/src/ucb/Mail/fio.c line 188
- in /usr/src/ucb/Mail/quit.c line 114, 433
- in /usr/src/ucb/PORT/pascal/eyacc/ey5.c line 29
- in /usr/src/ucb/PORT/pascal/pdx/object/readobj.c line 43, 53
- in /usr/src/ucb/PORT/pascal/pdx/source/source.c line 88
- in /usr/src/ucb/PORT/pascal/px/int.c line 106
- in /usr/src/ucb/PORT/pascal/src/yyput.c line 156
- in /usr/src/ucb/PORT/pascal/utilities/pc3.c line 168, 202, 771
- in /usr/src/ucb/ctags.c line 646-651(2), 945-948(2)
- in /usr/src/ucb/ftp/ftp.c line 541, 928, 938
- in /usr/src/ucb/mkstr.c line 239
- in /usr/src/ucb/more/more.c line 42
- in /usr/src/ucb/msgs/msgs.c line 392, 537, 552, 629, 658, 728, 738, 789, 817
- in /usr/src/ucb/pascal/eyacc/ey5.c line 20
- in /usr/src/ucb/pascal/pi/yyput.c line 160
- in /usr/src/ucb/sendbug/unixtomh.c line 199
- in /usr/src/ucb/strcompact.c line 144
- in /usr/src/ucb/strings.c line 75-83(3)
- in /usr/src/ucb/symcompact.c line 106, 135, 160, 253
- in /usr/src/ucb/symdump.c line 73, 79, 88
- in /usr/src/ucb/symorder.c line 95, 171, 194
- in /usr/src/ucb/tftp/tftpsubs.c line 206
- in /usr/src/ucb/what.c line 41
- in /usr/src/ucb/xstr.c line 337
- in /usr/src/usr.bin/diff3/diff3.c line 406, 444
- in /usr/src/usr.bin/join.c line 120, 128-132(2)
- in /usr/src/usr.bin/learn/copy.c line 99
- in /usr/src/usr.bin/look.c line 60-64(2), 87
- in /usr/src/usr.bin/prof/prof.c line 213, 240, 263
- in /usr/src/usr.bin/ranlib/build.c line 151, 187, 214
- in /usr/src/usr.bin/refer/deliv1.c line 43
- in /usr/src/usr.bin/refer/hunt1.c line 145
- in /usr/src/usr.bin/refer/hunt2.c line 80, 122
- in /usr/src/usr.bin/refer/hunt5.c line 27
- in /usr/src/usr.bin/refer/hunt6.c line 47, 126
- in /usr/src/usr.bin/refer/hunt7.c line 102
- in /usr/src/usr.bin/refer/inv5.c line 48
- in /usr/src/usr.bin/refer/mkey2.c line 96
- in /usr/src/usr.bin/refer/sortbib.c line 150
- in /usr/src/usr.bin/struct/1.form.c line 201
- in /usr/src/usr.bin/uucp/acucntrl.c line 456
- in /usr/src/usr.bin/uucp/aculib/mic.c line 31
- in /usr/src/usr.bin/uucp/anlwrk.c line 73-75(2)
- in /usr/src/usr.bin/uucp/fio.c line 228, 300
- in /usr/src/usr.lib/libI77/backspace.c line 48-54(3)
- in /usr/src/usr.lib/libI77/c_dfe.c line 39, 50, 60, 67
- in /usr/src/usr.lib/libI77/c_sfe.c line 50-55(2)
- in /usr/src/usr.lib/libI77/due.c line 57, 72
- in /usr/src/usr.lib/libI77/open.c line 114
- in /usr/src/usr.lib/libI77/rdfe.c line 81
- in /usr/src/usr.lib/libI77/sue.c line 44, 76-78(2), 84
- in /usr/src/usr.lib/libI77/util.c line 42, 48, 72
- in /usr/src/usr.lib/libI77/wdfe.c line 55
- in /usr/src/usr.lib/libI77/wsfe.c line 72, 79
- in /usr/src/usr.lib/libU77/fseek_.c line 38
- in /usr/src/usr.sbin/cron/env.c line 133
- in /usr/src/usr.sbin/inetd/inetd.c line 706
- in /usr/src/usr.sbin/lpr/filters/vfw.c line 33
- in /usr/src/usr.sbin/lpr/printjob.c line 379, 690

#### Defined variables

sccsid defined in line 2; never used

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