summaryrefslogtreecommitdiffstats
path: root/lzcheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'lzcheck.c')
-rw-r--r--lzcheck.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/lzcheck.c b/lzcheck.c
index 2f1d5a7..376c60b 100644
--- a/lzcheck.c
+++ b/lzcheck.c
@@ -1,5 +1,5 @@
/* Lzcheck - Test program for the lzlib library
- Copyright (C) 2009-2014 Antonio Diaz Diaz.
+ Copyright (C) 2009-2015 Antonio Diaz Diaz.
This program is free software: you have unlimited permission
to copy, distribute and modify it.
@@ -34,30 +34,14 @@ uint8_t mid_buffer[buffer_size];
uint8_t out_buffer[buffer_size];
-int main( const int argc, const char * const argv[] )
+int lzcheck( FILE * const file, const int dictionary_size )
{
- const int dictionary_size = 1 << 20;
const int match_len_limit = 16;
const unsigned long long member_size = 0x7FFFFFFFFFFFFFFFULL; /* INT64_MAX */
struct LZ_Encoder * encoder;
struct LZ_Decoder * decoder;
- FILE * file;
int retval = 0;
- if( argc < 2 )
- {
- fprintf( stderr, "Usage: lzcheck filename.txt\n" );
- return 1;
- }
-
- file = fopen( argv[1], "rb" );
- if( !file )
- {
- fprintf( stderr, "lzcheck: Can't open file '%s' for reading\n", argv[1] );
- return 1;
- }
-/* fprintf( stderr, "lzcheck: Testing file '%s'\n", argv[1] ); */
-
encoder = LZ_compress_open( dictionary_size, match_len_limit, member_size );
if( !encoder || LZ_compress_errno( encoder ) != LZ_ok )
{
@@ -224,6 +208,32 @@ int main( const int argc, const char * const argv[] )
LZ_decompress_close( decoder );
LZ_compress_close( encoder );
+ return retval;
+ }
+
+
+int main( const int argc, const char * const argv[] )
+ {
+ FILE * file;
+ int retval;
+
+ if( argc < 2 )
+ {
+ fprintf( stderr, "Usage: lzcheck filename.txt\n" );
+ return 1;
+ }
+
+ file = fopen( argv[1], "rb" );
+ if( !file )
+ {
+ fprintf( stderr, "lzcheck: Can't open file '%s' for reading.\n", argv[1] );
+ return 1;
+ }
+/* fprintf( stderr, "lzcheck: Testing file '%s'\n", argv[1] ); */
+
+ retval = lzcheck( file, 65535 );
+ if( retval == 0 )
+ { rewind( file ); retval = lzcheck( file, 1 << 20 ); }
fclose( file );
return retval;
}