61 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdio.h>
 | |
| #include <conio.h>
 | |
| #include "arclib.h"
 | |
| #include "copyengn.h"
 | |
| #include "filestor.h"
 | |
| #include "memstore.h"
 | |
| 
 | |
| main( int argc, char *argv[] )
 | |
| {
 | |
|     printf( "This program compresses an input file of\n"
 | |
|             "your choosing into a huge buffer.  It then\n"
 | |
|             "gets a pointer into the buffer and uses that\n"
 | |
|             "to see if things worked as they should have.\n"
 | |
|             "\n"
 | |
|             "Usage:  ex19con [file_name]\n"
 | |
|             "\n"
 | |
|             "Hit ESC to exit, any other key to continue..." );
 | |
|     if ( getch() == 0x1b )
 | |
|         return 1;
 | |
|     printf( "\n" );
 | |
| 
 | |
|     {
 | |
|         hALStorage f;
 | |
|         hALStorage h;
 | |
|         hALCompressor c;
 | |
|         int ch;
 | |
| #if defined( AL_FLAT_MODEL )
 | |
|         char *p;
 | |
| 
 | |
|         h = newALMemory( "My big buffer", 0, -1 );
 | |
| #else
 | |
|         char _huge *p;
 | |
|         h = newALHugeMemory( "My big buffer", 0, -1 );
 | |
| #endif
 | |
|         c = newALCopyCompressor();
 | |
|         if ( argc > 1 ) {
 | |
|             f = newALFile( argv[ 1 ] );
 | |
|             printf( "Compressing %s\n", argv[ 1 ] );
 | |
|         } else {
 | |
|             f = newALFile( "ex19con.exe" );
 | |
|             printf( "Compressing ex19con.exe\n" );
 | |
|         }
 | |
|         printf( "Compress returned %d\n",
 | |
|                 ALCompress( c, f, h ) );
 | |
| #if defined( AL_FLAT_MODEL )
 | |
|         p = ALMemoryGetBuffer( h );
 | |
| #else
 | |
|         p = ALHugeMemoryGetBuffer( h );
 | |
| #endif
 | |
|         ALStorageOpen( f );
 | |
|         while ( ( ch = ALStorageReadChar( f ) ) >= 0 )
 | |
|             if ( ch != ( *p++ & 0xff ) )  {
 | |
|                 printf( "Mismatch!\n" );
 | |
|                 return 0;
 | |
|             }
 | |
|         printf( "Comparison passed!\n" );
 | |
|     }
 | |
|     return 1;
 | |
| }
 | |
| 
 |