From:	CSBVAX::MRGATE!@KL.SRI.Com,@wiscvm.wisc.edu:JOE@FHCRCVAX.BITNET@SMTP 15-SEP-1987 23:30
To:	EVERHART
Subj:	INDEX, Part 5 of 5

Received: from wiscvm.wisc.edu by KL.SRI.COM with TCP; Tue 15 Sep 87 13:11:16-PDT
Received: from FHCRCVAX.BITNET by wiscvm.wisc.edu ; Tue, 15 Sep 87 14:48:08 CDT
Date: Tue, 15 Sep 87 09:16 PDT
From: Joe Meadows <JOE%FHCRCVAX.BITNET@wiscvm.wisc.edu>
Subject: INDEX, Part 5 of 5
To: info-vax@kl.sri.COM
X-VMS-To: IN%"info-vax@kl.sri.com"

Here's part 5 of INDEX, parts 1-4 having been previously posted.
Since I have not seen part 2 yet, I will be posting it again on
wednesday.

  Cheers,
  Joe Meadows Jr.
  VAX/VMS System Manager / guru in training
  Fred Hutchinson Cancer Research Center
  1124 Columbia St.
  Seattle Wa. 98104
     bitnet - JOE@FHCRCVAX
     arpa   - JOE%FHCRCVAX.BITNET@WISCVM.WISC.EDU
     voice  - (206) 467-4970

$ create/log IODEF.H
$DECK
/* This header file was created by Joe Meadows, and is not copyrighted
   in any way. No guarantee is made as to the accuracy of the contents
   of this header file. This header file was last modified on Sep. 8th,
   1987. */
