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/extractstreets.c | 66 ---------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/extractstreets.c (limited to 'src/extractstreets.c') diff --git a/src/extractstreets.c b/src/extractstreets.c deleted file mode 100644 index 097a736..0000000 --- a/src/extractstreets.c +++ /dev/null @@ -1,66 +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 ] != 0x22 ) || - ( mappedfile[ offset + 2 ] != 0x2d ) || - ( mappedfile[ offset + 3 ] != 0x6c ) || - ( mappedfile[ offset + 4 ] != 0x68 ) || - ( ( mappedfile[ offset + 5 ] != 0x35 ) && ( mappedfile[ offset + 5 ] != 0x30 )) || - ( mappedfile[ offset + 6 ] != 0x2d ) - ) ) 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; - - snprintf( filename, sizeof( filename ), "%012d.lha", filenum++ ); - - memcpy( ((unsigned char*)mf) + 22, filename, 12); - - for( i=2; i<36; ++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