/************************************************************************
*                       - INFOFLEX System -
* This source code is CONFIDENTIAL and PROPRIETARY to CUSTOMWARE COMPUTING,
* INC. (CWC). 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 CWC.
*
* COPYRIGHT (c) 1986 CUSTOMWARE COMPUTING, INC., BURLINGAME, CALIFORNIA.
* ALL RIGHTS RESERVED.
*************************************************************************/

#ifndef SQCON_H
#define SQCON_H

#include "fxisam.h"

#define OLDPROGNAME  "fxsql"
#ifdef MSDOS
#undef OLDPROGNAME
#define OLDPROGNAME  "FXSQL"
#endif

/* GWM 12/23/97 do not set SQLLONGFILENAME  for true 16 bit DOS */ 
#define SQLLONGFILENAME

#define TBLNAMSIZ    18
#define FLDNAMSIZ    18
#define IDXNAMSIZ    18
#define TBLPTHSIZ    64
#define MAXPTHSIZ  1024
#define USERNAMSIZ    8

#ifdef SQLLONGFILENAME
#   define DBNAMSIZ  10
#else
#   define DBNAMSIZ   8
#endif

#ifdef NETISAM
#define DATAFILESUFF	".rec"
#define IDXFILESUFF	".ind"
#else
#define DATAFILESUFF	".dat"
#define IDXFILESUFF	".idx"
#endif

#define TMSTACK

#define  NULLCHAR    ((char *) 0)
#define  NULLINSTR    -1
#define  NULLFUNC    ((int(*)()) 0)
#define  DEFAULTFUNC ((int(*)()) 0)
#define  EXITFUNC    ((int(*)()) 1)

typedef int (*PFUNC)();
typedef unsigned UNINT;
typedef long PTRTYPE;
#define PTRCAST (unsigned long)
#define UNSHORT (unsigned short)

#ifndef NULL
#define NULL 0
#endif

#define  NO  0
#define  YES 1

#define  OFF 0
#define  ON  1

#ifndef  EOF
#define  EOF (-1)
#endif

#ifndef  TRUE
#define  TRUE 1
#endif

#ifndef  FALSE
#define  FALSE 0
#endif

#define  SPACE      32
#define  PERIOD     46
#define  DASH       45
#define  ZERO       48
#define  NINE       57
#define  OPENBRACE  '{'
#define  CLOSBRACE  '}'

#define RNDFACTOR     .5000000001

/* Extended ISAM error codes.
 */
#define  ERRFILE     301
#define  ERRINDEX    302
#define  ERRNOFD     303
#define  ERRNODB     304
#define  ERRINTRP    305
#define  ERRMODE     306
#define  ERRPATH     307

/* "Julian" dates are number of years from the reference year.
 */
#define  REFYEAR    1900

#define MSGBUFSIZ    256
#define RAWSIZE  (unsigned)1024
#ifdef M_I86MM
#undef RAWSIZE
#define RAWSIZE  (unsigned)512
#endif

#define F_ZEROFILL   0x0002      /* zero fill                 */
#define F_RIGHT      0x0004      /* right-justify output using spaces */
#define F_LEFT       0x0008      /* left-justify output using spaces */
#define F_CENTER     0x0010      /* center output using spaces */
#define F_COMMA      0x0040
#define F_BLANKFILL  0x0080     /* blank fill                 */

#define STNONULLS   0x0100  /* sfState only
                              set by pre-processor to indicate null values
                              are disallowed. This value is equivalent
                              to RDS's value for SQLNONULL = 0400.
                           */

/*
 * The following values pertain to "dhState" element in "DBHEAD"
 */
#define STDHPOS      0x0002     /* data record has been positioned  */
#define STDHPERMTEMP 0x0010     /* DBHEAD generated from SQL
                                   SELECT INTO TEMP section */
#define STDHTEMP     0x0020     /* DBHEAD generated from SQL
                                   SELECT internal section - last duration of
                                   select  */

#define UNDEF	  -1

#ifdef MSDOS3
#define N_RWFILE 4
#else
#define N_RWFILE 20
#endif

struct _S_RWFILE {
    int  rwstatus;
    int  rwfd;
    int  rwmode;
    char rwbuf[RAWSIZE];
    unsigned  rwlastreadsize;
    int  rwnbuf;
    long rwreccnt;
    long rwlastrecnum;
};
typedef struct _S_RWFILE RWFILE;

#endif
