Rev 8793 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8793 | Rev 9868 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | #include |
|
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include |
Line 4... | Line -... | ||
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 | 5 | ||
25 | int vfscanf ( FILE * stream, const char * format, va_list arg ) |
6 | int vfscanf(FILE* stream, const char* format, va_list arg) |
- | 7 | { |
|
- | 8 | static char scanf_buffer[STDIO_MAX_MEM]; |
|
26 | { |
9 | fgets(scanf_buffer, STDIO_MAX_MEM-1, stream); |
27 | return format_scan(stream, format, arg, &virtual_getc_file, &virtual_ungetc_file); |
10 | return vsscanf(scanf_buffer, format, arg); |
Line 28... | Line 11... | ||
28 | }; |
11 | } |
29 | 12 | ||
30 | int fscanf ( FILE * stream, const char * format, ...) |
13 | int fscanf(FILE* stream, const char* format, ...) |
31 | { |
14 | { |
Line 36... | Line 19... | ||
36 | n = vfscanf(stream, format, arg); |
19 | n = vfscanf(stream, format, arg); |
Line 37... | Line 20... | ||
37 | 20 | ||
38 | va_end(arg); |
21 | va_end(arg); |
39 | return n; |
22 | return n; |
40 | } |
- | |
41 | - |