|
Last change
on this file since bc11fc1 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
|
Use standard integer types.
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [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 |
|
|---|
| 8 | #include "stdio.h"
|
|---|
| 9 | #include "biosdefs.h"
|
|---|
| 10 | #include "io.h"
|
|---|
| 11 | #include "stddefs.h"
|
|---|
| 12 |
|
|---|
| [7258c6a] | 13 | extern int32_t lseek(int16_t fd, int32_t pos, int16_t how);
|
|---|
| [6d3de83] | 14 |
|
|---|
| [f40a309] | 15 | /*
|
|---|
| 16 | =============================================================================
|
|---|
| 17 | fseek(fp, pos, mode) -- position file 'fp' at 'pos' in mode 'mode'.
|
|---|
| 18 | =============================================================================
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| [7258c6a] | 21 | int16_t fseek(FILE *fp, int32_t pos, int16_t mode)
|
|---|
| [f40a309] | 22 | {
|
|---|
| [7258c6a] | 23 | register int16_t i, lr;
|
|---|
| 24 | int32_t curpos;
|
|---|
| [f40a309] | 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)
|
|---|
| [7258c6a] | 34 | pos -= (int32_t)fp->_bend - (int32_t)fp->_bp;
|
|---|
| [f40a309] | 35 | }
|
|---|
| 36 |
|
|---|
| 37 | fp->_bp = fp->_bend = NULL;
|
|---|
| 38 | fp->_flags &= ~_EOF;
|
|---|
| 39 |
|
|---|
| 40 | lr = lseek(fp->_unit, pos, mode);
|
|---|
| 41 |
|
|---|
| [df097bf] | 42 | if (((struct fcb *)chantab[fp->_unit].c_arg)->modefl & FC_EOF)
|
|---|
| [f40a309] | 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.