Commit | Line | Data |
---|---|---|
c9be6cfe KB |
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[] = "@(#)vsnprintf.c 5.1 (Berkeley) %G%"; | |
13 | #endif /* LIBC_SCCS and not lint */ | |
14 | ||
15 | #include <stdio.h> | |
16 | ||
17 | vsnprintf(str, n, fmt, ap) | |
18 | char *str; | |
19 | size_t n; | |
20 | char *fmt; | |
21 | _VA_LIST_ ap; | |
22 | { | |
23 | int ret; | |
24 | FILE f; | |
25 | ||
26 | if ((int)n < 1) | |
27 | return (EOF); | |
28 | f._flags = __SWR | __SSTR; | |
29 | f._bf._base = f._p = (unsigned char *)str; | |
30 | f._bf._size = f._w = n - 1; | |
31 | ret = vfprintf(&f, fmt, ap); | |
32 | *f._p = 0; | |
33 | return (ret); | |
34 | } |