msvcrt: Use callback based printf in fprintf functions family.
This commit is contained in:
parent
7303b8c4db
commit
b9e456aa79
|
@ -3379,37 +3379,22 @@ MSVCRT_FILE* CDECL MSVCRT_tmpfile(void)
|
|||
return file;
|
||||
}
|
||||
|
||||
static int puts_clbk_file_a(void *file, int len, const char *str)
|
||||
{
|
||||
return MSVCRT_fwrite(str, sizeof(char), len, file);
|
||||
}
|
||||
|
||||
static int puts_clbk_file_w(void *file, int len, const MSVCRT_wchar_t *str)
|
||||
{
|
||||
return MSVCRT_fwrite(str, sizeof(MSVCRT_wchar_t), len, file);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* vfprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, __ms_va_list valist)
|
||||
{
|
||||
char buf[2048];
|
||||
LPWSTR formatW = NULL;
|
||||
DWORD sz;
|
||||
pf_output out;
|
||||
int written, retval;
|
||||
|
||||
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, FALSE, 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;
|
||||
return pf_printf_a(puts_clbk_file_a, file, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -3417,38 +3402,12 @@ int CDECL MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, __ms_va_list va
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
return pf_printf_a(puts_clbk_file_a, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -3456,23 +3415,7 @@ int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list
|
|||
*/
|
||||
int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist)
|
||||
{
|
||||
MSVCRT_wchar_t buf[2048];
|
||||
pf_output out;
|
||||
int written, retval;
|
||||
|
||||
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, FALSE, 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;
|
||||
return pf_printf_w(puts_clbk_file_w, file, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -3480,29 +3423,12 @@ int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
return pf_printf_w(puts_clbk_file_w, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
Loading…
Reference in New Issue