infra
/
goutils
Archived
1
0
Fork 0
This repository has been archived on 2022-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
goutils/tty/code/termcodes_linux.go

46 lines
765 B
Go

// +build linux
package code
import (
"os"
"syscall"
"unsafe"
)
type iflagSetter struct {
Flag uint32
}
type lflagSetter struct {
Flag uint32
}
type oflagSetter struct {
Flag uint32
}
type cflagSetter struct {
Flag uint32
}
func SetAttr(tty *os.File, termios *syscall.Termios) error {
r, _, e := syscall.Syscall(syscall.SYS_IOCTL, tty.Fd(), syscall.TCSETS, uintptr(unsafe.Pointer(termios)))
if r != 0 {
return os.NewSyscallError("SYS_IOCTL", e)
}
return nil
}
func GetAttr(tty *os.File) (*syscall.Termios, error) {
termios := &syscall.Termios{}
r, _, e := syscall.Syscall(syscall.SYS_IOCTL, tty.Fd(), syscall.TCGETS, uintptr(unsafe.Pointer(termios)))
if r != 0 {
return nil, os.NewSyscallError("SYS_IOCTL", e)
}
return termios, nil
}