#define IO$_NOP 0
#define IO$_UNLOAD      1
#define IO$_LOADMCODE   1
#define IO$_SEEK        2
#define IO$_SPACEFILE   2
#define IO$_STARTMPROC  2
#define IO$_RECAL       3
#define IO$_STOP        3
#define IO$_DRVCLR      4
#define IO$_INITIALIZE  4
#define IO$_RELEASE     5
#define IO$_SETCLOCKP   5
#define IO$_OFFSET      6
#define IO$_ERASETAPE   6
#define IO$_STARTDATAP  6
#define IO$_RETCENTER   7
#define IO$_QSTOP       7
#define IO$_PACKACK     8
#define IO$_SEARCH      9
#define IO$_SPACERECORD 9
#define IO$_READRCT     9
#define IO$_WRITECHECK  10
#define IO$_WRITEPBLK   11
#define IO$_READPBLK    12
#define IO$_WRITEHEAD   13
#define IO$_RDSTATS     13
#define IO$_CRESHAD     13
#define IO$_READHEAD    14
#define IO$_ADDSHAD     14
#define IO$_WRITETRACKD 15
#define IO$_COPYSHAD    15
#define IO$_READTRACKD  16
#define IO$_REMSHAD     16
#define IO$_AVAILABLE   17
#define IO$_SETPRFPATH  18
#define IO$_DSE 21
#define IO$_REREADN     22
#define IO$_REREADP     23
#define IO$_WRITERET    24
#define IO$_WRITECHECKH 24
#define IO$_READPRESET  25
#define IO$_STARTSPNDL  25
#define IO$_SETCHAR     26
#define IO$_SENSECHAR   27
#define IO$_WRITEMARK   28
#define IO$_WRTTMKR     29
#define IO$_DIAGNOSE    29
#define IO$_SHADMV      29
#define IO$_FORMAT      30
#define IO$_CLEAN       30
#define IO$_PHYSICAL    31
#define IO$_WRITELBLK   32
#define IO$_READLBLK    33
#define IO$_REWINDOFF   34
#define IO$_SETMODE     35
#define IO$_REWIND      36
#define IO$_SKIPFILE    37
#define IO$_SKIPRECORD  38
#define IO$_SENSEMODE   39
#define IO$_WRITEOF     40
#define IO$_TTY_PORT    41
#define IO$_LOGICAL     47
#define IO$_WRITEVBLK   48
#define IO$_READVBLK    49
#define IO$_ACCESS      50
#define IO$_CREATE      51
#define IO$_DEACCESS    52
#define IO$_DELETE      53
#define IO$_MODIFY      54
#define IO$_NETCONTROL  54
#define IO$_READPROMPT  55
#define IO$_SETCLOCK    55
#define IO$_ACPCONTROL  56
#define IO$_STARTDATA   56
#define IO$_MOUNT       57
#define IO$_TTYREADALL  58
#define IO$_TTYREADPALL 59
#define IO$_CONINTREAD  60
#define IO$_CONINTWRITE 61
#define IO$_VIRTUAL     63
#define IO$M_FCODE      63
#define IO$M_FMODIFIERS 65472
#define IO$M_INHERLOG   2048
#define IO$M_ERASE      1024
#define IO$M_ENCRYPT    8192
#define IO$M_DATACHECK  16384
#define IO$M_INHRETRY   32768
#define IO$M_INHSEEK    4096
#define IO$M_REVERSE    64
#define IO$M_NOWAIT     128
#define IO$M_INHEXTGAP  4096
#define IO$M_MSCPMODIFS 256
#define IO$M_SHADOW     64
#define IO$M_LOCATE     128
#define IO$M_ALLHOSTS   64
#define IO$M_DISSOLVE   128
#define IO$M_NOCLEANUP  256
#define IO$M_SPINDOWN   64
#define IO$M_FORCEPATH  64
#define IO$M_COMMOD     64
#define IO$M_MOVETRACKD 128
#define IO$M_DIAGNOSTIC 256
#define IO$M_SKPSECINH  512
#define IO$M_DELDATA    64
#define IO$M_NOMRSP     64
#define IO$M_SWAP       256
#define IO$M_OPPOSITE   512
#define IO$M_CLSEREXCP  512
#define IO$M_ACCESS     64
#define IO$M_CREATE     128
#define IO$M_DELETE     256
#define IO$M_MOUNT      512
#define IO$M_DMOUNT     1024
#define IO$M_REMOUNT    2048
#define IO$M_BINARY     64
#define IO$M_PACKED     128
#define IO$M_NOW        64
#define IO$M_READATTN   128
#define IO$M_WRTATTN    256
#define IO$M_SETPROT    512
#define IO$M_NORSWAIT   1024
#define IO$M_NOECHO     64
#define IO$M_TIMED      128
#define IO$M_CVTLOW     256
#define IO$M_NOFILTR    512
#define IO$M_DSABLMBX   1024
#define IO$M_PURGE      2048
#define IO$M_TRMNOECHO  4096
#define IO$M_REFRESH    8192
#define IO$M_ESCAPE     16384
#define IO$M_EXTEND     32768
#define IO$M_CANCTRLO   64
#define IO$M_ENABLMBX   128
#define IO$M_NOFORMAT   256
#define IO$M_BREAKTHRU  512
#define IO$M_NEWLINE    1024
#define IO$M_TYPEAHDCNT 64
#define IO$M_MAINT      64
#define IO$M_CTRLYAST   128
#define IO$M_CTRLCAST   256
#define IO$M_HANGUP     512
#define IO$M_OUTBAND    1024
#define IO$M_TT_CONNECT 2048
#define IO$M_TT_DISCON  4096
#define IO$M_TT_PROCESS 8192
#define IO$M_BRDCST     16384
#define IO$M_LOOP       128
#define IO$M_UNLOOP     256
#define IO$M_LINE_OFF   512
#define IO$M_SET_MODEM  1024
#define IO$M_LINE_ON    2048
#define IO$M_LOOP_EXT   4096
#define IO$M_AUTXOF_ENA 8192
#define IO$M_AUTXOF_DIS 16384
#define IO$M_INCLUDE    2048
#define IO$M_TT_ABORT   4096
#define IO$M_INTERRUPT  64
#define IO$M_ABORT      256
#define IO$M_SYNCH      512
#define IO$M_STARTUP    64
#define IO$M_SHUTDOWN   128
#define IO$M_ATTNAST    256
#define IO$M_CTRL       512
#define IO$M_RD_MEM     64
#define IO$M_RD_MODEM   128
#define IO$M_RD_COUNT   256
#define IO$M_CLR_COUNT  1024
#define IO$K_SRRUNOUT   0
#define IO$K_PTPBSC     8192
#define IO$K_LOOPTEST   57344
#define IO$M_MORE       64
#define IO$M_QUALIFIED  128
#define IO$M_REDIRECT   64
#define IO$M_ACCEPT     128
#define IO$M_SETEVF     64
#define IO$M_WORD       64
#define IO$M_SETFNCT    512
#define IO$M_DATAPATH   1024
#define IO$M_CYCLE      4096
#define IO$M_RESET      8192
#define IO$M_SETCUADR   256
#define IO$M_SETBSIZE   512
#define IO$M_SETPOOLSZ  1024
#define IO$M_SETENQCNT  2048
#define IO$M_CLEAR      4096
#define IO$M_LPBEXT     8192
#define IO$M_LPBINT     16384
#define IO$M_READCSR    32768
#define IO$M_NOCTSWAIT  64
#define IO$M_SLAVLOOP   128
#define IO$M_NODSRWAIT  256
#define IO$M_MAINTLOOP  512
#define IO$M_LASTBLOCK  1024
#define IO$M_INTCLOCK   4096
#define IO$S_IODEF      2
#define IO$S_FCODE      6
#define IO$V_FCODE      0
#define IO$S_FMODIFIERS 10
#define IO$V_FMODIFIERS 6
#define IO$V_INHERLOG   11
#define IO$V_ERASE      10
#define IO$V_ENCRYPT    13
#define IO$V_DATACHECK  14
#define IO$V_INHRETRY   15
#define IO$V_INHSEEK    12
#define IO$V_REVERSE    6
#define IO$V_NOWAIT     7
#define IO$V_INHEXTGAP  12
#define IO$V_MSCPMODIFS 8
#define IO$V_SHADOW     6
#define IO$V_LOCATE     7
#define IO$V_ALLHOSTS   6
#define IO$V_DISSOLVE   7
#define IO$V_NOCLEANUP  8
#define IO$V_SPINDOWN   6
#define IO$V_FORCEPATH  6
#define IO$V_COMMOD     6
#define IO$V_MOVETRACKD 7
#define IO$V_DIAGNOSTIC 8
#define IO$V_SKPSECINH  9
#define IO$V_DELDATA    6
#define IO$V_NOMRSP     6
#define IO$V_SWAP       8
#define IO$V_OPPOSITE   9
#define IO$V_CLSEREXCP  9
#define IO$V_ACCESS     6
#define IO$V_CREATE     7
#define IO$V_DELETE     8
#define IO$V_MOUNT      9
#define IO$V_DMOUNT     10
#define IO$V_REMOUNT    11
#define IO$V_BINARY     6
#define IO$V_PACKED     7
#define IO$V_NOW        6
#define IO$V_READATTN   7
#define IO$V_WRTATTN    8
#define IO$V_SETPROT    9
#define IO$V_NORSWAIT   10
#define IO$V_NOECHO     6
#define IO$V_TIMED      7
#define IO$V_CVTLOW     8
#define IO$V_NOFILTR    9
#define IO$V_DSABLMBX   10
#define IO$V_PURGE      11
#define IO$V_TRMNOECHO  12
#define IO$V_REFRESH    13
#define IO$V_ESCAPE     14
#define IO$V_EXTEND     15
#define IO$V_CANCTRLO   6
#define IO$V_ENABLMBX   7
#define IO$V_NOFORMAT   8
#define IO$V_BREAKTHRU  9
#define IO$V_NEWLINE    10
#define IO$V_TYPEAHDCNT 6
#define IO$V_MAINT      6
#define IO$V_CTRLYAST   7
#define IO$V_CTRLCAST   8
#define IO$V_HANGUP     9
#define IO$V_OUTBAND    10
#define IO$V_TT_CONNECT 11
#define IO$V_TT_DISCON  12
#define IO$V_TT_PROCESS 13
#define IO$V_BRDCST     14
#define IO$V_LOOP       7
#define IO$V_UNLOOP     8
#define IO$V_LINE_OFF   9
#define IO$V_SET_MODEM  10
#define IO$V_LINE_ON    11
#define IO$V_LOOP_EXT   12
#define IO$V_AUTXOF_ENA 13
#define IO$V_AUTXOF_DIS 14
#define IO$V_INCLUDE    11
#define IO$V_TT_ABORT   12
#define IO$V_INTERRUPT  6
#define IO$V_ABORT      8
#define IO$V_SYNCH      9
#define IO$V_STARTUP    6
#define IO$V_SHUTDOWN   7
#define IO$V_ATTNAST    8
#define IO$V_CTRL       9
#define IO$V_RD_MEM     6
#define IO$V_RD_MODEM   7
#define IO$V_RD_COUNT   8
#define IO$V_CLR_COUNT  10
#define IO$V_MORE       6
#define IO$V_QUALIFIED  7
#define IO$V_REDIRECT   6
#define IO$V_ACCEPT     7
#define IO$V_SETEVF     6
#define IO$V_WORD       6
#define IO$V_SETFNCT    9
#define IO$V_DATAPATH   10
#define IO$V_CYCLE      12
#define IO$V_RESET      13
#define IO$V_SETCUADR   8
#define IO$V_SETBSIZE   9
#define IO$V_SETPOOLSZ  10
#define IO$V_SETENQCNT  11
#define IO$V_CLEAR      12
#define IO$V_LPBEXT     13
#define IO$V_LPBINT     14
#define IO$V_READCSR    15
#define IO$V_NOCTSWAIT  6
#define IO$V_SLAVLOOP   7
#define IO$V_NODSRWAIT  8
#define IO$V_MAINTLOOP  9
#define IO$V_LASTBLOCK  10
#define IO$V_INTCLOCK   12
$EOD
$ create/log PARSE_UIC.MAR
$DECK
$tpadef

