From 43a5ac139b552b23de78434a8ee3df8fc6651b38 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Wed, 29 Apr 2015 12:44:47 +0200 Subject: We have a new format between the former version 1 and 2. So shift version numbers. Add README --- src/export/split_version_3.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/export/split_version_3.c (limited to 'src/export/split_version_3.c') diff --git a/src/export/split_version_3.c b/src/export/split_version_3.c new file mode 100644 index 0000000..2019762 --- /dev/null +++ b/src/export/split_version_3.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include + +int main( int argc, char **args ) { + char table[64], f[1024*1024]; + int outfiles[64], i, base = 0, fixed_columns = 0; + uint32_t *p = (uint32_t*)f; + + if( argc > 1 ) base = atoi( args[1] ); + if( argc > 2 ) fixed_columns = atoi( args[2] ); + + /* No output file yet valid */ + for( i=0; i<64; ++i ) outfiles[i] = -1; + + while( fgets( table, sizeof(table), stdin ) ) { + int file, strnr, columns, count; + + table[strlen(table)-1] = 0; + + { + int f_in = open( table, O_RDONLY ); + if( f_in < 0 || read( f_in, f, sizeof(f)) <= 0 ) { + fprintf( stderr, "Can not read file %s\n", table ); + exit(1); + } + close(f_in); + } + + count = (int)*p, + columns = fixed_columns ? fixed_columns : (int)p[1] / 4 - 1; + + for( file=0; file strings long */ + for( strnr=0; strnr < count; ++strnr ) { while( f[off++] ) {}; f[off-1] = '\n'; } + write( outfiles[file], f + p[file+1], off - p[file+1] ); + } + } + + for( i=0; i<64; ++i ) close( outfiles[i] ); + return 0; +} -- cgit v1.2.3