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

Last change on this file since 6262b5c 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
RevLine 
[f40a309]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
[6262b5c]8#include "all.h"
[f40a309]9
[7258c6a]10extern int32_t lseek(int16_t fd, int32_t pos, int16_t how);
[6d3de83]11
[e225e77]12extern int16_t flush_(FILE *ptr, int16_t data);
13
[f40a309]14/*
15 =============================================================================
16 fseek(fp, pos, mode) -- position file 'fp' at 'pos' in mode 'mode'.
17 =============================================================================
18*/
19
[7258c6a]20int16_t fseek(FILE *fp, int32_t pos, int16_t mode)
[f40a309]21{
[7258c6a]22 register int16_t i, lr;
23 int32_t curpos;
[f40a309]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)
[7258c6a]33 pos -= (int32_t)fp->_bend - (int32_t)fp->_bp;
[f40a309]34 }
35
36 fp->_bp = fp->_bend = NULL;
37 fp->_flags &= ~_EOF;
38
39 lr = lseek(fp->_unit, pos, mode);
40
[df097bf]41 if (((struct fcb *)chantab[fp->_unit].c_arg)->modefl & FC_EOF)
[f40a309]42 fp->_flags |= _EOF;
43
44 if (lr < 0)
45 return(EOF);
46
47 return(0);
48}
49
[6262b5c]50
Note: See TracBrowser for help on using the repository browser.