tparse_init:
        .long   tpa$k_count0
        .long   tpa$m_blanks!tpa$m_abbrev
tparse: .blkb   tpa$k_length0

        $init_state     uic_stb,uic_ktb
        $state
        $tran   tpa$_ident,,,,uic
        $state
        $tran   tpa$_eos,tpa$_exit
        $end_state

uic:    .long

        .entry  parse_uic,^m<r2,r3,r4,r5>

        ; initialize tparse block
        movc5   #8,tparse_init,#0,#tpa$k_length0,tparse

        ; set the tparse block string info
        movl    4(ap),r0
        movzwl  (r0),tparse+tpa$l_stringcnt
        movl    4(r0),tparse+tpa$l_stringptr

        ; call lib$tparse
        pushab  uic_ktb
        pushab  uic_stb
        pushab  tparse
        calls   #3,g^lib$tparse

        movl    uic,@8(ap)
        ret

        .end
$EOD
$ create/log SEARCHDEF.H
$DECK
/* This header file was created by Joe Meadows, and is not copyrighted
   in any way. No guarantee is made as to the accuracy of the contents
   of this header file. This header file was last modified on Sep. 8th,
   1987. */
#include descrip

#define DATE { unsigned : 32; unsigned : 32; }

#define SI_K_LBN_LIST_SIZE 40
#define SI_K_OWNER_LIST_SIZE 40
#define SI_K_BACKLINK_LIST_SIZE 40
#define SI_K_ACL_ID_LIST_SIZE 40

