Stub out most of stdio on AltOS
[fw/pdclib] / platform / altos / functions / stdio / puts.c
1 /* $Id$ */
2
3 /* puts( const char * )
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
13 int puts( const char * s )
14 {
15     char        c;
16
17     while ((c = *s++))
18         if (putchar (c) != c)
19             return EOF;
20     if (putchar('\n') != '\n')
21         return EOF;
22     return 0;
23 }
24
25 #endif
26
27 #ifdef TEST
28 #include <_PDCLIB_test.h>
29
30 int main( void )
31 {
32     FILE * fh;
33     char const * message = "SUCCESS testing puts()";
34     char buffer[23];
35     buffer[22] = 'x';
36     TESTCASE( ( fh = freopen( testfile, "wb+", stdout ) ) != NULL );
37     TESTCASE( puts( message ) >= 0 );
38     rewind( fh );
39     TESTCASE( fread( buffer, 1, 22, fh ) == 22 );
40     TESTCASE( memcmp( buffer, message, 22 ) == 0 );
41     TESTCASE( buffer[22] == 'x' );
42     TESTCASE( fclose( fh ) == 0 );
43     TESTCASE( remove( testfile ) == 0 );
44     return TEST_RESULTS;
45 }
46
47 #endif
48