summaryrefslogtreecommitdiff
path: root/src/stdio/sscanf.c
blob: c9f1c1f60fb34768999a61b163e8818d07ad9b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "_format.h"

/** read formatted input from a string **/

int sscanf(const char * restrict s, const char * restrict format, ...)
{
	int ret = 0;
	va_list ap;
	struct io_options opt = {0};

	SIGNAL_SAFE(0);
	ASSERT_NOOVERLAP(s, strlen(s), format, strlen(format));

	opt.fnname = "sscanf";
	opt.string = (char *)s;
	va_start(ap, format);
	ret = __scanf(&opt, format, ap);
	va_end(ap);
	/*
	RETURN_SUCCESS(the number of input items assigned);
	RETURN_FAILURE(CONSTANT(EOF));
	*/
	return ret;
}

/***
reads formatted input from the string ARGUMENT(s). The format of
ARGUMENT(format) at the variadic arguments is the same as that for
FUNCTION(scanf).
***/

/*
STDC(1)
*/