home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / D4INIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-19  |  3.0 KB  |  98 lines

  1.  
  2.  
  3. /*  d4init.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.  */
  4.  
  5. #include "d4all.h"
  6. #ifndef NOIO
  7. #include "w4.h"
  8. #endif
  9.  
  10. /* External Variable start with 'v4' to reduce potential name conficts */
  11. BASE    *v4base = (BASE *) 0 ;
  12.  
  13. /* Storage for the first reference to the list of open databases */
  14. int      v4last_base  = -1 ;
  15. int      v4cur_base   = -1 ;  /* The currently selected database */
  16. int      v4index_free = -1 ;  /* The next index file to free a block from */
  17. int      v4block_max  = 20 ;
  18. int      v4lock_wait  =  1 ;
  19.  
  20. X4FILTER  *v4filter =  (X4FILTER *) 0 ;
  21. X4RELATE  *v4relate =  (X4RELATE *) 0 ;
  22.  
  23. #ifdef TURBO
  24.    long     v4sort_memory_max =  0x60000L ;  /* 393K */
  25. #else
  26.    /* MSC runtime library does not current support the huge memory model. */
  27.    long     v4sort_memory_max =  0xFFE0L ;
  28. #endif
  29.  
  30. /*
  31.         Some index files must have unique keys.  Any attempt to add duplicate
  32.         keys are ignored.  This can cause these index files to have keys
  33.         for only a portion of the records in the database.  In some cases
  34.         it would be better to generate an error message instead of writing
  35.         a database record which would have no corresponding key in an unique
  36.         key index file.  To generate such an error message (E_UNIQUE), set
  37.         'unique_error' to '(int)1'.  Otherwise, set 'unique_error' to '(int)0'.
  38. */
  39. int      v4unique_error =  0 ;
  40. int      v4first =  1 ;
  41.  
  42. extern int      v4error ;
  43.  
  44. #ifndef SMALL
  45.    char    *v4eval_space = (char *) 0 ;
  46.    int      v4eval_len   = -1 ;
  47.    int      v4decimals   =  2 ;
  48.    INDEX   *v4index = (INDEX *) 0 ;
  49.    BLOCK   *v4block = (BLOCK *) 0 ;
  50. #endif
  51.  
  52. #ifndef NOIO
  53.    extern CB_WINDOW  *v4window ;
  54. #endif
  55.  
  56. int d4init()
  57. {
  58.    return( d4initialize( 10, 10, 12, 3000, 0xFC00L )) ;
  59. }
  60.  
  61. int d4init_memory( int num_base, int num_index, int num_block, int eval_len )
  62. {
  63.    return( d4initialize( num_base, num_index, num_block, eval_len, 0xFC00L )) ;
  64. }
  65.  
  66. int d4initialize( int num_base, int num_index, int num_block,
  67.                   int eval_len, long buf_bytes )
  68. {
  69.    if ( v4first == 0 )  return( -1  ) ;  /* Already Called by d4use */
  70.    v4first = 0 ;
  71.  
  72.    if ( h4create( (char **) &v4base,  num_base, sizeof(BASE),  5)  < 0 )  return -1 ;
  73.  
  74.    v4last_base =  -1 ;
  75.    v4cur_base  =  -1 ;
  76.    v4error   =   0 ;
  77.  
  78.    #ifndef NOIO
  79.       if( w4init( 5,0,0) < 0 )  return -1 ;
  80.    #endif
  81.  
  82.    #ifndef  SMALL
  83.       if ( h4create( (char **) &v4index, num_index, sizeof(INDEX), 5)  < 0 )  return -1 ;
  84.       /* Warning:  Do not make 'block' starting memory allocation less than 12
  85.          or 'i4reindex' will not work on large databases */
  86.       if ( h4create( (char **) &v4block, num_block, sizeof(BLOCK), 5)  < 0 )  return -1 ;
  87.  
  88.       v4eval_space =  h4alloc( eval_len ) ;  /* Space for the Stack */
  89.       if ( v4eval_space == (char *) 0 )  return -1 ;
  90.  
  91.       v4eval_len   =  eval_len ;
  92.  
  93.       d4buf_init( buf_bytes, 0L, 0x10000L ) ;
  94.    #endif
  95.  
  96.    return( 0) ;
  97. }
  98.