summaryrefslogtreecommitdiffstats
path: root/Modules/getbuildinfo.c
blob: 23b57c559d95a367bca0044661ef0ac1809bdc29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "Python.h"

#ifdef macintosh
#include "macbuildno.h"
#endif

#ifndef DONT_HAVE_STDIO_H
#include <stdio.h>
#endif

#ifndef DATE
#ifdef __DATE__
#define DATE __DATE__
#else
#define DATE "xx/xx/xx"
#endif
#endif

#ifndef TIME
#ifdef __TIME__
#define TIME __TIME__
#else
#define TIME "xx:xx:xx"
#endif
#endif

#ifndef BUILD
#define BUILD 0
#endif

#ifdef __VMS
#  ifdef __DECC
#    pragma extern_model save
#    pragma extern_model strict_refdef
extern long ctl$gl_imghdrbf;
#    pragma extern_model restore
#  endif

#  ifdef __ALPHA
#    define EIHD$L_IMGIDOFF 24
#    define EIHI$Q_LINKTIME  8
#    define _IMGIDOFF EIHD$L_IMGIDOFF
#    define _LINKTIME EIHI$Q_LINKTIME
#  else
#    define IHD$W_IMGIDOFF  6
#    define IHI$Q_LINKTIME 56
#    define _IMGIDOFF IHD$W_IMGIDOFF
#    define _LINKTIME IHI$Q_LINKTIME
#  endif /* __VMS */

long*
vms__get_linktime (void)
{
	long* al_imghdrbf;
	unsigned short* aw_imgidoff;
	unsigned short	  w_imgidoff;
	long* aq_linktime;
	unsigned char* ab_ihi;

	al_imghdrbf = &ctl$gl_imghdrbf;

	al_imghdrbf = (long *)*al_imghdrbf;
	al_imghdrbf = (long *)*al_imghdrbf;

	aw_imgidoff = (unsigned short *)
		((unsigned char *)al_imghdrbf + _IMGIDOFF);

	w_imgidoff = *aw_imgidoff;

	ab_ihi = (unsigned char *)al_imghdrbf + w_imgidoff;

	aq_linktime = (long *) (ab_ihi + _LINKTIME);

	return aq_linktime;
} /* vms__get_linktime (void) */
extern void vms__cvt_v2u_time (long * aq_vmstime, time_t * al_unixtime);
			    /* input		, output */
#endif /* __VMS */


const char *
Py_GetBuildInfo(void)
{
	static char buildinfo[50];
#ifdef __VMS
	time_t l_unixtime;

	vms__cvt_v2u_time(vms__get_linktime (), &l_unixtime );

	memset(buildinfo, 0, 40);
	sprintf(buildinfo, "#%d, %.24s", BUILD, ctime (&l_unixtime));
#else
	PyOS_snprintf(buildinfo, sizeof(buildinfo),
		      "#%d, %.20s, %.9s", BUILD, DATE, TIME);
#endif
	return buildinfo;
}