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

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

No more warnings in libcio.

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