Fix GNU/Hurd build. Bug 3044
[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-or-later */
9
10 #define EM_VERSION_C
11
12 #include "mytypes.h"
13 #include "store.h"
14 #include "path_max.h"
15 #include "macros.h"
16 #include <string.h>
17 #include <stdlib.h>
18
19 #include "version.h"
20
21 extern uschar *version_string;
22 extern uschar *version_date;
23
24 void
25 version_init(void)
26 {
27 int i = 0;
28 uschar today[20];
29
30 version_string = US"2.06";
31
32 #ifdef EXIM_BUILD_DATE_OVERRIDE
33 /* Reproducible build support; build tooling should have given us something looking like
34  * "25-Feb-2017 20:15:40" in EXIM_BUILD_DATE_OVERRIDE based on $SOURCE_DATE_EPOCH in environ
35  * per <https://reproducible-builds.org/specs/source-date-epoch/>
36  */
37 version_date = US malloc(32);
38 version_date[0] = 0;
39 Ustrncat(version_date, EXIM_BUILD_DATE_OVERRIDE, 31);
40
41 #else
42 Ustrcpy(today, US __DATE__);
43 if (today[4] == ' ') i = 1;
44 today[3] = today[6] = '-';
45
46 version_date = US malloc(32);
47 version_date[0] = 0;
48 Ustrncat(version_date, today+4+i, 3-i);
49 Ustrncat(version_date, today, 4);
50 Ustrncat(version_date, today+7, 4);
51 Ustrcat(version_date, US" ");
52 Ustrcat(version_date, US __TIME__);
53 #endif
54 }
55
56 /* End of em_version.c */