struct search_info {
  variant_union {
    variant_struct {
      long int si_l_srchbits0;
      long int si_l_srchbits1;
    } si_dummy_srchbits_struct;
    variant_struct {
      unsigned si_v_credat : 1;
      unsigned si_v_revdat : 1;
      unsigned si_v_expdat : 1;
      unsigned si_v_bakdat : 1;
      unsigned si_v_revision : 1;
      unsigned si_v_extents : 1;
      unsigned si_v_headers : 1;
      unsigned si_v_lbn : 1;
      unsigned si_v_owner : 1;
      unsigned si_v_char : 1;
      unsigned si_v_journal : 1;
      unsigned si_v_prot : 1;
      unsigned si_v_backlink : 1;
      unsigned si_v_access : 1;
      unsigned si_v_highwater : 1;
      unsigned si_v_ru_active : 1;
      unsigned si_v_rectype : 1;
      unsigned si_v_fileorg : 1;
      unsigned si_v_attrib : 1;
      unsigned si_v_rsize : 1;
      unsigned si_v_alloc : 1;
      unsigned si_v_used : 1;
      unsigned si_v_wasted : 1;
      unsigned si_v_bktsize : 1;
      unsigned si_v_vfcsize : 1;
      unsigned si_v_maxrec : 1;
      unsigned si_v_defext : 1;
      unsigned si_v_gbc : 1;
      unsigned si_v_ffbyte : 1;
      unsigned si_v_version_limit : 1;
      unsigned si_v_filename : 1;
      unsigned si_v_placement : 1;
      unsigned si_v_aclexists : 1;
      unsigned si_v_aclcontains : 1;
    } si_dummy_srchbits;
  } si_dummy_srch_union;
  unsigned si_v_and_match : 1;
  struct DATE si_q_credat_min;
  struct DATE si_q_credat_max;
  struct DATE si_q_revdat_min;
  struct DATE si_q_revdat_max;
  struct DATE si_q_expdat_min;
  struct DATE si_q_expdat_max;
  struct DATE si_q_bakdat_min;
  struct DATE si_q_bakdat_max;
  unsigned long int si_l_revision_min;
  unsigned long int si_l_revision_max;
  unsigned long int si_l_extents_min;
  unsigned long int si_l_extents_max;
  unsigned long int si_l_headers_min;
  unsigned long int si_l_headers_max;
  unsigned long int si_l_alloc_min;
  unsigned long int si_l_alloc_max;
  unsigned long int si_l_used_min;
  unsigned long int si_l_used_max;
  unsigned long int si_l_wasted_min;
  unsigned long int si_l_wasted_max;
  unsigned long si_l_highwater_min;
  unsigned long si_l_highwater_max;
  unsigned short int si_w_rsize_min;
  unsigned short int si_w_rsize_max;
  unsigned char si_b_bktsize_min;
  unsigned char si_b_bktsize_max;
  unsigned char si_b_vfcsize_min;
  unsigned char si_b_vfcsize_max;
  unsigned char si_b_ru_active_min;
  unsigned char si_b_ru_active_max;
  unsigned short int si_w_maxrec_min;
  unsigned short int si_w_maxrec_max;
  unsigned short int si_w_defext_min;
  unsigned short int si_w_defext_max;
  unsigned short int si_w_gbc_min;
  unsigned short int si_w_gbc_max;
  unsigned short int si_w_ffbyte_min;
  unsigned short int si_w_ffbyte_max;
  unsigned short int si_w_version_limit_min;
  unsigned short int si_w_version_limit_max;

