X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fwin32%2Ffunctions%2F_PDCLIB%2F_PDCLIB_fillbuffer.c;fp=platform%2Fwin32%2Ffunctions%2F_PDCLIB%2F_PDCLIB_fillbuffer.c;h=c6a2b6b520f436a6f5a1433d1f5483e3eec1ebeb;hb=d8928b5f31bbdac23f9ec296ef28b4b10efa31d5;hp=0000000000000000000000000000000000000000;hpb=219271fd548949abce8bd75c34dd42e519418fc4;p=pdclib diff --git a/platform/win32/functions/_PDCLIB/_PDCLIB_fillbuffer.c b/platform/win32/functions/_PDCLIB/_PDCLIB_fillbuffer.c new file mode 100644 index 0000000..c6a2b6b --- /dev/null +++ b/platform/win32/functions/_PDCLIB/_PDCLIB_fillbuffer.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +/* This is a stub version of _PDCLIB_fillbuffer +*/ + +#include + +#ifndef REGTEST +#include <_PDCLIB_glue.h> +#include +#include + +void _PDCLIB_w32errno(void); +int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream ) +{ + DWORD nBytesRead; + BOOL ok = ReadFile( stream->handle, stream->buffer, stream->bufsize, + &nBytesRead, NULL ); + + if( ok ) { + if( nBytesRead == 0 ) { + stream->status |= _PDCLIB_EOFFLAG; + return EOF; + } + stream->pos.offset += nBytesRead; + stream->bufend = nBytesRead; + stream->bufidx = 0; + return 0; + } else { + _PDCLIB_w32errno(); + stream->status |= _PDCLIB_ERRORFLAG; + return EOF; + } +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif +