SPDX: license tags (mostly by guesswork)
[exim.git] / src / exim_monitor / em_version.c
1 /*************************************************
2 *                  Exim Monitor                  *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2018 */
6 /* Copyright (c) The Exim Maintainers 2020 - 2021 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-only */
9
10 #define EM_VERSION_C
11
12 /* Needed by macros.h */
13 /* Some systems have PATH_MAX and some have MAX_PATH_LEN. */
14
15 #ifndef PATH_MAX
16 # ifdef MAX_PATH_LEN
17 #  define PATH_MAX MAX_PATH_LEN
18 # else
19 #  define PATH_MAX 1024
20 # endif
21 #endif
22
23 #include "mytypes.h"
24 #include "store.h"
25 #include "macros.h"
26 #include <string.h>
27 #include <stdlib.h>
28
29 #include "version.h"
30
31 extern uschar *version_string;
32 extern uschar *version_date;
33
34 void
35 version_init(void)
36 {
37 int i = 0;
38 uschar today[20];
39
40 version_string = US"2.06";
41
42 #ifdef EXIM_BUILD_DATE_OVERRIDE
43 /* Reproducible build support; build tooling should have given us something looking like
44  * "25-Feb-2017 20:15:40" in EXIM_BUILD_DATE_OVERRIDE based on $SOURCE_DATE_EPOCH in environ
45  * per <https://reproducible-builds.org/specs/source-date-epoch/>
46  */
47 version_date = US malloc(32);
48 version_date[0] = 0;
49 Ustrncat(version_date, EXIM_BUILD_DATE_OVERRIDE, 31);
50
51 #else
52 Ustrcpy(today, US __DATE__);
53 if (today[4] == ' ') i = 1;
54 today[3] = today[6] = '-';
55
56 version_date = US malloc(32);
57 version_date[0] = 0;
58 Ustrncat(version_date, today+4+i, 3-i);
59 Ustrncat(version_date, today, 4);
60 Ustrncat(version_date, today+7, 4);
61 Ustrcat(version_date, US" ");
62 Ustrcat(version_date, US __TIME__);
63 #endif
64 }
65
66 /* End of em_version.c */