strprintf.cpp revision 45fdb697e9030f33bf5fabea82ca7eeafab2f6af
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * IPRT - String Formatters.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Copyright (C) 2006-2007 Oracle Corporation
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * available from http://www.virtualbox.org. This file is free software;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * General Public License (GPL) as published by the Free Software
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * The contents of this file may alternatively be used under the terms
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * of the Common Development and Distribution License Version 1.0
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * VirtualBox OSE distribution, in which case the provisions of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * CDDL are applicable instead of those of the GPL.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * You may elect to license modified versions of this file under the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * terms and conditions of either the GPL or the CDDL or both.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/*******************************************************************************
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync* Header Files *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync*******************************************************************************/
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/*******************************************************************************
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync* Structures and Typedefs *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync*******************************************************************************/
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/** strbufoutput() argument structure. */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynctypedef struct STRBUFARG
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /** Pointer to current buffer position. */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /** Number of bytes left in the buffer - not including the trailing zero. */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/** Pointer to a strbufoutput() argument structure. */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/*******************************************************************************
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync* Internal Functions *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync*******************************************************************************/
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncstatic DECLCALLBACK(size_t) strbufoutput(void *pvArg, const char *pachChars, size_t cbChars);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Output callback.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * @returns number of bytes written.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * @param pvArg Pointer to a STRBUFARG structure.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * @param pachChars Pointer to an array of utf-8 characters.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * @param cbChars Number of bytes in the character array pointed to by pachChars.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncstatic DECLCALLBACK(size_t) strbufoutput(void *pvArg, const char *pachChars, size_t cbChars)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncRTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync AssertMsgFailed(("Excellent idea! Format a string with no space for the output!\n"));
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return RTStrFormatV(strbufoutput, &Arg, pfnFormat, pvArg, pszFormat, args);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncRTDECL(size_t) RTStrPrintfV(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return RTStrPrintfExV((PFNSTRFORMAT)NULL, NULL, pszBuffer, cchBuffer, pszFormat, args);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncRTDECL(size_t) RTStrPrintfEx(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync cbRet = RTStrPrintfExV(pfnFormat, pvArg, pszBuffer, cchBuffer, pszFormat, args);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncRTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...)