/************************************************************************
*                       - 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 SQTYPES_N
#define SQTYPES_N

/*

LABEL            CWARE     CISAM    ALL-II     C-ISAM-SQL   ALL-ESQL   4GL        CWARE
--------------
CHARTYPE                    0-1       0           0-1         0          0-1      1-1
SHORTTYPE                   ---       ---         ---         ---        1-2      11-2
INTTYPE                     1-2       1-2         1-2         1-2        2-4      1-2
LONGTYPE                    2-4       2-4         2-4         2-4        N/A      2-4
DOUBLETYPE                  3-DBL     3-dbl       3-DBL       3-DBL      3-DBL    3-DBL
FLOATTYPE                   4-flt     4-flt       4-FLT       4-FLT      4-FLT    etc.
DECTYPE                     ---       ---         0           ---        5-17
SERIALTYPE                  ---       long +x0100 ---         6-LONG     6-4
DATETYPE                    ---       long +x0200 ---         7-LONG     7-4
EDATETYPE                   ---       long +x0300 ---         ---        ---
YDATETYPE                   ---       long +x0400 ---         ---        ---
MONEYTYPE                   ---       dbl  +x0500 ---         8-DBL      8-17

TIMETYPE                    ---       -----       ---         ---        ---

*/

/*
    Define version of File Management System:

    CISAM2   ==> CISAM version 2.04
                 Use 'dbconvert -ln' utility on 3.3 Dictionary. Pre-processor
                 will read SQL dictionary and .dat/.idx.
                 Files are NOT readable by INFORMIX SQL because
                 tablenames are used for filenames.

    CISAM3   ==> CISAM version 3.x
                 Files are readable by INFORMIX SQL because
                 tablenames are used for filenames.


*/

#include "sqport.h"

#ifdef CISAM2
#    define CISAM
#    define NO_DEC
#    define CWNONULL
#    define NBUFFS
#endif

#ifdef CISAM3
#    define CISAM
#    define DEC_DBL
#    define ISCLUSTER
#    define NBUFFS
#endif

#ifdef CTREIVE 
#    define CISAM2
#    define NO_DEC
#    define CWNONULL
#endif

#ifdef NETISAM
#    define CISAM2
#    define NO_DEC
#endif

#ifdef DISAM2
#    define DISAM
#    define CISAM2
#    define NO_DEC
#    define CWNONULL
#    define ISCLUSTER
#endif

#ifdef DISAM3
#    define DISAM
#    define CISAM3
#    define DEC_DBL
#    define ISCLUSTER
#endif

#ifdef DISAM4
#    define DISAM
#    define CISAM3
#    define NO_DEC
#    define ISCLUSTER
#endif

#ifdef DISAM6
#    define DISAM
#    define CISAM3
#    define DEC_DBL
#    define ISCLUSTER
#endif

#ifdef MICROFOCUS
#    define DISAM2   /* this may vary depending on Microfocus version */
#    define DISAM
#    define CISAM2   /* this may vary depending on Microfocus version */
#    define DEC_DBL
#    define COBOL_DECIMAL
#endif

#include "decimal.h"
#include <ctype.h>

/*
     - define DEC_DEC to Use decimal structure dec_t
          in screens/reports buffers.
     - define DEC_DBL to Convert decimals to doubles
       in screen/report buffers.
     - define NO_DEC to use doubles only.

     To define a new TYPE update the following:
         I.  fx/include
             1) sqtypes.h  - define new type
         II. fx/src/lib
             1) sqtypes.c   - define new type in table
             2) sqmovtyp.c  - develop functions to move data 
             2) sqformat.c  - add cases to xbuftostr() and xstrtobuf() 
             2) sqgetvar.c  - develop functions for $variables
                              putsfxxx(), getsfxxx(), putdfxxx(), getdfxxx()
*/


#define  CHARTYPE       0
#define  INTTYPE        1
#define  LONGTYPE       2
#define  DOUBLETYPE     3
#define  FLOATTYPE      4
#ifdef NETISAM
#    define  DECTYPE        11 
#else
#    define  DECTYPE        5
#endif
#define  SERIALTYPE     6
#define  DATETYPE       7
#define  EDATETYPE      DATETYPE +  0x0300
#define  YDATETYPE      DATETYPE +  0x0400
#define  MONEYTYPE      8

#define  TIMETYPE       9	/* AM-PM style time format */
#define  DTIMETYPE     10	/* datetime (Informix compatible) */
#define  MTIMETYPE     12	/* military time format */
#define  HOSTTYPE      15
#ifdef NETISAM
#    define  BINTYPE    5 
#else
#    define  BINTYPE    11 
#endif

#define  SHORTTYPE     INTTYPE    /* for SQL only */
#define  COMPOSTYPE     -1
#define  NULLTYPE	-4

#define  SDATETYPE  DATETYPE + 0x10	/* date as quoted string,
					      eg. "12/31/88" */
#define  STIMETYPE  TIMETYPE + 0x10	/* 12 hr. time as quoted string,
					      eg. "03:45P" */
#define  SMTIMETYPE MTIMETYPE + 0x10	/* military time as quoted string,
					      eg. "22:00:00" */

#define SHTNULL    (short) -32768
#define LONGNULL   0x80000000L
#define DATENULL   0x80000000L


#define C_BUFFER 0
#define D_BUFFER 1

#define CWGETDF  0
#define CWPUTDF  1
#define CWGETSF  2
#define CWPUTSF  3

struct _S_VARTABLE {
    char  *vtName;	/* data type name */
    char  *vtAltname;	/* alternate name for data type (null if none) */
    short  vtLength;	/* display length for printing */
    short  vtSize[2];	/* byte size of fields (0 = C_BUFFER, 1 = D_BUFFER) */
    char   vtClearchar;	/* character used to clear variable */
    char  *vtNull[2];	/* null value (0 = C_BUFFER, 1 = D_BUFFER) */
    short  vtKeydtype;	/* data type used in kp_type of keydesc */
#ifdef ANSIPROTO
    void  (*vtMovfunc[4]) (char *,int,char *,int);
#else
    void  (*vtMovfunc[4]) ();
#endif
};
typedef struct _S_VARTABLE VARTABLE;

/* no M_TLS -- read only structures */
extern VARTABLE vartable[];
extern int n_vartable;

#endif
