/*----------------------------------------------------------------------*/ /* rtfhenv.c Tagger henvisninger fra registrene til selve teksten i */ /* renbeitekommissionen i taggen . */ /* */ /* */ /* Ver. 1.0 1997-05-12 Øyvind Eide/Dokumentasjonsprosjektet */ /* 1.1 1997-05-21 Kart legges i . */ /* */ /*----------------------------------------------------------------------*/ #include #include void main(argc, argv) int argc; char **argv; { FILE *innfil, *utfil; char tegn, streng[1000], tilbake[1000]; int i, j, teller; printf("Innfil: %s utfil: %s OK?", argv[1], argv[2]); tegn= getchar(); if (tegn == 'J' || tegn == 'j') { innfil= fopen(argv[1], "r"); utfil= fopen(argv[2], "w"); teller= 0; printf("\n\nHenvisning: %5d", teller); tegn= getc(innfil); while (tegn != EOF) { if (tegn == 'I') { i=0; streng[i++]= tegn; tegn= getc(innfil); if (tegn == 'I' || tegn == ' ') /* Tar sjansen på at dette stemmer */ { printf("\b\b\b\b\b%5d", ++teller); streng[i++]= tegn; tegn= getc(innfil); while ((tegn >= 48 && tegn <= 57) || tegn == ' ' || tegn == 'f' || tegn == '.' || tegn == ',' || tegn == '\n') { streng[i++]= tegn; tegn= getc(innfil); } j= 0; while (streng[i-1] == ' ' || streng[i-1] == ',' || streng[i-1] == '.' || streng[i-1] == '\n') tilbake[j++]= streng[--i]; streng[i]= 0; fprintf(utfil, "%s", &streng[0]); for(i=j-1; i>=0; i--) putc(tilbake[i], utfil); } else putc(streng[0], utfil); } /* Topografisk kart over Norge: */ else if (tegn == 'N' || tegn == 'K' || tegn == 'J' || tegn == 'L' || tegn == 'M') { streng[0]= tegn; tegn= getc(innfil); if (tegn >= 48 && tegn <= 57) { i=1; while (tegn >= 48 && tegn <= 57) { streng[i++]= tegn; tegn= getc(innfil); } streng[i]= 0; fprintf(utfil, "%s", &streng[0]); } else putc(streng[0], utfil); } /* Kart over Tromsø Amt i 4 blade: */ else if (tegn == 'A') { streng[0]= tegn; for (i=1; i<4; i++) streng[i]= getc(innfil); streng[4]= 0; tegn= getc(innfil); if (streng[1] == 'k' && (streng[2] == 'N' || streng[2] == 'S') && (streng[3] == 'V' || streng[3] == 'O')) fprintf(utfil, "%s", &streng[0]); else fprintf(utfil, "%s", &streng[0]); } /* Norrlandskarter: */ else if (tegn >= 48 && tegn <= 57) { streng[0]= tegn; tegn= getc(innfil); i=1; while (tegn >= 48 && tegn <= 57) { streng[i++]= tegn; tegn= getc(innfil); } streng[i]= 0; fprintf(utfil, "%s", &streng[0]); } /* Finland: */ else if (tegn == 'f') { streng[0]= tegn; for (i=1; i<5; i++) streng[i]= getc(innfil); streng[5]= 0; if (streng[1] == 'i' && streng[2] == 'n' && streng[3] == 's' && streng[4] == 'k') { for (i=5; i<8; i++) streng[i]= getc(innfil); streng[8]= 0; fprintf(utfil, "%s", &streng[0]); } else fprintf(utfil, "%s", &streng[0]); tegn= getc(innfil); } putc(tegn, utfil); tegn= getc(innfil); } } }