The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
version.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Version checking functions
19  *
20  * @file src/lib/util/version.h
21  *
22  * @copyright 2016 The FreeRADIUS server project
23  * @copyright 2016 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24  */
25 RCSIDH(version_h, "$Id: 92de79b6f5a7889a903620685149d3886bef034e $")
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <freeradius-devel/build.h>
32 #include <freeradius-devel/missing.h>
33 
34 #include <stdint.h>
35 
36 #ifndef NDEBUG
37 # define RADIUSD_VERSION_DEVELOPER "DEVELOPER BUILD - "
38 #else
39 # define RADIUSD_VERSION_DEVELOPER ""
40 #endif
41 
42 #ifdef RADIUSD_VERSION_COMMIT
43 # define RADIUSD_VERSION_COMMIT_STRING " (git #" STRINGIFY(RADIUSD_VERSION_COMMIT) ")"
44 #else
45 # define RADIUSD_VERSION_COMMIT_STRING ""
46 #endif
47 
48 #ifndef ENABLE_REPRODUCIBLE_BUILDS
49 # define RADIUSD_VERSION_BUILD_TIMESTAMP ", built on " __DATE__ " at " __TIME__
50 #else
51 # define RADIUSD_VERSION_BUILD_TIMESTAMP ""
52 #endif
53 
54 /** Create a version string for a utility in the suite of FreeRADIUS utilities
55  *
56  * @param _x utility name
57  */
58 #define RADIUSD_VERSION_BUILD(_x) \
59  RADIUSD_VERSION_DEVELOPER \
60  _x " version " \
61  STRINGIFY(RADIUSD_VERSION_MAJOR) "." STRINGIFY(RADIUSD_VERSION_MINOR) "." STRINGIFY(RADIUSD_VERSION_INCRM) \
62  RADIUSD_VERSION_COMMIT_STRING \
63  ", for host " HOSTINFO \
64  RADIUSD_VERSION_BUILD_TIMESTAMP
65 
66 #ifdef WITHOUT_VERSION_CHECK
67 # define RADIUSD_MAGIC_NUMBER ((uint64_t) (0xf4ee4ad3f4ee4ad3))
68 # define MAGIC_PREFIX(_x) ((uint8_t) 0x00)
69 # define MAGIC_VERSION(_x) ((uint32_t) 0x00000000)
70 #else
71 /*
72  * Mismatch between debug builds between
73  * the modules and the server causes all
74  * kinds of strange issues.
75  */
76 # ifndef NDEBUG
77 # define MAGIC_PREFIX_DEBUG 01
78 # else
79 # define MAGIC_PREFIX_DEBUG 00
80 # endif
81 # define RADIUSD_MAGIC_NUMBER ((uint64_t) HEXIFY2(MAGIC_PREFIX_DEBUG, RADIUSD_VERSION))
82 # define MAGIC_PREFIX(_x) ((uint8_t) ((0xff00000000000000 & (_x)) >> 56))
83 # define MAGIC_VERSION(_x) ((uint32_t)((0x00ffffff00000000 & (_x)) >> 32))
84 # define MAGIC_COMMIT(_x) ((uint32_t)((0x00000000ffffffff & (_x))))
85 #endif
86 
87 /*
88  * Version check.
89  */
90 int fr_check_lib_magic(uint64_t magic);
91 
92 #ifdef __cplusplus
93 }
94 #endif
#define RCSIDH(h, id)
Definition: build.h:482
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition: version.c:40