Subversion Repositories Kolibri OS

Rev

Rev 6424 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. int fprintf(FILE* file, const char* format, ...)
  7. {
  8.     va_list             arg;
  9.     va_start (arg, format);
  10.  
  11.     return vfprintf(file, format, arg);
  12.  
  13. }
  14.  
  15. int vfprintf ( FILE * file, const char * format, va_list arg )
  16. {
  17.     char                *buf;
  18.     int         printed, rc = 0;
  19.  
  20.     if(!file || !format)
  21.     {
  22.         errno = E_INVALIDPTR;
  23.         return errno;
  24.     }
  25.  
  26.     buf=malloc(4096*2); //8kb max
  27.     if(!buf)
  28.     {
  29.         errno = E_NOMEM;
  30.         return errno;
  31.     }
  32.  
  33.   printed=format_print(buf,8191, format,arg);
  34.   if (file == stderr)
  35.         debug_out_str(buf);
  36.   else
  37.         rc = fwrite(buf,printed,1,file);
  38.   free(buf);
  39.  
  40.   if (rc < 0)
  41.     return rc;
  42.   else
  43.     return(printed);
  44. }
  45.