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

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

Added include files for global functions and variables.

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