From a7747982af13037bf3e832203cf542122600ec51 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 22 Feb 2014 05:24:28 +0100 Subject: Disable debug output. Do not dump deleted entries. Add comments --- src/export/extract_version_1.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/export/extract_version_1.c b/src/export/extract_version_1.c index be6aa1b..8daec76 100644 --- a/src/export/extract_version_1.c +++ b/src/export/extract_version_1.c @@ -35,15 +35,12 @@ void act_on_record( int flag, uint8_t *page, uint16_t record_off ) uint8_t outbuf[8192], * out_dest = outbuf; int num_entries = *(uint16_t*)record; - printf( " Found record with %d entries at %04x.\n", num_entries, record_off ); - if( record_off > 0x1fff ) { - printf( "NEG!!!" ); - record_off ^= 0xffff; - record_off++; - } + /* printf( " Found record with %d entries at %04x.\n", num_entries, record_off ); */ + if( record_off > 0x1fff ) + return; /* Ignore deleted entries */ if( !flag ) - { + { /* Flags says whether page has a prefix row */ record += 2; if( *(uint16_t*)record ) { @@ -52,8 +49,8 @@ void act_on_record( int flag, uint8_t *page, uint16_t record_off ) } } - /* ignore prefix for now */ decode_7bit_string( record + 2, out_dest ); + /* XXX TODO: Split record in 12 chunks each, mark continuation, if num_entries > 1 */ puts( (char*)outbuf ); } @@ -70,8 +67,10 @@ void act_on_page( uint8_t *page, int page_nr ) if( blob_len ) { uint8_t outbuf[8192]; - printf( "-------- PAGE IS BLOB --------" ); + /* printf( "-------- PAGE IS BLOB --------" ); */ + decode_7bit_string( page + 0x6, outbuf ); + /* XXX TODO: Split record in 12 chunks each, mark continuation */ puts( (char *)outbuf ); } else for( record = 0; record < num_records; ++record ) @@ -87,7 +86,7 @@ void act_on_file( uint8_t *file, size_t len ) char *zip = ort + 1 + strlen(ort); char *vorwahl = zip + 1 + strlen(zip); - printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); + /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */ for( page = 0; page < num_pages; ++page ) act_on_page( file + 0x800 + 0x2000 * page, page ); @@ -102,19 +101,3 @@ int main( int args, char **argv ) unmap_file( &f ); return 0; } - -/* -int main() -{ - uint8_t chars[2048], in[1024], out[2048]; - int i = 0; - fgets( chars, sizeof(chars), stdin ); - - while( chars[i*2] > 32 && chars[i*2+1] > 32 ) - { - in[i] = ( fromhex( chars[i*2] ) << 4 ) + fromhex( chars[i*2+1] ); - i++; - } - decode_7bit_string( in, i, out ); - printf( "%s\n", out ); -} */ -- cgit v1.2.3