libc: add support for memory buffer stream with fmemopen()

Add support for POSIX interface fmemopen(). This interface open a memory
buffer as a stream and permits access to this buffer specified by mode.
This allows I/O operations to be performed on the memory buffer.

The implementation uses fopencookie() for custom stream operations and
callbacks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2023-10-23 10:35:54 +02:00
committed by Xiang Xiao
parent 01500f8b20
commit 65ae8a545c
4 changed files with 293 additions and 2 deletions
+4
View File
@@ -249,6 +249,10 @@ int vdprintf(int fd, FAR const IPTR char *fmt, va_list ap)
FAR FILE *fopencookie(FAR void *cookie, FAR const char *mode,
cookie_io_functions_t io_funcs);
/* Memory buffer stream */
FAR FILE *fmemopen(FAR void *buf, size_t size, FAR const char *mode);
/* Operations on paths */
FAR FILE *tmpfile(void) fopen_like;