From 046857dfb88f05e6b310fe9ef07b9f2d3ac5922d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 20 Feb 2014 22:42:56 +0100 Subject: Restructure project, make names more clear --- src/decompress.c | 61 -------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/decompress.c (limited to 'src/decompress.c') diff --git a/src/decompress.c b/src/decompress.c deleted file mode 100644 index fef4241..0000000 --- a/src/decompress.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "mystdlib.h" - -#define XORLEN (29) -#define HUGEBLOCK (1024*1024) - -int main(int argc, char **argv) { - MAP in = map_file( argv[1], 1 ); - - unsigned const char xorkey [XORLEN] = "Just for Fun. Linus Torvalds."; - unsigned char input [XORLEN]; - unsigned char output [HUGEBLOCK]; - char respath[32]; /* file_XXXXX\0 */ - int i, zres = 0, filenum = 0, resfile; - size_t offs = 0, reported = 0; - - z_stream z; memset( &z, 0, sizeof(z)); - - while( offs < in->size - XORLEN ) { - for( i=0; iaddr[offs+i] ^ xorkey[i]; - z.next_in = input; z.avail_in = XORLEN; - z.next_out = output; z.avail_out = HUGEBLOCK; - inflateInit( &z ); zres = inflate( &z, Z_NO_FLUSH ); - if( (zres != Z_OK) && (zres != Z_STREAM_END) ) - goto error_continue; - - z.next_in = in->addr + offs + XORLEN; z.avail_in = in->size - offs - XORLEN; - while( zres == Z_OK ) zres = inflate( &z, Z_NO_FLUSH ); - - if( zres != Z_STREAM_END ) { -error_continue: - inflateEnd(&z); memset( &z, 0, sizeof(z)); - offs++; - continue; - } - - sprintf( respath, "file_%05X", filenum++ ); - resfile = open( respath, O_RDWR | O_CREAT, 0644 ); - if( resfile < 0 ) { - fprintf( stderr, "Could not open output file %s\n", respath ); - exit(1); - } - write( resfile, output, z.total_out ); - close( resfile ); - offs += z.total_in; - - if( reported < ( offs * 10 ) / in->size ) { - reported++; - printf( "%zd%% ", 10 * reported ); - fflush( stdout ); - } - - inflateEnd(&z); memset( &z, 0, sizeof(z)); - } - unmap_file(&in); -} -- cgit v1.2.3