diff options
author | lloyd <[email protected]> | 2011-02-07 22:11:23 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-02-07 22:11:23 +0000 |
commit | 02ed4e271a6287a0c23b137e826e62d2be752b82 (patch) | |
tree | e50ccc16f91dc52671fdd24dd5d36d4685968511 /src/utils | |
parent | 80d591ec716fb6cea829db45b68da1af4afd1d0e (diff) |
Add a new configure.py option --distribution-info which sets a macro
in build.h named BOTAN_DISTRIBUTION_INFO. The default value is
'unspecified'. People packaging botan could set this to another
value, for instance 'Gentoo 1.9.13-r3' or 'Debian 1.9.13-1', or
'pristine' to indicate a completely unmodified/stock version. This
was suggested by Zooko for Crypto++ in
http://sourceforge.net/apps/trac/cryptopp/ticket/11
and seemed like an idea worth stealing.
Don't default the version datestmap to the current day if unset,
instead set to zero. This allows applications to detect
unreleased versions. Document that version_datestamp will return
zero for unreleased versions.
Change the version_string function to return more information about
the current version, including the release date and distribution
information. It will now return strings like:
Botan 1.9.13 (released 20110207, distribution Gentoo 1.9.13-r3)
or for an unreleased version:
Botan 1.9.13 (unreleased version, distribution unspecified)
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/version.cpp | 20 | ||||
-rw-r--r-- | src/utils/version.h | 15 |
2 files changed, 25 insertions, 10 deletions
diff --git a/src/utils/version.cpp b/src/utils/version.cpp index 22827cbe5..cf3205d19 100644 --- a/src/utils/version.cpp +++ b/src/utils/version.cpp @@ -1,12 +1,13 @@ /* * Version Information -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2011 Jack Lloyd * * Distributed under the terms of the Botan license */ #include <botan/version.h> #include <botan/parsing.h> +#include <sstream> namespace Botan { @@ -21,9 +22,20 @@ namespace Botan { */ std::string version_string() { - return to_string(version_major()) + "." + - to_string(version_minor()) + "." + - to_string(version_patch()); + std::ostringstream out; + + out << "Botan " << version_major() << "." + << version_minor() << "." + << version_patch() << " ("; + + if(BOTAN_VERSION_DATESTAMP == 0) + out << "unreleased version"; + else + out << "released " << version_datestamp(); + + out << ", distribution " << BOTAN_DISTRIBUTION_INFO << ")"; + + return out.str(); } u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; } diff --git a/src/utils/version.h b/src/utils/version.h index 13d0ac8bb..219c261a5 100644 --- a/src/utils/version.h +++ b/src/utils/version.h @@ -1,6 +1,6 @@ /* * Version Information -* (C) 1999-2007 Jack Lloyd +* (C) 1999-2011 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -18,16 +18,19 @@ namespace Botan { */ /** -* Get the version string identifying the version of Botan. +* Get a human-readable string identifying the version of Botan. +* No particular format should be assumed. * @return version string */ BOTAN_DLL std::string version_string(); /** -* Return the date this version of botan was released, in an -* integer of the form YYYYMMDD. For instance a version released -* on May 21, 2013 would return the integer 20130521 -* @return release date +* Return the date this version of botan was released, in an integer of +* the form YYYYMMDD. For instance a version released on May 21, 2013 +* would return the integer 20130521. If the currently running version +* is not an official release, this function will return 0 instead. +* +* @return release date, or zero if unreleased */ BOTAN_DLL u32bit version_datestamp(); |