From 22f703cab05b7cd368f4de9e03991b7664dc5022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 1 Sep 2014 13:56:46 +0200 Subject: Initial import of argyll version 1.5.1-8 --- tiff/contrib/mac-mpw/mactrans.c | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tiff/contrib/mac-mpw/mactrans.c (limited to 'tiff/contrib/mac-mpw/mactrans.c') diff --git a/tiff/contrib/mac-mpw/mactrans.c b/tiff/contrib/mac-mpw/mactrans.c new file mode 100644 index 0000000..d35373e --- /dev/null +++ b/tiff/contrib/mac-mpw/mactrans.c @@ -0,0 +1,63 @@ +/* + * mactrans.c -- Hack filter used to generate MPW files + * with special characters from pure ASCII, denoted "%nn" + * where nn is hex. (except for "%%", which is literal '%'). + * + * calling sequence: + * + * catenate file | mactrans [-toascii | -fromascii] > output + * + * Written by: Niles Ritter. + */ +#include +#include +#include + +void to_ascii(void); +void from_ascii(void); + +main(int argc, char *argv[]) +{ + if (argc<2 || argv[1][1]=='f') from_ascii(); + else to_ascii(); + exit (0); +} + +void from_ascii(void) +{ + char c; + int d; + while ((c=getchar())!=EOF) + { + if (c!='%' || (c=getchar())=='%') putchar(c); + else + { + ungetc(c,stdin); + scanf("%2x",&d); + *((unsigned char *)&c) = d; + putchar(c); + } + } +} + +void to_ascii(void) +{ + char c; + int d; + while ((c=getchar())!=EOF) + { + if (isascii(c)) putchar (c); + else + { + d = *((unsigned char *)&c); + printf("%%%2x",d); + } + } +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ -- cgit v1.2.3