/*--------------------------------------------------------------------------
  CODEBASE.H
  data : 23.01.95
  scopo: interfaccia verso CodeBase 5.0
  --------------------------------------------------------------------------*/
#ifndef __CODEBASE_H
#define __CODEBASE_H

#ifndef __EXTCTYPE_H     
#include <extctype.h>
#endif

/*--------------------------------------------------------------------------
  numero massimo di database aperti contemporaneamente
  --------------------------------------------------------------------------*/
#define CB4FILES 50

/*--------------------------------------------------------------------------
  prototipi funzioni
  --------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
  void DB_init(void);
  void DB_exit(void);
  int  DB_open(const char *filename,int mode);
  int  DB_close(int handle);
  char *DB_getrecord(int handle);
  int  DB_reclen(int handle); 
  int  DB_keylen(int handle);
  long int DB_recno(int handle);
  long int DB_reccount(int handle);
  int  DB_tagselect(int handle,int index_no);
  int DB_tagget(int handle);
  int DB_first(int handle);
  int DB_last(int handle);
  int DB_next(int handle);
  int DB_prev(int handle);
  int DB_skip(int handle,long int recno);
  int DB_lock(int handle);
  int DB_unlock(int handle);
  int DB_seek(int handle,char *key);
  int DB_eof(int handle);
  int DB_bof(int handle);
  int DB_go(int handle,long int recno);
  int DB_delete(int handle);           
  int DB_recall(int handle);
  int DB_delkey(int handle, char* key, long recno); 
  int DB_flush(int handle);
  int DB_rewrite(int handle);
  bool DB_has_memo(int handle);
  int DB_add(int handle);              
  int DB_lockfile(int handle); /* Per sbloccare il record basta la DB_unlock()*/
  int DB_packfile(short vis, const char * filename, long eod);
  int DB_packmemo(short vis, const char * filename);
  int DB_packindex(short vis, const char * filename, RecDes *r, long *peod );
  int DB_build(const char * filename, RecDes *r);  
  int DB_get_error(void);  
  void DB_zero_error(void);     
  int DB_index_seek(int handle, char* from);
  long DB_index_recno(int handle); 
  long DB_index_next(int handle);
  char* DB_index_getkey(int handle);
  char* DB_memoptr(const int handle, const char * fieldname );
  int DB_memowrite(const int handle, const char * fieldname, const char * data )  ;
  int DB_index_eof(int handle);  
  int DB_lock_rec(int handle,long nrec); 
  int DB_file_locked(int handle);
  int DB_rec_locked(int handle,long nrec);  
  long DB_getconf();   
  long DB_changed(int handle); /* returns true if the index of the key is changed */
#ifdef __cplusplus
};
#endif
#endif



