From 64c85dfc1d3b546dd4b5f84168e9256817f3a741 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 20 Feb 2014 02:46:41 +0100 Subject: clean up source directory --- src/extractblocks.c | 69 ----------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 src/extractblocks.c (limited to 'src/extractblocks.c') diff --git a/src/extractblocks.c b/src/extractblocks.c deleted file mode 100644 index 51505ef..0000000 --- a/src/extractblocks.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -#include -#include -#include - -int main( int args, char **argv ) -{ - int toindex; - int i, run = 1, filenum = 0, offset = 0, oldoffset = -1; - struct stat fstatus; - unsigned char *mappedfile; - - if( args != 2 ) - { fputs( "Missing filenames.", stderr ); exit( 1 ); } - - if( ( toindex = open( argv[1], O_RDONLY ) ) < 0 ) - { fprintf( stderr, "Can't open file: %s.\n", argv[1] ); exit( toindex ); } - - fstat( toindex, &fstatus ); - - printf( "Size of file: %d\n", fstatus.st_size ); - - if( ( mappedfile = mmap( NULL, (size_t)fstatus.st_size, PROT_READ | PROT_WRITE, MAP_NOCORE | MAP_PRIVATE, toindex, 0) ) == MAP_FAILED ) - { fprintf( stderr, "Can't mmap file: %s.", argv[1] ); exit( 1 ); } - - while( run ) - { - while( ( offset < fstatus.st_size ) && ( - ( mappedfile[ offset + 0 ] != 0xd9 ) || - ( mappedfile[ offset + 2 ] != 0x6f ) || - ( mappedfile[ offset + 3 ] != 0x6d ) || - ( mappedfile[ offset + 4 ] != 0xaa ) || - ( mappedfile[ offset + 5 ] != 0x11 ) || - ( mappedfile[ offset + 6 ] != 0x6f ) - ) ) offset++; - - printf( "Found an appropriate offset at: %d\n", oldoffset ); - - if( offset == fstatus.st_size ) - run = 0; - - if( oldoffset != -1 ) - { - unsigned long *mf = (unsigned long*)(mappedfile + oldoffset); - unsigned char filename[20], cs = 0; - - for( i=0; i<8; ++i) - mf[i]^=0x014224c2; - - snprintf( filename, sizeof( filename ), "%05d.lha", filenum++ ); - - memcpy( ((unsigned char*)mf) + 22, filename, 5); - - for( i=2; i<29; ++i) - cs += ((unsigned char*)mf)[i]; - ((unsigned char*)mf)[1] = cs; - - i = open( filename, O_CREAT | O_TRUNC | O_WRONLY, 0644 ); - write( i, mf, offset - oldoffset ); - close( i ); - } - oldoffset = offset; - offset++; - } - - return 0; -} -- cgit v1.2.3