/************************************************************************
*                       - INFOFLEX System -
* This source code is CONFIDENTIAL and PROPRIETARY to INFOFLEX ,
* INC. . The information contained herein may not be used, copied or
* disclosed in whole or in part except as permitted by written agreement
* signed by an officer of INFOFLEX,INC..
*
* COPYRIGHT (c) 1986 INFOFLEX , INC., BURLINGAME, CALIFORNIA.
* ALL RIGHTS RESERVED.
*************************************************************************/

#ifndef FXESQL_H
#define FXESQL_H

#include "sqlstd.h"
#include "sqlfx.h"
#include "sqlca.h"
#include "sqlda.h"
#include "sqltypes.h"
#include "sqlstype.h"
#include "datetime.h"
#ifdef ISTRANS
#include "istrans.h"
#endif

#define	 FXCRREADY	1
#define  FXCREOF	2
#define  FXCRREADTMP	3
#define  FXCRNEXT	0x10
#define  FXCRPREV	0x20
#define  FXCURROW(sqc)	((sqc)->_SQCfirst)
#define  FXREALROW(sqc) (((SELECT *) sqcselect( sqc))->selCurrow)

#define  FXSQL_CALL	0x100
#define  ECPP_CALL	0x200
#define  ECPP_DECL	0x400

#define  CURSSCRL	0x0020
#define  CURSHOLD	0x1000

#define  SQ_LOAD	53
#define  SQ_UNLOAD	54
#define  SQ_INFTAB	55
#define  SQ_INFCOL	56
#define  SQ_INFIDX	57

#define  ESQ_INCLUDE	0x100
#define  ESQ_VARDECL	0x200
#define  ESQ_PREPARE	0x300
#define  ESQ_EXECUTE	0x400
#define  ESQ_DECLARE	0x500
#define  ESQ_DESCRIBE	0x600
#define  ESQ_OPENCURS	0x700
#define  ESQ_CLOSCURS	0x800
#define  ESQ_FETCH	0x900
#define  ESQ_PUT	0xA00
#define  ESQ_FREE	0xB00
#define  ESQ_WHENEVER	0xC00
#define  ESQ_PAREN	0xD00
#define  ESQ_STMT	0xE00
#define  ESQ_DEFINE     0xF00

/* Cursor move parameters for FETCH.
 */
#define  ESQNEXT	1			/* next */
#define  ESQPREV	2			/* previous */
#define  ESQFIRST	3			/* first */
#define  ESQLAST	4			/* last */
#define  ESQCURR	5			/* current */
#define  ESQABS		6			/* absolute */
#define  ESQREL		7			/* relative */

#define  CSTRUCTTYPE	200
#define  CBOOLTYPE	201
/* #define  CTYPEDEF 	202 */

#define  SQLIDSIZ	18

/* SQCflags value for DATABASE execute to open transaction log.
 */
#define  OPENLOG	0x10

#define  SQSNULL	(_SQSTMT *) 0
#define  SQCNULL	(_SQCURSOR *) 0
#define  SQDNULL	(struct sqlda *) 0
#define  SQVNULL	(struct sqlvar_struct *) 0

#define  SCROLL		0x20

#define  sqcselect( sqc)	((sqc)->_SQCcommand[2])
#define  sqcsqltbl( sqc)	((sqc)->_SQCcommand[3])
#define  sqcparams( sqc)	((sqc)->_SQCcommand[4])
#define  sqchosts( sqc)		((sqc)->_SQCcommand[5])
#define  sqcdynamem( sqc)	((sqc)->_SQCstrtab)
#define  sqcparsmem( sqc)	((SQLMEM *) sqcdynamem( sqc))->sqmParsmem
#define  sqccursmem( sqc)	((SQLMEM *) sqcdynamem( sqc))->sqmCursmem
#define  cmdp( sqc)		((sqc)->_SQCcommand[1])
#define  getphase( sqc)		(sqc->_SQCsqlid >> 8)
#define  setphase( sqc, x)  sqc->_SQCsqlid = (sqc->_SQCsqlid & 0xFF) + (x << 8)
#define  fxeqmanualloc( qdesc)	sqdbuf_alloc( SQCNULL, qdesc, NO)
#define	 ecpp_call( sqc)	(sqc->_SQCflags & ECPP_CALL)
#define	 iscursopen( sqc)	(sqc->_SQCflags & 0xFF)
#define  isscrollcurs( sqc)	(sqc->_SQCtbsize)
#define  setscrollcurs( sqc)	sqc->_SQCtbsize = 1
#define  nullscrollcurs( sqc)	sqc->_SQCtbsize = 0

/* Pre-processor structure for host variables declarations.
 */
typedef struct _hvardecl {
	char *	hvdName;		/* variable name */
	short	hvdType;		/* C data type of variable */
	short	hvdLen;			/* data length of char variables or
					      datetime qualifier */
	short	hvdArraysiz;		/* number of elements in array
					      (0 - not an array) */
	short	hvdIsptr;		/* is the variable a pointer? */
	char *  hvdStctag;		/* tag name of structure, if any,
					      if variable is a structure */
	struct _hvardecl *hvdStruct;	/* structure, if any, in which this
					      variable is an element */
	struct _hvardecl *hvdStcdef;	/* pointer to structure that contains
					      the definition for tag */
	short	hvdBlocklvl;		/* nested block level (0 - global or
					      former block deallocated) */
	struct _hvardecl *hvdNext;	/* next host variable structure in
					      linked list */
} HVARDECL;

/* Pre-processor structure for host variables use
 *     pointed to from binding structures.
 */
typedef struct _hvaruse {
	HVARDECL *hvuVar;		/* pointer to variable declaration */
	HVARDECL *hvuStcdef;		/* if variable in a structure,
					       pointer to structure that
					       contains elements definitions */
	short	  hvuVararri;		/* array index if variable is array */
	short	  hvuVarvalp;		/* want value at variable pointer? */
	HVARDECL *hvuIndic;		/* pointer to indicator variable decl */
	HVARDECL *hvuIndstc;		/* if indicator in a structure,
					       pointer to structure that
					       contains elements definitions */
	short	  hvuIndarri;		/* array index if variable is array */
	short	  hvuIndvalp;		/* want value at indicator pointer? */
} HVARUSE;

/* Pre-processor statement i.d.'s and cursor names.
 */
typedef struct _stmtorcurs {
	char *	socStmtid;		/* statement i.d. */
	char *	socCursname;		/* cursor name */
	short   socNum;			/* cursor number */
} STMTORCURS;

#define HVDNULL (HVARDECL *)0
#define HVUNULL (HVARUSE *)0


typedef struct _userlist {
	char	ulUser[USERNAMSIZ+1];
	struct _userlist *ulNext;
} USERLIST;


#include "sqldecl.h"

#endif
