]> pd.if.org Git - pdclib/blob - functions/stdio/fputs.c
Added some functions.
[pdclib] / 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
13 int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
14 {
15     /* FIXME: This is devoid of any error checking (file writeable? r/w
16        constraints honored?)
17     */
18     /* FIXME: Proper buffering handling. */
19     while ( stream->bufidx < stream->bufsize )
20     {
21         if ( ( stream->buffer[stream->bufidx++] = *(s++) ) == '\0' )
22         {
23             break;
24         }
25     }
26     fflush( stream );
27     if ( *(s-1) != '\0' )
28     {
29         return fputs( s, stream );
30     }
31     else
32     {
33         return 1;
34     }
35 }
36
37 #endif
38
39 #ifdef TEST
40 #include <_PDCLIB_test.h>
41
42 int main( void )
43 {
44     TESTCASE( NO_TESTDRIVER );
45     return TEST_RESULTS;
46 }
47
48 #endif