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

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

Use standard integer types.

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