├── .codacy.yml ├── .gitignore ├── .travis.yml ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── ascii ├── ascii.go └── ascii_test.go ├── convert ├── convert.go ├── convert_test.go ├── resize.go ├── resize_test.go └── testdata │ ├── 3x3_black.png │ ├── 3x3_white.png │ ├── 8x3_multi_colors.png │ ├── cat_2000x1500.jpg │ ├── husky_100x100.jpg │ ├── husky_200x200.jpg │ ├── husky_300x300.jpg │ ├── husky_400x400.jpg │ ├── husky_500x500.jpg │ ├── husky_600x600.jpg │ ├── husky_700x700.jpg │ ├── husky_800x800.jpg │ ├── husky_900x900.jpg │ ├── jpg_sample_image.jpg │ ├── not_supported_sample_image │ └── png_sample_image.png ├── docs └── images │ ├── baozou.gif │ ├── baozou.jpg │ ├── baozou_ascii.png │ ├── baozou_ascii_colored.png │ ├── demo.gif │ ├── long.gif │ ├── long.jpg │ ├── lufei.gif │ ├── lufei.jpg │ ├── lufei_ascii.png │ ├── lufei_ascii_colored.png │ ├── peiqi.png │ ├── pikaqiu.gif │ ├── pikaqiu.jpeg │ ├── pikaqiu2.jpg │ ├── pikaqiu_ascii.png │ ├── pikaqiu_ascii_colored.png │ └── pikaqiu_s.gif ├── image2ascii.go ├── image2ascii_test.go ├── terminal ├── mocks │ └── terminal_mock.go ├── terminal.go └── terminal_test.go └── vendor ├── github.com ├── aybabtme │ └── rgbterm │ │ ├── LICENSE │ │ ├── README.md │ │ ├── codes.go │ │ ├── interpret.go │ │ ├── rainbow │ │ └── LICENSE │ │ ├── rgbterm.go │ │ └── util.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── mattn │ └── go-isatty │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── isatty_appengine.go │ │ ├── isatty_bsd.go │ │ ├── isatty_linux.go │ │ ├── isatty_linux_ppc64x.go │ │ ├── isatty_others.go │ │ ├── isatty_solaris.go │ │ └── isatty_windows.go ├── nfnt │ └── resize │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── converter.go │ │ ├── filters.go │ │ ├── nearest.go │ │ ├── resize.go │ │ ├── thumbnail.go │ │ └── ycc.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go ├── stretchr │ └── testify │ │ ├── LICENSE │ │ └── assert │ │ ├── assertion_format.go │ │ ├── assertion_format.go.tmpl │ │ ├── assertion_forward.go │ │ ├── assertion_forward.go.tmpl │ │ ├── assertions.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── forward_assertions.go │ │ └── http_assertions.go └── wayneashleyberry │ └── terminal-dimensions │ ├── .travis.yml │ ├── license │ ├── readme.md │ └── terminaldimensions.go └── golang.org └── x └── sys ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS └── unix ├── .gitignore ├── README.md ├── affinity_linux.go ├── aliases.go ├── asm_aix_ppc64.s ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_mipsx.s ├── asm_linux_ppc64x.s ├── asm_linux_s390x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_openbsd_arm.s ├── asm_solaris_amd64.s ├── bluetooth_linux.go ├── cap_freebsd.go ├── constants.go ├── dev_aix_ppc.go ├── dev_aix_ppc64.go ├── dev_darwin.go ├── dev_dragonfly.go ├── dev_freebsd.go ├── dev_linux.go ├── dev_netbsd.go ├── dev_openbsd.go ├── dirent.go ├── endian_big.go ├── endian_little.go ├── env_unix.go ├── errors_freebsd_386.go ├── errors_freebsd_amd64.go ├── errors_freebsd_arm.go ├── fcntl.go ├── fcntl_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── ioctl.go ├── mkall.sh ├── mkerrors.sh ├── mkpost.go ├── mksyscall.pl ├── mksyscall_aix_ppc.pl ├── mksyscall_aix_ppc64.pl ├── mksyscall_solaris.pl ├── mksysctl_openbsd.pl ├── mksysnum_darwin.pl ├── mksysnum_dragonfly.pl ├── mksysnum_freebsd.pl ├── mksysnum_netbsd.pl ├── mksysnum_openbsd.pl ├── openbsd_pledge.go ├── pagesize_unix.go ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_aix.go ├── syscall_aix_ppc.go ├── syscall_aix_ppc64.go ├── syscall_bsd.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_amd64_gc.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_gc.go ├── syscall_linux_gc_386.go ├── syscall_linux_gccgo_386.go ├── syscall_linux_gccgo_arm.go ├── syscall_linux_mips64x.go ├── syscall_linux_mipsx.go ├── syscall_linux_ppc64x.go ├── syscall_linux_riscv64.go ├── syscall_linux_s390x.go ├── syscall_linux_sparc64.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_openbsd_arm.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_unix.go ├── syscall_unix_gc.go ├── timestruct.go ├── types_aix.go ├── types_darwin.go ├── types_dragonfly.go ├── types_freebsd.go ├── types_netbsd.go ├── types_openbsd.go ├── types_solaris.go ├── xattr_bsd.go ├── zerrors_aix_ppc.go ├── zerrors_aix_ppc64.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_mipsle.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_linux_riscv64.go ├── zerrors_linux_s390x.go ├── zerrors_linux_sparc64.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_openbsd_arm.go ├── zerrors_solaris_amd64.go ├── zptrace386_linux.go ├── zptracearm_linux.go ├── zptracemips_linux.go ├── zptracemipsle_linux.go ├── zsyscall_aix_ppc.go ├── zsyscall_aix_ppc64.go ├── zsyscall_aix_ppc64_gc.go ├── zsyscall_aix_ppc64_gccgo.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_mipsle.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_linux_riscv64.go ├── zsyscall_linux_s390x.go ├── zsyscall_linux_sparc64.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_openbsd_arm.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd_386.go ├── zsysctl_openbsd_amd64.go ├── zsysctl_openbsd_arm.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_mipsle.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_linux_riscv64.go ├── zsysnum_linux_s390x.go ├── zsysnum_linux_sparc64.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_openbsd_arm.go ├── ztypes_aix_ppc.go ├── ztypes_aix_ppc64.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_mipsle.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_linux_riscv64.go ├── ztypes_linux_s390x.go ├── ztypes_linux_sparc64.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go ├── ztypes_openbsd_arm.go └── ztypes_solaris_amd64.go /.codacy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | exclude_paths: 3 | - '*.md' 4 | - 'vender/**/*' 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/go,intellij+all 2 | 3 | ### Go ### 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, build with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | ### Go Patch ### 18 | #/vendor/ 19 | /Godeps/ 20 | 21 | ### Intellij+all ### 22 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 23 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 24 | 25 | # User-specific stuff 26 | .idea/**/workspace.xml 27 | .idea/**/tasks.xml 28 | .idea/**/usage.statistics.xml 29 | .idea/**/dictionaries 30 | .idea/**/shelf 31 | 32 | # Generated files 33 | .idea/**/contentModel.xml 34 | 35 | # Sensitive or high-churn files 36 | .idea/**/dataSources/ 37 | .idea/**/dataSources.ids 38 | .idea/**/dataSources.local.xml 39 | .idea/**/sqlDataSources.xml 40 | .idea/**/dynamic.xml 41 | .idea/**/uiDesigner.xml 42 | .idea/**/dbnavigator.xml 43 | 44 | # Gradle 45 | .idea/**/gradle.xml 46 | .idea/**/libraries 47 | 48 | # Gradle and Maven with auto-import 49 | # When using Gradle or Maven with auto-import, you should exclude module files, 50 | # since they will be recreated, and may cause churn. Uncomment if using 51 | # auto-import. 52 | # .idea/modules.xml 53 | # .idea/*.iml 54 | # .idea/modules 55 | 56 | # CMake 57 | cmake-build-*/ 58 | 59 | # Mongo Explorer plugin 60 | .idea/**/mongoSettings.xml 61 | 62 | # File-based project format 63 | *.iws 64 | 65 | # IntelliJ 66 | out/ 67 | 68 | # mpeltonen/sbt-idea plugin 69 | .idea_modules/ 70 | 71 | # JIRA plugin 72 | atlassian-ide-plugin.xml 73 | 74 | # Cursive Clojure plugin 75 | .idea/replstate.xml 76 | 77 | # Crashlytics plugin (for Android Studio and IntelliJ) 78 | com_crashlytics_export_strings.xml 79 | crashlytics.properties 80 | crashlytics-build.properties 81 | fabric.properties 82 | 83 | # Editor-based Rest Client 84 | .idea/httpRequests 85 | 86 | # Android studio 3.1+ serialized cache file 87 | .idea/caches/build_file_checksums.ser 88 | 89 | ### Intellij+all Patch ### 90 | # Ignores the whole .idea folder and all .iml files 91 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 92 | 93 | .idea/ 94 | 95 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 96 | 97 | *.iml 98 | modules.xml 99 | .idea/misc.xml 100 | *.ipr 101 | 102 | image2ascii 103 | 104 | 105 | # End of https://www.gitignore.io/api/go,intellij+all -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | go: 8 | - "1.8" 9 | - "1.10.x" 10 | - "1.11.x" 11 | - "tip" 12 | 13 | before_install: 14 | - go get github.com/mattn/goveralls 15 | script: 16 | - $GOPATH/bin/goveralls -service=travis-ci 17 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | digest = "1:f8c5815a76aec3fac7f6d67911eccd3a93841294052b0e81bca1ff325a1ee62d" 7 | name = "github.com/aybabtme/rgbterm" 8 | packages = ["."] 9 | pruneopts = "UT" 10 | revision = "cc83f3b3ce5911279513a46d6d3316d67bedaa54" 11 | 12 | [[projects]] 13 | digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" 14 | name = "github.com/davecgh/go-spew" 15 | packages = ["spew"] 16 | pruneopts = "UT" 17 | revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" 18 | version = "v1.1.1" 19 | 20 | [[projects]] 21 | digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5" 22 | name = "github.com/mattn/go-isatty" 23 | packages = ["."] 24 | pruneopts = "UT" 25 | revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c" 26 | version = "v0.0.4" 27 | 28 | [[projects]] 29 | branch = "master" 30 | digest = "1:34534b73e925d20cc72cf202f8b482fdcbe3a1b113e19375f31aadabd0f0f97d" 31 | name = "github.com/nfnt/resize" 32 | packages = ["."] 33 | pruneopts = "UT" 34 | revision = "83c6a9932646f83e3267f353373d47347b6036b2" 35 | 36 | [[projects]] 37 | digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" 38 | name = "github.com/pmezard/go-difflib" 39 | packages = ["difflib"] 40 | pruneopts = "UT" 41 | revision = "792786c7400a136282c1664665ae0a8db921c6c2" 42 | version = "v1.0.0" 43 | 44 | [[projects]] 45 | digest = "1:18752d0b95816a1b777505a97f71c7467a8445b8ffb55631a7bf779f6ba4fa83" 46 | name = "github.com/stretchr/testify" 47 | packages = ["assert"] 48 | pruneopts = "UT" 49 | revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" 50 | version = "v1.2.2" 51 | 52 | [[projects]] 53 | digest = "1:9b4fd49bb5908e00ecb36f3199008562d5c9fa7b3ddee554465f4d8bfde52d4c" 54 | name = "github.com/wayneashleyberry/terminal-dimensions" 55 | packages = ["."] 56 | pruneopts = "UT" 57 | revision = "29d939246793fbd8100dcf74700637adcb839bc5" 58 | version = "v1.0.0" 59 | 60 | [[projects]] 61 | branch = "master" 62 | digest = "1:be4f165c438aa39318fd5c8c180a95f4a52524641c0b714638b0fd9fd912b38d" 63 | name = "golang.org/x/sys" 64 | packages = ["unix"] 65 | pruneopts = "UT" 66 | revision = "8e24a49d80f82323e1c4db1b5da3e0f31171a151" 67 | 68 | [solve-meta] 69 | analyzer-name = "dep" 70 | analyzer-version = 1 71 | input-imports = [ 72 | "github.com/aybabtme/rgbterm", 73 | "github.com/mattn/go-isatty", 74 | "github.com/nfnt/resize", 75 | "github.com/stretchr/testify/assert", 76 | "github.com/wayneashleyberry/terminal-dimensions", 77 | ] 78 | solver-name = "gps-cdcl" 79 | solver-version = 1 80 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [[constraint]] 29 | branch = "master" 30 | name = "github.com/nfnt/resize" 31 | 32 | [prune] 33 | go-tests = true 34 | unused-packages = true 35 | 36 | [[constraint]] 37 | name = "github.com/mattn/go-isatty" 38 | version = "0.0.4" 39 | 40 | [[constraint]] 41 | name = "github.com/wayneashleyberry/terminal-dimensions" 42 | version = "1.0.0" 43 | 44 | [[constraint]] 45 | branch = "master" 46 | name = "github.com/aybabtme/rgbterm" 47 | 48 | [[constraint]] 49 | name = "github.com/stretchr/testify" 50 | version = "1.2.2" 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 秦世成 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ascii/ascii.go: -------------------------------------------------------------------------------- 1 | // Package ascii can convert a image pixel to a raw char 2 | // base on it's RGBA value, in another word, input a image pixel 3 | // output a raw char ascii. 4 | package ascii 5 | 6 | import ( 7 | "github.com/aybabtme/rgbterm" 8 | "image/color" 9 | "math" 10 | "reflect" 11 | ) 12 | 13 | // CharPixel is converted pixel ascii 14 | type CharPixel struct { 15 | Char byte 16 | R uint8 17 | G uint8 18 | B uint8 19 | A uint8 20 | } 21 | 22 | // Options convert pixel to raw char 23 | type Options struct { 24 | Pixels []byte 25 | Reversed bool 26 | Colored bool 27 | } 28 | 29 | // DefaultOptions that contains the default pixels 30 | var DefaultOptions = Options{ 31 | Pixels: []byte(" .,:;i1tfLCG08@"), 32 | Reversed: false, 33 | Colored: true, 34 | } 35 | 36 | // NewOptions create a new convert option 37 | func NewOptions() Options { 38 | newOptions := Options{} 39 | newOptions.mergeOptions(&DefaultOptions) 40 | return newOptions 41 | } 42 | 43 | // mergeOptions merge two options 44 | func (options *Options) mergeOptions(newOptions *Options) { 45 | options.Pixels = append([]byte{}, newOptions.Pixels...) 46 | options.Reversed = newOptions.Reversed 47 | options.Colored = newOptions.Colored 48 | } 49 | 50 | // NewPixelConverter create a new pixel converter 51 | func NewPixelConverter() PixelConverter { 52 | return PixelASCIIConverter{} 53 | } 54 | 55 | // PixelConverter define the convert pixel operation 56 | type PixelConverter interface { 57 | ConvertPixelToASCII(pixel color.Color, options *Options) string 58 | ConvertPixelToPixelASCII(pixel color.Color, options *Options) CharPixel 59 | } 60 | 61 | // PixelASCIIConverter responsible for pixel ascii conversion 62 | type PixelASCIIConverter struct { 63 | } 64 | 65 | // ConvertPixelToPixelASCII convert a image pixel to CharPixel 66 | func (converter PixelASCIIConverter) ConvertPixelToPixelASCII(pixel color.Color, options *Options) CharPixel { 67 | convertOptions := NewOptions() 68 | convertOptions.mergeOptions(options) 69 | 70 | if convertOptions.Reversed { 71 | convertOptions.Pixels = converter.reverse(convertOptions.Pixels) 72 | } 73 | 74 | r := reflect.ValueOf(pixel).FieldByName("R").Uint() 75 | g := reflect.ValueOf(pixel).FieldByName("G").Uint() 76 | b := reflect.ValueOf(pixel).FieldByName("B").Uint() 77 | a := reflect.ValueOf(pixel).FieldByName("A").Uint() 78 | value := converter.intensity(r, g, b, a) 79 | 80 | // Choose the char 81 | precision := float64(255 * 3 / (len(convertOptions.Pixels) - 1)) 82 | rawChar := convertOptions.Pixels[converter.roundValue(float64(value)/precision)] 83 | return CharPixel{ 84 | Char: rawChar, 85 | R: uint8(r), 86 | G: uint8(g), 87 | B: uint8(b), 88 | A: uint8(a), 89 | } 90 | } 91 | 92 | // ConvertPixelToASCII converts a pixel to a ASCII char string 93 | func (converter PixelASCIIConverter) ConvertPixelToASCII(pixel color.Color, options *Options) string { 94 | convertOptions := NewOptions() 95 | convertOptions.mergeOptions(options) 96 | 97 | pixelASCII := converter.ConvertPixelToPixelASCII(pixel, options) 98 | rawChar, r, g, b := pixelASCII.Char, pixelASCII.R, pixelASCII.G, pixelASCII.B 99 | if convertOptions.Colored { 100 | return converter.decorateWithColor(r, g, b, rawChar) 101 | } 102 | return string([]byte{rawChar}) 103 | } 104 | 105 | func (converter PixelASCIIConverter) roundValue(value float64) int { 106 | return int(math.Floor(value + 0.5)) 107 | } 108 | 109 | func (converter PixelASCIIConverter) reverse(numbers []byte) []byte { 110 | for i := 0; i < len(numbers)/2; i++ { 111 | j := len(numbers) - i - 1 112 | numbers[i], numbers[j] = numbers[j], numbers[i] 113 | } 114 | return numbers 115 | } 116 | 117 | func (converter PixelASCIIConverter) intensity(r, g, b, a uint64) uint64 { 118 | return (r + g + b) * a / 255 119 | } 120 | 121 | // decorateWithColor decorate the raw char with the color base on r,g,b value 122 | func (converter PixelASCIIConverter) decorateWithColor(r, g, b uint8, rawChar byte) string { 123 | coloredChar := rgbterm.FgString(string([]byte{rawChar}), uint8(r), uint8(g), uint8(b)) 124 | return coloredChar 125 | } 126 | -------------------------------------------------------------------------------- /ascii/ascii_test.go: -------------------------------------------------------------------------------- 1 | package ascii 2 | 3 | import ( 4 | "fmt" 5 | "github.com/stretchr/testify/assert" 6 | "image/color" 7 | "reflect" 8 | "testing" 9 | ) 10 | 11 | // TestNewOptions create options with default values 12 | func TestNewOptions(t *testing.T) { 13 | newOptions := NewOptions() 14 | assertions := assert.New(t) 15 | assertions.True(newOptions.Colored, "Default colored option should be true") 16 | assertions.False(newOptions.Reversed, "Default reverse option should be false") 17 | assertions.Equal(" .,:;i1tfLCG08@", string(newOptions.Pixels), "Default pixels should be .,:;i1tfLCG08@") 18 | } 19 | 20 | // TestMergeOptions test merge the options 21 | func TestMergeOptions(t *testing.T) { 22 | assertions := assert.New(t) 23 | options1 := NewOptions() 24 | options2 := NewOptions() 25 | options2.Colored = false 26 | options1.mergeOptions(&options2) 27 | assertions.False(options1.Reversed, "Merged reverse option should be false") 28 | assertions.False(options1.Colored, "Merged colored option should be false") 29 | } 30 | 31 | // TestConvertPixelToASCIIWhiteColor convert a white image pixel to ascii string 32 | func TestConvertPixelToASCIIWhiteColor(t *testing.T) { 33 | converter := NewPixelConverter() 34 | assertions := assert.New(t) 35 | r, g, b, a := uint8(255), uint8(255), uint8(255), uint8(255) 36 | pixel := color.RGBA{ 37 | R: r, 38 | G: g, 39 | B: b, 40 | A: a, 41 | } 42 | 43 | defaultOptions := NewOptions() 44 | defaultOptions.Colored = false 45 | convertedChar := converter.ConvertPixelToASCII(pixel, &defaultOptions) 46 | lastPixelChar := defaultOptions.Pixels[len(defaultOptions.Pixels)-1] 47 | assertions.Equal(convertedChar, string([]byte{lastPixelChar}), 48 | fmt.Sprintf("White color chould be converted to %s", string([]byte{lastPixelChar}))) 49 | 50 | defaultOptions.Colored = false 51 | defaultOptions.Reversed = true 52 | convertedChar = converter.ConvertPixelToASCII(pixel, &defaultOptions) 53 | firstPixelChar := defaultOptions.Pixels[0] 54 | assertions.Equal(convertedChar, string([]byte{firstPixelChar}), 55 | fmt.Sprintf("Reversed white color chould be converted to %s", string([]byte{firstPixelChar}))) 56 | } 57 | 58 | // TestConvertPixelToASCIIBlackColor convert a white image pixel to ascii string 59 | func TestConvertPixelToASCIIBlackColor(t *testing.T) { 60 | converter := NewPixelConverter() 61 | assertions := assert.New(t) 62 | r, g, b, a := uint8(0), uint8(0), uint8(0), uint8(0) 63 | pixel := color.RGBA{ 64 | R: r, 65 | G: g, 66 | B: b, 67 | A: a, 68 | } 69 | 70 | defaultOptions := NewOptions() 71 | defaultOptions.Colored = false 72 | convertedChar := converter.ConvertPixelToASCII(pixel, &defaultOptions) 73 | firstPixelChar := defaultOptions.Pixels[0] 74 | assertions.Equal(convertedChar, string([]byte{firstPixelChar}), 75 | fmt.Sprintf("Black color chould be converted to %s", string([]byte{firstPixelChar}))) 76 | 77 | defaultOptions.Colored = false 78 | defaultOptions.Reversed = true 79 | convertedChar = converter.ConvertPixelToASCII(pixel, &defaultOptions) 80 | lastPixelChar := defaultOptions.Pixels[len(defaultOptions.Pixels)-1] 81 | assertions.Equal(convertedChar, string([]byte{lastPixelChar}), 82 | fmt.Sprintf("Reversed Black color chould be converted to %s", string([]byte{lastPixelChar}))) 83 | } 84 | 85 | func TestColoredASCIIChar(t *testing.T) { 86 | converter := NewPixelConverter() 87 | assertions := assert.New(t) 88 | r, g, b, a := uint8(123), uint8(123), uint8(123), uint8(255) 89 | pixel := color.RGBA{ 90 | R: r, 91 | G: g, 92 | B: b, 93 | A: a, 94 | } 95 | defaultOptions := NewOptions() 96 | defaultOptions.Colored = true 97 | coloredChar := converter.ConvertPixelToASCII(pixel, &defaultOptions) 98 | assertions.True(len(coloredChar) > 1) 99 | } 100 | 101 | // TestReverseSlice test reverse a slice 102 | func TestReverseSlice(t *testing.T) { 103 | converter := PixelASCIIConverter{} 104 | s := []byte{1, 2, 3, 4, 5} 105 | reversedSlice := converter.reverse(s) 106 | expectedReversedSlice := []byte{5, 4, 3, 2, 1} 107 | assert.True(t, reflect.DeepEqual(reversedSlice, expectedReversedSlice), 108 | fmt.Sprintf("%+v reversed should equal to %+v", s, expectedReversedSlice)) 109 | 110 | s = []byte{1, 2, 3, 4} 111 | reversedSlice = converter.reverse(s) 112 | expectedReversedSlice = []byte{4, 3, 2, 1} 113 | assert.True(t, reflect.DeepEqual(reversedSlice, expectedReversedSlice), 114 | fmt.Sprintf("%+v reversed should equal to %+v", s, expectedReversedSlice)) 115 | } 116 | 117 | // ExampleConvertPixelToASCII is a example convert pixel to ascii char 118 | func ExamplePixelASCIIConverter_ConvertPixelToASCII() { 119 | converter := NewPixelConverter() 120 | // Create the pixel 121 | r, g, b, a := uint8(255), uint8(255), uint8(255), uint8(255) 122 | pixel := color.RGBA{ 123 | R: r, 124 | G: g, 125 | B: b, 126 | A: a, 127 | } 128 | 129 | // Create the convert options 130 | defaultOptions := NewOptions() 131 | defaultOptions.Colored = false 132 | convertedChar := converter.ConvertPixelToASCII(pixel, &defaultOptions) 133 | fmt.Println(convertedChar) 134 | // Output: @ 135 | } 136 | -------------------------------------------------------------------------------- /convert/testdata/3x3_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/3x3_black.png -------------------------------------------------------------------------------- /convert/testdata/3x3_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/3x3_white.png -------------------------------------------------------------------------------- /convert/testdata/8x3_multi_colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/8x3_multi_colors.png -------------------------------------------------------------------------------- /convert/testdata/cat_2000x1500.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/cat_2000x1500.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_100x100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_100x100.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_200x200.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_200x200.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_300x300.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_300x300.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_400x400.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_400x400.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_500x500.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_500x500.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_600x600.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_600x600.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_700x700.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_700x700.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_800x800.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_800x800.jpg -------------------------------------------------------------------------------- /convert/testdata/husky_900x900.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/husky_900x900.jpg -------------------------------------------------------------------------------- /convert/testdata/jpg_sample_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/jpg_sample_image.jpg -------------------------------------------------------------------------------- /convert/testdata/not_supported_sample_image: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /convert/testdata/png_sample_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/convert/testdata/png_sample_image.png -------------------------------------------------------------------------------- /docs/images/baozou.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/baozou.gif -------------------------------------------------------------------------------- /docs/images/baozou.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/baozou.jpg -------------------------------------------------------------------------------- /docs/images/baozou_ascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/baozou_ascii.png -------------------------------------------------------------------------------- /docs/images/baozou_ascii_colored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/baozou_ascii_colored.png -------------------------------------------------------------------------------- /docs/images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/demo.gif -------------------------------------------------------------------------------- /docs/images/long.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/long.gif -------------------------------------------------------------------------------- /docs/images/long.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/long.jpg -------------------------------------------------------------------------------- /docs/images/lufei.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/lufei.gif -------------------------------------------------------------------------------- /docs/images/lufei.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/lufei.jpg -------------------------------------------------------------------------------- /docs/images/lufei_ascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/lufei_ascii.png -------------------------------------------------------------------------------- /docs/images/lufei_ascii_colored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/lufei_ascii_colored.png -------------------------------------------------------------------------------- /docs/images/peiqi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/peiqi.png -------------------------------------------------------------------------------- /docs/images/pikaqiu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu.gif -------------------------------------------------------------------------------- /docs/images/pikaqiu.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu.jpeg -------------------------------------------------------------------------------- /docs/images/pikaqiu2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu2.jpg -------------------------------------------------------------------------------- /docs/images/pikaqiu_ascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu_ascii.png -------------------------------------------------------------------------------- /docs/images/pikaqiu_ascii_colored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu_ascii_colored.png -------------------------------------------------------------------------------- /docs/images/pikaqiu_s.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qeesung/image2ascii/4db5ededbe82b0169015852779ed893c5b634201/docs/images/pikaqiu_s.gif -------------------------------------------------------------------------------- /image2ascii.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "flag" 6 | "fmt" 7 | "github.com/qeesung/image2ascii/convert" 8 | _ "image/jpeg" 9 | _ "image/png" 10 | "os" 11 | ) 12 | 13 | var imageFilename string 14 | var ratio float64 15 | var fixedWidth int 16 | var fixedHeight int 17 | var fitScreen bool 18 | var stretchedScreen bool 19 | var colored bool 20 | var reversed bool 21 | 22 | var convertDefaultOptions = convert.DefaultOptions 23 | 24 | func init() { 25 | flag.StringVar(&imageFilename, 26 | "f", 27 | "", 28 | "Image filename to be convert") 29 | flag.Float64Var(&ratio, 30 | "r", 31 | convertDefaultOptions.Ratio, 32 | "Ratio to scale the image, ignored when use -w or -g") 33 | flag.IntVar(&fixedWidth, 34 | "w", 35 | convertDefaultOptions.FixedWidth, 36 | "Expected image width, -1 for image default width") 37 | flag.IntVar(&fixedHeight, 38 | "g", 39 | convertDefaultOptions.FixedHeight, 40 | "Expected image height, -1 for image default height") 41 | flag.BoolVar(&fitScreen, 42 | "s", 43 | convertDefaultOptions.FitScreen, 44 | "Fit the terminal screen, ignored when use -w, -g, -r") 45 | flag.BoolVar(&colored, 46 | "c", 47 | convertDefaultOptions.Colored, 48 | "Colored the ascii when output to the terminal") 49 | flag.BoolVar(&reversed, 50 | "i", 51 | convertDefaultOptions.Reversed, 52 | "Reversed the ascii when output to the terminal") 53 | flag.BoolVar(&stretchedScreen, 54 | "t", 55 | convertDefaultOptions.StretchedScreen, 56 | "Stretch the picture to overspread the screen") 57 | flag.Usage = usage 58 | } 59 | 60 | func main() { 61 | flag.Parse() 62 | if convertOptions, err := parseOptions(); err == nil { 63 | converter := convert.NewImageConverter() 64 | fmt.Print(converter.ImageFile2ASCIIString(imageFilename, convertOptions)) 65 | } else { 66 | usage() 67 | } 68 | } 69 | 70 | func parseOptions() (*convert.Options, error) { 71 | if imageFilename == "" { 72 | return nil, errors.New("image file should not be empty") 73 | } 74 | // config the options 75 | convertOptions := &convert.Options{ 76 | Ratio: ratio, 77 | FixedWidth: fixedWidth, 78 | FixedHeight: fixedHeight, 79 | FitScreen: fitScreen, 80 | StretchedScreen: stretchedScreen, 81 | Colored: colored, 82 | Reversed: reversed, 83 | } 84 | return convertOptions, nil 85 | } 86 | 87 | func usage() { 88 | fmt.Fprintf(os.Stderr, `image2ascii version: image2ascii/1.0.0 89 | >> HomePage: https://github.com/qeesung/image2ascii 90 | >> Issue : https://github.com/qeesung/image2ascii/issues 91 | >> Author : qeesung 92 | Usage: image2ascii [-s] -f -r -w -g 93 | 94 | Options: 95 | `) 96 | flag.PrintDefaults() 97 | } 98 | -------------------------------------------------------------------------------- /image2ascii_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestParseEmptyFilenameOptions(t *testing.T) { 9 | assertions := assert.New(t) 10 | imageFilename = "" 11 | _, err := parseOptions() 12 | assertions.True(err != nil) 13 | } 14 | 15 | func TestParseOptions(t *testing.T) { 16 | assertions := assert.New(t) 17 | imageFilename = "filename" 18 | ratio = 0.5 19 | fitScreen = false 20 | colored = false 21 | fixedHeight = 100 22 | fixedWidth = 100 23 | opt, err := parseOptions() 24 | assertions.True(err == nil) 25 | assertions.Equal(ratio, opt.Ratio) 26 | assertions.False(fitScreen) 27 | assertions.False(colored) 28 | assertions.Equal(fixedWidth, opt.FixedWidth) 29 | assertions.Equal(fixedHeight, opt.FixedHeight) 30 | } 31 | 32 | func TestParseUsage(t *testing.T) { 33 | usage() 34 | } 35 | -------------------------------------------------------------------------------- /terminal/mocks/terminal_mock.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery v1.0.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import mock "github.com/stretchr/testify/mock" 6 | 7 | // Terminal is an autogenerated mock type for the Terminal type 8 | type Terminal struct { 9 | mock.Mock 10 | } 11 | 12 | // CharWidth provides a mock function with given fields: 13 | func (_m *Terminal) CharWidth() float64 { 14 | ret := _m.Called() 15 | 16 | var r0 float64 17 | if rf, ok := ret.Get(0).(func() float64); ok { 18 | r0 = rf() 19 | } else { 20 | r0 = ret.Get(0).(float64) 21 | } 22 | 23 | return r0 24 | } 25 | 26 | // IsWindows provides a mock function with given fields: 27 | func (_m *Terminal) IsWindows() bool { 28 | ret := _m.Called() 29 | 30 | var r0 bool 31 | if rf, ok := ret.Get(0).(func() bool); ok { 32 | r0 = rf() 33 | } else { 34 | r0 = ret.Get(0).(bool) 35 | } 36 | 37 | return r0 38 | } 39 | 40 | // ScreenSize provides a mock function with given fields: 41 | func (_m *Terminal) ScreenSize() (int, int, error) { 42 | ret := _m.Called() 43 | 44 | var r0 int 45 | if rf, ok := ret.Get(0).(func() int); ok { 46 | r0 = rf() 47 | } else { 48 | r0 = ret.Get(0).(int) 49 | } 50 | 51 | var r1 int 52 | if rf, ok := ret.Get(1).(func() int); ok { 53 | r1 = rf() 54 | } else { 55 | r1 = ret.Get(1).(int) 56 | } 57 | 58 | var r2 error 59 | if rf, ok := ret.Get(2).(func() error); ok { 60 | r2 = rf() 61 | } else { 62 | r2 = ret.Error(2) 63 | } 64 | 65 | return r0, r1, r2 66 | } 67 | -------------------------------------------------------------------------------- /terminal/terminal.go: -------------------------------------------------------------------------------- 1 | package terminal 2 | 3 | import ( 4 | "errors" 5 | "github.com/mattn/go-isatty" 6 | terminal "github.com/wayneashleyberry/terminal-dimensions" 7 | "os" 8 | "runtime" 9 | ) 10 | 11 | const ( 12 | charWidthWindows = 0.714 13 | charWidthOther = 0.5 14 | ) 15 | 16 | // NewTerminalAccessor create a new terminal accessor 17 | func NewTerminalAccessor() Terminal { 18 | return Accessor{} 19 | } 20 | 21 | // Terminal get the terminal basic information 22 | type Terminal interface { 23 | CharWidth() float64 24 | ScreenSize() (width, height int, err error) 25 | IsWindows() bool 26 | } 27 | 28 | // Accessor implement the Terminal interface and 29 | // fetch the terminal basic information 30 | type Accessor struct { 31 | } 32 | 33 | // CharWidth get the terminal char width 34 | func (accessor Accessor) CharWidth() float64 { 35 | if accessor.IsWindows() { 36 | return charWidthWindows 37 | } 38 | return charWidthOther 39 | } 40 | 41 | // IsWindows check if current system is windows 42 | func (accessor Accessor) IsWindows() bool { 43 | return runtime.GOOS == "windows" 44 | } 45 | 46 | // ScreenSize get the terminal screen size 47 | func (accessor Accessor) ScreenSize() (newWidth, newHeight int, err error) { 48 | if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) { 49 | return 0, 0, 50 | errors.New("can not detect the terminal") 51 | } 52 | 53 | x, _ := terminal.Width() 54 | y, _ := terminal.Height() 55 | 56 | return int(x), int(y), nil 57 | } 58 | -------------------------------------------------------------------------------- /terminal/terminal_test.go: -------------------------------------------------------------------------------- 1 | package terminal 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestNewTerminalAccessor(t *testing.T) { 9 | assertions := assert.New(t) 10 | accessor := NewTerminalAccessor() 11 | assertions.True(accessor != nil) 12 | } 13 | 14 | func TestAccessor_CharWidth(t *testing.T) { 15 | assertions := assert.New(t) 16 | accessor := NewTerminalAccessor() 17 | charWidth := accessor.CharWidth() 18 | if accessor.IsWindows() { 19 | assertions.Equal(charWidthWindows, charWidth) 20 | } else { 21 | assertions.Equal(charWidthOther, charWidth) 22 | } 23 | } 24 | 25 | func TestAccessor_ScreenSize(t *testing.T) { 26 | assertions := assert.New(t) 27 | accessor := NewTerminalAccessor() 28 | _, _, err := accessor.ScreenSize() 29 | assertions.True(err != nil) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/aybabtme/rgbterm/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014, Antoine Grondin. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | > Except for functions HSLtoRGB and RGBtoHSL, under a BSD 2 clause license: 24 | 25 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 26 | 27 | Redistribution and use in source and binary forms, with or without 28 | modification, are permitted provided that the following conditions are 29 | met: 30 | 31 | * Redistributions of source code must retain the above copyright 32 | notice, this list of conditions and the following disclaimer. 33 | * Redistributions in binary form must reproduce the above 34 | copyright notice, this list of conditions and the following disclaimer 35 | in the documentation and/or other materials provided with the 36 | distribution. 37 | * Neither the name of Google Inc. nor the names of its 38 | contributors may be used to endorse or promote products derived from 39 | this software without specific prior written permission. 40 | 41 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 42 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 43 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 44 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 45 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 47 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 48 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 49 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 50 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 51 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52 | -------------------------------------------------------------------------------- /vendor/github.com/aybabtme/rgbterm/README.md: -------------------------------------------------------------------------------- 1 | # RGB terminal 2 | 3 | Have you had enough of the same 16 colors in your terminal? 4 | 5 | Welcome to a new world. A new world where colors are plentyful. 6 | A world in 256 colors. 7 | 8 | ![so many colors!](https://cloud.githubusercontent.com/assets/1189716/3563662/15e67546-0a49-11e4-871e-47e694d08981.png) 9 | 10 | # Usage 11 | 12 | ```go 13 | // pick a color 14 | var r, g, b uint8 15 | r, g, b = 252, 255, 43 16 | // choose a word 17 | word := "=)" 18 | // colorize it! 19 | coloredWord := rgbterm.FgString(word, r, g, b) 20 | // print it! 21 | fmt.Println("Oh!", coloredWord, "hello!") 22 | ``` 23 | 24 | > ![screen shot 2014-07-13 at 0 56 44](https://cloud.githubusercontent.com/assets/1189716/3563695/54e7f048-0a4a-11e4-8b53-613761c6c4e2.png) 25 | 26 | Also, to be correct: there are 216 colors and 16 grey scales. For more details, [Xterm][xterm-wiki]. 27 | 28 | [xterm-wiki]: https://en.wikipedia.org/wiki/Xterm 29 | -------------------------------------------------------------------------------- /vendor/github.com/aybabtme/rgbterm/rainbow/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014, Antoine Grondin. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/aybabtme/rgbterm/rgbterm.go: -------------------------------------------------------------------------------- 1 | // Package rgbterm colorizes bytes and strings using RGB colors, for a 2 | // full range of pretty terminal strings. 3 | // 4 | // Beyond the traditional boring 16 colors of your terminal lie an 5 | // extended set of 256 pretty colors waiting to be used. However, they 6 | // are weirdly encoded; simply asking for an RGB color is much more 7 | // convenient! 8 | // 9 | // It's easy to use, pick an RGB code and just use it! 10 | // 11 | // var r, g, b uint8 12 | // // pick a color 13 | // r, g, b = 252, 255, 43 14 | // // choose a word 15 | // word := "=)" 16 | // // colorize it! 17 | // coloredWord := rgbterm.String(word, r, g, b) 18 | // 19 | // fmt.Println("Oh!", coloredWord, "hello!") 20 | // 21 | // Alternately, use ColorOut or one of the Interpret functions to output 22 | // a string with color escape codes: 23 | // 24 | // fmt.Fprintln(rgbterm.ColorOut, "Let's print some {#ff0000}red{} and {#00ff00}green{} text") 25 | // fmt.Fprintln(rgbterm.ColorOut, "Let's print some {#8080ff}blue,") 26 | // fmt.Fprintln(rgbterm.ColorOut, "blue, blue{} text.") 27 | // 28 | // The RGB <-> HSL helpers were shamelessly taken from gorilla color, BSD 2 clauses 29 | // licensed: 30 | // https://code.google.com/p/gorilla/source/browse/?r=ef489f63418265a7249b1d53bdc358b09a4a2ea0#hg%2Fcolor 31 | package rgbterm 32 | 33 | var ( 34 | before = []byte("\033[") 35 | after = []byte("m") 36 | reset = []byte("\033[0;00m") 37 | fgcolors = fgTermRGB[16:232] 38 | bgcolors = bgTermRGB[16:232] 39 | ) 40 | 41 | // String colorizes the input with the terminal color that matches 42 | // the closest the RGB color. 43 | // 44 | // This is simply a helper for Bytes. 45 | func String(in string, fr, fg, fb, br, bg, bb uint8) string { 46 | return string(Bytes([]byte(in), fr, fg, fb, br, bg, bb)) 47 | } 48 | 49 | // FgString colorizes the foreground of the input with the terminal color 50 | // that matches the closest the RGB color. 51 | // 52 | // This is simply a helper for Bytes. 53 | func FgString(in string, r, g, b uint8) string { 54 | return string(FgBytes([]byte(in), r, g, b)) 55 | } 56 | 57 | // BgString colorizes the background of the input with the terminal color 58 | // that matches the closest the RGB color. 59 | // 60 | // This is simply a helper for Bytes. 61 | func BgString(in string, r, g, b uint8) string { 62 | return string(BgBytes([]byte(in), r, g, b)) 63 | } 64 | 65 | // Bytes colorizes the input with the terminal color that matches 66 | // the closest the RGB color. 67 | func Bytes(in []byte, fr, fg, fb, br, bg, bb uint8) []byte { 68 | return colorize(rgb(fr, fg, fb, br, bg, bb), in) 69 | } 70 | 71 | // Bytes colorizes the foreground with the terminal color that matches 72 | // the closest the RGB color. 73 | func FgBytes(in []byte, r, g, b uint8) []byte { 74 | return colorize(color(r, g, b, true), in) 75 | } 76 | 77 | // BgBytes colorizes the background of the input with the terminal color 78 | // that matches the closest the RGB color. 79 | func BgBytes(in []byte, r, g, b uint8) []byte { 80 | return colorize(color(r, g, b, false), in) 81 | } 82 | 83 | // Byte colorizes the input with the terminal color that matches 84 | // the closest the RGB color. 85 | func FgByte(in byte, r, g, b uint8) []byte { 86 | return colorize(color(r, g, b, true), []byte{in}) 87 | } 88 | 89 | // BgByte colorizes the background of the input with the terminal color 90 | // that matches the closest the RGB color. 91 | func BgByte(in byte, r, g, b uint8) []byte { 92 | return colorize(color(r, g, b, false), []byte{in}) 93 | } 94 | 95 | func colorize(color, in []byte) []byte { 96 | return append(append(append(append(before, color...), after...), in...), reset...) 97 | } 98 | 99 | func rgb(fr, fg, fb, br, bg, bb uint8) []byte { 100 | fore := append(color(fr, fg, fb, true), byte(';')) 101 | back := color(br, bg, bb, false) 102 | return append(fore, back...) 103 | } 104 | 105 | func color(r, g, b uint8, foreground bool) []byte { 106 | // if all colors are equal, it might be in the grayscale range 107 | if r == g && g == b { 108 | color, ok := grayscale(r, foreground) 109 | if ok { 110 | return color 111 | } 112 | } 113 | 114 | // the general case approximates RGB by using the closest color. 115 | r6 := ((uint16(r) * 5) / 255) 116 | g6 := ((uint16(g) * 5) / 255) 117 | b6 := ((uint16(b) * 5) / 255) 118 | i := 36*r6 + 6*g6 + b6 119 | if foreground { 120 | return fgcolors[i] 121 | } else { 122 | return bgcolors[i] 123 | } 124 | } 125 | 126 | func grayscale(scale uint8, foreground bool) ([]byte, bool) { 127 | var source [256][]byte 128 | 129 | if foreground { 130 | source = fgTermRGB 131 | } else { 132 | source = bgTermRGB 133 | } 134 | 135 | switch scale { 136 | case 0x08: 137 | return source[232], true 138 | case 0x12: 139 | return source[233], true 140 | case 0x1c: 141 | return source[234], true 142 | case 0x26: 143 | return source[235], true 144 | case 0x30: 145 | return source[236], true 146 | case 0x3a: 147 | return source[237], true 148 | case 0x44: 149 | return source[238], true 150 | case 0x4e: 151 | return source[239], true 152 | case 0x58: 153 | return source[240], true 154 | case 0x62: 155 | return source[241], true 156 | case 0x6c: 157 | return source[242], true 158 | case 0x76: 159 | return source[243], true 160 | case 0x80: 161 | return source[244], true 162 | case 0x8a: 163 | return source[245], true 164 | case 0x94: 165 | return source[246], true 166 | case 0x9e: 167 | return source[247], true 168 | case 0xa8: 169 | return source[248], true 170 | case 0xb2: 171 | return source[249], true 172 | case 0xbc: 173 | return source[250], true 174 | case 0xc6: 175 | return source[251], true 176 | case 0xd0: 177 | return source[252], true 178 | case 0xda: 179 | return source[253], true 180 | case 0xe4: 181 | return source[254], true 182 | case 0xee: 183 | return source[255], true 184 | } 185 | return nil, false 186 | } 187 | -------------------------------------------------------------------------------- /vendor/github.com/aybabtme/rgbterm/util.go: -------------------------------------------------------------------------------- 1 | package rgbterm 2 | 3 | import ( 4 | "math" 5 | ) 6 | 7 | // stolen from gorilla color: 8 | // https://code.google.com/p/gorilla/source/browse/?r=ef489f63418265a7249b1d53bdc358b09a4a2ea0#hg%2Fcolor 9 | 10 | // RGBtoHSL is a helper that transforms 8bits HSL colors to 11 | // 8bits RGB colors. 12 | func RGBtoHSL(r, g, b uint8) (h, s, l float64) { 13 | fR := float64(r) / 255 14 | fG := float64(g) / 255 15 | fB := float64(b) / 255 16 | max := math.Max(math.Max(fR, fG), fB) 17 | min := math.Min(math.Min(fR, fG), fB) 18 | l = (max + min) / 2 19 | if max == min { 20 | // Achromatic. 21 | h, s = 0, 0 22 | } else { 23 | // Chromatic. 24 | d := max - min 25 | if l > 0.5 { 26 | s = d / (2.0 - max - min) 27 | } else { 28 | s = d / (max + min) 29 | } 30 | switch max { 31 | case fR: 32 | h = (fG - fB) / d 33 | if fG < fB { 34 | h += 6 35 | } 36 | case fG: 37 | h = (fB-fR)/d + 2 38 | case fB: 39 | h = (fR-fG)/d + 4 40 | } 41 | h /= 6 42 | } 43 | return 44 | } 45 | 46 | // HSLtoRGB is a helper that transforms 8bits RGB colors to 47 | // 8bits HSL colors. 48 | func HSLtoRGB(h, s, l float64) (r, g, b uint8) { 49 | var fR, fG, fB float64 50 | if s == 0 { 51 | fR, fG, fB = l, l, l 52 | } else { 53 | var q float64 54 | if l < 0.5 { 55 | q = l * (1 + s) 56 | } else { 57 | q = l + s - s*l 58 | } 59 | p := 2*l - q 60 | fR = hueToRGB(p, q, h+1.0/3) 61 | fG = hueToRGB(p, q, h) 62 | fB = hueToRGB(p, q, h-1.0/3) 63 | } 64 | r = uint8((fR * 255) + 0.5) 65 | g = uint8((fG * 255) + 0.5) 66 | b = uint8((fB * 255) + 0.5) 67 | return 68 | } 69 | 70 | // hueToRGB is a helper function for HSLtoRGB. 71 | func hueToRGB(p, q, t float64) float64 { 72 | if t < 0 { 73 | t++ 74 | } 75 | if t > 1 { 76 | t-- 77 | } 78 | if t < 1.0/6 { 79 | return p + (q-p)*6*t 80 | } 81 | if t < 0.5 { 82 | return q 83 | } 84 | if t < 2.0/3 { 85 | return p + (q-p)*(2.0/3-t)*6 86 | } 87 | return p 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypass.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is not running on Google App Engine, compiled by GopherJS, and 17 | // "-tags safe" is not added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // Go versions prior to 1.4 are disabled because they use a different layout 20 | // for interfaces which make the implementation of unsafeReflectValue more complex. 21 | // +build !js,!appengine,!safe,!disableunsafe,go1.4 22 | 23 | package spew 24 | 25 | import ( 26 | "reflect" 27 | "unsafe" 28 | ) 29 | 30 | const ( 31 | // UnsafeDisabled is a build-time constant which specifies whether or 32 | // not access to the unsafe package is available. 33 | UnsafeDisabled = false 34 | 35 | // ptrSize is the size of a pointer on the current arch. 36 | ptrSize = unsafe.Sizeof((*byte)(nil)) 37 | ) 38 | 39 | type flag uintptr 40 | 41 | var ( 42 | // flagRO indicates whether the value field of a reflect.Value 43 | // is read-only. 44 | flagRO flag 45 | 46 | // flagAddr indicates whether the address of the reflect.Value's 47 | // value may be taken. 48 | flagAddr flag 49 | ) 50 | 51 | // flagKindMask holds the bits that make up the kind 52 | // part of the flags field. In all the supported versions, 53 | // it is in the lower 5 bits. 54 | const flagKindMask = flag(0x1f) 55 | 56 | // Different versions of Go have used different 57 | // bit layouts for the flags type. This table 58 | // records the known combinations. 59 | var okFlags = []struct { 60 | ro, addr flag 61 | }{{ 62 | // From Go 1.4 to 1.5 63 | ro: 1 << 5, 64 | addr: 1 << 7, 65 | }, { 66 | // Up to Go tip. 67 | ro: 1<<5 | 1<<6, 68 | addr: 1 << 8, 69 | }} 70 | 71 | var flagValOffset = func() uintptr { 72 | field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") 73 | if !ok { 74 | panic("reflect.Value has no flag field") 75 | } 76 | return field.Offset 77 | }() 78 | 79 | // flagField returns a pointer to the flag field of a reflect.Value. 80 | func flagField(v *reflect.Value) *flag { 81 | return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) 82 | } 83 | 84 | // unsafeReflectValue converts the passed reflect.Value into a one that bypasses 85 | // the typical safety restrictions preventing access to unaddressable and 86 | // unexported data. It works by digging the raw pointer to the underlying 87 | // value out of the protected value and generating a new unprotected (unsafe) 88 | // reflect.Value to it. 89 | // 90 | // This allows us to check for implementations of the Stringer and error 91 | // interfaces to be used for pretty printing ordinarily unaddressable and 92 | // inaccessible values such as unexported struct fields. 93 | func unsafeReflectValue(v reflect.Value) reflect.Value { 94 | if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { 95 | return v 96 | } 97 | flagFieldPtr := flagField(&v) 98 | *flagFieldPtr &^= flagRO 99 | *flagFieldPtr |= flagAddr 100 | return v 101 | } 102 | 103 | // Sanity checks against future reflect package changes 104 | // to the type or semantics of the Value.flag field. 105 | func init() { 106 | field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") 107 | if !ok { 108 | panic("reflect.Value has no flag field") 109 | } 110 | if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { 111 | panic("reflect.Value flag field has changed kind") 112 | } 113 | type t0 int 114 | var t struct { 115 | A t0 116 | // t0 will have flagEmbedRO set. 117 | t0 118 | // a will have flagStickyRO set 119 | a t0 120 | } 121 | vA := reflect.ValueOf(t).FieldByName("A") 122 | va := reflect.ValueOf(t).FieldByName("a") 123 | vt0 := reflect.ValueOf(t).FieldByName("t0") 124 | 125 | // Infer flagRO from the difference between the flags 126 | // for the (otherwise identical) fields in t. 127 | flagPublic := *flagField(&vA) 128 | flagWithRO := *flagField(&va) | *flagField(&vt0) 129 | flagRO = flagPublic ^ flagWithRO 130 | 131 | // Infer flagAddr from the difference between a value 132 | // taken from a pointer and not. 133 | vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") 134 | flagNoPtr := *flagField(&vA) 135 | flagPtr := *flagField(&vPtrA) 136 | flagAddr = flagNoPtr ^ flagPtr 137 | 138 | // Check that the inferred flags tally with one of the known versions. 139 | for _, f := range okFlags { 140 | if flagRO == f.ro && flagAddr == f.addr { 141 | return 142 | } 143 | } 144 | panic("reflect.Value read-only flag has changed semantics") 145 | } 146 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | os: 6 | - linux 7 | - osx 8 | 9 | before_install: 10 | - go get github.com/mattn/goveralls 11 | - go get golang.org/x/tools/cmd/cover 12 | script: 13 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine,!ppc64,!ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build ppc64 ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "unsafe" 8 | 9 | syscall "golang.org/x/sys/unix" 10 | ) 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "strings" 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | fileNameInfo uintptr = 2 15 | fileTypePipe = 3 16 | ) 17 | 18 | var ( 19 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") 22 | procGetFileType = kernel32.NewProc("GetFileType") 23 | ) 24 | 25 | func init() { 26 | // Check if GetFileInformationByHandleEx is available. 27 | if procGetFileInformationByHandleEx.Find() != nil { 28 | procGetFileInformationByHandleEx = nil 29 | } 30 | } 31 | 32 | // IsTerminal return true if the file descriptor is terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var st uint32 35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 36 | return r != 0 && e == 0 37 | } 38 | 39 | // Check pipe name is used for cygwin/msys2 pty. 40 | // Cygwin/MSYS2 PTY has a name like: 41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master 42 | func isCygwinPipeName(name string) bool { 43 | token := strings.Split(name, "-") 44 | if len(token) < 5 { 45 | return false 46 | } 47 | 48 | if token[0] != `\msys` && token[0] != `\cygwin` { 49 | return false 50 | } 51 | 52 | if token[1] == "" { 53 | return false 54 | } 55 | 56 | if !strings.HasPrefix(token[2], "pty") { 57 | return false 58 | } 59 | 60 | if token[3] != `from` && token[3] != `to` { 61 | return false 62 | } 63 | 64 | if token[4] != "master" { 65 | return false 66 | } 67 | 68 | return true 69 | } 70 | 71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 72 | // terminal. 73 | func IsCygwinTerminal(fd uintptr) bool { 74 | if procGetFileInformationByHandleEx == nil { 75 | return false 76 | } 77 | 78 | // Cygwin/msys's pty is a pipe. 79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) 80 | if ft != fileTypePipe || e != 0 { 81 | return false 82 | } 83 | 84 | var buf [2 + syscall.MAX_PATH]uint16 85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), 87 | uintptr(len(buf)*2), 0, 0) 88 | if r == 0 || e != 0 { 89 | return false 90 | } 91 | 92 | l := *(*uint32)(unsafe.Pointer(&buf)) 93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/nfnt/resize/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.x" 5 | - "1.1" 6 | - "1.4" 7 | - "1.10" 8 | -------------------------------------------------------------------------------- /vendor/github.com/nfnt/resize/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Jan Schlicht 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose 4 | with or without fee is hereby granted, provided that the above copyright notice 5 | and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 11 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 12 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 13 | THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/nfnt/resize/README.md: -------------------------------------------------------------------------------- 1 | # This package is no longer being updated! Please look for alternatives if that bothers you. 2 | 3 | Resize 4 | ====== 5 | 6 | Image resizing for the [Go programming language](http://golang.org) with common interpolation methods. 7 | 8 | [![Build Status](https://travis-ci.org/nfnt/resize.svg)](https://travis-ci.org/nfnt/resize) 9 | 10 | Installation 11 | ------------ 12 | 13 | ```bash 14 | $ go get github.com/nfnt/resize 15 | ``` 16 | 17 | It's that easy! 18 | 19 | Usage 20 | ----- 21 | 22 | This package needs at least Go 1.1. Import package with 23 | 24 | ```go 25 | import "github.com/nfnt/resize" 26 | ``` 27 | 28 | The resize package provides 2 functions: 29 | 30 | * `resize.Resize` creates a scaled image with new dimensions (`width`, `height`) using the interpolation function `interp`. 31 | If either `width` or `height` is set to 0, it will be set to an aspect ratio preserving value. 32 | * `resize.Thumbnail` downscales an image preserving its aspect ratio to the maximum dimensions (`maxWidth`, `maxHeight`). 33 | It will return the original image if original sizes are smaller than the provided dimensions. 34 | 35 | ```go 36 | resize.Resize(width, height uint, img image.Image, interp resize.InterpolationFunction) image.Image 37 | resize.Thumbnail(maxWidth, maxHeight uint, img image.Image, interp resize.InterpolationFunction) image.Image 38 | ``` 39 | 40 | The provided interpolation functions are (from fast to slow execution time) 41 | 42 | - `NearestNeighbor`: [Nearest-neighbor interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation) 43 | - `Bilinear`: [Bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation) 44 | - `Bicubic`: [Bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) 45 | - `MitchellNetravali`: [Mitchell-Netravali interpolation](http://dl.acm.org/citation.cfm?id=378514) 46 | - `Lanczos2`: [Lanczos resampling](http://en.wikipedia.org/wiki/Lanczos_resampling) with a=2 47 | - `Lanczos3`: [Lanczos resampling](http://en.wikipedia.org/wiki/Lanczos_resampling) with a=3 48 | 49 | Which of these methods gives the best results depends on your use case. 50 | 51 | Sample usage: 52 | 53 | ```go 54 | package main 55 | 56 | import ( 57 | "github.com/nfnt/resize" 58 | "image/jpeg" 59 | "log" 60 | "os" 61 | ) 62 | 63 | func main() { 64 | // open "test.jpg" 65 | file, err := os.Open("test.jpg") 66 | if err != nil { 67 | log.Fatal(err) 68 | } 69 | 70 | // decode jpeg into image.Image 71 | img, err := jpeg.Decode(file) 72 | if err != nil { 73 | log.Fatal(err) 74 | } 75 | file.Close() 76 | 77 | // resize to width 1000 using Lanczos resampling 78 | // and preserve aspect ratio 79 | m := resize.Resize(1000, 0, img, resize.Lanczos3) 80 | 81 | out, err := os.Create("test_resized.jpg") 82 | if err != nil { 83 | log.Fatal(err) 84 | } 85 | defer out.Close() 86 | 87 | // write new image to file 88 | jpeg.Encode(out, m, nil) 89 | } 90 | ``` 91 | 92 | Caveats 93 | ------- 94 | 95 | * Optimized access routines are used for `image.RGBA`, `image.NRGBA`, `image.RGBA64`, `image.NRGBA64`, `image.YCbCr`, `image.Gray`, and `image.Gray16` types. All other image types are accessed in a generic way that will result in slow processing speed. 96 | * JPEG images are stored in `image.YCbCr`. This image format stores data in a way that will decrease processing speed. A resize may be up to 2 times slower than with `image.RGBA`. 97 | 98 | 99 | Downsizing Samples 100 | ------- 101 | 102 | Downsizing is not as simple as it might look like. Images have to be filtered before they are scaled down, otherwise aliasing might occur. 103 | Filtering is highly subjective: Applying too much will blur the whole image, too little will make aliasing become apparent. 104 | Resize tries to provide sane defaults that should suffice in most cases. 105 | 106 | ### Artificial sample 107 | 108 | Original image 109 | ![Rings](http://nfnt.github.com/img/rings_lg_orig.png) 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 |

