Botan  1.11.15
src/lib/utils/version.cpp
Go to the documentation of this file.
00001 /*
00002 * Version Information
00003 * (C) 1999-2013 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #include <botan/version.h>
00009 #include <botan/parsing.h>
00010 
00011 namespace Botan {
00012 
00013 /*
00014   These are intentionally compiled rather than inlined, so an
00015   application running against a shared library can test the true
00016   version they are running against.
00017 */
00018 
00019 /*
00020 * Return the version as a string
00021 */
00022 std::string version_string()
00023    {
00024    return std::string(version_cstr());
00025    }
00026 
00027 const char* version_cstr()
00028    {
00029 #define QUOTE(name) #name
00030 #define STR(macro) QUOTE(macro)
00031 
00032    /*
00033    It is intentional that this string is a compile-time constant;
00034    it makes it much easier to find in binaries.
00035    */
00036 
00037    return "Botan " STR(BOTAN_VERSION_MAJOR) "."
00038                    STR(BOTAN_VERSION_MINOR) "."
00039                    STR(BOTAN_VERSION_PATCH) " ("
00040                    BOTAN_VERSION_RELEASE_TYPE
00041 #if (BOTAN_VERSION_DATESTAMP != 0)
00042                    ", dated " STR(BOTAN_VERSION_DATESTAMP)
00043 #endif
00044                    ", revision " BOTAN_VERSION_VC_REVISION
00045                    ", distribution " BOTAN_DISTRIBUTION_INFO ")";
00046 
00047 #undef STR
00048 #undef QUOTE
00049    }
00050 
00051 u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; }
00052 
00053 /*
00054 * Return parts of the version as integers
00055 */
00056 u32bit version_major() { return BOTAN_VERSION_MAJOR; }
00057 u32bit version_minor() { return BOTAN_VERSION_MINOR; }
00058 u32bit version_patch() { return BOTAN_VERSION_PATCH; }
00059 
00060 }