From f08663d549fee6cf1201b029a86eb37221263ef5 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 19 May 2015 12:28:39 +0200 Subject: Fix variable names to match documentation (and a slightly saner scheme) --- src/export/extract_version_2.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/export/extract_version_2.c b/src/export/extract_version_2.c index ac082ca..fcbd59f 100644 --- a/src/export/extract_version_2.c +++ b/src/export/extract_version_2.c @@ -323,17 +323,17 @@ static int decomp(struct state *s) return 0; } -static void decompress_subchunk( uint8_t * subchunk, size_t subchunk_size, int chunks, size_t outchunk_size ) { - uint8_t output[ outchunk_size ]; +static void decompress_chunk( uint8_t * chunk, size_t chunk_size, int blocks ) { + uint8_t output[ MAXWIN ]; struct state s; /* input/output state */ int err; /* return value */ - memset( output, 0, outchunk_size ); + memset( output, 0, MAXWIN ); /* initialize input state */ - s.in = subchunk; - s.left = subchunk_size; - while( chunks-- ) { + s.in = chunk; + s.left = chunk_size; + while( blocks-- ) { /* (Re-)initialize output state */ s.out = output; s.next = 0; @@ -346,7 +346,7 @@ static void decompress_subchunk( uint8_t * subchunk, size_t subchunk_size, int c return; /* Dump to stdout for now */ - fwrite( output, outchunk_size, 1, stdout ); + fwrite( output, MAXWIN, 1, stdout ); } } @@ -368,8 +368,8 @@ static void decode_19bit_address( uint8_t const *source, uint32_t *dest, size_t int main( int args, char **argv ) { MAP file; uint32_t offsets[256]; - uint16_t num_subchunks, subchunk_rest_count, subchunk_one_count; - uint8_t *fp, *subchunk; + uint16_t chunk_count, restchunks_size, firstchunk_size; + uint8_t *fp, *firstchunk; int i; if( args < 2 ) { @@ -381,19 +381,19 @@ int main( int args, char **argv ) { if( !file ) exit( 1 ); fp = file->addr; - num_subchunks = *(uint16_t*)(fp+0x14); - subchunk_rest_count = *(uint16_t*)(fp+0x1c); - subchunk_one_count = *(uint16_t*)(fp+0x1e); - subchunk = fp + 0x20 + ( 19*num_subchunks +7 )/ 8; + chunk_count = *(uint16_t*)(fp+0x14); + firstchunk = fp + 0x20 + ( 19*chunk_count +7 )/ 8; + firstchunk_size = *(uint16_t*)(fp+0x1e) + 1; + restchunks_size = *(uint16_t*)(fp+0x1c); - decode_19bit_address ( fp + 0x20, offsets, num_subchunks ); - offsets[num_subchunks] = file->size; + decode_19bit_address ( fp + 0x20, offsets, chunk_count ); + offsets[chunk_count] = file->size; - decompress_subchunk( subchunk, offsets[0], subchunk_one_count + 1, MAXWIN ); + decompress_chunk( firstchunk, offsets[0], firstchunk_size ); - for( i=0; i< num_subchunks; ++i ) + for( i=0; i< chunk_count; ++i ) if( offsets[i] + 0x800 < file->size ) - decompress_subchunk( fp + offsets[i] + 0x800, offsets[i+1] - offsets[i], subchunk_rest_count, MAXWIN ); + decompress_chunk( fp + offsets[i] + 0x800, offsets[i+1] - offsets[i], restchunks_size ); return 0; } -- cgit v1.2.3