home *** CD-ROM | disk | FTP | other *** search
-
-
- /* d4init.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved. */
-
- #include "d4all.h"
- #ifndef NOIO
- #include "w4.h"
- #endif
-
- /* External Variable start with 'v4' to reduce potential name conficts */
- BASE *v4base = (BASE *) 0 ;
-
- /* Storage for the first reference to the list of open databases */
- int v4last_base = -1 ;
- int v4cur_base = -1 ; /* The currently selected database */
- int v4index_free = -1 ; /* The next index file to free a block from */
- int v4block_max = 20 ;
- int v4lock_wait = 1 ;
-
- X4FILTER *v4filter = (X4FILTER *) 0 ;
- X4RELATE *v4relate = (X4RELATE *) 0 ;
-
- #ifdef TURBO
- long v4sort_memory_max = 0x60000L ; /* 393K */
- #else
- /* MSC runtime library does not current support the huge memory model. */
- long v4sort_memory_max = 0xFFE0L ;
- #endif
-
- /*
- Some index files must have unique keys. Any attempt to add duplicate
- keys are ignored. This can cause these index files to have keys
- for only a portion of the records in the database. In some cases
- it would be better to generate an error message instead of writing
- a database record which would have no corresponding key in an unique
- key index file. To generate such an error message (E_UNIQUE), set
- 'unique_error' to '(int)1'. Otherwise, set 'unique_error' to '(int)0'.
- */
- int v4unique_error = 0 ;
- int v4first = 1 ;
-
- extern int v4error ;
-
- #ifndef SMALL
- char *v4eval_space = (char *) 0 ;
- int v4eval_len = -1 ;
- int v4decimals = 2 ;
- INDEX *v4index = (INDEX *) 0 ;
- BLOCK *v4block = (BLOCK *) 0 ;
- #endif
-
- #ifndef NOIO
- extern CB_WINDOW *v4window ;
- #endif
-
- int d4init()
- {
- return( d4initialize( 10, 10, 12, 3000, 0xFC00L )) ;
- }
-
- int d4init_memory( int num_base, int num_index, int num_block, int eval_len )
- {
- return( d4initialize( num_base, num_index, num_block, eval_len, 0xFC00L )) ;
- }
-
- int d4initialize( int num_base, int num_index, int num_block,
- int eval_len, long buf_bytes )
- {
- if ( v4first == 0 ) return( -1 ) ; /* Already Called by d4use */
- v4first = 0 ;
-
- if ( h4create( (char **) &v4base, num_base, sizeof(BASE), 5) < 0 ) return -1 ;
-
- v4last_base = -1 ;
- v4cur_base = -1 ;
- v4error = 0 ;
-
- #ifndef NOIO
- if( w4init( 5,0,0) < 0 ) return -1 ;
- #endif
-
- #ifndef SMALL
- if ( h4create( (char **) &v4index, num_index, sizeof(INDEX), 5) < 0 ) return -1 ;
- /* Warning: Do not make 'block' starting memory allocation less than 12
- or 'i4reindex' will not work on large databases */
- if ( h4create( (char **) &v4block, num_block, sizeof(BLOCK), 5) < 0 ) return -1 ;
-
- v4eval_space = h4alloc( eval_len ) ; /* Space for the Stack */
- if ( v4eval_space == (char *) 0 ) return -1 ;
-
- v4eval_len = eval_len ;
-
- d4buf_init( buf_bytes, 0L, 0x10000L ) ;
- #endif
-
- return( 0) ;
- }
-