Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utcs!utfyzx!oscvax!rico
From: rico@oscvax.UUCP
Newsgroups: comp.sys.amiga
Subject: Re: HAM Ray Traced Juggler (THE FIX) (Manx Version)
Message-ID: <468@oscvax.UUCP>
Date: Mon, 29-Dec-86 15:41:01 EST
Article-I.D.: oscvax.468
Posted: Mon Dec 29 15:41:01 1986
Date-Received: Tue, 30-Dec-86 00:37:56 EST
References: <16708@ucbvax.BERKELEY.EDU> <133@mentat.UUCP> <1986Dec28.124744.5871@utcs.uucp>
Reply-To: rico@oscvax.UUCP (Rico Mariani)
Distribution: na
Organization: Ontario Science Centre, Toronto
Lines: 108
Summary: 


Well... remember that bug in the for loop that I told you about a few
weeks ago... well the fixer program gets bitten by it... took me a while
to figure it all out but here is a working version for Manx users, the
only essential change is that the for loop be turned into a equivalent
'while' so that the test stays at the top of the code.

use:

	cc +L fix.c
	ln fix.o -lc32

to generate the executable

------

/* this program tries to fix the problem with the recent juggler posting */
/* it tries to fix the binary rather than forcing you to uudecode and    */
/* retransmit again.  Movie.data is a big file */

#include "stdio.h"

static long corrections[] = {
	162779, 0237, 0227,
	162780, 0374, 0372,
	162781, 00,   0377,
	162782, 0117, 0377,
	162783, 0374, 030,
	162784, 0141, 0120,
	162785, 0100, 01,
	162786, 04,   040,
	162787, 0200, 040,
	162788, 0201, 0120,
	162789, 0100, 01,
	162790, 05,   0140,
	162791, 0201, 0160,
	162792, 0301, 0160,
	162793, 0300, 01,
	162794, 05,   0140,
	162795, 0201, 0160,
	162796, 0301, 0160,
	162797, 0300, 00,
	162798, 01,   0140,
	162799, 0201, 0100,
	162800, 00,   060,
	162801, 0300, 01,
	162802, 05,   0140,
	162803, 0201, 0160,
	162804, 0301, 0160,
	162805, 0303, 0377,
	162809, 0374, 030,
	162810, 0140, 050
};

main()
{
	FILE *in,*out;
	int inchar;
	int current = 0;
	long counter;

	in = fopen("movie.bad.data","r");
	if (!in) {
		printf("can't open input");
		exit(1);
	}

	out = fopen("ram:movie.good.data","w");

	if (!out) {
		printf("can't open output");
		exit(2);
	}

	counter = 1;
	while ((inchar = getc(in)) != EOF) {
		if (counter == corrections[current]) {
			if (inchar == corrections[current+1]) {
				printf("applying fix at position %d %d-->%d\n",
				counter,
				corrections[current+1],
				corrections[current+2]
				    );
				inchar = corrections[current+2];
				current += 3;
			}
			else {
				printf("byte mismatch-position %d expecting %d-->%d got %d\n",
				counter,
				corrections[current+1],
				corrections[current+2],
				inchar
				    );

				inchar = corrections[current+2];
				current += 3;
			}
		}

		if (EOF == putc(inchar, out)) {
			printf("output problems");
			break;
		}
		counter++;
	}
	fclose(in);
	fclose(out);
}