Article 140236 of comp.os.vms:
Path: nntpd.lkg.dec.com!eps.enet.dec.com!vandenheuvel
From: vandenheuvel@eps.enet.dec.com (Hein RMS van den Heuvel)
Newsgroups: comp.os.vms
Subject: Re: Obtaining link date/time from within a program
Date: 13 FEB 96 17:37:59
Organization: Digital Equipment Corporation
Lines: 49
Distribution: world
Message-ID: <4fr4g2$at7@nntpd.lkg.dec.com>
References: <4fnrer$6on@lightning.cise.npl.co.uk> <4fqm12$k8p@gap.cco.caltech.edu>
NNTP-Posting-Host: amuzed.enet.dec.com


In article <4fqm12$k8p@gap.cco.caltech.edu>, carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick) writes...
>In article <4fnrer$6on@lightning.cise.npl.co.uk>, GPC@newton.npl.co.uk (Graham Carter Blg 93) writes:
>=Hi,
>=
>=Does anyone know how a Pascal program can obtain the date/time it was
>=linked?  A user wants to do this to comply with the requirements of
 : 
>Well, here's one way to do it using C on a VAX:
 :
>	if((fd = open(buffer, "r", "shr=put")) == NULL)
 :
>	timadr[0] = * ((long *)	(buffer+144));

Not bad. But the the hardcoded 144 is a bit rough, as is really an
offset in a IHI structure pointed to by an offset in the header (IHD).

Those structures are defined in $IHDDEF and $IHIDEF in SYS$LIBRARY:LIB.MLB
Also, the image header is already in memory and user readable pointed
to by MMG$IMGHDRBUF. 

In all languages but C, the image header buffer is also the third parameter
with which a main is called. [Yes, I know, you can get your own routine to 
be called in C upon image activation but that's a bit harder]

Anyway, here is an alternative (VAX C) solution...

#include descrip
#include stdio
globalref void *MMG$IMGHDRBUF;
main ()
{
	struct { unsigned short SIZE, ACTIVOFF, SYMDBGOFF, IMGIDOFF; } *ihd;
	struct { unsigned char IMGNAM[40], IMGID[16], LINKTIME[8]; } *ihi;
	static char timbuf[24];
	$DESCRIPTOR(timbuf_dx, timbuf);
	ihd = MMG$IMGHDRBUF;
	ihi = (void *) ((unsigned int)ihd + ihd->IMGIDOFF);
	sys$asctim(0,&timbuf_dx,&ihi->LINKTIME[0],0);
	timbuf[20]=0;	
	printf ("Image: %.*s, Linked: %s.\n", 
		ihi->IMGNAM[0], &ihi->IMGNAM[1], timbuf);
}


Hope this helps,		+--------------------------------------+
Hein van den Heuvel, Digital.	| All opinions expressed are mine, and |
  "Makers of VMS and other	| may not reflect those of my employer |
   fine Operating Systems."	+--------------------------------------+


