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.
10 #pragma ident "%Z%%M% %I% %E% SMI"
13 SM_RCSID("@(#)$Id: stringf.c,v 1.13 2001/03/03 03:40:43 ca Exp $")
18 #include <sm/string.h>
19 #include <sm/varargs.h>
22 ** SM_STRINGF_X -- printf() to dynamically allocated string.
24 ** Takes the same arguments as printf.
25 ** It returns a pointer to a dynamically allocated string
26 ** containing the text that printf would print to standard output.
27 ** It raises an exception on error.
28 ** The name comes from a PWB Unix function called stringf.
31 ** fmt -- format string.
32 ** ... -- arguments for format.
35 ** Pointer to a dynamically allocated string.
38 ** F:sm_heap -- out of memory (via sm_vstringf_x()).
43 sm_stringf_x(const char *fmt
, ...)
45 sm_stringf_x(fmt
, va_alist
)
48 #endif /* SM_VA_STD */
54 s
= sm_vstringf_x(fmt
, ap
);
60 ** SM_VSTRINGF_X -- printf() to dynamically allocated string.
63 ** fmt -- format string.
64 ** ap -- arguments for format.
67 ** Pointer to a dynamically allocated string.
70 ** F:sm_heap -- out of memory
74 sm_vstringf_x(fmt
, ap
)
80 sm_vasprintf(&s
, fmt
, ap
);
84 sm_exc_raise_x(&SmHeapOutOfMemory
);
85 sm_exc_raisenew_x(&SmEtypeOs
, errno
, "sm_vasprintf", NULL
);