Moin Marcus,
you codeed some thing like this in a few places:
char afmfn[256];
strcpy(afmfn,afmdir);
directories and filenames may be longer than 256 charaters. If you use such a value you should at least use strncpy or use FILENAME_MAX from stdio.h (if that's the right one).
Ciao Jörg