/* ---------------------------------------------------- */
/* Header-file DBSYS 1.0, (C) Wabnig Harald, 15.12.2002 */
/* ---------------------------------------------------- */

#ifndef DBBTYPES_INCLUDE
#define DBBTYPES_INCLUDE

#define SQL_NONE	      0
#define SQL_SELECTPK    1
#define SQL_SELECTLK    2
#define SQL_DO          3
#define SQL_SELECT      4
#define SQL_INSERT      5
#define SQL_UPDATE      6
#define SQL_DELETE      7

#define SQL_DEFSHORT    -32768
#define SQL_MINSHORT    SQL_DEFSHORT
#define SQL_MAXSHORT    32767

#define SQL_DEFLONG     -2147483647L
#define SQL_MINLONG     SQL_DEFLONG
#define SQL_MAXLONG     2147483647L

#define SQL_DEFFLOAT    -1.e+20f
#define SQL_MINFLOAT    SQL_DEFFLOAT
#define SQL_MAXFLOAT    1.e+20f

#define SQL_DEFDOUBLE   -1.e+20
#define SQL_MINDOUBLE   SQL_DEFDOUBLE
#define SQL_MAXDOUBLE   1.e+20

#define SQL_DEFDATE     {1800,1,1}
#define SQL_MINDATE     SQL_DEFDATE
#define SQL_MAXDATE     {2800,12,31}

#define SQL_DEFTIME     {0,0,1}
#define SQL_MINTIME     {0,0,0}
#define SQL_MAXTIME     {23,59,59}

#define SQL_DEFDATI     {1800,1,1,0,0,0,0}
#define SQL_MINDATI     SQL_DEFDATI
#define SQL_MAXDATI     {2800,12,31,23,59,59,0}

typedef enum {
  DATE_YYYYMMDD = 1, /* Stringformat: 20020524 */
  DATE_DDMMYYYY,     /* Stringformat: 24.05.2002 */
  DATE_DEFAULT,      /* Default Format: 2002.05.24 */
} DateType;

typedef enum {
  TIME_DEFAULT = 1   /* Default Format: 22.25.17 */
} TimeType;

typedef enum {
  DATI_DEFAULT = 1   /* Default Format: 2002.05.24.22.25.17.123456 */
} DatiType;

typedef enum {
  RND_FINANCE =  1,  /* Round financial */
  RND_UP,            /* Round up */
  RND_DOWN           /* Round down. */
} RndType;

typedef enum {
  MODE_30 = 1,       /* 30 days a month */
  MODE_30F,          /* 30 days a month, February has 30 days at 28th or 29th */
  MODE_ACT           /* Month has actual number of days */
} ModeType;

typedef struct ADATE {
  short sYear;
  unsigned char sMonth, sDay;
} ADATE;

typedef struct ATIME {
  unsigned char sHour, sMin, sSec ;
} ATIME;

typedef struct ADATI {
  short sYear ;
  unsigned char sMonth, sDay, sHour, sMin, sSec;
  long  lMicro;
} ADATI;

/* Common structure-header */

typedef struct DEF_STRUCT {
  int iSize, iDB, _iTablenr;
  void * _pfnCmpPk, * _pfnCmpLk;
} DEF_STRUCT;

/* Compressed data-row declarations */

typedef struct COMPR {
  int iCount, iPos, iMaxLen, iRowPos;
  char * pCPROW;
  short sFormat;
  void * fnInit;
} COMPR;

/* --------------------------- */

#define MAXSTRG		10000

#define TYP_LOGICAL	1
#define STYP_LOGICAL	"LOGICAL"

#define TYP_SHORT	2
#define STYP_SHORT	"SHORT"
#define DEF_SHORT 	SQL_DEFSHORT
#define MIN_SHORT 	SQL_MINSHORT
#define MAX_SHORT 	SQL_MAXSHORT

#define TYP_INT		3
#define STYP_INT	"INT"

#define TYP_LONG	4
#define STYP_LONG	"LONG"
#define DEF_LONG 	SQL_DEFLONG
#define MIN_LONG	SQL_MINLONG
#define MAX_LONG	SQL_MAXLONG

#define TYP_USHORT	5
#define STYP_USHORT	"USHORT"

#define TYP_UINT	6
#define STYP_UINT	"UINT"

#define TYP_ULONG	7
#define STYP_ULONG	"ULONG"

#define TYP_FLOAT	8
#define STYP_FLOAT	"FLOAT"
#define DEF_FLOAT 	SQL_DEFFLOAT
#define MIN_FLOAT	SQL_MINFLOAT
#define MAX_FLOAT	SQL_MAXFLOAT

#define TYP_DOUBLE	9
#define STYP_DOUBLE	"DOUBLE"
#define DEF_DOUBLE 	SQL_DEFDOUBLE
#define MIN_DOUBLE	SQL_MINDOUBLE
#define MAX_DOUBLE	SQL_MAXDOUBLE

#define TYP_CHAR	10
#define STYP_CHAR	"CHAR"

#define TYP_STRING	11
#define STYP_STRING	"STRING"

#define TYP_DATE	12
#define STYP_DATE	"DATE"
#define SIZE_DATE	10
#define DEF_DATE 	(_Def_Date)
#define MIN_DATE	DEF_DATE
#define MAX_DATE	(_Max_Date)

#define TYP_TIME	13
#define STYP_TIME	"TIME"
#define SIZE_TIME	8
#define DEF_TIME 	(_Def_Time)

#define TYP_DATI	14
#define STYP_DATI	"DATI"
#define SIZE_DATI	26
#define DEF_DATI 	(_Def_Dati)

#define TYP_BINARY	18
#define STYP_BINARY	"BINARY"

#define DEF_STRLEN	8000

#define DEF_STRING(l)	""


#endif