X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fflushbuffer.c;h=3ed891f159987aba96086bcf67948c32db5c3d16;hb=3044c7be997666943201e01b1a429833e826694f;hp=c2ac98d8ef8aac286460ede9a2e4aa8dcf326e7e;hpb=393020b6e48719d27699dea6b29e53025bbd5123;p=pdclib diff --git a/platform/example/functions/_PDCLIB/flushbuffer.c b/platform/example/functions/_PDCLIB/flushbuffer.c index c2ac98d..3ed891f 100644 --- a/platform/example/functions/_PDCLIB/flushbuffer.c +++ b/platform/example/functions/_PDCLIB/flushbuffer.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * ) This file is part of the Public Domain C Library (PDCLib). @@ -14,7 +12,8 @@ #include #ifndef REGTEST -#include <_PDCLIB_glue.h> + +#include "_PDCLIB_glue.h" #include @@ -50,6 +49,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ) /* Write error */ switch ( errno ) { + /* See <_PDCLIB_config.h>. There should be differenciated errno + handling here, possibly even a 1:1 mapping; but that is up + to the individual platform. + */ case EBADF: case EFAULT: case EFBIG: @@ -58,10 +61,11 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ) case EIO: case ENOSPC: case EPIPE: - _PDCLIB_errno = _PDCLIB_EIO; + _PDCLIB_errno = _PDCLIB_ERROR; break; default: - _PDCLIB_errno = _PDCLIB_EUNKNOWN; + /* This should be something like EUNKNOWN. */ + _PDCLIB_errno = _PDCLIB_ERROR; break; } stream->status |= _PDCLIB_ERRORFLAG; @@ -79,7 +83,10 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ) return 0; } } - _PDCLIB_errno = _PDCLIB_ERETRY; + /* Number of retries exceeded. You probably want a different errno value + here. + */ + _PDCLIB_errno = _PDCLIB_ERROR; stream->status |= _PDCLIB_ERRORFLAG; /* Move unwritten remains to begin of buffer. */ stream->bufidx -= written; @@ -89,9 +96,9 @@ int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ) #endif - #ifdef TEST -#include <_PDCLIB_test.h> + +#include "_PDCLIB_test.h" int main( void ) { @@ -100,4 +107,3 @@ int main( void ) } #endif -