/* TERM_C - QL-Kermit terminal emulation Loosely based on ckucon.c, (C) Columbia University */ /* Include files */ #include "ram1_ker_h" /* Kermit definitions */ #include "flp1_fcntl_h" /* File opening modes */ /* External variables */ extern int ttychid; /* QDOS channel ID for comms line */ extern bool echo; /* Local echo flag */ extern char enter[2]; /* What to send for ENTER */ /* DOCONNECT - dumb terminal emulator */ doconnect() { char *conname = "con_"; /* Name of emulation window */ unsigned char tchar; /* Character temporary */ int conchid; /* QDOS channel ID for window */ int confd; /* FD for window */ bool cnflg; /* In progress flag */ confd = open(conname,O_RDWR); /* Open emulation window */ if (confd<0) { error("Cannot open window %s",conname); return(0); } conchid = (int) getchid(confd); /* Now get the QDOS ID for it */ sd_curs(fgetchid(stdin),-1); /* Disable the console cursor */ cls(conchid); /* Clear the window */ printf("Type F2 to return to command mode\n"); sd_cure(conchid,-1); /* Enable cursor in it */ cnflg = TRUE; while (cnflg) /* Loop until F1 pressed */ { if (!io_pend(conchid,0)) /* If key pressed, */ { if (!io_fbyte(conchid,0,&tchar)) /* read it */ { switch(tchar) { case F2: cnflg = FALSE; /* Exit */ endcase; case F3: tchar = '\0'; /* NUL */ goto send; case F4: tchar = '\003'; /* CTRL-C */ goto send; case F5: tchar = '\177'; /* DEL */ goto send; case LF: if (echo) io_sbyte(conchid,0,LF); io_sbyte(ttychid,0,enter[0]); if (enter[1]!=0) io_sbyte(ttychid,0,enter[1]); endcase; send: default: io_sbyte(ttychid,0,tchar); if (echo) io_sbyte(conchid,0,tchar); endcase; } } } if (!io_pend(ttychid,0)) /* If line character there, */ { if (!io_fbyte(ttychid,0,&tchar)) io_sbyte(conchid,0,tchar); /* copy it to screen */ } } close(confd); /* Finished, drop the window */ sd_cure(fgetchid(stdin),-1); /* Cursor back to stdin */ printf("\n"); return(0); }