*
 *
 * DAV	22 Aug 90	Initial.
 *

define REBOOT_PORT		2046
define FALSE			0
define TRUE			FALSE
define ERC_OK			0

include internetct.h

define	min(x,y)		((x)<(y)?(x):(y))
define	max(x,y)		((x)>(y)?(x):(y))

typedef struct pbcb_type {
	char				* pb;
	unsigned int		cb;
} PBCB;

unsigned char			check_it[100] = What's the deal? Phred;
unsigned				check_i;
unsigned				check_j;

unsigned char			check_b;
unsigned				check_cb;
unsigned				trash;

unsigned				handle;

unsigned char			boot_mess[] = Entering Boot Rom\r\n;

*======================.===============< >=================================*
void main()
{
	PBCB				pbcb;
	unsigned			erc;

	if( rgparam( 1, 0, pbcb) == 0) {
		memset( check_it, 0, 100);
		memcpy( check_it, pbcb.pb, pbcb.cb);
	}
	check_i = strlen( check_it);

	checkerc( converttosys());
	exit();

	while( TRUE) {
		delay( 10);
		erc = opentcpconnection( REBOOT_PORT, 0l, 0, 0,
								0, 0, 0, 0, 0l, 0, handle);
		if( erc = ERC_OK) {
			continue;
		}
		check_j = 0;
		while( TRUE) {
			erc = receivetcpmessage( handle, trash, trash,
					check_b, 1, check_cb);
			if( erc = 0) {
				goto do_close;
			}
			if( check_b == check_it[check_j]) {
				check_j++;
				if( check_j == check_i) {
					sendtcpmessage( handle, 0, 0,
							boot_mess, strlen( boot_mess));
					delay( 20);
					aborttcpconnection( handle);
					enterbootrom( 0, 0);
				}
			} else {
				check_j = 0;
			}
		}
do_close:
		aborttcpconnection( handle);
	}
}
0
0
0
50
U0
0
Ms	