+/* actions associated with putting the terminal in open mode */
+tostart()
+{
+ putpad(VS);
+ putpad(KS);
+ if (!value(MESG)) {
+ if (ttynbuf[0] == 0) {
+ register char *tn;
+ if ((tn=ttyname(2)) == NULL &&
+ (tn=ttyname(1)) == NULL &&
+ (tn=ttyname(0)) == NULL)
+ ttynbuf[0] = 1;
+ else
+ strcpy(ttynbuf, tn);
+ }
+ if (ttynbuf[0] != 1) {
+ struct stat sbuf;
+ stat(ttynbuf, &sbuf);
+ ttymesg = sbuf.st_mode & 0777;
+ chmod(ttynbuf,
+#ifdef UCBV7
+ /*
+ * This applies to the UCB V7 Pdp-11 system with the
+ * -u write option only.
+ */
+ 0611 /* 11 = urgent only allowed */
+#else
+ 0600
+#endif
+ );
+ }
+ }
+}
+
+/*
+ * Turn off start/stop chars if they aren't the default ^S/^Q.
+ * This is so idiots who make esc their start/stop don't lose.
+ * We always turn off quit since datamedias send ^\ for their
+ * right arrow key.
+ */
+#ifdef TIOCGETC
+ttcharoff()
+{
+ nttyc.t_quitc = '\377';
+ if (nttyc.t_startc != CTRL(q))
+ nttyc.t_startc = '\377';
+ if (nttyc.t_stopc != CTRL(s))
+ nttyc.t_stopc = '\377';
+# ifdef TIOCLGET
+ nlttyc.t_suspc = '\377'; /* ^Z */
+ nlttyc.t_dsuspc = '\377'; /* ^Y */
+ nlttyc.t_flushc = '\377'; /* ^O */
+ nlttyc.t_lnextc = '\377'; /* ^V */
+# endif
+}
+#endif
+
+#ifdef USG3TTY
+ttcharoff()
+{
+ tty.c_cc[VQUIT] = '\377';
+# ifdef VSTART
+ /*
+ * The following is sample code if USG ever lets people change
+ * their start/stop chars. As long as they can't we can't get
+ * into trouble so we just leave them alone.
+ */
+ if (tty.c_cc[VSTART] != CTRL(q))
+ tty.c_cc[VSTART] = '\377';
+ if (tty.c_cc[VSTOP] != CTRL(s))
+ tty.c_cc[VSTOP] = '\377';
+# endif
+}
+#endif
+