1// +build dragonfly openbsd solaris
2
3package termios
4
5// #include<stdlib.h>
6import "C"
7
8import "syscall"
9
10func open_pty_master() (uintptr, error) {
11	rc := C.posix_openpt(syscall.O_NOCTTY | syscall.O_RDWR)
12	if rc < 0 {
13		return 0, syscall.Errno(rc)
14	}
15	return uintptr(rc), nil
16}
17
18func Ptsname(fd uintptr) (string, error) {
19	slavename := C.GoString(C.ptsname(C.int(fd)))
20	return slavename, nil
21}
22
23func grantpt(fd uintptr) error {
24	rc := C.grantpt(C.int(fd))
25	if rc == 0 {
26		return nil
27	}
28	return syscall.Errno(rc)
29}
30
31func unlockpt(fd uintptr) error {
32	rc := C.unlockpt(C.int(fd))
33	if rc == 0 {
34		return nil
35	}
36	return syscall.Errno(rc)
37}
38