www.pudn.com > pccp047.zip > COMSCRPT.C


/*	Copyright (C) 1992 Peter Edward Cann, all rights reserved. 
 *	MicroSoft QuickC: >qcl term.c graphics.lib 
 */ 
 
#include 
#include 
#include 
#include 
#include 
#include 
#include"port.h" 
 
#define PROGSIZ 512 
 
struct line 
	{ 
	char type; 
	union 
		{ 
		unsigned char byte; 
		int number; 
		struct 
			{ 
			int retries; 
			unsigned char label; 
			unsigned char reg; 
			} 
			retry; 
		struct 
			{ 
			unsigned char label; 
			unsigned char string[81]; 
			unsigned char ntokens; 
			} 
			l_and_s; 
		unsigned char string[81]; 
		} 
		stuff; 
	} 
	program[PROGSIZ]; 
 
#define MAXNSCANS 32 
 
struct 
	{ 
	unsigned char index; 
	unsigned char *str; 
	unsigned char hitlabel; 
	} 
	scans[MAXNSCANS]; 
 
int nscans; 
 
#define MAXKEYS 64 
 
struct 
	{ 
	unsigned char key; 
	unsigned char label; 
	} 
	keys[MAXKEYS]; 
 
short int labels[256]; /* Not a #define cause we use unsigned char all over */ 
 
unsigned short int rregs[256]; /* Same deal */ 
 
quit() 
	{ 
	cleanup(0); 
	exit(99); 
	} 
 
int demonflag; 
 
sendchar(c) 
	unsigned char c; 
	{ 
	while(!((inp(basereg+STATREG)&TXMTMASK)&&(inp(basereg+MSTATREG)&CTSMASK))) 
		{ 
		if(kbhit()) 
			if(getch()==24) 
				demonflag=1; 
		} 
	outp(basereg, c); 
	return(0); 
	} 
 
int follow; 
 
sleep() 
	{ 
	long tod, tod1, day; 
	day=0; 
	_bios_timeofday(_TIME_GETCLOCK, &tod); 
	while(1) 
		{ 
		if(_bios_timeofday(_TIME_GETCLOCK, &tod1)) 
			day=20*60*60*24; 
		if((tod1+day-tod)>8) 
			break; 
		} 
	} 
 
main(argc, argv) 
	int argc; 
	char **argv; 
	{ 
	FILE *scriptfd; 
	char c, fpname[256], str[81], *strptr, spawnpath[81]; 
	char comstr[16], speedstr[16], bitsstr[16], *spawnargv[41]; 
	int i, j, proglen, value[8], flag, progcnt, demon, curkey, spawnargc; 
	long timestamp, tstamp, tstamp1, dayofticksp; 
	index=follow=0; 
	printf("Copyright (C) 1992 Peter Edward Cann, all rights reserved.\n"); 
	if(!strcmp(getenv("REMOTE"), "YES")) 
		{ 
		printf("You appear to be logged in remotely, judging by the environment\n"); 
		printf("variable REMOTE, so it strikes me as somewhat peculiar that you\n"); 
		printf("want to run COMSCRPT. Are you sure you want to do it? (y or n) --> "); 
		if(getchar()!='y') /* Note getchar() and not getch()! */ 
			{ 
			printf("I didn't think so!\n"); 
			exit(99); 
			} 
		else 
			printf("OK, you're the boss!"); 
		} 
	if(argc!=2) 
		{ 
		printf("USAGE: comscrpt