From b2f288d217786ac2e02e86311496ace68f80eccd Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 16 Jul 2005 02:15:00 +0000 Subject: Jopp --- src/backen.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/backen.c b/src/backen.c index 434f3d5..b93c721 100644 --- a/src/backen.c +++ b/src/backen.c @@ -12,12 +12,10 @@ int mystrcmp2( void *a, void *b ) { int main( int argc, char **argv ) { char path[32]; /* files/file_XXXXX */ int streetnum = 0, geomapnum = 0, geomahnum = 0, d = 0, i, j, k, run = 1; - char *geomaps[1000000]; - char *geomahs[14000000]; + char *geomahs[15000000]; char *streets[400000]; MAP maps[11]; int mapoffs[11]; MAP streetf = map_file( "lists/streetlist", 1); - MAP geomapf = map_file( "lists/geolist", 1); MAP geomahf = map_file( "lists/geohnrlist", 1); unsigned char lookup[1024], **geokord; /* PLZ, Streetname, Hnr */ @@ -25,15 +23,10 @@ int main( int argc, char **argv ) { for( i=0; isize; ++i ) if( streetf->addr[i] == 0 ) streets[streetnum++] = streetf->addr+i+1; - geomaps[geomapnum++] = geomapf->addr; - for( i=0; isize; ++i ) - if( geomapf->addr[i] == 0 ) geomaps[geomapnum++] = geomapf->addr+i+1; - geomahs[geomahnum++] = geomahf->addr; for( i=0; isize; ++i ) if( geomahf->addr[i] == 0 ) geomahs[geomahnum++] = geomahf->addr+i+1; - qsort( geomaps, geomapnum, sizeof(char*), mystrcmp2 ); qsort( geomahs, geomahnum, sizeof(char*), mystrcmp2 ); i = 0; @@ -42,10 +35,15 @@ int main( int argc, char **argv ) { sprintf( path, "files/file_%05X", i++); maps[j] = map_file( path, 1 ); mapoffs[j] = 0; } + + if( !maps[0] ) goto out; + for(j=0;jsize;++j) { + char ch; + for( k=0; k<11; ++k) { unsigned char *end; - int sid; + int sid,x ; switch(k) { case 0: printf( "%02X\t", maps[k]->addr[mapoffs[k]++]); @@ -53,6 +51,9 @@ int main( int argc, char **argv ) { case 5: sid = strtol( maps[k]->addr+mapoffs[k], &end, 10); if( end > maps[k]->addr+mapoffs[k] ) { + // no hnr, end+1 points to "" afterwards + if( !*end ) end--; + printf( "%s\t%s\t", streets[sid], end+1 ); end = lookup + 6 + sprintf( lookup+6, "%s\t%s", streets[sid], end + 1 ); while( isalpha( (int)end[-1] )) *--end = 0; @@ -66,26 +67,31 @@ int main( int argc, char **argv ) { if( !maps[k]->addr[mapoffs[k]] ) printf( "\t\t" ); else if( !strchr(maps[k]->addr+mapoffs[k], 9)) - printf("%s\t\t", maps[k]->addr+mapoffs[k] ); + printf( "%s\t\t", maps[k]->addr+mapoffs[k] ); else - printf("%s\t", maps[k]->addr+mapoffs[k] ); + printf( "%s\t", maps[k]->addr+mapoffs[k] ); while( maps[k]->addr[mapoffs[k]++]); break; case 7: - memcpy( lookup, ".....\t", 6 ); - snprintf( lookup, 5, "%s", maps[k]->addr+mapoffs[k] ); - lookup[5] = '\t'; + for( x=0; (x<5) && (maps[k]->addr+mapoffs[k])[x]; ++x ) + lookup[x] = (maps[k]->addr+mapoffs[k])[x]; + for( ; x<5; ++x ) + lookup[x] = '.'; + lookup[x] = '\t'; default: - printf( "%s\t", maps[k]->addr+mapoffs[k] ); - while( maps[k]->addr[mapoffs[k]++]); + while( maps[k]->addr[mapoffs[k]] == '\t' ) mapoffs[k]++; + while( (ch = maps[k]->addr[mapoffs[k]++] )) + if( ch < 32 ) + putchar( 32 ); + else + putchar( ch ); + putchar( '\t' ); break; } } /* postprocessing */ -// printf( "\nLOOKUP: %s\n", lookup ); if( (geokord = (char**)bsearch( lookup, geomahs, geomahnum, sizeof(char *), mystrcmp ) ) ) { -// printf( "\nGEOKOORD: %s\n", *geokord ); printf( "%s", *geokord+strlen(lookup)+1 ); } else { putchar('\t'); putchar('\t'); @@ -94,8 +100,9 @@ int main( int argc, char **argv ) { } for(j=0; j<11; ++j) unmap_file( &maps[j] ); } + +out: unmap_file( &streetf ); - unmap_file( &geomapf ); unmap_file( &geomahf ); return 0; } -- cgit v1.2.3