2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * By using this file, you agree to the terms and conditions set
11 * forth in the LICENSE file which can be found at the top level of
12 * the sendmail distribution.
16 SM_RCSID("@(#)$Id: vsprintf.c,v 1.21 2001/09/11 04:04:49 gshapiro Exp $")
22 ** SM_VSPRINTF -- format data for "output" into a string
24 ** Assigned 'str' to a "fake" file pointer. This allows common
25 ** o/p formatting function sm_vprintf() to be used.
28 ** str -- location for output
29 ** fmt -- format directives
30 ** ap -- data unit vectors for use by 'fmt'
33 ** result from sm_io_vfprintf()
36 ** Quietly limits the size to INT_MAX though this may
37 ** not prevent SEGV's.
41 sm_vsprintf(str
, fmt
, ap
)
49 fake
.sm_magic
= SmFileMagic
;
51 fake
.f_flags
= SMWR
| SMSTR
;
52 fake
.f_bf
.smb_base
= fake
.f_p
= (unsigned char *)str
;
53 fake
.f_bf
.smb_size
= fake
.f_w
= INT_MAX
;
54 fake
.f_timeout
= SM_TIME_FOREVER
;
55 fake
.f_timeoutstate
= SM_TIME_BLOCK
;
61 fake
.f_setinfo
= fake
.f_getinfo
= NULL
;
62 fake
.f_type
= "sm_vsprintf:fake";
63 ret
= sm_io_vfprintf(&fake
, SM_TIME_FOREVER
, fmt
, ap
);