  variant_union {
    unsigned char si_b_fileorgset;
    struct si_fileorgdef {
      unsigned v_sequential : 1;
      unsigned v_relative : 1;
      unsigned v_indexed : 1;
      unsigned v_direct : 1;
    } si_fileorgset;
  } si_dummy_fileorgset_union;
  variant_union {
    unsigned char si_b_fileorgclr;
    struct si_fileorgdef si_fileorgclr;
  } si_dummy_fileorgclr_union;

  variant_union {
    unsigned char si_b_rectypeset;
    struct si_rectypedef {
      unsigned v_undefined : 1;
      unsigned v_fixed : 1;
      unsigned v_variable : 1;
      unsigned v_vfc : 1;
      unsigned v_stream : 1;
      unsigned v_streamlf : 1;
      unsigned v_streamcr : 1;
    } si_rectypeset;
  } si_dummy_rectypeset_union;
  variant_union {
    unsigned char si_b_rectypeclr;
    struct si_rectypedef si_rectypeclr;
  } si_dummy_rectypeclr_union;

  variant_union {
    unsigned long int si_l_charset;
    struct si_chardef {
      unsigned : 1;
      unsigned v_nobackup : 1;
      unsigned v_writeback : 1;
      unsigned v_readcheck : 1;
      unsigned v_writcheck : 1;
      unsigned v_contigb : 1;
      unsigned v_locked : 1;
      unsigned v_contig : 1;
      unsigned : 3;
      unsigned v_badacl : 1;
      unsigned v_spool : 1;
      unsigned v_directory : 1;
      unsigned v_badblock : 1;
      unsigned v_markdel : 1;
      unsigned v_nocharge : 1;
      unsigned v_erase : 1;
    } si_charset;
  } si_dummy_charset_union;
  variant_union {
    unsigned long int si_l_charclr;
    struct si_chardef si_charclr;
  } si_dummy_charclr_union;

  variant_union {
    unsigned char si_b_attrib_set;
    struct  si_attribdef {
      unsigned v_fortrancc : 1;
      unsigned v_impliedcc : 1;
      unsigned v_printcc : 1;
      unsigned v_nospan : 1;
    } si_attribset;
  } si_dummy_attribset_union;
  variant_union {
    unsigned char si_b_attrib_clr;
    struct  si_attribdef si_attribclr;
  } si_dummy_attribclr_union;

