[comp.os.vms] INDEX, Part 2 of 5, reposted.

JOE@FHCRCVAX.BITNET (Joe Meadows) (09/16/87)

Here's the reposting of part 2 of INDEX. This is being mailed on
wednesday morning, all other parts (1 through 5) were mailed one
part per day prior to today. If you receive this part, chances
are good that you should have already received the other parts,
however, you should probably wait a few days, and check local
archives, before requesting me to mail out sections. If after
this effort you are still missing pieces feel free to contact
me. I went to some effort making sure this didn't have long
lines, and would compile under earlier versions of C (I'm using 2.3,
even with the caveats about the 4.6 library). However, BITNET
does a good job of munging even ones best attempts, so, if you
get compilation errors, my number one guess would be that lines got
wrapped.

Have fun with it, and feel free to send me improvements, requests for
improvements, etc.

  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 DISPLAY.C
$DECK
/* Modification History
   --------------------
   Sep. 8, 1987 JEM - Conversion from BETA to Release

*/
#include descrip
#include climsgdef

#include "fh2def.h"
#include "fi2def.h"
#include "fm2def.h"
#include "FileInfo.h"

#include "displaydef.h"
#include "cld.h"

char *cvt_time();
char *format_uic();
char *get_header();
unsigned int change();

init_display(disp)
  struct display_info *disp;
{
  disp->di_l_dsplybits0 = 0;
  disp->di_l_dsplybits1 = 0;
  if (cli_present("DISPLAY.ALL") & 1) {
    disp->di_l_dsplybits0 = -1;
    disp->di_l_dsplybits1 = -1;
  };

  disp->di_v_fullname = 1;

  disp->di_v_credat = change(disp->di_v_credat, t_display, t_credate);
  disp->di_v_revdat = change(disp->di_v_revdat, t_display, t_revdate);
  disp->di_v_expdat = change(disp->di_v_expdat, t_display, t_expdate);
  disp->di_v_bakdat = change(disp->di_v_bakdat, t_display, t_bakdate);
  disp->di_v_revision =  change(disp->di_v_revision, t_display, t_revisions);
  disp->di_v_extents = change(disp->di_v_extents, t_display, t_extents);
  disp->di_v_headers = change(disp->di_v_headers, t_display, t_header);
  disp->di_v_lbn = change(disp->di_v_lbn , t_display, t_lbn);
  disp->di_v_owner = change(disp->di_v_owner, t_display, t_owner);
  disp->di_v_char = change(disp->di_v_char, t_display, t_char);
  disp->di_v_journal = change(disp->di_v_journal, t_display, t_journal);
  disp->di_v_prot = change(disp->di_v_prot, t_display, t_prot);
  disp->di_v_fid = change(disp->di_v_fid, t_display, t_fid);
  disp->di_v_backlink = change(disp->di_v_backlink, t_display, t_backlink);
  disp->di_v_access = change(disp->di_v_access, t_display, t_access);
  disp->di_v_highwater = change(disp->di_v_highwater, t_display, t_highwater);
  disp->di_v_ru_active = change(disp->di_v_ru_active, t_display, t_ru_active);
  disp->di_v_rectype = change(disp->di_v_rectype, t_display, t_rtype);
  disp->di_v_fileorg = change(disp->di_v_fileorg, t_display, t_fileorg);
  disp->di_v_attrib = change(disp->di_v_attrib, t_display, t_attr);
  disp->di_v_rsize = change(disp->di_v_rsize, t_display, t_rsize);
  disp->di_v_alloc = change(disp->di_v_alloc, t_display, t_hiblk);
  disp->di_v_used = change(disp->di_v_used, t_display, t_efblk);
  disp->di_v_wasted = change(disp->di_v_wasted, t_display, t_wasted);
  disp->di_v_bktsize = change(disp->di_v_bktsize, t_display, t_bktsize);
  disp->di_v_vfcsize = change(disp->di_v_vfcsize, t_display, t_vfcsize);
  disp->di_v_maxrec = change(disp->di_v_maxrec, t_display, t_maxrec);
  disp->di_v_defext = change(disp->di_v_defext, t_display, t_defext);
  disp->di_v_gbc = change(disp->di_v_gbc, t_display, t_gbc);
  disp->di_v_version_limit = change(disp->di_v_version_limit,
                                    t_display, t_versions);
  disp->di_v_filename = change(disp->di_v_filename, t_display, t_filename);
  disp->di_v_fullname = change(disp->di_v_fullname, t_display, t_fullname);
  disp->di_v_acl = change(disp->di_v_acl, t_display, "ACL");
  return;
}

