/*
* Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
SM_RCSID("@(#)$Id: vasprintf.c,v 1.26.2.1 2003/06/03 02:14:09 ca Exp $")
#include <stdlib.h>
#include <errno.h>
#include "local.h"
/*
** SM_VASPRINTF -- printf to a dynamically allocated string
**
** Write 'printf' output to a dynamically allocated string
** buffer which is returned to the caller.
**
** Parameters:
** str -- *str receives a pointer to the allocated string
** fmt -- format directives for printing
** ap -- variable argument list
**
** Results:
** On failure, set *str to NULL, set errno, and return -1.
**
** On success, set *str to a pointer to a nul-terminated
** string buffer containing printf output, and return the
** length of the string (not counting the nul).
*/
int
char **str;
const char *fmt;
{
int ret;
unsigned char *base;
goto err2;
if (ret == -1)
goto err;
/* use no more space than necessary */
goto err;
return ret;
err:
{
}
err2:
return -1;
}