From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com" 27-MAY-1993 07:13:56.51
To:	EVERHART
CC:	
Subj:	Re: reading open files

X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>
Warnings-To: <>
Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com
Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com
Message-Id: <0096D1A7.1E5307E0.14745@WKUVX1.BITNET>
X400-Received: by mta bunyip.cc.uq.oz.au in /PRMD=OZ.AU/ADMD=TELEMEMO/C=AU/;
    Relayed; Thu, 27 May 1993 14:00:41 +1000
X400-Received: by /ADMD=telememo/C=au/; Relayed; Thu, 27 May 1993 13:57:00 +1000
X400-Received: by /PRMD=WMC/ADMD=TELEMEMO/C=AU/; converted (ia5-text); Relayed;
    Thu, 27 May 1993 13:59:49 +1000
Date: Thu, 27 May 1993 13:59:49 +1000
X400-Originator: Dave.D.B.S.Sneddon@MIS.WMC.wmc.telememo.au
X400-Recipients: non-disclosure:;
X400-Mts-Identifier: [/PRMD=WMC/ADMD=TELEMEMO/C=AU/;90102172503991/98676@WEST]
X400-Content-Type: P2-1984 (2)
From: Dave Sneddon <Dave.D.B.S.Sneddon@mis.wmc.wmc.telememo.au>
Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com
To: MacroMan@WKUVX1.BITNET
Subject: Re: reading open files

On the subject of reading open files...

Below is something I wrote a while back to allow the reading of open files.
It just uses DUMP to display those blocks of the disk contained within the
file as described in the file header.  I also have a piece of software that
allows reading/writing of open files - regardless of normal "File locked..."
type stuff.

dbs
David B Sneddon                                Sneddon@MIS.WMC.wmc.telememo.au
Senior Systems Programmer
Western Mining Corporation
-------------------------------------------------------------------------------
$ ! Procedure:  DUMP_INDEXF.COM
$ __vfy = "VFY_''f$parse(f$environment("procedure"),,,"name")'"
$ if (f$type('__vfy') .eqs. "") then __vfy = 0
$ __vfy_saved = f$verify(&__vfy)
$       set noon
$       on control_y then goto bail_out
$       dih_say = "write sys$output"
$       dih_disk = f$edit(P1, "collapse, upcase")
$       if (dih_disk .eqs. "") then goto missing_param
$       dih_index = f$edit(P2, "collapse, upcase")
$       if (dih_index .eqs. "") then goto missing_param
$       dih_disk = dih_disk - ":" + ":"
$       dih_prefix = dih_disk + "_" + dih_index - ":"
$       dih_indexf_sys = dih_disk + "[000000]indexf.sys"
$       dih_option = "!"
$       dump_contents = 0
$       P3 = f$edit(P3, "collapse, upcase")
$ if (P3 .eqs. "") then goto no_option
$       dump_contents = -1*(P3 .eqs. f$extract(0, f$length(P3), "DUMP"))
$       if (.not. dump_contents) then dih_option = P3
$no_option:
$       dih_output = "''dih_prefix'_HEADER.OUTPUT"
$       srh_output = "''dih_prefix'_SEARCH.OUTPUT"
$       not_text = ""
$       if (.not. dump_contents) then not_text = "NOT "
$       dih_say " "
$       dih_say " Contents of the file will ''not_text'be dumped"
$       dih_say " "
$       dih_cluster = f$getdvi(dih_disk, "cluster")
$       dih_maxfiles = f$getdvi(dih_disk, "maxfiles")
$       dih_block = ((dih_maxfiles + 4095)/4096) + (4*dih_cluster) + dih_index
$       dumpit/file_header/block=(start='dih_block',count=1) -
                'dih_indexf_sys'/output='dih_output'
$       search/nohigh 'dih_output' "dentification:","owner UIC:","File name:"
$ if (.not. dump_contents) then goto try_option
$       search/nohigh 'dih_output' "  Count:"/output='srh_output'
$       open/read/error=bail_out pointers 'srh_output'
$loop:
$       read/end=end_loop/error=end_loop pointers text
$       dih_say " "
$       dih_say "''text'"
$       text = f$edit(text, "upcase, collapse") - "LBN"
$       ret_count = f$element(1, ":", text)
$       ret_start = f$element(2, ":", text)
$       dumpit/blocks=(start='ret_start',count='ret_count') 'dih_disk'
$ goto loop
$end_loop:
$ goto bail_out
$try_option:
$       'dih_option' 'dih_output'
$ goto bail_out
$missing_param:
$       dih_say "%DUMPINDEXF-E-REQPARMIS, a required parameter is missing"
$ goto bail_out
$bail_out:
$       if (f$trnlnm("pointers") .nes. "") then close/nolog pointers
$ !'f$verify(__vfy_saved)'
$ exit
$ !+==========================================================================
$ !
$ ! Procedure:  DUMP_INDEXF.COM
$ !
$ ! Purpose:    Given a disk and file index number, dump the indexf block in
$ !             a formatted way so we can read it and dump the file up to
$ !             the end of the first lot of retrieval pointers.
$ !
$ ! Parameters:
$ !      P1     Device name.
$ !      P2     File index number of the file.
$ !     [P3]    Determines what is done with the output;
$ !               <null> does nothing with the file
$ !               DUMP will dump the contents of the disk blocks using the
$ !                     retieval pointers from the header
$ !               anything else will be executed as a command, e.g. TYPE
$ !                     ,TYPE/PAGE, PRINT and try to use the output of the
$ !                     formatted dump as the filename.
$ !
$ ! History:
$ !             28-Jun-1989, DBS; Version V1-001
$ !     001 -   Original version.  Taken from one that only dumped the index
$ !             entry.
$ !-==========================================================================
