Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

INETDIAL.C

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search
/* Internet Dialer */

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <bios.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>

unsigned char in;
unsigned int out,scan;

char scanstr[31];
char scancrit[31];

char number[30];
char username[30];
char password[30];
char slipcmd[30];

unsigned int portadr = 0x2e8;
unsigned int irq=2;
unsigned int baudrate=38400;
unsigned int parity=0;
unsigned int wordlength=8;
unsigned int stopbits=1;

extern int  comm_init(unsigned port, int portadr, int irq, int baudrate,
					  int parity, int wordlen, int stopbits);
extern void comm_exit(unsigned port);
extern void comm_send(unsigned port, unsigned char c);
extern int  comm_rcv(unsigned port, unsigned char *c);


int main(void)
{
	init();

	while (1)
	{
		if (comm_rcv(0,&in))
			printf("%c",in);

		if (kbhit()) {
			out  = bioskey(0);
			scan = (out >> 8) & 0xff;

			switch(scan){
				case 0x3b : send_string(username,1);           /* F1 */
								break;
				case 0x3c : send_string(password,1);           /* F2  */
								break;
				case 0x3d : send_string(slipcmd,1);            /* F3 */
								break;
				case 0x44 : send_string(number,1);             /* F10 */
								break;
				case 1 	 :	quit();

				default: comm_send(0,(char)out);
			}
		}
	}
}

init()
{
FILE* f;

	if (! comm_init(0, portadr, irq, baudrate, parity, wordlength, stopbits))
	{
		printf("Error initializing COM port!!\n");
		exit(1);
	}

	if(!(f = fopen("INETDIAL.CFG","rt")))
	{
		printf("Can't find INETDIAL.CFG!\n");
		exit(1);
	}

	fgets(number,80,f);
	fgets(username,80,f);
	fgets(password,80,f);
	fgets(slipcmd,80,f);
	number[strlen(number)-1]=0;
	username[strlen(username)-1]=0;
	password[strlen(password)-1]=0;
	slipcmd[strlen(slipcmd)-1]=0;

	fclose(f);
}

quit()
{
	comm_exit(0);
	exit(0);
}


send_string(char *s,int cr_lf)
{
int i;

	for (i=0;i<strlen(s);i++) {
/*	if(! chk_flow()) return 0; */
		comm_send(0,s[i]);
		delay(8);
	}
	if(cr_lf) {
/*		if(! chk_flow()) return 0; */
		comm_send(0,13);
		delay(8);
	}
	return 1;
}


waitforstring()
{
		strcpy(scanstr,&scanstr[1]);
		scanstr[29] = in;
		if(strstr(scanstr,scancrit))
			return;
}