  variant_union {
    unsigned short int si_w_place_set;
    struct  si_placementdef {
      unsigned v_exact : 1;
      unsigned v_oncyl : 1;
      unsigned : 10;
      unsigned v_lbn : 1;
      unsigned v_rvn : 1;
    } si_placeset;
  } si_dummy_placeset_union;
  variant_union {
    unsigned short int si_w_place_clr;
    struct  si_placementdef si_placeclr;
  } si_dummy_placeclr_union;

  variant_union {
    unsigned char si_b_journalset;
    struct si_journaldef {
      unsigned v_only_ru : 1;
      unsigned v_rujnl : 1;
      unsigned v_bijnl : 1;
      unsigned v_aijnl : 1;
      unsigned v_atjnl : 1;
      unsigned v_never_ru : 1;
      unsigned v_journal_file:1;
    } si_journalset;
  } si_dummy_journalset_union;

  variant_union {
    unsigned char si_b_journalclr;
    struct si_journaldef si_journalclr;
  } si_dummy_journalset_union;

  variant_union {
    unsigned char si_b_access_set;
    struct si_accessdef {
      unsigned v_user : 1;
      unsigned v_supervisor : 1;
      unsigned v_executive : 1;
      unsigned v_kernel : 1;
    } si_access_set;
  } si_dummy_access_set_union;

  variant_union {
    unsigned char si_b_access_clr;
    struct si_accessdef si_access_clr;
  } si_dummy_access_clr_union;

  variant_union {
    short int si_w_protection;
    struct {
      unsigned read : 1;
      unsigned write : 1;
      unsigned execute : 1;
      unsigned delete : 1;
    } si_v_protection;
  } si_dummy_protection_union;

  unsigned short int si_w_protset;
  unsigned short int si_w_protclr;

  long int si_l_lbn_list[SI_K_LBN_LIST_SIZE+1];
  long int si_l_owner_list[SI_K_OWNER_LIST_SIZE+1];
  unsigned short int si_w_backlink[SI_K_BACKLINK_LIST_SIZE+1];
  long int si_l_acl_id_list[SI_K_ACL_ID_LIST_SIZE+1];
  struct dsc$descriptor si_t_filename;
};
$EOD
$ create/log SECTION.C
$DECK
/* Modification History
   --------------------
   Sep. 8, 1987 JEM - Conversion from BETA to Release

*/
#include descrip
#include iodef
#include ssdef
#include secdef

#include "FileInfo.h"

long int map_section(Filename,Defaultname,PageCount,Offset,Flag,context)
/* This routines maps a file into memory. If no context has been set then
   it allocates a FileInfo structure, and opens the necessary file. Once
   the file has been opened the Filename, Default name, and Flag parameters
   are ignored.

   Filename = Name of file to be opened
   Defaultname = Default name of file to be opened
   PageCount = number of pages to try to read into memory
   Offset = VBN of the file to start reading from (1 is first block)
   Flag = Flag specifies attributes about the file:
        bit 0 = File is opened for write
        bit 1 = File may be appended to
   context = Pointer to a FileInfo structure. Initialize it to zero before
        the first call to MapSection, don't touch it after that.
  */
  struct dsc$descriptor *Filename;
  struct dsc$descriptor *Defaultname;
  long int *PageCount;
  long int *Offset;
  long int *Flag;
  struct FileInfo **context;
{
  long int Status,TmpStatus;
  long int MapFlag=0;
  long int RetAdr[2],DeltAdr[2];
  long int i;

  if (*context==0) {
    /* This is a first call, we need to allocate space, init the FAB etc. */
    Status = LIB$GET_VM(&sizeof(struct FileInfo),context);
    if (!(Status & 1)) return(Status);

    (*context)->fi_l_flag = *Flag;
    (*context)->fi_l_begadr=0;
    (*context)->fi_l_endadr=0;
    (*context)->fi_r_fab = cc$rms_fab;
    (*context)->fi_r_nam = cc$rms_nam;
    (*context)->fi_r_xabfhc = cc$rms_xabfhc;
    (*context)->fi_r_fab.fab$l_fop=FAB$M_UFO;
    (*context)->fi_r_fab.fab$b_fac=FAB$M_GET;
    (*context)->fi_r_fab.fab$l_fna=Filename->dsc$a_pointer;
    (*context)->fi_r_fab.fab$b_fns=Filename->dsc$w_length;
    (*context)->fi_r_fab.fab$l_dna=Defaultname->dsc$a_pointer;
    (*context)->fi_r_fab.fab$b_dns=Defaultname->dsc$w_length;
    (*context)->fi_r_fab.fab$l_nam = &(**context).fi_r_nam ;
    (*context)->fi_r_fab.fab$l_xab = &(**context).fi_r_xabfhc ;

    if ((*context)->fi_m_write)
      (*context)->fi_r_fab.fab$b_fac |= FAB$M_PUT;

    Status=SYS$OPEN(&(*context)->fi_r_fab);
    if (!(Status & 1)) return(Status);

    /* use the xabfhc to find out the end of file block */
    (*context)->fi_l_filsiz = (*context)->fi_r_xabfhc.xab$l_ebk;
    if ((*context)->fi_r_xabfhc.xab$w_ffb == 0)
      --(*context)->fi_l_filsiz;

    MapFlag = SEC$M_EXPREG; /* first time we definitely need to expand */
  };

