• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 13210394651

08 Feb 2025 12:33AM UTC coverage: 91.656% (-0.006%) from 91.662%
13210394651

push

github

web-flow
Merge pull request #4642 from randombit/jack/target-info-header

Add internal target_info.h header

94837 of 103471 relevant lines covered (91.66%)

11243945.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.0
/src/lib/utils/version.cpp
1
/*
2
* Version Information
3
* (C) 1999-2013,2015 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/version.h>
9

10
#include <botan/internal/fmt.h>
11
#include <botan/internal/target_info.h>
12

13
namespace Botan {
14

15
/*
16
  These are intentionally compiled rather than inlined, so an
17
  application running against a shared library can test the true
18
  version they are running against.
19
*/
20

21
// NOLINTNEXTLINE(*-macro-usage)
22
#define QUOTE(name) #name
23
// NOLINTNEXTLINE(*-macro-usage)
24
#define STR(macro) QUOTE(macro)
25

26
const char* short_version_cstr() {
5✔
27
   return STR(BOTAN_VERSION_MAJOR) "." STR(BOTAN_VERSION_MINOR) "." STR(BOTAN_VERSION_PATCH)
5✔
28
#if defined(BOTAN_VERSION_SUFFIX)
29
      STR(BOTAN_VERSION_SUFFIX)
30
#endif
31
         ;
32
}
33

34
const char* version_cstr() {
12✔
35
   /*
36
   It is intentional that this string is a compile-time constant;
37
   it makes it much easier to find in binaries.
38
   */
39

40
   return "Botan " STR(BOTAN_VERSION_MAJOR) "." STR(BOTAN_VERSION_MINOR) "." STR(BOTAN_VERSION_PATCH)
12✔
41
#if defined(BOTAN_VERSION_SUFFIX)
42
      STR(BOTAN_VERSION_SUFFIX)
43
#endif
44
         " ("
45
#if defined(BOTAN_UNSAFE_FUZZER_MODE) || defined(BOTAN_TERMINATE_ON_ASSERTS)
46
         "UNSAFE "
47
   #if defined(BOTAN_UNSAFE_FUZZER_MODE)
48
         "FUZZER MODE "
49
   #endif
50
   #if defined(BOTAN_TERMINATE_ON_ASSERTS)
51
         "TERMINATE ON ASSERTS "
52
   #endif
53
         "BUILD "
54
#endif
55
      BOTAN_VERSION_RELEASE_TYPE
56
#if(BOTAN_VERSION_DATESTAMP != 0)
57
         ", dated " STR(BOTAN_VERSION_DATESTAMP)
58
#endif
59
            ", revision " BOTAN_VERSION_VC_REVISION ", distribution " BOTAN_DISTRIBUTION_INFO ")";
12✔
60
}
61

62
#undef STR
63
#undef QUOTE
64

65
/*
66
* Return the version as a string
67
*/
68
std::string version_string() {
8✔
69
   return std::string(version_cstr());
8✔
70
}
71

72
std::string short_version_string() {
3✔
73
   return std::string(short_version_cstr());
3✔
74
}
75

76
uint32_t version_datestamp() {
3✔
77
   return BOTAN_VERSION_DATESTAMP;
3✔
78
}
79

80
/*
81
* Return parts of the version as integers
82
*/
83
uint32_t version_major() {
6,600✔
84
   return BOTAN_VERSION_MAJOR;
6,600✔
85
}
86

87
uint32_t version_minor() {
6,598✔
88
   return BOTAN_VERSION_MINOR;
6,598✔
89
}
90

91
uint32_t version_patch() {
6,597✔
92
   return BOTAN_VERSION_PATCH;
6,597✔
93
}
94

95
bool unsafe_for_production_build() {
×
96
#if defined(BOTAN_UNSAFE_FUZZER_MODE) || defined(BOTAN_TERMINATE_ON_ASSERTS)
97
   return true;
×
98
#else
99
   return false;
100
#endif
101
}
102

103
std::string runtime_version_check(uint32_t major, uint32_t minor, uint32_t patch) {
6,596✔
104
   if(major != version_major() || minor != version_minor() || patch != version_patch()) {
6,596✔
105
      return fmt("Warning: linked version ({}) does not match version built against ({}.{}.{})\n",
1✔
106
                 short_version_cstr(),
1✔
107
                 major,
108
                 minor,
109
                 patch);
1✔
110
   }
111

112
   return "";
6,595✔
113
}
114

115
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc