diff options
Diffstat (limited to 'dviware/beebe/src/bintnx.c')
-rw-r--r-- | dviware/beebe/src/bintnx.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dviware/beebe/src/bintnx.c b/dviware/beebe/src/bintnx.c new file mode 100644 index 0000000000..169e8f4117 --- /dev/null +++ b/dviware/beebe/src/bintnx.c @@ -0,0 +1,51 @@ +/*********************************************************************** +Convert a TOPS-20 file transferred in FTP "binary" mode to "tenex" mode. +In "binary" mode, we have 2 36-bit words in 9 8-bit bytes. In "tenex" +mode, we want the top 32 bits of each 36-bit group, giving 8 8-bit bytes. + +Who knows what FTP did if the file had an odd number of 36-bit words. + +[08-Oct-87] + +***********************************************************************/ + +#include <stdio.h> + +main() +{ + int c,d; + + for (;;) + { + c = getchar(); + if (c == EOF) + break; + putchar(c); /* 0..7 */ + c = getchar(); putchar(c); /* 8..15 */ + c = getchar(); putchar(c); /* 16..23 */ + c = getchar(); putchar(c); /* 24..31 */ + + d = getchar(); + + c = (d << 4); + d = getchar(); + c |= 0xFF & (d >> 4); + putchar(c); /* 4..11 */ + + c = (d << 4); + d = getchar(); + c |= 0xFF & (d >> 4); + putchar(c); /* 12..19 */ + + c = (d << 4); + d = getchar(); + c |= 0xFF & (d >> 4); + putchar(c); /* 20..27 */ + + c = (d << 4); + d = getchar(); + c |= 0xFF & (d >> 4); + putchar(c); /* 28..36 */ + + } +} |