summaryrefslogtreecommitdiff
path: root/src/export/split_version_2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/export/split_version_2.c')
-rw-r--r--src/export/split_version_2.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/export/split_version_2.c b/src/export/split_version_2.c
index ab6c8cf..2019762 100644
--- a/src/export/split_version_2.c
+++ b/src/export/split_version_2.c
@@ -7,19 +7,17 @@
7 7
8int main( int argc, char **args ) { 8int main( int argc, char **args ) {
9 char table[64], f[1024*1024]; 9 char table[64], f[1024*1024];
10 int outfiles[64], i, base = 0; 10 int outfiles[64], i, base = 0, fixed_columns = 0;
11 uint32_t fixed_columns = 0;
12 uint32_t *p = (uint32_t*)f; 11 uint32_t *p = (uint32_t*)f;
13 12
14 if( argc > 1 ) base = atol( args[1] ); 13 if( argc > 1 ) base = atoi( args[1] );
15 if( argc > 2 ) fixed_columns = atol( args[2] ); 14 if( argc > 2 ) fixed_columns = atoi( args[2] );
16 15
17 /* No output file yet valid */ 16 /* No output file yet valid */
18 for( i=0; i<64; ++i ) outfiles[i] = -1; 17 for( i=0; i<64; ++i ) outfiles[i] = -1;
19 18
20 while( fgets( table, sizeof(table), stdin ) ) { 19 while( fgets( table, sizeof(table), stdin ) ) {
21 unsigned int file, strnr; 20 int file, strnr, columns, count;
22 uint32_t count, columns;
23 21
24 table[strlen(table)-1] = 0; 22 table[strlen(table)-1] = 0;
25 23
@@ -32,15 +30,15 @@ int main( int argc, char **args ) {
32 close(f_in); 30 close(f_in);
33 } 31 }
34 32
35 count = p[0], 33 count = (int)*p,
36 columns = fixed_columns ? fixed_columns : p[1] / 4 - 1; 34 columns = fixed_columns ? fixed_columns : (int)p[1] / 4 - 1;
37 35
38 for( file=0; file<columns; ++file ) { 36 for( file=0; file<columns; ++file ) {
39 uint32_t off; 37 uint32_t off;
40 38
41 /* Create outfile, if it is not yet there */ 39 /* Create outfile, if it is not yet there */
42 if( outfiles[file] == -1 ) { 40 if( outfiles[file] == -1 ) {
43 sprintf( table, "%02d_unknown", file+base ); 41 sprintf( table, "%02d_unknown", file + base );
44 outfiles[file] = open( table, O_WRONLY | O_APPEND | O_CREAT, 0644 ); 42 outfiles[file] = open( table, O_WRONLY | O_APPEND | O_CREAT, 0644 );
45 if ( outfiles[file] == -1 ) { 43 if ( outfiles[file] == -1 ) {
46 fprintf( stderr, "Can not create output file %s\n", table ); 44 fprintf( stderr, "Can not create output file %s\n", table );