aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/vendor/github.com/mattn/go-isatty
diff options
context:
space:
mode:
Diffstat (limited to 'src/dma/vendor/github.com/mattn/go-isatty')
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/.travis.yml13
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/LICENSE9
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/README.md50
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/doc.go2
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/go.mod3
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/go.sum2
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_android.go23
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_bsd.go24
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_linux.go19
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_others.go15
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_solaris.go22
-rw-r--r--src/dma/vendor/github.com/mattn/go-isatty/isatty_windows.go94
12 files changed, 276 insertions, 0 deletions
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/.travis.yml b/src/dma/vendor/github.com/mattn/go-isatty/.travis.yml
new file mode 100644
index 00000000..5597e026
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/.travis.yml
@@ -0,0 +1,13 @@
+language: go
+go:
+ - tip
+
+os:
+ - linux
+ - osx
+
+before_install:
+ - go get github.com/mattn/goveralls
+ - go get golang.org/x/tools/cmd/cover
+script:
+ - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/LICENSE b/src/dma/vendor/github.com/mattn/go-isatty/LICENSE
new file mode 100644
index 00000000..65dc692b
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/LICENSE
@@ -0,0 +1,9 @@
+Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
+
+MIT License (Expat)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/README.md b/src/dma/vendor/github.com/mattn/go-isatty/README.md
new file mode 100644
index 00000000..1e69004b
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/README.md
@@ -0,0 +1,50 @@
+# go-isatty
+
+[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty)
+[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty)
+[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
+[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty)
+
+isatty for golang
+
+## Usage
+
+```go
+package main
+
+import (
+ "fmt"
+ "github.com/mattn/go-isatty"
+ "os"
+)
+
+func main() {
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Println("Is Terminal")
+ } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
+ fmt.Println("Is Cygwin/MSYS2 Terminal")
+ } else {
+ fmt.Println("Is Not Terminal")
+ }
+}
+```
+
+## Installation
+
+```
+$ go get github.com/mattn/go-isatty
+```
+
+## License
+
+MIT
+
+## Author
+
+Yasuhiro Matsumoto (a.k.a mattn)
+
+## Thanks
+
+* k-takata: base idea for IsCygwinTerminal
+
+ https://github.com/k-takata/go-iscygpty
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/doc.go b/src/dma/vendor/github.com/mattn/go-isatty/doc.go
new file mode 100644
index 00000000..17d4f90e
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/doc.go
@@ -0,0 +1,2 @@
+// Package isatty implements interface to isatty
+package isatty
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/go.mod b/src/dma/vendor/github.com/mattn/go-isatty/go.mod
new file mode 100644
index 00000000..f310320c
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/go.mod
@@ -0,0 +1,3 @@
+module github.com/mattn/go-isatty
+
+require golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/go.sum b/src/dma/vendor/github.com/mattn/go-isatty/go.sum
new file mode 100644
index 00000000..426c8973
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/go.sum
@@ -0,0 +1,2 @@
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_android.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_android.go
new file mode 100644
index 00000000..d3567cb5
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_android.go
@@ -0,0 +1,23 @@
+// +build android
+
+package isatty
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+const ioctlReadTermios = syscall.TCGETS
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var termios syscall.Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_bsd.go
new file mode 100644
index 00000000..07e93039
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_bsd.go
@@ -0,0 +1,24 @@
+// +build darwin freebsd openbsd netbsd dragonfly
+// +build !appengine
+
+package isatty
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var termios syscall.Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_linux.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_linux.go
new file mode 100644
index 00000000..4f8af465
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_linux.go
@@ -0,0 +1,19 @@
+// +build linux
+// +build !appengine
+// +build !android
+
+package isatty
+
+import "golang.org/x/sys/unix"
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
+ return err == nil
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_others.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_others.go
new file mode 100644
index 00000000..f02849c5
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_others.go
@@ -0,0 +1,15 @@
+// +build appengine js
+
+package isatty
+
+// IsTerminal returns true if the file descriptor is terminal which
+// is always false on js and appengine classic which is a sandboxed PaaS.
+func IsTerminal(fd uintptr) bool {
+ return false
+}
+
+// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_solaris.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_solaris.go
new file mode 100644
index 00000000..bdd5c79a
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_solaris.go
@@ -0,0 +1,22 @@
+// +build solaris
+// +build !appengine
+
+package isatty
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
+func IsTerminal(fd uintptr) bool {
+ var termio unix.Termio
+ err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
+ return err == nil
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/src/dma/vendor/github.com/mattn/go-isatty/isatty_windows.go b/src/dma/vendor/github.com/mattn/go-isatty/isatty_windows.go
new file mode 100644
index 00000000..af51cbca
--- /dev/null
+++ b/src/dma/vendor/github.com/mattn/go-isatty/isatty_windows.go
@@ -0,0 +1,94 @@
+// +build windows
+// +build !appengine
+
+package isatty
+
+import (
+ "strings"
+ "syscall"
+ "unicode/utf16"
+ "unsafe"
+)
+
+const (
+ fileNameInfo uintptr = 2
+ fileTypePipe = 3
+)
+
+var (
+ kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+ procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
+ procGetFileType = kernel32.NewProc("GetFileType")
+)
+
+func init() {
+ // Check if GetFileInformationByHandleEx is available.
+ if procGetFileInformationByHandleEx.Find() != nil {
+ procGetFileInformationByHandleEx = nil
+ }
+}
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var st uint32
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
+ return r != 0 && e == 0
+}
+
+// Check pipe name is used for cygwin/msys2 pty.
+// Cygwin/MSYS2 PTY has a name like:
+// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
+func isCygwinPipeName(name string) bool {
+ token := strings.Split(name, "-")
+ if len(token) < 5 {
+ return false
+ }
+
+ if token[0] != `\msys` && token[0] != `\cygwin` {
+ return false
+ }
+
+ if token[1] == "" {
+ return false
+ }
+
+ if !strings.HasPrefix(token[2], "pty") {
+ return false
+ }
+
+ if token[3] != `from` && token[3] != `to` {
+ return false
+ }
+
+ if token[4] != "master" {
+ return false
+ }
+
+ return true
+}
+
+// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
+// terminal.
+func IsCygwinTerminal(fd uintptr) bool {
+ if procGetFileInformationByHandleEx == nil {
+ return false
+ }
+
+ // Cygwin/msys's pty is a pipe.
+ ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
+ if ft != fileTypePipe || e != 0 {
+ return false
+ }
+
+ var buf [2 + syscall.MAX_PATH]uint16
+ r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
+ 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
+ uintptr(len(buf)*2), 0, 0)
+ if r == 0 || e != 0 {
+ return false
+ }
+
+ l := *(*uint32)(unsafe.Pointer(&buf))
+ return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
+}