singrdk/base/boot/include/printf.cpp

68 lines
1.3 KiB
C++
Raw Normal View History

2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
////////////////////////////////////////////////// Publicly Visible Interface.
//
void __cdecl PutChar(char cOut);
static void printfout(void * /* pContext */, char c)
{
PutChar(c);
}
int printf(const char *pszFmt, ...)
{
int nOut;
va_list args;
va_start(args, pszFmt);
nOut = strformat(printfout, 0, pszFmt, args);
va_end(args);
return nOut;
}
int vprintf(const char *pszFmt, va_list args)
{
int nOut;
nOut = strformat(printfout, 0, pszFmt, args);
return nOut;
}
static void sprintfout(void *pContext, char c)
{
char **ppszOut = (char **)pContext;
*(*ppszOut)++ = c;
}
int sprintf(char *pszOut, const char *pszFmt, ...)
{
int nOut;
va_list args;
va_start(args, pszFmt);
nOut = strformat(sprintfout, &pszOut, pszFmt, args);
va_end(args);
*pszOut = '\0';
return nOut;
}
int svprintf(char *pszOut, const char *pszFmt, va_list args)
{
int nOut;
nOut = strformat(sprintfout, &pszOut, pszFmt, args);
*pszOut = '\0';
return nOut;
}