msvcrt: Implement vfprintf_s and vfwprintf_s.

This commit is contained in:
Eryk Wieliczko 2010-11-24 21:12:35 +01:00 committed by Alexandre Julliard
parent ab2e5c0499
commit 8bf437d827
7 changed files with 80 additions and 11 deletions

View File

@ -1617,9 +1617,9 @@
@ cdecl ungetc(long ptr) msvcrt.ungetc
@ cdecl ungetwc(long ptr) msvcrt.ungetwc
@ cdecl vfprintf(ptr str ptr) msvcrt.vfprintf
@ stub vfprintf_s
@ cdecl vfprintf_s(ptr str ptr) msvcrt.vfprintf_s
@ cdecl vfwprintf(ptr wstr ptr) msvcrt.vfwprintf
@ stub vfwprintf_s
@ cdecl vfwprintf_s(ptr wstr ptr) msvcrt.vfwprintf_s
@ cdecl vprintf(str ptr) msvcrt.vprintf
@ stub vprintf_s
@ cdecl vsprintf(ptr str ptr) msvcrt.vsprintf

View File

@ -1471,9 +1471,9 @@
@ cdecl ungetc(long ptr) msvcrt.ungetc
@ cdecl ungetwc(long ptr) msvcrt.ungetwc
@ cdecl vfprintf(ptr str ptr) msvcrt.vfprintf
@ stub vfprintf_s
@ cdecl vfprintf_s(ptr str ptr) msvcrt.vfprintf_s
@ cdecl vfwprintf(ptr wstr ptr) msvcrt.vfwprintf
@ stub vfwprintf_s
@ cdecl vfwprintf_s(ptr wstr ptr) msvcrt.vfwprintf_s
@ cdecl vprintf(str ptr) msvcrt.vprintf
@ stub vprintf_s
@ cdecl vsprintf(ptr str ptr) msvcrt.vsprintf

View File

@ -1455,9 +1455,9 @@
@ cdecl ungetc(long ptr) msvcrt.ungetc
@ cdecl ungetwc(long ptr) msvcrt.ungetwc
@ cdecl vfprintf(ptr str ptr) msvcrt.vfprintf
@ stub vfprintf_s
@ cdecl vfprintf_s(ptr str ptr) msvcrt.vfprintf_s
@ cdecl vfwprintf(ptr wstr ptr) msvcrt.vfwprintf
@ stub vfwprintf_s
@ cdecl vfwprintf_s(ptr wstr ptr) msvcrt.vfwprintf_s
@ cdecl vprintf(str ptr) msvcrt.vprintf
@ stub vprintf_s
@ cdecl vsprintf(ptr str ptr) msvcrt.vsprintf

View File

@ -3361,11 +3361,47 @@ int CDECL MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, __ms_va_list va
return retval;
}
/*********************************************************************
* vfprintf_s (MSVCRT.@)
*/
int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list valist)
{
char buf[2048];
LPWSTR formatW = NULL;
DWORD sz;
pf_output out;
int written, retval;
if( !MSVCRT_CHECK_PMT( file != NULL ) )
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
out.unicode = FALSE;
out.buf.A = out.grow.A = buf;
out.used = 0;
out.len = sizeof(buf);
sz = MultiByteToWideChar( CP_ACP, 0, format, -1, NULL, 0 );
formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
if ((written = pf_vsnprintf( &out, formatW, NULL, TRUE, valist )) >= 0)
{
retval = MSVCRT_fwrite(out.buf.A, sizeof(*out.buf.A), written, file);
}
else retval = -1;
HeapFree( GetProcessHeap(), 0, formatW );
if (out.buf.A != out.grow.A)
MSVCRT_free (out.buf.A);
return retval;
}
/*********************************************************************
* vfwprintf (MSVCRT.@)
* FIXME:
* Is final char included in written (then resize is too big) or not
* (then we must test for equality too)?
*/
int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist)
{
@ -3388,6 +3424,36 @@ int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms
return retval;
}
/*********************************************************************
* vfwprintf_s (MSVCRT.@)
*/
int CDECL MSVCRT_vfwprintf_s(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist)
{
MSVCRT_wchar_t buf[2048];
pf_output out;
int written, retval;
if( !MSVCRT_CHECK_PMT( file != NULL ) )
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
out.unicode = TRUE;
out.buf.W = out.grow.W = buf;
out.used = 0;
out.len = sizeof(buf) / sizeof(buf[0]);
if ((written = pf_vsnprintf( &out, format, NULL, TRUE, valist )) >= 0)
{
retval = MSVCRT_fwrite(out.buf.W, sizeof(*out.buf.W), written, file);
}
else retval = -1;
if (out.buf.W != out.grow.W)
MSVCRT_free (out.buf.W);
return retval;
}
/*********************************************************************
* vprintf (MSVCRT.@)
*/

View File

@ -1422,9 +1422,9 @@
@ cdecl ungetwc(long ptr) MSVCRT_ungetwc
# stub utime
@ cdecl vfprintf(ptr str ptr) MSVCRT_vfprintf
# stub vfprintf_s
@ cdecl vfprintf_s(ptr str ptr) MSVCRT_vfprintf_s
@ cdecl vfwprintf(ptr wstr ptr) MSVCRT_vfwprintf
# stub vfwprintf_s
@ cdecl vfwprintf_s(ptr wstr ptr) MSVCRT_vfwprintf_s
@ cdecl vprintf(str ptr) MSVCRT_vprintf
# stub vprintf_s
# stub vsnprintf

View File

@ -166,6 +166,7 @@ FILE* __cdecl tmpfile(void);
char* __cdecl tmpnam(char*);
int __cdecl ungetc(int,FILE*);
int __cdecl vfprintf(FILE*,const char*,__ms_va_list);
int __cdecl vfprintf_s(FILE*,const char*,__ms_va_list);
int __cdecl vprintf(const char*,__ms_va_list);
int __cdecl vsprintf(char*,const char*,__ms_va_list);
int __cdecl vsprintf_s(char*,size_t,const char*,__ms_va_list);
@ -212,6 +213,7 @@ int __cdecl swscanf(const wchar_t*,const wchar_t*,...);
int __cdecl swscanf_s(const wchar_t*,const wchar_t*,...);
wint_t __cdecl ungetwc(wint_t,FILE*);
int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vfwprintf_s(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf_s(wchar_t*,size_t,const wchar_t*,__ms_va_list);
int __cdecl vwprintf(const wchar_t*,__ms_va_list);

View File

@ -310,6 +310,7 @@ int __cdecl swscanf(const wchar_t*,const wchar_t*,...);
int __cdecl swscanf_s(const wchar_t*,const wchar_t*,...);
wint_t __cdecl ungetwc(wint_t,FILE*);
int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vfwprintf_s(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf_s(wchar_t*,size_t,const wchar_t*,__ms_va_list);
int __cdecl vwprintf(const wchar_t*,__ms_va_list);