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

#ifndef DBTYPES_INCLUDE
#define DBTYPES_INCLUDE

#include <speedy.h>
#include <speedydb.h>

#ifdef WIN32
#include <windows.h>
#endif

#include "dbarray.h"
#include "dbbtypes.h"
#include "dbtypes.h"
#include "dbapi.h"

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

#define TYPE_FSurrogat        TYP_STRING
#define SIZE_FSurrogat        8
#define DEF_FSurrogat         "        "
#define INIT_FSurrogat(a)    strcpy(a, DEF_FSurrogat)
#define FILL_FSurrogat(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FSurrogat(a,b)    my_strncpy((char*)a,(char*)b,8)
#define CMP_FSurrogat(a,b)    my_strcmp(a,b)
typedef char TFSurrogat[9];

#define TYPE_FLogical        TYP_CHAR
#define DEF_FLogical         '0'
#define INIT_FLogical(a)    a = DEF_FLogical
#define FILL_FLogical(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%c", &(a))
#define COPY_FLogical(a,b)    a = b
#define CMP_FLogical(a,b)    (a == b)
typedef char TFLogical;

#define TYPE_FChar_1        TYP_CHAR
#define DEF_FChar_1         '0'
#define INIT_FChar_1(a)        a = DEF_FChar_1
#define FILL_FChar_1(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%c", &(a))
#define COPY_FChar_1(a,b)    (a = b)
#define CMP_FChar_1(a,b)    (a == b)
typedef char TFChar_1;

#define TYPE_FChar_2        TYP_STRING
#define SIZE_FChar_2        2
#define DEF_FChar_2         DEF_STRING(2)
#define INIT_FChar_2(a)        strcpy(a, DEF_FChar_2)
#define FILL_FChar_2(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_2(a,b)    my_strncpy((char*)a,(char*)b,2)
#define CMP_FChar_2(a,b)    my_strcmp(a,b)
typedef char TFChar_2[3];

#define TYPE_FChar_3        TYP_STRING
#define SIZE_FChar_3        3
#define DEF_FChar_3         DEF_STRING(3)
#define INIT_FChar_3(a)        strcpy(a, DEF_FChar_3)
#define FILL_FChar_3(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_3(a,b)    my_strncpy((char*)a,(char*)b,3)
#define CMP_FChar_3(a,b)    my_strcmp(a,b)
typedef char TFChar_3[4];

#define TYPE_FChar_4        TYP_STRING
#define SIZE_FChar_4        4
#define DEF_FChar_4         DEF_STRING(4)
#define INIT_FChar_4(a)        strcpy(a, DEF_FChar_4)
#define FILL_FChar_4(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_4(a,b)    my_strncpy((char*)a,(char*)b,4)
#define CMP_FChar_4(a,b)    my_strcmp(a,b)
typedef char TFChar_4[5];

#define TYPE_FChar_5        TYP_STRING
#define SIZE_FChar_5        5
#define DEF_FChar_5         DEF_STRING(5)
#define INIT_FChar_5(a)        strcpy(a, DEF_FChar_5)
#define FILL_FChar_5(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_5(a,b)    my_strncpy((char*)a,(char*)b,5)
#define CMP_FChar_5(a,b)    my_strcmp(a,b)
typedef char TFChar_5[6];

#define TYPE_FChar_6        TYP_STRING
#define SIZE_FChar_6        6
#define DEF_FChar_6         DEF_STRING(6)
#define INIT_FChar_6(a)        strcpy(a, DEF_FChar_6)
#define FILL_FChar_6(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_6(a,b)    my_strncpy((char*)a,(char*)b,6)
#define CMP_FChar_6(a,b)    my_strcmp(a,b)
typedef char TFChar_6[7];

