X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=platform%2Faltos%2Ffunctions%2F_PDCLIB%2Fflushbuffer.c;fp=platform%2Faltos%2Ffunctions%2F_PDCLIB%2Fflushbuffer.c;h=2c54ce0d941506d23d565a96b46545d1f638103b;hb=d58957de3e0b9b7076a6f5dd49d5df8e78f5a826;hp=0000000000000000000000000000000000000000;hpb=6225e295ec21ab2e47ab4cd153921221bc05a2b0;p=fw%2Fpdclib diff --git a/platform/altos/functions/_PDCLIB/flushbuffer.c b/platform/altos/functions/_PDCLIB/flushbuffer.c new file mode 100644 index 0000000..2c54ce0 --- /dev/null +++ b/platform/altos/functions/_PDCLIB/flushbuffer.c @@ -0,0 +1,52 @@ +/* $Id$ */ + +/* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +/* This is an example implementation of _PDCLIB_flushbuffer() fit for + use with POSIX kernels. +*/ + +#include + +#ifndef REGTEST +#include <_PDCLIB_glue.h> + +/* The number of attempts to complete an output buffer flushing before giving + * up. + * */ +#define _PDCLIB_IO_RETRIES 1 + +/* What the system should do after an I/O operation did not succeed, before */ +/* trying again. (Empty by default.) */ +#define _PDCLIB_IO_RETRY_OP( stream ) + +/* Must be provided by host system */ +extern void outbyte(char c); + +int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream ) +{ + char *c = stream->buffer; + int i = stream->bufidx; + while (i--) + outbyte(*c++); + return 0; +} + +#endif + + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by ftell.c */ + return TEST_RESULTS; +} + +#endif +