home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cslio205.zip / INCLUDE / CSBASE.H < prev    next >
C/C++ Source or Header  |  1997-01-21  |  6KB  |  227 lines

  1. /***********************************************************************
  2.  
  3.                       CSDB Library, Free Evaluation Version 2.0.5 
  4.                                        Release: January 22th 1997 
  5.  
  6.        BASE class for many database classes.
  7.  
  8.  
  9.                                            Copyright(c) 1994-1997 
  10.                                                           ComBits 
  11.                                                   The Netherlands 
  12. ***********************************************************************/
  13.  
  14. #ifndef __CSBASE_H
  15. #define __CSBASE_H
  16.  
  17. #include "cstools.h"
  18. #include "cswarnof.h"
  19. #include "csfile.h"
  20.  
  21.  
  22. #define CS_CLID_VRAM        1
  23. #define CS_CLID_BTREE        2
  24. #define CS_CLID_VBASE        3
  25. #define CS_CLID_VBAXE        4
  26. #define CS_CLID_OLAY        5
  27. #define CS_CLID_DLAY        6
  28. #define CS_CLID_OLAYd        CS_CLID_DLAY
  29. #define CS_CLID_TBASE        7
  30. #define CS_CLID_RBASE        8
  31. #define CS_CLID_DAVL        9
  32. #define CS_CLID_RAVL           10
  33. #define CS_CLID_PAGE           11
  34. #define CS_CLID_BTREEb           12
  35. #define CS_CLID_BTREEi           13
  36. #define CS_CLID_BTREEc           14
  37. #define CS_CLID_BTREEl           15
  38. #define CS_CLID_BTREEf           16
  39. #define CS_CLID_BTREEd           17
  40. #define CS_CLID_BTREEa           18
  41. #define CS_CLID_VBASEi           19
  42. #define CS_CLID_VBASEd           20
  43. #define CS_CLID_IBASE           21
  44. #define CS_CLID_BTREEs           22
  45.  
  46.  
  47. int cs_db_type(csCHAR *name,U32 &cs_lib,U32 &fi_ID, S16 &cl_ID);
  48. U32 cs_fi_type(csCHAR *name);
  49. U16 cs_cl_type(csCHAR *name);
  50.  
  51.  
  52. csCHAR *lock_file_name(csCHAR *DBName,csCHAR *LockName);
  53. int    lock_file_exist(csCHAR *DBName);
  54. int    remove_lock_file(csCHAR *DBName);
  55.  
  56. class VBAXE;
  57.  
  58.  
  59.  
  60. ////////////////////////////////////////////////////////////////////////////
  61. ////////////////////////////////////////////////////////////////////////////
  62. ////////////////////////////////////////////////////////////////////////////
  63.  
  64.  
  65.  
  66. class BASE
  67. {
  68.  
  69. friend class VBAXE;
  70.  
  71. protected:
  72.  
  73.    void *head;
  74.    U16     is_open;
  75.    U32     numpage;
  76.    U16     lenpage;
  77.    U16     page_foot;
  78.    csSTR db_name;
  79.    FILE_NAME LockFile;
  80.    FILE *fp;
  81.    int     ReadOnly;
  82.    U16     ErrorNr;
  83.    int     use_locking;
  84.  
  85.    void set_page_size(U16 t);
  86.    void init_vars(void);
  87.    void init_defaults(void);
  88.  
  89.  
  90.  
  91. protected:
  92.  
  93.    void close2(void);
  94.  
  95.  
  96.  
  97.    U16    debug_error(U16 errnr);
  98.    U16    debug_error(U16 errnr,csCHAR *name);
  99.  
  100.    U16    visible_error(U16 errnr);
  101.    U16    visible_error(U16 errnr,csCHAR *name);
  102.  
  103.  
  104.  
  105. public:
  106.  
  107. ///////////////////////// Compatibility ////////////////////////////////////
  108.  
  109.    void name(csCHAR *s)       { db_name=s; }
  110.    int    already_open(void)      { return is_open; }
  111. //   void save(int updated);
  112. // int    set_open(int FT)      { return is_open=(U16)FT; }
  113.  
  114.  
  115. // void zap(void);
  116.  
  117. //////////////// Made public to support the program generator //////////////
  118.  
  119.    S32    sj_updated(void);
  120.    S32    sj_created(void);
  121.  
  122.  
  123.  
  124. ////////////////////////////////////////////////////////////////////////////////
  125. ////////////////////////                ////////////////////////////
  126. ////////////////////////     P U B L I C        ////////////////////////////
  127. ////////////////////////                ////////////////////////////
  128. ////////////////////////////////////////////////////////////////////////////////
  129.  
  130.  
  131.  
  132.  
  133. public:
  134.  
  135.    BASE(void);
  136.  
  137.    virtual
  138.   ~BASE(void);
  139.  
  140.  
  141. ///////////////////////// Error & Messages ///////////////////////////
  142.  
  143.    csCHAR *e_name(void)       { return (csCHAR *)db_name; }
  144.    void    e_name(csCHAR *s)      { db_name=s; }
  145.  
  146.    void error_nr(U16 nr)      { ErrorNr=nr; }
  147.    U16    error_nr(void  )      { U16 RC=ErrorNr; ErrorNr=0; return RC; }
  148.  
  149.  
  150.    U16    display_error(void);
  151.  
  152. ///////////////////////// Read-Only Mode ////////////////////////////////
  153.  
  154.    int    read_only(void)     { return read_only(TRUE); }
  155.    int    read_only(int ToF);
  156.  
  157.    int    is_read_only(void)  { return ReadOnly; }
  158.  
  159.  
  160. ///////////////////////// Open & Close //////////////////////////////////
  161.  
  162.    int    open(csCHAR *name);
  163.    void close(void);
  164.  
  165.    int    save(void) {return TRUE;}
  166.  
  167.  
  168.    int    IsOpen(void)        { return is_open; }
  169.    void IsOpen(int ToF)     { is_open=ToF; }
  170.  
  171.  
  172.  
  173. ///////////////////////// Lock files ////////////////////////////////////
  174.  
  175.    void use_lock_file(int ToF)    { use_locking=ToF; }
  176.    int    use_lock_file(void   )    { return use_locking; }
  177.  
  178.    int    lock_file_exist(csCHAR *DBNAME);
  179.  
  180.    int    if_cr_lofi(csCHAR *DBName,U16 Exist,U16 False);
  181.    int    if_re_lofi(void);
  182.  
  183.    int    create_lock_file(csCHAR *DBName,U16 Exist,U16 False);
  184.  
  185.    int    remove_lock_file(csCHAR *DBName);
  186.    int    remove_lock_file(void);
  187.  
  188.  
  189.  
  190. /////////////////////////Header block ///////////////////////////////////
  191.  
  192.    virtual int read_header(void);
  193.    virtual int write_header(void);
  194.  
  195.    void    TimeStamp(void);
  196.  
  197.  
  198. ///////////////////////// Create /////////////////////////////////////
  199.  
  200.    void define(void);
  201.  
  202.    void page_size(U16 t)      { set_page_size(t); }
  203.    U16    page_size(void)       { return lenpage;   }
  204.    U16    foot_size(void)       { return page_foot; }
  205.    void foot_size(int size)      { page_foot=(U16)size;   }
  206.  
  207. //////////////////////// Number of Pages /////////////////////////////////////
  208.  
  209.    long num_page(void)          { return numpage; }
  210.    void set_num_page(long n)      { numpage=n; }
  211.  
  212.  
  213. ////////////////////////// Miscellaneous ///////////////////////////////////////
  214.    int    fseek(U32 l)          { return ::fseek(fp,l,SEEK_SET); }
  215.    long ftell(void )          { return ::ftell(fp); }
  216.    U16    page_free(void)       { return (U16)(page_size()-foot_size()); }
  217.    void empty(void);
  218.  
  219.    virtual int class_ID(void)=0;
  220.  
  221.  
  222.  
  223. };
  224.  
  225.  
  226. #endif
  227.