From: David M Smith [dsmit115@csc.com] Sent: Wednesday, April 16, 2003 2:07 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: [OpenVMS Alpha] How to get image version in DCL ? On Wed, 16 Apr 2003 13:21:40 -0400, David M Smith wrote: >On Wed, 16 Apr 2003 08:46:37 +0100, Chris Sharman >wrote: > >>$ open/read i 'f$parse(p1,".exe")' >>$ read i h >>$ close i > ... > >Thanks! A few minor omissions in the code you posted (SAY symbol, NOVMS_IMAGE >label not defined) but otherwise looks good. What are the symbols DEBUG and >SHARE all about? You get them, but don't display them. To followup on my own post, since I did the work to address what I considered limitations, I thought I should repost it, so here is Chris's original with some minor changes. This version can be called with an optional P2 which, if any DCL true value (i.e., 1, YES, TRUE, etc.) suppresses output and writes the information to a set of global symbols with names of the form IMGID_xxxx. For example: $ @imgid trnlnm Image identification information for TRNLNM.EXE Image type: VAX Image name: "TRNLNM" Image identification: "V1.0-00" Link Date/Time: 9-JAN-2001 14:43:03.87 Linker Identification: "05-13" $ @imgid trnlnm 1 $ sho sym imgid* IMGID_FULLFILE == "TRNLNM.EXE" IMGID_IMGID == "V1.0-00" IMGID_IMGNAME == "TRNLNM" IMGID_LINKDATE == " 9-JAN-2001 14:43:03.87" IMGID_LINKID == "05-13" IMGID.COM follows... --- cut --- $! IMGID.COM -- Get Image Identification Information $ if p1 .eqs. "" then $ inquire p1 "Image filename" $ if p1 .eqs. "" then $ exit 1 $ say = "write sys$output" $ fullfile = p1 $ tmpname = f$parse(fullfile,".MISSING") $ ftype = f$parse(tmpname,,,"type","syntax_only") $ if ftype .eqs. ".MISSING" then $ fullfile = fullfile + ".EXE" $! $ open/read/error=no_such_file i 'fullfile' $ read i h $ close i $ if f$length(h).ne.512 then $ goto novms_image $ if f$cvui(0,32,h).lt.16 $ then $ arch = "Alpha" $ debug_byte = 80 $ hi = f$extract(f$cvui(24*8,32,h),104,h) $ imgtimo = 8 $ imgnam = f$extract(17,f$cvui(16*8,8,hi),hi) $ imgid = f$extract(57,f$cvui(56*8,8,hi),hi) $ linkid = f$extract(73,f$cvui(72*8,8,hi),hi) $ else $ arch = "VAX" $ debug_byte = 32 $ hi = f$extract(f$cvui(6*8,16,h),80,h) $ imgnam = f$extract(1,f$cvui(0,8,hi),hi) $ imgid = f$extract(41,f$cvui(40*8,8,hi),hi) $ imgtimo = 56 $ linkid = f$extract(65,f$cvui(64*8,8,hi),hi) $ endif $ linkdate = f$fao("!%D",imgtimo+f$cvui(32,32,f$fao("!AD",8,hi))) $ debug = f$cvui(debug_byte*8,1,h) $ share = f$cvui(debug_byte*8+6,1,h) $ if .not. p2 $ then $ say "Image identification information for ",fullfile $ say "" $ say " Image type: ",arch $ say " Image name: """,imgnam,"""" $ say " Image identification: """,imgid,"""" $ say " Link Date/Time: ",linkdate $ say " Linker Identification: """,linkid,"""" $ else $ imgid_fullfile == fullfile $ imgid_imgname == imgnam $ imgid_imgid == imgid $ imgid_linkdate == linkdate $ imgid_linkid == linkid $ endif $ exit %x10000001 $no_such_file: $ say "%IMGID-E-NOSUCHFILE, file ''fullfile' not found" $ exit %x10000002 $novms_image: $ say "%IMGID-E-NOTIMAGE, ''p1' is not a VMS image" $ exit %x10000002 $!++ $! IMGID.COM -- Get Image Identification Information $! $$!^^^^^^^^^^^^^^^^^^^^^^ TIME DCL MAGIC ^^^^^^^^^^^^^^^^^^^^^^^^^^^ $! Explanation: hi is a string & therefore passed by descriptor $! f$fao("!AD",n,s) expects a string by reference, & therefore $! returns the binary descriptor of hi as an 8 byte string $! f$cvui(32,32,desc) returns the actual address of hi from $! the descriptor (2nd longword) $! add whatever offset into the record is required $! f$fao("!%D",a) expects a quadword by reference, and gets $! the carefully constructed address of a quadword time $!-- $! Revision history: $! 16-Apr-2003 Chris Sharman $! . Original version posted in comp.os.vms. $! 16-Apr-2003 Dave Smith $! . Address minor shortcomings. $! . Add support for output to global symbols. --- cut --- ------------------------------------------------------------------------- David M. Smith 302.391.8533 dsmit115 at csc dot com Computer Sciences Corporation (Opinions are those of the writer only) -------------------------------------------------------------------------