mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 08:25:38 +00:00
vendor: switch to go modules and update deps
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
8b6de6073c
commit
7ce6c9c696
47 changed files with 39 additions and 5586 deletions
85
Gopkg.lock
generated
85
Gopkg.lock
generated
|
@ -1,85 +0,0 @@
|
||||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
|
||||||
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
|
|
||||||
name = "github.com/davecgh/go-spew"
|
|
||||||
packages = ["spew"]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
|
|
||||||
version = "v1.1.1"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a"
|
|
||||||
name = "github.com/fatih/color"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
|
|
||||||
version = "v1.7.0"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
|
|
||||||
name = "github.com/konsorten/go-windows-terminal-sequences"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
|
|
||||||
version = "v1.0.1"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67"
|
|
||||||
name = "github.com/mattn/go-colorable"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
|
|
||||||
version = "v0.0.9"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
|
|
||||||
name = "github.com/mattn/go-isatty"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
|
|
||||||
version = "v0.0.4"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:87c2e02fb01c27060ccc5ba7c5a407cc91147726f8f40b70cceeedbc52b1f3a8"
|
|
||||||
name = "github.com/sirupsen/logrus"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "e1e72e9de974bd926e5c56f83753fba2df402ce5"
|
|
||||||
version = "v1.3.0"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
digest = "1:ee2bb461b8a43f9eace0910d7c9f567676760a038dc996295da0efff6f62f353"
|
|
||||||
name = "golang.org/x/crypto"
|
|
||||||
packages = [
|
|
||||||
"ripemd160",
|
|
||||||
"ssh/terminal",
|
|
||||||
]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "ff983b9c42bc9fbf91556e191cc8efb585c16908"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
digest = "1:72f402ba458cb14ed7964c8b9a38d992f27834b3cf3479f3b08ea9e5334811b3"
|
|
||||||
name = "golang.org/x/sys"
|
|
||||||
packages = [
|
|
||||||
"unix",
|
|
||||||
"windows",
|
|
||||||
]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "770c60269bf0ef965e9e7ac8bedcb6bca2a1cefd"
|
|
||||||
|
|
||||||
[solve-meta]
|
|
||||||
analyzer-name = "dep"
|
|
||||||
analyzer-version = 1
|
|
||||||
input-imports = [
|
|
||||||
"github.com/davecgh/go-spew/spew",
|
|
||||||
"github.com/fatih/color",
|
|
||||||
"github.com/sirupsen/logrus",
|
|
||||||
"golang.org/x/crypto/ripemd160",
|
|
||||||
"golang.org/x/sys/unix",
|
|
||||||
]
|
|
||||||
solver-name = "gps-cdcl"
|
|
||||||
solver-version = 1
|
|
42
Gopkg.toml
42
Gopkg.toml
|
@ -1,42 +0,0 @@
|
||||||
# Gopkg.toml example
|
|
||||||
#
|
|
||||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
|
||||||
# for detailed Gopkg.toml documentation.
|
|
||||||
#
|
|
||||||
# required = ["github.com/user/thing/cmd/thing"]
|
|
||||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
|
||||||
#
|
|
||||||
# [[constraint]]
|
|
||||||
# name = "github.com/user/project"
|
|
||||||
# version = "1.0.0"
|
|
||||||
#
|
|
||||||
# [[constraint]]
|
|
||||||
# name = "github.com/user/project2"
|
|
||||||
# branch = "dev"
|
|
||||||
# source = "github.com/myfork/project2"
|
|
||||||
#
|
|
||||||
# [[override]]
|
|
||||||
# name = "github.com/x/y"
|
|
||||||
# version = "2.4.0"
|
|
||||||
#
|
|
||||||
# [prune]
|
|
||||||
# non-go = false
|
|
||||||
# go-tests = true
|
|
||||||
# unused-packages = true
|
|
||||||
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/davecgh/go-spew"
|
|
||||||
version = "1.1.1"
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/fatih/color"
|
|
||||||
version = "1.6.0"
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/sirupsen/logrus"
|
|
||||||
version = "1.0.0"
|
|
||||||
|
|
||||||
[prune]
|
|
||||||
go-tests = true
|
|
||||||
unused-packages = true
|
|
10
go.mod
Normal file
10
go.mod
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module github.com/vbatts/go-mtree
|
||||||
|
|
||||||
|
go 1.13
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1
|
||||||
|
github.com/sirupsen/logrus v1.3.0
|
||||||
|
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
|
||||||
|
golang.org/x/sys v0.0.0-20190121090251-770c60269bf0
|
||||||
|
)
|
17
go.sum
Normal file
17
go.sum
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||||
|
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGqAlGX3+oCsiL1Q629FL90M=
|
||||||
|
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190121090251-770c60269bf0 h1:kTCXMFd85FwiS5g4PBFOimFnVyc7jqgrMI8TZIq/W/Y=
|
||||||
|
golang.org/x/sys v0.0.0-20190121090251-770c60269bf0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
5
vendor/github.com/fatih/color/.travis.yml
generated
vendored
5
vendor/github.com/fatih/color/.travis.yml
generated
vendored
|
@ -1,5 +0,0 @@
|
||||||
language: go
|
|
||||||
go:
|
|
||||||
- 1.8.x
|
|
||||||
- tip
|
|
||||||
|
|
27
vendor/github.com/fatih/color/Gopkg.lock
generated
vendored
27
vendor/github.com/fatih/color/Gopkg.lock
generated
vendored
|
@ -1,27 +0,0 @@
|
||||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
|
||||||
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
name = "github.com/mattn/go-colorable"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
|
|
||||||
version = "v0.0.9"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
name = "github.com/mattn/go-isatty"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
|
||||||
version = "v0.0.3"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "golang.org/x/sys"
|
|
||||||
packages = ["unix"]
|
|
||||||
revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
|
|
||||||
|
|
||||||
[solve-meta]
|
|
||||||
analyzer-name = "dep"
|
|
||||||
analyzer-version = 1
|
|
||||||
inputs-digest = "e8a50671c3cb93ea935bf210b1cd20702876b9d9226129be581ef646d1565cdc"
|
|
||||||
solver-name = "gps-cdcl"
|
|
||||||
solver-version = 1
|
|
30
vendor/github.com/fatih/color/Gopkg.toml
generated
vendored
30
vendor/github.com/fatih/color/Gopkg.toml
generated
vendored
|
@ -1,30 +0,0 @@
|
||||||
|
|
||||||
# Gopkg.toml example
|
|
||||||
#
|
|
||||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
|
||||||
# for detailed Gopkg.toml documentation.
|
|
||||||
#
|
|
||||||
# required = ["github.com/user/thing/cmd/thing"]
|
|
||||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
|
||||||
#
|
|
||||||
# [[constraint]]
|
|
||||||
# name = "github.com/user/project"
|
|
||||||
# version = "1.0.0"
|
|
||||||
#
|
|
||||||
# [[constraint]]
|
|
||||||
# name = "github.com/user/project2"
|
|
||||||
# branch = "dev"
|
|
||||||
# source = "github.com/myfork/project2"
|
|
||||||
#
|
|
||||||
# [[override]]
|
|
||||||
# name = "github.com/x/y"
|
|
||||||
# version = "2.4.0"
|
|
||||||
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/mattn/go-colorable"
|
|
||||||
version = "0.0.9"
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/mattn/go-isatty"
|
|
||||||
version = "0.0.3"
|
|
20
vendor/github.com/fatih/color/LICENSE.md
generated
vendored
20
vendor/github.com/fatih/color/LICENSE.md
generated
vendored
|
@ -1,20 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Fatih Arslan
|
|
||||||
|
|
||||||
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.
|
|
179
vendor/github.com/fatih/color/README.md
generated
vendored
179
vendor/github.com/fatih/color/README.md
generated
vendored
|
@ -1,179 +0,0 @@
|
||||||
# Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color) [![Build Status](https://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Color lets you use colorized outputs in terms of [ANSI Escape
|
|
||||||
Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
|
|
||||||
has support for Windows too! The API can be used in several ways, pick one that
|
|
||||||
suits you.
|
|
||||||
|
|
||||||
|
|
||||||
![Color](https://i.imgur.com/c1JI0lA.png)
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go get github.com/fatih/color
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that the `vendor` folder is here for stability. Remove the folder if you
|
|
||||||
already have the dependencies in your GOPATH.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Standard colors
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Print with default helper functions
|
|
||||||
color.Cyan("Prints text in cyan.")
|
|
||||||
|
|
||||||
// A newline will be appended automatically
|
|
||||||
color.Blue("Prints %s in blue.", "text")
|
|
||||||
|
|
||||||
// These are using the default foreground colors
|
|
||||||
color.Red("We have red")
|
|
||||||
color.Magenta("And many others ..")
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Mix and reuse colors
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Create a new color object
|
|
||||||
c := color.New(color.FgCyan).Add(color.Underline)
|
|
||||||
c.Println("Prints cyan text with an underline.")
|
|
||||||
|
|
||||||
// Or just add them to New()
|
|
||||||
d := color.New(color.FgCyan, color.Bold)
|
|
||||||
d.Printf("This prints bold cyan %s\n", "too!.")
|
|
||||||
|
|
||||||
// Mix up foreground and background colors, create new mixes!
|
|
||||||
red := color.New(color.FgRed)
|
|
||||||
|
|
||||||
boldRed := red.Add(color.Bold)
|
|
||||||
boldRed.Println("This will print text in bold red.")
|
|
||||||
|
|
||||||
whiteBackground := red.Add(color.BgWhite)
|
|
||||||
whiteBackground.Println("Red text with white background.")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Use your own output (io.Writer)
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Use your own io.Writer output
|
|
||||||
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
|
|
||||||
|
|
||||||
blue := color.New(color.FgBlue)
|
|
||||||
blue.Fprint(writer, "This will print text in blue.")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Custom print functions (PrintFunc)
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Create a custom print function for convenience
|
|
||||||
red := color.New(color.FgRed).PrintfFunc()
|
|
||||||
red("Warning")
|
|
||||||
red("Error: %s", err)
|
|
||||||
|
|
||||||
// Mix up multiple attributes
|
|
||||||
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
|
|
||||||
notice("Don't forget this...")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Custom fprint functions (FprintFunc)
|
|
||||||
|
|
||||||
```go
|
|
||||||
blue := color.New(FgBlue).FprintfFunc()
|
|
||||||
blue(myWriter, "important notice: %s", stars)
|
|
||||||
|
|
||||||
// Mix up with multiple attributes
|
|
||||||
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
|
|
||||||
success(myWriter, "Don't forget this...")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Insert into noncolor strings (SprintFunc)
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Create SprintXxx functions to mix strings with other non-colorized strings:
|
|
||||||
yellow := color.New(color.FgYellow).SprintFunc()
|
|
||||||
red := color.New(color.FgRed).SprintFunc()
|
|
||||||
fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))
|
|
||||||
|
|
||||||
info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
|
|
||||||
fmt.Printf("This %s rocks!\n", info("package"))
|
|
||||||
|
|
||||||
// Use helper functions
|
|
||||||
fmt.Println("This", color.RedString("warning"), "should be not neglected.")
|
|
||||||
fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")
|
|
||||||
|
|
||||||
// Windows supported too! Just don't forget to change the output to color.Output
|
|
||||||
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
|
|
||||||
```
|
|
||||||
|
|
||||||
### Plug into existing code
|
|
||||||
|
|
||||||
```go
|
|
||||||
// Use handy standard colors
|
|
||||||
color.Set(color.FgYellow)
|
|
||||||
|
|
||||||
fmt.Println("Existing text will now be in yellow")
|
|
||||||
fmt.Printf("This one %s\n", "too")
|
|
||||||
|
|
||||||
color.Unset() // Don't forget to unset
|
|
||||||
|
|
||||||
// You can mix up parameters
|
|
||||||
color.Set(color.FgMagenta, color.Bold)
|
|
||||||
defer color.Unset() // Use it in your function
|
|
||||||
|
|
||||||
fmt.Println("All text will now be bold magenta.")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Disable/Enable color
|
|
||||||
|
|
||||||
There might be a case where you want to explicitly disable/enable color output. the
|
|
||||||
`go-isatty` package will automatically disable color output for non-tty output streams
|
|
||||||
(for example if the output were piped directly to `less`)
|
|
||||||
|
|
||||||
`Color` has support to disable/enable colors both globally and for single color
|
|
||||||
definitions. For example suppose you have a CLI app and a `--no-color` bool flag. You
|
|
||||||
can easily disable the color output with:
|
|
||||||
|
|
||||||
```go
|
|
||||||
|
|
||||||
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
|
|
||||||
|
|
||||||
if *flagNoColor {
|
|
||||||
color.NoColor = true // disables colorized output
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
It also has support for single color definitions (local). You can
|
|
||||||
disable/enable color output on the fly:
|
|
||||||
|
|
||||||
```go
|
|
||||||
c := color.New(color.FgCyan)
|
|
||||||
c.Println("Prints cyan text")
|
|
||||||
|
|
||||||
c.DisableColor()
|
|
||||||
c.Println("This is printed without any color")
|
|
||||||
|
|
||||||
c.EnableColor()
|
|
||||||
c.Println("This prints again cyan...")
|
|
||||||
```
|
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
* Save/Return previous values
|
|
||||||
* Evaluate fmt.Formatter interface
|
|
||||||
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
* [Fatih Arslan](https://github.com/fatih)
|
|
||||||
* Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details
|
|
||||||
|
|
603
vendor/github.com/fatih/color/color.go
generated
vendored
603
vendor/github.com/fatih/color/color.go
generated
vendored
|
@ -1,603 +0,0 @@
|
||||||
package color
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/mattn/go-colorable"
|
|
||||||
"github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// NoColor defines if the output is colorized or not. It's dynamically set to
|
|
||||||
// false or true based on the stdout's file descriptor referring to a terminal
|
|
||||||
// or not. This is a global option and affects all colors. For more control
|
|
||||||
// over each color block use the methods DisableColor() individually.
|
|
||||||
NoColor = os.Getenv("TERM") == "dumb" ||
|
|
||||||
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
|
|
||||||
|
|
||||||
// Output defines the standard output of the print functions. By default
|
|
||||||
// os.Stdout is used.
|
|
||||||
Output = colorable.NewColorableStdout()
|
|
||||||
|
|
||||||
// Error defines a color supporting writer for os.Stderr.
|
|
||||||
Error = colorable.NewColorableStderr()
|
|
||||||
|
|
||||||
// colorsCache is used to reduce the count of created Color objects and
|
|
||||||
// allows to reuse already created objects with required Attribute.
|
|
||||||
colorsCache = make(map[Attribute]*Color)
|
|
||||||
colorsCacheMu sync.Mutex // protects colorsCache
|
|
||||||
)
|
|
||||||
|
|
||||||
// Color defines a custom color object which is defined by SGR parameters.
|
|
||||||
type Color struct {
|
|
||||||
params []Attribute
|
|
||||||
noColor *bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attribute defines a single SGR Code
|
|
||||||
type Attribute int
|
|
||||||
|
|
||||||
const escape = "\x1b"
|
|
||||||
|
|
||||||
// Base attributes
|
|
||||||
const (
|
|
||||||
Reset Attribute = iota
|
|
||||||
Bold
|
|
||||||
Faint
|
|
||||||
Italic
|
|
||||||
Underline
|
|
||||||
BlinkSlow
|
|
||||||
BlinkRapid
|
|
||||||
ReverseVideo
|
|
||||||
Concealed
|
|
||||||
CrossedOut
|
|
||||||
)
|
|
||||||
|
|
||||||
// Foreground text colors
|
|
||||||
const (
|
|
||||||
FgBlack Attribute = iota + 30
|
|
||||||
FgRed
|
|
||||||
FgGreen
|
|
||||||
FgYellow
|
|
||||||
FgBlue
|
|
||||||
FgMagenta
|
|
||||||
FgCyan
|
|
||||||
FgWhite
|
|
||||||
)
|
|
||||||
|
|
||||||
// Foreground Hi-Intensity text colors
|
|
||||||
const (
|
|
||||||
FgHiBlack Attribute = iota + 90
|
|
||||||
FgHiRed
|
|
||||||
FgHiGreen
|
|
||||||
FgHiYellow
|
|
||||||
FgHiBlue
|
|
||||||
FgHiMagenta
|
|
||||||
FgHiCyan
|
|
||||||
FgHiWhite
|
|
||||||
)
|
|
||||||
|
|
||||||
// Background text colors
|
|
||||||
const (
|
|
||||||
BgBlack Attribute = iota + 40
|
|
||||||
BgRed
|
|
||||||
BgGreen
|
|
||||||
BgYellow
|
|
||||||
BgBlue
|
|
||||||
BgMagenta
|
|
||||||
BgCyan
|
|
||||||
BgWhite
|
|
||||||
)
|
|
||||||
|
|
||||||
// Background Hi-Intensity text colors
|
|
||||||
const (
|
|
||||||
BgHiBlack Attribute = iota + 100
|
|
||||||
BgHiRed
|
|
||||||
BgHiGreen
|
|
||||||
BgHiYellow
|
|
||||||
BgHiBlue
|
|
||||||
BgHiMagenta
|
|
||||||
BgHiCyan
|
|
||||||
BgHiWhite
|
|
||||||
)
|
|
||||||
|
|
||||||
// New returns a newly created color object.
|
|
||||||
func New(value ...Attribute) *Color {
|
|
||||||
c := &Color{params: make([]Attribute, 0)}
|
|
||||||
c.Add(value...)
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets the given parameters immediately. It will change the color of
|
|
||||||
// output with the given SGR parameters until color.Unset() is called.
|
|
||||||
func Set(p ...Attribute) *Color {
|
|
||||||
c := New(p...)
|
|
||||||
c.Set()
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unset resets all escape attributes and clears the output. Usually should
|
|
||||||
// be called after Set().
|
|
||||||
func Unset() {
|
|
||||||
if NoColor {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(Output, "%s[%dm", escape, Reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets the SGR sequence.
|
|
||||||
func (c *Color) Set() *Color {
|
|
||||||
if c.isNoColorSet() {
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(Output, c.format())
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) unset() {
|
|
||||||
if c.isNoColorSet() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Unset()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) setWriter(w io.Writer) *Color {
|
|
||||||
if c.isNoColorSet() {
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(w, c.format())
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) unsetWriter(w io.Writer) {
|
|
||||||
if c.isNoColorSet() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if NoColor {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(w, "%s[%dm", escape, Reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add is used to chain SGR parameters. Use as many as parameters to combine
|
|
||||||
// and create custom color objects. Example: Add(color.FgRed, color.Underline).
|
|
||||||
func (c *Color) Add(value ...Attribute) *Color {
|
|
||||||
c.params = append(c.params, value...)
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) prepend(value Attribute) {
|
|
||||||
c.params = append(c.params, 0)
|
|
||||||
copy(c.params[1:], c.params[0:])
|
|
||||||
c.params[0] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fprint formats using the default formats for its operands and writes to w.
|
|
||||||
// Spaces are added between operands when neither is a string.
|
|
||||||
// It returns the number of bytes written and any write error encountered.
|
|
||||||
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
|
||||||
// type *os.File.
|
|
||||||
func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
|
|
||||||
c.setWriter(w)
|
|
||||||
defer c.unsetWriter(w)
|
|
||||||
|
|
||||||
return fmt.Fprint(w, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print formats using the default formats for its operands and writes to
|
|
||||||
// standard output. Spaces are added between operands when neither is a
|
|
||||||
// string. It returns the number of bytes written and any write error
|
|
||||||
// encountered. This is the standard fmt.Print() method wrapped with the given
|
|
||||||
// color.
|
|
||||||
func (c *Color) Print(a ...interface{}) (n int, err error) {
|
|
||||||
c.Set()
|
|
||||||
defer c.unset()
|
|
||||||
|
|
||||||
return fmt.Fprint(Output, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fprintf formats according to a format specifier and writes to w.
|
|
||||||
// It returns the number of bytes written and any write error encountered.
|
|
||||||
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
|
||||||
// type *os.File.
|
|
||||||
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
|
|
||||||
c.setWriter(w)
|
|
||||||
defer c.unsetWriter(w)
|
|
||||||
|
|
||||||
return fmt.Fprintf(w, format, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Printf formats according to a format specifier and writes to standard output.
|
|
||||||
// It returns the number of bytes written and any write error encountered.
|
|
||||||
// This is the standard fmt.Printf() method wrapped with the given color.
|
|
||||||
func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
|
|
||||||
c.Set()
|
|
||||||
defer c.unset()
|
|
||||||
|
|
||||||
return fmt.Fprintf(Output, format, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fprintln formats using the default formats for its operands and writes to w.
|
|
||||||
// Spaces are always added between operands and a newline is appended.
|
|
||||||
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
|
||||||
// type *os.File.
|
|
||||||
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
|
|
||||||
c.setWriter(w)
|
|
||||||
defer c.unsetWriter(w)
|
|
||||||
|
|
||||||
return fmt.Fprintln(w, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Println formats using the default formats for its operands and writes to
|
|
||||||
// standard output. Spaces are always added between operands and a newline is
|
|
||||||
// appended. It returns the number of bytes written and any write error
|
|
||||||
// encountered. This is the standard fmt.Print() method wrapped with the given
|
|
||||||
// color.
|
|
||||||
func (c *Color) Println(a ...interface{}) (n int, err error) {
|
|
||||||
c.Set()
|
|
||||||
defer c.unset()
|
|
||||||
|
|
||||||
return fmt.Fprintln(Output, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprint is just like Print, but returns a string instead of printing it.
|
|
||||||
func (c *Color) Sprint(a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprint(a...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprintln is just like Println, but returns a string instead of printing it.
|
|
||||||
func (c *Color) Sprintln(a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprintln(a...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprintf is just like Printf, but returns a string instead of printing it.
|
|
||||||
func (c *Color) Sprintf(format string, a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprintf(format, a...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// FprintFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Fprint().
|
|
||||||
func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
|
|
||||||
return func(w io.Writer, a ...interface{}) {
|
|
||||||
c.Fprint(w, a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrintFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Print().
|
|
||||||
func (c *Color) PrintFunc() func(a ...interface{}) {
|
|
||||||
return func(a ...interface{}) {
|
|
||||||
c.Print(a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FprintfFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Fprintf().
|
|
||||||
func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
|
|
||||||
return func(w io.Writer, format string, a ...interface{}) {
|
|
||||||
c.Fprintf(w, format, a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrintfFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Printf().
|
|
||||||
func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
|
|
||||||
return func(format string, a ...interface{}) {
|
|
||||||
c.Printf(format, a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FprintlnFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Fprintln().
|
|
||||||
func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
|
|
||||||
return func(w io.Writer, a ...interface{}) {
|
|
||||||
c.Fprintln(w, a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrintlnFunc returns a new function that prints the passed arguments as
|
|
||||||
// colorized with color.Println().
|
|
||||||
func (c *Color) PrintlnFunc() func(a ...interface{}) {
|
|
||||||
return func(a ...interface{}) {
|
|
||||||
c.Println(a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SprintFunc returns a new function that returns colorized strings for the
|
|
||||||
// given arguments with fmt.Sprint(). Useful to put into or mix into other
|
|
||||||
// string. Windows users should use this in conjunction with color.Output, example:
|
|
||||||
//
|
|
||||||
// put := New(FgYellow).SprintFunc()
|
|
||||||
// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
|
|
||||||
func (c *Color) SprintFunc() func(a ...interface{}) string {
|
|
||||||
return func(a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprint(a...))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SprintfFunc returns a new function that returns colorized strings for the
|
|
||||||
// given arguments with fmt.Sprintf(). Useful to put into or mix into other
|
|
||||||
// string. Windows users should use this in conjunction with color.Output.
|
|
||||||
func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
|
|
||||||
return func(format string, a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprintf(format, a...))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SprintlnFunc returns a new function that returns colorized strings for the
|
|
||||||
// given arguments with fmt.Sprintln(). Useful to put into or mix into other
|
|
||||||
// string. Windows users should use this in conjunction with color.Output.
|
|
||||||
func (c *Color) SprintlnFunc() func(a ...interface{}) string {
|
|
||||||
return func(a ...interface{}) string {
|
|
||||||
return c.wrap(fmt.Sprintln(a...))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sequence returns a formatted SGR sequence to be plugged into a "\x1b[...m"
|
|
||||||
// an example output might be: "1;36" -> bold cyan
|
|
||||||
func (c *Color) sequence() string {
|
|
||||||
format := make([]string, len(c.params))
|
|
||||||
for i, v := range c.params {
|
|
||||||
format[i] = strconv.Itoa(int(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(format, ";")
|
|
||||||
}
|
|
||||||
|
|
||||||
// wrap wraps the s string with the colors attributes. The string is ready to
|
|
||||||
// be printed.
|
|
||||||
func (c *Color) wrap(s string) string {
|
|
||||||
if c.isNoColorSet() {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.format() + s + c.unformat()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) format() string {
|
|
||||||
return fmt.Sprintf("%s[%sm", escape, c.sequence())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) unformat() string {
|
|
||||||
return fmt.Sprintf("%s[%dm", escape, Reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DisableColor disables the color output. Useful to not change any existing
|
|
||||||
// code and still being able to output. Can be used for flags like
|
|
||||||
// "--no-color". To enable back use EnableColor() method.
|
|
||||||
func (c *Color) DisableColor() {
|
|
||||||
c.noColor = boolPtr(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// EnableColor enables the color output. Use it in conjunction with
|
|
||||||
// DisableColor(). Otherwise this method has no side effects.
|
|
||||||
func (c *Color) EnableColor() {
|
|
||||||
c.noColor = boolPtr(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) isNoColorSet() bool {
|
|
||||||
// check first if we have user setted action
|
|
||||||
if c.noColor != nil {
|
|
||||||
return *c.noColor
|
|
||||||
}
|
|
||||||
|
|
||||||
// if not return the global option, which is disabled by default
|
|
||||||
return NoColor
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equals returns a boolean value indicating whether two colors are equal.
|
|
||||||
func (c *Color) Equals(c2 *Color) bool {
|
|
||||||
if len(c.params) != len(c2.params) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, attr := range c.params {
|
|
||||||
if !c2.attrExists(attr) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Color) attrExists(a Attribute) bool {
|
|
||||||
for _, attr := range c.params {
|
|
||||||
if attr == a {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func boolPtr(v bool) *bool {
|
|
||||||
return &v
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCachedColor(p Attribute) *Color {
|
|
||||||
colorsCacheMu.Lock()
|
|
||||||
defer colorsCacheMu.Unlock()
|
|
||||||
|
|
||||||
c, ok := colorsCache[p]
|
|
||||||
if !ok {
|
|
||||||
c = New(p)
|
|
||||||
colorsCache[p] = c
|
|
||||||
}
|
|
||||||
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func colorPrint(format string, p Attribute, a ...interface{}) {
|
|
||||||
c := getCachedColor(p)
|
|
||||||
|
|
||||||
if !strings.HasSuffix(format, "\n") {
|
|
||||||
format += "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(a) == 0 {
|
|
||||||
c.Print(format)
|
|
||||||
} else {
|
|
||||||
c.Printf(format, a...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func colorString(format string, p Attribute, a ...interface{}) string {
|
|
||||||
c := getCachedColor(p)
|
|
||||||
|
|
||||||
if len(a) == 0 {
|
|
||||||
return c.SprintFunc()(format)
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.SprintfFunc()(format, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Black is a convenient helper function to print with black foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
|
|
||||||
|
|
||||||
// Red is a convenient helper function to print with red foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
|
|
||||||
|
|
||||||
// Green is a convenient helper function to print with green foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
|
|
||||||
|
|
||||||
// Yellow is a convenient helper function to print with yellow foreground.
|
|
||||||
// A newline is appended to format by default.
|
|
||||||
func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
|
|
||||||
|
|
||||||
// Blue is a convenient helper function to print with blue foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
|
|
||||||
|
|
||||||
// Magenta is a convenient helper function to print with magenta foreground.
|
|
||||||
// A newline is appended to format by default.
|
|
||||||
func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
|
|
||||||
|
|
||||||
// Cyan is a convenient helper function to print with cyan foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
|
|
||||||
|
|
||||||
// White is a convenient helper function to print with white foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
|
|
||||||
|
|
||||||
// BlackString is a convenient helper function to return a string with black
|
|
||||||
// foreground.
|
|
||||||
func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
|
|
||||||
|
|
||||||
// RedString is a convenient helper function to return a string with red
|
|
||||||
// foreground.
|
|
||||||
func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
|
|
||||||
|
|
||||||
// GreenString is a convenient helper function to return a string with green
|
|
||||||
// foreground.
|
|
||||||
func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
|
|
||||||
|
|
||||||
// YellowString is a convenient helper function to return a string with yellow
|
|
||||||
// foreground.
|
|
||||||
func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
|
|
||||||
|
|
||||||
// BlueString is a convenient helper function to return a string with blue
|
|
||||||
// foreground.
|
|
||||||
func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
|
|
||||||
|
|
||||||
// MagentaString is a convenient helper function to return a string with magenta
|
|
||||||
// foreground.
|
|
||||||
func MagentaString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgMagenta, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CyanString is a convenient helper function to return a string with cyan
|
|
||||||
// foreground.
|
|
||||||
func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
|
|
||||||
|
|
||||||
// WhiteString is a convenient helper function to return a string with white
|
|
||||||
// foreground.
|
|
||||||
func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
|
|
||||||
|
|
||||||
// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
|
|
||||||
|
|
||||||
// HiRed is a convenient helper function to print with hi-intensity red foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
|
|
||||||
|
|
||||||
// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
|
|
||||||
|
|
||||||
// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
|
|
||||||
// A newline is appended to format by default.
|
|
||||||
func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
|
|
||||||
|
|
||||||
// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
|
|
||||||
|
|
||||||
// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
|
|
||||||
// A newline is appended to format by default.
|
|
||||||
func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
|
|
||||||
|
|
||||||
// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
|
|
||||||
|
|
||||||
// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
|
|
||||||
// newline is appended to format by default.
|
|
||||||
func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
|
|
||||||
|
|
||||||
// HiBlackString is a convenient helper function to return a string with hi-intensity black
|
|
||||||
// foreground.
|
|
||||||
func HiBlackString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgHiBlack, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HiRedString is a convenient helper function to return a string with hi-intensity red
|
|
||||||
// foreground.
|
|
||||||
func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
|
|
||||||
|
|
||||||
// HiGreenString is a convenient helper function to return a string with hi-intensity green
|
|
||||||
// foreground.
|
|
||||||
func HiGreenString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgHiGreen, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
|
|
||||||
// foreground.
|
|
||||||
func HiYellowString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgHiYellow, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HiBlueString is a convenient helper function to return a string with hi-intensity blue
|
|
||||||
// foreground.
|
|
||||||
func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
|
|
||||||
|
|
||||||
// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
|
|
||||||
// foreground.
|
|
||||||
func HiMagentaString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgHiMagenta, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
|
|
||||||
// foreground.
|
|
||||||
func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
|
|
||||||
|
|
||||||
// HiWhiteString is a convenient helper function to return a string with hi-intensity white
|
|
||||||
// foreground.
|
|
||||||
func HiWhiteString(format string, a ...interface{}) string {
|
|
||||||
return colorString(format, FgHiWhite, a...)
|
|
||||||
}
|
|
133
vendor/github.com/fatih/color/doc.go
generated
vendored
133
vendor/github.com/fatih/color/doc.go
generated
vendored
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
Package color is an ANSI color package to output colorized or SGR defined
|
|
||||||
output to the standard output. The API can be used in several way, pick one
|
|
||||||
that suits you.
|
|
||||||
|
|
||||||
Use simple and default helper functions with predefined foreground colors:
|
|
||||||
|
|
||||||
color.Cyan("Prints text in cyan.")
|
|
||||||
|
|
||||||
// a newline will be appended automatically
|
|
||||||
color.Blue("Prints %s in blue.", "text")
|
|
||||||
|
|
||||||
// More default foreground colors..
|
|
||||||
color.Red("We have red")
|
|
||||||
color.Yellow("Yellow color too!")
|
|
||||||
color.Magenta("And many others ..")
|
|
||||||
|
|
||||||
// Hi-intensity colors
|
|
||||||
color.HiGreen("Bright green color.")
|
|
||||||
color.HiBlack("Bright black means gray..")
|
|
||||||
color.HiWhite("Shiny white color!")
|
|
||||||
|
|
||||||
However there are times where custom color mixes are required. Below are some
|
|
||||||
examples to create custom color objects and use the print functions of each
|
|
||||||
separate color object.
|
|
||||||
|
|
||||||
// Create a new color object
|
|
||||||
c := color.New(color.FgCyan).Add(color.Underline)
|
|
||||||
c.Println("Prints cyan text with an underline.")
|
|
||||||
|
|
||||||
// Or just add them to New()
|
|
||||||
d := color.New(color.FgCyan, color.Bold)
|
|
||||||
d.Printf("This prints bold cyan %s\n", "too!.")
|
|
||||||
|
|
||||||
|
|
||||||
// Mix up foreground and background colors, create new mixes!
|
|
||||||
red := color.New(color.FgRed)
|
|
||||||
|
|
||||||
boldRed := red.Add(color.Bold)
|
|
||||||
boldRed.Println("This will print text in bold red.")
|
|
||||||
|
|
||||||
whiteBackground := red.Add(color.BgWhite)
|
|
||||||
whiteBackground.Println("Red text with White background.")
|
|
||||||
|
|
||||||
// Use your own io.Writer output
|
|
||||||
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
|
|
||||||
|
|
||||||
blue := color.New(color.FgBlue)
|
|
||||||
blue.Fprint(myWriter, "This will print text in blue.")
|
|
||||||
|
|
||||||
You can create PrintXxx functions to simplify even more:
|
|
||||||
|
|
||||||
// Create a custom print function for convenient
|
|
||||||
red := color.New(color.FgRed).PrintfFunc()
|
|
||||||
red("warning")
|
|
||||||
red("error: %s", err)
|
|
||||||
|
|
||||||
// Mix up multiple attributes
|
|
||||||
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
|
|
||||||
notice("don't forget this...")
|
|
||||||
|
|
||||||
You can also FprintXxx functions to pass your own io.Writer:
|
|
||||||
|
|
||||||
blue := color.New(FgBlue).FprintfFunc()
|
|
||||||
blue(myWriter, "important notice: %s", stars)
|
|
||||||
|
|
||||||
// Mix up with multiple attributes
|
|
||||||
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
|
|
||||||
success(myWriter, don't forget this...")
|
|
||||||
|
|
||||||
|
|
||||||
Or create SprintXxx functions to mix strings with other non-colorized strings:
|
|
||||||
|
|
||||||
yellow := New(FgYellow).SprintFunc()
|
|
||||||
red := New(FgRed).SprintFunc()
|
|
||||||
|
|
||||||
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
|
|
||||||
|
|
||||||
info := New(FgWhite, BgGreen).SprintFunc()
|
|
||||||
fmt.Printf("this %s rocks!\n", info("package"))
|
|
||||||
|
|
||||||
Windows support is enabled by default. All Print functions work as intended.
|
|
||||||
However only for color.SprintXXX functions, user should use fmt.FprintXXX and
|
|
||||||
set the output to color.Output:
|
|
||||||
|
|
||||||
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
|
|
||||||
|
|
||||||
info := New(FgWhite, BgGreen).SprintFunc()
|
|
||||||
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
|
|
||||||
|
|
||||||
Using with existing code is possible. Just use the Set() method to set the
|
|
||||||
standard output to the given parameters. That way a rewrite of an existing
|
|
||||||
code is not required.
|
|
||||||
|
|
||||||
// Use handy standard colors.
|
|
||||||
color.Set(color.FgYellow)
|
|
||||||
|
|
||||||
fmt.Println("Existing text will be now in Yellow")
|
|
||||||
fmt.Printf("This one %s\n", "too")
|
|
||||||
|
|
||||||
color.Unset() // don't forget to unset
|
|
||||||
|
|
||||||
// You can mix up parameters
|
|
||||||
color.Set(color.FgMagenta, color.Bold)
|
|
||||||
defer color.Unset() // use it in your function
|
|
||||||
|
|
||||||
fmt.Println("All text will be now bold magenta.")
|
|
||||||
|
|
||||||
There might be a case where you want to disable color output (for example to
|
|
||||||
pipe the standard output of your app to somewhere else). `Color` has support to
|
|
||||||
disable colors both globally and for single color definition. For example
|
|
||||||
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
|
|
||||||
the color output with:
|
|
||||||
|
|
||||||
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
|
|
||||||
|
|
||||||
if *flagNoColor {
|
|
||||||
color.NoColor = true // disables colorized output
|
|
||||||
}
|
|
||||||
|
|
||||||
It also has support for single color definitions (local). You can
|
|
||||||
disable/enable color output on the fly:
|
|
||||||
|
|
||||||
c := color.New(color.FgCyan)
|
|
||||||
c.Println("Prints cyan text")
|
|
||||||
|
|
||||||
c.DisableColor()
|
|
||||||
c.Println("This is printed without any color")
|
|
||||||
|
|
||||||
c.EnableColor()
|
|
||||||
c.Println("This prints again cyan...")
|
|
||||||
*/
|
|
||||||
package color
|
|
9
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
9
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
|
@ -1,9 +0,0 @@
|
||||||
language: go
|
|
||||||
go:
|
|
||||||
- tip
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- go get github.com/mattn/goveralls
|
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
|
||||||
- $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw
|
|
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
|
@ -1,21 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Yasuhiro Matsumoto
|
|
||||||
|
|
||||||
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.
|
|
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
|
@ -1,48 +0,0 @@
|
||||||
# go-colorable
|
|
||||||
|
|
||||||
[![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable)
|
|
||||||
[![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable)
|
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master)
|
|
||||||
[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable)
|
|
||||||
|
|
||||||
Colorable writer for windows.
|
|
||||||
|
|
||||||
For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
|
|
||||||
This package is possible to handle escape sequence for ansi color on windows.
|
|
||||||
|
|
||||||
## Too Bad!
|
|
||||||
|
|
||||||
![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png)
|
|
||||||
|
|
||||||
|
|
||||||
## So Good!
|
|
||||||
|
|
||||||
![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```go
|
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
|
||||||
logrus.SetOutput(colorable.NewColorableStdout())
|
|
||||||
|
|
||||||
logrus.Info("succeeded")
|
|
||||||
logrus.Warn("not correct")
|
|
||||||
logrus.Error("something error")
|
|
||||||
logrus.Fatal("panic")
|
|
||||||
```
|
|
||||||
|
|
||||||
You can compile above code on non-windows OSs.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```
|
|
||||||
$ go get github.com/mattn/go-colorable
|
|
||||||
```
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
# Author
|
|
||||||
|
|
||||||
Yasuhiro Matsumoto (a.k.a mattn)
|
|
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
|
@ -1,29 +0,0 @@
|
||||||
// +build appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
|
@ -1,30 +0,0 @@
|
||||||
// +build !windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
|
@ -1,884 +0,0 @@
|
||||||
// +build windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
foregroundBlue = 0x1
|
|
||||||
foregroundGreen = 0x2
|
|
||||||
foregroundRed = 0x4
|
|
||||||
foregroundIntensity = 0x8
|
|
||||||
foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
|
|
||||||
backgroundBlue = 0x10
|
|
||||||
backgroundGreen = 0x20
|
|
||||||
backgroundRed = 0x40
|
|
||||||
backgroundIntensity = 0x80
|
|
||||||
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
|
|
||||||
)
|
|
||||||
|
|
||||||
type wchar uint16
|
|
||||||
type short int16
|
|
||||||
type dword uint32
|
|
||||||
type word uint16
|
|
||||||
|
|
||||||
type coord struct {
|
|
||||||
x short
|
|
||||||
y short
|
|
||||||
}
|
|
||||||
|
|
||||||
type smallRect struct {
|
|
||||||
left short
|
|
||||||
top short
|
|
||||||
right short
|
|
||||||
bottom short
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleScreenBufferInfo struct {
|
|
||||||
size coord
|
|
||||||
cursorPosition coord
|
|
||||||
attributes word
|
|
||||||
window smallRect
|
|
||||||
maximumWindowSize coord
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleCursorInfo struct {
|
|
||||||
size dword
|
|
||||||
visible int32
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
||||||
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
|
||||||
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
|
|
||||||
procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
|
|
||||||
procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
|
|
||||||
procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
|
|
||||||
procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
|
|
||||||
procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
|
|
||||||
procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Writer provide colorable Writer to the console
|
|
||||||
type Writer struct {
|
|
||||||
out io.Writer
|
|
||||||
handle syscall.Handle
|
|
||||||
oldattr word
|
|
||||||
oldpos coord
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence from File.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isatty.IsTerminal(file.Fd()) {
|
|
||||||
var csbi consoleScreenBufferInfo
|
|
||||||
handle := syscall.Handle(file.Fd())
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
|
|
||||||
}
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return NewColorable(os.Stdout)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return NewColorable(os.Stderr)
|
|
||||||
}
|
|
||||||
|
|
||||||
var color256 = map[int]int{
|
|
||||||
0: 0x000000,
|
|
||||||
1: 0x800000,
|
|
||||||
2: 0x008000,
|
|
||||||
3: 0x808000,
|
|
||||||
4: 0x000080,
|
|
||||||
5: 0x800080,
|
|
||||||
6: 0x008080,
|
|
||||||
7: 0xc0c0c0,
|
|
||||||
8: 0x808080,
|
|
||||||
9: 0xff0000,
|
|
||||||
10: 0x00ff00,
|
|
||||||
11: 0xffff00,
|
|
||||||
12: 0x0000ff,
|
|
||||||
13: 0xff00ff,
|
|
||||||
14: 0x00ffff,
|
|
||||||
15: 0xffffff,
|
|
||||||
16: 0x000000,
|
|
||||||
17: 0x00005f,
|
|
||||||
18: 0x000087,
|
|
||||||
19: 0x0000af,
|
|
||||||
20: 0x0000d7,
|
|
||||||
21: 0x0000ff,
|
|
||||||
22: 0x005f00,
|
|
||||||
23: 0x005f5f,
|
|
||||||
24: 0x005f87,
|
|
||||||
25: 0x005faf,
|
|
||||||
26: 0x005fd7,
|
|
||||||
27: 0x005fff,
|
|
||||||
28: 0x008700,
|
|
||||||
29: 0x00875f,
|
|
||||||
30: 0x008787,
|
|
||||||
31: 0x0087af,
|
|
||||||
32: 0x0087d7,
|
|
||||||
33: 0x0087ff,
|
|
||||||
34: 0x00af00,
|
|
||||||
35: 0x00af5f,
|
|
||||||
36: 0x00af87,
|
|
||||||
37: 0x00afaf,
|
|
||||||
38: 0x00afd7,
|
|
||||||
39: 0x00afff,
|
|
||||||
40: 0x00d700,
|
|
||||||
41: 0x00d75f,
|
|
||||||
42: 0x00d787,
|
|
||||||
43: 0x00d7af,
|
|
||||||
44: 0x00d7d7,
|
|
||||||
45: 0x00d7ff,
|
|
||||||
46: 0x00ff00,
|
|
||||||
47: 0x00ff5f,
|
|
||||||
48: 0x00ff87,
|
|
||||||
49: 0x00ffaf,
|
|
||||||
50: 0x00ffd7,
|
|
||||||
51: 0x00ffff,
|
|
||||||
52: 0x5f0000,
|
|
||||||
53: 0x5f005f,
|
|
||||||
54: 0x5f0087,
|
|
||||||
55: 0x5f00af,
|
|
||||||
56: 0x5f00d7,
|
|
||||||
57: 0x5f00ff,
|
|
||||||
58: 0x5f5f00,
|
|
||||||
59: 0x5f5f5f,
|
|
||||||
60: 0x5f5f87,
|
|
||||||
61: 0x5f5faf,
|
|
||||||
62: 0x5f5fd7,
|
|
||||||
63: 0x5f5fff,
|
|
||||||
64: 0x5f8700,
|
|
||||||
65: 0x5f875f,
|
|
||||||
66: 0x5f8787,
|
|
||||||
67: 0x5f87af,
|
|
||||||
68: 0x5f87d7,
|
|
||||||
69: 0x5f87ff,
|
|
||||||
70: 0x5faf00,
|
|
||||||
71: 0x5faf5f,
|
|
||||||
72: 0x5faf87,
|
|
||||||
73: 0x5fafaf,
|
|
||||||
74: 0x5fafd7,
|
|
||||||
75: 0x5fafff,
|
|
||||||
76: 0x5fd700,
|
|
||||||
77: 0x5fd75f,
|
|
||||||
78: 0x5fd787,
|
|
||||||
79: 0x5fd7af,
|
|
||||||
80: 0x5fd7d7,
|
|
||||||
81: 0x5fd7ff,
|
|
||||||
82: 0x5fff00,
|
|
||||||
83: 0x5fff5f,
|
|
||||||
84: 0x5fff87,
|
|
||||||
85: 0x5fffaf,
|
|
||||||
86: 0x5fffd7,
|
|
||||||
87: 0x5fffff,
|
|
||||||
88: 0x870000,
|
|
||||||
89: 0x87005f,
|
|
||||||
90: 0x870087,
|
|
||||||
91: 0x8700af,
|
|
||||||
92: 0x8700d7,
|
|
||||||
93: 0x8700ff,
|
|
||||||
94: 0x875f00,
|
|
||||||
95: 0x875f5f,
|
|
||||||
96: 0x875f87,
|
|
||||||
97: 0x875faf,
|
|
||||||
98: 0x875fd7,
|
|
||||||
99: 0x875fff,
|
|
||||||
100: 0x878700,
|
|
||||||
101: 0x87875f,
|
|
||||||
102: 0x878787,
|
|
||||||
103: 0x8787af,
|
|
||||||
104: 0x8787d7,
|
|
||||||
105: 0x8787ff,
|
|
||||||
106: 0x87af00,
|
|
||||||
107: 0x87af5f,
|
|
||||||
108: 0x87af87,
|
|
||||||
109: 0x87afaf,
|
|
||||||
110: 0x87afd7,
|
|
||||||
111: 0x87afff,
|
|
||||||
112: 0x87d700,
|
|
||||||
113: 0x87d75f,
|
|
||||||
114: 0x87d787,
|
|
||||||
115: 0x87d7af,
|
|
||||||
116: 0x87d7d7,
|
|
||||||
117: 0x87d7ff,
|
|
||||||
118: 0x87ff00,
|
|
||||||
119: 0x87ff5f,
|
|
||||||
120: 0x87ff87,
|
|
||||||
121: 0x87ffaf,
|
|
||||||
122: 0x87ffd7,
|
|
||||||
123: 0x87ffff,
|
|
||||||
124: 0xaf0000,
|
|
||||||
125: 0xaf005f,
|
|
||||||
126: 0xaf0087,
|
|
||||||
127: 0xaf00af,
|
|
||||||
128: 0xaf00d7,
|
|
||||||
129: 0xaf00ff,
|
|
||||||
130: 0xaf5f00,
|
|
||||||
131: 0xaf5f5f,
|
|
||||||
132: 0xaf5f87,
|
|
||||||
133: 0xaf5faf,
|
|
||||||
134: 0xaf5fd7,
|
|
||||||
135: 0xaf5fff,
|
|
||||||
136: 0xaf8700,
|
|
||||||
137: 0xaf875f,
|
|
||||||
138: 0xaf8787,
|
|
||||||
139: 0xaf87af,
|
|
||||||
140: 0xaf87d7,
|
|
||||||
141: 0xaf87ff,
|
|
||||||
142: 0xafaf00,
|
|
||||||
143: 0xafaf5f,
|
|
||||||
144: 0xafaf87,
|
|
||||||
145: 0xafafaf,
|
|
||||||
146: 0xafafd7,
|
|
||||||
147: 0xafafff,
|
|
||||||
148: 0xafd700,
|
|
||||||
149: 0xafd75f,
|
|
||||||
150: 0xafd787,
|
|
||||||
151: 0xafd7af,
|
|
||||||
152: 0xafd7d7,
|
|
||||||
153: 0xafd7ff,
|
|
||||||
154: 0xafff00,
|
|
||||||
155: 0xafff5f,
|
|
||||||
156: 0xafff87,
|
|
||||||
157: 0xafffaf,
|
|
||||||
158: 0xafffd7,
|
|
||||||
159: 0xafffff,
|
|
||||||
160: 0xd70000,
|
|
||||||
161: 0xd7005f,
|
|
||||||
162: 0xd70087,
|
|
||||||
163: 0xd700af,
|
|
||||||
164: 0xd700d7,
|
|
||||||
165: 0xd700ff,
|
|
||||||
166: 0xd75f00,
|
|
||||||
167: 0xd75f5f,
|
|
||||||
168: 0xd75f87,
|
|
||||||
169: 0xd75faf,
|
|
||||||
170: 0xd75fd7,
|
|
||||||
171: 0xd75fff,
|
|
||||||
172: 0xd78700,
|
|
||||||
173: 0xd7875f,
|
|
||||||
174: 0xd78787,
|
|
||||||
175: 0xd787af,
|
|
||||||
176: 0xd787d7,
|
|
||||||
177: 0xd787ff,
|
|
||||||
178: 0xd7af00,
|
|
||||||
179: 0xd7af5f,
|
|
||||||
180: 0xd7af87,
|
|
||||||
181: 0xd7afaf,
|
|
||||||
182: 0xd7afd7,
|
|
||||||
183: 0xd7afff,
|
|
||||||
184: 0xd7d700,
|
|
||||||
185: 0xd7d75f,
|
|
||||||
186: 0xd7d787,
|
|
||||||
187: 0xd7d7af,
|
|
||||||
188: 0xd7d7d7,
|
|
||||||
189: 0xd7d7ff,
|
|
||||||
190: 0xd7ff00,
|
|
||||||
191: 0xd7ff5f,
|
|
||||||
192: 0xd7ff87,
|
|
||||||
193: 0xd7ffaf,
|
|
||||||
194: 0xd7ffd7,
|
|
||||||
195: 0xd7ffff,
|
|
||||||
196: 0xff0000,
|
|
||||||
197: 0xff005f,
|
|
||||||
198: 0xff0087,
|
|
||||||
199: 0xff00af,
|
|
||||||
200: 0xff00d7,
|
|
||||||
201: 0xff00ff,
|
|
||||||
202: 0xff5f00,
|
|
||||||
203: 0xff5f5f,
|
|
||||||
204: 0xff5f87,
|
|
||||||
205: 0xff5faf,
|
|
||||||
206: 0xff5fd7,
|
|
||||||
207: 0xff5fff,
|
|
||||||
208: 0xff8700,
|
|
||||||
209: 0xff875f,
|
|
||||||
210: 0xff8787,
|
|
||||||
211: 0xff87af,
|
|
||||||
212: 0xff87d7,
|
|
||||||
213: 0xff87ff,
|
|
||||||
214: 0xffaf00,
|
|
||||||
215: 0xffaf5f,
|
|
||||||
216: 0xffaf87,
|
|
||||||
217: 0xffafaf,
|
|
||||||
218: 0xffafd7,
|
|
||||||
219: 0xffafff,
|
|
||||||
220: 0xffd700,
|
|
||||||
221: 0xffd75f,
|
|
||||||
222: 0xffd787,
|
|
||||||
223: 0xffd7af,
|
|
||||||
224: 0xffd7d7,
|
|
||||||
225: 0xffd7ff,
|
|
||||||
226: 0xffff00,
|
|
||||||
227: 0xffff5f,
|
|
||||||
228: 0xffff87,
|
|
||||||
229: 0xffffaf,
|
|
||||||
230: 0xffffd7,
|
|
||||||
231: 0xffffff,
|
|
||||||
232: 0x080808,
|
|
||||||
233: 0x121212,
|
|
||||||
234: 0x1c1c1c,
|
|
||||||
235: 0x262626,
|
|
||||||
236: 0x303030,
|
|
||||||
237: 0x3a3a3a,
|
|
||||||
238: 0x444444,
|
|
||||||
239: 0x4e4e4e,
|
|
||||||
240: 0x585858,
|
|
||||||
241: 0x626262,
|
|
||||||
242: 0x6c6c6c,
|
|
||||||
243: 0x767676,
|
|
||||||
244: 0x808080,
|
|
||||||
245: 0x8a8a8a,
|
|
||||||
246: 0x949494,
|
|
||||||
247: 0x9e9e9e,
|
|
||||||
248: 0xa8a8a8,
|
|
||||||
249: 0xb2b2b2,
|
|
||||||
250: 0xbcbcbc,
|
|
||||||
251: 0xc6c6c6,
|
|
||||||
252: 0xd0d0d0,
|
|
||||||
253: 0xdadada,
|
|
||||||
254: 0xe4e4e4,
|
|
||||||
255: 0xeeeeee,
|
|
||||||
}
|
|
||||||
|
|
||||||
// `\033]0;TITLESTR\007`
|
|
||||||
func doTitleSequence(er *bytes.Reader) error {
|
|
||||||
var c byte
|
|
||||||
var err error
|
|
||||||
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c != '0' && c != '2' {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c != ';' {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
title := make([]byte, 0, 80)
|
|
||||||
for {
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c == 0x07 || c == '\n' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
title = append(title, c)
|
|
||||||
}
|
|
||||||
if len(title) > 0 {
|
|
||||||
title8, err := syscall.UTF16PtrFromString(string(title))
|
|
||||||
if err == nil {
|
|
||||||
procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write write data on console
|
|
||||||
func (w *Writer) Write(data []byte) (n int, err error) {
|
|
||||||
var csbi consoleScreenBufferInfo
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
|
|
||||||
er := bytes.NewReader(data)
|
|
||||||
var bw [1]byte
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
c1, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c1 != 0x1b {
|
|
||||||
bw[0] = c1
|
|
||||||
w.out.Write(bw[:])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c2, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
|
|
||||||
if c2 == ']' {
|
|
||||||
if err := doTitleSequence(er); err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if c2 != 0x5b {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
var m byte
|
|
||||||
for {
|
|
||||||
c, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
|
||||||
m = c
|
|
||||||
break
|
|
||||||
}
|
|
||||||
buf.Write([]byte(string(c)))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch m {
|
|
||||||
case 'A':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.y -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'B':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.y += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'C':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'D':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'E':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = 0
|
|
||||||
csbi.cursorPosition.y += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'F':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = 0
|
|
||||||
csbi.cursorPosition.y -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'G':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = short(n - 1)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'H', 'f':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
token := strings.Split(buf.String(), ";")
|
|
||||||
switch len(token) {
|
|
||||||
case 1:
|
|
||||||
n1, err := strconv.Atoi(token[0])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
csbi.cursorPosition.y = short(n1 - 1)
|
|
||||||
case 2:
|
|
||||||
n1, err := strconv.Atoi(token[0])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
n2, err := strconv.Atoi(token[1])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
csbi.cursorPosition.x = short(n2 - 1)
|
|
||||||
csbi.cursorPosition.y = short(n1 - 1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
csbi.cursorPosition.y = 0
|
|
||||||
}
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'J':
|
|
||||||
n := 0
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var count, written dword
|
|
||||||
var cursor coord
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
switch n {
|
|
||||||
case 0:
|
|
||||||
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
case 1:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
case 2:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
}
|
|
||||||
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
case 'K':
|
|
||||||
n := 0
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
var cursor coord
|
|
||||||
var count, written dword
|
|
||||||
switch n {
|
|
||||||
case 0:
|
|
||||||
cursor = coord{x: csbi.cursorPosition.x + 1, y: csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x - 1)
|
|
||||||
case 1:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x)
|
|
||||||
case 2:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x)
|
|
||||||
}
|
|
||||||
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
case 'm':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
attr := csbi.attributes
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "" {
|
|
||||||
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
token := strings.Split(cs, ";")
|
|
||||||
for i := 0; i < len(token); i++ {
|
|
||||||
ns := token[i]
|
|
||||||
if n, err = strconv.Atoi(ns); err == nil {
|
|
||||||
switch {
|
|
||||||
case n == 0 || n == 100:
|
|
||||||
attr = w.oldattr
|
|
||||||
case 1 <= n && n <= 5:
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
case n == 7:
|
|
||||||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
|
||||||
case n == 22 || n == 25:
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
case n == 27:
|
|
||||||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
|
||||||
case 30 <= n && n <= 37:
|
|
||||||
attr &= backgroundMask
|
|
||||||
if (n-30)&1 != 0 {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if (n-30)&2 != 0 {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if (n-30)&4 != 0 {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
case n == 38: // set foreground color.
|
|
||||||
if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
|
|
||||||
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
|
||||||
if n256foreAttr == nil {
|
|
||||||
n256setup()
|
|
||||||
}
|
|
||||||
attr &= backgroundMask
|
|
||||||
attr |= n256foreAttr[n256]
|
|
||||||
i += 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attr = attr & (w.oldattr & backgroundMask)
|
|
||||||
}
|
|
||||||
case n == 39: // reset foreground color.
|
|
||||||
attr &= backgroundMask
|
|
||||||
attr |= w.oldattr & foregroundMask
|
|
||||||
case 40 <= n && n <= 47:
|
|
||||||
attr &= foregroundMask
|
|
||||||
if (n-40)&1 != 0 {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if (n-40)&2 != 0 {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if (n-40)&4 != 0 {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
case n == 48: // set background color.
|
|
||||||
if i < len(token)-2 && token[i+1] == "5" {
|
|
||||||
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
|
||||||
if n256backAttr == nil {
|
|
||||||
n256setup()
|
|
||||||
}
|
|
||||||
attr &= foregroundMask
|
|
||||||
attr |= n256backAttr[n256]
|
|
||||||
i += 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attr = attr & (w.oldattr & foregroundMask)
|
|
||||||
}
|
|
||||||
case n == 49: // reset foreground color.
|
|
||||||
attr &= foregroundMask
|
|
||||||
attr |= w.oldattr & backgroundMask
|
|
||||||
case 90 <= n && n <= 97:
|
|
||||||
attr = (attr & backgroundMask)
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
if (n-90)&1 != 0 {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if (n-90)&2 != 0 {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if (n-90)&4 != 0 {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
case 100 <= n && n <= 107:
|
|
||||||
attr = (attr & foregroundMask)
|
|
||||||
attr |= backgroundIntensity
|
|
||||||
if (n-100)&1 != 0 {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if (n-100)&2 != 0 {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if (n-100)&4 != 0 {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'h':
|
|
||||||
var ci consoleCursorInfo
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "5>" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 0
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
} else if cs == "?25" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 1
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
}
|
|
||||||
case 'l':
|
|
||||||
var ci consoleCursorInfo
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "5>" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 1
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
} else if cs == "?25" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 0
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
}
|
|
||||||
case 's':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
w.oldpos = csbi.cursorPosition
|
|
||||||
case 'u':
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(data), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleColor struct {
|
|
||||||
rgb int
|
|
||||||
red bool
|
|
||||||
green bool
|
|
||||||
blue bool
|
|
||||||
intensity bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c consoleColor) foregroundAttr() (attr word) {
|
|
||||||
if c.red {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if c.green {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if c.blue {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
if c.intensity {
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c consoleColor) backgroundAttr() (attr word) {
|
|
||||||
if c.red {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if c.green {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if c.blue {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
if c.intensity {
|
|
||||||
attr |= backgroundIntensity
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var color16 = []consoleColor{
|
|
||||||
{0x000000, false, false, false, false},
|
|
||||||
{0x000080, false, false, true, false},
|
|
||||||
{0x008000, false, true, false, false},
|
|
||||||
{0x008080, false, true, true, false},
|
|
||||||
{0x800000, true, false, false, false},
|
|
||||||
{0x800080, true, false, true, false},
|
|
||||||
{0x808000, true, true, false, false},
|
|
||||||
{0xc0c0c0, true, true, true, false},
|
|
||||||
{0x808080, false, false, false, true},
|
|
||||||
{0x0000ff, false, false, true, true},
|
|
||||||
{0x00ff00, false, true, false, true},
|
|
||||||
{0x00ffff, false, true, true, true},
|
|
||||||
{0xff0000, true, false, false, true},
|
|
||||||
{0xff00ff, true, false, true, true},
|
|
||||||
{0xffff00, true, true, false, true},
|
|
||||||
{0xffffff, true, true, true, true},
|
|
||||||
}
|
|
||||||
|
|
||||||
type hsv struct {
|
|
||||||
h, s, v float32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a hsv) dist(b hsv) float32 {
|
|
||||||
dh := a.h - b.h
|
|
||||||
switch {
|
|
||||||
case dh > 0.5:
|
|
||||||
dh = 1 - dh
|
|
||||||
case dh < -0.5:
|
|
||||||
dh = -1 - dh
|
|
||||||
}
|
|
||||||
ds := a.s - b.s
|
|
||||||
dv := a.v - b.v
|
|
||||||
return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func toHSV(rgb int) hsv {
|
|
||||||
r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
|
|
||||||
float32((rgb&0x00FF00)>>8)/256.0,
|
|
||||||
float32(rgb&0x0000FF)/256.0
|
|
||||||
min, max := minmax3f(r, g, b)
|
|
||||||
h := max - min
|
|
||||||
if h > 0 {
|
|
||||||
if max == r {
|
|
||||||
h = (g - b) / h
|
|
||||||
if h < 0 {
|
|
||||||
h += 6
|
|
||||||
}
|
|
||||||
} else if max == g {
|
|
||||||
h = 2 + (b-r)/h
|
|
||||||
} else {
|
|
||||||
h = 4 + (r-g)/h
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h /= 6.0
|
|
||||||
s := max - min
|
|
||||||
if max != 0 {
|
|
||||||
s /= max
|
|
||||||
}
|
|
||||||
v := max
|
|
||||||
return hsv{h: h, s: s, v: v}
|
|
||||||
}
|
|
||||||
|
|
||||||
type hsvTable []hsv
|
|
||||||
|
|
||||||
func toHSVTable(rgbTable []consoleColor) hsvTable {
|
|
||||||
t := make(hsvTable, len(rgbTable))
|
|
||||||
for i, c := range rgbTable {
|
|
||||||
t[i] = toHSV(c.rgb)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t hsvTable) find(rgb int) consoleColor {
|
|
||||||
hsv := toHSV(rgb)
|
|
||||||
n := 7
|
|
||||||
l := float32(5.0)
|
|
||||||
for i, p := range t {
|
|
||||||
d := hsv.dist(p)
|
|
||||||
if d < l {
|
|
||||||
l, n = d, i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color16[n]
|
|
||||||
}
|
|
||||||
|
|
||||||
func minmax3f(a, b, c float32) (min, max float32) {
|
|
||||||
if a < b {
|
|
||||||
if b < c {
|
|
||||||
return a, c
|
|
||||||
} else if a < c {
|
|
||||||
return a, b
|
|
||||||
} else {
|
|
||||||
return c, b
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if a < c {
|
|
||||||
return b, c
|
|
||||||
} else if b < c {
|
|
||||||
return b, a
|
|
||||||
} else {
|
|
||||||
return c, a
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var n256foreAttr []word
|
|
||||||
var n256backAttr []word
|
|
||||||
|
|
||||||
func n256setup() {
|
|
||||||
n256foreAttr = make([]word, 256)
|
|
||||||
n256backAttr = make([]word, 256)
|
|
||||||
t := toHSVTable(color16)
|
|
||||||
for i, rgb := range color256 {
|
|
||||||
c := t.find(rgb)
|
|
||||||
n256foreAttr[i] = c.foregroundAttr()
|
|
||||||
n256backAttr[i] = c.backgroundAttr()
|
|
||||||
}
|
|
||||||
}
|
|
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
|
@ -1,55 +0,0 @@
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NonColorable hold writer but remove escape sequence.
|
|
||||||
type NonColorable struct {
|
|
||||||
out io.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewNonColorable return new instance of Writer which remove escape sequence from Writer.
|
|
||||||
func NewNonColorable(w io.Writer) io.Writer {
|
|
||||||
return &NonColorable{out: w}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write write data on console
|
|
||||||
func (w *NonColorable) Write(data []byte) (n int, err error) {
|
|
||||||
er := bytes.NewReader(data)
|
|
||||||
var bw [1]byte
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
c1, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c1 != 0x1b {
|
|
||||||
bw[0] = c1
|
|
||||||
w.out.Write(bw[:])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c2, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c2 != 0x5b {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
for {
|
|
||||||
c, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
buf.Write([]byte(string(c)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(data), nil
|
|
||||||
}
|
|
13
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
13
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
|
@ -1,13 +0,0 @@
|
||||||
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
|
|
9
vendor/github.com/mattn/go-isatty/LICENSE
generated
vendored
9
vendor/github.com/mattn/go-isatty/LICENSE
generated
vendored
|
@ -1,9 +0,0 @@
|
||||||
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.
|
|
50
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
50
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
|
@ -1,50 +0,0 @@
|
||||||
# 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
|
|
2
vendor/github.com/mattn/go-isatty/doc.go
generated
vendored
2
vendor/github.com/mattn/go-isatty/doc.go
generated
vendored
|
@ -1,2 +0,0 @@
|
||||||
// Package isatty implements interface to isatty
|
|
||||||
package isatty
|
|
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
|
@ -1,15 +0,0 @@
|
||||||
// +build appengine
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
// IsTerminal returns true if the file descriptor is terminal which
|
|
||||||
// is always false on on 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
|
|
||||||
}
|
|
18
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
18
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
|
@ -1,18 +0,0 @@
|
||||||
// +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
|
|
||||||
}
|
|
18
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
18
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
|
@ -1,18 +0,0 @@
|
||||||
// +build linux
|
|
||||||
// +build !appengine,!ppc64,!ppc64le
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
19
vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go
generated
vendored
19
vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go
generated
vendored
|
@ -1,19 +0,0 @@
|
||||||
// +build linux
|
|
||||||
// +build ppc64 ppc64le
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
syscall "golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
10
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
10
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
|
@ -1,10 +0,0 @@
|
||||||
// +build !windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
16
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
16
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
|
@ -1,16 +0,0 @@
|
||||||
// +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
|
|
||||||
}
|
|
94
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
94
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
|
@ -1,94 +0,0 @@
|
||||||
// +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])))
|
|
||||||
}
|
|
0
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
Executable file → Normal file
61
vendor/golang.org/x/sys/unix/mkasm_darwin.go
generated
vendored
61
vendor/golang.org/x/sys/unix/mkasm_darwin.go
generated
vendored
|
@ -1,61 +0,0 @@
|
||||||
// Copyright 2018 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
|
|
||||||
//This program must be run after mksyscall.go.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
in1, err := ioutil.ReadFile("syscall_darwin.go")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open syscall_darwin.go: %s", err)
|
|
||||||
}
|
|
||||||
arch := os.Args[1]
|
|
||||||
in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err)
|
|
||||||
}
|
|
||||||
in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err)
|
|
||||||
}
|
|
||||||
in := string(in1) + string(in2) + string(in3)
|
|
||||||
|
|
||||||
trampolines := map[string]bool{}
|
|
||||||
|
|
||||||
var out bytes.Buffer
|
|
||||||
|
|
||||||
fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " "))
|
|
||||||
fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n")
|
|
||||||
fmt.Fprintf(&out, "\n")
|
|
||||||
fmt.Fprintf(&out, "// +build go1.12\n")
|
|
||||||
fmt.Fprintf(&out, "\n")
|
|
||||||
fmt.Fprintf(&out, "#include \"textflag.h\"\n")
|
|
||||||
for _, line := range strings.Split(in, "\n") {
|
|
||||||
if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fn := line[5 : len(line)-13]
|
|
||||||
if !trampolines[fn] {
|
|
||||||
trampolines[fn] = true
|
|
||||||
fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
|
|
||||||
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err)
|
|
||||||
}
|
|
||||||
}
|
|
0
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
Executable file → Normal file
106
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
106
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
|
@ -1,106 +0,0 @@
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// mkpost processes the output of cgo -godefs to
|
|
||||||
// modify the generated types. It is used to clean up
|
|
||||||
// the sys API in an architecture specific manner.
|
|
||||||
//
|
|
||||||
// mkpost is run after cgo -godefs; see README.md.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"go/format"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Get the OS and architecture (using GOARCH_TARGET if it exists)
|
|
||||||
goos := os.Getenv("GOOS")
|
|
||||||
goarch := os.Getenv("GOARCH_TARGET")
|
|
||||||
if goarch == "" {
|
|
||||||
goarch = os.Getenv("GOARCH")
|
|
||||||
}
|
|
||||||
// Check that we are using the Docker-based build system if we should be.
|
|
||||||
if goos == "linux" {
|
|
||||||
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
|
|
||||||
os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n")
|
|
||||||
os.Stderr.WriteString("See README.md\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(os.Stdin)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Intentionally export __val fields in Fsid and Sigset_t
|
|
||||||
valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`)
|
|
||||||
b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}"))
|
|
||||||
|
|
||||||
// Intentionally export __fds_bits field in FdSet
|
|
||||||
fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`)
|
|
||||||
b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}"))
|
|
||||||
|
|
||||||
// If we have empty Ptrace structs, we should delete them. Only s390x emits
|
|
||||||
// nonempty Ptrace structs.
|
|
||||||
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
|
|
||||||
b = ptraceRexexp.ReplaceAll(b, nil)
|
|
||||||
|
|
||||||
// Replace the control_regs union with a blank identifier for now.
|
|
||||||
controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
|
|
||||||
b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
|
|
||||||
|
|
||||||
// Remove fields that are added by glibc
|
|
||||||
// Note that this is unstable as the identifers are private.
|
|
||||||
removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`)
|
|
||||||
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// Convert [65]int8 to [65]byte in Utsname members to simplify
|
|
||||||
// conversion to string; see golang.org/issue/20753
|
|
||||||
convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
|
|
||||||
b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
|
|
||||||
|
|
||||||
// Convert [1024]int8 to [1024]byte in Ptmget members
|
|
||||||
convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`)
|
|
||||||
b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte"))
|
|
||||||
|
|
||||||
// Remove spare fields (e.g. in Statx_t)
|
|
||||||
spareFieldsRegex := regexp.MustCompile(`X__spare\S*`)
|
|
||||||
b = spareFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// Remove cgo padding fields
|
|
||||||
removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
|
|
||||||
b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// Remove padding, hidden, or unused fields
|
|
||||||
removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`)
|
|
||||||
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// Remove the first line of warning from cgo
|
|
||||||
b = b[bytes.IndexByte(b, '\n')+1:]
|
|
||||||
// Modify the command in the header to include:
|
|
||||||
// mkpost, our own warning, and a build tag.
|
|
||||||
replacement := fmt.Sprintf(`$1 | go run mkpost.go
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build %s,%s`, goarch, goos)
|
|
||||||
cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
|
|
||||||
b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
|
|
||||||
|
|
||||||
// gofmt
|
|
||||||
b, err = format.Source(b)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
os.Stdout.Write(b)
|
|
||||||
}
|
|
398
vendor/golang.org/x/sys/unix/mksyscall.go
generated
vendored
398
vendor/golang.org/x/sys/unix/mksyscall.go
generated
vendored
|
@ -1,398 +0,0 @@
|
||||||
// Copyright 2018 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
This program reads a file containing function prototypes
|
|
||||||
(like syscall_darwin.go) and generates system call bodies.
|
|
||||||
The prototypes are marked by lines beginning with "//sys"
|
|
||||||
and read like func declarations if //sys is replaced by func, but:
|
|
||||||
* The parameter lists must give a name for each argument.
|
|
||||||
This includes return parameters.
|
|
||||||
* The parameter lists must give a type for each argument:
|
|
||||||
the (x, y, z int) shorthand is not allowed.
|
|
||||||
* If the return parameter is an error number, it must be named errno.
|
|
||||||
|
|
||||||
A line beginning with //sysnb is like //sys, except that the
|
|
||||||
goroutine will not be suspended during the execution of the system
|
|
||||||
call. This must only be used for system calls which can never
|
|
||||||
block, as otherwise the system call could cause all goroutines to
|
|
||||||
hang.
|
|
||||||
*/
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
b32 = flag.Bool("b32", false, "32bit big-endian")
|
|
||||||
l32 = flag.Bool("l32", false, "32bit little-endian")
|
|
||||||
plan9 = flag.Bool("plan9", false, "plan9")
|
|
||||||
openbsd = flag.Bool("openbsd", false, "openbsd")
|
|
||||||
netbsd = flag.Bool("netbsd", false, "netbsd")
|
|
||||||
dragonfly = flag.Bool("dragonfly", false, "dragonfly")
|
|
||||||
arm = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair
|
|
||||||
tags = flag.String("tags", "", "build tags")
|
|
||||||
filename = flag.String("output", "", "output file name (standard output if omitted)")
|
|
||||||
)
|
|
||||||
|
|
||||||
// cmdLine returns this programs's commandline arguments
|
|
||||||
func cmdLine() string {
|
|
||||||
return "go run mksyscall.go " + strings.Join(os.Args[1:], " ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// buildTags returns build tags
|
|
||||||
func buildTags() string {
|
|
||||||
return *tags
|
|
||||||
}
|
|
||||||
|
|
||||||
// Param is function parameter
|
|
||||||
type Param struct {
|
|
||||||
Name string
|
|
||||||
Type string
|
|
||||||
}
|
|
||||||
|
|
||||||
// usage prints the program usage
|
|
||||||
func usage() {
|
|
||||||
fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseParamList parses parameter list and returns a slice of parameters
|
|
||||||
func parseParamList(list string) []string {
|
|
||||||
list = strings.TrimSpace(list)
|
|
||||||
if list == "" {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseParam splits a parameter into name and type
|
|
||||||
func parseParam(p string) Param {
|
|
||||||
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
|
||||||
if ps == nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
return Param{ps[1], ps[2]}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Get the OS and architecture (using GOARCH_TARGET if it exists)
|
|
||||||
goos := os.Getenv("GOOS")
|
|
||||||
goarch := os.Getenv("GOARCH_TARGET")
|
|
||||||
if goarch == "" {
|
|
||||||
goarch = os.Getenv("GOARCH")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that we are using the Docker-based build system if we should
|
|
||||||
if goos == "linux" {
|
|
||||||
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
|
|
||||||
fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n")
|
|
||||||
fmt.Fprintf(os.Stderr, "See README.md\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flag.Usage = usage
|
|
||||||
flag.Parse()
|
|
||||||
if len(flag.Args()) <= 0 {
|
|
||||||
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
|
||||||
usage()
|
|
||||||
}
|
|
||||||
|
|
||||||
endianness := ""
|
|
||||||
if *b32 {
|
|
||||||
endianness = "big-endian"
|
|
||||||
} else if *l32 {
|
|
||||||
endianness = "little-endian"
|
|
||||||
}
|
|
||||||
|
|
||||||
libc := false
|
|
||||||
if goos == "darwin" && strings.Contains(buildTags(), ",go1.12") {
|
|
||||||
libc = true
|
|
||||||
}
|
|
||||||
trampolines := map[string]bool{}
|
|
||||||
|
|
||||||
text := ""
|
|
||||||
for _, path := range flag.Args() {
|
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
s := bufio.NewScanner(file)
|
|
||||||
for s.Scan() {
|
|
||||||
t := s.Text()
|
|
||||||
t = strings.TrimSpace(t)
|
|
||||||
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
|
||||||
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
|
||||||
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Line must be of the form
|
|
||||||
// func Open(path string, mode int, perm int) (fd int, errno error)
|
|
||||||
// Split into name, in params, out params.
|
|
||||||
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t)
|
|
||||||
if f == nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
funct, inps, outps, sysname := f[2], f[3], f[4], f[5]
|
|
||||||
|
|
||||||
// Split argument lists on comma.
|
|
||||||
in := parseParamList(inps)
|
|
||||||
out := parseParamList(outps)
|
|
||||||
|
|
||||||
// Try in vain to keep people from editing this file.
|
|
||||||
// The theory is that they jump into the middle of the file
|
|
||||||
// without reading the header.
|
|
||||||
text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
|
||||||
|
|
||||||
// Go function header.
|
|
||||||
outDecl := ""
|
|
||||||
if len(out) > 0 {
|
|
||||||
outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", "))
|
|
||||||
}
|
|
||||||
text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl)
|
|
||||||
|
|
||||||
// Check if err return available
|
|
||||||
errvar := ""
|
|
||||||
for _, param := range out {
|
|
||||||
p := parseParam(param)
|
|
||||||
if p.Type == "error" {
|
|
||||||
errvar = p.Name
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare arguments to Syscall.
|
|
||||||
var args []string
|
|
||||||
n := 0
|
|
||||||
for _, param := range in {
|
|
||||||
p := parseParam(param)
|
|
||||||
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))")
|
|
||||||
} else if p.Type == "string" && errvar != "" {
|
|
||||||
text += fmt.Sprintf("\tvar _p%d *byte\n", n)
|
|
||||||
text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name)
|
|
||||||
text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
|
||||||
n++
|
|
||||||
} else if p.Type == "string" {
|
|
||||||
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
|
||||||
text += fmt.Sprintf("\tvar _p%d *byte\n", n)
|
|
||||||
text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name)
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
|
||||||
n++
|
|
||||||
} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
// Convert slice into pointer, length.
|
|
||||||
// Have to be careful not to take address of &a[0] if len == 0:
|
|
||||||
// pass dummy pointer in that case.
|
|
||||||
// Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
|
|
||||||
text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n)
|
|
||||||
text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name)
|
|
||||||
text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n)
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name))
|
|
||||||
n++
|
|
||||||
} else if p.Type == "int64" && (*openbsd || *netbsd) {
|
|
||||||
args = append(args, "0")
|
|
||||||
if endianness == "big-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
} else if endianness == "little-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
}
|
|
||||||
} else if p.Type == "int64" && *dragonfly {
|
|
||||||
if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil {
|
|
||||||
args = append(args, "0")
|
|
||||||
}
|
|
||||||
if endianness == "big-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
} else if endianness == "little-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
}
|
|
||||||
} else if p.Type == "int64" && endianness != "" {
|
|
||||||
if len(args)%2 == 1 && *arm {
|
|
||||||
// arm abi specifies 64-bit argument uses
|
|
||||||
// (even, odd) pair
|
|
||||||
args = append(args, "0")
|
|
||||||
}
|
|
||||||
if endianness == "big-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine which form to use; pad args with zeros.
|
|
||||||
asm := "Syscall"
|
|
||||||
if nonblock != nil {
|
|
||||||
if errvar == "" && goos == "linux" {
|
|
||||||
asm = "RawSyscallNoError"
|
|
||||||
} else {
|
|
||||||
asm = "RawSyscall"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if errvar == "" && goos == "linux" {
|
|
||||||
asm = "SyscallNoError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(args) <= 3 {
|
|
||||||
for len(args) < 3 {
|
|
||||||
args = append(args, "0")
|
|
||||||
}
|
|
||||||
} else if len(args) <= 6 {
|
|
||||||
asm += "6"
|
|
||||||
for len(args) < 6 {
|
|
||||||
args = append(args, "0")
|
|
||||||
}
|
|
||||||
} else if len(args) <= 9 {
|
|
||||||
asm += "9"
|
|
||||||
for len(args) < 9 {
|
|
||||||
args = append(args, "0")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct)
|
|
||||||
}
|
|
||||||
|
|
||||||
// System call number.
|
|
||||||
if sysname == "" {
|
|
||||||
sysname = "SYS_" + funct
|
|
||||||
sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
|
|
||||||
sysname = strings.ToUpper(sysname)
|
|
||||||
}
|
|
||||||
|
|
||||||
var libcFn string
|
|
||||||
if libc {
|
|
||||||
asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call
|
|
||||||
sysname = strings.TrimPrefix(sysname, "SYS_") // remove SYS_
|
|
||||||
sysname = strings.ToLower(sysname) // lowercase
|
|
||||||
if sysname == "getdirentries64" {
|
|
||||||
// Special case - libSystem name and
|
|
||||||
// raw syscall name don't match.
|
|
||||||
sysname = "__getdirentries64"
|
|
||||||
}
|
|
||||||
libcFn = sysname
|
|
||||||
sysname = "funcPC(libc_" + sysname + "_trampoline)"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actual call.
|
|
||||||
arglist := strings.Join(args, ", ")
|
|
||||||
call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist)
|
|
||||||
|
|
||||||
// Assign return values.
|
|
||||||
body := ""
|
|
||||||
ret := []string{"_", "_", "_"}
|
|
||||||
doErrno := false
|
|
||||||
for i := 0; i < len(out); i++ {
|
|
||||||
p := parseParam(out[i])
|
|
||||||
reg := ""
|
|
||||||
if p.Name == "err" && !*plan9 {
|
|
||||||
reg = "e1"
|
|
||||||
ret[2] = reg
|
|
||||||
doErrno = true
|
|
||||||
} else if p.Name == "err" && *plan9 {
|
|
||||||
ret[0] = "r0"
|
|
||||||
ret[2] = "e1"
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
reg = fmt.Sprintf("r%d", i)
|
|
||||||
ret[i] = reg
|
|
||||||
}
|
|
||||||
if p.Type == "bool" {
|
|
||||||
reg = fmt.Sprintf("%s != 0", reg)
|
|
||||||
}
|
|
||||||
if p.Type == "int64" && endianness != "" {
|
|
||||||
// 64-bit number in r1:r0 or r0:r1.
|
|
||||||
if i+2 > len(out) {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct)
|
|
||||||
}
|
|
||||||
if endianness == "big-endian" {
|
|
||||||
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1)
|
|
||||||
} else {
|
|
||||||
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i)
|
|
||||||
}
|
|
||||||
ret[i] = fmt.Sprintf("r%d", i)
|
|
||||||
ret[i+1] = fmt.Sprintf("r%d", i+1)
|
|
||||||
}
|
|
||||||
if reg != "e1" || *plan9 {
|
|
||||||
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" {
|
|
||||||
text += fmt.Sprintf("\t%s\n", call)
|
|
||||||
} else {
|
|
||||||
if errvar == "" && goos == "linux" {
|
|
||||||
// raw syscall without error on Linux, see golang.org/issue/22924
|
|
||||||
text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call)
|
|
||||||
} else {
|
|
||||||
text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
text += body
|
|
||||||
|
|
||||||
if *plan9 && ret[2] == "e1" {
|
|
||||||
text += "\tif int32(r0) == -1 {\n"
|
|
||||||
text += "\t\terr = e1\n"
|
|
||||||
text += "\t}\n"
|
|
||||||
} else if doErrno {
|
|
||||||
text += "\tif e1 != 0 {\n"
|
|
||||||
text += "\t\terr = errnoErr(e1)\n"
|
|
||||||
text += "\t}\n"
|
|
||||||
}
|
|
||||||
text += "\treturn\n"
|
|
||||||
text += "}\n\n"
|
|
||||||
|
|
||||||
if libc && !trampolines[libcFn] {
|
|
||||||
// some system calls share a trampoline, like read and readlen.
|
|
||||||
trampolines[libcFn] = true
|
|
||||||
// Declare assembly trampoline.
|
|
||||||
text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn)
|
|
||||||
// Assembly trampoline calls the libc_* function, which this magic
|
|
||||||
// redirects to use the function from libSystem.
|
|
||||||
text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn)
|
|
||||||
text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn)
|
|
||||||
text += "\n"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := s.Err(); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
file.Close()
|
|
||||||
}
|
|
||||||
fmt.Printf(srcTemplate, cmdLine(), buildTags(), text)
|
|
||||||
}
|
|
||||||
|
|
||||||
const srcTemplate = `// %s
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build %s
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ syscall.Errno
|
|
||||||
|
|
||||||
%s
|
|
||||||
`
|
|
404
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
generated
vendored
404
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
generated
vendored
|
@ -1,404 +0,0 @@
|
||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
This program reads a file containing function prototypes
|
|
||||||
(like syscall_aix.go) and generates system call bodies.
|
|
||||||
The prototypes are marked by lines beginning with "//sys"
|
|
||||||
and read like func declarations if //sys is replaced by func, but:
|
|
||||||
* The parameter lists must give a name for each argument.
|
|
||||||
This includes return parameters.
|
|
||||||
* The parameter lists must give a type for each argument:
|
|
||||||
the (x, y, z int) shorthand is not allowed.
|
|
||||||
* If the return parameter is an error number, it must be named err.
|
|
||||||
* If go func name needs to be different than its libc name,
|
|
||||||
* or the function is not in libc, name could be specified
|
|
||||||
* at the end, after "=" sign, like
|
|
||||||
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
|
||||||
*/
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
b32 = flag.Bool("b32", false, "32bit big-endian")
|
|
||||||
l32 = flag.Bool("l32", false, "32bit little-endian")
|
|
||||||
aix = flag.Bool("aix", false, "aix")
|
|
||||||
tags = flag.String("tags", "", "build tags")
|
|
||||||
)
|
|
||||||
|
|
||||||
// cmdLine returns this programs's commandline arguments
|
|
||||||
func cmdLine() string {
|
|
||||||
return "go run mksyscall_aix_ppc.go " + strings.Join(os.Args[1:], " ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// buildTags returns build tags
|
|
||||||
func buildTags() string {
|
|
||||||
return *tags
|
|
||||||
}
|
|
||||||
|
|
||||||
// Param is function parameter
|
|
||||||
type Param struct {
|
|
||||||
Name string
|
|
||||||
Type string
|
|
||||||
}
|
|
||||||
|
|
||||||
// usage prints the program usage
|
|
||||||
func usage() {
|
|
||||||
fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseParamList parses parameter list and returns a slice of parameters
|
|
||||||
func parseParamList(list string) []string {
|
|
||||||
list = strings.TrimSpace(list)
|
|
||||||
if list == "" {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseParam splits a parameter into name and type
|
|
||||||
func parseParam(p string) Param {
|
|
||||||
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
|
||||||
if ps == nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
return Param{ps[1], ps[2]}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
flag.Usage = usage
|
|
||||||
flag.Parse()
|
|
||||||
if len(flag.Args()) <= 0 {
|
|
||||||
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
|
||||||
usage()
|
|
||||||
}
|
|
||||||
|
|
||||||
endianness := ""
|
|
||||||
if *b32 {
|
|
||||||
endianness = "big-endian"
|
|
||||||
} else if *l32 {
|
|
||||||
endianness = "little-endian"
|
|
||||||
}
|
|
||||||
|
|
||||||
pack := ""
|
|
||||||
text := ""
|
|
||||||
cExtern := "/*\n#include <stdint.h>\n#include <stddef.h>\n"
|
|
||||||
for _, path := range flag.Args() {
|
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
s := bufio.NewScanner(file)
|
|
||||||
for s.Scan() {
|
|
||||||
t := s.Text()
|
|
||||||
t = strings.TrimSpace(t)
|
|
||||||
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
|
||||||
if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" {
|
|
||||||
pack = p[1]
|
|
||||||
}
|
|
||||||
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
|
||||||
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Line must be of the form
|
|
||||||
// func Open(path string, mode int, perm int) (fd int, err error)
|
|
||||||
// Split into name, in params, out params.
|
|
||||||
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t)
|
|
||||||
if f == nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6]
|
|
||||||
|
|
||||||
// Split argument lists on comma.
|
|
||||||
in := parseParamList(inps)
|
|
||||||
out := parseParamList(outps)
|
|
||||||
|
|
||||||
inps = strings.Join(in, ", ")
|
|
||||||
outps = strings.Join(out, ", ")
|
|
||||||
|
|
||||||
// Try in vain to keep people from editing this file.
|
|
||||||
// The theory is that they jump into the middle of the file
|
|
||||||
// without reading the header.
|
|
||||||
text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
|
||||||
|
|
||||||
// Check if value return, err return available
|
|
||||||
errvar := ""
|
|
||||||
retvar := ""
|
|
||||||
rettype := ""
|
|
||||||
for _, param := range out {
|
|
||||||
p := parseParam(param)
|
|
||||||
if p.Type == "error" {
|
|
||||||
errvar = p.Name
|
|
||||||
} else {
|
|
||||||
retvar = p.Name
|
|
||||||
rettype = p.Type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// System call name.
|
|
||||||
if sysname == "" {
|
|
||||||
sysname = funct
|
|
||||||
}
|
|
||||||
sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
|
|
||||||
sysname = strings.ToLower(sysname) // All libc functions are lowercase.
|
|
||||||
|
|
||||||
cRettype := ""
|
|
||||||
if rettype == "unsafe.Pointer" {
|
|
||||||
cRettype = "uintptr_t"
|
|
||||||
} else if rettype == "uintptr" {
|
|
||||||
cRettype = "uintptr_t"
|
|
||||||
} else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil {
|
|
||||||
cRettype = "uintptr_t"
|
|
||||||
} else if rettype == "int" {
|
|
||||||
cRettype = "int"
|
|
||||||
} else if rettype == "int32" {
|
|
||||||
cRettype = "int"
|
|
||||||
} else if rettype == "int64" {
|
|
||||||
cRettype = "long long"
|
|
||||||
} else if rettype == "uint32" {
|
|
||||||
cRettype = "unsigned int"
|
|
||||||
} else if rettype == "uint64" {
|
|
||||||
cRettype = "unsigned long long"
|
|
||||||
} else {
|
|
||||||
cRettype = "int"
|
|
||||||
}
|
|
||||||
if sysname == "exit" {
|
|
||||||
cRettype = "void"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change p.Types to c
|
|
||||||
var cIn []string
|
|
||||||
for _, param := range in {
|
|
||||||
p := parseParam(param)
|
|
||||||
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
cIn = append(cIn, "uintptr_t")
|
|
||||||
} else if p.Type == "string" {
|
|
||||||
cIn = append(cIn, "uintptr_t")
|
|
||||||
} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
cIn = append(cIn, "uintptr_t", "size_t")
|
|
||||||
} else if p.Type == "unsafe.Pointer" {
|
|
||||||
cIn = append(cIn, "uintptr_t")
|
|
||||||
} else if p.Type == "uintptr" {
|
|
||||||
cIn = append(cIn, "uintptr_t")
|
|
||||||
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
cIn = append(cIn, "uintptr_t")
|
|
||||||
} else if p.Type == "int" {
|
|
||||||
cIn = append(cIn, "int")
|
|
||||||
} else if p.Type == "int32" {
|
|
||||||
cIn = append(cIn, "int")
|
|
||||||
} else if p.Type == "int64" {
|
|
||||||
cIn = append(cIn, "long long")
|
|
||||||
} else if p.Type == "uint32" {
|
|
||||||
cIn = append(cIn, "unsigned int")
|
|
||||||
} else if p.Type == "uint64" {
|
|
||||||
cIn = append(cIn, "unsigned long long")
|
|
||||||
} else {
|
|
||||||
cIn = append(cIn, "int")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if funct != "fcntl" && funct != "FcntlInt" && funct != "readlen" && funct != "writelen" {
|
|
||||||
// Imports of system calls from libc
|
|
||||||
cExtern += fmt.Sprintf("%s %s", cRettype, sysname)
|
|
||||||
cIn := strings.Join(cIn, ", ")
|
|
||||||
cExtern += fmt.Sprintf("(%s);\n", cIn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// So file name.
|
|
||||||
if *aix {
|
|
||||||
if modname == "" {
|
|
||||||
modname = "libc.a/shr_64.o"
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strconvfunc := "C.CString"
|
|
||||||
|
|
||||||
// Go function header.
|
|
||||||
if outps != "" {
|
|
||||||
outps = fmt.Sprintf(" (%s)", outps)
|
|
||||||
}
|
|
||||||
if text != "" {
|
|
||||||
text += "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps)
|
|
||||||
|
|
||||||
// Prepare arguments to Syscall.
|
|
||||||
var args []string
|
|
||||||
n := 0
|
|
||||||
argN := 0
|
|
||||||
for _, param := range in {
|
|
||||||
p := parseParam(param)
|
|
||||||
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
args = append(args, "C.uintptr_t(uintptr(unsafe.Pointer("+p.Name+")))")
|
|
||||||
} else if p.Type == "string" && errvar != "" {
|
|
||||||
text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
|
||||||
n++
|
|
||||||
} else if p.Type == "string" {
|
|
||||||
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
|
||||||
text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
|
||||||
n++
|
|
||||||
} else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil {
|
|
||||||
// Convert slice into pointer, length.
|
|
||||||
// Have to be careful not to take address of &a[0] if len == 0:
|
|
||||||
// pass nil in that case.
|
|
||||||
text += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1])
|
|
||||||
text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name)
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(unsafe.Pointer(_p%d)))", n))
|
|
||||||
n++
|
|
||||||
text += fmt.Sprintf("\tvar _p%d int\n", n)
|
|
||||||
text += fmt.Sprintf("\t_p%d = len(%s)\n", n, p.Name)
|
|
||||||
args = append(args, fmt.Sprintf("C.size_t(_p%d)", n))
|
|
||||||
n++
|
|
||||||
} else if p.Type == "int64" && endianness != "" {
|
|
||||||
if endianness == "big-endian" {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
|
||||||
}
|
|
||||||
n++
|
|
||||||
} else if p.Type == "bool" {
|
|
||||||
text += fmt.Sprintf("\tvar _p%d uint32\n", n)
|
|
||||||
text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n)
|
|
||||||
args = append(args, fmt.Sprintf("_p%d", n))
|
|
||||||
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
|
|
||||||
} else if p.Type == "unsafe.Pointer" {
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
|
|
||||||
} else if p.Type == "int" {
|
|
||||||
if (argN == 2) && ((funct == "readlen") || (funct == "writelen")) {
|
|
||||||
args = append(args, fmt.Sprintf("C.size_t(%s)", p.Name))
|
|
||||||
} else if argN == 0 && funct == "fcntl" {
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
|
||||||
} else if (argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt")) {
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
|
||||||
}
|
|
||||||
} else if p.Type == "int32" {
|
|
||||||
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
|
||||||
} else if p.Type == "int64" {
|
|
||||||
args = append(args, fmt.Sprintf("C.longlong(%s)", p.Name))
|
|
||||||
} else if p.Type == "uint32" {
|
|
||||||
args = append(args, fmt.Sprintf("C.uint(%s)", p.Name))
|
|
||||||
} else if p.Type == "uint64" {
|
|
||||||
args = append(args, fmt.Sprintf("C.ulonglong(%s)", p.Name))
|
|
||||||
} else if p.Type == "uintptr" {
|
|
||||||
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
|
||||||
} else {
|
|
||||||
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
|
||||||
}
|
|
||||||
argN++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actual call.
|
|
||||||
arglist := strings.Join(args, ", ")
|
|
||||||
call := ""
|
|
||||||
if sysname == "exit" {
|
|
||||||
if errvar != "" {
|
|
||||||
call += "er :="
|
|
||||||
} else {
|
|
||||||
call += ""
|
|
||||||
}
|
|
||||||
} else if errvar != "" {
|
|
||||||
call += "r0,er :="
|
|
||||||
} else if retvar != "" {
|
|
||||||
call += "r0,_ :="
|
|
||||||
} else {
|
|
||||||
call += ""
|
|
||||||
}
|
|
||||||
call += fmt.Sprintf("C.%s(%s)", sysname, arglist)
|
|
||||||
|
|
||||||
// Assign return values.
|
|
||||||
body := ""
|
|
||||||
for i := 0; i < len(out); i++ {
|
|
||||||
p := parseParam(out[i])
|
|
||||||
reg := ""
|
|
||||||
if p.Name == "err" {
|
|
||||||
reg = "e1"
|
|
||||||
} else {
|
|
||||||
reg = "r0"
|
|
||||||
}
|
|
||||||
if reg != "e1" {
|
|
||||||
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify return
|
|
||||||
if sysname != "exit" && errvar != "" {
|
|
||||||
if regexp.MustCompile(`^uintptr`).FindStringSubmatch(cRettype) != nil {
|
|
||||||
body += "\tif (uintptr(r0) ==^uintptr(0) && er != nil) {\n"
|
|
||||||
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
|
||||||
body += "\t}\n"
|
|
||||||
} else {
|
|
||||||
body += "\tif (r0 ==-1 && er != nil) {\n"
|
|
||||||
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
|
||||||
body += "\t}\n"
|
|
||||||
}
|
|
||||||
} else if errvar != "" {
|
|
||||||
body += "\tif (er != nil) {\n"
|
|
||||||
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
|
||||||
body += "\t}\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
text += fmt.Sprintf("\t%s\n", call)
|
|
||||||
text += body
|
|
||||||
|
|
||||||
text += "\treturn\n"
|
|
||||||
text += "}\n"
|
|
||||||
}
|
|
||||||
if err := s.Err(); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
file.Close()
|
|
||||||
}
|
|
||||||
imp := ""
|
|
||||||
if pack != "unix" {
|
|
||||||
imp = "import \"golang.org/x/sys/unix\"\n"
|
|
||||||
|
|
||||||
}
|
|
||||||
fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, cExtern, imp, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
const srcTemplate = `// %s
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build %s
|
|
||||||
|
|
||||||
package %s
|
|
||||||
|
|
||||||
|
|
||||||
%s
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
%s
|
|
||||||
|
|
||||||
%s
|
|
||||||
`
|
|
0
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.pl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.pl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Executable file → Normal file
0
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Executable file → Normal file
190
vendor/golang.org/x/sys/unix/mksysnum.go
generated
vendored
190
vendor/golang.org/x/sys/unix/mksysnum.go
generated
vendored
|
@ -1,190 +0,0 @@
|
||||||
// Copyright 2018 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// Generate system call table for DragonFly, NetBSD,
|
|
||||||
// FreeBSD, OpenBSD or Darwin from master list
|
|
||||||
// (for example, /usr/src/sys/kern/syscalls.master or
|
|
||||||
// sys/syscall.h).
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
goos, goarch string
|
|
||||||
)
|
|
||||||
|
|
||||||
// cmdLine returns this programs's commandline arguments
|
|
||||||
func cmdLine() string {
|
|
||||||
return "go run mksysnum.go " + strings.Join(os.Args[1:], " ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// buildTags returns build tags
|
|
||||||
func buildTags() string {
|
|
||||||
return fmt.Sprintf("%s,%s", goarch, goos)
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkErr(err error) {
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// source string and substring slice for regexp
|
|
||||||
type re struct {
|
|
||||||
str string // source string
|
|
||||||
sub []string // matched sub-string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match performs regular expression match
|
|
||||||
func (r *re) Match(exp string) bool {
|
|
||||||
r.sub = regexp.MustCompile(exp).FindStringSubmatch(r.str)
|
|
||||||
if r.sub != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetchFile fetches a text file from URL
|
|
||||||
func fetchFile(URL string) io.Reader {
|
|
||||||
resp, err := http.Get(URL)
|
|
||||||
checkErr(err)
|
|
||||||
defer resp.Body.Close()
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
|
||||||
checkErr(err)
|
|
||||||
return strings.NewReader(string(body))
|
|
||||||
}
|
|
||||||
|
|
||||||
// readFile reads a text file from path
|
|
||||||
func readFile(path string) io.Reader {
|
|
||||||
file, err := os.Open(os.Args[1])
|
|
||||||
checkErr(err)
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
func format(name, num, proto string) string {
|
|
||||||
name = strings.ToUpper(name)
|
|
||||||
// There are multiple entries for enosys and nosys, so comment them out.
|
|
||||||
nm := re{str: name}
|
|
||||||
if nm.Match(`^SYS_E?NOSYS$`) {
|
|
||||||
name = fmt.Sprintf("// %s", name)
|
|
||||||
}
|
|
||||||
if name == `SYS_SYS_EXIT` {
|
|
||||||
name = `SYS_EXIT`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(" %s = %s; // %s\n", name, num, proto)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Get the OS (using GOOS_TARGET if it exist)
|
|
||||||
goos = os.Getenv("GOOS_TARGET")
|
|
||||||
if goos == "" {
|
|
||||||
goos = os.Getenv("GOOS")
|
|
||||||
}
|
|
||||||
// Get the architecture (using GOARCH_TARGET if it exists)
|
|
||||||
goarch = os.Getenv("GOARCH_TARGET")
|
|
||||||
if goarch == "" {
|
|
||||||
goarch = os.Getenv("GOARCH")
|
|
||||||
}
|
|
||||||
// Check if GOOS and GOARCH environment variables are defined
|
|
||||||
if goarch == "" || goos == "" {
|
|
||||||
fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
file := strings.TrimSpace(os.Args[1])
|
|
||||||
var syscalls io.Reader
|
|
||||||
if strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "http://") {
|
|
||||||
// Download syscalls.master file
|
|
||||||
syscalls = fetchFile(file)
|
|
||||||
} else {
|
|
||||||
syscalls = readFile(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
var text, line string
|
|
||||||
s := bufio.NewScanner(syscalls)
|
|
||||||
for s.Scan() {
|
|
||||||
t := re{str: line}
|
|
||||||
if t.Match(`^(.*)\\$`) {
|
|
||||||
// Handle continuation
|
|
||||||
line = t.sub[1]
|
|
||||||
line += strings.TrimLeft(s.Text(), " \t")
|
|
||||||
} else {
|
|
||||||
// New line
|
|
||||||
line = s.Text()
|
|
||||||
}
|
|
||||||
t = re{str: line}
|
|
||||||
if t.Match(`\\$`) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
t = re{str: line}
|
|
||||||
|
|
||||||
switch goos {
|
|
||||||
case "dragonfly":
|
|
||||||
if t.Match(`^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$`) {
|
|
||||||
num, proto := t.sub[1], t.sub[2]
|
|
||||||
name := fmt.Sprintf("SYS_%s", t.sub[3])
|
|
||||||
text += format(name, num, proto)
|
|
||||||
}
|
|
||||||
case "freebsd":
|
|
||||||
if t.Match(`^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$`) {
|
|
||||||
num, proto := t.sub[1], t.sub[2]
|
|
||||||
name := fmt.Sprintf("SYS_%s", t.sub[3])
|
|
||||||
text += format(name, num, proto)
|
|
||||||
}
|
|
||||||
case "openbsd":
|
|
||||||
if t.Match(`^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$`) {
|
|
||||||
num, proto, name := t.sub[1], t.sub[3], t.sub[4]
|
|
||||||
text += format(name, num, proto)
|
|
||||||
}
|
|
||||||
case "netbsd":
|
|
||||||
if t.Match(`^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$`) {
|
|
||||||
num, proto, compat := t.sub[1], t.sub[6], t.sub[8]
|
|
||||||
name := t.sub[7] + "_" + t.sub[9]
|
|
||||||
if t.sub[11] != "" {
|
|
||||||
name = t.sub[7] + "_" + t.sub[11]
|
|
||||||
}
|
|
||||||
name = strings.ToUpper(name)
|
|
||||||
if compat == "" || compat == "13" || compat == "30" || compat == "50" {
|
|
||||||
text += fmt.Sprintf(" %s = %s; // %s\n", name, num, proto)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "darwin":
|
|
||||||
if t.Match(`^#define\s+SYS_(\w+)\s+([0-9]+)`) {
|
|
||||||
name, num := t.sub[1], t.sub[2]
|
|
||||||
name = strings.ToUpper(name)
|
|
||||||
text += fmt.Sprintf(" SYS_%s = %s;\n", name, num)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "unrecognized GOOS=%s\n", goos)
|
|
||||||
os.Exit(1)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err := s.Err()
|
|
||||||
checkErr(err)
|
|
||||||
|
|
||||||
fmt.Printf(template, cmdLine(), buildTags(), text)
|
|
||||||
}
|
|
||||||
|
|
||||||
const template = `// %s
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build %s
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const(
|
|
||||||
%s)`
|
|
236
vendor/golang.org/x/sys/unix/types_aix.go
generated
vendored
236
vendor/golang.org/x/sys/unix/types_aix.go
generated
vendored
|
@ -1,236 +0,0 @@
|
||||||
// Copyright 2018 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
// +build aix
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/limits.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <utime.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/statfs.h>
|
|
||||||
#include <sys/termio.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
#include <termios.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
type off64 C.off64_t
|
|
||||||
type off C.off_t
|
|
||||||
type Mode_t C.mode_t
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type StTimespec C.struct_st_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
type Timeval32 C.struct_timeval32
|
|
||||||
|
|
||||||
type Timex C.struct_timex
|
|
||||||
|
|
||||||
type Time_t C.time_t
|
|
||||||
|
|
||||||
type Tms C.struct_tms
|
|
||||||
|
|
||||||
type Utimbuf C.struct_utimbuf
|
|
||||||
|
|
||||||
type Timezone C.struct_timezone
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit64
|
|
||||||
|
|
||||||
type Pid_t C.pid_t
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
type dev_t C.dev_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type StatxTimestamp C.struct_statx_timestamp
|
|
||||||
|
|
||||||
type Statx_t C.struct_statx
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsgHdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
// Misc
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
||||||
|
|
||||||
type Ustat_t C.struct_ustat
|
|
||||||
|
|
||||||
type Sigset_t C.sigset_t
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Termio C.struct_termio
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
//poll
|
|
||||||
|
|
||||||
type PollFd struct {
|
|
||||||
Fd int32
|
|
||||||
Events uint16
|
|
||||||
Revents uint16
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
//flock_t
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock64
|
|
||||||
|
|
||||||
// Statfs
|
|
||||||
|
|
||||||
type Fsid_t C.struct_fsid_t
|
|
||||||
type Fsid64_t C.struct_fsid64_t
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
|
||||||
|
|
||||||
const RNDGETENTCNT = 0x80045200
|
|
277
vendor/golang.org/x/sys/unix/types_darwin.go
generated
vendored
277
vendor/golang.org/x/sys/unix/types_darwin.go
generated
vendored
|
@ -1,277 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define __DARWIN_UNIX03 0
|
|
||||||
#define KERNEL
|
|
||||||
#define _DARWIN_USE_64_BIT_INODE
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <mach/mach.h>
|
|
||||||
#include <mach/message.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/if_var.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
type Timeval32 C.struct_timeval32
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat64
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs64
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Fstore_t C.struct_fstore
|
|
||||||
|
|
||||||
type Radvisory_t C.struct_radvisory
|
|
||||||
|
|
||||||
type Fbootstraptransfer_t C.struct_fbootstraptransfer
|
|
||||||
|
|
||||||
type Log2phys_t C.struct_log2phys
|
|
||||||
|
|
||||||
type Fsid C.struct_fsid
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet4Pktinfo C.struct_in_pktinfo
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ptrace requests
|
|
||||||
|
|
||||||
const (
|
|
||||||
PTRACE_TRACEME = C.PT_TRACE_ME
|
|
||||||
PTRACE_CONT = C.PT_CONTINUE
|
|
||||||
PTRACE_KILL = C.PT_KILL
|
|
||||||
)
|
|
||||||
|
|
||||||
// Events (kqueue, kevent)
|
|
||||||
|
|
||||||
type Kevent_t C.struct_kevent
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
|
||||||
SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfData C.struct_if_data
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type IfmaMsghdr C.struct_ifma_msghdr
|
|
||||||
|
|
||||||
type IfmaMsghdr2 C.struct_ifma_msghdr2
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
// fchmodat-like syscalls.
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
|
||||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
// uname
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
263
vendor/golang.org/x/sys/unix/types_dragonfly.go
generated
vendored
263
vendor/golang.org/x/sys/unix/types_dragonfly.go
generated
vendored
|
@ -1,263 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define KERNEL
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
type Fsid C.struct_fsid
|
|
||||||
|
|
||||||
// File system limits
|
|
||||||
|
|
||||||
const (
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
)
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ptrace requests
|
|
||||||
|
|
||||||
const (
|
|
||||||
PTRACE_TRACEME = C.PT_TRACE_ME
|
|
||||||
PTRACE_CONT = C.PT_CONTINUE
|
|
||||||
PTRACE_KILL = C.PT_KILL
|
|
||||||
)
|
|
||||||
|
|
||||||
// Events (kqueue, kevent)
|
|
||||||
|
|
||||||
type Kevent_t C.struct_kevent
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
|
||||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfData C.struct_if_data
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type IfmaMsghdr C.struct_ifma_msghdr
|
|
||||||
|
|
||||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
// fchmodat-like syscalls.
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
// Uname
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
356
vendor/golang.org/x/sys/unix/types_freebsd.go
generated
vendored
356
vendor/golang.org/x/sys/unix/types_freebsd.go
generated
vendored
|
@ -1,356 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define _WANT_FREEBSD11_STAT 1
|
|
||||||
#define _WANT_FREEBSD11_STATFS 1
|
|
||||||
#define _WANT_FREEBSD11_DIRENT 1
|
|
||||||
#define _WANT_FREEBSD11_KEVENT 1
|
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/capsicum.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
|
|
||||||
// See /usr/include/net/if.h.
|
|
||||||
struct if_data8 {
|
|
||||||
u_char ifi_type;
|
|
||||||
u_char ifi_physical;
|
|
||||||
u_char ifi_addrlen;
|
|
||||||
u_char ifi_hdrlen;
|
|
||||||
u_char ifi_link_state;
|
|
||||||
u_char ifi_spare_char1;
|
|
||||||
u_char ifi_spare_char2;
|
|
||||||
u_char ifi_datalen;
|
|
||||||
u_long ifi_mtu;
|
|
||||||
u_long ifi_metric;
|
|
||||||
u_long ifi_baudrate;
|
|
||||||
u_long ifi_ipackets;
|
|
||||||
u_long ifi_ierrors;
|
|
||||||
u_long ifi_opackets;
|
|
||||||
u_long ifi_oerrors;
|
|
||||||
u_long ifi_collisions;
|
|
||||||
u_long ifi_ibytes;
|
|
||||||
u_long ifi_obytes;
|
|
||||||
u_long ifi_imcasts;
|
|
||||||
u_long ifi_omcasts;
|
|
||||||
u_long ifi_iqdrops;
|
|
||||||
u_long ifi_noproto;
|
|
||||||
u_long ifi_hwassist;
|
|
||||||
// FIXME: these are now unions, so maybe need to change definitions?
|
|
||||||
#undef ifi_epoch
|
|
||||||
time_t ifi_epoch;
|
|
||||||
#undef ifi_lastchange
|
|
||||||
struct timeval ifi_lastchange;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
|
|
||||||
// See /usr/include/net/if.h.
|
|
||||||
struct if_msghdr8 {
|
|
||||||
u_short ifm_msglen;
|
|
||||||
u_char ifm_version;
|
|
||||||
u_char ifm_type;
|
|
||||||
int ifm_addrs;
|
|
||||||
int ifm_flags;
|
|
||||||
u_short ifm_index;
|
|
||||||
struct if_data8 ifm_data;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
const (
|
|
||||||
_statfsVersion = C.STATFS_VERSION
|
|
||||||
_dirblksiz = C.DIRBLKSIZ
|
|
||||||
)
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type stat_freebsd11_t C.struct_freebsd11_stat
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
|
||||||
|
|
||||||
type statfs_freebsd11_t C.struct_freebsd11_statfs
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
type dirent_freebsd11 C.struct_freebsd11_dirent
|
|
||||||
|
|
||||||
type Fsid C.struct_fsid
|
|
||||||
|
|
||||||
// File system limits
|
|
||||||
|
|
||||||
const (
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
)
|
|
||||||
|
|
||||||
// Advice to Fadvise
|
|
||||||
|
|
||||||
const (
|
|
||||||
FADV_NORMAL = C.POSIX_FADV_NORMAL
|
|
||||||
FADV_RANDOM = C.POSIX_FADV_RANDOM
|
|
||||||
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
|
|
||||||
FADV_WILLNEED = C.POSIX_FADV_WILLNEED
|
|
||||||
FADV_DONTNEED = C.POSIX_FADV_DONTNEED
|
|
||||||
FADV_NOREUSE = C.POSIX_FADV_NOREUSE
|
|
||||||
)
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPMreqn C.struct_ip_mreqn
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPMreqn = C.sizeof_struct_ip_mreqn
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ptrace requests
|
|
||||||
|
|
||||||
const (
|
|
||||||
PTRACE_TRACEME = C.PT_TRACE_ME
|
|
||||||
PTRACE_CONT = C.PT_CONTINUE
|
|
||||||
PTRACE_KILL = C.PT_KILL
|
|
||||||
)
|
|
||||||
|
|
||||||
// Events (kqueue, kevent)
|
|
||||||
|
|
||||||
type Kevent_t C.struct_kevent_freebsd11
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
sizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
|
|
||||||
sizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data8
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
|
|
||||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type ifMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr8
|
|
||||||
|
|
||||||
type ifData C.struct_if_data
|
|
||||||
|
|
||||||
type IfData C.struct_if_data8
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type IfmaMsghdr C.struct_ifma_msghdr
|
|
||||||
|
|
||||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfZbuf C.struct_bpf_zbuf
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
type BpfZbufHeader C.struct_bpf_zbuf_header
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
// fchmodat-like syscalls.
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
|
||||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLINIGNEOF = C.POLLINIGNEOF
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
// Capabilities
|
|
||||||
|
|
||||||
type CapRights C.struct_cap_rights
|
|
||||||
|
|
||||||
// Uname
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
289
vendor/golang.org/x/sys/unix/types_netbsd.go
generated
vendored
289
vendor/golang.org/x/sys/unix/types_netbsd.go
generated
vendored
|
@ -1,289 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define KERNEL
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
type Fsid C.fsid_t
|
|
||||||
|
|
||||||
// File system limits
|
|
||||||
|
|
||||||
const (
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
)
|
|
||||||
|
|
||||||
// Advice to Fadvise
|
|
||||||
|
|
||||||
const (
|
|
||||||
FADV_NORMAL = C.POSIX_FADV_NORMAL
|
|
||||||
FADV_RANDOM = C.POSIX_FADV_RANDOM
|
|
||||||
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
|
|
||||||
FADV_WILLNEED = C.POSIX_FADV_WILLNEED
|
|
||||||
FADV_DONTNEED = C.POSIX_FADV_DONTNEED
|
|
||||||
FADV_NOREUSE = C.POSIX_FADV_NOREUSE
|
|
||||||
)
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ptrace requests
|
|
||||||
|
|
||||||
const (
|
|
||||||
PTRACE_TRACEME = C.PT_TRACE_ME
|
|
||||||
PTRACE_CONT = C.PT_CONTINUE
|
|
||||||
PTRACE_KILL = C.PT_KILL
|
|
||||||
)
|
|
||||||
|
|
||||||
// Events (kqueue, kevent)
|
|
||||||
|
|
||||||
type Kevent_t C.struct_kevent
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfData C.struct_if_data
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
type Mclpool C.struct_mclpool
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
type BpfTimeval C.struct_bpf_timeval
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
type Ptmget C.struct_ptmget
|
|
||||||
|
|
||||||
// fchmodat-like syscalls.
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
// Sysctl
|
|
||||||
|
|
||||||
type Sysctlnode C.struct_sysctlnode
|
|
||||||
|
|
||||||
// Uname
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
||||||
|
|
||||||
// Clockinfo
|
|
||||||
|
|
||||||
const SizeofClockinfo = C.sizeof_struct_clockinfo
|
|
||||||
|
|
||||||
type Clockinfo C.struct_clockinfo
|
|
276
vendor/golang.org/x/sys/unix/types_openbsd.go
generated
vendored
276
vendor/golang.org/x/sys/unix/types_openbsd.go
generated
vendored
|
@ -1,276 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define KERNEL
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <uvm/uvmexp.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
type Fsid C.fsid_t
|
|
||||||
|
|
||||||
// File system limits
|
|
||||||
|
|
||||||
const (
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
)
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ptrace requests
|
|
||||||
|
|
||||||
const (
|
|
||||||
PTRACE_TRACEME = C.PT_TRACE_ME
|
|
||||||
PTRACE_CONT = C.PT_CONTINUE
|
|
||||||
PTRACE_KILL = C.PT_KILL
|
|
||||||
)
|
|
||||||
|
|
||||||
// Events (kqueue, kevent)
|
|
||||||
|
|
||||||
type Kevent_t C.struct_kevent
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfData C.struct_if_data
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
type Mclpool C.struct_mclpool
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
type BpfTimeval C.struct_bpf_timeval
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
// fchmodat-like syscalls.
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
)
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
||||||
|
|
||||||
// Signal Sets
|
|
||||||
|
|
||||||
type Sigset_t C.sigset_t
|
|
||||||
|
|
||||||
// Uname
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
||||||
|
|
||||||
// Uvmexp
|
|
||||||
|
|
||||||
const SizeofUvmexp = C.sizeof_struct_uvmexp
|
|
||||||
|
|
||||||
type Uvmexp C.struct_uvmexp
|
|
266
vendor/golang.org/x/sys/unix/types_solaris.go
generated
vendored
266
vendor/golang.org/x/sys/unix/types_solaris.go
generated
vendored
|
@ -1,266 +0,0 @@
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
|
||||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define KERNEL
|
|
||||||
// These defines ensure that builds done on newer versions of Solaris are
|
|
||||||
// backwards-compatible with older versions of Solaris and
|
|
||||||
// OpenSolaris-based derivatives.
|
|
||||||
#define __USE_SUNOS_SOCKETS__ // msghdr
|
|
||||||
#define __USE_LEGACY_PROTOTYPES__ // iovec
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <termio.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/statvfs.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/times.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/icmp6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <ustat.h>
|
|
||||||
#include <utime.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
sizeofPtr = sizeof(void*),
|
|
||||||
};
|
|
||||||
|
|
||||||
union sockaddr_all {
|
|
||||||
struct sockaddr s1; // this one gets used for fields
|
|
||||||
struct sockaddr_in s2; // these pad it out
|
|
||||||
struct sockaddr_in6 s3;
|
|
||||||
struct sockaddr_un s4;
|
|
||||||
struct sockaddr_dl s5;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sockaddr_any {
|
|
||||||
struct sockaddr addr;
|
|
||||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// Machine characteristics
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofPtr = C.sizeofPtr
|
|
||||||
SizeofShort = C.sizeof_short
|
|
||||||
SizeofInt = C.sizeof_int
|
|
||||||
SizeofLong = C.sizeof_long
|
|
||||||
SizeofLongLong = C.sizeof_longlong
|
|
||||||
PathMax = C.PATH_MAX
|
|
||||||
MaxHostNameLen = C.MAXHOSTNAMELEN
|
|
||||||
)
|
|
||||||
|
|
||||||
// Basic types
|
|
||||||
|
|
||||||
type (
|
|
||||||
_C_short C.short
|
|
||||||
_C_int C.int
|
|
||||||
_C_long C.long
|
|
||||||
_C_long_long C.longlong
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time
|
|
||||||
|
|
||||||
type Timespec C.struct_timespec
|
|
||||||
|
|
||||||
type Timeval C.struct_timeval
|
|
||||||
|
|
||||||
type Timeval32 C.struct_timeval32
|
|
||||||
|
|
||||||
type Tms C.struct_tms
|
|
||||||
|
|
||||||
type Utimbuf C.struct_utimbuf
|
|
||||||
|
|
||||||
// Processes
|
|
||||||
|
|
||||||
type Rusage C.struct_rusage
|
|
||||||
|
|
||||||
type Rlimit C.struct_rlimit
|
|
||||||
|
|
||||||
type _Gid_t C.gid_t
|
|
||||||
|
|
||||||
// Files
|
|
||||||
|
|
||||||
type Stat_t C.struct_stat
|
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
|
||||||
|
|
||||||
type Dirent C.struct_dirent
|
|
||||||
|
|
||||||
// Filesystems
|
|
||||||
|
|
||||||
type _Fsblkcnt_t C.fsblkcnt_t
|
|
||||||
|
|
||||||
type Statvfs_t C.struct_statvfs
|
|
||||||
|
|
||||||
// Sockets
|
|
||||||
|
|
||||||
type RawSockaddrInet4 C.struct_sockaddr_in
|
|
||||||
|
|
||||||
type RawSockaddrInet6 C.struct_sockaddr_in6
|
|
||||||
|
|
||||||
type RawSockaddrUnix C.struct_sockaddr_un
|
|
||||||
|
|
||||||
type RawSockaddrDatalink C.struct_sockaddr_dl
|
|
||||||
|
|
||||||
type RawSockaddr C.struct_sockaddr
|
|
||||||
|
|
||||||
type RawSockaddrAny C.struct_sockaddr_any
|
|
||||||
|
|
||||||
type _Socklen C.socklen_t
|
|
||||||
|
|
||||||
type Linger C.struct_linger
|
|
||||||
|
|
||||||
type Iovec C.struct_iovec
|
|
||||||
|
|
||||||
type IPMreq C.struct_ip_mreq
|
|
||||||
|
|
||||||
type IPv6Mreq C.struct_ipv6_mreq
|
|
||||||
|
|
||||||
type Msghdr C.struct_msghdr
|
|
||||||
|
|
||||||
type Cmsghdr C.struct_cmsghdr
|
|
||||||
|
|
||||||
type Inet6Pktinfo C.struct_in6_pktinfo
|
|
||||||
|
|
||||||
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|
||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
|
||||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
|
|
||||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
|
|
||||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
|
|
||||||
SizeofLinger = C.sizeof_struct_linger
|
|
||||||
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
|
||||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
|
||||||
SizeofMsghdr = C.sizeof_struct_msghdr
|
|
||||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
|
||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
|
||||||
)
|
|
||||||
|
|
||||||
// Select
|
|
||||||
|
|
||||||
type FdSet C.fd_set
|
|
||||||
|
|
||||||
// Misc
|
|
||||||
|
|
||||||
type Utsname C.struct_utsname
|
|
||||||
|
|
||||||
type Ustat_t C.struct_ustat
|
|
||||||
|
|
||||||
const (
|
|
||||||
AT_FDCWD = C.AT_FDCWD
|
|
||||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
|
||||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
|
|
||||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
|
||||||
AT_EACCESS = C.AT_EACCESS
|
|
||||||
)
|
|
||||||
|
|
||||||
// Routing and interface messages
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
|
||||||
SizeofIfData = C.sizeof_struct_if_data
|
|
||||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
|
|
||||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
|
||||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
type IfMsghdr C.struct_if_msghdr
|
|
||||||
|
|
||||||
type IfData C.struct_if_data
|
|
||||||
|
|
||||||
type IfaMsghdr C.struct_ifa_msghdr
|
|
||||||
|
|
||||||
type RtMsghdr C.struct_rt_msghdr
|
|
||||||
|
|
||||||
type RtMetrics C.struct_rt_metrics
|
|
||||||
|
|
||||||
// Berkeley packet filter
|
|
||||||
|
|
||||||
const (
|
|
||||||
SizeofBpfVersion = C.sizeof_struct_bpf_version
|
|
||||||
SizeofBpfStat = C.sizeof_struct_bpf_stat
|
|
||||||
SizeofBpfProgram = C.sizeof_struct_bpf_program
|
|
||||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn
|
|
||||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr
|
|
||||||
)
|
|
||||||
|
|
||||||
type BpfVersion C.struct_bpf_version
|
|
||||||
|
|
||||||
type BpfStat C.struct_bpf_stat
|
|
||||||
|
|
||||||
type BpfProgram C.struct_bpf_program
|
|
||||||
|
|
||||||
type BpfInsn C.struct_bpf_insn
|
|
||||||
|
|
||||||
type BpfTimeval C.struct_bpf_timeval
|
|
||||||
|
|
||||||
type BpfHdr C.struct_bpf_hdr
|
|
||||||
|
|
||||||
// Terminal handling
|
|
||||||
|
|
||||||
type Termios C.struct_termios
|
|
||||||
|
|
||||||
type Termio C.struct_termio
|
|
||||||
|
|
||||||
type Winsize C.struct_winsize
|
|
||||||
|
|
||||||
// poll
|
|
||||||
|
|
||||||
type PollFd C.struct_pollfd
|
|
||||||
|
|
||||||
const (
|
|
||||||
POLLERR = C.POLLERR
|
|
||||||
POLLHUP = C.POLLHUP
|
|
||||||
POLLIN = C.POLLIN
|
|
||||||
POLLNVAL = C.POLLNVAL
|
|
||||||
POLLOUT = C.POLLOUT
|
|
||||||
POLLPRI = C.POLLPRI
|
|
||||||
POLLRDBAND = C.POLLRDBAND
|
|
||||||
POLLRDNORM = C.POLLRDNORM
|
|
||||||
POLLWRBAND = C.POLLWRBAND
|
|
||||||
POLLWRNORM = C.POLLWRNORM
|
|
||||||
)
|
|
12
vendor/modules.txt
vendored
Normal file
12
vendor/modules.txt
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# github.com/davecgh/go-spew v1.1.1
|
||||||
|
github.com/davecgh/go-spew/spew
|
||||||
|
# github.com/konsorten/go-windows-terminal-sequences v1.0.1
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences
|
||||||
|
# github.com/sirupsen/logrus v1.3.0
|
||||||
|
github.com/sirupsen/logrus
|
||||||
|
# golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
|
||||||
|
golang.org/x/crypto/ripemd160
|
||||||
|
golang.org/x/crypto/ssh/terminal
|
||||||
|
# golang.org/x/sys v0.0.0-20190121090251-770c60269bf0
|
||||||
|
golang.org/x/sys/unix
|
||||||
|
golang.org/x/sys/windows
|
Loading…
Reference in a new issue