From f4c2a5c19a7ba798c3b178c765dca2eaf5e782a7 Mon Sep 17 00:00:00 2001 From: SolDev69 Date: Sun, 10 Dec 2023 20:17:51 -0500 Subject: [PATCH] add stdioext.h --- src/util/meson.build | 1 + src/util/stdioext.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/util/stdioext.h diff --git a/src/util/meson.build b/src/util/meson.build index eb88f235c47..a4100d8be75 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -30,6 +30,7 @@ endif subdir('blake3') files_mesa_util = files( + 'stdioext.h', 'anon_file.h', 'anon_file.c', 'bigmath.h', diff --git a/src/util/stdioext.h b/src/util/stdioext.h new file mode 100644 index 00000000000..6c1bd416c47 --- /dev/null +++ b/src/util/stdioext.h @@ -0,0 +1,28 @@ +#ifndef _STDIOEXT_H +#define _STDIOEXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct cookie_io_functions_t { + ssize_t (*read)(void *cookie, char *buf, size_t n); + ssize_t (*write)(void *cookie, const char *buf, size_t n); + int (*seek)(void *cookie, off_t *pos, int whence); + int (*close)(void *cookie); +} cookie_io_functions_t; + +FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t functions); + +FILE *fmemopen(void *buf, size_t size, const char *mode); + +FILE *open_memstream(char **buf, size_t *size); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* _STDIOEXT_H */