#include <stdio.h> #include <string.h> int strcmpl(const char * cs, const char * ct) { return(strncmp( cs, ct, strlen(ct) ) ) ; } int tib_flag = 0 ; int dols_mode = 0 ; int dols_flag = 0 ; int filecount = 0 ; char charcount[3] ; char * charcountp = &charcount[0] ; char charval[3] ; char * charvalp = &charval[0] ; /*tib1_trans*/ int mkovpd(char *iptr, char * ostr, char * gstr) { int syll_len ; char charvaloct[6] ; int charvalint ; char charvalhex[3] ; char charvalchr ; /* return first charcter of input string as a string of length one */ /* function value is length of input 'syllable' translated */ *ostr = '\0' ; *gstr = '\0' ; if ( (strcmpl(iptr, "(FAMILY ") == 0) ) { strcat(ostr, charcount) ; strcat(ostr, ":\n") ; return ; } if ( (strcmpl(iptr, "(CHARACTER O ") == 0) ) { strcat(ostr, charcountp) ; iptr = iptr + strlen("(CHARACTER O ") ; strncpy(charvaloct, iptr, 5) ; sscanf(charvaloct, "%o", &charvalint) ; sprintf(charvalhex, "%02x", charvalint) ; strcat(ostr, charvalhex) ; strcat(ostr, "\n") ; strcat(gstr, "O ") ; /**/ strcat(gstr, charvaloct) ; /**/ /* if ( charvalint > 63) strcat(gstr, "\n") ; /**/ return ; } if ( (strcmpl(iptr, "(CHARACTER C ") == 0) ) { strcat(ostr, charcountp) ; iptr = iptr + strlen("(CHARACTER C ") ; charvalchr = *iptr ; charvalint = charvalchr ; sprintf(charvalhex, "%02x", charvalint) ; strcat(ostr, charvalhex) ; strcat(ostr, "\n") ; /* /**/ strcat(gstr, "C ") ; /**/ *(gstr + 1 + strlen(gstr)) = '\0' ; /**/ *(gstr + strlen(gstr)) = charvalchr ; /**/ strcat(gstr, "\n") ; return ; } syll_len = 0 ; return syll_len ; } /*fileproc*/ void fileproc (FILE *ifp, FILE *ofp, FILE *gfp) { char iline [500] ; char oline [500] ; char ostr [500] ; char gline [500] ; char gstr [500] ; char *iptr ; char *optr ; char *gptr ; int i ; iptr = fgets(iline, 500, ifp) ; while (iptr != NULL) { *oline = '\0' ; *gline = '\0' ; optr = oline ; gptr = gline ; mkovpd( iptr , ostr, gstr) ; strcat( optr, ostr) ; strcat( gptr, gstr) ; fputs(oline, ofp) ; fputs(gline, gfp) ; iptr = fgets(iline, 500, ifp) ; } } main ( int argc, char*argv[] ) { FILE *ifp, *ofp, *gfp ; char ifilename[64] ; char * ifilenamep = &ifilename[0] ; char ofilename[64] ; char * ofilenamep = &ofilename[0] ; char gfilename[64] ; char * gfilenamep = &gfilename[0] ; void fileproc(FILE *, FILE *, FILE *) ; if (argc != 2) /* wrong args */ { printf("mkovpd: wrong number of arguments\n") ; exit(1) ; } strcpy(ofilenamep, *(argv + 1) ) ; strcat(ofilenamep, ".ovp-data") ; if ((ofp = fopen(ofilenamep, "w") ) == NULL) { printf("mkovpd can't open %s\n", ofilenamep) ; exit(1) ; } for (filecount = 0; filecount < 256; filecount = filecount + 1) { strcpy(ifilenamep, *(argv + 1) ) ; sprintf(charcountp, "%02x", filecount) ; strcat(ifilenamep, charcountp) ; strcat(ifilenamep, ".pl") ; if ((ifp = fopen(ifilenamep, "r") ) == NULL) { printf("mkovpd can't open %s\n", ifilenamep) ; continue ; } strcpy(gfilenamep, *(argv + 1) ) ; sprintf(charcountp, "%02x", filecount) ; strcat(gfilenamep, charcountp) ; strcat(gfilenamep, ".gil") ; if ((gfp = fopen(gfilenamep, "w") ) == NULL) { printf("mkovpd can't open %s\n", ofilenamep) ; exit(1) ; } fileproc( ifp, ofp, gfp ) ; /**/ fputs("-\n", ofp) ; fclose (ifp); fclose (gfp); } fclose (ofp); exit(0); }