Skip to content
vsprintf.c 47 KiB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
		}
		num++;

		if (!next)
			break;
		str = next;
	}

	/*
	 * Now we've come all the way through so either the input string or the
	 * format ended. In the former case, there can be a %n at the current
	 * position in the format that needs to be filled.
	 */
	if (*fmt == '%' && *(fmt + 1) == 'n') {
		int *p = (int *)va_arg(args, int *);
		*p = str - buf;
	}

Linus Torvalds's avatar
Linus Torvalds committed
	return num;
}
EXPORT_SYMBOL(vsscanf);

/**
 * sscanf - Unformat a buffer into a list of arguments
 * @buf:	input buffer
 * @fmt:	formatting of buffer
 * @...:	resulting arguments
 */
int sscanf(const char *buf, const char *fmt, ...)
Linus Torvalds's avatar
Linus Torvalds committed
{
	va_list args;
	int i;

	va_start(args, fmt);
	i = vsscanf(buf, fmt, args);
Linus Torvalds's avatar
Linus Torvalds committed
	va_end(args);
Linus Torvalds's avatar
Linus Torvalds committed
	return i;
}
EXPORT_SYMBOL(sscanf);