#define TYPE_FChar_7        TYP_STRING
#define SIZE_FChar_7        7
#define DEF_FChar_7         DEF_STRING(7)
#define INIT_FChar_7(a)        strcpy(a, DEF_FChar_7)
#define FILL_FChar_7(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_7(a,b)    my_strncpy((char*)a,(char*)b,7)
#define CMP_FChar_7(a,b)    my_strcmp(a,b)
typedef char TFChar_7[8];

#define TYPE_FChar_8        TYP_STRING
#define SIZE_FChar_8        8
#define DEF_FChar_8         DEF_STRING(8)
#define INIT_FChar_8(a)        strcpy(a, DEF_FChar_4)
#define FILL_FChar_8(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_8(a,b)    my_strncpy((char*)a,(char*)b,8)
#define CMP_FChar_8(a,b)    my_strcmp(a,b)
typedef char TFChar_8[9];

#define TYPE_FChar_10        TYP_STRING
#define SIZE_FChar_10        10
#define DEF_FChar_10         DEF_STRING(10)
#define INIT_FChar_10(a)    strcpy(a, DEF_FChar_10)
#define FILL_FChar_10(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_10(a,b)    my_strncpy((char*)a,(char*)b,10)
#define CMP_FChar_10(a,b)    my_strcmp(a,b)
typedef char TFChar_10[11];

#define TYPE_FChar_12        TYP_STRING
#define SIZE_FChar_12        12
#define DEF_FChar_12         DEF_STRING(12)
#define INIT_FChar_12(a)    strcpy(a, DEF_FChar_12)
#define FILL_FChar_12(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_12(a,b)    my_strncpy((char*)a,(char*)b,12)
#define CMP_FChar_12(a,b)    my_strcmp(a,b)
typedef char TFChar_12[13];

#define TYPE_FChar_15        TYP_STRING
#define SIZE_FChar_15        15
#define DEF_FChar_15         DEF_STRING(15)
#define INIT_FChar_15(a)    strcpy(a, DEF_FChar_15)
#define FILL_FChar_15(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_15(a,b)    my_strncpy((char*)a,(char*)b,15)
#define CMP_FChar_15(a,b)    my_strcmp(a,b)
typedef char TFChar_15[16];

#define TYPE_FChar_16        TYP_STRING
#define SIZE_FChar_16        16
#define DEF_FChar_16         DEF_STRING(16)
#define INIT_FChar_16(a)    strcpy(a, DEF_FChar_16)
#define FILL_FChar_16(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_16(a, b)    my_strncpy((char*)a,(char*)b,16)
#define CMP_FChar_16(a,b)    my_strcmp(a,b)
typedef char TFChar_16[17];

#define TYPE_FChar_19        TYP_STRING
#define SIZE_FChar_19        19
#define DEF_FChar_19         DEF_STRING(19)
#define INIT_FChar_19(a)    strcpy(a, DEF_FChar_19)
#define FILL_FChar_19(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_19(a, b)    my_strncpy((char*)a,(char*)b,19)
#define CMP_FChar_19(a,b)    my_strcmp(a,b)
typedef char TFChar_19[20];

#define TYPE_FChar_20        TYP_STRING
#define SIZE_FChar_20        20
#define DEF_FChar_20         DEF_STRING(20)
#define INIT_FChar_20(a)    strcpy(a, DEF_FChar_20)
#define FILL_FChar_20(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_20(a,b)    my_strncpy((char*)a,(char*)b,20)
#define CMP_FChar_20(a,b)    my_strcmp(a,b)
typedef char TFChar_20[21];

#define TYPE_FChar_21        TYP_STRING
#define SIZE_FChar_21        21
#define DEF_FChar_21         DEF_STRING(21)
#define INIT_FChar_21(a)    strcpy(a, DEF_FChar_21)
#define FILL_FChar_21(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_21(a,b)    my_strncpy((char*)a,(char*)b,21)
#define CMP_FChar_21(a,b)    my_strcmp(a,b)
typedef char TFChar_21[22];

