#include #include #include #include #ifdef quantum #define MODEM_PORT 0x3fb #define DELAY 4 #include #endif #define SUCCESS 0 extern int turn,speed; extern char *ttyname; FILE * ttopen(tn, mode) char *tn, *mode; { FILE *fp; if ( !(strcmp(tn,"$con")) && !(strcmp(mode, "r")) ) return(stdin); if ( !(strcmp(tn,"$con")) && !(strcmp(mode, "w")) ) return(stdout); if ((fp = fopen(tn, mode)) == NULL) { printmsg("Cannot open %s with mode %s",tn, mode); exit(1); } return(fp); } ttbin(fp,old) int fp; unsigned *old; { unsigned new; char baudcmd[80], buf[10]; *old = get_option(fp); /* Save current mode for later restoration */ new = get_option(fp); /* set tty to "RAW" mode */ new &= ~ECHO; /* turn off automatic echoing */ new &= ~EDIT; /* turn off line editing of input */ new &= ~EDEL; /* don't expand DEL to */ new &= ~MAPCR; /* don't expand CR to record separator */ if (!turn) new |= XON_XOFF; /* use xon/xoff if no handshaking */ set_option(fp, new); /* finally set the option */ /* * set the baud rate by spawning "stty" */ if (speed) { strcpy(baudcmd, "stty baud="); sprintf(buf, "%d >", speed); strcat(baudcmd, buf); strcat(baudcmd, ttyname); if (shell(baudcmd) != SUCCESS) { printmsg("Unable to set the %s's baud rate to %d", ttyname, speed); exit(1); } } } ttres(fp,old) int fp; unsigned *old; { sleep(1); /* wait before releasing the line */ set_option(fp, *old); } /* * C O M B R E A K - send a break to the comm line */ combreak(fp) FILE *fp; { unsigned admin; char buf[3]; /* * Send break request to DEV_ADMIN for version 1.1x * otherwise send to the administrator that owns the task */ admin = (((unsigned)task_info(0, 6)) < 120) ? DEV_ADMIN : fp->_admin_tid; buf.mtype = STTY_MESSAGE; buf.stty_devno = fp->_dev_no; buf.stty_type = STTY_SEND_BREAK; send(admin, &buf, &buf, 3); } /************** comment out ********************************************** mask = io_in(MODEM_PORT); io_out(MODEM_PORT, mask | 0x040); set_timer(TIMER_WAKEUP, RELATIVE, DELAY); io_out(MODEM_PORT, mask); } ************ end comment out *********************************************/