/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)sprintf.c 8.1 (Berkeley) 06/04/93"; #endif /* LIBC_SCCS and not lint */ #include #if __STDC__ #include #else #include #endif #include #include "local.h" #if __STDC__ sprintf(char *str, char const *fmt, ...) #else sprintf(str, fmt, va_alist) char *str; char *fmt; va_dcl #endif { int ret; va_list ap; FILE f; f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *)str; f._bf._size = f._w = INT_MAX; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = vfprintf(&f, fmt, ap); va_end(ap); *f._p = 0; return (ret); }