X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Ffillbuffer.c;h=c961f48dfdeb92c607e3ed3f29549de8be9526eb;hb=e0a1864c7e4dbd4d482379b1bb6fd56b5ac68617;hp=a5520a34f43b0bc770862568a88d2ba37b5547df;hpb=ce0e5d8cd76b50f239fb8e95170502b146247b35;p=pdclib diff --git a/platform/example/functions/_PDCLIB/fillbuffer.c b/platform/example/functions/_PDCLIB/fillbuffer.c index a5520a3..c961f48 100644 --- a/platform/example/functions/_PDCLIB/fillbuffer.c +++ b/platform/example/functions/_PDCLIB/fillbuffer.c @@ -6,60 +6,18 @@ Permission is granted to use, modify, and / or redistribute at will. */ -/* This is an example implementation of _PDCLIB_fillbuffer() fit for - use with POSIX kernels. +/* This is a stub version of _PDCLIB_fillbuffer */ #include #ifndef REGTEST #include <_PDCLIB_glue.h> - -#include - -typedef long ssize_t; -extern ssize_t read( int fd, void * buf, size_t count ); +#include int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream ) { - /* No need to handle buffers > INT_MAX, as PDCLib doesn't allow them */ - ssize_t rc = read( stream->handle, stream->buffer, stream->bufsize ); - if ( rc > 0 ) - { - /* Reading successful. */ - if ( ! ( stream->status & _PDCLIB_FBIN ) ) - { - /* TODO: Text stream conversion here */ - } - stream->pos.offset += rc; - stream->bufend = rc; - stream->bufidx = 0; - return 0; - } - if ( rc < 0 ) - { - /* Reading error */ - switch ( errno ) - { - /* See comments on implementation-defined errno values in - <_PDCLIB_config.h>. - */ - case EBADF: - case EFAULT: - case EINTR: - case EINVAL: - case EIO: - _PDCLIB_errno = _PDCLIB_ERROR; - break; - default: - /* This should probably be something like EUNKNOWN. */ - _PDCLIB_errno = _PDCLIB_ERROR; - break; - } - stream->status |= _PDCLIB_ERRORFLAG; - return EOF; - } - /* End-of-File */ + errno = ENOTSUP; stream->status |= _PDCLIB_EOFFLAG; return EOF; }