/* Ported to GNU C openVMS/Alpha by Klaus Kämpf, kkaempf@progis.de  */
/* <xabcxfdef.h>
 *
 *	RMS context XAB associated with FAB
 */
#ifndef _XABCXFDEF_H
#define _XABCXFDEF_H

#ifdef __cplusplus
extern "C" {
#endif

#define XAB$C_CXF	32	/* xabcxf ID code */
#define XAB$V_CXFRST	0
#define XAB$M_CXFRST	(1<<XAB$V_CXFRST)	/* 0x01 */
#define XAB$K_CXFLEN	60	/* length of xab type CXF */
#define XAB$C_CXFLEN	60

#ifndef __XABSTART_FIELDS
#include <vms/xabdef.h>
#endif

#ifdef __ALPHA
#define XABCXF xabcxfdef
#else
struct XABCXF {
  __XABSTART_FIELDS
    unsigned long  xab$l_cxfsts;	/* status of last file operation */
    unsigned long  xab$l_cxfstv;	/* status value of last file operation */
    unsigned long  xab$l_cxfcop;	/* context options */
    unsigned long  xab$l_cxfbkp;	/* bookkeeping bits */
    unsigned short xab$w_cxfifi;	/* internal file identifier */
    unsigned char  xab$b_cxfver;	/* prologue version num */
	unsigned char : 8;		/* spare to longword align commonality */
	unsigned : 32;			/* spare */
    unsigned short xab$w_cxfdeq;	/* default extention quantity */
    unsigned char  xab$b_cxffac;	/* file access */
    unsigned char  xab$b_cxfshr;	/* file sharing */
    unsigned short xab$w_cxfrte;	/* (not used) */
	unsigned char : 8;		/* spare */
    unsigned char  xab$b_cxforg;	/* file organization */
    unsigned short xab$w_cxfgbc;	/* global buffer count */
    unsigned char  xab$b_cxfrtv;	/* retrieval window */
	unsigned char : 8;
	unsigned int : 32, : 32, : 32, : 32;	/*long[4]*/
} __attribute__ ((packed));
#endif

struct xabcxfdef {
  __XABSTART_FIELDS
    unsigned long xab$l_cxfsts;		/* status of last file operation */
    unsigned long xab$l_cxfstv;		/* status value of last file operation */
/*
   Top four bits of the options longword are reserved for the XABCXR.  These
   bits describe the version of the key buffer.
 */
    union {
	unsigned long xab$l_cxfcop;	/* context options */
#define xab$l_cxfcop xab$r_cxfcop_overlay.xab$l_cxfcop
	struct {
	    unsigned xab$v_cxfrst : 1;	/* restore file state - use context blk as input */
	    unsigned		  : 7;
	} xab$r_cxfcop_bits;
#define xab$v_cxfrst xab$r_cxfcop_overlay.xab$r_cxfcop_bits.xab$v_cxfrst
    } xab$r_cxfcop_overlay;
    unsigned long xab$l_cxfbkp;		/* bookkeeping bits */
    unsigned short xab$w_cxfifi;	/* internal file identifier */
    unsigned char xab$b_cxfver;		/* prologue version num */
	unsigned char : 8;		/* char fill; spare for alignment */
	unsigned int : 32;			/* long fill; spare */
 /* the following fields correspond to those in the FAB or IFB */
    unsigned short xab$w_cxfdeq;	/* default extention quantity */
    unsigned char xab$b_cxffac;		/* file access */
    unsigned char xab$b_cxfshr;		/* file sharing */
    unsigned short xab$w_cxfrte;	/* (not used) */
	unsigned char : 8;		/* char fill; spare */
    unsigned char xab$b_cxforg;		/* file organization */
    unsigned short xab$w_cxfgbc;	/* global buffer count */
    unsigned char xab$b_cxfrtv;		/* retrieval window */
	unsigned char : 8;		/* char fill; */
	unsigned int : 32, : 32, : 32, : 32; /* long fill[4]; spares */
} __attribute__ ((packed));

#if 0	/* there's no FAB context xab prototype available */
#ifdef __ALPHA
#else
/* declare initialized prototype data structure */
extern struct XABCXF cc$rms_xabcxf __asm("_$$PsectAttributes_GLOBALSYMBOL$$cc$rms_xabcxf");
/* globalref struct XABCXF cc$rms_xabcxf; */
#endif
#endif

#ifdef __cplusplus
  }
#endif

#endif	/*_XABCXFDEF_H*/
