/*****************************************************************************/
/*
                               ODSstruct.h


VERSION HISTORY
---------------
23-DEC-1999  MGD  initial; provide support for ODS-2 and ODS-5
*/
/*****************************************************************************/

#ifndef ODSSTRUCT_H_LOADED
#define ODSSTRUCT_H_LOADED 1

/* VMS related header files */
#include <descrip.h>
#include <rms.h>
#include <rmsdef.h>
#include <atrdef.h>
#include <fibdef.h>

/* application header files */
#include "enamel.h"

#ifndef NO_ODS_EXTENDED
#   define ODS_EXTENDED 1
    /* this is smaller than the technical maximum, but still quite large! */
#   define ODS_MAX_FILE_NAME_LENGTH 511
#   define ODS_MAX_FILESYS_NAME_LENGTH 264
#endif
#define ODS2_MAX_FILE_NAME_LENGTH 255
#ifndef ODS_MAX_FILE_NAME_LENGTH
#  define ODS_MAX_FILE_NAME_LENGTH ODS2_MAX_FILE_NAME_LENGTH
#endif
#ifndef ODS_MAX_FILESYS_NAME_LENGTH
#  define ODS_MAX_FILESYS_NAME_LENGTH 39+39
#endif
#if ODS_MAX_FILE_NAME_LENGTH < ODS2_MAX_FILE_NAME_LENGTH
#  define ODS_MAX_FILE_NAME_LENGTH ODS2_MAX_FILE_NAME_LENGTH
#endif

#pragma __member_alignment __save
#pragma nomember_alignment

/* I/O User's Reference Manual, ACP Subfunctions, "Read/Write Attributes" */

typedef struct AcpQioAscDates ACPQIO_ASC_DATES;

struct AcpQioAscDates
{
   ushort  RevisionCount;
   uchar  OfNoInterest [33];
};

/* I/O User's Reference Manual, ACP Subfunctions, "Read/Write Attributes" */

#define FAT$C_UNDEFINED 0
#define FAT$C_FIXED 1
#define FAT$C_VARIABLE 2
#define FAT$C_VFC 3
#define FAT$C_STREAM 4
#define FAT$C_STMLF 5
#define FAT$C_STMCR 6
#define FAT$M_NOSPAN 8
#define FAT$M_MSBRCW 16

typedef struct AcpQioRecordAttributes ACPQIO_RECORD_ATTRIBUTES;

struct AcpQioRecordAttributes
{
   uchar  fat$b_rtype;
   uchar  fat$b_rattrib;
   ushort  fat$w_rsize;
   ulong  fat$l_hiblk;
   ulong  fat$l_efblk;
   ushort  fat$w_ffbyte;
   uchar  fat$b_bktsize;
   uchar  fat$b_vfcsize;
   ushort  fat$w_maxrec;
   ushort  fat$w_defext;
   ushort  fat$w_gbc;
   uchar   fat$reserved [6];
   ushort  fat$w_unused;
   ushort  fat$w_versions;
};

typedef struct FileQioStruct FILE_QIO;

struct FileQioStruct
{
   BOOL  EndOfFile;
   int  AdjustBuffer,
        AllocatedVbn,
        BlockNumber,
        BufferCount,
        BufferSize,
        EndOfFileVbn,
        FirstFreeByte;
   int64  CdtTime64,
          ModTime64,
          RdtTime64;
   ushort  AcpChannel,
           AtrFpro,
           QioChannel,
           RecordCount,
           RecordSize;
   ulong  AtrUchar,
          AtrUic;
   char  *BufferPtr;

   int64  SizeInBytes64;

   ACPQIO_RECORD_ATTRIBUTES  RecAttr;
   ATRDEF  FileAtr [8];
   struct dsc$descriptor  FibDsc,
                          FileNameDsc;
   IO_SB  IOsb;

#ifdef ODS_EXTENDED
   /* only use the local ENAMEL.H FIB definition when necessary */
#  ifdef ENAMEL_FIBDEF
      struct enamel_fibdef  Fib;
#  else
      FIBDEF  Fib;
#  endif
#else /* ODS_EXTENDED */
   struct fibdef  Fib;
#endif /* ODS_EXTENDED */
};

#pragma member_alignment

typedef struct OdsStruct ODS_STRUCT;

struct OdsStruct
{
   BOOL  DeleteOnClose,
         NamlInUse;

   int  DataLength,
        DataLineLength,
        DataLineNumber,
        DataLineSize,
        ExpFileNameLength,
        NamDeviceLength,
        NamDirectoryLength,
        NamFileSysNameLength,
        NamNameLength,
        NamNodeLength,
        NamTypeLength,
        NamVersionLength,
        ParseInUse,
        ResFileNameLength;

   ulong  Nam_fnb;

   char  *DataPtr,
         *DataLinePtr,
         *DataParsePtr,
         *NamDevicePtr,
         *NamDirectoryPtr,
         *NamFileSysNamePtr,
         *NamNamePtr,
         *NamNodePtr,
         *NamTypePtr,
         *NamVersionPtr;

   char  ExpFileName [ODS_MAX_FILE_NAME_LENGTH+1],
         ResFileName [ODS_MAX_FILE_NAME_LENGTH+1],
         SysFileName [ODS_MAX_FILESYS_NAME_LENGTH+1];

   /* FILES-11 directory parser */
   BOOL  DirectDotDir,
         DirectRetry,
         DirectVersion0,
         DirectVersionHit0;
   uint  DirectCallCount,
         DirectCurrentLength,
         DirectSubRecord,
         DirectSysFileNameLength,
         DirectTheLength,
         DirectTheRecord;
   char  DirectCurrent [256],
         DirectWildcard [256];

   GENERAL_AST  AstFunction;
   ulong  AstParam;

   struct FAB  Fab;
#  ifdef ODS_EXTENDED
      variant_union {
         struct NAM  Nam;
         struct NAML Naml;
      } Overlay1;
#  else /* ODS_EXTENDED */
      struct NAM  Nam;
#  endif /* ODS_EXTENDED */
   struct RAB  Rab;
   struct XABDAT  XabDat;
   struct XABFHC  XabFhc;
   struct XABPRO  XabPro;

   FILE_QIO  FileQio;
};

#pragma __member_alignment __restore

#endif /* ODSSTRUCT_H_LOADED */

/****************************************************************************/

