2c54ce0d941506d23d565a96b46545d1f638103b
[fw/pdclib] / platform / altos / functions / _PDCLIB / flushbuffer.c
1 /* $Id$ */
2
3 /* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 /* This is an example implementation of _PDCLIB_flushbuffer() fit for
10    use with POSIX kernels.
11 */
12
13 #include <stdio.h>
14
15 #ifndef REGTEST
16 #include <_PDCLIB_glue.h>
17
18 /* The number of attempts to complete an output buffer flushing before giving
19  *    up.
20  *    */
21 #define _PDCLIB_IO_RETRIES 1
22
23 /* What the system should do after an I/O operation did not succeed, before   */
24 /* trying again. (Empty by default.)                                          */
25 #define _PDCLIB_IO_RETRY_OP( stream )
26
27 /* Must be provided by host system */
28 extern void outbyte(char c);
29
30 int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )
31 {
32         char *c = stream->buffer;
33         int i = stream->bufidx;
34         while (i--)
35                 outbyte(*c++);
36         return 0;
37 }
38
39 #endif
40
41
42 #ifdef TEST
43 #include <_PDCLIB_test.h>
44
45 int main( void )
46 {
47     /* Testing covered by ftell.c */
48     return TEST_RESULTS;
49 }
50
51 #endif
52