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

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

Added missing includes and declarations.

  • Property mode set to 100644
File size: 1.1 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 int32_t lseek(int16_t fd, int32_t pos, int16_t how);
14
15extern int16_t flush_(FILE *ptr, int16_t data);
16
17/*
18 =============================================================================
19 fseek(fp, pos, mode) -- position file 'fp' at 'pos' in mode 'mode'.
20 =============================================================================
21*/
22
23int16_t fseek(FILE *fp, int32_t pos, int16_t mode)
24{
25 register int16_t i, lr;
26 int32_t curpos;
27
28 if (fp->_flags & _DIRTY) {
29
30 if (flush_(fp, -1))
31 return(EOF);
32
33 } else {
34
35 if (mode EQ 1 AND fp->_bp)
36 pos -= (int32_t)fp->_bend - (int32_t)fp->_bp;
37 }
38
39 fp->_bp = fp->_bend = NULL;
40 fp->_flags &= ~_EOF;
41
42 lr = lseek(fp->_unit, pos, mode);
43
44 if (((struct fcb *)chantab[fp->_unit].c_arg)->modefl & FC_EOF)
45 fp->_flags |= _EOF;
46
47 if (lr < 0)
48 return(EOF);
49
50 return(0);
51}
52
Note: See TracBrowser for help on using the repository browser.