• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* printf.c
2  *
3  * $Id: printf.c,v 1.1 2008/08/11 22:41:55 keithmarshall Exp $
4  *
5  * Provides an implementation of the "printf" 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 <keithmarshall@users.sourceforge.net>
12  *
13  * This implementation of "printf" will normally be invoked by calling
14  * "__mingw_printf()" in preference to a direct reference to "printf()"
15  * itself; this leaves the MSVCRT implementation as the default, which
16  * will be deployed when user code invokes "print()".  Users who then
17  * wish to use this implementation may either call "__mingw_printf()"
18  * directly, or may use conditional preprocessor defines, to redirect
19  * references to "printf()" to "__mingw_printf()".
20  *
21  * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this
22  * recommended convention, such that references to "printf()" in user
23  * code will ALWAYS be redirected to "__mingw_printf()"; if this option
24  * is adopted, then users wishing to use the MSVCRT implementation of
25  * "printf()" 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_printf()"; 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 __printf(const APICHAR *, ...) __MINGW_NOTHROW;
48 
__printf(const APICHAR * fmt,...)49 int __cdecl __printf(const APICHAR *fmt, ...)
50 {
51   register int retval;
52   va_list argv; va_start( argv, fmt );
53   _lock_file( stdout );
54   retval = __pformat( PFORMAT_TO_FILE | PFORMAT_NOLIMIT, stdout, 0, fmt, argv );
55   _unlock_file( stdout );
56   va_end( argv );
57   return retval;
58 }
59 
60