From 92b63576052fd29dacbc3db5dc9177ca7684d14d Mon Sep 17 00:00:00 2001 From: shivers Date: Thu, 19 Oct 1995 08:22:56 +0000 Subject: [PATCH] Hacked tty stuff; added .cvsignore files. --- .gitignore | 9 + Makefile.in | 7 +- cig/.gitignore | 2 + scsh/.gitignore | 3 + scsh/hpux/tty-consts.scm | 251 +++++++++++++++++++++++++++ scsh/next/tty-consts.scm | 272 ++++++++++++++++++++++++++++++ scsh/regexp/.gitignore | 1 + scsh/scsh-interfaces.scm | 355 ++++++++++++++++++++++++--------------- scsh/scsh-package.scm | 14 +- scsh/tty-consts.scm | 184 -------------------- scsh/tty.scm | 46 ++--- scsh/tty1.c | 17 +- 12 files changed, 819 insertions(+), 342 deletions(-) create mode 100644 cig/.gitignore create mode 100644 scsh/.gitignore create mode 100644 scsh/hpux/tty-consts.scm create mode 100644 scsh/next/tty-consts.scm create mode 100644 scsh/regexp/.gitignore delete mode 100644 scsh/tty-consts.scm diff --git a/.gitignore b/.gitignore index da8168b..d2e1ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,12 @@ _$* *.ln core # CVS default ignores end +Makefile +config.log +config.cache +config.status +sysdep.h +script +scsh.1 +scheme48.image +scshvm diff --git a/Makefile.in b/Makefile.in index 533496d..c96b765 100644 --- a/Makefile.in +++ b/Makefile.in @@ -111,8 +111,8 @@ SCSHOBJS = \ scsh/re.o \ scsh/rescm.o \ scsh/syscalls.o scsh/syscalls1.o \ - scsh/tty.o scsh/tty1.o \ scsh/time.o scsh/time1.o \ + scsh/tty.o scsh/tty1.o \ scsh/userinfo.o \ scsh/regexp/libregexp.a \ scsh/rdelim.o \ @@ -525,8 +525,9 @@ SCHEME =scsh/defrec.scm \ scsh/machine/netconst.scm \ scsh/machine/packages.scm \ scsh/machine/signals.scm \ - scsh/machine/waitcodes.scm \ scsh/machine/time_dep.scm \ + scsh/machine/tty-consts.scm \ + scsh/machine/waitcodes.scm \ scsh/network.scm \ scsh/newports.scm \ scsh/procobj.scm \ @@ -541,9 +542,9 @@ SCHEME =scsh/defrec.scm \ scsh/syntax-helpers.scm \ scsh/syntax.scm \ scsh/syscalls.scm \ - scsh/tty.scm scsh/tty-consts.scm \ scsh/time.scm \ scsh/top.scm \ + scsh/tty.scm \ scsh/utilities.scm # scsh/dbm.scm diff --git a/cig/.gitignore b/cig/.gitignore new file mode 100644 index 0000000..673b46f --- /dev/null +++ b/cig/.gitignore @@ -0,0 +1,2 @@ +cig +cig.image diff --git a/scsh/.gitignore b/scsh/.gitignore new file mode 100644 index 0000000..f653657 --- /dev/null +++ b/scsh/.gitignore @@ -0,0 +1,3 @@ +tty.c +scsh.image +scsh diff --git a/scsh/hpux/tty-consts.scm b/scsh/hpux/tty-consts.scm new file mode 100644 index 0000000..66917ae --- /dev/null +++ b/scsh/hpux/tty-consts.scm @@ -0,0 +1,251 @@ +;;; Constant definitions for tty control code (POSIX termios). +;;; Copyright (c) 1995 by Brian Carlstrom. +;;; Largely rehacked by Olin. + +;;; These constants are for HP-UX, +;;; and are taken from /usr/include/sys/termio.h. + +;;; Non-standard (POSIX, SVR4, 4.3+BSD) things: +;;; - Some of the baud rates. + + +;;; Special Control Characters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Indices into the c_cc[] character array. + +;;; Name Subscript Enabled by +;;; ---- --------- ---------- +;;; POSIX +(define ttychar/eof 4) ; ^d icanon +(define ttychar/eol 5) ; icanon +(define ttychar/erase 2) ; ^? icanon +(define ttychar/kill 3) ; ^u icanon +(define ttychar/intr 0) ; ^c isig +(define ttychar/quit 1) ; ^\ isig +(define ttychar/susp 13) ; ^z isig +(define ttychar/start 14) ; ^q ixon, ixoff +(define ttychar/stop 15) ; ^s ixon, ixoff +(define ttychar/min 11) ; !icanon ; Not exported +(define ttychar/time 12) ; !icanon ; Not exported + +;;; SVR4 & 4.3+BSD +(define ttychar/word-erase #f) ; ^w icanon +(define ttychar/reprint #f) ; ^r icanon +(define ttychar/lnext #f) ; ^v iexten +(define ttychar/discard #f) ; ^o iexten +(define ttychar/dsusp #f) ; ^y isig +(define ttychar/eol2 #f) ; icanon + +;;; 4.3+BSD +(define ttychar/status #f) ; ^t icanon + +;;; Length of control-char string -- *Not Exported* +(define num-ttychars 16) + +;;; Magic "disable feature" tty character +(define disable-tty-char (ascii->char #xff)) ; _POSIX_VDISABLE + + + +;;; Flags controllling input processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyin/ignore-break #o00001) ; ignbrk +(define ttyin/interrupt-on-break #o00002) ; brkint +(define ttyin/ignore-bad-parity-chars #o00004) ; ignpar +(define ttyin/mark-parity-errors #o00010) ; parmrk +(define ttyin/check-parity #o00020) ; inpck +(define ttyin/strip-bit-8 #o00040) ; istrip +(define ttyin/nl->cr #o00100) ; inlcr +(define ttyin/ignore-cr #o00200) ; igncr +(define ttyin/cr->nl #o00400) ; icrnl +(define ttyin/output-flow-ctl #o02000) ; ixon +(define ttyin/input-flow-ctl #o10000) ; ixoff + +;;; SVR4 & 4.3+BSD +(define ttyin/xon-any #o4000) ; ixany: Any char restarts after stop +(define ttyin/beep-on-overflow #f) ; imaxbel: queue full => ring bell + +;;; SVR4 +(define ttyin/lowercase #o1000) ; iuclc: Map upper-case to lower case + + +;;; Flags controlling output processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyout/enable #o000001) ; opost: enable output processing + +;;; SVR4 & 4.3+BSD +(define ttyout/nl->crnl #o000004) ; onlcr: map nl to cr-nl + +;;; 4.3+BSD +(define ttyout/discard-eot #f) ; onoeot +(define ttyout/expand-tabs #f) ; oxtabs (NOT xtabs) + +;;; SVR4 +(define ttyout/cr->nl #o000010) ; ocrnl +(define ttyout/fill-w/del #o000200) ; ofdel +(define ttyout/delay-w/fill-char #o000100) ; ofill +(define ttyout/uppercase #o000002) ; olcuc +(define ttyout/nl-does-cr #o000040) ; onlret +(define ttyout/no-col0-cr #o000020) ; onocr + +;;; Newline delay +(define ttyout/nl-delay #o000400) ; mask (nldly) +(define ttyout/nl-delay0 #o000000) +(define ttyout/nl-delay1 #o000400) ; tty 37 + +;;; Horizontal-tab delay +(define ttyout/tab-delay #o014000) ; mask (tabdly) +(define ttyout/tab-delay0 #o000000) +(define ttyout/tab-delay1 #o004000) ; tty 37 +(define ttyout/tab-delay2 #o010000) +(define ttyout/tab-delayx #o014000) ; Expand tabs (xtabs, tab3) + +;;; Carriage-return delay +(define ttyout/cr-delay #o003000) ; mask (crdly) +(define ttyout/cr-delay0 #o000000) +(define ttyout/cr-delay1 #o001000) ; tn 300 +(define ttyout/cr-delay2 #o002000) ; tty 37 +(define ttyout/cr-delay3 #o003000) ; concept 100 + +;;; Vertical tab delay +(define ttyout/vtab-delay #o040000) ; mask (vtdly) +(define ttyout/vtab-delay0 #o000000) +(define ttyout/vtab-delay1 #o040000) ; tty 37 + +;;; Backspace delay +(define ttyout/bs-delay #o020000) ; mask (bsdly) +(define ttyout/bs-delay0 #o000000) +(define ttyout/bs-delay1 #o020000) + +;;; Form-feed delay +(define ttout/ff-delay #o100000) ; mask (ffdly) +(define ttyout/ff-delay0 #o000000) +(define ttyout/ff-delay1 #o100000) + +(define ttyout/all-delay + (bitwise-ior (bitwise-ior (bitwise-ior ttyout/nl-delay ttyout/tab-delay) + (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) + (bitwise-ior ttyout/bs-delay ttout/ff-delay))) + + +;;; Control flags - hacking the serial-line. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyc/char-size #o00140) ; csize: character size mask +(define ttyc/char-size5 #o00000) ; 5 bits (cs5) +(define ttyc/char-size6 #o00040) ; 6 bits (cs6) +(define ttyc/char-size7 #o00100) ; 7 bits (cs7) +(define ttyc/char-size8 #o00140) ; 8 bits (cs8) +(define ttyc/2-stop-bits #o00200) ; cstopb: Send 2 stop bits. +(define ttyc/enable-read #o00400) ; cread: Enable receiver. +(define ttyc/enable-parity #o01000) ; parenb +(define ttyc/odd-parity #o02000) ; parodd +(define ttyc/hup-on-close #o04000) ; hupcl: Hang up on last close. +(define ttyc/no-modem-sync #o10000) ; clocal: Ignore modem lines. + +;;; 4.3+BSD +(define ttyc/ignore-flags #f) ; cignore: ignore control flags +(define ttyc/CTS-output-flow-ctl #f) ; ccts_oflow: CTS flow control of output +(define ttyc/RTS-input-flow-ctl #f) ; crts_iflow: RTS flow control of input +(define ttyc/carrier-flow-ctl #f) ; mdmbuf + +;;; Local flags -- hacking the tty driver / user interface. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyl/visual-erase #o020) ; echoe: Visually erase chars +(define ttyl/echo-line-kill #o040) ; echok: Echo nl after line kill +(define ttyl/echo #o010) ; echo: Enable echoing +(define ttyl/echo-nl #o100) ; echonl: Echo nl even if echo is off +(define ttyl/canonical #o002) ; icanon: Canonicalize input +(define ttyl/enable-signals #o001) ; isig: Enable ^c, ^z signalling +(define ttyl/extended #o20000000000); iexten: Enable extensions +(define ttyl/ttou-signal #o10000000000); tostop: SIGTTOU on background output +(define ttyl/no-flush-on-interrupt #o200) ; noflsh + +;;; SVR4 & 4.3+BSD +(define ttyl/visual-line-kill #f) ; echoke: visually erase a line-kill +(define ttyl/hardcopy-erase #f) ; echoprt: visual erase for hardcopy +(define ttyl/echo-ctl #f) ; echoctl: echo control chars as "^X" +(define ttyl/flush-output #f) ; flusho: output is being flushed +(define ttyl/reprint-unread-chars #f) ; pendin: retype pending input + +;;; 4.3+BSD +(define ttyl/alt-word-erase #f) ; altwerase +(define ttyl/no-kernel-status #f) ; nokerninfo: no kernel status on ^T + +;;; SVR4 +(define ttyl/case-map #o4) ; xcase: canonical upper/lower presentation + + +;;; Baud Rates +(define baud/0 0) +(define baud/50 1) +(define baud/75 2) +(define baud/110 3) +(define baud/134 4) +(define baud/150 5) +(define baud/200 6) +(define baud/300 7) +(define baud/600 8) +(define baud/900 9) ; Non-standard +(define baud/1200 10) +(define baud/1800 11) +(define baud/2400 12) +(define baud/3600 13) ; Non-standard +(define baud/4800 14) +(define baud/7200 15) ; Non-standard +(define baud/9600 16) +(define baud/19200 17) +(define baud/38400 18) +(define baud/57600 19) ; Non-standard +(define baud/115200 20) ; Non-standard +(define baud/230400 21) ; Non-standard +(define baud/460800 22) ; Non-standard +(define baud/exta 30) ; Non-standard +(define baud/extb 31) ; Non-standard + +;;; Rather cheesy mechanism here. +;;; Vector of lists because some OS's define EXTA and EXTB to be +;;; the same code as 19.2k and 38.4k baud. + +(define baud-rates '#((0) (50) (75) + (110) (134) (150) + (200) (300) (600) + (900) (1200) (1800) + (2400) (3600) (4800) + (7200) (9600) (19200) + (38400) (57600) (115200) + (230400) (460800) #f + #f #f #f #f #f #f ; 24-29 + (exta) (extb))) + + +;;; tcflush() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %flush-tty/input 0) ; TCIFLUSH +(define %flush-tty/output 1) ; TCOFLUSH +(define %flush-tty/both 2) ; TCIOFLUSH + + +;;; tcflow() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %tcflow/start-out 1) ; TCOON +(define %tcflow/stop-out 0) ; TCOOFF +(define %tcflow/start-in 3) ; TCION +(define %tcflow/stop-in 2) ; TCIOFF + + +;;; tcsetattr() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %set-tty-info/now 0) ; TCSANOW Make change immediately. +(define %set-tty-info/drain 1) ; TCSADRAIN Drain output, then change. +(define %set-tty-info/flush 2) ; TCSAFLUSH Drain output, flush input. diff --git a/scsh/next/tty-consts.scm b/scsh/next/tty-consts.scm new file mode 100644 index 0000000..ec797b7 --- /dev/null +++ b/scsh/next/tty-consts.scm @@ -0,0 +1,272 @@ +;;; Constant definitions for tty control code (POSIX termios). +;;; Copyright (c) 1995 by Brian Carlstrom. +;;; Largely rehacked by Olin. + +;;; These constants are for NeXTSTEP 3.x, +;;; and are taken from /usr/include/bsd/sys/termios.h and +;;; /usr/include/bsd/sys/ttydev.h + +;;; Non-standard (POSIX, SVR4, 4.3+BSD) things: +;;; - Useless ttychar/quote char. +;;; - Two extra newline delay values +;;; - Some control and local flags: +;;; ttyc/2-stop-bits-when-110-baud stopb110 +;;; ttyc/parity0 par0 +;;; ttyc/parity1 par1 +;;; ttyl/crt-erase echocrt +;;; ttyl/xlcase xlcase Vas ist das? +;;; ttyl/xeucbksp xeucbksp 'n das? +;;; - Some baud rates + + +;;; Special Control Characters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Indices into the c_cc[] character array. + +;;; Name Subscript Enabled by +;;; ---- --------- ---------- +;;; POSIX +(define ttychar/eof 0) ; ^d icanon +(define ttychar/eol 1) ; icanon +(define ttychar/erase 2) ; ^? icanon +(define ttychar/kill 3) ; ^u icanon +(define ttychar/intr 4) ; ^c isig +(define ttychar/quit 5) ; ^\ isig +(define ttychar/susp 6) ; ^z isig +(define ttychar/start 7) ; ^q ixon, ixoff +(define ttychar/stop 8) ; ^s ixon, ixoff +(define ttychar/min 9) ; !icanon ; Not exported +(define ttychar/time 10) ; !icanon ; Not exported + +;;; SVR4 & 4.3+BSD +(define ttychar/word-erase 11) ; ^w icanon +(define ttychar/reprint 12) ; ^r icanon +(define ttychar/lnext 13) ; ^v iexten +(define ttychar/discard 14) ; ^o iexten +(define ttychar/dsusp 15) ; ^y isig +(define ttychar/eol2 #f) ; icanon + +;;; 4.3+BSD +(define ttychar/status #f) ; ^t icanon + +;;; NeXT +(define ttychar/quote 16) ; icanon + +;;; Length of control-char string -- *Not Exported* +(define num-ttychars 17) + +;;; Magic "disable feature" tty character +(define disable-tty-char (ascii->char #xff)) + + + +;;; Flags controllling input processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyin/ignore-break #x0001) ; ignbrk +(define ttyin/interrupt-on-break #x0002) ; brkint +(define ttyin/ignore-bad-parity-chars #x0004) ; ignpar +(define ttyin/mark-parity-errors #x0008) ; parmrk +(define ttyin/check-parity #x0010) ; inpck +(define ttyin/strip-bit-8 #x0020) ; istrip +(define ttyin/nl->cr #x0040) ; inlcr +(define ttyin/ignore-cr #x0080) ; igncr +(define ttyin/cr->nl #x0100) ; icrnl +(define ttyin/output-flow-ctl #x0200) ; ixon +(define ttyin/input-flow-ctl #x0400) ; ixoff + + +;;; SVR4 & 4.3+BSD +(define ttyin/xon-any #x0800) ; ixany: Any char restarts after stop +(define ttyin/beep-on-overflow #x2000) ; imaxbel: queue full => ring bell + +;;; SVR4 +(define ttyin/lowercase #f) ; iuclc: Map upper-case to lower case + + +;;; Flags controlling output processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyout/enable #x0001) ; opost: enable output processing + +;;; SVR4 & 4.3+BSD +(define ttyout/nl->crnl #x0002) ; onlcr: map nl to cr-nl + +;;; 4.3+BSD +(define ttyout/discard-eot #f) ; onoeot +(define ttyout/expand-tabs #f) ; oxtabs (NOT xtabs) + +;;; SVR4 +(define ttyout/cr->nl #f) ; ocrnl +(define ttyout/fill-w/del #f) ; ofdel +(define ttyout/delay-w/fill-char #f) ; ofill +(define ttyout/uppercase #f) ; olcuc +(define ttyout/nl-does-cr #f) ; onlret +(define ttyout/no-col0-cr #f) ; onocr + +;;; Newline delay +(define ttyout/nl-delay #x0300) ; mask (nldly) +(define ttyout/nl-delay0 #x0000) +(define ttyout/nl-delay1 #x0100) ; tty 37 +(define ttyout/nl-delay2 #x0200) ; vt05 Non-standard +(define ttyout/nl-delay3 #x0300) ; Non-standard + +;;; Horizontal-tab delay +(define ttyout/tab-delay #x0c00) ; mask (tabdly) +(define ttyout/tab-delay0 #x0000) +(define ttyout/tab-delay1 #x0400) ; tty 37 +(define ttyout/tab-delay2 #x0800) +(define ttyout/tab-delayx #x0c00) ; Expand tabs (xtabs, tab3) + +;;; Carriage-return delay +(define ttyout/cr-delay #x3000) ; mask (crdly) +(define ttyout/cr-delay0 #x0000) +(define ttyout/cr-delay1 #x1000) ; tn 300 +(define ttyout/cr-delay2 #x2000) ; tty 37 +(define ttyout/cr-delay3 #x3000) ; concept 100 + +;;; Vertical tab delay +(define ttyout/vtab-delay #x4000) ; mask (vtdly) +(define ttyout/vtab-delay0 #x0000) +(define ttyout/vtab-delay1 #x4000) ; tty 37 + +;;; Backspace delay +(define ttyout/bs-delay #x8000) ; mask (bsldy) +(define ttyout/bs-delay0 #x0000) +(define ttyout/bs-delay1 #x8000) + +;;; Form-feed delay -- appears to be rolled into the vertical-tab delay. +(define ttout/ff-delay ttyout/vtab-delay) ; mask (ffdly) +(define ttyout/ff-delay0 ttyout/vtab-delay0) +(define ttyout/ff-delay1 ttyout/vtab-delay1) + +(define ttyout/all-delay + (bitwise-ior (bitwise-ior (bitwise-ior ttyout/nl-delay ttyout/tab-delay) + (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) + (bitwise-ior ttyout/bs-delay ttout/ff-delay))) + + +;;; Control flags - hacking the serial-line. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyc/char-size #x0300) ; csize: character size mask +(define ttyc/char-size5 #x0000) ; 5 bits (cs5) +(define ttyc/char-size6 #x0100) ; 6 bits (cs6) +(define ttyc/char-size7 #x0200) ; 7 bits (cs7) +(define ttyc/char-size8 #x0300) ; 8 bits (cs8) +(define ttyc/2-stop-bits #x0400) ; cstopb: Send 2 stop bits. +(define ttyc/enable-read #x0800) ; cread: Enable receiver. +(define ttyc/enable-parity #x1000) ; parenb +(define ttyc/odd-parity #x2000) ; parodd +(define ttyc/hup-on-close #x4000) ; hupcl: Hang up on last close. +(define ttyc/no-modem-sync #x8000) ; clocal: Ignore modem lines. + +;;; 4.3+BSD +(define ttyc/ignore-flags #x0001); cignore: ignore control flags +(define ttyc/CTS-output-flow-ctl #f) ; ccts_oflow: CTS flow control of output +(define ttyc/RTS-input-flow-ctl #f) ; crts_iflow: RTS flow control of input +(define ttyc/carrier-flow-ctl #f) ; mdmbuf + +;;; NeXT +(define ttyc/2-stop-bits-when-110-baud #x010000) ; stopb110 +(define ttyc/parity0 #x20000) ; par0 +(define ttyc/parity1 #x40000) ; par1 + + +;;; Local flags -- hacking the tty driver / user interface. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyl/visual-erase #x000002) ; echoe: Visually erase chars +(define ttyl/echo-line-kill #x000004) ; echok: Echo nl after line kill +(define ttyl/echo #x000008) ; echo: Enable echoing +(define ttyl/echo-nl #x000010) ; echonl: Echo nl even if echo is off +(define ttyl/canonical #x000020) ; icanon: Canonicalize input +(define ttyl/enable-signals #x000040) ; isig: Enable ^c, ^z signalling +(define ttyl/extended #x000080) ; iexten: Enable extensions +(define ttyl/ttou-signal #x400000) ; tostop: SIGTTOU on background output +(define ttyl/no-flush-on-interrupt #x80000000) ; noflsh + +;;; SVR4 & 4.3+BSD +(define ttyl/visual-line-kill #x001) ; echoke: visually erase a line-kill +(define ttyl/hardcopy-erase #x200) ; echoprt: visual erase for hardcopy +(define ttyl/echo-ctl #x400) ; echoctl: echo control chars as "^X" +(define ttyl/flush-output #f) ; flusho: output is being flushed +(define ttyl/reprint-unread-chars #f) ; pendin: retype pending input + +;;; 4.3+BSD +(define ttyl/alt-word-erase #x800) ; altwerase +(define ttyl/no-kernel-status #f) ; nokerninfo: no kernel status on ^T + +;;; SVR4 +(define ttyl/case-map #f) ; xcase: canonical upper/lower presentation + +;;; NeXT +(define ttyl/crt-erase #x00000100) ; visual erase does "\b \b" +(define ttyl/xlcase #x04000000) ; Vas ist das? +(define ttyl/xeucbksp #x08000000) ; 'n das? + +;;; NOTE: xlcase and xeucbksp are in the NeXT , but don't appear +;;; in the tty(4) or termios(4) man pages. Where are they documented? + + +;;; Baud Rates +(define baud/0 0) +(define baud/50 1) +(define baud/75 2) +(define baud/110 3) +(define baud/134 4) +(define baud/150 5) +(define baud/200 6) +(define baud/300 7) +(define baud/600 8) +(define baud/1200 9) +(define baud/1800 10) +(define baud/2400 11) +(define baud/4800 12) +(define baud/9600 13) +(define baud/19200 14) +(define baud/38400 15) +(define baud/exta baud/19200) ; Non-standard +(define baud/extb baud/38400) ; Non-standard +(define baud/14400 16) ; Non-standard +(define baud/28800 17) ; Non-standard +(define baud/43200 18) ; Non-standard +(define baud/57600 19) ; Non-standard + + +;;; Rather cheesy mechanism here. +;;; Vector of lists because some OS's define EXTA and EXTB to be +;;; the same code as 19.2k and 38.4k baud. + +(define baud-rates '#((0) (50) (75) (110) (134) (150) + (200) (300) (600) (1200) (1800) (2400) + (4800) (9600) (19200 exta) (38400 extb) + (14400) (28800) (43200) (57600))) + +;;; tcflush() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %flush-tty/input 0) ; TCIFLUSH +(define %flush-tty/output 1) ; TCOFLUSH +(define %flush-tty/both 2) ; TCIOFLUSH + + +;;; tcflow() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %tcflow/stop-out 1) ; TCOOFF +(define %tcflow/start-out 2) ; TCOON +(define %tcflow/stop-in 3) ; TCIOFF +(define %tcflow/start-in 4) ; TCION + + +;;; tcsetattr() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %set-tty-info/now 0) ; TCSANOW Make change immediately. +(define %set-tty-info/drain 1) ; TCSADRAIN Drain output, then change. +(define %set-tty-info/flush 2) ; TCSAFLUSH Drain output, flush input. diff --git a/scsh/regexp/.gitignore b/scsh/regexp/.gitignore new file mode 100644 index 0000000..f3c7a7c --- /dev/null +++ b/scsh/regexp/.gitignore @@ -0,0 +1 @@ +Makefile diff --git a/scsh/scsh-interfaces.scm b/scsh/scsh-interfaces.scm index 9f05caf..06bb5cc 100644 --- a/scsh/scsh-interfaces.scm +++ b/scsh/scsh-interfaces.scm @@ -724,135 +724,228 @@ recno-info? make-recno-info)) -(define-interface scsh-terminal-interface - (export tcgetattr - tcsetattr - terminal-info? - terminal-info:input-flags - terminal-info:output-flags - terminal-info:control-flags - terminal-info:local-flags - set-terminal-info:input-flags - set-terminal-info:output-flags - set-terminal-info:control-flags - set-terminal-info:local-flags - tc/set-attributes/now - tc/set-attributes/drain - tc/set-attributes/flush - cc/veof - cc/veol - cc/verase - cc/vkill - cc/vintr - cc/vquit - cc/vsusp - cc/vstart - cc/vstop - cc/vmin - cc/vtime - ;; NeXT - cc/vwerase - cc/vreprint - cc/vlnext - cc/vdiscard - cc/vdsusp - cc/vquote - iflag/ignbrk - iflag/brkint - iflag/ignpar - iflag/parmrk - iflag/inpck - iflag/istrip - iflag/inlcr - iflag/igncr - iflag/icrnl - iflag/ixon - iflag/ixoff - ;;next - iflag/ixany - iflag/imaxbel - ;; POSIX - oflag/opost - ;; NeXT - oflag/onlcr - ; use the same bits as old delay flags - oflag/nldelay - oflag/nl0 - oflag/nl1 - oflag/nl2 - oflag/nl3 - oflag/tbdelay - oflag/tab0 - oflag/tab1 - oflag/tab2 - oflag/xtabs - oflag/crdelay - oflag/cr0 - oflag/cr1 - oflag/cr2 - oflag/cr3 - oflag/vtdelay - oflag/ff0 - oflag/ff1 - oflag/bsdelay - oflag/bs0 - oflag/bs1 - oflag/alldelay - ;; NeXT - cflag/cignore - ;; POSIX - cflag/csize - cflag/cs5 - cflag/cs6 - cflag/cs7 - cflag/cs8 - cflag/cstopb - cflag/cread - cflag/parenb - cflag/parodd - cflag/hupcl - cflag/clocal - ;; NeXT - cflag/cstopb110 - cflag/par0 - cflag/par1 - ;; NeXT - lflag/echoke - ;; POSIX - lflag/echoe - lflag/echok - lflag/echo - lflag/echonl - lflag/icanon - lflag/isig - lflag/iexten - ;; NeXT - lflag/echocrt - lflag/echoprt - lflag/echoctl - lflag/altwerase - lflag/mdmbuf - ;; POSIX - lflag/tostop - ;; NeXT - lflag/xlcase - lflag/xeucbksp - ;; POSIX - lflag/noflsh - baud/0 - baud/50 - baud/75 - baud/110 - baud/134 - baud/150 - baud/200 - baud/300 - baud/600 - baud/1200 - baud/1800 - baud/2400 - baud/4800 - baud/9600 - baud/19200 - baud/38400 +;;; Magic flags for SCSH-TTY-INTERFACE. +(define-interface tty-flags-interface + (export + ;; Indices into the control char string + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Posix + ttychar/eof + ttychar/eol + ttychar/erase + ttychar/kill + ttychar/intr + ttychar/quit + ttychar/susp + ttychar/start + ttychar/stop + ttychar/min + ttychar/time + + ;; SVR4 & 4.3+BSD + ttychar/word-erase + ttychar/reprint + ttychar/lnext + ttychar/discard + ttychar/dsusp + ttychar/eol2 + + ;; 4.3+BSD + ttychar/status + + disable-tty-char + + ;; Input flag bits + ;;;;;;;;;;;;;;;;;; + ;; Posix + ttyin/ignore-break + ttyin/interrupt-on-break + ttyin/ignore-bad-parity-chars + ttyin/mark-parity-errors + ttyin/check-parity + ttyin/strip-bit-8 + ttyin/nl->cr + ttyin/ignore-cr + ttyin/cr->nl + ttyin/output-flow-ctl + ttyin/input-flow-ctl + + ;; SVR4 & 4.3+BSD + ttyin/xon-any + ttyin/beep-on-overflow + + ;; SVR4 + ttyin/lowercase + + ;; Output flag bits + ;;;;;;;;;;;;;;;;;;; + ttyout/enable ; opost: enable output processing + + ;; SVR4 & 4.3+BSD + ttyout/nl->crnl ; onlcr: map nl to cr-nl + + ;; 4.3+BSD + ttyout/discard-eot ; onoeot + ttyout/expand-tabs ; oxtabs (NOT xtabs) + + ;; SVR4 + ttyout/cr->nl ; ocrnl + ttyout/fill-w/del ; ofdel + ttyout/delay-w/fill-char ; ofill + ttyout/uppercase ; olcuc + ttyout/nl-does-cr ; onlret + ttyout/no-col0-cr ; onocr + + ;; Newline delay + ttyout/nl-delay ; mask (nldly) + ttyout/nl-delay0 + ttyout/nl-delay1 ; tty 37 + + ;; Horizontal-tab delay + ttyout/tab-delay ; mask (tabdly) + ttyout/tab-delay0 + ttyout/tab-delay1 ; tty 37 + ttyout/tab-delay2 + ttyout/tab-delayx ; Expand tabs (xtabs, tab3) + + ;; Carriage-return delay + ttyout/cr-delay ; mask (crdly) + ttyout/cr-delay0 + ttyout/cr-delay1 ; tn 300 + ttyout/cr-delay2 ; tty 37 + ttyout/cr-delay3 ; concept 100 + + ;; Vertical tab delay + ttyout/vtab-delay ; mask (vtdly) + ttyout/vtab-delay0 + ttyout/vtab-delay1 ; tty 37 + + ;; Backspace delay + ttyout/bs-delay ; mask (bsdly) + ttyout/bs-delay0 + ttyout/bs-delay1 + + ;; Form-feed delay + ttout/ff-delay ; mask (ffdly) + ttyout/ff-delay0 + ttyout/ff-delay1 + + ttyout/all-delay + + + ;; Control flag bits + ;;;;;;;;;;;;;;;;;;;; + ;; Posix + ttyc/char-size ; csize: character size mask + ttyc/char-size5 ; 5 bits (cs5) + ttyc/char-size6 ; 6 bits (cs6) + ttyc/char-size7 ; 7 bits (cs7) + ttyc/char-size8 ; 8 bits (cs8) + ttyc/2-stop-bits ; cstopb: Send 2 stop bits. + ttyc/enable-read ; cread: Enable receiver. + ttyc/enable-parity ; parenb + ttyc/odd-parity ; parodd + ttyc/hup-on-close ; hupcl: Hang up on last close. + ttyc/no-modem-sync ; clocal: Ignore modem lines. + + ;; 4.3+BSD + ttyc/ignore-flags ; cignore: ignore control flags + ttyc/CTS-output-flow-ctl ; ccts_oflow: CTS flow control of output + ttyc/RTS-input-flow-ctl ; crts_iflow: RTS flow control of input + ttyc/carrier-flow-ctl ; mdmbuf + + ;; Local flag bits + ;;;;;;;;;;;;;;;;;; + ;; POSIX + ttyl/visual-erase ; echoe: Visually erase chars + ttyl/echo-line-kill ; echok: Echo nl after line kill + ttyl/echo ; echo: Enable echoing + ttyl/echo-nl ; echonl: Echo nl even if echo is off + ttyl/canonical ; icanon: Canonicalize input + ttyl/enable-signals ; isig: Enable ^c, ^z signalling + ttyl/extended ; iexten: Enable extensions + ttyl/ttou-signal ; tostop: SIGTTOU on background output + ttyl/no-flush-on-interrupt ; noflsh + + ;; SVR4 & 4.3+BSD + ttyl/visual-line-kill ; echoke: visually erase a line-kill + ttyl/hardcopy-erase ; echoprt: visual erase for hardcopy + ttyl/echo-ctl ; echoctl: echo control chars as "^X" + ttyl/flush-output ; flusho: output is being flushed + ttyl/reprint-unread-chars ; pendin: retype pending input + + ;; 4.3+BSD + ttyl/alt-word-erase ; altwerase + ttyl/no-kernel-status ; nokerninfo: no kernel status on ^T + + ;; SVR4 + ttyl/case-map ; xcase: canonical upper/lower presentation + + ;; Baud Rates + baud/0 baud/50 baud/75 baud/110 + baud/134 baud/150 baud/200 baud/300 + baud/600 baud/1200 baud/1800 baud/2400 + baud/4800 baud/9600 baud/19200 baud/38400 )) + +;;; Non-exported values required by the tty code. +(define-interface scsh-internal-tty-flags-interface + (export baud-rates + num-ttychars + + ;; tcflush() constants + %flush-tty/input ; TCIFLUSH + %flush-tty/output ; TCOFLUSH + %flush-tty/both ; TCIOFLUSH + + ;; tcflow() constants + %tcflow/start-out ; TCOON + %tcflow/stop-out ; TCOOFF + %tcflow/start-in ; TCION + %tcflow/stop-in ; TCIOFF + + ;; tcsetattr() constants + %set-tty-info/now ; TCSANOW Make change immediately. + %set-tty-info/drain ; TCSADRAIN Drain output, then change. + %set-tty-info/flush ; TCSAFLUSH Drain output, flush input. + )) + + +;;; POSIX termios tty control. +(define-interface tty-interface + (compound-interface + tty-flags-interface + (export + ;; The tty-info record + tty-info? type/tty-info + tty-info:control-chars set-tty-info:control-chars + tty-info:input-flags set-tty-info:input-flags + tty-info:output-flags set-tty-info:output-flags + tty-info:control-flags set-tty-info:control-flags + tty-info:local-flags set-tty-info:local-flags + tty-info:input-speed set-tty-info:input-speed + tty-info:output-speed set-tty-info:output-speed + tty-info:min set-tty-info:min + tty-info:time set-tty-info:time + + make-tty-info copy-tty-info + + tty-info + set-tty-info/now + set-tty-info/drain + set-tty-info/flush + + send-tty-break + drain-tty + flush-tty/input + flush-tty/output + flush-tty/both + + start-tty-output + stop-tty-output + start-tty-input + stop-tty-input + + encode-baud-rate + decode-baud-rate + ))) diff --git a/scsh/scsh-package.scm b/scsh/scsh-package.scm index fec2cb2..595d53f 100644 --- a/scsh/scsh-package.scm +++ b/scsh/scsh-package.scm @@ -5,7 +5,7 @@ ;;; It is defined in rdelim.scm. ;;; You link up a scsh package by defining a package named OS-DEPENDENT -;;; that provides the interfaces +;;; that satisfies the interfaces for packages ;;; buffered-io-flags ;;; posix-fdflags ;;; posix-errno @@ -93,6 +93,12 @@ (begin (define-syntax awk expand-awk))) +(define-structures ((tty-flags tty-flags-interface) + (scsh-internal-tty-flags scsh-internal-tty-flags-interface)) + (open scheme ascii bitwise) + (files (machine tty-consts))) + + (define-structure scsh-version scsh-version-interface (open scheme) (files scsh-version)) @@ -130,7 +136,7 @@ scsh-high-level-process-interface scsh-time-interface ; new in 0.2 scsh-sockets-interface ; new in 0.3 - ; scsh-terminal-interface ; under construction + tty-interface ; new in 0.4 scsh-version-interface char-set-interface ;; This stuff would probably be better off kept @@ -165,6 +171,8 @@ scsh-regexp-package char-set-package scsh-version + tty-flags + scsh-internal-tty-flags ; Not exported scheme ) @@ -200,7 +208,7 @@ (machine time_dep) network ; New in release 0.3. flock ; New in release 0.4. -; tc ; Under construction -bri + tty ; New in release 0.4. scsh )) diff --git a/scsh/tty-consts.scm b/scsh/tty-consts.scm deleted file mode 100644 index ac04eb6..0000000 --- a/scsh/tty-consts.scm +++ /dev/null @@ -1,184 +0,0 @@ -;;; Constant definitions for tty control code (POSIX termios). -;;; Copyright (c) 1995 by Brian Carlstrom. -;;; Largely rehacked by Olin. - -;;; Values taken from HP-UX /usr/include/sys/termio.h. - -;;; Special Control Characters -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Indices into the c_cc[] character array. - -;;; Name Subscript Enabled by -;;; ---- --------- ---------- -;; POSIX -(define ttychar/intr 0) ; isig -(define ttychar/quit 1) ; isig -(define ttychar/erase 2) ; icanon -(define ttychar/kill 3) ; icanon -(define ttychar/eof 4) ; icanon -(define ttychar/eol 5) ; icanon - -(define ttychar/min 11) ; !icanon ; Not exported -(define ttychar/time 12) ; !icanon ; Not exported -(define ttychar/susp 13) ; isig -(define ttychar/start 14) ; ixon, ixoff -(define ttychar/stop 15) ; ixon, ixoff - -;; Number of Control Characters - *Not Exported* -(define num-ttychars 16) - - -;;; Flags controllling input processing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; POSIX -(define ttyin/ignore-break #x00000001) ; ignbrk -(define ttyin/interrupt-on-break #x00000002) ; brkint -(define ttyin/ignore-bad-parity-chars #x00000004) ; ignpar -(define ttyin/mark-parity-errors #x00000008) ; parmrk -(define ttyin/enable-parity #x00000010) ; inpck -(define ttyin/strip-8th #x00000020) ; istrip -(define ttyin/nl->cr #x00000040) ; inlcr -(define ttyin/ignore-cr #x00000080) ; igncr -(define ttyin/cr->nl #x00000100) ; icrnl -(define ttyin/output-flow-ctl #x00000400) ; ixon -(define ttyin/input-flow-ctl #x00001000) ; ixoff - -;; HP-UX -(define ttyin/xon-any #x00000800) ; _ixany: Any char will restart after stop. -(define ttyin/lowercase #x00002000) ; _iuclc: Map upper-case to lower-case. - - -;;; Flags controlling output processing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; POSIX -(define ttyout/process #x00000001) ; opost: enable output processing. - -;; HP-UX -(define ttyout/nl->crnl #x00000002) ; onlcr: map nl to cr-nl -(define ttyout/uppercase ) ; olcuc -(define ttyout/cr->nl ) ; ocrnl -(define ttyout/no-col0-cr ) ; onocr -(define ttyout/nl-does-cr ) ; onlret -(define ttyout/delay-w/fill-char ) ; ofill -(define ttyout/fill-w/del ) ; ofdel - -; use the same bits as old delay flags -(define ttyout/nl-delay #x00000300) ; \n delay -(define ttyout/nl-delay0 #x00000000) -(define ttyout/nl-delay1 #x00000100) ; tty 37 -(define ttyout/nl-delay2 #x00000200) ; vt05 -(define ttyout/nl-delay3 #x00000300) - -(define ttyout/tab-delay #x00000c00) ; horizontal tab delay -(define ttyout/tab-delay0 #x00000000) -(define ttyout/tab-delay1 #x00000400) ; tty 37 -(define ttyout/tab-delay2 #x00000800) -(define ttyout/expand-tabs #x00000c00) ; xtabs: expand tabs on output - -(define ttyout/cr-delay #x00003000) ; \r delay -(define ttyout/cr-delay0 #x00000000) -(define ttyout/cr-delay1 #x00001000) ; tn 300 -(define ttyout/cr-delay2 #x00002000) ; tty 37 -(define ttyout/cr-delay3 #x00003000) ; concept 100 - -(define ttyout/vtab-delay #x00004000) ; vertical tab delay -(define ttyout/vtab-delay0 #x00000000) -(define ttyout/vtab-delay1 #x00004000) ; tty 37 - -(define ttyout/bs-delay #x00008000) ; \b delay -(define ttyout/bs-delay0 #x00000000) -(define ttyout/bs-delay1 #x00008000) - -(define ttyout/all-delay (bitwise-ior - (bitwise-ior - (bitwise-ior ttyout/nl-delay ttyout/tab-delay) - (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) - ttyout/bs-delay)) - - -;;; Control flags - hardware control of terminal -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; POSIX -(define ttyc/char-size #x00000300) ; csize: character size mask -(define ttyc/char-size5 #x00000000) ; 5 bits (cs5) -(define ttyc/char-size6 #x00000100) ; 6 bits (cs6) -(define ttyc/char-size7 #x00000200) ; 7 bits (cs7) -(define ttyc/char-size8 #x00000300) ; 8 bits (cs8) -(define ttyc/2-stop-bits #x00000400) ; cstopb: Send 2 stop bits. -(define ttyc/read #x00000800) ; cread: Enable receiver. -(define ttyc/enable-parity #x00001000) ; parenb -(define ttyc/odd-parity #x00002000) ; parodd -(define ttyc/hup-on-close #x00004000) ; hupcl: Hang up on last close. -(define ttyc/no-modem-sync #x00008000) ; local: Ignore modem lines. - -;; NeXT -(define ttyc/ignore #x00000001) ; ignore control flags -(define ttyc/stopb110 #x00010000) ; VAS IST DAS? -Olin -(define ttyc/mark-parity #x00020000) ; par1 -(define ttyc/space-parity #x00040000) ; par0 - - -;;; "Local" flags - dumping ground for other state -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Warning: some flags in this structure begin with the -;; letter "I" and look like they belong in the input flag. - -;; POSIX -(define ttyl/echo-erase #x00000002) ; echoe: Visually erase chars. -(define ttyl/echo-kill #x00000004) ; echok: Echo nl after line kill. -(define ttyl/echo #x00000008) ; echo: Enable echoing. -(define ttyl/echo-nl #x00000010) ; echonl: Echo nl even if echo is off. -(define ttyl/icanon #x00000020) ; icanon: Canonicalize input. -(define ttyl/enable-signals #x00000040) ; isig: Enable ^c, ^z signalling. -(define ttyl/extended #x00000080) ; iexten: Enable extensions. -(define ttyl/ttou-signal #x00400000) ; itostop: Send SIGTTOU on background output. -(define ttyl/no-flush-on-interrupt #x80000000) ; noflsh: Don't flush after interrupt. - -;; NeXT -(define ttyl/visual-echo-kill #x00000001) ; echoke: visually erase line kill -(define ttyl/echo-crt #x00000100) ; visual erase mode for crt -(define ttyl/echo-printer #x00000200) ; visual erase mode for hardcopy -(define ttyl/echo-ctl #x00000400) ; echo control chars as ^(char) -(define ttyl/alt-word-erase #x00000800) ; use alternate werase algorithm -(define ttyl/carrier-sync #x00100000) ; mdmbuf flow control output via carrier -(define ttyl/xlcase #x04000000) ; VAS IST DAS? -(define ttyl/xeucbksp #x08000000) ; VAS IST DAS? - -;;; NOTE: altwerase xlcase and xeucbksp don't appear in the NeXT tty(4) man -;;; page. Where do they appear? - - -;;; Baud Rates -(define baud/0 0) -(define baud/50 1) -(define baud/75 2) -(define baud/110 3) -(define baud/134 4) -(define baud/150 5) -(define baud/200 6) -(define baud/300 7) -(define baud/600 8) -(define baud/1200 9) -(define baud/1800 10) -(define baud/2400 11) -(define baud/4800 12) -(define baud/9600 13) -(define baud/19200 14) -(define baud/38400 15) - -;;; tcflush magic -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(define %flush-tty/input 0) ; TCIFLUSH -(define %flush-tty/output 1) ; TCOFLUSH -(define %flush-tty/both 2) ; TCIOFLUSH - -;;; tcflow magic -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(define %tcflow/stop-out 0) ; TCOOFF -(define %tcflow/start-out 1) ; TCOON -(define %tcflow/stop-in 2) ; TCIOFF -(define %tcflow/start-in 3) ; TCION diff --git a/scsh/tty.scm b/scsh/tty.scm index e9d7a8a..03a600b 100644 --- a/scsh/tty.scm +++ b/scsh/tty.scm @@ -1,7 +1,3 @@ -;;; To do: -;;; Add new bindings to scsh-level-0 interface defn. -;;; Magic constant defns. - ;;; My comments: ;;; - We have a lot of NeXT-specific stuff. More importantly, what is the ;;; Linux, Solaris, and HP-UX specific stuff? @@ -155,6 +151,7 @@ (tty-info:min info) (tty-info:time info))))))) + (define-simple-errno-syscall (%set-tty-info fdes option control-chars iflag-hi8 iflag-lo24 @@ -165,6 +162,7 @@ min time) %set-tty-info/errno) + (define-foreign %set-tty-info/errno (scheme_tcsetattr (integer fdes) (integer option) @@ -184,25 +182,17 @@ (to-scheme integer errno_or_false)) -;;; Magic Numbers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;; -(define %set-tty-info/now 0) ; Make change immediately. -(define %set-tty-info/drain 1) ; Drain output, then change. -(define %set-tty-info/flush 2) ; Drain output, flush input. - ;;; Exported procs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Note that the magic %set-tty-info/foo constants must be defined before this +;;; file is loaded due to the set-tty-info/foo definitions below. -(define (set-tty-info/now fd/port info) - (set-tty-info fd/port %set-tty-info/now info)) +(define (make-tty-info-setter how) + (lambda (fdport info) (set-tty-info fdport how info))) -(define (set-tty-info/drain fd/port info) - (set-tty-info fd/port %set-tty-info/drain info)) - -(define (set-tty-info/flush fd/port info) - (set-tty-info fd/port %set-tty-info/flush info)) +(define set-tty-info/now (make-tty-info-setter %set-tty-info/now)) +(define set-tty-info/drain (make-tty-info-setter %set-tty-info/drain)) +(define set-tty-info/flush (make-tty-info-setter %set-tty-info/flush)) ;;; Send a break on the serial line. @@ -238,6 +228,8 @@ ;;; Flushing the device queues. (tcflush) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Note that the magic %flush-tty/foo constants must be defined before this +;;; file is loaded due to the flush-tty/foo definitions below. (define (make-tty-flusher flag) (lambda (fdport) @@ -254,6 +246,8 @@ ;;; Stopping and starting I/O (tcflow) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Note that the magic %tcflow/foo constants must be defined before this +;;; file is loaded due to the definitions below. (define (make-flow-controller action) (lambda (fdport) @@ -269,3 +263,17 @@ (define-foreign %tcflow/errno (tcflow (integer fdes) (integer action)) (to-scheme integer errno_or_false)) + + +;;; Baud rate translation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define (encode-baud-rate speed) ; 9600 -> value of BAUD/9600 + (do ((i (- (vector-length baud-rates) 1) (- i 1))) + ((let ((entry (vector-ref baud-rates i))) + (and (pair? entry) (memv speed entry))) + i) + (if (< i 0) (error "Unknown baud rate." speed)))) + +(define (decode-baud-rate code) ; value of BAUD/9600 -> 9600 + (car (vector-ref baud-rates code))) diff --git a/scsh/tty1.c b/scsh/tty1.c index e334308..d27abb4 100644 --- a/scsh/tty1.c +++ b/scsh/tty1.c @@ -6,6 +6,7 @@ * Scheme48/scsh terminal control interface. * Routines that require custom C support. * Copyright (c) 1995 by Brian D. Carlstrom + * Re-written by Olin. */ #include @@ -47,12 +48,24 @@ int scheme_tcsetattr(int fd, int option, struct termios t; memcpy(t.c_cc, control_chars, NCCS); - t.c_cc[VMIN] = min; - t.c_cc[VTIME] = time; + + /* This first clause of this conditional test will hopefully + ** resolve the branch at compile time. However, since VMIN/VEOF + ** and VTIME/VEOL are allowed by POSIX to colllide, we have to check. + ** If they do collide, we set EOF & EOL in canonical mode, and MIN & TIME + ** in raw mode. Ah, Unix. + */ + + if( (VMIN != VEOF && VTIME != VEOL) || !(t.c_lflag & ICANON) ) { + t.c_cc[VMIN] = min; + t.c_cc[VTIME] = time; + } + t.c_iflag = (iflag_hi8 << 24) | iflag_lo24; t.c_oflag = (oflag_hi8 << 24) | oflag_lo24; t.c_cflag = (cflag_hi8 << 24) | cflag_lo24; t.c_lflag = (lflag_hi8 << 24) | lflag_lo24; + cfsetispeed(&t, ispeed); cfsetospeed(&t, ospeed);