From 4b736f44406c502625df5920a02fb47405052a2b Mon Sep 17 00:00:00 2001 From: Tino Didriksen Date: Wed, 27 Dec 2023 20:28:46 +0100 Subject: [PATCH] fmemopen is optional --- configure.ac | 5 ++--- lttoolbox/input_file.cc | 4 +++- lttoolbox/input_file.h | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index ac56f88..a5c6640 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.52) m4_define([PKG_VERSION_MAJOR], [3]) m4_define([PKG_VERSION_MINOR], [7]) -m4_define([PKG_VERSION_PATCH], [5]) +m4_define([PKG_VERSION_PATCH], [6]) # Bump if the ABI (not API) changed in a backwards-incompatible manner m4_define([PKG_VERSION_ABI], [3]) @@ -61,8 +61,7 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_ERROR_AT_LINE -AC_CHECK_DECLS([fread_unlocked, fwrite_unlocked, fgetc_unlocked, \ -fputc_unlocked, fputs_unlocked]) +AC_CHECK_DECLS([fread_unlocked, fwrite_unlocked, fgetc_unlocked, fputc_unlocked, fputs_unlocked, fmemopen]) AC_CHECK_FUNCS([setlocale strdup getopt_long]) diff --git a/lttoolbox/input_file.cc b/lttoolbox/input_file.cc index b10d418..f296927 100644 --- a/lttoolbox/input_file.cc +++ b/lttoolbox/input_file.cc @@ -44,13 +44,15 @@ InputFile::open(const char* fname) return (infile != nullptr); } +#if HAVE_DECL_FMEMOPEN bool InputFile::open_in_memory(char *input_buffer) { close(); infile = fmemopen(input_buffer, strlen(input_buffer), "rb"); - return (infile != nullptr); + return (infile != nullptr); } +#endif void InputFile::open_or_exit(const char* fname) diff --git a/lttoolbox/input_file.h b/lttoolbox/input_file.h index 7925ad4..2a5fb72 100644 --- a/lttoolbox/input_file.h +++ b/lttoolbox/input_file.h @@ -34,7 +34,9 @@ class InputFile InputFile(); ~InputFile(); bool open(const char* fname = nullptr); +#if HAVE_DECL_FMEMOPEN bool open_in_memory(char* input_buffer); +#endif void open_or_exit(const char* fname = nullptr); void close(); void wrap(FILE* newinfile);