/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Copyright 2008 mibo@student.math.hr */ /* * Opis: program zamjenjuje "hrvatska" slova s * ekvivalentnim LaTeX sekvencama. Radi pod * Debian-om * Compile: gcc -o lahrtex lahrtex-deb.c * Verzija: 1.10.01.2008 */ #include void zamjena(FILE *izlaz, int z1, int z2){ switch(z1 + z2){ case -176: fprintf(izlaz, "\\v{C}"); break; case -175: fprintf(izlaz, "\\v{c}"); break; case -182: fprintf(izlaz, "\\\'{C}"); break; case -181: fprintf(izlaz, "\\\'{c}"); break; case -155: fprintf(izlaz, "\\v{S}"); break; case -154: fprintf(izlaz, "\\v{s}"); break; case -172: fprintf(izlaz, "\\DJ{}"); break; case -171: fprintf(izlaz, "\\dj{}"); break; case -126: fprintf(izlaz, "\\v{Z}"); break; case -125: fprintf(izlaz, "\\v{z}"); break; default: fprintf(izlaz, ""); } } int main(int argc, char* argv[]){ FILE *u, *i; signed char z, sz; if(!(u = fopen(argv[1], "rb"))) return 91; if(!(i = fopen(argv[2], "wb"))) return 92; while(1) { z = fgetc(u); if(z == EOF) break; if(z >= 0) fputc(z, i); else{ sz = fgetc(u); /* ne ocekujem EOF :-| */ zamjena(i, z, sz); } }; fclose(u); fclose(i); printf("\n"); return 0; }