source: trunk/sys/dietlibc/vsscanf.c @ 167

Last change on this file since 167 was 1, checked in by alain, 7 years ago

First import

File size: 581 bytes
Line 
1#include <stdarg.h>
2#include <stdlib.h>
3#include "dietstdio.h"
4#include <unistd.h>
5
6struct str_data {
7  unsigned char* str;
8};
9
10static int sgetc(struct str_data* sd) {
11  register unsigned int ret = *(sd->str++);
12  return (ret)?(int)ret:-1;
13}
14
15static int sputc(int c, struct str_data* sd) {
16  return (*(--sd->str)==c)?c:-1;
17}
18
19int 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.