1 #include <config.h> 2 3 #if !HAVE_SNPRINTF 4 #include <sys/types.h> 5 6 #ifdef __STDC__ 7 #include <stdarg.h> 8 #else 9 #include <varargs.h> 10 #endif 11 #include <stdio.h> 12 13 #ifdef __STDC__ 14 int snprintf(char *str, size_t n, const char *fmt, ...) 15 #else 16 int snprintf(str, n, fmt, va_alist) 17 char *str; 18 size_t n; 19 const char *fmt; 20 va_dcl 21 #endif 22 { 23 va_list ap; 24 int rval; 25 #ifdef VSPRINTF_CHARSTAR 26 char *rp; 27 #endif 28 #ifdef __STDC__ 29 va_start(ap, fmt); 30 #else 31 va_start(ap); 32 #endif 33 #ifdef VSPRINTF_CHARSTAR 34 rp = vsprintf(str, fmt, ap); 35 va_end(ap); 36 return (strlen(rp)); 37 #else 38 rval = vsprintf(str, fmt, ap); 39 va_end(ap); 40 return (rval); 41 #endif 42 } 43 44 int 45 vsnprintf(str, n, fmt, ap) 46 char *str; 47 size_t n; 48 const char *fmt; 49 va_list ap; 50 { 51 #ifdef VSPRINTF_CHARSTAR 52 return (strlen(vsprintf(str, fmt, ap))); 53 #else 54 return (vsprintf(str, fmt, ap)); 55 #endif 56 } 57 #else 58 int snprintf_bs; 59 #endif 60