X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffseek.c;h=f33f250938a0e1cdaaa7fddbe6f971b2e8d52b3a;hb=e8945ee2684f5c8de0104ea183de2010ae72ffd5;hp=b4e76b9cbab17e4cea0c85372e0816fb16d42c2f;hpb=e5456e3c2697c4e17fc9aa3439f2e305517b4d96;p=pdclib.old diff --git a/functions/stdio/fseek.c b/functions/stdio/fseek.c index b4e76b9..f33f250 100644 --- a/functions/stdio/fseek.c +++ b/functions/stdio/fseek.c @@ -1,65 +1,30 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* $Id$ */ -int fseek( FILE * stream, long offset, int mode ) { /* TODO */ }; +/* fseek( FILE *, long int, int ) -/* PDPC code - unreviewed -Read the note in fopen.c. + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int fseek( struct _PDCLIB_file_t * stream, long int offset, int whence ) { - long newpos; -#ifdef __OS2__ - ULONG retpos; - APIRET rc; -#endif + /* TODO: Implement. */ + return 0; +} - if (stream->mode == __WRITE_MODE) - { - fflush(stream); - } - if (whence == SEEK_SET) - { - newpos = offset; - } - else if (whence == SEEK_CUR) - { - newpos = offset + stream->bufStartR + (stream->upto - stream->fbuf); - } - if ((newpos > stream->bufStartR) - && (newpos < (stream->bufStartR + (stream->endbuf - stream->fbuf))) - && stream->update) - { - stream->upto = stream->fbuf + (size_t)(newpos - stream->bufStartR); - } - else - { -#ifdef __OS2__ - rc = DosSetFilePtr(stream->hfile, newpos, FILE_BEGIN, &retpos); - if ((rc != 0) || (retpos != newpos)) - { - errno = rc; - return (-1); - } - else - { - stream->endbuf = stream->fbuf + stream->szfbuf; - stream->upto = stream->endbuf; - stream->bufStartR = newpos - stream->szfbuf; - } -#endif -#ifdef __MSDOS - __seek(stream->hfile, newpos, whence); - stream->endbuf = stream->fbuf + stream->szfbuf; - stream->upto = stream->endbuf; - stream->bufStartR = newpos - stream->szfbuf; #endif - } - stream->quickBin = 0; - stream->quickText = 0; - stream->ungetCh = -1; - return (0); + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE( NO_TESTDRIVER ); + return TEST_RESULTS; } -*/ + +#endif