#define TYPE_FChar_24        TYP_STRING
#define SIZE_FChar_24        24
#define DEF_FChar_24         DEF_STRING(24)
#define INIT_FChar_24(a)    strcpy(a, DEF_FChar_24)
#define FILL_FChar_24(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_24(a,b)    my_strncpy((char*)a,(char*)b,24)
#define CMP_FChar_24(a,b)    my_strcmp(a,b)
typedef char TFChar_24[25];

#define TYPE_FChar_25        TYP_STRING
#define SIZE_FChar_25        25
#define DEF_FChar_25         DEF_STRING(25)
#define INIT_FChar_25(a)    strcpy(a, DEF_FChar_25)
#define FILL_FChar_25(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_25(a,b)    my_strncpy((char*)a,(char*)b,25)
#define CMP_FChar_25(a,b)    my_strcmp(a,b)
typedef char TFChar_25[26];

#define TYPE_FChar_30        TYP_STRING
#define SIZE_FChar_30        30
#define DEF_FChar_30         DEF_STRING(30)
#define INIT_FChar_30(a)    strcpy(a, DEF_FChar_30)
#define FILL_FChar_30(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_30(a,b)    my_strncpy((char*)a,(char*)b,30)
#define CMP_FChar_30(a,b)    my_strcmp(a,b)
typedef char TFChar_30[31];

#define TYPE_FChar_32        TYP_STRING
#define SIZE_FChar_32        32
#define DEF_FChar_32         DEF_STRING(32)
#define INIT_FChar_32(a)    strcpy(a, DEF_FChar_32)
#define FILL_FChar_32(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_32(a,b)    my_strncpy((char*)a,(char*)b,32)
#define CMP_FChar_32(a,b)    my_strcmp(a,b)
typedef char TFChar_32[33];

#define TYPE_FChar_35        TYP_STRING
#define SIZE_FChar_35        35
#define DEF_FChar_35         DEF_STRING(35)
#define INIT_FChar_35(a)    strcpy(a, DEF_FChar_35)
#define FILL_FChar_35(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_35(a,b)    my_strncpy((char*)a,(char*)b,35)
#define CMP_FChar_35(a,b)    my_strcmp(a,b)
typedef char TFChar_35[36];

#define TYPE_FChar_40        TYP_STRING
#define SIZE_FChar_40        40
#define DEF_FChar_40         DEF_STRING(40)
#define INIT_FChar_40(a)    strcpy(a, DEF_FChar_40)
#define FILL_FChar_40(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_40(a,b)    my_strncpy((char*)a,(char*)b,40)
#define CMP_FChar_40(a,b)    my_strcmp(a,b)
typedef char TFChar_40[41];

#define TYPE_FChar_46        TYP_STRING
#define SIZE_FChar_46        46
#define DEF_FChar_46         DEF_STRING(46)
#define INIT_FChar_46(a)    strcpy(a, DEF_FChar_46)
#define FILL_FChar_46(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_46(a,b)    my_strncpy((char*)a,(char*)b,46)
#define CMP_FChar_46(a,b)    my_strcmp(a,b)
typedef char TFChar_46[47];

#define TYPE_FChar_55        TYP_STRING
#define SIZE_FChar_55        55
#define DEF_FChar_55         DEF_STRING(55)
#define INIT_FChar_55(a)    strcpy(a, DEF_FChar_55)
#define FILL_FChar_55(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_55(a, b)    my_strncpy((char*)a,(char*)b,55)
#define CMP_FChar_55(a,b)    my_strcmp(a,b)
typedef char TFChar_55[56];

#define TYPE_FChar_58        TYP_STRING
#define DEF_FChar_58         DEF_STRING(58)
#define INIT_FChar_58(a)    strcpy(a, DEF_FChar_58)
#define FILL_FChar_58(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_58(a,b)    my_strncpy((char*)a,(char*)b,58)
#define CMP_FChar_58(a,b)    my_strcmp(a,b)
typedef char TFChar_58[59];

