anon ftp to Simtel

Ken Yap ken at cs.rochester.edu
Fri Sep 15 15:39:51 AEST 1989


If you have used binary mode instead of tenex mode to a TOPS20 machine,
don't despair. Here is bintnx.c to fix those files. It is short enough
to post here. I didn't write it. I found it somewhere on Simtel.

/***********************************************************************
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 */

    }
}



More information about the Comp.unix.questions mailing list