XINU
lib
sscanf.c
Go to the documentation of this file.
1
6
#define EOF (-2)
8
9
static
int
sgetch
(
int
,
char
**);
10
static
int
sungetch
(
int
,
char
**);
11
extern
int
_doscan
(
register
char
*,
register
int
**,
12
int
(*
getc
)(
int
,
char
**),
13
int
(*ungetc)(
int
,
char
**),
int
,
int
);
14
15
/*------------------------------------------------------------------------
16
* sscanf - Read from a string according to a format.
17
* Return result of _doscan.
18
*------------------------------------------------------------------------
19
*/
20
int
sscanf
(
21
char
*str,
/* String to read from */
22
char
*fmt,
/* Format string */
23
int
args
/* Num of args in format string */
24
)
25
{
26
char
*s;
27
28
s = str;
29
return
(
_doscan
(fmt, (
int
**)&args,
sgetch
,
sungetch
, 0, (
int
)&s));
30
}
31
32
/*------------------------------------------------------------------------
33
* sgetch - Get the next character from a string
34
*------------------------------------------------------------------------
35
*/
36
static
int
sgetch
(
37
int
dummy,
/* Dummy unused variable */
38
char
**cpp
/* String to use */
39
)
40
{
41
return
(*(*cpp) ==
'\0'
?
EOF
: *(*cpp)++);
42
}
43
44
/*------------------------------------------------------------------------
45
* sungetch - Pushback a character in a string
46
*------------------------------------------------------------------------
47
*/
48
static
int
sungetch
(
49
int
dummy,
/* Dummy unused variable */
50
char
**cpp
/* String for pushback */
51
)
52
{
53
return
(*(*cpp)--);
54
}
_doscan
int _doscan(register char *, register int **, int(*getc)(int, char **), int(*ungetc)(int, char **), int, int)
EOF
#define EOF
End of File.
Definition:
sscanf.c:7
sungetch
static int sungetch(int, char **)
Definition:
sscanf.c:48
getc
syscall getc(did32)
Definition:
getc.c:9
sscanf
int sscanf(char *str, char *fmt, int args)
Definition:
sscanf.c:20
sgetch
static int sgetch(int, char **)
Definition:
sscanf.c:36
Generated by
1.8.13