2007-10-15 11:42:17 +02:00
|
|
|
#include <stdio.h>
|
2016-05-15 21:19:22 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int virtual_getc_file(void *sp, const void *obj)
|
|
|
|
// get next chat from file obj, save point is ptr to string char ptr
|
2006-09-07 16:14:53 +02:00
|
|
|
{
|
2016-05-15 21:19:22 +02:00
|
|
|
FILE *f = (FILE *)obj;
|
|
|
|
|
|
|
|
return fgetc(f);
|
2006-09-07 16:14:53 +02:00
|
|
|
}
|
2016-04-30 15:50:04 +02:00
|
|
|
|
2016-05-15 21:19:22 +02:00
|
|
|
void virtual_ungetc_file(void *sp, int c, const void *obj)
|
|
|
|
// if can, one step back savepoint in s
|
2006-09-07 16:14:53 +02:00
|
|
|
{
|
2016-05-15 21:19:22 +02:00
|
|
|
FILE *f = (FILE *)obj;
|
|
|
|
|
|
|
|
if (f) ungetc(c, f);
|
2006-09-07 16:14:53 +02:00
|
|
|
}
|
2016-05-15 21:19:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
int vfscanf ( FILE * stream, const char * format, va_list arg )
|
|
|
|
{
|
|
|
|
return format_scan(stream, format, arg, &virtual_getc_file, &virtual_ungetc_file);
|
|
|
|
};
|
|
|
|
|
|
|
|
int fscanf ( FILE * stream, const char * format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
int n;
|
|
|
|
va_start(arg, format);
|
|
|
|
|
|
|
|
n = vfscanf(stream, format, arg);
|
|
|
|
|
|
|
|
va_end(arg);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|