Home | History | Annotate | Download | only in lib
      1 /*
      2  * vfprintf.c
      3  */
      4 
      5 #include <stdio.h>
      6 #include <string.h>
      7 #include <stdarg.h>
      8 #include <unistd.h>
      9 
     10 #define BUFFER_SIZE	32768
     11 
     12 int vfprintf(FILE * file, const char *format, va_list ap)
     13 {
     14     int rv;
     15     char buffer[BUFFER_SIZE];
     16 
     17     rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
     18 
     19     if (rv < 0)
     20 	return rv;
     21 
     22     if (rv > BUFFER_SIZE - 1)
     23 	rv = BUFFER_SIZE - 1;
     24 
     25     return _fwrite(buffer, rv, file);
     26 }
     27