libc/stream: Add support for lib_scanf
This commit adds support for the `lib_scanf` function, which is a stream-oriented version of the `scanf` function. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
a3f8b55143
commit
4b8a738141
2 changed files with 26 additions and 1 deletions
|
|
@ -857,6 +857,13 @@ int lib_vsprintf_internal(FAR struct lib_outstream_s *stream,
|
||||||
int lib_vsprintf(FAR struct lib_outstream_s *stream,
|
int lib_vsprintf(FAR struct lib_outstream_s *stream,
|
||||||
FAR const IPTR char *src, va_list ap) printf_like(2, 0);
|
FAR const IPTR char *src, va_list ap) printf_like(2, 0);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lib_scanf
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int lib_scanf(FAR struct lib_instream_s *stream, FAR int *lastc,
|
||||||
|
FAR const IPTR char *fmt, ...) scanf_like(3, 4);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lib_vscanf
|
* Name: lib_vscanf
|
||||||
*
|
*
|
||||||
|
|
@ -867,7 +874,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int lib_vscanf(FAR struct lib_instream_s *stream, FAR int *lastc,
|
int lib_vscanf(FAR struct lib_instream_s *stream, FAR int *lastc,
|
||||||
FAR const IPTR char *src, va_list ap) scanf_like(3, 0);
|
FAR const IPTR char *fmt, va_list ap) scanf_like(3, 0);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lib_bscanf
|
* Name: lib_bscanf
|
||||||
|
|
|
||||||
|
|
@ -1279,6 +1279,24 @@ int lib_vscanf(FAR struct lib_instream_s *stream, FAR int *lastc,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lib_scanf
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int lib_scanf(FAR struct lib_instream_s *stream, FAR int *lastc,
|
||||||
|
FAR const IPTR char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Let lib_vscanf do the real work */
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
n = lib_vscanf(stream, lastc, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: lib_bscanf
|
* Name: lib_bscanf
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue