#include #include #include int main(argc,argv) int argc; char **argv; { if(argc < 2) {puts("Usage: tocom source [out]"); exit(1);} FILE *out,*in; in=fopen(argv[1],"r"); if(argc > 2) {out=fopen(argv[2],"w");} else out=stdout; char mod; char b; char c; do {c=fgetc(in); if(c>='0' && c<='9') {c=c-'0'; if(mod==2) c=b*16+c;} else if(c>='A' && c<='F') {c=c-'A'+10; if(mod==2) c=b*16+c;} else if(c>='a' && c<='f') {c=c-'a'+10; if(mod==2) c=b*16+c;} else if(c==';') {do {c=fgetc(in);} while(c!=10 && c!=EOF); continue;} else continue; if(mod==2) {fputc(c,out); mod=1;} else {b=c; mod=2;}} while(c!=EOF); fclose(in); fclose(out); }