X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffputs.c;fp=functions%2Fstdio%2Ffputs.c;h=716fef838b5ebddaba629c760c52e777f268eadb;hb=a6dd99e5c0b3af81082d24751218c21f7f3e7443;hp=0000000000000000000000000000000000000000;hpb=725b1cc72b121ef663aaf23bdaa1a512ae45adb6;p=pdclib.old diff --git a/functions/stdio/fputs.c b/functions/stdio/fputs.c new file mode 100644 index 0000000..716fef8 --- /dev/null +++ b/functions/stdio/fputs.c @@ -0,0 +1,48 @@ +/* $Id$ */ + +/* fputs( const char *, FILE * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) +{ + /* FIXME: This is devoid of any error checking (file writeable? r/w + constraints honored?) + */ + /* FIXME: Proper buffering handling. */ + while ( stream->bufidx < stream->bufsize ) + { + if ( ( stream->buffer[stream->bufidx++] = *(s++) ) == '\0' ) + { + break; + } + } + fflush( stream ); + if ( *(s-1) != '\0' ) + { + return fputs( s, stream ); + } + else + { + return 1; + } +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE( NO_TESTDRIVER ); + return TEST_RESULTS; +} + +#endif