home *** CD-ROM | disk | FTP | other *** search
-
- /* t4open
-
- (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- Tests Code Base by repeatedly opening and closing files.
- */
-
- #include "p4misc.h"
- #include "d4all.h"
- #include "w4.h"
- #include "u4error.h"
-
- #include <string.h>
- #include <stdlib.h>
-
- static void er(void) ;
-
- static void er()
- {
- u4error( 0, "t4open: Error", (char *) 0 ) ;
- w4exit(0) ;
- }
-
- static FIELD testfields[] =
- {
- /* Name , Type, Width, Dec, Offset */
- {"N1 ", 'F', 5, 2, 0 },
- {"N2 ", 'N', 10, 0, 0 },
- {"C1 ", 'C', 10, 0, 0 },
- {"C2 ", 'C', 10, 0, 0 },
- {"C3 ", 'C', 10, 0, 0 },
- {"C4 ", 'C', 15, 0, 0 },
- {"C5 ", 'C', 15, 0, 0 },
- {"D1 ", 'D', 8, 0, 0 },
- {"D2 ", 'D', 8, 0, 0 },
- {"L1 ", 'L', 1, 0, 0 },
- {"L2 ", 'L', 1, 0, 0 }
- };
-
-
- main( int argc, char **argv )
- {
- long num_times, i_time ;
- int c;
-
- if ( argc < 2 )
- num_times = 20L ;
- else
- {
- num_times = atol( argv[1] ) ;
- if ( num_times <= 0L ) num_times = 20L ;
- }
-
- #ifdef NO_HUGE
- #ifdef IS_386
- d4init() ;
- #else
- d4initialize( 4, 4, 20, 1000, 20000L ) ;
- #endif
- #else
- d4init() ;
- #endif
- w4clear(-1) ;
-
- if ( d4create("t4open", 11,testfields,0) < 0 ) er() ;
- if ( i4index( "t4open1", "N1", 0, 0 ) < 0 ) er() ;
- if ( i4index( "t4open2", "C1", 0, 0 ) < 0 ) er() ;
- if ( d4create("t4open2", 11,testfields,0) < 0 ) er() ;
- if ( i4index( "t4open3", "C5", 0, 0 ) < 0 ) er() ;
- if ( i4index( "t4open4", "D2", 0, 0 ) < 0 ) er() ;
- d4close_all();
-
- w4( 0,0, "Num Open/Close:" ) ;
- w4long( w4row(),w4col(), num_times, 6 ) ;
- c = w4col() ;
-
- for ( i_time = 1L; i_time <= num_times; i_time++ )
- {
- w4long( w4row(),c, i_time, 6 ) ;
-
- if ( d4use( "t4open" ) < 0 ) er() ;
- if ( i4open( "t4open1" ) < 0 ) er() ;
- if ( i4open( "t4open2" ) < 0 ) er() ;
- if ( d4use( "t4open2" ) < 0 ) er() ;
- if ( i4open( "t4open3" ) < 0 ) er() ;
- if ( i4open( "t4open4" ) < 0 ) er() ;
-
- if ( d4close_all() < 0 ) er() ;
- }
-
-
- #ifdef H4TEST
- {
- int rc ;
- d4init_undo() ;
- rc = h4free_check(32000) ;
- d4init() ;
- if ( rc != 0 )
- {
- u4error( 0, "t4open: Memory items not freed", (char *) 0 );
- w4exit(1) ;
- }
- }
- #endif
-
- w4handle(1) ;
- w4( w4row()+1,0, "t4open: SUCCESS" ) ;
- w4exit(0) ;
- }
-
-