/*----------------------------------------------------------------------*/ /* rtfhex_sag.c Avviker fra rtfhex.c ved at [ og ] ikke erstattes */ /* */ /* */ /* Ver. 1.0 1997-05-21 Øyvind Eide/Dokumentasjonsprosjektet */ /* */ /*----------------------------------------------------------------------*/ #include #include void main(argc, argv) int argc; char **argv; { FILE *innfil, *utfil; char tegn, tegn2, streng[1000]; int verdi, i, 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\nKode nummer: %5d", teller); tegn= getc(innfil); while (tegn != EOF) { if (tegn == '\\') { tegn2= getc(innfil); if (tegn2 == '\'') { fscanf(innfil, "%2x", &verdi); putc(verdi, utfil); tegn= getc(innfil); } else if (tegn2 == '{') { fprintf(utfil, "&Cstrek;"); tegn= getc(innfil); } else if (tegn2 == '}') { fprintf(utfil, "&cstrek;"); tegn= getc(innfil); } else { streng[0]= tegn; streng[1]= tegn2; tegn= getc(innfil); i=2; while (tegn != ' ' && tegn != '\n' && tegn != EOF) { streng[i++]= tegn; tegn= getc(innfil); } tegn= getc(innfil); streng[i]= 0; if (i > 7) ; else if (i == 2 && streng[1] == 'i') fprintf(utfil, "%s ", &streng[0]); else if (i == 4 && streng[1] == 'p' && streng[2] == 'a' && streng[3] == 'r') fprintf(utfil, ""); else if (i == 5 && streng[1] == 'l' && streng[2] == 'i' && streng[3] == 'n' && streng[4] == 'e') fprintf(utfil, ""); else if (i == 5 && streng[1] == 'p' && streng[2] == 'a' && streng[3] == 'g' && streng[4] == 'e') fprintf(utfil, ""); else if (i == 7 && streng[1] == 'e' && streng[2] == 'm' && streng[3] == 'd' && streng[4] == 'a' && streng[5] == 's' && streng[6] == 'h') fprintf(utfil, "—"); printf("\b\b\b\b\b%5d", ++teller); } } else { putc(tegn, utfil); tegn= getc(innfil); } } } printf("\n\n"); fclose(innfil); fclose(utfil); }