xref: /original-bsd/lib/libc/stdio/vsprintf.c (revision b30b9691)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Chris Torek.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #if defined(LIBC_SCCS) && !defined(lint)
12 static char sccsid[] = "@(#)vsprintf.c	5.5 (Berkeley) 02/05/91";
13 #endif /* LIBC_SCCS and not lint */
14 
15 #include <stdio.h>
16 #include <limits.h>
17 
18 vsprintf(str, fmt, ap)
19 	char *str;
20 	const char *fmt;
21 	_VA_LIST_ ap;
22 {
23 	int ret;
24 	FILE f;
25 
26 	f._flags = __SWR | __SSTR;
27 	f._bf._base = f._p = (unsigned char *)str;
28 	f._bf._size = f._w = INT_MAX;
29 	ret = vfprintf(&f, fmt, ap);
30 	*f._p = 0;
31 	return (ret);
32 }
33