1 /* $Header$ */ 2 3 #include <stdio.h> 4 #include <stdarg.h> 5 #include <limits.h> 6 #include "loc_incl.h" 7 8 int 9 vsnprintf(char *s, size_t n, const char *format, va_list arg) 10 { 11 int retval; 12 FILE tmp_stream; 13 14 tmp_stream._fd = -1; 15 tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; 16 tmp_stream._buf = (unsigned char *) s; 17 tmp_stream._ptr = (unsigned char *) s; 18 tmp_stream._count = n-1; 19 20 retval = _doprnt(format, arg, &tmp_stream); 21 if(n > 0) { 22 tmp_stream._count = 1; 23 (void) putc('\0',&tmp_stream); 24 } 25 26 return retval; 27 } 28 29