#define TYPE_FChar_60        TYP_STRING
#define SIZE_FChar_60        60
#define DEF_FChar_60         DEF_STRING(60)
#define INIT_FChar_60(a)    strcpy(a, DEF_FChar_60)
#define FILL_FChar_60(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_60(a,b)    my_strncpy((char*)a,(char*)b,60)
#define CMP_FChar_60(a,b)    my_strcmp(a,b)
typedef char TFChar_60[61];

#define TYPE_FChar_68        TYP_STRING
#define DEF_FChar_68         DEF_STRING(68)
#define INIT_FChar_68(a)    strcpy(a, DEF_FChar_68)
#define FILL_FChar_68(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_68(a,b)    my_strncpy((char*)a,(char*)b,68)
#define CMP_FChar_68(a,b)    my_strcmp(a,b)
typedef char TFChar_68[69];

#define TYPE_FChar_80        TYP_STRING
#define SIZE_FChar_80        80
#define DEF_FChar_80         DEF_STRING(80)
#define INIT_FChar_80(a)    strcpy(a, DEF_FChar_80)
#define FILL_FChar_80(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_80(a,b)    my_strncpy((char*)a,(char*)b,80)
#define CMP_FChar_80(a,b)    my_strcmp(a,b)
typedef char TFChar_80[81];

#define TYPE_FChar_120        TYP_STRING
#define SIZE_FChar_120        120
#define DEF_FChar_120         DEF_STRING(120)
#define INIT_FChar_120(a)    strcpy(a, DEF_FChar_120)
#define FILL_FChar_120(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_120(a,b)    my_strncpy((char*)a,(char*)b,120)
#define CMP_FChar_120(a,b)    my_strcmp(a,b)
typedef char TFChar_120[121];

#define TYPE_FChar_132        TYP_STRING
#define SIZE_FChar_132        132
#define DEF_FChar_132         DEF_STRING(132)
#define INIT_FChar_132(a)    strcpy(a, DEF_FChar_132)
#define FILL_FChar_132(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_132(a, b)    my_strncpy((char*)a,(char*)b,132)
#define CMP_FChar_132(a,b)    my_strcmp(a,b)
typedef char TFChar_132[133];

#define TYPE_FChar_140        TYP_STRING
#define SIZE_FChar_140        140
#define DEF_FChar_140         DEF_STRING(140)
#define INIT_FChar_140(a)    strcpy(a, DEF_FChar_140)
#define FILL_FChar_140(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_140(a,b)    my_strncpy((char*)a,(char*)b,140)
#define CMP_FChar_140(a,b)    my_strcmp(a,b)
typedef char TFChar_140[141];

#define TYPE_FChar_146        TYP_STRING
#define DEF_FChar_146         DEF_STRING(146)
#define INIT_FChar_146(a)    strcpy(a, DEF_FChar_146)
#define FILL_FChar_146(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_146(a,b)    my_strncpy((char*)a,(char*)b,146)
#define CMP_FChar_146(a,b)    my_strcmp(a,b)
typedef char TFChar_146[147];

#define TYPE_FChar_160        TYP_STRING
#define DEF_FChar_160         DEF_STRING(160)
#define INIT_FChar_160(a)    strcpy(a, DEF_FChar_160)
#define FILL_FChar_160(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_160(a,b)    my_strncpy((char*)a,(char*)b,160)
#define CMP_FChar_160(a,b)    my_strcmp(a,b)
typedef char TFChar_160[161];

#define TYPE_FChar_254        TYP_STRING
#define SIZE_FChar_254        254
#define DEF_FChar_254         DEF_STRING(254)
#define INIT_FChar_254(a)    strcpy(a, DEF_FChar_254)
#define FILL_FChar_254(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_254(a,b)    my_strncpy((char*)a,(char*)b,254)
#define CMP_FChar_254(a,b)    my_strcmp(a,b)
typedef char TFChar_254[255];

