constification
[exim.git] / src / src / version.c
CommitLineData
059ec3d9
PH
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
0a49a7a4 5/* Copyright (c) University of Cambridge 1995 - 2009 */
f9ba5e22 6/* Copyright (c) The Exim Maintainers 2010 - 2018 */
059ec3d9
PH
7/* See the file NOTICE for conditions of use and distribution. */
8
9/* Function for setting up the version string. */
10
11#include "exim.h"
12
6545de78 13#include "version.h"
059ec3d9
PH
14
15
16/* The header file cnumber.h contains a single line containing the
17compilation number, making it easy to have it updated automatically.
18Hence the fudgery below to get the number turned into a string, since
19we can't use #include inside a macro argument list */
20
21void
22version_init(void)
23{
24static uschar cnumber_buffer[24];
25static uschar date_buffer[32];
26
27uschar today[20];
28uschar *version_cnumber_format;
29
30int cnumber =
31#include "cnumber.h"
32;
33
34/* The odd magic after each of these is so they can be easily found
35for automatic patching to standard values when running regression tests.
36The reason that version_cnumber_format isn't just written inline in the
37sprintf() call is the gcc -Wall warns about a \0 in a format string. */
38
39version_cnumber = cnumber_buffer;
40version_cnumber_format = US"%d\0<<eximcnumber>>";
41sprintf(CS version_cnumber, CS version_cnumber_format, cnumber);
6545de78 42version_string = US EXIM_VERSION_STR "\0<<eximversion>>";
059ec3d9 43
6e411084
PP
44#ifdef EXIM_BUILD_DATE_OVERRIDE
45/* Reproducible build support; build tooling should have given us something looking like
46 * "25-Feb-2017 20:15:40" in EXIM_BUILD_DATE_OVERRIDE based on $SOURCE_DATE_EPOCH in environ
47 * per <https://reproducible-builds.org/specs/source-date-epoch/>
48 */
49version_date = date_buffer;
50version_date[0] = 0;
51Ustrncat(version_date, EXIM_BUILD_DATE_OVERRIDE, sizeof(date_buffer));
52
53#else
059ec3d9
PH
54Ustrcpy(today, __DATE__);
55if (today[4] == ' ') today[4] = '0';
56today[3] = today[6] = '-';
57
58version_date = date_buffer;
59version_date[0] = 0;
60Ustrncat(version_date, today+4, 3);
61Ustrncat(version_date, today, 4);
62Ustrncat(version_date, today+7, 4);
63Ustrcat(version_date, " ");
64Ustrcat(version_date, __TIME__);
6e411084 65#endif
059ec3d9
PH
66}
67
68/* End of version.c */