sscanf.c 505 Bytes
Newer Older
1
2
3
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 */

#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;
}