source: buchla-68k/libcio/fseek.c@ 6d3de83

Last change on this file since 6d3de83 was 6d3de83, checked in by Thomas Lopatic <thomas@…>, 7 years ago

No local function declarations.

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 =============================================================================
3 fseek.c -- perform a seek on a stream file
4 Version 4 -- 1987-10-28 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stdio.h"
9#include "biosdefs.h"
10#include "io.h"
11#include "stddefs.h"
12
13extern long lseek();
14
15/*
16 =============================================================================
17 fseek(fp, pos, mode) -- position file 'fp' at 'pos' in mode 'mode'.
18 =============================================================================
19*/
20
21fseek(fp, pos, mode)
22register FILE *fp;
23long pos;
24int mode;
25{
26 register int i, lr;
27 long curpos;
28
29 if (fp->_flags & _DIRTY) {
30
31 if (flush_(fp, -1))
32 return(EOF);
33
34 } else {
35
36 if (mode EQ 1 AND fp->_bp)
37 pos -= (long)fp->_bend - (long)fp->_bp;
38 }
39
40 fp->_bp = fp->_bend = NULL;
41 fp->_flags &= ~_EOF;
42
43 lr = lseek(fp->_unit, pos, mode);
44
45 if (((struct fcb *)chantab[fp->_unit].c_arg)->modefl & FC_EOF)
46 fp->_flags |= _EOF;
47
48 if (lr < 0)
49 return(EOF);
50
51 return(0);
52}
53
Note: See TracBrowser for help on using the repository browser.