straprintf.cpp revision 45fdb697e9030f33bf5fabea82ca7eeafab2f6af
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * IPRT - Allocating String Formatters.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Copyright (C) 2006-2010 Oracle Corporation
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * available from http://www.virtualbox.org. This file is free software;
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * you can redistribute it and/or modify it under the terms of the GNU
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * General Public License (GPL) as published by the Free Software
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * The contents of this file may alternatively be used under the terms
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * of the Common Development and Distribution License Version 1.0
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * VirtualBox OSE distribution, in which case the provisions of the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * CDDL are applicable instead of those of the GPL.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * You may elect to license modified versions of this file under the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * terms and conditions of either the GPL or the CDDL or both.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/*******************************************************************************
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync* Header Files *
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync*******************************************************************************/
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/*******************************************************************************
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync* Structures and Typedefs *
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync*******************************************************************************/
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/** strallocoutput() argument structure. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsynctypedef struct STRALLOCARG
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** Pointer to current buffer position. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** Number of bytes left in the buffer - not including the trailing zero. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** Pointer to the start of the buffer. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** The number of bytes in the buffer. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** Set if the buffer was allocated using RTMemRealloc(). If clear
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * pszBuffer points to the initial stack buffer. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync /** Allocation tag used for statistics and such. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync const char *pszTag;
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/** Pointer to a strallocoutput() argument structure. */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/*******************************************************************************
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync* Internal Functions *
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync*******************************************************************************/
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsyncstatic DECLCALLBACK(size_t) strallocoutput(void *pvArg, const char *pachChars, size_t cbChars);
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Output callback.
if (cbChars)
return cbChars;
if (pszBuffer)
if (cbChars)
return cbChars;
RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag)
#ifdef IN_RING3
if (psz)
return cbRet;
char *pszBuffer;
return pszBuffer;