Botan 3.6.1
Crypto and TLS for C&
version.h
Go to the documentation of this file.
1/*
2* Version Information
3* (C) 1999-2011,2015 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_VERSION_H_
9#define BOTAN_VERSION_H_
10
11#include <botan/types.h>
12#include <string>
13
14namespace Botan {
15
16/*
17* Get information describing the version
18*/
19
20/**
21* Get a human-readable single-line string identifying the version of Botan.
22* No particular format should be assumed.
23* @return version string
24*/
25BOTAN_PUBLIC_API(2, 0) std::string version_string();
26
27/**
28* Same as version_string() except returning a pointer to a statically
29* allocated string.
30* @return version string
31*/
32BOTAN_PUBLIC_API(2, 0) const char* version_cstr();
33
34/**
35* Return a version string of the form "MAJOR.MINOR.PATCH" where
36* each of the values is an integer.
37*/
38BOTAN_PUBLIC_API(2, 4) std::string short_version_string();
39
40/**
41* Same as version_short_string except returning a pointer to the string.
42*/
43BOTAN_PUBLIC_API(2, 4) const char* short_version_cstr();
44
45/**
46* Return the date this version of botan was released, in an integer of
47* the form YYYYMMDD. For instance a version released on May 21, 2013
48* would return the integer 20130521. If the currently running version
49* is not an official release, this function will return 0 instead.
50*
51* @return release date, or zero if unreleased
52*/
53BOTAN_PUBLIC_API(2, 0) uint32_t version_datestamp();
54
55/**
56* Get the major version number.
57* @return major version number
58*/
59BOTAN_PUBLIC_API(2, 0) uint32_t version_major();
60
61/**
62* Get the minor version number.
63* @return minor version number
64*/
65BOTAN_PUBLIC_API(2, 0) uint32_t version_minor();
66
67/**
68* Get the patch number.
69* @return patch number
70*/
71BOTAN_PUBLIC_API(2, 0) uint32_t version_patch();
72
73/**
74* Usable for checking that the DLL version loaded at runtime exactly matches the
75* compile-time version. Call using BOTAN_VERSION_* macro values, like so:
76*
77* ```
78* Botan::runtime_version_check(BOTAN_VERSION_MAJOR, BOTAN_VERSION_MINOR, BOTAN_VERSION_PATCH);
79* ```
80*
81* It will return an empty string if the versions match, or otherwise an error
82* message indicating the discrepancy. This only is useful in dynamic libraries,
83* where it is possible to compile and run against different versions.
84*/
85BOTAN_PUBLIC_API(2, 0) std::string runtime_version_check(uint32_t major, uint32_t minor, uint32_t patch);
86
87/*
88* Macros for compile-time version checks
89*
90* Return a value that can be used to compare versions. The current
91* (compile-time) version is available as the macro BOTAN_VERSION_CODE. For
92* instance, to choose one code path for version 3.1.0 and later, and another
93* code path for older releases:
94*
95* ```
96* #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(3,1,0)
97* // 3.1+ code path
98* #else
99* // code path for older versions
100* #endif
101* ```
102*/
103#define BOTAN_VERSION_CODE_FOR(a, b, c) ((a << 16) | (b << 8) | (c))
104
105/**
106* Compare using BOTAN_VERSION_CODE_FOR, as in
107* # if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,8,0)
108* # error "Botan version too old"
109* # endif
110*/
111#define BOTAN_VERSION_CODE BOTAN_VERSION_CODE_FOR(BOTAN_VERSION_MAJOR, BOTAN_VERSION_MINOR, BOTAN_VERSION_PATCH)
112
113} // namespace Botan
114
115#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
uint32_t version_minor()
Definition version.cpp:86
std::string version_string()
Definition version.cpp:67
const char * short_version_cstr()
Definition version.cpp:25
uint32_t version_major()
Definition version.cpp:82
const char * version_cstr()
Definition version.cpp:33
uint32_t version_datestamp()
Definition version.cpp:75
uint32_t version_patch()
Definition version.cpp:90
std::string short_version_string()
Definition version.cpp:71
std::string runtime_version_check(uint32_t major, uint32_t minor, uint32_t patch)
Definition version.cpp:94