From 08a9f406a0e18e0902bdf4f50b4f5ecad9fe2588 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 10 May 2015 21:45:16 +0200 Subject: Split entries into different column files. Done for non-continuation-entries --- src/export/split_version_2.c | 185 +++++++++++++++++++++++-------------------- 1 file changed, 99 insertions(+), 86 deletions(-) diff --git a/src/export/split_version_2.c b/src/export/split_version_2.c index 2b7a79f..7a6f04e 100644 --- a/src/export/split_version_2.c +++ b/src/export/split_version_2.c @@ -1,10 +1,20 @@ #include #include #include +#include +#include #include "mystdlib.h" -static int g_first_field_length; +enum { g_outfiles = 17 }; + +static struct { + int outfiles[g_outfiles]; + uint8_t *outbuf [g_outfiles]; + size_t outfill [g_outfiles]; +} g_state; + +static int g_northern_version;; static uint8_t cp437_to_iso8859_1_table[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, @@ -23,14 +33,24 @@ static uint8_t cp437_to_iso8859_1_table[] = { 0x2e, 0xdf, 0x2e, 0x2e, 0x2e, 0x2e, 0xb5, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0xb1, 0x2e, 0x2e, 0x2e, 0x2e, 0xf7, 0x2e, 0xb0, 0x2e, 0xb7, 0x2e, 0x2e, 0xb2, 0x2e, 0xa0 }; -static void dump_field( uint8_t **end) { - uint8_t *e = *end; - uint8_t len = *--e; - *end = e - len; - printf( "_%02d_ ", len ); + +static void dump_string( uint8_t *start, size_t len, int file ) { + uint8_t *dest = g_state.outbuf[file] + g_state.outfill[file]; + g_state.outfill[file] += len; while( len-- ) - putchar( cp437_to_iso8859_1_table[ e[-len-1] ] ); - putchar( 9 ); + *(dest++) = cp437_to_iso8859_1_table[ *(start++) ]; +} + +static void dump_field( uint8_t **end, int file ) { + uint8_t len = (*end)[-1]; + *end -= len + 1; + dump_string( *end, len, file); +} + +static void finish_record( ) { + int i; + for( i=0; i \n", argv[0] ); exit(1); } + + for( i=0; iaddr[0x21e]; + g_northern_version = data->addr[0x21e] != 5; + + /* Each entry in outfile[0] is flag + \n, i.e. 3 bytes + We want to flush at ever percent progress */ + limit = 3 * ( ( index->size / 4 ) / 100 ); for( indoff = (uint32_t*)(index->addr + 8); indoff < (uint32_t*)(index->addr + index->size) && *indoff; indoff++ ) { // printf( "\nActing on record at off: %08X\n", *indoff ); -// if( indoff[0] >> 14 < indoff[1] >> 14 ) act_on_record( data->addr + *indoff, *indoff & 0x1fff ); + + /* Write out results */ + if( g_state.outfill[0] > limit ) + for( i=0; i 1024*1024*6 ) printf( "Large: %zd\n", g_state.outfill[i] ); + write( g_state.outfiles[i], g_state.outbuf[i], g_state.outfill[i] ); + g_state.outfill[i] = 0; + } } + + for( i=0; i