|
| 1 | +/* fprintf.c |
| 2 | + * |
| 3 | + * $Id: fprintf.c,v 1.1 2008/08/11 22:41:55 keithmarshall Exp $ |
| 4 | + * |
| 5 | + * Provides an implementation of the "fprintf" function, conforming |
| 6 | + * generally to C99 and SUSv3/POSIX specifications, with extensions |
| 7 | + * to support Microsoft's non-standard format specifications. This |
| 8 | + * is included in libmingwex.a, whence it may replace the Microsoft |
| 9 | + * function of the same name. |
| 10 | + * |
| 11 | + * Written by Keith Marshall <[email protected]> |
| 12 | + * |
| 13 | + * This implementation of "fprintf" will normally be invoked by calling |
| 14 | + * "__mingw_fprintf()" in preference to a direct reference to "fprintf()" |
| 15 | + * itself; this leaves the MSVCRT implementation as the default, which |
| 16 | + * will be deployed when user code invokes "fprint()". Users who then |
| 17 | + * wish to use this implementation may either call "__mingw_fprintf()" |
| 18 | + * directly, or may use conditional preprocessor defines, to redirect |
| 19 | + * references to "fprintf()" to "__mingw_fprintf()". |
| 20 | + * |
| 21 | + * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this |
| 22 | + * recommended convention, such that references to "fprintf()" in user |
| 23 | + * code will ALWAYS be redirected to "__mingw_fprintf()"; if this option |
| 24 | + * is adopted, then users wishing to use the MSVCRT implementation of |
| 25 | + * "fprintf()" will be forced to use a "back-door" mechanism to do so. |
| 26 | + * Such a "back-door" mechanism is provided with MinGW, allowing the |
| 27 | + * MSVCRT implementation to be called as "__msvcrt_fprintf()"; however, |
| 28 | + * since users may not expect this behaviour, a standard libmingwex.a |
| 29 | + * installation does not employ this option. |
| 30 | + * |
| 31 | + * |
| 32 | + * This is free software. You may redistribute and/or modify it as you |
| 33 | + * see fit, without restriction of copyright. |
| 34 | + * |
| 35 | + * This software is provided "as is", in the hope that it may be useful, |
| 36 | + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of |
| 37 | + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no |
| 38 | + * time will the author accept any form of liability for any damages, |
| 39 | + * however caused, resulting from the use of this software. |
| 40 | + * |
| 41 | + */ |
| 42 | +#include <stdio.h> |
| 43 | +#include <stdarg.h> |
| 44 | + |
| 45 | +#include "mingw_pformat.h" |
| 46 | + |
| 47 | +int __cdecl __fprintf (FILE *, const APICHAR *, ...) __MINGW_NOTHROW; |
| 48 | + |
| 49 | +int __cdecl __fprintf(FILE *stream, const APICHAR *fmt, ...) |
| 50 | +{ |
| 51 | + register int retval; |
| 52 | + va_list argv; va_start( argv, fmt ); |
| 53 | + _lock_file( stream ); |
| 54 | + retval = __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stream, 0, fmt, argv ); |
| 55 | + _unlock_file( stream ); |
| 56 | + va_end( argv ); |
| 57 | + return retval; |
| 58 | +} |
0 commit comments