kolibrios/programs/develop/libraries/kolibri-libc/source/stdio/sscanf.c
turbocat 1c24cac315 kolibri-libc:
[include]
 - ksys.h : fixed sruct name
 - string.h: set memcpy, memset, and memove as static for libtcc
 - stdio.h: added sscanf and ungetc
 - stdint.h: added int64 limits
[stdio]
fixed *scanf functions
added ungetc functon
[lib]
 - upated binaries
 - added libtcc.a for tcc optimization
[crt]
 - removed duplicate files
[samples]
 - added fasm libc.obj example
 - updated old examples 




git-svn-id: svn://kolibrios.org@8718 a494cfbc-eb01-0410-851d-a64ba20cac60
2021-05-09 22:12:43 +00:00

47 lines
1.0 KiB
C

#include <stdio.h>
#include <stdarg.h>
int virtual_getc_str(void *sp, const void *obj)
// get next chat from string obj, save point is ptr to string char ptr
{
int ch;
const char *s = (const char *)obj;
const char**spc= (const char**)sp;
if (!s || !spc) return EOF; // error
if (!*spc) *spc = s; // first call, init savepoint
if (!**spc) return EOF; // EOS
ch = **spc; (*spc)++ ;
return ch;
}
void virtual_ungetc_str(void *sp, int c, const void *obj)
// if can, one step back savepoint in s
{
const char *s = (const char *)obj;
const char**spc= (const char**)sp;
if (s && spc && *spc > s) (*spc)--;
}
int vsscanf ( const char * s, const char * format, va_list arg )
{
return format_scan(s, format, arg, &virtual_getc_str, &virtual_ungetc_str);
};
int sscanf ( const char * s, const char * format, ...)
{
va_list arg;
int n;
va_start(arg, format);
n = vsscanf(s, format, arg);
va_end(arg);
return n;
}