Просмотр исходного кода

Fixed color in telnet (extra ; before m).

Also removed golang.org/x/sys/unix requirement.
We don't need that, just "fix" telnet before connecting to
the door.  (Which is what a BBS would normally do for us anyway.)
Steve Thielemann 3 лет назад
Родитель
Сommit
f905c906d1
3 измененных файлов с 3 добавлено и 66 удалено
  1. 3 62
      door/door.go
  2. 0 2
      door/go.mod
  3. 0 2
      door/go.sum

+ 3 - 62
door/door.go

@@ -9,8 +9,6 @@ import (
 	"strings"
 	"syscall"
 	"time"
-
-	"golang.org/x/sys/unix"
 )
 
 const CRNL = "\r\n"
@@ -36,6 +34,7 @@ func Color(arg ...int) string {
 	for i := range arg {
 		result += fmt.Sprintf("%d;", arg[i])
 	}
+	result = result[:len(result)-1]
 	result += "m"
 	return result
 }
@@ -240,57 +239,6 @@ func (d *Door) detect() {
 
 }
 
-func tcgetattr(fd uintptr) (*unix.Termios, error) {
-	return unix.IoctlGetTermios(int(fd), unix.TCGETS)
-}
-
-func cfmakeraw(attr *unix.Termios) {
-	attr.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.ISTRIP | unix.PARMRK |
-		unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
-	attr.Oflag &^= unix.OPOST
-	attr.Cflag &^= unix.CSIZE | unix.PARENB
-	attr.Cflag |= unix.CS8
-	attr.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.IEXTEN | unix.ISIG
-	attr.Cc[unix.VMIN] = 0
-	attr.Cc[unix.VTIME] = 1
-
-	/*
-		attr.Iflag &^= unix.BRKINT | unix.INLCR | unix.ICRNL | unix.INPCK | unix.ISTRIP | unix.IXON
-		attr.Oflag &^= unix.OPOST
-		attr.Cflag &^= unix.CSIZE | unix.PARENB
-		attr.Cflag |= unix.CS8
-		attr.Lflag &^= unix.ECHO | unix.ICANON | unix.IEXTEN | unix.ISIG
-		attr.Cc[unix.VMIN] = 1
-		attr.Cc[unix.VTIME] = 0
-	*/
-}
-
-const (
-	TCIFLUSH  = 0
-	TCOFLUSH  = 1
-	TCIOFLUSH = 2
-
-	TCSANOW   = 0
-	TCSADRAIN = 1
-	TCSAFLUSH = 2
-)
-
-// Tcsetattr sets the current serial port settings.
-func tcsetattr(fd, action uintptr, argp *unix.Termios) error {
-	var request uintptr
-	switch action {
-	case TCSANOW:
-		request = unix.TCSETS
-	case TCSADRAIN:
-		request = unix.TCSETSW
-	case TCSAFLUSH:
-		request = unix.TCSETSF
-	default:
-		return unix.EINVAL
-	}
-	return unix.IoctlSetTermios(int(fd), uint(request), argp)
-}
-
 func (d *Door) Init() {
 	var dropfile string
 
@@ -305,15 +253,6 @@ func (d *Door) Init() {
 	d.ReadDropfile(dropfile)
 
 	fmt.Printf("BBS %s, User %s / Handle %s / File %d\n", d.config.BBSID, d.config.real_name, d.config.handle, d.READFD)
-	// putting the linux terminal into raw mode ...
-	// requires golang.org/x/sys/unix  unix.Ioctlgetermios, etc.
-
-	// telnet: getting terminal echo, terminal still not in raw mode (needs CR to submit)
-	// syncterm: weird cursor movement (delays before doing CR?), but otherwise "works".
-	a, _ := tcgetattr(uintptr(d.READFD))
-	cfmakeraw(a)
-	_ = tcsetattr(uintptr(d.READFD), TCSANOW, a)
-	// _ = tcsetattr(uintptr(d.READFD), TCSAFLUSH, a)
 	d.detect()
 }
 
@@ -418,6 +357,7 @@ func (d *Door) Getch() int {
 	return int(buffer[0])
 }
 
+/*
 func sleep_key(config *DropfileConfig, secs int) int {
 	// var fdsetRead, fdsetWrite, fdsete syscall.FdSet
 	var fdsetRead = syscall.FdSet{}
@@ -451,6 +391,7 @@ func sleep_key(config *DropfileConfig, secs int) int {
 	}
 	return int(buffer[0])
 }
+*/
 
 /*
 func main() {

+ 0 - 2
door/go.mod

@@ -1,5 +1,3 @@
 module red-green/door
 
 go 1.17
-
-require golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

+ 0 - 2
door/go.sum

@@ -1,2 +0,0 @@
-golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
-golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=