1 /** 2 * Version Information 3 * 4 * Copyright: 5 * (C) 1999-2011 Jack Lloyd 6 * (C) 2014-2015 Etienne Cimon 7 * 8 * License: 9 * Botan is released under the Simplified BSD License (see LICENSE.md) 10 */ 11 module botan.utils.version_; 12 13 import botan.constants; 14 import botan.utils.types; 15 import botan.utils.parsing; 16 /* 17 * These are intentionally compiled so an application running against a 18 * shared library can test the true version they are running against. 19 */ 20 21 /** 22 * Get a human-readable string identifying the version of Botan. 23 * No particular format should be assumed. 24 * Returns: version string 25 */ 26 string versionString() 27 { 28 /* 29 It is intentional that this string is a compile-time constant; 30 it makes it much easier to find in binaries. 31 */ 32 return "Botan " ~ BOTAN_VERSION_MAJOR.to!string ~ "." 33 ~ BOTAN_VERSION_MINOR.to!string ~ "." 34 ~ BOTAN_VERSION_PATCH.to!string ~ " (" 35 ~ BOTAN_VERSION_RELEASE_TYPE.to!string 36 ~ ", dated " ~ BOTAN_VERSION_DATESTAMP.to!string 37 ~ ", revision " ~ BOTAN_VERSION_VC_REVISION.to!string 38 ~ ", distribution " ~ BOTAN_DISTRIBUTION_INFO.to!string ~ ")"; 39 } 40 41 /** 42 * Return the date this version of botan was released, in an integer of 43 * the form YYYYMMDD. For instance a version released on May 21, 2013 44 * would return the integer 20130521. If the currently running version 45 * is not an official release, this function will return 0 instead. 46 * 47 * Returns: release date, or zero if unreleased 48 */ 49 uint versionDatestamp() { return BOTAN_VERSION_DATESTAMP; } 50 51 /** 52 * Get the major version number. 53 * Returns: major version number 54 */ 55 uint versionMajor() { return BOTAN_VERSION_MAJOR; } 56 57 /** 58 * Get the minor version number. 59 * Returns: minor version number 60 */ 61 uint versionMinor() { return BOTAN_VERSION_MINOR; } 62 63 /** 64 * Get the patch number. 65 * Returns: patch number 66 */ 67 uint versionPatch() { return BOTAN_VERSION_PATCH; } 68 69 /* 70 * Allows compile-time version checks 71 */ 72 long BOTAN_VERSION_CODE_FOR(ubyte a, ubyte b, ubyte c) { 73 return ((a << 16) | (b << 8) | (c)); 74 } 75 76 /** 77 * Compare using BOTAN_VERSION_CODE_FOR, as in 78 * static assert (BOTAN_VERSION_CODE > BOTAN_VERSION_CODE_FOR(1,8,0), "Botan version too old"); 79 */ 80 static long BOTAN_VERSION_CODE = BOTAN_VERSION_CODE_FOR(BOTAN_VERSION_MAJOR, BOTAN_VERSION_MINOR, BOTAN_VERSION_PATCH);