summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2014-02-22 05:24:28 +0100
committerDirk Engling <erdgeist@erdgeist.org>2014-02-22 05:24:28 +0100
commita7747982af13037bf3e832203cf542122600ec51 (patch)
tree86c45a5392c48dc435928d74fdb0744b1d45c57c /src
parentd302eb1e2855760e8038b7e1377e06f729e2c900 (diff)
Disable debug output. Do not dump deleted entries. Add comments
Diffstat (limited to 'src')
-rw-r--r--src/export/extract_version_1.c35
1 files changed, 9 insertions, 26 deletions
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 )
35 uint8_t outbuf[8192], * out_dest = outbuf; 35 uint8_t outbuf[8192], * out_dest = outbuf;
36 int num_entries = *(uint16_t*)record; 36 int num_entries = *(uint16_t*)record;
37 37
38 printf( " Found record with %d entries at %04x.\n", num_entries, record_off ); 38 /* printf( " Found record with %d entries at %04x.\n", num_entries, record_off ); */
39 if( record_off > 0x1fff ) { 39 if( record_off > 0x1fff )
40 printf( "NEG!!!" ); 40 return; /* Ignore deleted entries */
41 record_off ^= 0xffff;
42 record_off++;
43 }
44 41
45 if( !flag ) 42 if( !flag )
46 { 43 { /* Flags says whether page has a prefix row */
47 record += 2; 44 record += 2;
48 if( *(uint16_t*)record ) 45 if( *(uint16_t*)record )
49 { 46 {
@@ -52,8 +49,8 @@ void act_on_record( int flag, uint8_t *page, uint16_t record_off )
52 } 49 }
53 } 50 }
54 51
55 /* ignore prefix for now */
56 decode_7bit_string( record + 2, out_dest ); 52 decode_7bit_string( record + 2, out_dest );
53 /* XXX TODO: Split record in 12 chunks each, mark continuation, if num_entries > 1 */
57 puts( (char*)outbuf ); 54 puts( (char*)outbuf );
58} 55}
59 56
@@ -70,8 +67,10 @@ void act_on_page( uint8_t *page, int page_nr )
70 if( blob_len ) 67 if( blob_len )
71 { 68 {
72 uint8_t outbuf[8192]; 69 uint8_t outbuf[8192];
73 printf( "-------- PAGE IS BLOB --------" ); 70 /* printf( "-------- PAGE IS BLOB --------" ); */
71
74 decode_7bit_string( page + 0x6, outbuf ); 72 decode_7bit_string( page + 0x6, outbuf );
73 /* XXX TODO: Split record in 12 chunks each, mark continuation */
75 puts( (char *)outbuf ); 74 puts( (char *)outbuf );
76 } else 75 } else
77 for( record = 0; record < num_records; ++record ) 76 for( record = 0; record < num_records; ++record )
@@ -87,7 +86,7 @@ void act_on_file( uint8_t *file, size_t len )
87 char *zip = ort + 1 + strlen(ort); 86 char *zip = ort + 1 + strlen(ort);
88 char *vorwahl = zip + 1 + strlen(zip); 87 char *vorwahl = zip + 1 + strlen(zip);
89 88
90 printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); 89 /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */
91 90
92 for( page = 0; page < num_pages; ++page ) 91 for( page = 0; page < num_pages; ++page )
93 act_on_page( file + 0x800 + 0x2000 * page, page ); 92 act_on_page( file + 0x800 + 0x2000 * page, page );
@@ -102,19 +101,3 @@ int main( int args, char **argv )
102 unmap_file( &f ); 101 unmap_file( &f );
103 return 0; 102 return 0;
104} 103}
105
106/*
107int main()
108{
109 uint8_t chars[2048], in[1024], out[2048];
110 int i = 0;
111 fgets( chars, sizeof(chars), stdin );
112
113 while( chars[i*2] > 32 && chars[i*2+1] > 32 )
114 {
115 in[i] = ( fromhex( chars[i*2] ) << 4 ) + fromhex( chars[i*2+1] );
116 i++;
117 }
118 decode_7bit_string( in, i, out );
119 printf( "%s\n", out );
120} */