| Line | |
|---|
| 1 | #include <stdarg.h> |
|---|
| 2 | #include <stdlib.h> |
|---|
| 3 | #include "dietstdio.h" |
|---|
| 4 | #include <unistd.h> |
|---|
| 5 | |
|---|
| 6 | struct str_data { |
|---|
| 7 | unsigned char* str; |
|---|
| 8 | }; |
|---|
| 9 | |
|---|
| 10 | static int sgetc(struct str_data* sd) { |
|---|
| 11 | register unsigned int ret = *(sd->str++); |
|---|
| 12 | return (ret)?(int)ret:-1; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | static int sputc(int c, struct str_data* sd) { |
|---|
| 16 | return (*(--sd->str)==c)?c:-1; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | int vsscanf(const char* str, const char* format, va_list arg_ptr) |
|---|
| 20 | { |
|---|
| 21 | struct str_data fdat = { (unsigned char*)str }; |
|---|
| 22 | struct arg_scanf farg = { (void*)&fdat, (int(*)(void*))sgetc, (int(*)(int,void*))sputc }; |
|---|
| 23 | return __v_scanf(&farg,format,arg_ptr); |
|---|
| 24 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.