/***************************************************************************/ /* File KPARM.C for RML Kermit, Chris Kennington, 8th July 1985. */ #define DEFS1 1 #define DEFS3 1 #include "stdio.h" #include "b:kext.h" /* Structure for handling parameters in set/show:- */ struct parm { /* parameter-description */ int (*p_action)(); /* action-routine */ CHAR p_key; /* key-letter (inverse capital) */ char *p_name; /* parameter-name */ unsigned *p_value; /* pointer to variable */ CHAR p_vtype; /* code for type of value */ char *p_vtexts[10]; /* descriptions of up to 10 values */ char *p_help[5]; /* up to 5 lines of help-text */ } ; /* N.B. The actual variable holding the value is not a structure member, but is the object of p_value. If it is int, then bit0 of p_vtype = 0; if it is char, bit0 of p_vtype = 1. Where it is char, if it takes values 0-9 corresponding to p_vtexts, then bits 1/2 = 00; if it takes character values, then bits 1/2 = 01; if it takes hex values, = 11. p_action() is the routine which gives effect to a change in the setting of p_value; for unimplemented parameters or values is pmnyi(). */ extern int chkbaud(), no_op(), pmnyi(), set8(), setlen(), setflow(), setpar(); extern unsigned int getval(); /* these declared here to prevent "undeclared" errors in initializations */ /* static global variables (local to this file) */ #ifdef MPUZ80 static char flowcode = 1; /* CTS/RTS default for 480Z */ #else static char flowcode = 0; /* but not for Nimbus */ #endif static char *pointc; static char firston, laston, /* first & last entries on display */ index; /* current parameter-number */ static int psiz = 0, line, *pointi; static struct parm *pm; /* pointer to current parm */ static CHAR ptype; /* type of current parm */ /* Local strings */ static char off[] = "0 = OFF"; static char on[] = "1 = ON"; static char arros[] = " Arrows set parameters "; static char hfor[] = " H for Help "; static char toexit[] = " RETURN to Continue "; static char hdr1[] = "Key"; static char hdr2[] = "Parameter"; static char hdr3[] = "Current Setting"; static char maychange[] = "This parameter needs agreement from remote Kermit and may therefore change. "; static char *genhelp[] = { "Parameter Setting: Use up \136 & down \036 arrows to find the parameter to be", "----------------- changed, or F1 & F3 to find another page of parameters.", " Use right \035 & left \033 arrows to change setting of the", " parameter you have selected. \"?\" for help on the current parameter.", kqhelp}; /* structures for controllable parameters */ static struct parm pecho = {&no_op,0xc5,"Local Echo",&echo,0, off,on,0,0,0,0,0,0,0,0, "Local Echo: If ON, all characters sent to mainframe in Connect Mode will also", "----------- be displayed on the screen. Required for \"half-duplex\" working.",0}; static struct parm pavoid = {&no_op,0x20,"File Collision",&nmavoid,1, "Overwrite","Rename","Refuse","Ask user", 0,0,0,0,0,0, "Collision Avoidance: If the name of an incoming file matches one already on", "-------------------- the disk, it will overwrite the old one, be renamed to", " avoid overwriting, or be rejected, or the user will be", "asked for permission to overwrite, according to value of this parameter.",0}; static struct parm pimage = {&set8,0x20,"8th-bit mode",&image,0, "7-bit stripped","8-bit image","8-bit prefixed", 0,0,0,0,0,0,0, "8th-Bit Handling: Normally OFF; all data sent/received as 7-bit characters", "----------------- (top bit zero). In IMAGE, all 8 bits sent and received,", " but this may not always work; PREFIXED gets around", "this problem, but not all Kermits can cope.",0}; static struct parm ppkt = {&setlen,0x20,"Packet-Size",&psiz,0, "94 bytes","86 bytes","78 bytes","70 bytes", "62 bytes","54 bytes","46 bytes","38 bytes", 0,0, /* reduce in 8s to ease calculation */ "Size of Packet: Maximum length of data-packets on line; 95 should normally", "--------------- be used since shorter packets mean slower transfers.",0}; static struct parm ppage = {&no_op,0x20,"Page-Wait",&pager,1, off,"4 lines","8 lines","12 lines","16 lines", "20 lines","24 lines",0,0,0, "Page-Wait: If turned ON, mainframe output in Connect Mode, and data listing", "---------- in Disk Maintenance, will be held up every screenfull.",0}; static struct parm plist = {&no_op,0xcc,"List/Debug",&list,0, off,"Dot-per-Block","Data-Listing","Debug Trace", "Debug Data","Debug Overkill",0,0,0,0, "List - Debug: Normally ON, a dot will be printed for each good data-block", "------------- to/from the mainframe (with D, C, T for duplicates,", " checksum-errors & timeouts); alternatively all data sent or", "received may be listed. Debug settings give increasing amounts of trace", "information."}; static struct parm pnslow = {&no_op,0xce,"Slow-Network",&netslow,1, off,on,0,0,0,0,0,0,0,0, "Slow-Network: If ON, steps taken so that duplicate blocks held in the", "------------- communications network are discarded. Use if many duplicates", " are reported.",0}; static struct parm ppar = {&setpar,0x20,"Parity Generation",&parity,0, off,"1 = Odd","2 = Even","3 = Mark", 0,0,0,0,0,0, "Parity: Controls the addition of parity to all characters sent to mainframe;", "------- normally OFF, but can be set to give Odd, Even or Mark parity.", " Must always be off during IMAGE transfers.", "Parity of incoming data is not checked; characters received are stripped to", "7 bits (except in IMAGE)."}; static struct parm pbaud = {&chkbaud,0x20,"Baud-Rate",&spdcode,1, sp0,sp1,sp2,sp3,sp4,sp5,sp6,sp7,0,0, "Baud-Rate: Speed (in baud) to which the communications line is set.", "----------",0}; static struct parm pflow = {&setflow,0x20,"Flow-Control",&flowcode,1, "None","CTS-RTS","XON/XOFF","CTS & XON/XOFF", "ENQ-ACK","CTS & ENQ/ACK",0,0,0,0, "Flow-Control: CTS/RTS is hardware control using control lines; XON/XOFF, alias", "------------- Tandem, uses these chars (11H & 13H) to hold up and reenable", " transmission; ENQ/ACK sends an ACK (06H) whenever an ENQ (05H)", "or an ETX (03H) is received and processed. The first two work in both", "directions. Kermit works OK without flow-control in most cases."; static struct parm *pmlist[] = {&pbaud,&ppar,&plist,&pimage,&ppage, &pavoid,&ppkt,&pnslow,&pecho, &pflow,0}; #define PMCOUNT 10 /* number of entries in pmlist[] */ /* Procedures for handling parameter-structures */ static chkbaud() /* validate baud-rate */ { if (getval() <= MAXSPD) setbaud(); else pmnyi(); return; } /* end of chkbaud() */ static down1() /* go down one parm */ /* returns -1 if already at bottom, else 0 */ { if (index == (PMCOUNT-1)) /* already on last parm */ return(-1); else { /* move down to next parm */ vtout( (line+PA2COL), SP ); /* wipe arrow */ pm = pmlist[++index]; if (index > laston) { /* is bottom entry */ scroll(2); pmdisp(line); ++laston; ++firston; } else /* another below */ line += 512; /* so down 2 lines */ vtout( (line+PA2COL), LARROW ); /* point to new entry */ } return(0); } /* End of down1() */ static unsigned getval() /* return value of parm */ { unsigned val; ptype = pm->p_vtype & (char)0x01; /* update parm-type */ pointc = pointi = pm->p_value; /* & typed value-pointers*/ if (ptype == 0) /* integer */ val = *pointi; else /* char */ val = *pointc & 0xff; return(val); } /* end of getval() */ static pmnyi() /* tell user not yet implemented */ { vtline( (line+256), "This parameter (or value) not yet implemented." ); return; } /* end of pmnyi() */ static pmdisp(ln) /* display parameter settings */ /* ln is number of line-on-screen * 256 */ int ln; { int pos; unsigned i; char *t; cursor(0); vtline(ln,blanx); /* clear garbage */ pos = ln + PKCOL; /* position for letter */ vtout(pos,pm->p_key); pos = ln + PNMCOL; vtline(pos,pm->p_name); /* name of parameter */ pos = ln + PVCOL; i = getval(); t = pm->p_vtexts[i]; if ( (i > 9 ) || (t == 0 ) ) bell(); else vtline(pos,t); /* value of parmeter */ return; } /* end of pmdisp() */ scrdiv() /* divide screen for menu */ { int i; keyinit(); for (i=SCRTOP-2; i< SCRLEN; ++i) vtline((int)i*256,blanx); vtline((SCRBOT+1)*256,divisor); vtline((SCRBOT+1)*256+9,arros); vtline((SCRBOT+1)*256+38,hfor); vtline((SCRBOT+1)*256+55,toexit); screen(SCRTOP,SCRBOT); curset(SCRTOP,0); /* cursor @ home */ cursor(0); /* but switched off */ return; } /* End of scrdiv() */ static set8() /* check 8th-bit handling */ { if (image > 1) vtline((line+256),maychange); oldimage = image; return; } /* end of set8 */ static setflow() /* set flowcontrol from flowcode */ { #ifdef MPUZ80 /* 480Z - all working except enq/ack */ if (flowcode > 3) #else /* Nimbus - only XON/OFF working */ if ( (flowcode & 0x0d) != 0 ) #endif pmnyi(); else { commode &= 0xfc; commode |= flowcode; s4set(commode,comctrl); } return; } /* end of setflow() */ static setlen() /* set receive & send lengths */ { rpsiz = 94- (psiz << 3); if (spsiz > rpsiz) spsiz = rpsiz; vtline((line+256),maychange); return; } /* end of setlen() */ setshow() /* set & show parameter values */ /* Used in PARM mode to allow display of current parameter settings and manipulation of them, with help displays. */ { CHAR c, d; char i, *text; int lin2; unsigned value; /* value of current parameter */ scrdiv(); vtline((SCRTOP-2)*256+PKCOL-1,hdr1); vtline((SCRTOP-2)*256+PNMCOL+1,hdr2); vtline((SCRTOP-2)*256+PVCOL-2,hdr3); line = FIRSTLINE; for (i=0; ip_vtexts[value]; if ( (text == 0) || (value > 9) ) /* increment value */ value = 0; /* cycle values */ goto Update; case 'L': /* left arrow - previous value */ value = getval(); if (value == 0) { /* if first value */ while ( (pm->p_vtexts[++value] != 0) && (value < 10) ) ; /* find first invalid */ } --value; Update: if (ptype == 0) /* if => int */ *pointi = value; else /* if => char */ *pointc = (char)value; pmdisp(line); /* update display */ (*pm->p_action)(); /* call routine */ vtout( (line+PA2COL), LARROW ); break; case 'N': /* next page of values */ for (i=0; i<(SCRSIZE-1); ++i) if (down1() != 0) break; break; case 'B': /* back one page of values */ for (i=0; i<(SCRSIZE-1); ++i) if (up1() != 0) break; break; case 'Q': /* quit from Kermit (after check) */ screen(5,23); clear5(); curset(19,5); kermkill(0); /* fall thro into 'K'if not confirmed */ case 'K': /* return to Kermit */ abtflag = 1; case CR: screen(5,23); clrscrn(); curset(6,0); cursor(1); return; case '?': /* help on current param */ case 0x1f: /* '?' & 0x5f */ case 0x0f: /* '/' & 0x5f */ clear5(); show5(pm->p_help); break; default: bell(); case 'H': clear5(); show5(genhelp); /* general help */ } /* end switch */ } /* end while */ } /* end setshow() */ static up1() /* up one parm */ /* returns -1 if already at top, else 0 */ { if (index == 0) /* already on first parm */ return(-1); else { /* move up to next parm */ vtout( (line+PA2COL), SP ); /* wipe arrow */ pm = pmlist[--index]; if (firston > index ) { /* is top entry */ scroll(-2); pmdisp(line); --firston; --laston; } else /* another below */ line -= 512; /* so up 2 lines */ vtout( (line+PA2COL), LARROW ); /* point to new entry */ return(0); } } /* End of up1() */ /************** END of File KPARM.C ********************************/