#define TYPE_FChar_255        TYP_STRING
#define SIZE_FChar_255        255
#define DEF_FChar_255         DEF_STRING(255)
#define INIT_FChar_255(a)    strcpy(a, DEF_FChar_255)
#define FILL_FChar_255(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_255(a,b)    my_strncpy((char*)a,(char*)b,255)
#define CMP_FChar_255(a,b)    my_strcmp(a,b)
typedef char TFChar_255[256];

#define TYPE_FChar_4000        TYP_STRING
#define SIZE_FChar_4000        4000
#define DEF_FChar_4000         DEF_STRING(4000)
#define INIT_FChar_4000(a)    strcpy(a, DEF_FChar_4000)
#define FILL_FChar_4000(res, i, a)    strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FChar_4000(a,b)    my_strncpy((char*)a,(char*)b,4000)
#define CMP_FChar_4000(a,b)    my_strcmp(a,b)
typedef char TFChar_4000[4001];

#define TYPE_FTimestamp        TYP_DATI
#define SIZE_FTimestamp     SIZE_DATI
#define DEF_FTimestamp         DEF_DATI
#define VALID_FTimestamp(a)    DATI_IsValid(&a)
#define INIT_FTimestamp(a)    (a = DEF_FTimestamp)
#define FILL_FTimestamp(res, i, a)    \
    (DATI_FromString(&(a), dbgetvalue(res, 0, i)))
#define COPY_FTimestamp(a,b)    (a = b)
#define CMP_FTimestamp(a,b)    (((ADATI*)&a)->lMicro==((ADATI*)&b)->lMicro && \
                             ((ADATI*)&a)->sSec  ==((ADATI*)&b)->sSec && \
                 ((ADATI*)&a)->sMin  ==((ADATI*)&b)->sMin && \
                 ((ADATI*)&a)->sHour ==((ADATI*)&b)->sHour && \
                 ((ADATI*)&a)->sDay  ==((ADATI*)&b)->sDay && \
                 ((ADATI*)&a)->sMonth==((ADATI*)&b)->sMonth && \
                 ((ADATI*)&a)->sYear ==((ADATI*)&b)->sYear)
typedef ADATI TFTimestamp;

#define TYPE_FShort    TYP_SHORT
#define DEF_FShort     DEF_SHORT
#define MIN_FShort     MIN_SHORT
#define MAX_FShort     MAX_SHORT
#define INIT_FShort(a)    a = DEF_FShort
#define FILL_FShort(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%hd", &(a))
#define COPY_FShort(a,b)    a = b
#define CMP_FShort(a,b)    (a == b)
typedef short int TFShort;

#define TYPE_FInt    TYP_INT
#define DEF_FInt     DEF_INT
#define MIN_FInt     MIN_INT
#define MAX_FInt     MAX_INT
#define INIT_FInt(a)    a = DEF_FInt
#define FILL_FInt(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%d", &(a))
#define COPY_FInt(a,b)    a = b
#define CMP_FInt(a,b)    (a == b)
typedef int TFInt;

#define TYPE_FLong    TYP_LONG
#define DEF_FLong      DEF_LONG
#define MIN_FLong      MIN_LONG
#define MAX_FLong      MAX_LONG
#define INIT_FLong(a)    a = DEF_FLong
#define FILL_FLong(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%d", &(a))
#define COPY_FLong(a,b)    a = b
#define CMP_FLong(a,b)    (a == b)
typedef long int TFLong;

#define TYPE_FDouble        TYP_DOUBLE
#define DEF_FDouble         DEF_DOUBLE
#define MIN_FDouble         MIN_DOUBLE
#define MAX_FDouble         MAX_DOUBLE
#define INIT_FDouble(a)        a = DEF_FDouble
#define FILL_FDouble(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%lf", &(a))
#define COPY_FDouble(a,b)    a = b
#define CMP_FDouble(a,b)    (a == b)
typedef double TFDouble;

