2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_RCSID("@(#)$Id: stringf.c,v 1.15 2001/09/11 04:04:49 gshapiro Exp $")
16 #include <sm/string.h>
17 #include <sm/varargs.h>
20 ** SM_STRINGF_X -- printf() to dynamically allocated string.
22 ** Takes the same arguments as printf.
23 ** It returns a pointer to a dynamically allocated string
24 ** containing the text that printf would print to standard output.
25 ** It raises an exception on error.
26 ** The name comes from a PWB Unix function called stringf.
29 ** fmt -- format string.
30 ** ... -- arguments for format.
33 ** Pointer to a dynamically allocated string.
36 ** F:sm_heap -- out of memory (via sm_vstringf_x()).
41 sm_stringf_x(const char *fmt, ...)
43 sm_stringf_x(fmt, va_alist)
46 #endif /* SM_VA_STD */
52 s = sm_vstringf_x(fmt, ap);
58 ** SM_VSTRINGF_X -- printf() to dynamically allocated string.
61 ** fmt -- format string.
62 ** ap -- arguments for format.
65 ** Pointer to a dynamically allocated string.
68 ** F:sm_heap -- out of memory
72 sm_vstringf_x(fmt, ap)
78 sm_vasprintf(&s, fmt, ap);
82 sm_exc_raise_x(&SmHeapOutOfMemory);
83 sm_exc_raisenew_x(&SmEtypeOs, errno, "sm_vasprintf", NULL);