1*46105Sbostic /*- 2*46105Sbostic * Copyright (c) 1990 The Regents of the University of California. 332989Sbostic * All rights reserved. 432989Sbostic * 5*46105Sbostic * This code is derived from software contributed to Berkeley by 6*46105Sbostic * Chris Torek. 7*46105Sbostic * 842633Sbostic * %sccs.include.redist.c% 932989Sbostic */ 1032989Sbostic 1126663Sdonn #if defined(LIBC_SCCS) && !defined(lint) 12*46105Sbostic static char sccsid[] = "@(#)sprintf.c 5.7 (Berkeley) 01/20/91"; 1332989Sbostic #endif /* LIBC_SCCS and not lint */ 1422148Smckusick 1532989Sbostic #include <stdio.h> 16*46105Sbostic #if __STDC__ 17*46105Sbostic #include <stdarg.h> 18*46105Sbostic #else 19*46105Sbostic #include <varargs.h> 20*46105Sbostic #endif 21*46105Sbostic #include <limits.h> 22*46105Sbostic #include "local.h" 232033Swnj 24*46105Sbostic #if __STDC__ 25*46105Sbostic sprintf(char *str, char const *fmt, ...) 26*46105Sbostic #else 27*46105Sbostic sprintf(str, fmt, va_alist) 28*46105Sbostic char *str; 29*46105Sbostic char *fmt; 30*46105Sbostic va_dcl 31*46105Sbostic #endif 322033Swnj { 33*46105Sbostic int ret; 34*46105Sbostic va_list ap; 35*46105Sbostic FILE f; 362033Swnj 37*46105Sbostic f._flags = __SWR | __SSTR; 38*46105Sbostic f._bf._base = f._p = (unsigned char *)str; 39*46105Sbostic f._bf._size = f._w = INT_MAX; 40*46105Sbostic #if __STDC__ 41*46105Sbostic va_start(ap, fmt); 42*46105Sbostic #else 43*46105Sbostic va_start(ap); 44*46105Sbostic #endif 45*46105Sbostic ret = vfprintf(&f, fmt, ap); 46*46105Sbostic va_end(ap); 47*46105Sbostic *f._p = 0; 48*46105Sbostic return (ret); 492033Swnj } 50