Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InputFile::open_in_memory #178

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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], [4])
m4_define([PKG_VERSION_PATCH], [5])

# Bump if the ABI (not API) changed in a backwards-incompatible manner
m4_define([PKG_VERSION_ABI], [3])
Expand Down
8 changes: 8 additions & 0 deletions lttoolbox/input_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ InputFile::open(const char* fname)
return (infile != nullptr);
}

bool
InputFile::open_in_memory(char *input_buffer)
{
close();
infile = fmemopen(input_buffer, strlen(input_buffer), "rb");
return (infile != nullptr);
}

void
InputFile::open_or_exit(const char* fname)
{
Expand Down
1 change: 1 addition & 0 deletions lttoolbox/input_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class InputFile
InputFile();
~InputFile();
bool open(const char* fname = nullptr);
bool open_in_memory(char* input_buffer);
void open_or_exit(const char* fname = nullptr);
void close();
void wrap(FILE* newinfile);
Expand Down