1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
8 int fseek( FILE * stream, long offset, int mode ) { /* TODO */ };
10 /* PDPC code - unreviewed
11 Read the note in fopen.c.
19 if (stream->mode == __WRITE_MODE)
23 if (whence == SEEK_SET)
27 else if (whence == SEEK_CUR)
29 newpos = offset + stream->bufStartR + (stream->upto - stream->fbuf);
31 if ((newpos > stream->bufStartR)
32 && (newpos < (stream->bufStartR + (stream->endbuf - stream->fbuf)))
35 stream->upto = stream->fbuf + (size_t)(newpos - stream->bufStartR);
40 rc = DosSetFilePtr(stream->hfile, newpos, FILE_BEGIN, &retpos);
41 if ((rc != 0) || (retpos != newpos))
48 stream->endbuf = stream->fbuf + stream->szfbuf;
49 stream->upto = stream->endbuf;
50 stream->bufStartR = newpos - stream->szfbuf;
54 __seek(stream->hfile, newpos, whence);
55 stream->endbuf = stream->fbuf + stream->szfbuf;
56 stream->upto = stream->endbuf;
57 stream->bufStartR = newpos - stream->szfbuf;
61 stream->quickText = 0;