#include "trans.h" struct xcript_tab { char *in; char *out; }; struct xcript_tab xcript_tab[] = { { "μπ", "b" }, { "γγ", "g" }, { "γκ", "g" }, { "γχ", "g" }, { "ντ", "d" }, { "αι", "e" }, { "αί", "e" }, { "αυ", "au"}, { "αύ", "au"}, { "ου", "ou"}, { "ού", "ou"}, { "ευ", "eu"}, { "εύ", "eu"}, { "οι", "i" }, { "ει", "i" }, { "εί", "i" }, { "υι", "i" }, { "α", "a" }, { "Α", "a" }, { "Ά", "a" }, { "ά", "a" }, { "β", "b" }, { "Β", "b" }, { "γ", "g" }, { "Γ", "g" }, { "δ", "d" }, { "Δ", "d" }, { "ε", "e" }, { "Ε", "e" }, { "Έ", "e" }, { "έ", "e" }, { "ζ", "z" }, { "Ζ", "z" }, { "η", "i" }, { "Η", "i" }, { "Ή", "i" }, { "ή", "i" }, { "θ", "t" }, { "Θ", "t" }, { "ι", "i" }, { "Ι", "i" }, { "Ί", "i" }, { "ί", "i" }, { "ϊ", "i" }, { "κ", "k" }, { "Κ", "k" }, { "λ", "l" }, { "Λ", "l" }, { "μ", "m" }, { "Μ", "m" }, { "ν", "n" }, { "Ν", "n" }, { "ξ", "x" }, { "Ξ", "x" }, { "ο", "o" }, { "Ο", "o" }, { "Ό", "o" }, { "ό", "o" }, { "π", "p" }, { "Π", "p" }, { "ρ", "r" }, { "Ρ", "r" }, { "σ", "s" }, { "Σ", "s" }, { "ς", "s" }, { "τ", "t" }, { "Τ", "t" }, { "υ", "i" }, { "Υ", "i" }, { "Ύ", "i" }, { "υ", "i" }, { "ύ", "i" }, { "φ", "f" }, { "Φ", "f" }, { "χ", "h" }, { "Χ", "h" }, { "ψ", "P" }, { "Ψ", "P" }, { "ω", "o" }, { "Ω", "o" }, { "Ώ", "o" }, { "ώ", "o" }, { "Ϊ", "i" }, { "ΐ", "i" }, { "Ϋ", "i" }, { "ΰ", "i" }, NULL }; u_char * xcript_lookup(struct xcript_tab tab[], u_char *p, u_char **pp) { struct xcript_tab *tabp; for (tabp = tab; tabp->in; tabp++) { size_t len = strlen(tabp->in); if (strncmp(tabp->in, p, len) == 0) { *pp = p + len; return tabp->out; } } return NULL; } u_char * greek_to_transcription(u_char *input) { u_char *xstr = emalloc(strlen(input)+1); u_char *p; u_char *q; u_char *x; for (p = input, x = xstr; *p; ) { q = xcript_lookup(xcript_tab, p, &p); if (q) { size_t len = strlen(q); memcpy(x, q, len); x += len; } else { fprintf(stderr, "Failed to translate %s\n", p); abort(); /* FIXME */ } } *x = 0; return xstr; }