Stub out most of stdio on AltOS
[fw/pdclib] / platform / altos / functions / stdio / fputs.c
1 /* $Id$ */
2
3 /* fputs( const char *, FILE * )
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 #include <stdio.h>
10
11 #ifndef REGTEST
12 #include <_PDCLIB_glue.h>
13
14 int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
15 {
16     char c;
17
18     while ((c = *s++))
19         if (putc(stream, c) != c)
20             return EOF;
21     return 0;
22 }
23
24 #endif
25 #ifdef TEST
26 #include <_PDCLIB_test.h>
27
28 int main( void )
29 {
30     char const * const message = "SUCCESS testing fputs()";
31     FILE * fh;
32     TESTCASE( ( fh = tmpfile() ) != NULL );
33     TESTCASE( fputs( message, fh ) >= 0 );
34     rewind( fh );
35     for ( size_t i = 0; i < 23; ++i )
36     {
37         TESTCASE( fgetc( fh ) == message[i] );
38     }
39     TESTCASE( fclose( fh ) == 0 );
40     return TEST_RESULTS;
41 }
42
43 #endif
44