Nearest-Neighbor

Bilinear

Bicubic

Mitchell-Netravali

Lanczos2

Lanczos3
125 | 126 | ### Real-Life sample 127 | 128 | Original image 129 | ![Original](http://nfnt.github.com/img/IMG_3694_720.jpg) 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 |

Nearest-Neighbor

Bilinear

Bicubic

Mitchell-Netravali

Lanczos2

Lanczos3
145 | 146 | 147 | License 148 | ------- 149 | 150 | Copyright (c) 2012 Jan Schlicht 151 | Resize is released under a MIT style license. 152 | -------------------------------------------------------------------------------- /vendor/github.com/nfnt/resize/filters.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Jan Schlicht 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose 5 | with or without fee is hereby granted, provided that the above copyright notice 6 | and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 10 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 12 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 13 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 14 | THIS SOFTWARE. 15 | */ 16 | 17 | package resize 18 | 19 | import ( 20 | "math" 21 | ) 22 | 23 | func nearest(in float64) float64 { 24 | if in >= -0.5 && in < 0.5 { 25 | return 1 26 | } 27 | return 0 28 | } 29 | 30 | func linear(in float64) float64 { 31 | in = math.Abs(in) 32 | if in <= 1 { 33 | return 1 - in 34 | } 35 | return 0 36 | } 37 | 38 | func cubic(in float64) float64 { 39 | in = math.Abs(in) 40 | if in <= 1 { 41 | return in*in*(1.5*in-2.5) + 1.0 42 | } 43 | if in <= 2 { 44 | return in*(in*(2.5-0.5*in)-4.0) + 2.0 45 | } 46 | return 0 47 | } 48 | 49 | func mitchellnetravali(in float64) float64 { 50 | in = math.Abs(in) 51 | if in <= 1 { 52 | return (7.0*in*in*in - 12.0*in*in + 5.33333333333) * 0.16666666666 53 | } 54 | if in <= 2 { 55 | return (-2.33333333333*in*in*in + 12.0*in*in - 20.0*in + 10.6666666667) * 0.16666666666 56 | } 57 | return 0 58 | } 59 | 60 | func sinc(x float64) float64 { 61 | x = math.Abs(x) * math.Pi 62 | if x >= 1.220703e-4 { 63 | return math.Sin(x) / x 64 | } 65 | return 1 66 | } 67 | 68 | func lanczos2(in float64) float64 { 69 | if in > -2 && in < 2 { 70 | return sinc(in) * sinc(in*0.5) 71 | } 72 | return 0 73 | } 74 | 75 | func lanczos3(in float64) float64 { 76 | if in > -3 && in < 3 { 77 | return sinc(in) * sinc(in*0.3333333333333333) 78 | } 79 | return 0 80 | } 81 | 82 | // range [-256,256] 83 | func createWeights8(dy, filterLength int, blur, scale float64, kernel func(float64) float64) ([]int16, []int, int) { 84 | filterLength = filterLength * int(math.Max(math.Ceil(blur*scale), 1)) 85 | filterFactor := math.Min(1./(blur*scale), 1) 86 | 87 | coeffs := make([]int16, dy*filterLength) 88 | start := make([]int, dy) 89 | for y := 0; y < dy; y++ { 90 | interpX := scale*(float64(y)+0.5) - 0.5 91 | start[y] = int(interpX) - filterLength/2 + 1 92 | interpX -= float64(start[y]) 93 | for i := 0; i < filterLength; i++ { 94 | in := (interpX - float64(i)) * filterFactor 95 | coeffs[y*filterLength+i] = int16(kernel(in) * 256) 96 | } 97 | } 98 | 99 | return coeffs, start, filterLength 100 | } 101 | 102 | // range [-65536,65536] 103 | func createWeights16(dy, filterLength int, blur, scale float64, kernel func(float64) float64) ([]int32, []int, int) { 104 | filterLength = filterLength * int(math.Max(math.Ceil(blur*scale), 1)) 105 | filterFactor := math.Min(1./(blur*scale), 1) 106 | 107 | coeffs := make([]int32, dy*filterLength) 108 | start := make([]int, dy) 109 | for y := 0; y < dy; y++ { 110 | interpX := scale*(float64(y)+0.5) - 0.5 111 | start[y] = int(interpX) - filterLength/2 + 1 112 | interpX -= float64(start[y]) 113 | for i := 0; i < filterLength; i++ { 114 | in := (interpX - float64(i)) * filterFactor 115 | coeffs[y*filterLength+i] = int32(kernel(in) * 65536) 116 | } 117 | } 118 | 119 | return coeffs, start, filterLength 120 | } 121 | 122 | func createWeightsNearest(dy, filterLength int, blur, scale float64) ([]bool, []int, int) { 123 | filterLength = filterLength * int(math.Max(math.Ceil(blur*scale), 1)) 124 | filterFactor := math.Min(1./(blur*scale), 1) 125 | 126 | coeffs := make([]bool, dy*filterLength) 127 | start := make([]int, dy) 128 | for y := 0; y < dy; y++ { 129 | interpX := scale*(float64(y)+0.5) - 0.5 130 | start[y] = int(interpX) - filterLength/2 + 1 131 | interpX -= float64(start[y]) 132 | for i := 0; i < filterLength; i++ { 133 | in := (interpX - float64(i)) * filterFactor 134 | if in >= -0.5 && in < 0.5 { 135 | coeffs[y*filterLength+i] = true 136 | } else { 137 | coeffs[y*filterLength+i] = false 138 | } 139 | } 140 | } 141 | 142 | return coeffs, start, filterLength 143 | } 144 | -------------------------------------------------------------------------------- /vendor/github.com/nfnt/resize/thumbnail.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Jan Schlicht 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose 5 | with or without fee is hereby granted, provided that the above copyright notice 6 | and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 10 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 12 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 13 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 14 | THIS SOFTWARE. 15 | */ 16 | 17 | package resize 18 | 19 | import ( 20 | "image" 21 | ) 22 | 23 | // Thumbnail will downscale provided image to max width and height preserving 24 | // original aspect ratio and using the interpolation function interp. 25 | // It will return original image, without processing it, if original sizes 26 | // are already smaller than provided constraints. 27 | func Thumbnail(maxWidth, maxHeight uint, img image.Image, interp InterpolationFunction) image.Image { 28 | origBounds := img.Bounds() 29 | origWidth := uint(origBounds.Dx()) 30 | origHeight := uint(origBounds.Dy()) 31 | newWidth, newHeight := origWidth, origHeight 32 | 33 | // Return original image if it have same or smaller size as constraints 34 | if maxWidth >= origWidth && maxHeight >= origHeight { 35 | return img 36 | } 37 | 38 | // Preserve aspect ratio 39 | if origWidth > maxWidth { 40 | newHeight = uint(origHeight * maxWidth / origWidth) 41 | if newHeight < 1 { 42 | newHeight = 1 43 | } 44 | newWidth = maxWidth 45 | } 46 | 47 | if newHeight > maxHeight { 48 | newWidth = uint(newWidth * maxHeight / newHeight) 49 | if newWidth < 1 { 50 | newWidth = 1 51 | } 52 | newHeight = maxHeight 53 | } 54 | return Resize(newWidth, newHeight, img, interp) 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/http_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "net/url" 8 | "strings" 9 | ) 10 | 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 and 12 | // an error if building a new request fails. 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { 14 | w := httptest.NewRecorder() 15 | req, err := http.NewRequest(method, url, nil) 16 | if err != nil { 17 | return -1, err 18 | } 19 | req.URL.RawQuery = values.Encode() 20 | handler(w, req) 21 | return w.Code, nil 22 | } 23 | 24 | // HTTPSuccess asserts that a specified handler returns a success status code. 25 | // 26 | // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 27 | // 28 | // Returns whether the assertion was successful (true) or not (false). 29 | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 30 | if h, ok := t.(tHelper); ok { 31 | h.Helper() 32 | } 33 | code, err := httpCode(handler, method, url, values) 34 | if err != nil { 35 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 36 | return false 37 | } 38 | 39 | isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent 40 | if !isSuccessCode { 41 | Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) 42 | } 43 | 44 | return isSuccessCode 45 | } 46 | 47 | // HTTPRedirect asserts that a specified handler returns a redirect status code. 48 | // 49 | // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 50 | // 51 | // Returns whether the assertion was successful (true) or not (false). 52 | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 53 | if h, ok := t.(tHelper); ok { 54 | h.Helper() 55 | } 56 | code, err := httpCode(handler, method, url, values) 57 | if err != nil { 58 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 59 | return false 60 | } 61 | 62 | isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect 63 | if !isRedirectCode { 64 | Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) 65 | } 66 | 67 | return isRedirectCode 68 | } 69 | 70 | // HTTPError asserts that a specified handler returns an error status code. 71 | // 72 | // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 73 | // 74 | // Returns whether the assertion was successful (true) or not (false). 75 | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 76 | if h, ok := t.(tHelper); ok { 77 | h.Helper() 78 | } 79 | code, err := httpCode(handler, method, url, values) 80 | if err != nil { 81 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 82 | return false 83 | } 84 | 85 | isErrorCode := code >= http.StatusBadRequest 86 | if !isErrorCode { 87 | Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) 88 | } 89 | 90 | return isErrorCode 91 | } 92 | 93 | // HTTPBody is a helper that returns HTTP body of the response. It returns 94 | // empty string if building a new request fails. 95 | func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { 96 | w := httptest.NewRecorder() 97 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 98 | if err != nil { 99 | return "" 100 | } 101 | handler(w, req) 102 | return w.Body.String() 103 | } 104 | 105 | // HTTPBodyContains asserts that a specified handler returns a 106 | // body that contains a string. 107 | // 108 | // assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 109 | // 110 | // Returns whether the assertion was successful (true) or not (false). 111 | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { 112 | if h, ok := t.(tHelper); ok { 113 | h.Helper() 114 | } 115 | body := HTTPBody(handler, method, url, values) 116 | 117 | contains := strings.Contains(body, fmt.Sprint(str)) 118 | if !contains { 119 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 120 | } 121 | 122 | return contains 123 | } 124 | 125 | // HTTPBodyNotContains asserts that a specified handler returns a 126 | // body that does not contain a string. 127 | // 128 | // assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 129 | // 130 | // Returns whether the assertion was successful (true) or not (false). 131 | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { 132 | if h, ok := t.(tHelper); ok { 133 | h.Helper() 134 | } 135 | body := HTTPBody(handler, method, url, values) 136 | 137 | contains := strings.Contains(body, fmt.Sprint(str)) 138 | if contains { 139 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 140 | } 141 | 142 | return !contains 143 | } 144 | -------------------------------------------------------------------------------- /vendor/github.com/wayneashleyberry/terminal-dimensions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | before_install: 3 | - go get github.com/mattn/goveralls 4 | script: 5 | - $HOME/gopath/bin/goveralls -service=travis-ci 6 | -------------------------------------------------------------------------------- /vendor/github.com/wayneashleyberry/terminal-dimensions/license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Wayne Ashley Berry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/wayneashleyberry/terminal-dimensions/readme.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/wayneashleyberry/terminal-dimensions?status.svg)](https://godoc.org/github.com/wayneashleyberry/terminal-dimensions) 2 | [![Go Report Card](https://goreportcard.com/badge/github.com/wayneashleyberry/terminal-dimensions)](https://goreportcard.com/report/github.com/wayneashleyberry/terminal-dimensions) 3 | [![Build Status](https://travis-ci.org/wayneashleyberry/terminal-dimensions.svg?branch=master)](https://travis-ci.org/wayneashleyberry/terminal-dimensions) 4 | [![Coverage Status](https://coveralls.io/repos/github/wayneashleyberry/terminal-dimensions/badge.svg?branch=master)](https://coveralls.io/github/wayneashleyberry/terminal-dimensions?branch=master) 5 | 6 | ```sh 7 | go get github.com/wayneashleyberry/terminal-dimensions 8 | ``` 9 | 10 | ```go 11 | package main 12 | 13 | import ( 14 | "fmt" 15 | 16 | terminal "github.com/wayneashleyberry/terminal-dimensions" 17 | ) 18 | 19 | func main() { 20 | x, _ := terminal.Width() 21 | y, _ := terminal.Height() 22 | fmt.Printf("Terminal is %d wide and %d high", x, y) 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /vendor/github.com/wayneashleyberry/terminal-dimensions/terminaldimensions.go: -------------------------------------------------------------------------------- 1 | // Package terminaldimensions provides simple helper functions to get the width 2 | // and height of a users terminal. 3 | package terminaldimensions 4 | 5 | import ( 6 | "os" 7 | "os/exec" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | func size() (string, error) { 13 | cmd := exec.Command("stty", "size") 14 | cmd.Stdin = os.Stdin 15 | out, err := cmd.Output() 16 | return string(out), err 17 | } 18 | 19 | func parse(input string) (uint, uint, error) { 20 | parts := strings.Split(input, " ") 21 | x, err := strconv.Atoi(parts[0]) 22 | if err != nil { 23 | return 0, 0, err 24 | } 25 | y, err := strconv.Atoi(strings.Replace(parts[1], "\n", "", 1)) 26 | if err != nil { 27 | return 0, 0, err 28 | } 29 | return uint(x), uint(y), nil 30 | } 31 | 32 | // Width return the width of the terminal. 33 | func Width() (uint, error) { 34 | output, err := size() 35 | if err != nil { 36 | return 0, err 37 | } 38 | _, width, err := parse(output) 39 | return width, err 40 | } 41 | 42 | // Height returns the height of the terminal. 43 | func Height() (uint, error) { 44 | output, err := size() 45 | if err != nil { 46 | return 0, err 47 | } 48 | height, _, err := parse(output) 49 | return height, err 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 14 | 15 | // CPUSet represents a CPU affinity mask. 16 | type CPUSet [cpuSetSize]cpuMask 17 | 18 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 19 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 20 | if e != 0 { 21 | return errnoErr(e) 22 | } 23 | return nil 24 | } 25 | 26 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 27 | // If pid is 0 the calling thread is used. 28 | func SchedGetaffinity(pid int, set *CPUSet) error { 29 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 30 | } 31 | 32 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 33 | // If pid is 0 the calling thread is used. 34 | func SchedSetaffinity(pid int, set *CPUSet) error { 35 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 36 | } 37 | 38 | // Zero clears the set s, so that it contains no CPUs. 39 | func (s *CPUSet) Zero() { 40 | for i := range s { 41 | s[i] = 0 42 | } 43 | } 44 | 45 | func cpuBitsIndex(cpu int) int { 46 | return cpu / _NCPUBITS 47 | } 48 | 49 | func cpuBitsMask(cpu int) cpuMask { 50 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 51 | } 52 | 53 | // Set adds cpu to the set s. 54 | func (s *CPUSet) Set(cpu int) { 55 | i := cpuBitsIndex(cpu) 56 | if i < len(s) { 57 | s[i] |= cpuBitsMask(cpu) 58 | } 59 | } 60 | 61 | // Clear removes cpu from the set s. 62 | func (s *CPUSet) Clear(cpu int) { 63 | i := cpuBitsIndex(cpu) 64 | if i < len(s) { 65 | s[i] &^= cpuBitsMask(cpu) 66 | } 67 | } 68 | 69 | // IsSet reports whether cpu is in the set s. 70 | func (s *CPUSet) IsSet(cpu int) bool { 71 | i := cpuBitsIndex(cpu) 72 | if i < len(s) { 73 | return s[i]&cpuBitsMask(cpu) != 0 74 | } 75 | return false 76 | } 77 | 78 | // Count returns the number of CPUs in the set s. 79 | func (s *CPUSet) Count() int { 80 | c := 0 81 | for _, b := range s { 82 | c += onesCount64(uint64(b)) 83 | } 84 | return c 85 | } 86 | 87 | // onesCount64 is a copy of Go 1.9's math/bits.OnesCount64. 88 | // Once this package can require Go 1.9, we can delete this 89 | // and update the caller to use bits.OnesCount64. 90 | func onesCount64(x uint64) int { 91 | const m0 = 0x5555555555555555 // 01010101 ... 92 | const m1 = 0x3333333333333333 // 00110011 ... 93 | const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... 94 | const m3 = 0x00ff00ff00ff00ff // etc. 95 | const m4 = 0x0000ffff0000ffff 96 | 97 | // Implementation: Parallel summing of adjacent bits. 98 | // See "Hacker's Delight", Chap. 5: Counting Bits. 99 | // The following pattern shows the general approach: 100 | // 101 | // x = x>>1&(m0&m) + x&(m0&m) 102 | // x = x>>2&(m1&m) + x&(m1&m) 103 | // x = x>>4&(m2&m) + x&(m2&m) 104 | // x = x>>8&(m3&m) + x&(m3&m) 105 | // x = x>>16&(m4&m) + x&(m4&m) 106 | // x = x>>32&(m5&m) + x&(m5&m) 107 | // return int(x) 108 | // 109 | // Masking (& operations) can be left away when there's no 110 | // danger that a field's sum will carry over into the next 111 | // field: Since the result cannot be > 64, 8 bits is enough 112 | // and we can ignore the masks for the shifts by 8 and up. 113 | // Per "Hacker's Delight", the first line can be simplified 114 | // more, but it saves at best one instruction, so we leave 115 | // it alone for clarity. 116 | const m = 1<<64 - 1 117 | x = x>>1&(m0&m) + x&(m0&m) 118 | x = x>>2&(m1&m) + x&(m1&m) 119 | x = (x>>4 + x) & (m2 & m) 120 | x += x >> 8 121 | x += x >> 16 122 | x += x >> 32 123 | return int(x) & (1<<7 - 1) 124 | } 125 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | //extern gccgoRealSyscallNoError 16 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 17 | 18 | //extern gccgoRealSyscall 19 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 20 | 21 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 22 | syscall.Entersyscall() 23 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 24 | syscall.Exitsyscall() 25 | return r, 0 26 | } 27 | 28 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 29 | syscall.Entersyscall() 30 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 31 | syscall.Exitsyscall() 32 | return r, 0, syscall.Errno(errno) 33 | } 34 | 35 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 36 | syscall.Entersyscall() 37 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 38 | syscall.Exitsyscall() 39 | return r, 0, syscall.Errno(errno) 40 | } 41 | 42 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 43 | syscall.Entersyscall() 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 45 | syscall.Exitsyscall() 46 | return r, 0, syscall.Errno(errno) 47 | } 48 | 49 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 50 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 51 | return r, 0 52 | } 53 | 54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 55 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 56 | return r, 0, syscall.Errno(errno) 57 | } 58 | 59 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 60 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 61 | return r, 0, syscall.Errno(errno) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 25 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs; see README.md. 12 | package main 13 | 14 | import ( 15 | "bytes" 16 | "fmt" 17 | "go/format" 18 | "io/ioutil" 19 | "log" 20 | "os" 21 | "regexp" 22 | ) 23 | 24 | func main() { 25 | // Get the OS and architecture (using GOARCH_TARGET if it exists) 26 | goos := os.Getenv("GOOS") 27 | goarch := os.Getenv("GOARCH_TARGET") 28 | if goarch == "" { 29 | goarch = os.Getenv("GOARCH") 30 | } 31 | // Check that we are using the new build system if we should be. 32 | if goos == "linux" && goarch != "sparc64" { 33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" { 34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") 35 | os.Stderr.WriteString("See README.md\n") 36 | os.Exit(1) 37 | } 38 | } 39 | 40 | b, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | // Intentionally export __val fields in Fsid and Sigset_t 46 | valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`) 47 | b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}")) 48 | 49 | // If we have empty Ptrace structs, we should delete them. Only s390x emits 50 | // nonempty Ptrace structs. 51 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) 52 | b = ptraceRexexp.ReplaceAll(b, nil) 53 | 54 | // Replace the control_regs union with a blank identifier for now. 55 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) 56 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) 57 | 58 | // Remove fields that are added by glibc 59 | // Note that this is unstable as the identifers are private. 60 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) 61 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 62 | 63 | // Convert [65]int8 to [65]byte in Utsname members to simplify 64 | // conversion to string; see golang.org/issue/20753 65 | convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) 66 | b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) 67 | 68 | // Remove spare fields (e.g. in Statx_t) 69 | spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) 70 | b = spareFieldsRegex.ReplaceAll(b, []byte("_")) 71 | 72 | // Remove cgo padding fields 73 | removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) 74 | b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) 75 | 76 | // Remove padding, hidden, or unused fields 77 | removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`) 78 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 79 | 80 | // Remove the first line of warning from cgo 81 | b = b[bytes.IndexByte(b, '\n')+1:] 82 | // Modify the command in the header to include: 83 | // mkpost, our own warning, and a build tag. 84 | replacement := fmt.Sprintf(`$1 | go run mkpost.go 85 | // Code generated by the command above; see README.md. DO NOT EDIT. 86 | 87 | // +build %s,%s`, goarch, goos) 88 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) 89 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) 90 | 91 | // gofmt 92 | b, err = format.Source(b) 93 | if err != nil { 94 | log.Fatal(err) 95 | } 96 | 97 | os.Stdout.Write(b) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < 6.2, pass execpromises to the syscall. 58 | if maj > 6 || (maj == 6 && min > 2) { 59 | exptr, err := syscall.BytePtrFromString(execpromises) 60 | if err != nil { 61 | return err 62 | } 63 | expr = unsafe.Pointer(exptr) 64 | } 65 | 66 | _, _, e := syscall.Syscall(_SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) 67 | if e != 0 { 68 | return e 69 | } 70 | 71 | return nil 72 | } 73 | 74 | // majmin returns major and minor version number for an OpenBSD system. 75 | func majmin() (major int, minor int, err error) { 76 | var v Utsname 77 | err = Uname(&v) 78 | if err != nil { 79 | return 80 | } 81 | 82 | major, err = strconv.Atoi(string(v.Release[0])) 83 | if err != nil { 84 | err = errors.New("cannot parse major version number returned by uname") 85 | return 86 | } 87 | 88 | minor, err = strconv.Atoi(string(v.Release[2])) 89 | if err != nil { 90 | err = errors.New("cannot parse minor version number returned by uname") 91 | return 92 | } 93 | 94 | return 95 | } 96 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := SizeofPtr 16 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and 17 | // Solaris kernels still require 32-bit aligned access to 18 | // network subsystem. 19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { 20 | salign = 4 21 | } 22 | return (salen + salign - 1) & ^(salign - 1) 23 | } 24 | 25 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 26 | // structure, taking into account any necessary alignment. 27 | func CmsgLen(datalen int) int { 28 | return cmsgAlignOf(SizeofCmsghdr) + datalen 29 | } 30 | 31 | // CmsgSpace returns the number of bytes an ancillary element with 32 | // payload of the passed data length occupies. 33 | func CmsgSpace(datalen int) int { 34 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 35 | } 36 | 37 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 38 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 39 | } 40 | 41 | // SocketControlMessage represents a socket control message. 42 | type SocketControlMessage struct { 43 | Header Cmsghdr 44 | Data []byte 45 | } 46 | 47 | // ParseSocketControlMessage parses b as an array of socket control 48 | // messages. 49 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 50 | var msgs []SocketControlMessage 51 | i := 0 52 | for i+CmsgLen(0) <= len(b) { 53 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | m := SocketControlMessage{Header: *h, Data: dbuf} 58 | msgs = append(msgs, m) 59 | i += cmsgAlignOf(int(h.Len)) 60 | } 61 | return msgs, nil 62 | } 63 | 64 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 65 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 66 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 67 | return nil, nil, EINVAL 68 | } 69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 70 | } 71 | 72 | // UnixRights encodes a set of open file descriptors into a socket 73 | // control message for sending to another process. 74 | func UnixRights(fds ...int) []byte { 75 | datalen := len(fds) * 4 76 | b := make([]byte, CmsgSpace(datalen)) 77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 78 | h.Level = SOL_SOCKET 79 | h.Type = SCM_RIGHTS 80 | h.SetLen(CmsgLen(datalen)) 81 | data := cmsgData(h) 82 | for _, fd := range fds { 83 | *(*int32)(data) = int32(fd) 84 | data = unsafe.Pointer(uintptr(data) + 4) 85 | } 86 | return b 87 | } 88 | 89 | // ParseUnixRights decodes a socket control message that contains an 90 | // integer array of open file descriptors from another process. 91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 92 | if m.Header.Level != SOL_SOCKET { 93 | return nil, EINVAL 94 | } 95 | if m.Header.Type != SCM_RIGHTS { 96 | return nil, EINVAL 97 | } 98 | fds := make([]int, len(m.Data)>>2) 99 | for i, j := 0, 0; i < len(m.Data); i += 4 { 100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 | j++ 102 | } 103 | return fds, nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package unix // import "golang.org/x/sys/unix" 26 | 27 | import "strings" 28 | 29 | // ByteSliceFromString returns a NUL-terminated slice of bytes 30 | // containing the text of s. If s contains a NUL byte at any 31 | // location, it returns (nil, EINVAL). 32 | func ByteSliceFromString(s string) ([]byte, error) { 33 | if strings.IndexByte(s, 0) != -1 { 34 | return nil, EINVAL 35 | } 36 | a := make([]byte, len(s)+1) 37 | copy(a, s) 38 | return a, nil 39 | } 40 | 41 | // BytePtrFromString returns a pointer to a NUL-terminated array of 42 | // bytes containing the text of s. If s contains a NUL byte at any 43 | // location, it returns (nil, EINVAL). 44 | func BytePtrFromString(s string) (*byte, error) { 45 | a, err := ByteSliceFromString(s) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &a[0], nil 50 | } 51 | 52 | // Single-word zero for use when we need a valid pointer to 0 bytes. 53 | // See mkunix.pl. 54 | var _zero uintptr 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build sparc64,linux 6 | 7 | package unix 8 | 9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 10 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Lchown(path string, uid int, gid int) (err error) 24 | //sys Listen(s int, n int) (err error) 25 | //sys Lstat(path string, stat *Stat_t) (err error) 26 | //sys Pause() (err error) 27 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 28 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 29 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 30 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 31 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 32 | //sys Setfsgid(gid int) (err error) 33 | //sys Setfsuid(uid int) (err error) 34 | //sysnb Setregid(rgid int, egid int) (err error) 35 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 36 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 37 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 38 | //sysnb Setreuid(ruid int, euid int) (err error) 39 | //sys Shutdown(fd int, how int) (err error) 40 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 41 | //sys Stat(path string, stat *Stat_t) (err error) 42 | //sys Statfs(path string, buf *Statfs_t) (err error) 43 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 44 | //sys Truncate(path string, length int64) (err error) 45 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 46 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 47 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 48 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 50 | //sysnb setgroups(n int, list *_Gid_t) (err error) 51 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 52 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 53 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 54 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 55 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 56 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 58 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 59 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 60 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 62 | 63 | func Ioperm(from int, num int, on int) (err error) { 64 | return ENOSYS 65 | } 66 | 67 | func Iopl(level int) (err error) { 68 | return ENOSYS 69 | } 70 | 71 | //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 72 | //sysnb Gettimeofday(tv *Timeval) (err error) 73 | 74 | func Time(t *Time_t) (tt Time_t, err error) { 75 | var tv Timeval 76 | err = Gettimeofday(&tv) 77 | if err != nil { 78 | return 0, err 79 | } 80 | if t != nil { 81 | *t = Time_t(tv.Sec) 82 | } 83 | return Time_t(tv.Sec), nil 84 | } 85 | 86 | //sys Utime(path string, buf *Utimbuf) (err error) 87 | //sys utimes(path string, times *[2]Timeval) (err error) 88 | 89 | func setTimespec(sec, nsec int64) Timespec { 90 | return Timespec{Sec: sec, Nsec: nsec} 91 | } 92 | 93 | func setTimeval(sec, usec int64) Timeval { 94 | return Timeval{Sec: sec, Usec: int32(usec)} 95 | } 96 | 97 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 98 | 99 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 100 | 101 | func (iov *Iovec) SetLen(length int) { 102 | iov.Len = uint64(length) 103 | } 104 | 105 | func (msghdr *Msghdr) SetControllen(length int) { 106 | msghdr.Controllen = uint64(length) 107 | } 108 | 109 | func (cmsg *Cmsghdr) SetLen(length int) { 110 | cmsg.Len = uint64(length) 111 | } 112 | 113 | //sysnb pipe(p *[2]_C_int) (err error) 114 | 115 | func Pipe(p []int) (err error) { 116 | if len(p) != 2 { 117 | return EINVAL 118 | } 119 | var pp [2]_C_int 120 | err = pipe(&pp) 121 | p[0] = int(pp[0]) 122 | p[1] = int(pp[1]) 123 | return 124 | } 125 | 126 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 127 | 128 | func Pipe2(p []int, flags int) (err error) { 129 | if len(p) != 2 { 130 | return EINVAL 131 | } 132 | var pp [2]_C_int 133 | err = pipe2(&pp, flags) 134 | p[0] = int(pp[0]) 135 | p[1] = int(pp[1]) 136 | return 137 | } 138 | 139 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 140 | 141 | func Poll(fds []PollFd, timeout int) (n int, err error) { 142 | if len(fds) == 0 { 143 | return poll(nil, 0, timeout) 144 | } 145 | return poll(&fds[0], len(fds), timeout) 146 | } 147 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_aix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | // +build aix 7 | 8 | /* 9 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 10 | */ 11 | 12 | // +godefs map struct_in_addr [4]byte /* in_addr */ 13 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 14 | 15 | package unix 16 | 17 | /* 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | #include 40 | #include 41 | 42 | enum { 43 | sizeofPtr = sizeof(void*), 44 | }; 45 | 46 | union sockaddr_all { 47 | struct sockaddr s1; // this one gets used for fields 48 | struct sockaddr_in s2; // these pad it out 49 | struct sockaddr_in6 s3; 50 | struct sockaddr_un s4; 51 | struct sockaddr_dl s5; 52 | }; 53 | 54 | struct sockaddr_any { 55 | struct sockaddr addr; 56 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 57 | }; 58 | 59 | */ 60 | import "C" 61 | 62 | // Machine characteristics 63 | 64 | const ( 65 | SizeofPtr = C.sizeofPtr 66 | SizeofShort = C.sizeof_short 67 | SizeofInt = C.sizeof_int 68 | SizeofLong = C.sizeof_long 69 | SizeofLongLong = C.sizeof_longlong 70 | PathMax = C.PATH_MAX 71 | ) 72 | 73 | // Basic types 74 | 75 | type ( 76 | _C_short C.short 77 | _C_int C.int 78 | _C_long C.long 79 | _C_long_long C.longlong 80 | ) 81 | 82 | type off64 C.off64_t 83 | type off C.off_t 84 | type Mode_t C.mode_t 85 | 86 | // Time 87 | 88 | type Timespec C.struct_timespec 89 | 90 | type StTimespec C.struct_st_timespec 91 | 92 | type Timeval C.struct_timeval 93 | 94 | type Timeval32 C.struct_timeval32 95 | 96 | type Timex C.struct_timex 97 | 98 | type Time_t C.time_t 99 | 100 | type Tms C.struct_tms 101 | 102 | type Utimbuf C.struct_utimbuf 103 | 104 | type Timezone C.struct_timezone 105 | 106 | // Processes 107 | 108 | type Rusage C.struct_rusage 109 | 110 | type Rlimit C.struct_rlimit64 111 | 112 | type Pid_t C.pid_t 113 | 114 | type _Gid_t C.gid_t 115 | 116 | type dev_t C.dev_t 117 | 118 | // Files 119 | 120 | type Stat_t C.struct_stat 121 | 122 | type StatxTimestamp C.struct_statx_timestamp 123 | 124 | type Statx_t C.struct_statx 125 | 126 | type Dirent C.struct_dirent 127 | 128 | // Sockets 129 | 130 | type RawSockaddrInet4 C.struct_sockaddr_in 131 | 132 | type RawSockaddrInet6 C.struct_sockaddr_in6 133 | 134 | type RawSockaddrUnix C.struct_sockaddr_un 135 | 136 | type RawSockaddr C.struct_sockaddr 137 | 138 | type RawSockaddrAny C.struct_sockaddr_any 139 | 140 | type _Socklen C.socklen_t 141 | 142 | type Cmsghdr C.struct_cmsghdr 143 | 144 | type ICMPv6Filter C.struct_icmp6_filter 145 | 146 | type Iovec C.struct_iovec 147 | 148 | type IPMreq C.struct_ip_mreq 149 | 150 | type IPv6Mreq C.struct_ipv6_mreq 151 | 152 | type IPv6MTUInfo C.struct_ip6_mtuinfo 153 | 154 | type Linger C.struct_linger 155 | 156 | type Msghdr C.struct_msghdr 157 | 158 | const ( 159 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 160 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 161 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 162 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 163 | SizeofLinger = C.sizeof_struct_linger 164 | SizeofIPMreq = C.sizeof_struct_ip_mreq 165 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 166 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 167 | SizeofMsghdr = C.sizeof_struct_msghdr 168 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 169 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 170 | ) 171 | 172 | // Routing and interface messages 173 | 174 | const ( 175 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 176 | ) 177 | 178 | type IfMsgHdr C.struct_if_msghdr 179 | 180 | // Misc 181 | 182 | type FdSet C.fd_set 183 | 184 | type Utsname C.struct_utsname 185 | 186 | type Ustat_t C.struct_ustat 187 | 188 | type Sigset_t C.sigset_t 189 | 190 | const ( 191 | AT_FDCWD = C.AT_FDCWD 192 | AT_REMOVEDIR = C.AT_REMOVEDIR 193 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 194 | ) 195 | 196 | // Terminal handling 197 | 198 | type Termios C.struct_termios 199 | 200 | type Termio C.struct_termio 201 | 202 | type Winsize C.struct_winsize 203 | 204 | //poll 205 | 206 | type PollFd struct { 207 | Fd int32 208 | Events uint16 209 | Revents uint16 210 | } 211 | 212 | const ( 213 | POLLERR = C.POLLERR 214 | POLLHUP = C.POLLHUP 215 | POLLIN = C.POLLIN 216 | POLLNVAL = C.POLLNVAL 217 | POLLOUT = C.POLLOUT 218 | POLLPRI = C.POLLPRI 219 | POLLRDBAND = C.POLLRDBAND 220 | POLLRDNORM = C.POLLRDNORM 221 | POLLWRBAND = C.POLLWRBAND 222 | POLLWRNORM = C.POLLWRNORM 223 | ) 224 | 225 | //flock_t 226 | 227 | type Flock_t C.struct_flock64 228 | 229 | // Statfs 230 | 231 | type Fsid_t C.struct_fsid_t 232 | type Fsid64_t C.struct_fsid64_t 233 | 234 | type Statfs_t C.struct_statfs 235 | 236 | const RNDGETENTCNT = 0x80045200 237 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | --------------------------------------------------------------------------------