summaryrefslogtreecommitdiff
path: root/lib/stdlib/sscanf.c
blob: 674ae79f9c9e4f83e1b001749d18b05c05f9c0e9 (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
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <sys/cdefs.h>

/*
 * TODO: This is not a real implementation of the sscanf() function. It just
 * returns the number of expected arguments based on the number of '%' found
 * in the format string.
 */
int
sscanf(const char *__restrict str, char const *__restrict fmt, ...)
{
	int ret = 0;

	while (*fmt != '\0') {
		if (*fmt++ == '%') {
			ret++;
		}
	}

	return ret;
}