home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
researchmachines
/
rmlmai.c
< prev
next >
Wrap
Text File
|
1985-07-10
|
9KB
|
398 lines
/***********************************************************************/
/* File KMAIN.C - RML Kermit - main() & associated routines.
Chris Kennington, 3rd July 1985. */
#define DEFS1 1
#define DEFS2 1
#define DEFS3 1
#define DEFS4 1
#include "stdio.h"
#include "b:kext.h"
char verdate[] = "Version 1.22, 10th July 1985.";
/* max 32 chars: 12345678901234567890123456789012 */
extern CHAR menu();
static char cmdmenu[] = "C O M M A N D S to S E R V E R";
static char *copyrite[] = {head1,head3,head2,0};
static char mainmenu[] = "K E R M I T M A I N M E N U";
static char *mainhelp[] = {
" Use up \136 & down \036 arrows to select next Kermit activity;",
" (or F1/PGUP & F3/PGDN for top & bottom of list).",
" Hit ? for help on selected parameter, RETURN to take action,",kqhelp,
" Kermit will prompt for file-names etc. as needed.",0};
main(argc,argv)
int argc;
char **argv;
{
int i, mod, rsc;
char c, rcmd, **txt;
struct mode *md;
keyinit();
netcool();
s4go();
s4set(commode,comctrl);
dynamic();
cursor(0);
vtline(0x0000,head1);
vtline(0x0100,head4);
vtline(0x0200,head5);
vtline(0x0300,head6);
vtline(0x0400,divisor);
vtline(LOCVER,verdate);
setbaud(); /* set initial speed (300baud) */
i = head2; /* prolink restriction */
env = s4env();
strcop(locations[env],i+64); /* source of comms */
/* main Kermit loop - go on until exits surreptitiously */
mod = rsc = 1; /* top lines of menus */
kmode = KERM;
forever {
/* at this point "break" leads to "Hit any key..", "continue" skips it */
nakflag = abtflag = 0;
rptflg = TRUE; /* attempt repeat-counting */
flushinput(); /* avoid trouble */
screen(5,23);
switch (kmode) {
case KERM: /* command-mode */
md = &modker; /* Prolink restriction */
vtline(LOCMODE,md->m_text);
i = menu(kmodes,MODMAX,mainmenu,&mod);
md = kmodes[i];
vtline(LOCMODE,md->m_text); /* next action */
kmode = md->m_value;
clrscrn();
continue;
case LOGO: /* kill mainframe Kermit */
md = &rclogo;
printmsg(md->m_text);
servsend(kmode);
/* fall through into connect */
case CONN: /* connect-mode */
s4set(commode,comctrl);
cursor(0x09);
connect();
continue;
case SEND:
vtline(LOCMODE,sendf);
s4set(commode,comctrl);
s4sleep();
cursor(0x1d);
printmsg("%sEnter filename(s) > ",sendf);
if (keyline(cmdline) == 0)
goto Out2;
cursor(0);
upper(cmdline);
filecount = decol8(cmdline,cmdparm,8);
filelist = cmdparm; /* Set up file list */
if ( (gnxtfl() == FALSE) || (sendsw('S') == FALSE) ) /* Send file(s) */
printmsg("** SEND failure. ");
goto Out1;
case RECV: /* Receive-mode */
vtline(LOCMODE,filblank);
vtline(LOCMODE,rcvng);
state = 'R';
case GET: /* from Server-Command mode */
s4set(commode,comctrl);
s4sleep();
cursor(0x1d);
vtline(LOCFILE,filblank);
printmsg("%sStore under own names",rcvng);
if (confirm() != TRUE) { /* if overriding */
if (abtflag != 0)
goto Out2;
printmsg("New filenames &/or disk-letter > ");
keyline(cmdline);
upper(cmdline);
if ( (filecount = decol8(cmdline,cmdparm,8)) == 0 )
goto Out2;
filelist = cmdparm; /* Set up file list */
printmsg("%sas requested%s",rcvng,dots);
vtline(LOCFILE,*filelist);
}
else {
filelist = filecount = 0;
printmsg("%s%s",rcvng,dots);
}
cursor(0);
kmode = RECV; /* makes ESCs valid */
if (recsw(state,'R') == FALSE)
printmsg("** RECEIVE failure. ");
else
printmsg("** Files received OK. ");
goto Out1;
case PARM: /* Set parameters */
setshow();
goto Out2;
case CMND: /* Commands to server */
if ( (i = menu(rcmds,CMDMAX,cmdmenu,&rsc)) == 0 ) {
kmode = KERM;
continue;
}
md = rcmds[i];
if ( (rcmd = md->m_value) != MAIN )
printmsg(md->m_text);
outc(SP);
cursor(0x1d);
servsend(rcmd);
continue;
case DISK: /* process BDOS commands */
cursor(9);
md = &modisk; /* Prolink restriction */
printmsg(md->m_text);
outc(CR);
txt = md->m_help;
while (*txt != 0) {
outc(CR);
txtout(*txt++);
}
s4sleep();
outc(CR);
forever
if (osaction() == 0)
break;
netcool();
Out2:
kmode = KERM;
continue;
case QUIT: /* exit from prog */
printmsg(null);
kermkill(1);
default: /* unknown mode */
Out1:
cursor(0x1d);
kmode = KERM;
break;
} /* end switch */
if ( (kmode == KERM) || (kmode == CMND) ) {
printmsg("Hit any key to continue ... ");
while (keyget(&c) == 0)
; /* pause */
} } /* end if, forever */
/* we never come out of this loop */
printmsg("%sExit!",interr);
kermkill(1);
} /* End of main() */
static dynamic() /* set up dynamic storage */
{
cmdline = getram(85);
osline = getram(85);
work = getram(MAXPACKSIZE+10);
packet = getram(MAXPACKSIZE+2);
recpkt = getram(MAXPACKSIZE+2);
oldpkt = getram(MAXPACKSIZE+2);
ownfcb = getram(42);
fname = getram(50);
filblank = blanx;
filblank += 60; /* PROLINK restriction */
return;
} /* end of dynamic() */
errdisp() /* display error-counts */
/* Display counts of naks in, bad crcs, duplicate blocks
and timouts in header. */
{
static char buff[20];
static int old1=0, old2 =0, old3=0, old4=0;
if (dupes != old1) {
old1 = dupes;
sprintf(buff,"%d Dupes,",dupes);
vtline(LOCDUPES,buff);
}
if (badcrcs != old2) {
old2 = badcrcs;
sprintf(buff,"%d Cksm,",badcrcs);
vtline(LOCCRCS,buff);
}
if (timouts != old3) {
old3 = timouts;
sprintf(buff,"%d Timeouts,",timouts);
vtline(LOCTIMOS,buff);
}
if (naxin != old4) {
old4 = naxin;
sprintf(buff,"%d NAKs.",naxin);
vtline(LOCNAKS,buff);
}
return;
} /* end of errdisp() */
kermkill(code) /* close down Kermit */
/* confirms with user if code = 0 */
char code;
{
char c, *msg;
if (code == 0) {
printmsg("Quit Kermit");
if (confirm() != TRUE)
return;
}
keyrest();
s4stop();
#ifdef MPUZ80
txtout(" End of Kermit.");
#else
msg = "\n Kermit cancelled - You may have to reload MSDOS.\n";
while ( (c = *msg++) != 0 )
putchar(c);
#endif
cpmgo();
} /* end of kermkill() */
CHAR menu(modes,max,title,iline) /* display menu */
struct mode *modes[];
int max, *iline;
char *title;
{
CHAR c;
int i, mod;
struct mode *md;
scrdiv();
screen(19,24);
vtline((SCRTOP-1)*256+MENUCOL,title);
i = SCRTOP*256+MENUCOL;
c = strlen(title);
while (c-- > 0) /* underline */
vtout(i++,0x1f);
for (i=1; i<max; ++i) {
md = modes[i];
vtline((SCRTOP+i)*256+PNMCOL,md->m_text);
}
show5( (title == mainmenu) ? copyrite : mainhelp );
curset(23,0);
mod = *iline;
md = modes[mod];
forever { /* control arrow-selection */
vtout((SCRTOP+mod)*256+PVCOL,LARROW);
while (keyget(&c) == 0)
;
vtout((SCRTOP+mod)*256+PVCOL,SP); /* & old arrow */
c &= (char)0x5f; /* u.c. 7-bit */
switch (c) {
case CR: /* action */
case LF:
*iline = mod; /* remember line-# */
screen(5,23);
clrscrn();
return(mod); /* exit with index-# */
case 0: /* SP&0x5f - cycle */
if (++mod > (max-1))
mod = 1;
break;
case 'B': /* back to top */
mod = 1;
break;
case 'D': /* down */
if (++mod > (max-1)) {
bell();
--mod;
}
break;
case 'H': /* general help */
show5(mainhelp);
continue;
case 'N': /* on to bottom */
mod = max-1;
break;
case 'Q': /* quit */
kermkill(0);
/* if not confirmed, fall through */
case 'K':
return(0); /* no-op exit */
case 'U': /* up */
if (--mod == 0) {
bell();
++mod;
}
break;
case '?': /* specific help */
case 0x1f:
case 0x0f:
break;
default:
continue;
} /* end switch */
md = modes[mod];
show5(md->m_help);
} /* end forever */
} /* End of menu() */
prerrpkt(msg)
/* Print contents of error packet received from remote host. */
char *msg;
{
printmsg("Aborting; %s\r \"%s\". ",mainsays,msg);
return;
} /* end of prerrpkt() */
printmsg(fmt, a1,a2,a3,a4,a5)
char *fmt;
{
txtout(prompt);
outc(':');
outc(SP);
printf(fmt,a1,a2,a3,a4,a5);
outc(DEOL); /* Delete to EoL */
} /* end of printmsg() */
/**************** END of file KMAIN.C ***********************/