Last change
on this file since 6dd74a9 was 0580615, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Point of no return.
|
-
Property mode
set to
100644
|
File size:
1.0 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 |
|
---|
[0580615] | 13 | extern long lseek(int fd, long pos, int how);
|
---|
[6d3de83] | 14 |
|
---|
[f40a309] | 15 | /*
|
---|
| 16 | =============================================================================
|
---|
| 17 | fseek(fp, pos, mode) -- position file 'fp' at 'pos' in mode 'mode'.
|
---|
| 18 | =============================================================================
|
---|
| 19 | */
|
---|
| 20 |
|
---|
[0580615] | 21 | int fseek(FILE *fp, long pos, int mode)
|
---|
[f40a309] | 22 | {
|
---|
| 23 | register int i, lr;
|
---|
[6d3de83] | 24 | long 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)
|
---|
| 34 | pos -= (long)fp->_bend - (long)fp->_bp;
|
---|
| 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.