#ifndef __EXTCDECL_H
#define __EXTCDECL_H

#ifndef __EXTCTYPE_H
#include <extctype.h>
#endif
#if XVT_OS == XVT_OS_SCOUNIX
#include "keye.h"
#else
#include "hlapi_c.h"
#endif
/* @(:) 2.3.01.178 */
#define MAXCKEY                                 5
#define MAXCLEN                                 10
#define MAXENTRYNAME    16
#define MAXTENTRY                               48
/* @(!) 2.3.01.temp */
#define MAXENTRYSIZE    4096
/* @(:) 2.3.01.temp */
#define MAXDISPCOLS                     4
#define CONFFILE                "conf.gen"
#if     XVT_OS == XVT_OS_SCOUNIX
#include "keye.h"
#define HLBLOCK         2
#else
#include "hlapi_c.h"
#define HLBLOCK         1
#define REFKEY          "CAMPOKEY"
#define VERKEY          "ìpÙˆ¬cê<"
#endif


/* @DES Funzioni C esterne. Sorgenti in /disk1/p.uno */

extern "C"  {

  /* @DPUB */
  extern SecDef fdir[2], rdir[2];
  extern int dirfl[2], recfl[2];
  extern short    formflag;
  extern int      SerNo;
  extern word     ModAd;
  extern word                   _int_tab0[4];
  extern char   __ptprf[80];

  // Guy moved these outside extern
  extern isfdptr* openf;
  extern Str80    cprefix;

#ifdef __STDTYPES_CPP
#define extern
#endif

  extern short    isjournal;

#ifdef __STDTYPES_CPP
#undef extern
#endif

  /* @END */

  /* @FPUB */
#if XVT_OS == XVT_OS_SCOUNIX
  Word Hl_Port(Word);
#endif
  short cverdata(char *);
  TrDate cpackdata(char *);
  void ceditdata(TrDate ,char *);
  void cgetdata(TrDate *,char *);
  void cputdata(char *);
  int month(TrDate);
  int year(TrDate);
  int day(TrDate);
  TrDate makedata(int,int,int);
  TrDate addmonth(TrDate,int);
  TrDate addyear(TrDate,int);
  TDitta *CGetDitta(char *);
  short CGetAut(int );
  char *CGetConf(int );
  word getser(void);
  void CVerify(SecDef *,char *);
  void COpen(SecDef *,char *, unsigned, unsigned, unsigned);
  void CCreate(SecDef *,char *,unsigned ,unsigned ,RecNoType);
  void CChsize(SecDef *,char *,unsigned ,unsigned ,RecNoType);
  void CClose(SecDef *);
  void CDelete(SecDef *,char *);
  void CRead(SecDef *, RecType, RecNoType, unsigned );
  void CLockRec(SecDef *, RecNoType, unsigned);
  void CWrite(SecDef *,RecType,RecNoType ,unsigned );
  int excllock(char *, short);
  int exclunlock(char *, short);
  void COpenDir(int, int);
  void CCloseDir(int);
  void COpenFile(int, FileDes *, int, int);
  void CCloseFile(int, FileDes *, int);
  void CGetFile(int,  FileDes *, int, int);
  void CPutFile(int,  FileDes *, int);
  void zerofdes(FileDes *);
  void COpenRecDir(int, int);
  void CCloseRecDir(int);
  void CGetRec(int, RecDes *, int);
  void CPutRec(int, RecDes *, int);
  void zerordes(RecDes *);
  word setrdes(RecDes *);
  char *prefname(void);
  char  *CGetPref(void);
  void  CPutPref(char *);
  char  *CInsPref(char *, int);
  char  *CGetIdxName(char *);
  int findfld(RecDes *,char *);
  void setdec(char *, int);
  unsigned int  CFieldSize(char *, RecDes *);
  unsigned int  CFieldDec(char *, RecDes *);
  int   CFieldType(char *, RecDes *);
  int   CGetField(char *, RecDes *, RecType, void *);
  int   CPutField(char *, RecDes *, void *, RecType);
  int   CGetFieldBuff(char *, RecDes *, RecType,         char *);
  int   CPutFieldBuff(char *, RecDes *, char *, RecType);
  int   CZeroField(char *, RecDes *, RecType);
  void  CZeroRec(RecDes *, RecType);
  int   CBuildKey(RecDes *,int ,RecType,        char *);
  void  CBOpenFile(FilCtrl *,char *,unsigned int, int *);
  void  CBCloseFile(FilCtrl *,int *);
  void  GetHead(FilCtrl *, int, int *);
  int GetAPage(FilCtrl *, Page *,RecNoType ,int *);
  void GetAKey( Page ,int ,int ,char *,RecNoType *);
  void BTrRead(FilCtrl *,char *,char *,RecNoType *,int *);
  RecNoType   cisgeteod(isfdptr, int *);
  int   cisbuild(isfdptr,int ,RecNoType ,int *);
  int   cisextend(isfdptr,int ,RecNoType ,int *);
  long  cisextension(int ,RecNoType ,int *);
  int cisupdflags(isfdptr, int *, short);
  int   cisopen(isfdptr*, int, RecType *, unsigned int ,int *);
  int   cisopentemp(isfdptr*, int, PathSt, RecType *, short, RecNoType, RecNoType, int *);
  RecNoType     cisgeteod(isfdptr, int *);
  int   cisclosetemp(isfdptr*,RecType *, short, int *);
  int   cisclose(isfdptr*,RecType *,int *);
  int   cisallocrec(int ,RecType *,int *);
  int   ciscopyrec(int ,RecType , RecType ,int *);
  int   cisstart(isfdptr,int ,RecType ,unsigned int ,int *);
  int   cisread(isfdptr,RecType ,unsigned int ,int *);
  int   ciswrite(isfdptr,RecType ,int *);
  int   cisdelete(isfdptr,RecType ,int *);
  int   cisrewrite(isfdptr,RecType ,int *);
  int   cisdelcurr(isfdptr,int *);
  int   cisrewcurr(isfdptr,RecType ,int *);
  int   cisreadrec(isfdptr,RecNoType ,RecType ,unsigned int,int *);
  int   cisrewrec(isfdptr,RecNoType ,RecType ,int *);
  int   cisdelrec(isfdptr,RecNoType ,int *);
  RecNoType cisgetrecno(isfdptr, int *);
  int           cislock(isfdptr,int *);
  int           cisunlock(isfdptr,int *);
  int           cisrelease(isfdptr,int *);
  void  IndexOn(void);
  void  IndexOff(void);
  void  StTrans(void);
  void  EndTrans(void);
  void  AbTrans(void);
  int   cupdatefile(int ,unsigned int ,RecDes *,short ,int *);
  int   creorgfile(int ,short ,int *);
  int   creorgindex(int ,short ,int *);
  int   cloadfile(char *,int ,char ,char ,char ,short ,int *);
  int   cdumpfile(char *,int ,int ,char ,char ,char ,short ,int *);
  int init_sort(struct s_prm *);
  void sort(char *);
  char *sort_op(void);
  void sort_stats(void);

  /* @END */
};

#endif // __EXTCDECL_H
