1 /* 2 FUNCTION 3 <<siprintf>>---write formatted output (integer only) 4 INDEX 5 siprintf 6 7 ANSI_SYNOPSIS 8 #include <stdio.h> 9 10 int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]); 11 12 13 DESCRIPTION 14 <<siprintf>> is a restricted version of <<sprintf>>: it has the same 15 arguments and behavior, save that it cannot perform any floating-point 16 formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers 17 are not recognized. 18 19 RETURNS 20 <<siprintf>> returns the number of bytes in the output string, 21 save that the concluding <<NULL>> is not counted. 22 <<siprintf>> returns when the end of the format string is 23 encountered. 24 25 PORTABILITY 26 <<siprintf>> is not required by ANSI C. 27 28 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, 29 <<lseek>>, <<read>>, <<sbrk>>, <<write>>. 30 */ 31 32 #include <stdio.h> 33 #ifdef _HAVE_STDC 34 #include <stdarg.h> 35 #else 36 #include <varargs.h> 37 #endif 38 #include <limits.h> 39 #include <_ansi.h> 40 #include <reent.h> 41 #include "local.h" 42 43 int 44 #ifdef _HAVE_STDC 45 _DEFUN (siprintf, (str, fmt), char *str _AND _CONST char *fmt _DOTS) 46 #else 47 siprintf (str, fmt, va_alist) 48 char *str; 49 _CONST char *fmt; 50 va_dcl 51 #endif 52 { 53 int ret; 54 va_list ap; 55 FILE f; 56 57 f._flags = __SWR | __SSTR; 58 f._bf._base = f._p = (unsigned char *) str; 59 f._bf._size = f._w = INT_MAX; 60 #ifdef _HAVE_STDC 61 va_start (ap, fmt); 62 #else 63 va_start (ap); 64 #endif 65 ret = vfiprintf (&f, fmt, ap); 66 va_end (ap); 67 *f._p = 0; 68 return (ret); 69 } 70