display_header(disp,fid,fh2,context,cached,chan)
  struct display_info *disp;
  short int fid,chan;
  struct fh2def *fh2;
  struct FileInfo *context;
  int cached;
{
  struct fh2def *exthdr;
  struct fi2def *fi2;
  struct fm2def *fm2,*fm2adr;
  long int fm2offset=0,lbn=0,count=0,totextents=0,tothdrs=0;
  static struct dsc$descriptor filename={0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};
  $DESCRIPTOR(newline,"\n");
  short int nxtfid[3];
  long int used,alloc,wasted,blocknum,addr;
  long status;
  long int i,j;
  static char *blockaddr=0;
  static char *No = "No";

  static char ace_buff[512];
  static struct dsc$descriptor ace_txt =
    {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,ace_buff};
  static struct dsc$descriptor ace_bin =
    {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
  struct binary_acl {
    unsigned char length;
    unsigned char type;
    unsigned short int flags;
  } *acaddr;

  /* if this is a completely unused header, don't bother displaying it */
  if ((fh2->fh2$w_fid[0] == 0)
      && (fh2->fh2$w_fid[1] == 0)
      && (fh2->fh2$b_idoffset == 0)
      && (fh2->fh2$b_mpoffset == 0)
      && (fh2->fh2$b_acoffset == 0)
      && (fh2->fh2$b_rsoffset == 0))
    return;

  /* compute where in the file header the file ident info is */
  fi2 = (long int)fh2 + fh2->fh2$b_idoffset * 2;

  printf("\n"); /* separate the buggers with a blank line */

  if (disp->di_v_fullname) {
    status = fid_to_name(&chan,(*fh2).fh2$w_fid,&filename);
    if ((status & 1) && fh2->fh2$w_fid[0])
      printf("%.*s\n",filename.dsc$w_length,filename.dsc$a_pointer);
    else {
      status = fid_to_name(&chan,(*fh2).fh2$w_backlink,&filename);
      for (i=0;(i < FI2$S_FILENAME) &&
                    ((*fi2).fi2$t_filename[i] != ' ');i++);
      j = 0;
      if ((fh2->fh2$b_mpoffset - fh2->fh2$b_idoffset) >= 60)
        for (j=0;(j < FI2$S_FILENAMEXT) &&
                      ((*fi2).fi2$t_filenamext[j] != ' ');j++);
      printf("[?]%.*s%.*s\n",i,(*fi2).fi2$t_filename,
                             j,(*fi2).fi2$t_filenamext);
      if (status & 1)
        printf("(in %.*s%)\n",filename.dsc$w_length,filename.dsc$a_pointer);
    };
  };

  if (disp->di_v_filename) {
    for (i=0;(i < FI2$S_FILENAME)
         && ((*fi2).fi2$t_filename[i] != ' ');i++);
    j = 0;
    if ((fh2->fh2$b_mpoffset - fh2->fh2$b_idoffset) >= 60)
      for (j=0;(j < FI2$S_FILENAMEXT)
           && ((*fi2).fi2$t_filenamext[j] != ' ');j++);

    printf("Filename = %.*s%.*s\n",
           i,(*fi2).fi2$t_filename, j,(*fi2).fi2$t_filenamext);
  };

  if (disp->di_v_prot)
    printf("protection = (S%s%s,O%s%s,G%s%s,W%s%s)\n",
      (fh2->fh2$v_fileprot_system != 15)?":":"",
      t_fileprot[fh2->fh2$v_fileprot_system],
      (fh2->fh2$v_fileprot_owner != 15)?":":"",
      t_fileprot[fh2->fh2$v_fileprot_owner],
      (fh2->fh2$v_fileprot_group != 15)?":":"",
      t_fileprot[fh2->fh2$v_fileprot_group],
      (fh2->fh2$v_fileprot_world != 15)?":":"",
      t_fileprot[fh2->fh2$v_fileprot_world]);

  if (disp->di_v_fid)
    printf("File ID = (%s%d,%d,%d)\n",
           (fh2->fh2$w_fid[0] == 0)?"*":"",
           (fh2->fh2$w_fid[0] == 0)?fid:fh2->fh2$w_fid[0],
           fh2->fh2$w_fid[1],
           fh2->fh2$w_fid[2]);

  if (disp->di_v_backlink)
    printf("Backlink File ID = (%d,%d,%d)\n",
           fh2->fh2$w_backlink[0],
           fh2->fh2$w_backlink[1],
           fh2->fh2$w_backlink[2]);

  if (disp->di_v_owner)
    printf("%s = [%o,%o] = [%s]\n",t_owner,
           fh2->fh2$w_uicgroup,fh2->fh2$w_uicmember,
           format_uic(fh2->fh2$l_fileowner));

  if (disp->di_v_credat)
    printf("%s = %s\n",t_credate,cvt_time(&(*fi2).fi2$q_credate));
  if (disp->di_v_revdat)
    printf("%s = %s\n",t_revdate,cvt_time(&(*fi2).fi2$q_revdate));
  if (disp->di_v_expdat)
    printf("%s = %s\n",t_expdate,cvt_time(&(*fi2).fi2$q_expdate));
  if (disp->di_v_bakdat)
    printf("%s = %s\n",t_bakdate,cvt_time(&(*fi2).fi2$q_bakdate));
  if (disp->di_v_revision)
    printf("%s = %d\n",t_revisions,(*fi2).fi2$w_revision);

  if (disp->di_v_fileorg)
    printf("%s = %s\n",t_fileorg,ta_fileorg[fh2->fat.fat$v_fileorg]);
  if (disp->di_v_rectype)
    printf("%s = %s\n",t_rtype,ta_rtype[fh2->fat.fat$v_rtype]);
  if (disp->di_v_attrib)
    printf("%s = (%s%s,%s%s,%s%s,%s%s)\n",
      t_attr,
      fh2->fat.fat$v_fortrancc?"":No,t_fortrancc,
      fh2->fat.fat$v_impliedcc?"":No,t_impliedcc,
      fh2->fat.fat$v_printcc?"":No,t_printcc,
      fh2->fat.fat$v_nospan?No:"",t_nospan);

  if (disp->di_v_char) {
    printf("%s = (%s%s,%s%s,%s%s,%s%s,\n",
      t_char,
      fh2->fh2$v_badacl?"":No,t_badacl,
      fh2->fh2$v_nobackup?No:"",t_nobackup,
      fh2->fh2$v_contigb?"":No,t_contigb,
      fh2->fh2$v_nocharge?No:"",t_nocharge);
    printf("    %s%s,%s%s,%s%s,%s%s,%s%s,\n",
      fh2->fh2$v_contig?"":No,t_contig,
      fh2->fh2$v_directory?"":No,t_directory,
      fh2->fh2$v_erase?"":No,t_erase,
      fh2->fh2$v_badblock?"":No,t_badblock,
      fh2->fh2$v_locked?"":No,t_locked);
    printf("    %s%s,%s%s,%s%s,%s%s,%s%s)\n",
      fh2->fh2$v_markdel?"":No,t_markdel,
      fh2->fh2$v_spool?"":No,t_spool,
      fh2->fh2$v_readcheck?"":No,t_readcheck,
      fh2->fh2$v_writeback?"":No,t_writeback,
      fh2->fh2$v_writcheck?"":No,t_writcheck);
  };

  if (disp->di_v_journal)
    printf("%s = (%s%s,%s%s,%s%s,%s%s,%s%s,%s%s,%s%s)\n",
      t_journal,
      fh2->fh2$v_journal_file?"":No,t_journal_file,
      fh2->fh2$v_aijnl?"":No,t_aijnl,
      fh2->fh2$v_atjnl?"":No,t_atjnl,
      fh2->fh2$v_bijnl?"":No,t_bijnl,
      fh2->fh2$v_rujnl?"":No,t_rujnl,
      fh2->fh2$v_never_ru?"":No,t_never_ru,
      fh2->fh2$v_only_ru?"":No,t_only_ru);

  if (disp->di_v_ru_active)
    printf("%s = %d\n",t_ru_active,fh2->fh2$b_ru_active);

  if (disp->di_v_rsize)
    printf("%s = %d\n",t_rsize,fh2->fat.fat$w_rsize);
  if (disp->di_v_vfcsize)
    printf("%s = %d\n",t_vfcsize,fh2->fat.fat$b_vfcsize);
  if (disp->di_v_maxrec)
    printf("%s = %d\n",t_maxrec,fh2->fat.fat$w_maxrec);

  used = (fh2->fat.fat$w_efblkh<<16)|fh2->fat.fat$w_efblkl;
  if (fh2->fat.fat$w_ffbyte == 0)
    --used;
  if (disp->di_v_used)
    printf("%s = %d (+%d)\n",t_efblk,used,fh2->fat.fat$w_ffbyte);

  alloc = (fh2->fat.fat$w_hiblkh<<16)|fh2->fat.fat$w_hiblkl;
  if (disp->di_v_alloc)
    printf("%s = %d\n",t_hiblk,alloc);

  if (disp->di_v_wasted) {
    wasted = alloc-used;
    printf("%s = %d\n",t_wasted,wasted);
  };

  if (disp->di_v_defext)
    printf("%s = %d\n",t_defext,fh2->fat.fat$w_defext);
  if (disp->di_v_bktsize)
    printf("%s = %d\n",t_bktsize,fh2->fat.fat$b_bktsize);
  if (disp->di_v_gbc)
    printf("%s = %d\n",t_gbc,fh2->fat.fat$w_gbc);
  if (disp->di_v_version_limit)
    printf("%s = %d\n",t_versions,fh2->fat.fat$w_versions);

  if (disp->di_v_highwater) {
    i = fh2->fh2$l_highwater;
    printf("%s = %d\n",t_highwater,i==0?0:i-1);
  };

  if (disp->di_v_access)
    printf("%s = %s\n",t_access,ta_access[fh2->fh2$b_acc_mode]);

  /* if display headers or extents, then counts the suckers up */
  /* note that to ease the code, we'll display the lbns here as well */
  if (disp->di_v_headers || disp->di_v_extents || disp->di_v_lbn) {
    /* okay, loop through all the header blocks, starting with this one */
    exthdr = fh2;
    while (exthdr && (exthdr->fh2$b_mpoffset!=255)) {
      fm2offset = 0;
      fm2adr = (char *)exthdr + exthdr->fh2$b_mpoffset * 2;
      i = exthdr->fh2$b_map_inuse * 2;
      while (fm2offset < i) {
        fm2 = (char *)fm2adr + fm2offset;
        j=0;
        switch (fm2->fm2$v_format) {
          case FM2$C_PLACEMENT:
            lbn = 0;
            count = 0;
            if (disp->di_v_lbn)
              printf("Placement control: (%04x) %s%s%s%s\n",
                     fm2->fm2$w_word0,
                     fm2->fm2$v_exact?"  Exact":"",
                     fm2->fm2$v_oncyl?"  On cylinder placement desired":"",
                     fm2->fm2$v_rvn?"  Relative volume number":"",
                     fm2->fm2$v_lbn?"  Specific LBN":"");
            fm2offset += FM2$C_LENGTH0;
            break;
          case FM2$C_FORMAT1:
            ++j;
            ++totextents;
            lbn = (fm2->fm2$v_highlbn <<16) + fm2->fm2$w_lowlbn;
            count = fm2->fm2$b_count1;
            fm2offset += FM2$C_LENGTH1;
            break;
          case FM2$C_FORMAT2:
            ++j;
            ++totextents;
            lbn = fm2->fm2$l_lbn2;
            count = fm2->fm2$v_count2;
            fm2offset += FM2$C_LENGTH2;
            break;
          case FM2$C_FORMAT3:
            ++j;
            ++totextents;
            lbn = fm2->fm2$l_lbn3;
            count = (fm2->fm2$v_count2 << 16) + fm2->fm2$w_lowcount;
            fm2offset += FM2$C_LENGTH3;
            break;
        };
        if (disp->di_v_lbn && j)
          printf("%s = %10d - %10d (%10d blocks)\n",
                 t_lbn,lbn,lbn+count,count+1);
      };

      if (exthdr->fh2$w_ext_fid[0]) {
        printf("Extension header #%d (%d,%d,%d)\n",
          exthdr->fh2$w_seg_num+1,
          exthdr->fh2$w_ext_fid[0],
          exthdr->fh2$w_ext_fid[1],
          exthdr->fh2$w_ext_fid[2]);
        exthdr = get_header(exthdr->fh2$w_ext_fid,exthdr->fh2$w_fid,
                            context,cached,chan);
        if (exthdr == 0)
          printf("--unable to get extension header\n");
        ++tothdrs;
      }
      else
       exthdr = 0;
    };
    if (disp->di_v_headers)
      printf("%s = %d\n",t_header,tothdrs);
    if (disp->di_v_extents)
      printf("%s = %d\n",t_extents,totextents);
  };

  if (disp->di_v_acl) {
    /* okay, loop through all the header blocks, starting with this one */
    if (fh2->fh2$b_acoffset < fh2->fh2$b_rsoffset)
      printf("Access control list\n");

    exthdr = fh2;
    while (exthdr && (exthdr->fh2$b_acoffset < exthdr->fh2$b_rsoffset)) {
      acaddr = (char *)exthdr + exthdr->fh2$b_acoffset * 2;
      ace_bin.dsc$w_length = acaddr->length;
      while ((acaddr < ((char *)exthdr + (exthdr->fh2$b_rsoffset*2)))
             && (ace_bin.dsc$w_length != 0)) {
        /* format the ace */
        ace_bin.dsc$a_pointer = acaddr;
        ace_txt.dsc$w_length = 512;
        i = 3; /* number of chars to indent */
        j = 77; /* width of acl */
        status = sys$format_acl(&ace_bin,&ace_txt.dsc$w_length,
                                &ace_txt,&j,&newline,&i,0);
        if (status & 1)
          printf("%.*s\n",ace_txt.dsc$w_length,ace_txt.dsc$a_pointer);
        else
          printf("Error %d in formal_acl call\n",status);

        /* move on to next ace */
        acaddr = (char *)acaddr + ace_bin.dsc$w_length;
        ace_bin.dsc$w_length = acaddr->length;
      };
      exthdr = get_header(exthdr->fh2$w_ext_fid,exthdr->fh2$w_fid,
                          context,cached,chan);
    };
  };

  return;
}

char *cvt_time(date)
  long int date[2];
{
  static char str[27];
  static struct dsc$descriptor date_str={26,DSC$K_DTYPE_T,DSC$K_CLASS_S,str};

  if ((date[0]==0) && (date[1]==0))
    return("none");

  str[0]='\0';
  if (sys$asctim(0,&date_str,date,0) & 1)
    str[26]='\0';

  return(str);
}

char *format_uic(uic)
  long int uic;
{
  static char id[66];
  static struct dsc$descriptor id_str={65,DSC$K_DTYPE_T,DSC$K_CLASS_S,id};
  unsigned short int idlen;
  long int status;

  id[0] = '\0';
  status = sys$idtoasc(uic,&idlen,&id_str,0,0,0);
  if (status & 1)
    id[idlen] = '\0';
  return(id);
}
$EOD
$ create/log FCHDEF.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 FCH$V_BADACL    0x00B
#define FCH$M_BADACL    (1 << FCH$V_ACL)
#define FCH$V_BADBLOCK  0x00E
#define FCH$M_BADBLOCK  (1 << FCH$V_BADBLOCK)
#define FCH$V_CONTIG    0x007
#define FCH$M_CONTIG    (1 << FCH$V_CONTIG)
#define FCH$V_CONTIGB   0x005
#define FCH$M_CONTIGB   (1 << FCH$V_CONTIGB)
#define FCH$V_DIRECTORY 0x00D
#define FCH$M_DIRECTORY (1 << FCH$V_DIRECTORY)
#define FCH$V_ERASE     0x011
#define FCH$M_ERASE     (1 << FCH$V_ERASE)
#define FCH$V_LOCKED    0x006
#define FCH$M_LOCKED    (1 << FCH$V_LOCKED)
#define FCH$V_MARKDEL   0x00F
#define FCH$M_MARKDEL   (1 << FCH$V_MARKDEL)
#define FCH$V_NOBACKUP  0x001
#define FCH$M_NOBACKUP  (1 << FCH$V_NOBACKUP)
#define FCH$V_NOCHARGE  0x010
#define FCH$M_NOCHARGE  (1 << FCH$V_NOCHARGE)
#define FCH$V_READCHECK 0x003
#define FCH$M_READCHECK (1 << FCH$V_READCHECK)
#define FCH$V_SPOOL     0x00C
#define FCH$M_SPOOL     (1 << FCH$V_SPOOL)
#define FCH$V_WRITCHECK 0x004
#define FCH$M_WRITCHECK (1 << FCH$V_WRITCHECK)
#define FCH$V_WRITEBACK 0x002
#define FCH$M_WRITEBACK (1 << FCH$V_WRITEBACK)

struct fchdef  {
  unsigned : 1;
  unsigned fch$v_nobackup : 1 ;
  unsigned fch$v_writeback : 1;
  unsigned fch$v_readcheck : 1;
  unsigned fch$v_writcheck : 1;
  unsigned fch$v_contigb : 1;
  unsigned fch$v_locked : 1;
  unsigned fch$v_contig : 1;
  unsigned : 3;
  unsigned fch$v_badacl : 1;
  unsigned fch$v_spool : 1;
  unsigned fch$v_directory : 1;
  unsigned fch$v_badblock : 1;
  unsigned fch$v_markdel : 1;
  unsigned fch$v_nocharge : 1;
  unsigned fch$v_erase : 1;
};
$EOD
$ create/log FH2DEF.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 "fatdef.h"

#define FH2$C_LEVEL1    257
#define FH2$C_LEVEL2    512
#define FH2$M_NOBACKUP  2
#define FH2$M_WRITEBACK 4
#define FH2$M_READCHECK 8
#define FH2$M_WRITCHECK 16
#define FH2$M_CONTIGB   32
#define FH2$M_LOCKED    64
#define FH2$M_CONTIG    128
#define FH2$M_BADACL    2048
#define FH2$M_SPOOL     4096
#define FH2$M_DIRECTORY 8192
#define FH2$M_BADBLOCK  16384
#define FH2$M_MARKDEL   32768
#define FH2$M_NOCHARGE  65536
#define FH2$M_ERASE     131072
#define FH2$M_ONLY_RU   1
#define FH2$M_RUJNL     2
#define FH2$M_BIJNL     4
#define FH2$M_AIJNL     8
#define FH2$M_ATJNL     16
#define FH2$M_NEVER_RU  32
#define FH2$M_JOURNAL_FILE      64
#define FH2$C_RU_FACILITY_RMS   1
#define FH2$C_RU_FACILITY_DBMS  2
#define FH2$C_RU_FACILITY_RDB   3
#define FH2$C_RU_FACILITY_CHKPNT        4
#define FH2$K_LENGTH    80
#define FH2$C_LENGTH    80
#define FH2$K_SUBSET0_LENGTH    88
#define FH2$C_SUBSET0_LENGTH    88
#define FH2$K_FULL_LENGTH       108
#define FH2$C_FULL_LENGTH       108
#define FH2$S_FH2DEF    512

#define FH2$S_FID       6
#define FH2$S_EXT_FID   6
#define FH2$S_RECATTR   32
#define FH2$S_BACKLINK  6
#define FH2$S_CLASS_PROT        20

struct fh2def {
  unsigned char fh2$b_idoffset;
  unsigned char fh2$b_mpoffset;
  unsigned char fh2$b_acoffset;
  unsigned char fh2$b_rsoffset;
  unsigned short int fh2$w_seg_num;
  variant_union {
    unsigned short int fh2$w_struclev;
    variant_struct {
      unsigned char fh2$b_strucver;
      unsigned char fh2$b_struclev;
    } fh2$dummy_struclev_fields;
  } fh2$dummy_struclev;
  variant_union {
    unsigned short int fh2$w_fid[FH2$S_FID/2];
    variant_struct {
      unsigned short int fh2$w_fid_num;
      unsigned short int fh2$w_fid_seq;
      variant_union {
        unsigned short int fh2$w_fid_rvn;
        variant_struct {
          unsigned char fh2$b_fid_rvn;
          unsigned char fh2$b_fid_nmx;
        } fh2$dummy_w_fid_rvn_struct;
      } fh2$dummy_w_fid_rvn_union;
    } fh2$dummy_w_fid_struct;
  } fh2$dummy_w_fid_union;
  variant_union {
    unsigned short int fh2$w_ext_fid[FH2$S_EXT_FID/2];
    variant_struct {
      unsigned short int fh2$w_ex_fidnum;
      unsigned short int fh2$w_ex_fidseq;
      variant_union {
        unsigned short int fh2$w_ex_fidrvn;
        variant_struct {
          unsigned char fh2$b_ex_fidrvn;
          unsigned char fh2$b_ex_fidnmx;
        } fh2$dummy_w_ex_fidrvn_struct;
      } fh2$dummy_w_ex_fidrvn_union;
    } fh2$dummy_w_ext_fid_struct;
  } fh2$dummy_w_ext_fid_union;
  variant_union {
    unsigned short int fh2$w_recattr[FH2$S_RECATTR/2];
    struct FATDEF fat;
  } fh2$dummy_recattr_union;
  variant_union {
    unsigned long int fh2$l_filechar;
    variant_struct {
      unsigned : 1;
      unsigned fh2$v_nobackup : 1;
      unsigned fh2$v_writeback : 1;
      unsigned fh2$v_readcheck : 1;
      unsigned fh2$v_writcheck : 1;
      unsigned fh2$v_contigb : 1;
      unsigned fh2$v_locked : 1;
      unsigned fh2$v_contig : 1;
      unsigned : 3;
      unsigned fh2$v_badacl : 1;
      unsigned fh2$v_spool : 1;
      unsigned fh2$v_directory : 1;
      unsigned fh2$v_badblock : 1;
      unsigned fh2$v_markdel : 1;
      unsigned fh2$v_nocharge : 1;
      unsigned fh2$v_erase : 1;
    } fh2$dummy_l_filechar_struct;
  } fh2$dummy_l_filechar_union;
  unsigned short int fh2$w_recprot;
  unsigned char fh2$b_map_inuse;
  unsigned char fh2$b_acc_mode;
  variant_union {
    unsigned long int fh2$l_fileowner;
    variant_struct {
      unsigned short int fh2$w_uicmember;
      unsigned short int fh2$w_uicgroup;
    } fh2$dummy_l_fileowner_struct;
  } fh2$dummy_l_fileowner_union;
  variant_union {
    unsigned short int fh2$w_fileprot;
    variant_struct {
    unsigned fh2$v_fileprot_system : 4;
    unsigned fh2$v_fileprot_owner : 4;
    unsigned fh2$v_fileprot_group : 4;
    unsigned fh2$v_fileprot_world : 4;
    } fh2$dummy_w_fileprot_struct;
  } fh2$dummy_w_fileprot_union;
  variant_union {
    unsigned short int fh2$w_backlink[FH2$S_BACKLINK/2];
    variant_struct {
      unsigned short int fh2$w_bk_fidnum;
      unsigned short int fh2$w_bk_fidseq;
      variant_union {
        unsigned short int fh2$w_bk_fidrvn;
        variant_struct {
          unsigned char fh2$b_bk_fidrvn;
          unsigned char fh2$b_bk_fidnmx;
        } fh2$dummy_w_bk_fidrvn_struct;
      } fh2$dummy_w_bk_fidrvn_union;
    } fh2$dummy_w_backlink_struct;
  } fh2$dummy_w_backlink_union;
  variant_union {
    unsigned char fh2$b_journal;
    variant_struct {
      unsigned fh2$v_only_ru : 1;
      unsigned fh2$v_rujnl : 1;
      unsigned fh2$v_bijnl : 1;
      unsigned fh2$v_aijnl : 1;
      unsigned fh2$v_atjnl : 1;
      unsigned fh2$v_never_ru : 1;
      unsigned fh2$v_journal_file : 1;
    } fh2$dummy_b_journal_struct;
  } fh2$dummy_b_journal_union;
  unsigned char fh2$b_ru_active;
  unsigned char fh2$fill_1[2];
  unsigned long int fh2$l_highwater;
  unsigned char fh2$fill_2[8];
  unsigned char fh2$r_class_prot[FH2$S_CLASS_PROT];
  unsigned char fh2$fill_3[402];
  unsigned short int fh2$w_checksum;
};
$EOD
$ create/log FI2DEF.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 FI2$K_LENGTH    120
#define FI2$C_LENGTH    120
#define FI2$S_FI2DEF    200
#define FI2$S_FILENAME  20
#define FI2$S_CREDATE   8
#define FI2$S_REVDATE   8
#define FI2$S_EXPDATE   8
#define FI2$S_BAKDATE   8
#define FI2$S_FILENAMEXT        66
#define FI2$S_USERLABEL 80
#define DATE {unsigned : 32; unsigned : 32;}

struct fi2def {
  unsigned char fi2$t_filename[FI2$S_FILENAME];
  unsigned short int fi2$w_revision;
  struct DATE fi2$q_credate;
  struct DATE fi2$q_revdate;
  struct DATE fi2$q_expdate;
  struct DATE fi2$q_bakdate;
  unsigned char fi2$t_filenamext[FI2$S_FILENAMEXT];
  unsigned char fi2$t_userlabel[FI2$S_USERLABEL];
};
$EOD
$ create/log FIBDEF.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 FIB$M_NOWRITE 1
#define FIB$M_DLOCK 2
#define FIB$M_BLK_LOCK 4
#define FIB$M_SPOOL 16
#define FIB$M_WRITECK 32
#define FIB$M_SEQONLY 64
#define FIB$M_WRITE 256
#define FIB$M_READCK 512
#define FIB$M_NOREAD 1024
#define FIB$M_NOTRUNC 2048
#define FIB$M_CONTROL 4096
#define FIB$M_EXECUTE 65536
#define FIB$M_PRSRV_ATR 131072
#define FIB$M_RMSLOCK 262144
#define FIB$M_WRITETHRU 524288
#define FIB$M_NOLOCK 1048576
#define FIB$M_NORECORD 2097152
#define FIB$M_REWIND 8
#define FIB$M_CURPOS 16
#define FIB$M_UPDATE 64
#define FIB$K_ACCDATA 10
#define FIB$C_ACCDATA 10
#define FIB$K_DIRDATA 22
#define FIB$C_DIRDATA 22
#define FIB$M_ALLVER 8
#define FIB$M_ALLTYP 16
#define FIB$M_ALLNAM 32
#define FIB$M_WILD 256
#define FIB$M_NEWVER 512
#define FIB$M_SUPERSEDE 1024
#define FIB$M_FINDFID 2048
#define FIB$M_LOWVER 16384
#define FIB$M_HIGHVER 32768
#define FIB$M_ALCON 1
#define FIB$M_ALCONB 2
#define FIB$M_FILCON 4
#define FIB$M_ALDEF 8
#define FIB$M_ALLOCATR 16
#define FIB$M_EXTEND 128
#define FIB$M_TRUNC 256
#define FIB$M_NOHDREXT 512
#define FIB$M_MARKBAD 1024
#define FIB$M_NOCHARGE 32768
#define FIB$K_EXTDATA 32
#define FIB$C_EXTDATA 32
#define FIB$M_EXACT 1
#define FIB$M_ONCYL 2
#define FIB$C_CYL 1
#define FIB$C_LBN 2
#define FIB$C_VBN 3
#define FIB$C_RFI 4
#define FIB$K_ALCDATA 44
#define FIB$C_ALCDATA 44
#define FIB$M_ALT_REQ 1
#define FIB$M_ALT_GRANTED 2
#define FIB$M_DIRACL 4
#define FIB$M_PROPAGATE 8
#define FIB$K_LENGTH 64
#define FIB$C_LENGTH 64
struct fibdef {
    variant_union  {
        unsigned long int fib$l_acctl;
        variant_struct  {
            unsigned fib$v_nowrite : 1;
            unsigned fib$v_dlock : 1;
            unsigned fib$v_blk_lock : 1;
            unsigned fibdef$$_fill_1 : 1;
            unsigned fib$v_spool : 1;
            unsigned fib$v_writeck : 1;
            unsigned fib$v_seqonly : 1;
            unsigned fibdef$$_fill_2 : 1;
            unsigned fib$v_write : 1;
            unsigned fib$v_readck : 1;
            unsigned fib$v_noread : 1;
            unsigned fib$v_notrunc : 1;
            unsigned fib$v_control : 1;
            unsigned fibdef$$_fill_3 : 3;


            unsigned fib$v_execute : 1;
            unsigned fib$v_prsrv_atr : 1;
            unsigned fib$v_rmslock : 1;
            unsigned fib$v_writethru : 1;
            unsigned fib$v_nolock : 1;
            unsigned fib$v_norecord : 1;
            unsigned fibdef$$_fill_4 : 2;
            } fib$r_acctl_bits0;
        variant_struct  {
            unsigned fibdef$$_fill_5 : 3;
            unsigned fib$v_rewind : 1;
            unsigned fib$v_curpos : 1;
            unsigned fibdef$$_fill_6 : 1;
            unsigned fib$v_update : 1;
            unsigned fib$v_fill_1 : 1;
            } fib$r_acctl_bits1;
        variant_struct  {
            char fibdef$$_fill_13 [3];
            char fib$b_wsize;
            } fib$r_acctl_fields2;
        } fib$r_acctl_overlay;
    variant_union  {
        unsigned short int fib$w_fid [3];
        variant_struct  {
            unsigned short int fib$w_fid_num;
            unsigned short int fib$w_fid_seq;
            variant_union  {
                unsigned short int fib$w_fid_rvn;
                variant_struct  {
                    unsigned char fib$b_fid_rvn;
                    unsigned char fib$b_fid_nmx;
                    } fib$r_fid_rvn_fields;
                } fib$r_fid_rvn_overlay;
            } fib$r_fid_fields;
        } fib$r_fid_overlay;
    variant_union  {
        unsigned short int fib$w_did [3];
        variant_struct  {
            unsigned short int fib$w_did_num;
            unsigned short int fib$w_did_seq;
            variant_union  {
                unsigned short int fib$w_did_rvn;
                variant_struct  {
                    unsigned char fib$b_did_rvn;
                    unsigned char fib$b_did_nmx;
                    } fib$r_did_rvn_fields;
                } fib$r_did_rvn_overlay;
            } fib$r_did_fields;
        } fib$r_did_overlay;
    unsigned long int fib$l_wcc;
    variant_union  {
        unsigned short int fib$w_nmctl;
        variant_struct  {
            unsigned fibdef$$_fill_7 : 3;
            unsigned fib$v_allver : 1;
            unsigned fib$v_alltyp : 1;
            unsigned fib$v_allnam : 1;
            unsigned fibdef$$_fill_8 : 2;
            unsigned fib$v_wild : 1;
            unsigned fib$v_newver : 1;
            unsigned fib$v_supersede : 1;
            unsigned fib$v_findfid : 1;
            unsigned fibdef$$_fill_9 : 2;
            unsigned fib$v_lowver : 1;
            unsigned fib$v_highver : 1;
            } fib$r_nmctl_bits;
        } fib$r_nmctl_overlay;
    variant_union  {
        unsigned short int fib$w_exctl;
        variant_struct  {
            unsigned fib$v_alcon : 1;
            unsigned fib$v_alconb : 1;
            unsigned fib$v_filcon : 1;
            unsigned fib$v_aldef : 1;
            unsigned fib$v_allocatr : 1;
            unsigned fibdef$$_fill_10 : 2;
            unsigned fib$v_extend : 1;
            unsigned fib$v_trunc : 1;
            unsigned fib$v_nohdrext : 1;
            unsigned fib$v_markbad : 1;
            unsigned fibdef$$_fill_11 : 4;
            unsigned fib$v_nocharge : 1;
            } fib$r_exctl_bits;
        } fib$r_exctl_overlay;
    unsigned long int fib$l_exsz;
    unsigned long int fib$l_exvbn;
    variant_union  {
        unsigned char fib$b_alopts;
        variant_struct  {
            unsigned fib$v_exact : 1;
            unsigned fib$v_oncyl : 1;
            unsigned fib$v_fill_2 : 6;
            } fib$r_alopts_bits;
        } fib$r_alopts_overlay;
    unsigned char fib$b_alalign;
    variant_union  {
        unsigned short int fib$w_alloc [5];
        variant_struct  {
            variant_union  {
                unsigned short int fib$w_loc_fid [3];
                variant_struct  {
                    unsigned short int fib$w_loc_num;
                    unsigned short int fib$w_loc_seq;
                    variant_union  {
                        unsigned short int fib$w_loc_rvn;
                        variant_struct  {
                            unsigned char fib$b_loc_rvn;
                            unsigned char fib$b_loc_nmx;
                            } fib$r_loc_rvn_fields;
                        } fib$r_loc_rvn_overlay;
                    } fib$r_loc_fid_fields;
                } fib$r_loc_fid_overlay;
            unsigned long int fib$l_loc_addr;
            } fib$r_alloc_fields;
        } fib$r_alloc_overlay;
    unsigned short int fib$w_verlimit;
    unsigned char fib$b_agent_mode;
    char fibdef$$_fill_12;
    unsigned long int fib$l_aclctx;
    unsigned long int fib$l_acl_status;
    variant_union  {
        unsigned long int fib$l_status;
        variant_struct  {
            unsigned fib$v_alt_req : 1;
            unsigned fib$v_alt_granted : 1;
            unsigned fib$v_diracl : 1;
            unsigned fib$v_propagate : 1;
            unsigned fib$v_fill_3 : 4;
            } fib$r_status_bits;
        } fib$r_status_overlay;
    unsigned long int fib$l_alt_access;
    } ;
#define FIB$C_REWINDVOL 1
#define FIB$C_POSEND 2
#define FIB$C_NEXTVOL 3
#define FIB$C_SPACE 4
#define FIB$C_ILLEGAL 5
#define FIB$C_REWINDFIL 6
#define FIB$C_LOCK_VOL 7
#define FIB$C_UNLK_VOL 8

#define FIB$C_ENA_QUOTA 9
#define FIB$C_DSA_QUOTA 10
#define FIB$C_ADD_QUOTA 11
#define FIB$C_EXA_QUOTA 12
#define FIB$C_MOD_QUOTA 13
#define FIB$C_REM_QUOTA 14
#define FIB$C_USEREOT 15
#define FIB$C_REMAP 16
#define FIB$C_CLSEREXCP 17
#define FIB$C_FLUSH_CACHE 18
#define FIB$K_MTALEN 28
#define FIB$C_MTALEN 28



#define FIB$C_FID_CACHE 1
#define FIB$C_EXTENT_CACHE 2
#define FIB$C_QUOTA_CACHE 3



#define FIB$M_ALL_MEM 1
#define FIB$M_ALL_GRP 2
#define FIB$M_MOD_USE 4
#define FIB$M_MOD_PERM 8
#define FIB$M_MOD_OVER 16
struct fibdef1 {
    char fibdef$$_fill_14 [22];
    unsigned short int fib$w_cntrlfunc;


    variant_union  {
        unsigned long int fib$l_cntrlval;
        variant_struct  {
            unsigned fib$v_all_mem : 1;
            unsigned fib$v_all_grp : 1;
            unsigned fib$v_mod_use : 1;
            unsigned fib$v_mod_perm : 1;
            unsigned fib$v_mod_over : 1;
            unsigned fib$v_fill_4 : 3;
            } fib$r_cntrlval_bits;
        } fib$r_cntrlval_overlay;
    } ;
$EOD