|
@@ -9,8 +9,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"syscall"
|
|
"syscall"
|
|
"time"
|
|
"time"
|
|
-
|
|
|
|
- "golang.org/x/sys/unix"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
const CRNL = "\r\n"
|
|
const CRNL = "\r\n"
|
|
@@ -36,6 +34,7 @@ func Color(arg ...int) string {
|
|
for i := range arg {
|
|
for i := range arg {
|
|
result += fmt.Sprintf("%d;", arg[i])
|
|
result += fmt.Sprintf("%d;", arg[i])
|
|
}
|
|
}
|
|
|
|
+ result = result[:len(result)-1]
|
|
result += "m"
|
|
result += "m"
|
|
return result
|
|
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() {
|
|
func (d *Door) Init() {
|
|
var dropfile string
|
|
var dropfile string
|
|
|
|
|
|
@@ -305,15 +253,6 @@ func (d *Door) Init() {
|
|
d.ReadDropfile(dropfile)
|
|
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)
|
|
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()
|
|
d.detect()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -418,6 +357,7 @@ func (d *Door) Getch() int {
|
|
return int(buffer[0])
|
|
return int(buffer[0])
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
func sleep_key(config *DropfileConfig, secs int) int {
|
|
func sleep_key(config *DropfileConfig, secs int) int {
|
|
// var fdsetRead, fdsetWrite, fdsete syscall.FdSet
|
|
// var fdsetRead, fdsetWrite, fdsete syscall.FdSet
|
|
var fdsetRead = syscall.FdSet{}
|
|
var fdsetRead = syscall.FdSet{}
|
|
@@ -451,6 +391,7 @@ func sleep_key(config *DropfileConfig, secs int) int {
|
|
}
|
|
}
|
|
return int(buffer[0])
|
|
return int(buffer[0])
|
|
}
|
|
}
|
|
|
|
+*/
|
|
|
|
|
|
/*
|
|
/*
|
|
func main() {
|
|
func main() {
|