#ifndef PLANDB_HBG
#define PLANDB_HBG

#include "dbsys.h"


#define PLANS_TABLENR    1000
typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  PFNCMP _pfnCmpPk;
  PFNCMP _pfnCmpLk;
  TFSurrogat	fszPLANS_Id;
  TFDate	fdaAt;
  TFChar_35	fszTitle;
  TFChar_80	fszContents;
  TFChar_80	fszComment1;
  TFChar_80	fszComment2;
  TFChar_1	fcDone;
} PLANS;


typedef ARRAY MPLANS;

#define MPLANS_New()	(MPLANS *) ARRAY_New()
MPLANS * MPLANS_Init(MPLANS *mplans);
#define MPLANS_Assign(p1,p2)	ARRAY_Assign((ARRAY*)p1,(ARRAY*)p2)
#define MPLANS_Free(p)	ARRAY_Free((ARRAY*)p)
#define MPLANS_Remove(p,i)	ARRAY_Remove((ARRAY*)p,i)
#define MPLANS_Add(p,ps)	ARRAY_Add((ARRAY*)p,(void *)ps)
#define MPLANS_SetDefault(p)	ARRAY_Free((ARRAY*)p)
#define MPLANS_GetPtr(p,i)	((PLANS*)ARRAY_GetPtr((ARRAY*)p,i))
#define MPLANS_GetCount(p)	(((ARRAY*)p)->iCount)
#define MPLANS_SetCmpFunc(p,pfn)	(p)->pfnCmp=(PFNCMP)pfn
#define MPLANS_Sort(p)	ARRAY_Sort((ARRAY*)p)

