home *** CD-ROM | disk | FTP | other *** search
-
- /* (c)Copyright Sequiter Software Inc., 1989. All rights reserved.
-
- This program counts the number of non-blank data bytes in
- a database.
-
- It illustrates how small an EXE file for a Code Base application can be.
-
- This application was compiled with the NOIO and SMALL switches set.
-
- After compiling and linking with the Turbo C 2.0 Tiny memory model,
- the EXE size was 22.5K. Refer to file 'd4small.prj'.
-
- After compiling and linking with the Microsoft C 5.1 compiler, with
- size optimization, the EXE size was 13.5K. Refer to file 'd4sm.bat'.
-
- */
-
- #include "d4base.h"
-
- #ifndef UNIX
- #include <io.h>
- #endif
- #include <stdlib.h>
- #include <string.h>
-
- extern int v4cur_base ;
- extern BASE *v4base ;
-
- char msg[] = "\nd4small database_file_name" ;
- char msg2[] = "\nThe number of blank characters in the database: " ;
-
- main( argc, argv )
- int argc ;
- char *argv[] ;
- {
- long i_rec, count ;
- int rec_width, i ;
- char *ptr, output[40] ;
-
- if ( argc < 2 )
- {
- write( 1, msg, sizeof(msg)-1 ) ;
- exit(1) ;
- }
-
- if ( d4use( argv[1] ) < 0 ) exit(2) ;
-
- ptr = f4record() ;
- rec_width = f4record_width() ;
- count = 0 ;
-
- for ( i_rec = 1; i_rec <= d4reccount(); i_rec++ )
- {
- if ( d4go(i_rec) < 0 ) exit(2) ;
- for ( i=0; i< rec_width; i++ )
- if ( ptr[i] == ' ' ) count++ ;
- }
-
- ltoa( count, output, 10 ) ;
-
- write( 1, msg2, sizeof(msg2)-1 ) ;
- write( 1, output, strlen(output) ) ;
- write( 1, "\n", 1 ) ;
-
- exit(0) ;
- }
-
-
-
- /* Pull 'f4record' and 'f4record_width' out of file 'f4.c' so
- that all of the routines in the file do not get linked in !
- */
-
- void * f4record()
- {
- if ( v4cur_base < 0 ) return ( (void *) 0 ) ;
- return ( (void *) v4base[v4cur_base].buffer ) ;
- }
-
- int f4record_width()
- {
- if ( v4cur_base < 0 ) return ( -1 ) ;
- return ( v4base[v4cur_base].buffer_len ) ;
- }