2007-03-14 20:24:57 +00:00
|
|
|
/*
|
2007-10-19 23:21:45 +00:00
|
|
|
* COPYRIGHT: Winehq
|
2007-03-14 20:24:57 +00:00
|
|
|
* PROJECT: wine
|
|
|
|
* FILE: msvcrt/conio/cprintf.c
|
|
|
|
* PURPOSE: C Runtime
|
2007-10-19 23:21:45 +00:00
|
|
|
* PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
|
2007-03-14 20:24:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
_cprintf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char buf[2048], *mem = buf;
|
|
|
|
int written, resize = sizeof(buf), retval;
|
|
|
|
va_list valist;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 ||
|
|
|
|
written > resize)
|
|
|
|
{
|
|
|
|
resize = (written == -1 ? resize * 2 : written + 1);
|
|
|
|
if (mem != buf)
|
|
|
|
free (mem);
|
|
|
|
if (!(mem = (char *)malloc(resize)))
|
|
|
|
return EOF;
|
|
|
|
va_start( valist, fmt );
|
|
|
|
}
|
|
|
|
va_end(valist);
|
|
|
|
retval = _cputs( mem );
|
|
|
|
if (mem != buf)
|
2007-10-19 23:21:45 +00:00
|
|
|
free (mem);
|
2007-03-14 20:24:57 +00:00
|
|
|
return retval;
|
|
|
|
}
|