Subversion Repositories Kolibri OS

Rev

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

  1. //#include "format_scan.h"
  2.  
  3. static int __virtual_getc_str(void *sp, const void *obj)
  4. // get next chat from string obj, save point is ptr to string char ptr
  5. {
  6.     int ch;
  7.     const char *s = (const char *)obj;
  8.     const char**spc= (const char**)sp;
  9.     if (!s || !spc) return EOF;  // error
  10.  
  11.     if (!*spc) *spc = s;    // first call, init savepoint
  12.  
  13.     if (!**spc) return EOF;  // EOS
  14.  
  15.     ch = **spc; (*spc)++ ;
  16.  
  17.     return ch;
  18. }
  19.  
  20. void __virtual_ungetc_str(void *sp, int c, const void *obj)
  21. // if can, one step back savepoint in s
  22. {
  23.     const char *s = (const char *)obj;
  24.     const char**spc= (const char**)sp;
  25.  
  26.     if (s && spc && *spc > s) (*spc)--;
  27. }
  28.  
  29. int vsscanf(const char * s, const char * format, va_list arg)
  30. {
  31.     return _format_scan(s, format, arg, &__virtual_getc_str, &__virtual_ungetc_str);
  32. };