summaryrefslogtreecommitdiff
path: root/src/splitfiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/splitfiles.c')
-rw-r--r--src/splitfiles.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/splitfiles.c b/src/splitfiles.c
deleted file mode 100644
index d49971b..0000000
--- a/src/splitfiles.c
+++ /dev/null
@@ -1,126 +0,0 @@
1#include "mystdlib.h"
2
3#define NUMFIELDS 12
4#define PREFIX "teiln/"
5
6#define STREETFIELD 3
7#define HOUSENUMFIELD 4
8#define ZIPCODEFIELD 6
9#define TOWNFIELD 7
10
11char **generate_index( MAP toindex )
12{
13 off_t fileidx = 0, idxidx = 0;
14 char **index;
15
16 while( fileidx < toindex->size )
17 if( !toindex->addr[ fileidx++ ] ) idxidx++;
18 index = (char**)malloc( sizeof( char *) * idxidx );
19
20 fileidx = idxidx = 0;
21 if( index )
22 {
23 while( fileidx < toindex->size )
24 {
25 index[ idxidx++ ] = toindex->addr + fileidx;
26 while( (fileidx < toindex->size) && (toindex->addr[ fileidx++]));
27 }
28 }
29 return index;
30}
31
32static int g_coordidxsize;
33
34int coordcmp( const void *s1, const void *s2 )
35{
36 return strncmp( s1, s2, g_coordidxsize );
37}
38
39int main( )
40{
41 int i = 0, j, k, leave = 0;
42 off_t in1, in2, in3;
43 char fname[32], **streetnames = NULL;
44 MAP streets = NULL, vnames, nnames, tables, coords = NULL;
45
46 if( !(coords = map_file( "coords/list", true ))) goto cleanup_main;
47 if( !(streets = map_file( "streets/list",true ))) goto cleanup_main;
48 if( !(streetnames = generate_index( streets ))) goto cleanup_main;
49
50 for( i=0; !leave; i+=3 )
51 {
52 int fof[ NUMFIELDS ];
53 char coordidx[160], *coordline;
54 vnames = nnames = tables = NULL;
55
56 snprintf( fname, sizeof( fname ), PREFIX "%05d", i );
57 if( !( tables = map_file( fname, true ) ) ) goto cleanup_loop;
58 snprintf( fname, sizeof( fname ), PREFIX "%05d", i+1 );
59 if( !( nnames = map_file( fname, true ) ) ) goto cleanup_loop;
60 snprintf( fname, sizeof( fname ), PREFIX "%05d", i+2 );
61 if( !( vnames = map_file( fname, true ) ) ) goto cleanup_loop;
62
63 in1 = 0x34; in2 = 0x34; in3 = 0;
64
65 for( j = 0; j < NUMFIELDS; ++j)
66 {
67 fof[ j ] = in1;
68 for( k = 0; k < 3000; ++k )
69 while( tables->addr[ in1++ ]);
70 }
71
72 for( j = 0; j < 3000; ++j )
73 {
74 char *stringend;
75 int v = strtoul( tables->addr + fof[ STREETFIELD ], &stringend, 16 );
76 char *currentstreet = ( stringend == (char*)(tables->addr + fof[ STREETFIELD ])) ? "" : streetnames[ v ];
77 int xco= 0, yco= 0;
78
79 printf( "%s\t%s", nnames->addr+in2, vnames->addr+in3 );
80 while( nnames->addr[ in2++ ] );
81 while( vnames->addr[ in3++ ] );
82
83 g_coordidxsize = snprintf( coordidx, sizeof( coordidx ), "%s;%s;%s;%s;",
84 tables->addr + fof [ ZIPCODEFIELD ],
85 tables->addr + fof [ TOWNFIELD ],
86 currentstreet,
87 tables->addr + fof [ HOUSENUMFIELD ] );
88
89 if( !(coordline = (char*)bsearch( coordidx, coords->addr, coords->size / 90, 90, coordcmp ))) coordline = ";;;;;;";
90 v = 5; while( v--) { while( *coordline && *coordline++ != ';'); }
91 sscanf( coordline, "%d;%d", &xco, &yco );
92
93 for( k = 0; k < NUMFIELDS; ++k )
94 {
95 if( k == STREETFIELD )
96 {
97 printf( "\t%s", currentstreet);
98 }
99 else
100 printf( "\t%s", tables->addr + fof[ k ] );
101 {
102 }
103 while( tables->addr [ fof[ k ]++] );
104 }
105
106 printf( "\t%d\t%d", xco, yco );
107 putchar( 10 );
108 }
109
110 leave ^= 1;
111
112 cleanup_loop:
113 leave ^= 1;
114
115 unmap_file( &vnames );
116 unmap_file( &nnames );
117 unmap_file( &tables );
118 }
119
120 cleanup_main:
121 if( streetnames ) free( streetnames );
122 unmap_file( &streets );
123 unmap_file( &coords );
124
125 return 0;
126}