/* TERM module File 2 */ #include "zmp.h" #include long lseek(); /* Display current keyboard macros */ keydisp() { short i; cls(); printf("\r\t\t"); stndout(); printf(" KEYPAD MACRO LIST \n\n"); stndend(); for (i=0; i<10; i++) printf("\t%d - %s\n",i,KbMacro[i]); printf("\n\n"); } /* Save a buffer to a file. If flag set, send ctl-s/ctl-q to stop remote */ keep(filename,flag) char *filename; short flag; { short fl, i, new; long pos; if (!BFlag) return; if (!TxtPtr) goto cleanup; if (flag) mcharout(CTRLS); while (TxtPtr % 128) MainBuffer[TxtPtr++] = CPMEOF; /* fill buffer with Ctrl-Z */ strcpy(Pathname,filename); addu(Pathname,Invokdrive,Invokuser); new = FALSE; if ((fl = open(Pathname, 2)) == UBIOT) { new = TRUE; if ((fl = creat(Pathname,0)) == UBIOT) openerror(fl,Pathname,UBIOT); } if (fl != UBIOT) { if (!new) { pos = lseek(fl, 0L, 2); /* go to start of last record */ *Buf = CPMEOF; /* fake it to start with */ while (*Buf == CPMEOF && pos) { pos -= 128L; lseek(fl, pos, 0); read(fl, Buf, 128); /* read it */ } for (i = 0; i < 128; i++) /* stop when we find a ^Z */ if (Buf[i] == CPMEOF) break; pos += (long) i; /* adjust position */ } else pos = 0L; lseek(fl, pos, 0); /* seek to new position */ write(fl,MainBuffer,TxtPtr); /* write it */ close(fl); } if (flag) mcharout(CTRLQ); TxtPtr = 0; cleanup: free(MainBuffer); } startcapture() /* allocate capture buffer */ { char *grabmem(); if (!BFlag) return; MainBuffer = grabmem(&Bufsize); Buftop = Bufsize - 1; TxtPtr = 0; #ifdef DEBUG printf("\ncapture Bufsize = %u\n",Bufsize); #endif } /* Allow user to change things */ docmd() { char c,parity,databits,stopbits; int i,oldfdx,oldremecho,oldbaud; unsigned baud; static char offstr[] = "OFF", onstr[] = "ON"; start: cls(); printf("\t\t"); stndout(); printf(" CHANGE LINE PARAMETERS \n"); stndend(); printf("\n\tB - Change Baud Rate (now %u)\n", Baudtable[Current.cbaudindex]); printf("\tC - Set Checksum/CRC default for X/Ymodem: now %s\n", Crcflag ? "CRC" : "Checksum"); printf("\tD - Set Half/Full Duplex/Echo\n"); printf("\tF - Toggle Control Character Filter: now %s\n", Filter ? onstr : offstr); printf("\tH - Toggle 32-bit FCS request in Zmodem: now %s\n", Wantfcs32 ? onstr : offstr); printf("\tI - Initialise Modem\n"); printf("\tO - Switch Port: now %c\n",Port ? 'B' : 'A'); printf("\tP - Handle Parity Bit in Terminal Mode: now %s\n", ParityMask ? "Stripped" : "Passed"); printf("\tU - Set up UART: Parity, Stop Bits, Data Bits\n"); printf("\tW - Toggle Word Wrap in Terminal Mode: now %s\n", WordWrap ? onstr : offstr); printf("\tX - Toggle Xon-Xoff Protocol: now %s\n", XonXoff ? onstr : offstr); printf("\tZ - Exit\n"); printf("\n Select: "); switch (c = toupper(bdos(CONIN))) { case 'B' : do { printf("\nEnter new baud rate: "); scanf("%d",&baud); while(getchar() != '\n'); /* flush */ for (i = 0; i < 13; i++) if (Baudtable[i] == baud) break; } while (i > 12); /* Don't leave till it's right */ oldbaud = Current.cbaudindex; Current.cbaudindex = i; updateace(); /* error if change is intended but rejected */ if ((*Mspeed == oldbaud) && (i != oldbaud)) { Current.cbaudindex = oldbaud; printf("\nBaud rate %u not available.\n",baud); waitakey(); } break; case 'C': Crcflag = !Crcflag; break; case 'D': oldfdx = FDx; /* Save original */ oldremecho = RemEcho; FDx = TRUE; RemEcho = FALSE; printf("\null Duplex, alf Duplex or Remote cho? "); switch (c = toupper(bdos(CONIN))) { case 'H' : FDx = FALSE; break; case 'E' : FDx = FALSE; RemEcho = TRUE; break; case 'F' : break; default : FDx = oldfdx; /* no change */ RemEcho = oldremecho; break; } break; case 'F': Filter = !Filter; break; case 'H': Wantfcs32 = !Wantfcs32; break; case 'O': Port ^= 1; setport(Port); break; case 'P': ParityMask = !ParityMask; break; case 'I': initace(Current.cbaudindex,Current.cparity, Current.cdatabits,Current.cstopbits); mstrout("\n\n",FALSE); mstrout(Modem.init,FALSE); while (readline(10) != TIMEOUT); break; case 'U': do { printf("\nEnter new parity (E, O, N): "); parity = toupper(bdos(CONIN)); } while ((parity != 'E') && (parity != 'O') && (parity != 'N')); Current.cparity = parity; do { printf("\nEnter number of data bits (7,8): "); databits = toupper(bdos(CONIN)); } while ((databits != '7') && (databits != '8')); Current.cdatabits = databits - '0'; do { printf("\nEnter number of stop bits (1,2): "); stopbits = toupper(bdos(CONIN)); } while ((stopbits != '1') && (stopbits != '2')); Current.cstopbits = stopbits - '0'; updateace(); break; case 'W': WordWrap = !WordWrap; break; case 'X': XonXoff = !XonXoff; break; case ESC: case 'Z': return; default: break; } /* End of main switch */ goto start; /* Loop till esc or Z */ } capturetog(filename) char *filename; { if (!BFlag) { BFlag = TRUE; startcapture(); if (allocerror(MainBuffer)) BFlag = FALSE; else { printf("\nEnter capture filename (cr = %s): ",filename); if (getline(Buf,16)) strcpy(Lastlog,Buf); else strcpy(Lastlog,filename); printf("\nCapture ON\n"); } } else { keep(Lastlog,FALSE); /* assume remote not running */ BFlag = FALSE; printf("\nCapture OFF\n"); } } comlabel() /*print level 2 labels*/ { /* ** Removed for now killlabel(); printf( "%s2> \033p Dial%sHost%sConfigure%sPrint%sDisk%sHangup%s Level %s", Stline,Vl,Vl,Vl,Vl,Vl,Vl,Vl); printf("Help%sQuit%s %02d%c%d%d%s%s%s%s%s%s\033q%s",Vl,Vl, Baudtable[Current.cbaudindex]/100,Current.cparity,Current.cdatabits, Current.cstopbits,Vl,BFlag?"LG":"--",Vl,PFlag?"PR":"--",Vl, FDx?"FDX":"HDX",Endline); */ } scplabel() { /* removed putlabel("READING THE SCREEN -> Please wait..."); */ } diskstuff() { static int c,drive,user; char newname[20]; char q, *j; for (;;) { cls(); printf("\r\t\t"); stndout(); printf(" FILE AND DISK COMMANDS \n"); stndend(); printf("\n\tC - Change disk in default drive\n"); printf("\tD - Directory of current disk\n"); printf("\tE - Erase file on default drive\n"); printf("\tF - Change default name of capture file (currently %s)\n", Logfile); printf("\tL - Log into new du: (currently %c%d:)\n",Currdrive,Curruser); printf("\tP - Print a file on default drive\n"); printf("\tR - Rename a file on default drive\n"); printf("\tV - View a file on default drive\n"); printf("\tZ - Exit\n"); printf("\n Select: "); flush(); c = toupper(chrin()); switch (c) { case 'C': printf("\nChange disk in %c: then press any key...",Currdrive); flush(); chrin(); reset(Currdrive,Curruser); break; case 'D': directory(); waitakey(); break; case 'E': if (!possdirectory("Erase")) break; printf("\nAre you sure? (Y/N) "); flush(); c = toupper(chrin()); if (c == 'Y') unlink(Pathname); break; case 'F': if (!BFlag) { printf("\nEnter new filename: "); scanf("%s",Logfile); } else { printf("\nNot while capture on!\n"); waitakey(); } break; case 'L': printf("\nEnter the new default du: "); flush(); if (!getline(Pathname,10)) break; drive = Currdrive; user = Curruser; j = Pathname; if (isalpha(q = toupper(j[0]))) { drive = q; j++; } if (isdigit(q = j[0])) user = q - '0'; if (isdigit(q = j[1])) user = user * 10 + q - '0'; reset(drive,user); break; case 'P': if (!possdirectory("Print")) break; addu(Pathname,Currdrive,Curruser); printfile(Pathname); break; case 'R': if (!possdirectory("Rename")) break; flush(); printf("New name for %s: ",Pathname); if (!getline(newname,16)) break; rename(Pathname,newname); break; case 'V': if (!possdirectory("View")) break; addu(Pathname,Currdrive,Curruser); cls(); viewfile(Pathname); waitakey(); break; case 'Z': case ESC: return; default: break; } } } /* Prompt user and possibly give directory */ possdirectory(prompt) char *prompt; { short x; do { printf("\n%s which file (CR = quit, ? = directory)? ",prompt); if (!getline(Pathname,16)) return FALSE; if (x = (Pathname[0] == '?')) directory(); } while (x); return TRUE; } help() { int c; cls(); printf("\r\t\t\t\t"); stndout(); printf(" ZMP HELP \n\n"); stndend(); strcpy(Pathname,"ZMP.HLP"); addu(Pathname,Overdrive,Overuser); viewfile(Pathname); printf("\nEnter function (cr to abort): "); return ((c = dio()) == CR ? 0 : c); } /* View a file set up in Pathname */ viewfile() { int i; char c, kbdata; FILE *fd; fd = fopen(Pathname,"rb"); /* Use binary or it ignores CR */ if (openerror(fd,Pathname,BUFIOT)) return; newpage: for (i = 0; (i < 21) && ((c=getc(fd)) != EOF) && (c != CTRLZ); ) { if (c != LF) putchar(c); if (c == CR) { /* This will even print TRS80 files */ putchar(LF); ++i; } } if ((c == EOF) || (c == CTRLZ)) goto viewend; printf("\n\n Typing %s - ",Pathname); flush(); if (((kbdata = bdos(CONIN)) == CTRLC) || (kbdata == CTRLX)) goto viewend; printf("\n"); goto newpage; viewend: fclose(fd); } /* Print a file set up in Pathname */ printfile() { char c; FILE *fd; fd = fopen(Pathname,"rb"); /* Use binary or it ignores CR */ if (openerror(fd,Pathname,BUFIOT)) return; printf("\nAny key to abort..\n"); while (((c=getc(fd)) != EOF) && (c != CTRLZ) && !(bdos(DIRCTIO,INPUT))) { if (c != LF) bdos(5,c); /* list output */ if (c == CR) /* This will even print TRS80 files */ bdos(5,LF); } fclose(fd); } /* End of TERM module File 2 */