diff options
| author | Rusty Wagner <rusty@vector35.com> | 2015-10-15 20:57:04 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2015-10-15 20:57:04 -0400 |
| commit | cb87ea835ed3d4f01f91a9e67c2fc61cab18bd2c (patch) | |
| tree | 8ec474e663f8affc09ba35e10aa1bb3afcb2ef29 | |
| parent | 519988c1ed48c5dbb54670bb6cc4b03847b47516 (diff) | |
Add API to get list of valid channels and latest version for active license
| -rw-r--r-- | binaryninjaapi.h | 17 | ||||
| -rw-r--r-- | update.cpp | 32 |
2 files changed, 49 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 2dc15f2c..04749e97 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1339,4 +1339,21 @@ namespace BinaryNinja virtual bool RecognizeLowLevelIL(BinaryView* data, Function* func, LowLevelILFunction* il); }; + + class UpdateException: public std::exception + { + const std::string m_desc; + public: + UpdateException(const std::string& desc): std::exception(), m_desc(desc) {} + virtual const char* what() const NOEXCEPT { return m_desc.c_str(); } + }; + + struct UpdateChannel + { + std::string name; + std::string description; + std::string latestVersion; + + static std::vector<UpdateChannel> GetList(); + }; } diff --git a/update.cpp b/update.cpp new file mode 100644 index 00000000..9dcf66cb --- /dev/null +++ b/update.cpp @@ -0,0 +1,32 @@ +#include "binaryninjaapi.h" + +using namespace BinaryNinja; +using namespace std; + + +vector<UpdateChannel> UpdateChannel::GetList() +{ + size_t count; + char* errors; + BNUpdateChannel* channels = BNGetUpdateChannels(&count, &errors); + + if (errors) + { + string errorStr = errors; + BNFreeString(errors); + throw UpdateException(errorStr); + } + + vector<UpdateChannel> result; + for (size_t i = 0; i < count; i++) + { + UpdateChannel channel; + channel.name = channels[i].name; + channel.description = channels[i].description; + channel.latestVersion = channels[i].latestVersion; + result.push_back(channel); + } + + BNFreeUpdateChannelList(channels, count); + return result; +} |
