#ifndef PHONEDB_HBG
#define PHONEDB_HBG

#include "dbsys.h"


#define TELNR_TABLENR    1000
typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  PFNCMP _pfnCmpPk;
  PFNCMP _pfnCmpLk;
  TFSurrogat	fszTELNR_Id;
  TFChar_35	fszName;
  TFChar_25	fszPrivate;
  TFChar_25	fszOffice;
  TFChar_25	fszHandy;
  TFChar_80	fszEmail;
  TFChar_80	fszComment;
} TELNR;


typedef ARRAY MTELNR;

#define MTELNR_New()	(MTELNR *) ARRAY_New()
MTELNR * MTELNR_Init(MTELNR *mtelnr);
#define MTELNR_Assign(p1,p2)	ARRAY_Assign((ARRAY*)p1,(ARRAY*)p2)
#define MTELNR_Free(p)	ARRAY_Free((ARRAY*)p)
#define MTELNR_Remove(p,i)	ARRAY_Remove((ARRAY*)p,i)
#define MTELNR_Add(p,ps)	ARRAY_Add((ARRAY*)p,(void *)ps)
#define MTELNR_SetDefault(p)	ARRAY_Free((ARRAY*)p)
#define MTELNR_GetPtr(p,i)	((TELNR*)ARRAY_GetPtr((ARRAY*)p,i))
#define MTELNR_GetCount(p)	(((ARRAY*)p)->iCount)
#define MTELNR_SetCmpFunc(p,pfn)	(p)->pfnCmp=(PFNCMP)pfn
#define MTELNR_Sort(p)	ARRAY_Sort((ARRAY*)p)

extern int TELNR_Sizeof(void);
extern TELNR * TELNR_New(void);
extern TELNR * TELNR_Init(TELNR *telnr);
#define TELNR_Assign(p1,p2)    (*(TELNR*)p1=*(TELNR*)p2)
#define TELNR_SetDefault(p1)    TELNR_Init((TELNR*)p1)
#define TELNR_SetDB(p1, p2)    (p1)->iDB = p2
extern char * TELNR_Definition(void);
extern int TELNR_BFill(TELNR *telnr, DBresult *res, int row, int status, DBHANDLE *pbsc);
extern char * TELNR_Attribs(void);
extern char * TELNR_Data(DBHANDLE *pDBHANDLE, TELNR *telnr);
extern int TELNR_IsValid(DBHANDLE *pDBHANDLE, TELNR *telnr);
extern char * TELNR_TB_Attribs(int kz_db);
extern int TELNR_SelectPk(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_SelectLk(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_Insert(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_Load(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_Update(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_Delete(TELNR *telnr, DBHANDLE *pbsc);
#define TELNR_DeletePk(p1,p2)    TELNR_Delete(p1,p2)
extern int TELNR_DeleteAll(DBHANDLE *pbsc);
extern int TELNR_Do(TELNR *telnr, DBHANDLE *pbsc);

extern int TELNR_CopyPk(TELNR *telnr1, TELNR *telnr2);

extern int TELNR_CmpPk(TFSurrogat pkey, TELNR *telnr2);
extern int TELNR_CmpLk(TELNR *telnr1, TELNR *telnr2);

extern int TELNR_Select(TELNR *telnr, DBHANDLE *pbsc);
extern int TELNR_Fetch(TELNR *telnr, DBHANDLE *pbsc);

extern int TELNR_Select_Name (TELNR * telnr, DBHANDLE * pDBHANDLE);
extern int TELNR_Fetch_Name (TELNR * telnr, DBHANDLE * pDBHANDLE);

extern int TELNR_Count (TELNR * telnr, 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