  if (*Offset==0)
    *Offset=1;

  if ((*Offset+*PageCount-1)>(*context)->fi_l_filsiz) {
    /* they asked for more pages then there are in the file! */
    if ((*context)->fi_m_append) {
      /* okay, extend the file */
      /* Extend by (*Offset+*PageCount-1)-(*context)->fi_l_filsiz bytes */
      /* and update (*context)->fi_l_filsiz += */
      /* for now, it's a no-op. */
    }
  else
    *PageCount=(*context)->fi_l_filsiz - *Offset + 1;
  };

  if ((*context)->fi_m_write)
    MapFlag |= SEC$M_WRT;

  Status=SYS$CRMPSC(&(*context)->fi_l_begadr,RetAdr,0,MapFlag,0,0,0,
                     (*context)->fi_r_fab.fab$l_stv,*PageCount,*Offset,0,0);

  /* see if we lost a chunk while remapping, if so deltva it */
  if ((*context)->fi_l_endadr > RetAdr[1]) {
    /* Hmm, the old end was larger  than the new end, so deltva the diff */
    DeltAdr[0] = RetAdr[1]+1;
    DeltAdr[1] = (*context)->fi_l_endadr;
    TmpStatus = SYS$DELTVA(DeltAdr,0,0);
    if (!(TmpStatus & 1)) return(TmpStatus);
  };
  (*context)->fi_l_begadr = RetAdr[0];
  (*context)->fi_l_endadr = RetAdr[1];

  i = (RetAdr[1]-RetAdr[0]+1)/512;
  if ((i < *PageCount) || (*PageCount==0))
    *PageCount = i;
  (*context)->fi_l_pagcnt = *PageCount;
  (*context)->fi_l_offset = *Offset;

  return(Status);
}

long int delete_section(context)
  struct FileInfo **context;
{
  long int Status;

  Status = SYS$DELTVA(&(*context)->fi_l_begadr,0,0);
  if (!(Status & 1)) return(Status);

  Status = SYS$DASSGN((**context).fi_r_fab.fab$l_stv);
  if (!(Status & 1)) return(Status);

  Status = LIB$FREE_VM(&sizeof(struct FileInfo),context);
  *context = 0;

  return(Status);
}

long int read_section_block (context,blocknum,blockaddr)
  struct FileInfo **context;
  long int *blocknum;
  long int **blockaddr;
{
  static long int block=512;
  long int iosb[2];
  long int Status;

  if (*blockaddr==0) {
    /* they didn't specify where to read the block to, so we'll
       allocate a block and read into there */
    Status = LIB$GET_VM(&block,blockaddr);
    if (!(Status & 1)) return(Status);
  };

  Status = SYS$QIOW(0,(*context)->fi_r_fab.fab$l_stv,IO$_READVBLK,
                    iosb,0,0,*blockaddr,block,*blocknum,0,0,0);
  if (Status & 1)
    Status = iosb[0];
  return(Status);
}
$EOD
$ TYPE SYS$INPUT
$DECK
  To compile and link: $ @INDEX ALL
  Modify INDEX.CLD so that the IMAGE clause points to where you
  want to store INDEX.EXE, then do SET COMMAND INDEX

  Joe Meadows Jr.
  VAX/VMS System Manager / guru in training
  Fred Hutchinson Cancer Research Center
  1124 Columbia St.
  Seattle Wa. 98104
     bitnet - JOE@FHCRCVAX
     arpa   - JOE%FHCRCVAX.BITNET@WISCVM.WISC.EDU
     voice  - (206) 467-4970
$EOD
