Update zoneinfo database.
[dragonfly/netmp.git] / contrib / sendmail / libsm / vsprintf.c
blob827fcec5a955804315cda65d1abecb21ba36173c
1 /*
2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
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
8 * Chris Torek.
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.
15 #include <sm/gen.h>
16 SM_RCSID("@(#)$Id: vsprintf.c,v 1.21 2001/09/11 04:04:49 gshapiro Exp $")
17 #include <limits.h>
18 #include <sm/io.h>
19 #include "local.h"
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.
27 ** Parameters:
28 ** str -- location for output
29 ** fmt -- format directives
30 ** ap -- data unit vectors for use by 'fmt'
32 ** Results:
33 ** result from sm_io_vfprintf()
35 ** Side Effects:
36 ** Quietly limits the size to INT_MAX though this may
37 ** not prevent SEGV's.
40 int
41 sm_vsprintf(str, fmt, ap)
42 char *str;
43 const char *fmt;
44 SM_VA_LOCAL_DECL
46 int ret;
47 SM_FILE_T fake;
49 fake.sm_magic = SmFileMagic;
50 fake.f_file = -1;
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;
56 fake.f_close = NULL;
57 fake.f_open = NULL;
58 fake.f_read = NULL;
59 fake.f_write = NULL;
60 fake.f_seek = NULL;
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);
64 *fake.f_p = '\0';
65 return ret;