#define TYPE_FTime        TYP_TIME
#define SIZE_FTime        8
#define DEF_FTime         DEF_TIME
#define VALID_FTime(a)        TIME_IsValid(&a)
#define INIT_FTime(a)        (a = DEF_FTime)
#define FILL_FTime(res, i, a) \
    (TIME_FromString(&(a), dbgetvalue(res, 0, i)))
#define COPY_FTime(a,b)        (a = b)
#define CMP_FTime(a,b)        (((ATIME*)&a)->sSec ==((ATIME*)&b)->sSec && \
                 ((ATIME*)&a)->sMin ==((ATIME*)&b)->sMin && \
                 ((ATIME*)&a)->sHour==((ATIME*)&b)->sHour)
typedef ATIME TFTime;

#define TYPE_FDate        TYP_DATE
#define SIZE_FDate        SIZE_DATE
#define DEF_FDate         DEF_DATE
#define MIN_FDate         MIN_DATE
#define MAX_FDate         MAX_DATE
#define VALID_FDate(a)        DATE_IsValid(&a)
#define INIT_FDate(a)        (a = DEF_FDate)
#define FILL_FDate(res, i, a) \
    (DATE_FromString(&(a), dbgetvalue(res, 0, i), DA_DEFAULT))
#define COPY_FDate(a,b)    (a = b)
#define CMP_FDate(a,b)        (((ADATI*)&a)->sDay  ==((ADATI*)&b)->sDay && \
                 ((ADATI*)&a)->sMonth==((ADATI*)&b)->sMonth && \
                 ((ADATI*)&a)->sYear ==((ADATI*)&b)->sYear)
typedef ADATE TFDate;

#define TYPE_FDay        TYP_SHORT
#define DEF_FDay         DEF_SHORT
#define MIN_FDay         MIN_SHORT
#define MAX_FDay         MAX_SHORT
#define INIT_FDay(a)        a = DEF_FDay
#define FILL_FDay(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%hd", &(a))
#define COPY_FDay(a,b)        a = b
#define CMP_FDay(a,b)        (a == b)
typedef short int TFDay;

#define TYPE_FMonth        TYP_SHORT
#define DEF_FMonth         DEF_SHORT
#define MIN_FMonth         MIN_SHORT
#define MAX_FMonth         MAX_SHORT
#define INIT_FMonth(a)        a = DEF_FMonth
#define FILL_FMonth(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%hd", &(a))
#define COPY_FMonth(a,b)        a = b
#define CMP_FMonth(a,b)        (a == b)
typedef short int TFMonth;

#define TYPE_FYear        TYP_SHORT
#define DEF_FYear         DEF_SHORT
#define MIN_FYear         MIN_SHORT
#define MAX_FYear         MAX_SHORT
#define INIT_FYear(a)        a = DEF_FYear
#define FILL_FYear(res, i, a)    sscanf(dbgetvalue(res, 0, i), "%hd", &(a))
#define COPY_FYear(a,b)        a = b
#define CMP_FYear(a,b)        (a == b)
typedef short int TFYear;

#define BINARY_LEN(a)   (*((short*)a))
#define BINARY_DATA(a)  ((char*)&((a)[sizeof(short)]))
   
#define SIZE_FBinary		4000
#define TYPE_FBinary		TYP_BINARY
#define DEF_FBinary 		_Def_Binary
#define INIT_FBinary(a)	bin_strinit(a,SIZE_FBinary)
#define FILL_FBinary(res, i, a)	bin_strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FBinary(a,b)	bin_strcpy((char*)a,(char*)b)
#define CMP_FBinary(a,b)	bin_strcmp(a,b)
typedef char TFBinary[SIZE_FBinary + sizeof(short) + 1];

