/*******************************************************************************
* YORKTOWN ADVANCED SGML PARSER (YASP)                                         *
*         An SGML Parser conforming to International Standard ISO 8879 --      *
*         Standard Generalized Markup Language                                 *
*------------------------------------------------------------------------------*
* Written 1987 - 1993 by                                                       *
*         Pierre G. Richard                                                    *
*         IBM T.J. Watson Research Center                                      *
*         Yorktown Heights, New York                                           *
*         petrus@watson.ibm.com                                                *
*------------------------------------------------------------------------------*
* FUNCTION NAME    = YASP / Header File                                        *
* STATUS           = Version 0, Release 1, Level 25 and up                     *
* COMPONENT NAME   = ocs.h                                                     *
* DESCRIPTIVE NAME = Define structures / functions shared by OCS modules       *
* DATE_WR          = 03/29/1988                                                *
* AUTHOR           = Pierre G. Richard - PETRUS at YKTVMX                      *
*                                                                              *
* FUNCTIONAL DESCRIPTION =                                                     *
* IMPLEMENTATION NOTES =                                                       *
* CHANGE HISTORY =                                                             *
*******************************************************************************/

typedef struct t_CHARSTAT {       /* indexed by the system character position */
   uchar  doc_d_chnb;             /* code # in the document */
   uchar  syn_d_chnb;             /* code # in the syntax */
   uint   is_described  : 2;      /* doc/syn code # describes this char */
   uint   is_multiple   : 2;      /* only one or more than one */
   uint                 : 4;      /* filler */
   uint   upper         : 8;      /* s_chnb upper case form */
}CHARSTAT;

/* for the is_described and is_multiple fields:               */
/* 0x01 is the mask for CHARSET, 0x02 is the mask for SYNTAX  */
#define IN_DOC_MASK  0x01
#define IN_SYN_MASK  0x02

/*-----------------------------------------------------------------+
|This structure is a common data area used when compiling the CSD  |
+-----------------------------------------------------------------*/
typedef struct {
   GA_P     gbla_p;
   DSTAB    dstab;
   struct t_DDLMV_STR {
      uchar *s1;
      uchar *s2;
   }ddlmv_str[NBR_OF_DDLMV];     /* combined delimiters */
   CHARSTAT charstat[2 * MAX_CHARSET];
   DSET     syn_dset[MAX_CHARSET];
   uchar   *parmlit[MAX_CHARSET];
   uchar    swtab[MAX_CHARSET];  /* switch handling */
   ushort   gtype[MAX_CHARSET];
   uchar    uctab[MAX_CHARSET];
   ALLMO    dltab[MAX_CHARSET];  /* updated by dlm_bld / dlm_dvtb */
   EQTK    *srtab;
   uint     sr_max;
   uint     dv_max;
   OPT      opt;
   void    *delim_id;            /* to identify the delimiter sa_array */
   boolean  is_not_FPID;         /* If a formal PID was incorrect */
   boolean  must_abort;
   struct {                      /* check allowed changes if SCOPE INSTANCE */
     uint mdo    :  1;
     uint pio    :  1;
     uint com    :  1;
     uint mdc    :  1;
     uint unused : 12;
   }is_dlm_change;
}COMMON_OCS_AREA;

/* Common area is on the stack (in the nearby) */
typedef COMMON_OCS_AREA STACK_BASED * COMMON_P;

extern uint  P_FCT ocs_gplt    (COMMON_P, uchar *, boolean);
extern int   P_FCT ocs_chrf    (COMMON_P, uchar);
extern void  P_FCT cap_bld     (COMMON_P);
extern void  P_FCT qty_bld     (GA_P, QNTY *);
extern void  P_FCT nam_bld     (GA_P, GNWDTAB **, FNCR *);
extern void  P_FCT chr_shun    (COMMON_P);
extern void  P_FCT chr_bld     (COMMON_P, boolean);
extern void  P_FCT dlm_bld     (COMMON_P);
extern DV *  P_FCT dlm_dvtb    (COMMON_P, DVTBENT *);
/******************************************************************************/