extern int PLANS_Sizeof(void);
extern PLANS * PLANS_New(void);
extern PLANS * PLANS_Init(PLANS *plans);
#define PLANS_Assign(p1,p2)    (*(PLANS*)p1=*(PLANS*)p2)
#define PLANS_SetDefault(p1)    PLANS_Init((PLANS*)p1)
#define PLANS_SetDB(p1, p2)    (p1)->iDB = p2
extern char * PLANS_Definition(void);
extern int PLANS_BFill(PLANS *plans, DBresult *res, int row, int status, DBHANDLE *pbsc);
extern char * PLANS_Attribs(void);
extern char * PLANS_Data(DBHANDLE *pDBHANDLE, PLANS *plans);
extern int PLANS_IsValid(DBHANDLE *pDBHANDLE, PLANS *plans);
extern char * PLANS_TB_Attribs(int kz_db);
extern int PLANS_SelectPk(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_SelectLk(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_Insert(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_Load(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_Update(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_Delete(PLANS *plans, DBHANDLE *pbsc);
#define PLANS_DeletePk(p1,p2)    PLANS_Delete(p1,p2)
extern int PLANS_DeleteAll(DBHANDLE *pbsc);
extern int PLANS_Do(PLANS *plans, DBHANDLE *pbsc);

extern int PLANS_CopyPk(PLANS *plans1, PLANS *plans2);

extern int PLANS_CmpPk(TFSurrogat pkey, PLANS *plans2);
extern int PLANS_CmpLk(PLANS *plans1, PLANS *plans2);

extern int PLANS_Select(PLANS *plans, DBHANDLE *pbsc);
extern int PLANS_Fetch(PLANS *plans, DBHANDLE *pbsc);

extern int PLANS_Select_Title (PLANS * plans, DBHANDLE * pDBHANDLE);
extern int PLANS_Fetch_Title (PLANS * plans, DBHANDLE * pDBHANDLE);

extern int PLANS_Select_Title_Date (PLANS * plans, DBHANDLE * pDBHANDLE);
extern int PLANS_Fetch_Title_Date (PLANS * plans, DBHANDLE * pDBHANDLE);

extern int PLANS_Select_Title_Date_Acc (PLANS * plans, DBHANDLE * pDBHANDLE);
extern int PLANS_Fetch_Title_Date_Acc (PLANS * plans, DBHANDLE * pDBHANDLE);

extern int PLANS_Count (PLANS * plans, int * iCount, DBHANDLE * pDBHANDLE);


#define PASSWD_TABLENR    2000
typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  PFNCMP _pfnCmpPk;
  PFNCMP _pfnCmpLk;
  TFSurrogat	fszPASSWD_Id;
  TFChar_35	fszPassword;
  TFShort	fsSubnummer;
  TFTimestamp	fdtAt;
} PASSWD;


typedef ARRAY MPASSWD;

#define MPASSWD_New()	(MPASSWD *) ARRAY_New()
MPASSWD * MPASSWD_Init(MPASSWD *mpasswd);
#define MPASSWD_Assign(p1,p2)	ARRAY_Assign((ARRAY*)p1,(ARRAY*)p2)
#define MPASSWD_Free(p)	ARRAY_Free((ARRAY*)p)
#define MPASSWD_Remove(p,i)	ARRAY_Remove((ARRAY*)p,i)
#define MPASSWD_Add(p,ps)	ARRAY_Add((ARRAY*)p,(void *)ps)
#define MPASSWD_SetDefault(p)	ARRAY_Free((ARRAY*)p)
#define MPASSWD_GetPtr(p,i)	((PASSWD*)ARRAY_GetPtr((ARRAY*)p,i))
#define MPASSWD_GetCount(p)	(((ARRAY*)p)->iCount)
#define MPASSWD_SetCmpFunc(p,pfn)	(p)->pfnCmp=(PFNCMP)pfn
#define MPASSWD_Sort(p)	ARRAY_Sort((ARRAY*)p)

extern int PASSWD_Sizeof(void);
extern PASSWD * PASSWD_New(void);
extern PASSWD * PASSWD_Init(PASSWD *passwd);
#define PASSWD_Assign(p1,p2)    (*(PASSWD*)p1=*(PASSWD*)p2)
#define PASSWD_SetDefault(p1)    PASSWD_Init((PASSWD*)p1)
#define PASSWD_SetDB(p1, p2)    (p1)->iDB = p2
extern char * PASSWD_Definition(void);
extern int PASSWD_BFill(PASSWD *passwd, DBresult *res, int row, int status, DBHANDLE *pbsc);
extern char * PASSWD_Attribs(void);
extern char * PASSWD_Data(DBHANDLE *pDBHANDLE, PASSWD *passwd);
extern int PASSWD_IsValid(DBHANDLE *pDBHANDLE, PASSWD *passwd);
extern char * PASSWD_TB_Attribs(int kz_db);
extern int PASSWD_SelectPk(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_SelectLk(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_Insert(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_Load(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_Update(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_Delete(PASSWD *passwd, DBHANDLE *pbsc);
#define PASSWD_DeletePk(p1,p2)    PASSWD_Delete(p1,p2)
extern int PASSWD_DeleteAll(DBHANDLE *pbsc);
extern int PASSWD_Do(PASSWD *passwd, DBHANDLE *pbsc);

extern int PASSWD_CopyPk(PASSWD *passwd1, PASSWD *passwd2);

extern int PASSWD_CmpPk(TFSurrogat pkey, PASSWD *passwd2);
extern int PASSWD_CmpLk(PASSWD *passwd1, PASSWD *passwd2);

extern int PASSWD_Select(PASSWD *passwd, DBHANDLE *pbsc);
extern int PASSWD_Fetch(PASSWD *passwd, DBHANDLE *pbsc);

extern int PASSWD_Select_Subnummer (PASSWD * passwd, DBHANDLE * pDBHANDLE);
extern int PASSWD_Fetch_Name (PASSWD * passwd, DBHANDLE * pDBHANDLE);

extern int PASSWD_Delete_Wrong (PASSWD * passwd, int * iCount, DBHANDLE * pDBHANDLE);

extern int PASSWD_Update_Password (PASSWD * passwd, int * iCount, DBHANDLE * pDBHANDLE);

extern void Get_GRPs (_MGRP * pMGrp);

extern int GRP_Data_Save (DBHANDLE * pDBHANDLE, char * fn, char * kuerzel);

extern int GRP_Data_Load (DBHANDLE * pDBHANDLE, char * fn, char * kuerzel);

extern int GRP_Data_Delete (DBHANDLE * pDBHANDLE, char * kuerzel);

#endif