#define SIZE_FBinary_255		255
#define TYPE_FBinary_255		TYP_BINARY
#define DEF_FBinary_255 		_Def_Binary
#define INIT_FBinary_255(a)	bin_strinit(a,SIZE_FBinary_255)
#define FILL_FBinary_255(res, i, a)	bin_strcpy(a, dbgetvalue(res, 0, i))
#define COPY_FBinary_255(a,b)	bin_strcpy((char*)a,(char*)b)
#define CMP_FBinary_255(a,b)	bin_strcmp(a,b)
typedef char TFBinary_255[SIZE_FBinary_255 + sizeof(short) + 1];

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

extern int _GetTypeId(char * typename);
extern int _GetTypeSize(int typeid);
extern int _CheckStrIdentifier(char * strg);
extern int _ValStrCheckType(char * valstr, int size, char * typename,
                                int * kz_value, int * kz_longsize);
extern int _IsKeyType(int typeid);
extern int _IsBinaryType(int typeid);
extern int _IsStringType(int typeid);
extern int _IsTimeType(int typeid);
extern int _IsDateType(int typeid);
extern int _IsDatiType(int typeid);
extern int _IsCharType(int typeid);
extern int _IsLogicalType(int typeid);
extern int _IsIntType(int typeid);
extern int _IsDoubleType(int typeid);
extern char * _GenVarPref(int typeid, char * attrib);
extern char * _GenWhereStr(int typeid);
extern char * _GenParamStr(int typeid, char * strg, int size);
extern char * _GenAttribStr(char * domain, int typeid);
extern char * _GenValueStr(char * domain, int typeid, char * strg,
                           int size, int svzid);
extern char * _GenMakeValueStr(char * domain, int typeid, char * strg,
                               int size, int svzid);
extern char * _GenHTMLAttribStr(char * domain, int typeid);
extern char * _GenHTMLValueStr(char * domain, int typeid, char * strg,
                               int size, int svzid);
extern char * _GenMakeHTMLValueStr(char * domain, int typeid, char * strg,
                                   int size, int svzid);
extern char * _GenDBType(int typeid);

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

typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  char * table;
  char * attrib;
  char * value1;
  char * value2;
} _CMP;

typedef ARRAY _MCMP;

#define _MCMP_New()    (_MCMP *) ARRAY_New()
#define _MCMP_Init(p)    ARRAY_Init((ARRAY*)p)
#define _MCMP_GetPtr(p,i)    ((_CMP*)ARRAY_GetPtr((ARRAY*)p,i))
#define _MCMP_Add(p,ps)    ARRAY_Add((ARRAY*)p,(void *)ps)

extern _CMP * _CMP_New(void);
extern _CMP * _CMP_Init(_CMP * cmp);
extern char * _CMP_Attribs(void);
extern char * _CMP_Data(void * pDBHANDLE, _CMP * cmp);

extern void _AddCmpMultiple(void * pDBHANDLE, _MCMP * mcmp,
                            char * table, char * attrib,
                            char * value1, char * value2);
extern void _MCMP_Free(_MCMP * mcmp);

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

typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  char * grpname;
  char * grpkuerzel;
  int grpid;
} _GRP;

typedef ARRAY _MGRP;

#define _MGRP_New()    (_MGRP *) ARRAY_New()
#define _MGRP_Init(p)    ARRAY_Init((ARRAY*)p)
#define _MGRP_GetPtr(p,i)    ((_GRP*)ARRAY_GetPtr((ARRAY*)p,i))
#define _MGRP_Add(p,ps)    ARRAY_Add((ARRAY*)p,(void *)ps)

extern _GRP * _GRP_New(void);
extern _GRP * _GRP_Init(_GRP * grp);
extern char * _GRP_Attribs(void);
extern char * _GRP_Data(void * pDBHANDLE, _GRP * grp);

extern void _MGRP_Free(_MGRP * mgrp);

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

typedef struct {
  MYDB_Conn *conn;
  char dbname[20];
} DBHANDLE;


#endif
