From 00369dcd62ea48a9174a6923498f4375968a94c3 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 19 Aug 2015 23:49:04 -0400 Subject: Add C preprocessor in preparation for type parsing --- type.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'type.cpp') diff --git a/type.cpp b/type.cpp index 62176deb..1a0bec58 100644 --- a/type.cpp +++ b/type.cpp @@ -355,3 +355,26 @@ void Enumeration::AddMemberWithValue(const string& name, uint64_t value) { BNAddEnumerationMemberWithValue(m_enum, name.c_str(), value); } + + +bool BinaryNinja::PreprocessSource(const string& source, const string& fileName, string& output, string& errors, + const vector& includeDirs) +{ + char* outStr; + char* errorStr; + const char** includeDirList = new const char*[includeDirs.size()]; + + for (size_t i = 0; i < includeDirs.size(); i++) + includeDirList[i] = includeDirs[i].c_str(); + + bool result = BNPreprocessSource(source.c_str(), fileName.c_str(), &outStr, &errorStr, + includeDirList, includeDirs.size()); + + output = outStr; + errors = errorStr; + + BNFreeString(outStr); + BNFreeString(errorStr); + delete[] includeDirList; + return result; +} -- cgit v1.3.1