X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=includes%2Fstdio.h;h=560b4f2687b4fcaafa077ea852db748181f4e1a5;hb=9f87d9e27e74d9e06e0c93114ffd70a45ee152fa;hp=4a029a01f493824aacf820c8b19246e9d037cc18;hpb=cf36f1e20754bd66d6504a1c082bc317ed3e8186;p=pdclib diff --git a/includes/stdio.h b/includes/stdio.h index 4a029a0..560b4f2 100644 --- a/includes/stdio.h +++ b/includes/stdio.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Input/output +/* 7.19 Input/output This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. @@ -9,10 +9,7 @@ #ifndef _PDCLIB_STDIO_H #define _PDCLIB_STDIO_H _PDCLIB_STDIO_H -#ifndef _PDCLIB_INT_H -#define _PDCLIB_INT_H _PDCLIB_INT_H #include <_PDCLIB_int.h> -#endif #ifndef _PDCLIB_SIZE_T_DEFINED #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED @@ -52,17 +49,18 @@ extern FILE * stderr; /* Remove the given file. Returns zero if successful, non-zero otherwise. - This implementation does detect if the filename corresponds to an open file, - and closes it before attempting the rename. + This implementation does detect if a file of that name is currently open, + and fails the remove in this case. This does not detect two distinct names + that merely result in the same file (e.g. "/home/user/foo" vs. "~/foo"). */ int remove( const char * filename ); /* Rename the given old file to the given new name. Returns zero if successful, non-zero otherwise. This implementation does detect if the old filename corresponds to an open - file, and closes it before attempting the rename. - If the already is a file with the new filename, behaviour is defined by the - OS. + file, and fails the rename in this case. + If there already is a file with the new filename, behaviour is defined by + the glue code (see functions/_PDCLIB/rename.c). */ int rename( const char * old, const char * new ); @@ -161,7 +159,9 @@ FILE * fopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restr identified by the given filename with the given mode (equivalent to fopen()), and associate it with the given stream. If filename is a NULL pointer, attempt to change the mode of the given stream. - This implementation allows the following mode changes: TODO + This implementation allows any mode changes on "real" files, and associating + of the standard streams with files. It does *not* support mode changes on + standard streams. (Primary use of this function is to redirect stdin, stdout, and stderr.) */ FILE * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, FILE * _PDCLIB_restrict stream ); @@ -651,13 +651,13 @@ int fputc( int c, FILE * stream ); */ int fputs( const char * _PDCLIB_restrict s, FILE * _PDCLIB_restrict stream ); -/* Equivalent to fgetc( stream ), but may be implemented as a macro that +/* Equivalent to fgetc( stream ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define getc( stream ) fgetc( stream ) +int getc( FILE * stream ); -/* Equivalent to fgetc( stdin ), but may be implemented as a macro. */ -#define getchar() fgetc( stdin ) +/* Equivalent to fgetc( stdin ). */ +int getchar( void ); /* Read characters from given stream into the array s, stopping at \n or EOF. The string read is terminated with \0. Returns s if successful. If EOF is @@ -667,15 +667,15 @@ int fputs( const char * _PDCLIB_restrict s, FILE * _PDCLIB_restrict stream ); */ char * gets( char * s ); -/* Equivalent to fputc( c, stream ), but may be implemented as a macro that +/* Equivalent to fputc( c, stream ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define putc( c, stream ) fputc( c, stream ) +int putc( int c, FILE * stream ); -/* Equivalent to fputc( c, stdout ), but may be implemented as a macro that +/* Equivalent to fputc( c, stdout ), but may be overloaded by a macro that evaluates its parameter more than once. */ -#define putchar( c ) putc( c, stdout ) +int putchar( int c ); /* Write the string s (not including the terminating \0) to stdout, and append a newline to the output. Returns a value >= 0 when successful, EOF if a