home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CODE4-1.ZIP / SOURCE.ZIP / D4INIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  2.3 KB  |  78 lines

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