Skip to content

Commit

Permalink
fmemopen is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
TinoDidriksen committed Dec 27, 2023
1 parent e682fe1 commit 2b5f401
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])

Expand Down
4 changes: 3 additions & 1 deletion lttoolbox/input_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ InputFile::open(const char* fname)
return (infile != nullptr);
}

#ifdef 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)
Expand Down
2 changes: 2 additions & 0 deletions lttoolbox/input_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class InputFile
InputFile();
~InputFile();
bool open(const char* fname = nullptr);
#ifdef 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);
Expand Down

0 comments on commit 2b5f401

Please sign in to comment.