home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
telecomm
/
autolog
/
autolog.c
next >
Wrap
C/C++ Source or Header
|
1989-06-03
|
3KB
|
157 lines
#include <osbind.h>
#include <bios.h>
#include <aesbind.h>
#include <gemdefs.h>
#include <special2.h>
char buffer[25],keybuffer[100],text[1000],name[16],filename[128];
char buffer2[25],ret[]="\n",*cp,*kb,*tx;
int rsinput,key,button,ii,checkinput,result;
int drv,count,backcount,gchk;
FILE *fp;
long keyinp,textlen;
main()
{
appl_init(); /* open application */
graf_mouse(M_OFF,0); /* turn mouse off */
cls;
title();
checkinput=0;
kb=keybuffer;
tx=text;
backcount=0;
gchk=0;
get_input(); /* accept input */
}
get_input()
{
for(;;)
{
while(Bconstat(1)==-1) /* loop while char is ready */
{
if(checkinput==1)
{
save_data(); /* save buffer, reset flag */
checkinput=0;
backcount=0;
}
rsinput=Bconin(1); /* get char from seriel */
if (rsinput=='>')
gchk=1;
if (buffer[3]==13 || buffer[3]==10)
{
gchk=0;
for(ii=0;ii<=24;ii++)
{
buffer[ii]=0;
buffer2[ii]=0;
}
}
if((rsinput>=32 && rsinput<=126 && gchk==0)|| rsinput==13)
{
for(ii=24;ii>0;ii--) /* build buffer */
buffer[ii]=buffer[ii-1];
buffer[0]=rsinput;
}
Cconout(rsinput); /* print character */
}
if (Bconstat(2)==-1)
{
keyinp=Bconin(2);
key=keyinp & 0xff;
if (keyinp==3866624) /* check for F1 */
save_file(); /* save capture */
if(keyinp==6356992) /* check for UNDO */
quit(); /* quit program */
gchk=0;
if (key==8 && backcount>0)
{
backcount--; /* count # of char inputted */
*kb--=0; /* erase character */
Bconout(1,(int)key); /* output to seriel */
for (ii=0;ii<3;ii++)
Cconout((int)Bconin(1)); /* print echo char */
}
if (key>=1 && key<=126 && key!=8)
{
backcount++; /* count # of char inputted */
if (backcount==100)
{
kb==keybuffer; /* check for overflow */
backcount=0;
for (ii=0;ii<100;ii++)
keybuffer[ii]=0;
}
Bconout(1,(int)key);
key=(key==13) ? '|' : key; /* handle carr ret */
*kb++=key; /* save input */
checkinput=1;
}
if ((key>=32 && key<=126) || key==13)
Cconout((int)Bconin(1)); /* print echo char */
}
}
}
save_data()
{
count=0;
for(ii=24;ii>=0;ii--)
{
if (buffer[ii]>31)
{
buffer2[count]=buffer[ii];
count++;
}
}
strcat(text,">WA "); /* the WAIT command */
strcat(text,buffer2); /* string to wait for */
strcat(text,"|"); /* RETURN character */
strcat(text,ret); /* REAL carr return */
strcat(text,keybuffer); /* copy response */
strcat(text,ret);
kb=keybuffer; /* reset pointer */
for(ii=0;ii<100;ii++) /* clear buffer */
keybuffer[ii]=0;
}
save_file()
{
get_file(filename,"*.DO");
if (filename[0]!=0)
{
fp=fopen(filename,"w"); /* create file */
fwrite(text,1,strlen(text),fp);
fclose(fp);
quit();
}
}
quit()
{
appl_exit(); /* close application */
printf("\33f\n"); /* turn cursor off */
exit(0);
}
title()
{
printf("\33j \33p Bob Areddy's Autolog (c) 1989 \33q\33k\n");
}