home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Mint
/
mntlib25.zoo
/
sscanf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-05
|
1KB
|
63 lines
#include <stdio.h>
#include <stdarg.h>
#include "lib.h"
typedef int (*gettype)(void *);
typedef int (*ungettype)(int, void *);
static int sgetc __PROTO((unsigned char **s));
static int sungetc __PROTO((int c, unsigned char **s));
static int sgetc(s)
unsigned char **s;
{
register unsigned char c;
c = *(*s)++;
return((c == '\0') ? EOF : c);
}
static int sungetc(c, s)
int c;
unsigned char **s;
{
if(c == EOF)
c = '\0';
return(*--(*s) = c);
}
#ifdef __STDC__
int sscanf(const char *buf, const char *fmt, ...)
{
int retval;
va_list args;
va_start (args, fmt);
retval = _scanf(&buf, (gettype) sgetc, (ungettype) sungetc,
(unsigned char *) fmt, args);
va_end (args);
return retval;
}
#else
int
sscanf(buf, fmt, arg)
const char *buf, *fmt;
int arg;
{
return(_scanf(&buf, sgetc, sungetc, fmt, &arg));
}
#endif /* __STDC__ */
#ifdef __STDC__
int vsscanf(const char *buf, const char *fmt, va_list arg)
#else
int
vsscanf(buf, fmt, arg)
const char *buf, *fmt;
char *arg;
#endif /* __STDC__ */
{
return(_scanf(&buf, (gettype) sgetc, (ungettype) sungetc,
(unsigned char *) fmt, arg));
}