Subversion Repositories Kolibri OS

Rev

Rev 6431 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <stdlib.h>
  4.  
  5. int virtual_getc_file(void *sp, const void *obj)
  6. // get next chat from file obj, save point is ptr to string char ptr
  7. {
  8.     FILE *f = (FILE *)obj;
  9.     int     ch = fgetc(f);
  10.  
  11. //printf("getc '%c'[%d];", ch, ch);
  12.  
  13.     return ch;
  14. }
  15.  
  16. void virtual_ungetc_file(void *sp, int c, const void *obj)
  17. // if can, one step back savepoint in s
  18. {
  19.     FILE *f = (FILE *)obj;
  20.  
  21.     if (f) ungetc(c, f);
  22. }
  23.  
  24.  
  25. int vfscanf ( FILE * stream, const char * format, va_list arg )
  26. {
  27.     return format_scan(stream, format, arg, &virtual_getc_file, &virtual_ungetc_file);
  28. };
  29.  
  30. int fscanf ( FILE * stream, const char * format, ...)
  31. {
  32.    va_list      arg;
  33.    int  n;
  34.    va_start(arg, format);
  35.  
  36.    n = vfscanf(stream, format, arg);
  37.  
  38.    va_end(arg);
  39.    return n;
  40. }
  41.  
  42.  
  43.