diff options
author | Jack Lloyd <[email protected]> | 2017-12-06 05:34:39 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-06 05:34:39 -0500 |
commit | dd9b4462b1319719128fb20e2cbffcafd13b9b36 (patch) | |
tree | 72899758cad6ba8a95021fa80108da6ea50a3ce7 /src/lib/utils/version.cpp | |
parent | 5d101ca94e2a53ebd9313d35669320e87835c618 (diff) |
Add a new version function returning just the version without extras
Diffstat (limited to 'src/lib/utils/version.cpp')
-rw-r--r-- | src/lib/utils/version.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/lib/utils/version.cpp b/src/lib/utils/version.cpp index ff4c4f0f3..d04856d37 100644 --- a/src/lib/utils/version.cpp +++ b/src/lib/utils/version.cpp @@ -16,18 +16,18 @@ namespace Botan { version they are running against. */ -/* -* Return the version as a string -*/ -std::string version_string() +#define QUOTE(name) #name +#define STR(macro) QUOTE(macro) + +const char* short_version_cstr() { - return std::string(version_cstr()); + return STR(BOTAN_VERSION_MAJOR) "." + STR(BOTAN_VERSION_MINOR) "." + STR(BOTAN_VERSION_PATCH); } const char* version_cstr() { -#define QUOTE(name) #name -#define STR(macro) QUOTE(macro) /* It is intentional that this string is a compile-time constant; @@ -46,9 +46,22 @@ const char* version_cstr() #endif ", revision " BOTAN_VERSION_VC_REVISION ", distribution " BOTAN_DISTRIBUTION_INFO ")"; + } #undef STR #undef QUOTE + +/* +* Return the version as a string +*/ +std::string version_string() + { + return std::string(version_cstr()); + } + +std::string short_version_string() + { + return std::string(short_version_cstr()); } uint32_t version_datestamp() { return BOTAN_VERSION_DATESTAMP; } @@ -66,16 +79,11 @@ std::string runtime_version_check(uint32_t major, { std::ostringstream oss; - if(major != version_major() || - minor != version_minor() || - patch != version_patch()) + if(major != version_major() || minor != version_minor() || patch != version_patch()) { - oss << "Warning: linked version (" - << Botan::version_major() << '.' - << Botan::version_minor() << '.' - << Botan::version_patch() - << ") does not match version built against (" - << major << '.' << minor << '.' << patch << ")\n"; + oss << "Warning: linked version (" << short_version_string() << ")" + << " does not match version built against " + << "(" << major << '.' << minor << '.' << patch << ")\n"; } return oss.str(); |