├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── VERSION ├── _vendor ├── github.com │ ├── codegangsta │ │ └── cli │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── app.go │ │ │ ├── app_test.go │ │ │ ├── autocomplete │ │ │ ├── bash_autocomplete │ │ │ └── zsh_autocomplete │ │ │ ├── cli.go │ │ │ ├── cli_test.go │ │ │ ├── command.go │ │ │ ├── command_test.go │ │ │ ├── context.go │ │ │ ├── context_test.go │ │ │ ├── flag.go │ │ │ ├── flag_test.go │ │ │ ├── help.go │ │ │ ├── help_test.go │ │ │ └── helpers_test.go │ ├── go-fsnotify │ │ └── fsevents │ │ │ ├── AUTHORS │ │ │ ├── INTERNALS.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── example │ │ │ └── main.go │ │ │ ├── fsevents.go │ │ │ └── fsevents_test.go │ ├── hashicorp │ │ └── errwrap │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── errwrap.go │ │ │ └── errwrap_test.go │ ├── imdario │ │ └── mergo │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── map.go │ │ │ ├── merge.go │ │ │ ├── mergo.go │ │ │ ├── mergo_test.go │ │ │ └── testdata │ │ │ ├── license.yml │ │ │ └── thing.yml │ ├── kardianos │ │ ├── osext │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── osext.go │ │ │ ├── osext_plan9.go │ │ │ ├── osext_procfs.go │ │ │ ├── osext_sysctl.go │ │ │ ├── osext_test.go │ │ │ └── osext_windows.go │ │ └── service │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── console.go │ │ │ ├── example │ │ │ ├── logging │ │ │ │ └── main.go │ │ │ ├── runner │ │ │ │ ├── runner.go │ │ │ │ └── runner.json │ │ │ ├── simple │ │ │ │ └── main.go │ │ │ └── stopPause │ │ │ │ └── main.go │ │ │ ├── linux_test │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── systemd │ │ │ │ └── Dockerfile │ │ │ ├── sysv │ │ │ │ └── Dockerfile │ │ │ └── upstart │ │ │ │ └── Dockerfile │ │ │ ├── name_test.go │ │ │ ├── service.go │ │ │ ├── service_darwin.go │ │ │ ├── service_linux.go │ │ │ ├── service_systemd_linux.go │ │ │ ├── service_sysv_linux.go │ │ │ ├── service_test.go │ │ │ ├── service_unix.go │ │ │ ├── service_upstart_linux.go │ │ │ └── service_windows.go │ └── mattn │ │ └── go-isatty │ │ ├── README.md │ │ ├── doc.go │ │ ├── isatty_bsd.go │ │ ├── isatty_linux.go │ │ └── isatty_windows.go └── golang.org │ └── x │ └── sys │ ├── .gitattributes │ ├── .gitignore │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── README │ ├── codereview.cfg │ ├── plan9 │ ├── asm.s │ ├── asm_plan9_386.s │ ├── asm_plan9_amd64.s │ ├── const_plan9.go │ ├── dir_plan9.go │ ├── env_plan9.go │ ├── env_unset.go │ ├── errors_plan9.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mksyscall.pl │ ├── mksysnum_plan9.sh │ ├── pwd_go15_plan9.go │ ├── pwd_plan9.go │ ├── race.go │ ├── race0.go │ ├── str.go │ ├── syscall.go │ ├── syscall_plan9.go │ ├── syscall_test.go │ ├── zsyscall_plan9_386.go │ ├── zsyscall_plan9_amd64.go │ └── zsysnum_plan9.go │ ├── unix │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_386.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_ppc64x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── constants.go │ ├── creds_test.go │ ├── env_unix.go │ ├── env_unset.go │ ├── export_test.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── mmap_unix_test.go │ ├── race.go │ ├── race0.go │ ├── so_solaris.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_bsd_test.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_386.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_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_test.go │ ├── syscall_unix.go │ ├── syscall_unix_test.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_386.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_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_386.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_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_386.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_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_386.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_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go │ └── windows │ ├── asm.s │ ├── asm_windows_386.s │ ├── asm_windows_amd64.s │ ├── dll_windows.go │ ├── env_unset.go │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── race.go │ ├── race0.go │ ├── registry │ ├── export_test.go │ ├── key.go │ ├── registry_test.go │ ├── syscall.go │ ├── value.go │ └── zsyscall_windows.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── svc │ ├── debug │ │ ├── log.go │ │ └── service.go │ ├── event.go │ ├── eventlog │ │ ├── install.go │ │ ├── log.go │ │ └── log_test.go │ ├── example │ │ ├── beep.go │ │ ├── install.go │ │ ├── main.go │ │ ├── manage.go │ │ └── service.go │ ├── go12.c │ ├── go12.go │ ├── go13.go │ ├── mgr │ │ ├── config.go │ │ ├── mgr.go │ │ ├── mgr_test.go │ │ └── service.go │ ├── security.go │ ├── service.go │ ├── svc_test.go │ ├── sys_386.s │ └── sys_amd64.s │ ├── syscall.go │ ├── syscall_test.go │ ├── syscall_windows.go │ ├── syscall_windows_test.go │ ├── zsyscall_windows.go │ ├── ztypes_windows.go │ ├── ztypes_windows_386.go │ └── ztypes_windows_amd64.go ├── command ├── client.go ├── init.go ├── install.go ├── pause.go ├── pull.go ├── punch.go ├── push.go ├── reset.go ├── start.go ├── status.go ├── stop.go ├── sum.go ├── types.go └── uninstall.go ├── config └── config.go ├── docs ├── config.md ├── manual_installation.md ├── query.md ├── screenshot.png ├── sharing.md └── uninstall.md ├── glass-daemon ├── errors.go ├── keeper.go ├── keeper_test.go ├── logger.go ├── main.go ├── paths.go ├── server.go ├── server_test.go ├── timer.go ├── timer_test.go └── util_test.go ├── installers ├── msi │ ├── .gitignore │ ├── Product.wxs │ ├── glass.wixproject │ └── make.bash └── pkg │ ├── .gitignore │ ├── distribution.xml │ ├── make.bash │ └── scripts │ ├── glass-daemon │ └── postinstall │ └── glass │ └── postinstall ├── main.go ├── main_test.go ├── make.bash ├── timeglass.json └── vcs ├── git.go └── vcs.go /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{go}] 4 | indent_style = tabs 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{Makefile}] 12 | indent_style = tabs 13 | indent_size = 2 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | *.db 6 | 7 | # Folders 8 | _obj 9 | _test 10 | bin 11 | 12 | # Architecture specific extensions/prefixes 13 | *.[568vq] 14 | [568vq].out 15 | 16 | *.cgo1.go 17 | *.cgo2.c 18 | _cgo_defun.c 19 | _cgo_gotypes.go 20 | _cgo_export.* 21 | 22 | _testmain.go 23 | 24 | *.exe 25 | *.test 26 | *.prof 27 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.6.0 2 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.1 3 | 4 | script: 5 | - go vet ./... 6 | - go test -v ./... 7 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Jeremy Saenz 2 | All Rights Reserved. 3 | 4 | MIT LICENSE 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, 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 in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | _cli_bash_autocomplete() { 4 | local cur prev opts base 5 | COMPREPLY=() 6 | cur="${COMP_WORDS[COMP_CWORD]}" 7 | prev="${COMP_WORDS[COMP_CWORD-1]}" 8 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) 9 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 10 | return 0 11 | } 12 | 13 | complete -F _cli_bash_autocomplete $PROG -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete: -------------------------------------------------------------------------------- 1 | autoload -U compinit && compinit 2 | autoload -U bashcompinit && bashcompinit 3 | 4 | script_dir=$(dirname $0) 5 | source ${script_dir}/bash_autocomplete 6 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/cli_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 7 | ) 8 | 9 | func Example() { 10 | app := cli.NewApp() 11 | app.Name = "todo" 12 | app.Usage = "task list on the command line" 13 | app.Commands = []cli.Command{ 14 | { 15 | Name: "add", 16 | Aliases: []string{"a"}, 17 | Usage: "add a task to the list", 18 | Action: func(c *cli.Context) { 19 | println("added task: ", c.Args().First()) 20 | }, 21 | }, 22 | { 23 | Name: "complete", 24 | Aliases: []string{"c"}, 25 | Usage: "complete a task on the list", 26 | Action: func(c *cli.Context) { 27 | println("completed task: ", c.Args().First()) 28 | }, 29 | }, 30 | } 31 | 32 | app.Run(os.Args) 33 | } 34 | 35 | func ExampleSubcommand() { 36 | app := cli.NewApp() 37 | app.Name = "say" 38 | app.Commands = []cli.Command{ 39 | { 40 | Name: "hello", 41 | Aliases: []string{"hi"}, 42 | Usage: "use it to see a description", 43 | Description: "This is how we describe hello the function", 44 | Subcommands: []cli.Command{ 45 | { 46 | Name: "english", 47 | Aliases: []string{"en"}, 48 | Usage: "sends a greeting in english", 49 | Description: "greets someone in english", 50 | Flags: []cli.Flag{ 51 | cli.StringFlag{ 52 | Name: "name", 53 | Value: "Bob", 54 | Usage: "Name of the person to greet", 55 | }, 56 | }, 57 | Action: func(c *cli.Context) { 58 | println("Hello, ", c.String("name")) 59 | }, 60 | }, { 61 | Name: "spanish", 62 | Aliases: []string{"sp"}, 63 | Usage: "sends a greeting in spanish", 64 | Flags: []cli.Flag{ 65 | cli.StringFlag{ 66 | Name: "surname", 67 | Value: "Jones", 68 | Usage: "Surname of the person to greet", 69 | }, 70 | }, 71 | Action: func(c *cli.Context) { 72 | println("Hola, ", c.String("surname")) 73 | }, 74 | }, { 75 | Name: "french", 76 | Aliases: []string{"fr"}, 77 | Usage: "sends a greeting in french", 78 | Flags: []cli.Flag{ 79 | cli.StringFlag{ 80 | Name: "nickname", 81 | Value: "Stevie", 82 | Usage: "Nickname of the person to greet", 83 | }, 84 | }, 85 | Action: func(c *cli.Context) { 86 | println("Bonjour, ", c.String("nickname")) 87 | }, 88 | }, 89 | }, 90 | }, { 91 | Name: "bye", 92 | Usage: "says goodbye", 93 | Action: func(c *cli.Context) { 94 | println("bye") 95 | }, 96 | }, 97 | } 98 | 99 | app.Run(os.Args) 100 | } 101 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/command_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | ) 9 | 10 | func TestCommandDoNotIgnoreFlags(t *testing.T) { 11 | app := cli.NewApp() 12 | set := flag.NewFlagSet("test", 0) 13 | test := []string{"blah", "blah", "-break"} 14 | set.Parse(test) 15 | 16 | c := cli.NewContext(app, set, set) 17 | 18 | command := cli.Command{ 19 | Name: "test-cmd", 20 | Aliases: []string{"tc"}, 21 | Usage: "this is for testing", 22 | Description: "testing", 23 | Action: func(_ *cli.Context) {}, 24 | } 25 | err := command.Run(c) 26 | 27 | expect(t, err.Error(), "flag provided but not defined: -break") 28 | } 29 | 30 | func TestCommandIgnoreFlags(t *testing.T) { 31 | app := cli.NewApp() 32 | set := flag.NewFlagSet("test", 0) 33 | test := []string{"blah", "blah"} 34 | set.Parse(test) 35 | 36 | c := cli.NewContext(app, set, set) 37 | 38 | command := cli.Command{ 39 | Name: "test-cmd", 40 | Aliases: []string{"tc"}, 41 | Usage: "this is for testing", 42 | Description: "testing", 43 | Action: func(_ *cli.Context) {}, 44 | SkipFlagParsing: true, 45 | } 46 | err := command.Run(c) 47 | 48 | expect(t, err, nil) 49 | } 50 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/help_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | ) 9 | 10 | func Test_ShowAppHelp_NoAuthor(t *testing.T) { 11 | output := new(bytes.Buffer) 12 | app := cli.NewApp() 13 | app.Writer = output 14 | 15 | c := cli.NewContext(app, nil, nil) 16 | 17 | cli.ShowAppHelp(c) 18 | 19 | if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { 20 | t.Errorf("expected\n%snot to include %s", output.String(), "AUTHOR(S):") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /_vendor/github.com/codegangsta/cli/helpers_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | /* Test Helpers */ 9 | func expect(t *testing.T, a interface{}, b interface{}) { 10 | if a != b { 11 | t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 12 | } 13 | } 14 | 15 | func refute(t *testing.T, a interface{}, b interface{}) { 16 | if a == b { 17 | t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /_vendor/github.com/go-fsnotify/fsevents/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file as 2 | # Name or Organization 3 | # The email address is not required for organizations. 4 | 5 | # You can update this list using the following command: 6 | # 7 | # $ git shortlog -se | awk '{print $2 " " $3 " " $4}' 8 | 9 | # Please keep the list sorted. 10 | 11 | Nathan Youngman 12 | Sam Jacobson 13 | -------------------------------------------------------------------------------- /_vendor/github.com/go-fsnotify/fsevents/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The fsevents 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/github.com/go-fsnotify/fsevents/README.md: -------------------------------------------------------------------------------- 1 | # FSEvents bindings for Go (OS X) 2 | 3 | [![GoDoc](https://godoc.org/github.com/go-fsnotify/fsevents?status.svg)](https://godoc.org/github.com/go-fsnotify/fsevents) 4 | 5 | [FSEvents](https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/) allows an application to monitor a whole file system or portion of it. FSEvents is only available on OS X. 6 | 7 | **Warning:** This API should be considered unstable. 8 | 9 | ## Contributing 10 | 11 | Request features and report bugs using the [GitHub Issue Tracker](https://github.com/go-fsnotify/fsevents/issues). 12 | 13 | fsevents carries the same [LICENSE](https://github.com/go-fsnotify/fsevents/blob/master/LICENSE) as Go. Contributors retain their copyright, so you need to fill out a short form before we can accept your contribution: [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual). 14 | -------------------------------------------------------------------------------- /_vendor/github.com/go-fsnotify/fsevents/example/main.go: -------------------------------------------------------------------------------- 1 | // +build darwin 2 | 3 | package main 4 | 5 | import ( 6 | "bufio" 7 | "log" 8 | "os" 9 | "runtime" 10 | "time" 11 | 12 | "github.com/timeglass/glass/_vendor/github.com/go-fsnotify/fsevents" 13 | ) 14 | 15 | func main() { 16 | dev, _ := fsevents.DeviceForPath("/tmp") 17 | log.Print(dev) 18 | log.Println(fsevents.EventIDForDeviceBeforeTime(dev, time.Now())) 19 | 20 | es := &fsevents.EventStream{ 21 | Paths: []string{"/tmp"}, 22 | Latency: 500 * time.Millisecond, 23 | // Device: dev, 24 | Flags: fsevents.FileEvents | fsevents.WatchRoot} 25 | es.Start() 26 | ec := es.Events 27 | 28 | go func() { 29 | for msg := range ec { 30 | for _, event := range msg { 31 | logEvent(event) 32 | } 33 | } 34 | }() 35 | 36 | in := bufio.NewReader(os.Stdin) 37 | 38 | if false { 39 | log.Print("Started, press enter to GC") 40 | in.ReadString('\n') 41 | runtime.GC() 42 | log.Print("GC'd, press enter to quit") 43 | in.ReadString('\n') 44 | } else { 45 | log.Print("Started, press enter to stop") 46 | in.ReadString('\n') 47 | es.Stop() 48 | 49 | log.Print("Stopped, press enter to restart") 50 | in.ReadString('\n') 51 | es.Resume = true 52 | es.Start() 53 | 54 | log.Print("Restarted, press enter to quit") 55 | in.ReadString('\n') 56 | es.Stop() 57 | } 58 | } 59 | 60 | var noteDescription = map[fsevents.EventFlags]string{ 61 | fsevents.MustScanSubDirs: "MustScanSubdirs", 62 | fsevents.UserDropped: "UserDropped", 63 | fsevents.KernelDropped: "KernelDropped", 64 | fsevents.EventIDsWrapped: "EventIDsWrapped", 65 | fsevents.HistoryDone: "HistoryDone", 66 | fsevents.RootChanged: "RootChanged", 67 | fsevents.Mount: "Mount", 68 | fsevents.Unmount: "Unmount", 69 | 70 | fsevents.ItemCreated: "Created", 71 | fsevents.ItemRemoved: "Removed", 72 | fsevents.ItemInodeMetaMod: "InodeMetaMod", 73 | fsevents.ItemRenamed: "Renamed", 74 | fsevents.ItemModified: "Modified", 75 | fsevents.ItemFinderInfoMod: "FinderInfoMod", 76 | fsevents.ItemChangeOwner: "ChangeOwner", 77 | fsevents.ItemXattrMod: "XAttrMod", 78 | fsevents.ItemIsFile: "IsFile", 79 | fsevents.ItemIsDir: "IsDir", 80 | fsevents.ItemIsSymlink: "IsSymLink", 81 | } 82 | 83 | func logEvent(event fsevents.Event) { 84 | note := "" 85 | for bit, description := range noteDescription { 86 | if event.Flags&bit == bit { 87 | note += description + " " 88 | } 89 | } 90 | log.Printf("EventID: %d Path: %s Flags: %s", event.ID, event.Path, note) 91 | } 92 | -------------------------------------------------------------------------------- /_vendor/github.com/go-fsnotify/fsevents/fsevents_test.go: -------------------------------------------------------------------------------- 1 | // +build darwin 2 | 3 | package fsevents 4 | -------------------------------------------------------------------------------- /_vendor/github.com/hashicorp/errwrap/errwrap_test.go: -------------------------------------------------------------------------------- 1 | package errwrap 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestWrappedError_impl(t *testing.T) { 9 | var _ error = new(wrappedError) 10 | } 11 | 12 | func TestGetAll(t *testing.T) { 13 | cases := []struct { 14 | Err error 15 | Msg string 16 | Len int 17 | }{ 18 | {}, 19 | { 20 | fmt.Errorf("foo"), 21 | "foo", 22 | 1, 23 | }, 24 | { 25 | fmt.Errorf("bar"), 26 | "foo", 27 | 0, 28 | }, 29 | { 30 | Wrapf("bar", fmt.Errorf("foo")), 31 | "foo", 32 | 1, 33 | }, 34 | { 35 | Wrapf("{{err}}", fmt.Errorf("foo")), 36 | "foo", 37 | 2, 38 | }, 39 | { 40 | Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))), 41 | "foo", 42 | 1, 43 | }, 44 | } 45 | 46 | for i, tc := range cases { 47 | actual := GetAll(tc.Err, tc.Msg) 48 | if len(actual) != tc.Len { 49 | t.Fatalf("%d: bad: %#v", i, actual) 50 | } 51 | for _, v := range actual { 52 | if v.Error() != tc.Msg { 53 | t.Fatalf("%d: bad: %#v", i, actual) 54 | } 55 | } 56 | } 57 | } 58 | 59 | func TestGetAllType(t *testing.T) { 60 | cases := []struct { 61 | Err error 62 | Type interface{} 63 | Len int 64 | }{ 65 | {}, 66 | { 67 | fmt.Errorf("foo"), 68 | "foo", 69 | 0, 70 | }, 71 | { 72 | fmt.Errorf("bar"), 73 | fmt.Errorf("foo"), 74 | 1, 75 | }, 76 | { 77 | Wrapf("bar", fmt.Errorf("foo")), 78 | fmt.Errorf("baz"), 79 | 2, 80 | }, 81 | { 82 | Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))), 83 | Wrapf("", nil), 84 | 0, 85 | }, 86 | } 87 | 88 | for i, tc := range cases { 89 | actual := GetAllType(tc.Err, tc.Type) 90 | if len(actual) != tc.Len { 91 | t.Fatalf("%d: bad: %#v", i, actual) 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /_vendor/github.com/imdario/mergo/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | install: go get -t 3 | -------------------------------------------------------------------------------- /_vendor/github.com/imdario/mergo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dario Castañé. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. 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 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /_vendor/github.com/imdario/mergo/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Dario Castañé. All rights reserved. 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 | /* 7 | Package mergo merges same-type structs and maps by setting default values in zero-value fields. 8 | 9 | Mergo won't merge unexported (private) fields but will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection). 10 | 11 | Usage 12 | 13 | From my own work-in-progress project: 14 | 15 | type networkConfig struct { 16 | Protocol string 17 | Address string 18 | ServerType string `json: "server_type"` 19 | Port uint16 20 | } 21 | 22 | type FssnConfig struct { 23 | Network networkConfig 24 | } 25 | 26 | var fssnDefault = FssnConfig { 27 | networkConfig { 28 | "tcp", 29 | "127.0.0.1", 30 | "http", 31 | 31560, 32 | }, 33 | } 34 | 35 | // Inside a function [...] 36 | 37 | if err := mergo.Merge(&config, fssnDefault); err != nil { 38 | log.Fatal(err) 39 | } 40 | 41 | // More code [...] 42 | 43 | */ 44 | package mergo 45 | -------------------------------------------------------------------------------- /_vendor/github.com/imdario/mergo/testdata/license.yml: -------------------------------------------------------------------------------- 1 | import: ../../../../fossene/db/schema/thing.yml 2 | fields: 3 | site: string 4 | -------------------------------------------------------------------------------- /_vendor/github.com/imdario/mergo/testdata/thing.yml: -------------------------------------------------------------------------------- 1 | fields: 2 | id: int 3 | name: string 4 | parent: ref "datu:thing" 5 | status: enum(draft, public, private) 6 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 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/github.com/kardianos/osext/README.md: -------------------------------------------------------------------------------- 1 | ### Extensions to the "os" package. 2 | 3 | ## Find the current Executable and ExecutableFolder. 4 | 5 | There is sometimes utility in finding the current executable file 6 | that is running. This can be used for upgrading the current executable 7 | or finding resources located relative to the executable file. Both 8 | working directory and the os.Args[0] value are arbitrary and cannot 9 | be relied on; os.Args[0] can be "faked". 10 | 11 | Multi-platform and supports: 12 | * Linux 13 | * OS X 14 | * Windows 15 | * Plan 9 16 | * BSDs. 17 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/osext.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 | // Extensions to the standard "os" package. 6 | package osext 7 | 8 | import "path/filepath" 9 | 10 | // Executable returns an absolute path that can be used to 11 | // re-invoke the current program. 12 | // It may not be valid after the current program exits. 13 | func Executable() (string, error) { 14 | p, err := executable() 15 | return filepath.Clean(p), err 16 | } 17 | 18 | // Returns same path as Executable, returns just the folder 19 | // path. Excludes the executable name and any trailing slash. 20 | func ExecutableFolder() (string, error) { 21 | p, err := Executable() 22 | if err != nil { 23 | return "", err 24 | } 25 | 26 | return filepath.Dir(p), nil 27 | } 28 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/osext_plan9.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 | package osext 6 | 7 | import ( 8 | "os" 9 | "strconv" 10 | "syscall" 11 | ) 12 | 13 | func executable() (string, error) { 14 | f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text") 15 | if err != nil { 16 | return "", err 17 | } 18 | defer f.Close() 19 | return syscall.Fd2path(int(f.Fd())) 20 | } 21 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/osext_procfs.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 linux netbsd openbsd solaris dragonfly 6 | 7 | package osext 8 | 9 | import ( 10 | "errors" 11 | "fmt" 12 | "os" 13 | "runtime" 14 | "strings" 15 | ) 16 | 17 | func executable() (string, error) { 18 | switch runtime.GOOS { 19 | case "linux": 20 | const deletedTag = " (deleted)" 21 | execpath, err := os.Readlink("/proc/self/exe") 22 | if err != nil { 23 | return execpath, err 24 | } 25 | execpath = strings.TrimSuffix(execpath, deletedTag) 26 | execpath = strings.TrimPrefix(execpath, deletedTag) 27 | return execpath, nil 28 | case "netbsd": 29 | return os.Readlink("/proc/curproc/exe") 30 | case "openbsd", "dragonfly": 31 | return os.Readlink("/proc/curproc/file") 32 | case "solaris": 33 | return os.Readlink(fmt.Sprintf("/proc/%d/path/a.out", os.Getpid())) 34 | } 35 | return "", errors.New("ExecPath not implemented for " + runtime.GOOS) 36 | } 37 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/osext_sysctl.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 freebsd 6 | 7 | package osext 8 | 9 | import ( 10 | "os" 11 | "path/filepath" 12 | "runtime" 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | var initCwd, initCwdErr = os.Getwd() 18 | 19 | func executable() (string, error) { 20 | var mib [4]int32 21 | switch runtime.GOOS { 22 | case "freebsd": 23 | mib = [4]int32{1 /* CTL_KERN */, 14 /* KERN_PROC */, 12 /* KERN_PROC_PATHNAME */, -1} 24 | case "darwin": 25 | mib = [4]int32{1 /* CTL_KERN */, 38 /* KERN_PROCARGS */, int32(os.Getpid()), -1} 26 | } 27 | 28 | n := uintptr(0) 29 | // Get length. 30 | _, _, errNum := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, 0, uintptr(unsafe.Pointer(&n)), 0, 0) 31 | if errNum != 0 { 32 | return "", errNum 33 | } 34 | if n == 0 { // This shouldn't happen. 35 | return "", nil 36 | } 37 | buf := make([]byte, n) 38 | _, _, errNum = syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&n)), 0, 0) 39 | if errNum != 0 { 40 | return "", errNum 41 | } 42 | if n == 0 { // This shouldn't happen. 43 | return "", nil 44 | } 45 | for i, v := range buf { 46 | if v == 0 { 47 | buf = buf[:i] 48 | break 49 | } 50 | } 51 | var err error 52 | execPath := string(buf) 53 | // execPath will not be empty due to above checks. 54 | // Try to get the absolute path if the execPath is not rooted. 55 | if execPath[0] != '/' { 56 | execPath, err = getAbs(execPath) 57 | if err != nil { 58 | return execPath, err 59 | } 60 | } 61 | // For darwin KERN_PROCARGS may return the path to a symlink rather than the 62 | // actual executable. 63 | if runtime.GOOS == "darwin" { 64 | if execPath, err = filepath.EvalSymlinks(execPath); err != nil { 65 | return execPath, err 66 | } 67 | } 68 | return execPath, nil 69 | } 70 | 71 | func getAbs(execPath string) (string, error) { 72 | if initCwdErr != nil { 73 | return execPath, initCwdErr 74 | } 75 | // The execPath may begin with a "../" or a "./" so clean it first. 76 | // Join the two paths, trailing and starting slashes undetermined, so use 77 | // the generic Join function. 78 | return filepath.Join(initCwd, filepath.Clean(execPath)), nil 79 | } 80 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/osext/osext_windows.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 | package osext 6 | 7 | import ( 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | var ( 14 | kernel = syscall.MustLoadDLL("kernel32.dll") 15 | getModuleFileNameProc = kernel.MustFindProc("GetModuleFileNameW") 16 | ) 17 | 18 | // GetModuleFileName() with hModule = NULL 19 | func executable() (exePath string, err error) { 20 | return getModuleFileName() 21 | } 22 | 23 | func getModuleFileName() (string, error) { 24 | var n uint32 25 | b := make([]uint16, syscall.MAX_PATH) 26 | size := uint32(len(b)) 27 | 28 | r0, _, e1 := getModuleFileNameProc.Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(size)) 29 | n = uint32(r0) 30 | if n == 0 { 31 | return "", e1 32 | } 33 | return string(utf16.Decode(b[0:n])), nil 34 | } 35 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeglass/glass/e7312876059e35eea800b935df8b77a1ce2c9ec5/_vendor/github.com/kardianos/service/.gitignore -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Daniel Theophanes 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source 20 | distribution. 21 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/README.md: -------------------------------------------------------------------------------- 1 | # service 2 | service will install / un-install, start / stop, and run a program as a service (daemon). 3 | Currently supports Windows XP+, Linux/(systemd | Upstart | SysV), and OSX/Launchd. 4 | 5 | Windows controls services by setting up callbacks that is non-trivial. This 6 | is very different then other systems. This package provides the same API 7 | despite the substantial differences. 8 | It also can be used to detect how a program is called, from an interactive 9 | terminal or from a service manager. 10 | 11 | ## BUGS 12 | * Dependencies field is not implemented for Linux systems and Launchd. 13 | * OS X when running as a UserService Interactive will not be accurate. 14 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/console.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | package service 6 | 7 | import ( 8 | "log" 9 | "os" 10 | ) 11 | 12 | // ConsoleLogger logs to the std err. 13 | var ConsoleLogger = consoleLogger{} 14 | 15 | type consoleLogger struct { 16 | info, warn, err *log.Logger 17 | } 18 | 19 | func init() { 20 | ConsoleLogger.info = log.New(os.Stderr, "I: ", log.Ltime) 21 | ConsoleLogger.warn = log.New(os.Stderr, "W: ", log.Ltime) 22 | ConsoleLogger.err = log.New(os.Stderr, "E: ", log.Ltime) 23 | } 24 | 25 | func (c consoleLogger) Error(v ...interface{}) error { 26 | c.err.Print(v...) 27 | return nil 28 | } 29 | func (c consoleLogger) Warning(v ...interface{}) error { 30 | c.warn.Print(v...) 31 | return nil 32 | } 33 | func (c consoleLogger) Info(v ...interface{}) error { 34 | c.info.Print(v...) 35 | return nil 36 | } 37 | func (c consoleLogger) Errorf(format string, a ...interface{}) error { 38 | c.err.Printf(format, a...) 39 | return nil 40 | } 41 | func (c consoleLogger) Warningf(format string, a ...interface{}) error { 42 | c.warn.Printf(format, a...) 43 | return nil 44 | } 45 | func (c consoleLogger) Infof(format string, a ...interface{}) error { 46 | c.info.Printf(format, a...) 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/example/runner/runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "builder", 3 | "DisplayName": "Go Builder", 4 | "Description": "Run the Go Builder", 5 | 6 | "Dir": "C:\\dev\\go\\src", 7 | "Exec": "C:\\windows\\system32\\cmd.exe", 8 | "Args": ["/C","C:\\dev\\go\\src\\all.bat"], 9 | "Env": [ 10 | "PATH=C:\\TDM-GCC-64\\bin;C:\\Program Files (x86)\\Git\\cmd", 11 | "GOROOT_BOOTSTRAP=C:\\dev\\go_ready", 12 | "HOMEDRIVE=C:", 13 | "HOMEPATH=\\Documents and Settings\\Administrator" 14 | ], 15 | 16 | "Stderr": "C:\\builder_err.log", 17 | "Stdout": "C:\\builder_out.log" 18 | } -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/example/simple/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | // simple does nothing except block while running the service. 6 | package main 7 | 8 | import ( 9 | "log" 10 | 11 | "github.com/timeglass/glass/_vendor/github.com/kardianos/service" 12 | ) 13 | 14 | var logger service.Logger 15 | 16 | type program struct{} 17 | 18 | func (p *program) Start(s service.Service) error { 19 | // Start should not block. Do the actual work async. 20 | go p.run() 21 | return nil 22 | } 23 | func (p *program) run() { 24 | // Do work here 25 | } 26 | func (p *program) Stop(s service.Service) error { 27 | // Stop should not block. Return with a few seconds. 28 | return nil 29 | } 30 | 31 | func main() { 32 | svcConfig := &service.Config{ 33 | Name: "GoServiceExampleSimple", 34 | DisplayName: "Go Service Example", 35 | Description: "This is an example Go service.", 36 | } 37 | 38 | prg := &program{} 39 | s, err := service.New(prg, svcConfig) 40 | if err != nil { 41 | log.Fatal(err) 42 | } 43 | logger, err = s.Logger(nil) 44 | if err != nil { 45 | log.Fatal(err) 46 | } 47 | err = s.Run() 48 | if err != nil { 49 | logger.Error(err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/example/stopPause/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | // simple does nothing except block while running the service. 6 | package main 7 | 8 | import ( 9 | "log" 10 | "os" 11 | "time" 12 | 13 | "github.com/timeglass/glass/_vendor/github.com/kardianos/service" 14 | ) 15 | 16 | var logger service.Logger 17 | 18 | type program struct{} 19 | 20 | func (p *program) Start(s service.Service) error { 21 | // Start should not block. Do the actual work async. 22 | go p.run() 23 | return nil 24 | } 25 | func (p *program) run() { 26 | // Do work here 27 | } 28 | func (p *program) Stop(s service.Service) error { 29 | // Stop should not block. Return with a few seconds. 30 | <-time.After(time.Second * 13) 31 | return nil 32 | } 33 | 34 | func main() { 35 | svcConfig := &service.Config{ 36 | Name: "GoServiceExampleStopPause", 37 | DisplayName: "Go Service Example: Stop Pause", 38 | Description: "This is an example Go service that pauses on stop.", 39 | } 40 | 41 | prg := &program{} 42 | s, err := service.New(prg, svcConfig) 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | if len(os.Args) > 1 { 47 | err = service.Control(s, os.Args[1]) 48 | if err != nil { 49 | log.Fatal(err) 50 | } 51 | return 52 | } 53 | 54 | logger, err = s.Logger(nil) 55 | if err != nil { 56 | log.Fatal(err) 57 | } 58 | err = s.Run() 59 | if err != nil { 60 | logger.Error(err) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/linux_test/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: sysv systemd upstart clean 3 | 4 | test: 5 | @go test -c .. 6 | 7 | clean: 8 | -rm service.test 9 | 10 | sysv: test 11 | @echo sysv 12 | @cp service.test sysv/ 13 | @docker build -q --tag="service.test.sysv" sysv 14 | @-docker run service.test.sysv 15 | @-docker rm $(shell docker ps -l -q) 16 | @-docker rmi -f service.test.sysv 17 | @-rm sysv/service.test 18 | 19 | systemd: test 20 | @echo systemd 21 | @cp service.test systemd/ 22 | @docker build -q --tag="service.test.systemd" systemd 23 | @-docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro service.test.systemd 24 | @-docker rm $(shell docker ps -l -q) 25 | @-docker rmi -f service.test.systemd 26 | @-rm systemd/service.test 27 | 28 | upstart: test 29 | @echo upstart 30 | @cp service.test upstart/ 31 | @docker build -q --tag="service.test.upstart" upstart 32 | @-docker run service.test.upstart 33 | @-docker rm $(shell docker ps -l -q) 34 | @-docker rmi -f service.test.upstart 35 | @-rm upstart/service.test 36 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/linux_test/README.md: -------------------------------------------------------------------------------- 1 | ## Docker images to help vet linux configurations. 2 | 3 | Although the actual init systems won't run in docker, 4 | it may still be usefull to attempt to run it in different 5 | environments. 6 | 7 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/linux_test/systemd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minimum2scp/systemd:latest 2 | ADD service.test /tmp/ 3 | CMD /tmp/service.test -test.v=true 4 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/linux_test/sysv/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minimum2scp/baseimage:latest 2 | ADD service.test /tmp/ 3 | CMD /tmp/service.test -test.v=true 4 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/linux_test/upstart/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | ADD service.test /tmp/ 3 | CMD /tmp/service.test -test.v=true 4 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/name_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | package service 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestPlatformName(t *testing.T) { 12 | t.Logf("Platform is %v", Platform()) 13 | } 14 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/service_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | package service 6 | 7 | import ( 8 | "os" 9 | "strings" 10 | ) 11 | 12 | type linuxSystemService struct { 13 | name string 14 | detect func() bool 15 | interactive func() bool 16 | new func(i Interface, c *Config) (Service, error) 17 | } 18 | 19 | func (sc linuxSystemService) String() string { 20 | return sc.name 21 | } 22 | func (sc linuxSystemService) Detect() bool { 23 | return sc.detect() 24 | } 25 | func (sc linuxSystemService) Interactive() bool { 26 | return sc.interactive() 27 | } 28 | func (sc linuxSystemService) New(i Interface, c *Config) (Service, error) { 29 | return sc.new(i, c) 30 | } 31 | 32 | func init() { 33 | ChooseSystem(linuxSystemService{ 34 | name: "linux-systemd", 35 | detect: isSystemd, 36 | interactive: func() bool { 37 | is, _ := isInteractive() 38 | return is 39 | }, 40 | new: newSystemdService, 41 | }, 42 | linuxSystemService{ 43 | name: "linux-upstart", 44 | detect: isUpstart, 45 | interactive: func() bool { 46 | is, _ := isInteractive() 47 | return is 48 | }, 49 | new: newUpstartService, 50 | }, 51 | linuxSystemService{ 52 | name: "unix-systemv", 53 | detect: func() bool { return true }, 54 | interactive: func() bool { 55 | is, _ := isInteractive() 56 | return is 57 | }, 58 | new: newSystemVService, 59 | }, 60 | ) 61 | } 62 | 63 | func isInteractive() (bool, error) { 64 | // TODO: This is not true for user services. 65 | return os.Getppid() != 1, nil 66 | } 67 | 68 | var tf = map[string]interface{}{ 69 | "cmd": func(s string) string { 70 | return `"` + strings.Replace(s, `"`, `\"`, -1) + `"` 71 | }, 72 | } 73 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/service_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | package service_test 6 | 7 | import ( 8 | "log" 9 | "os" 10 | "testing" 11 | 12 | "github.com/timeglass/glass/_vendor/github.com/kardianos/service" 13 | ) 14 | 15 | const runAsServiceArg = "RunThisAsService" 16 | 17 | var sc = &service.Config{ 18 | Name: "go_service_test", 19 | Arguments: []string{runAsServiceArg}, 20 | } 21 | 22 | func TestMain(m *testing.M) { 23 | if len(os.Args) > 1 && os.Args[1] == runAsServiceArg { 24 | runService() 25 | return 26 | } 27 | os.Exit(m.Run()) 28 | } 29 | 30 | func TestInstallRunRestartStopRemove(t *testing.T) { 31 | p := &program{} 32 | s, err := service.New(p, sc) 33 | if err != nil { 34 | t.Fatal(err) 35 | } 36 | _ = s.Uninstall() 37 | 38 | err = s.Install() 39 | if err != nil { 40 | t.Fatal("install", err) 41 | } 42 | defer s.Uninstall() 43 | 44 | err = s.Start() 45 | if err != nil { 46 | t.Fatal("start", err) 47 | } 48 | err = s.Restart() 49 | if err != nil { 50 | t.Fatal("restart", err) 51 | } 52 | err = s.Stop() 53 | if err != nil { 54 | t.Fatal("stop", err) 55 | } 56 | err = s.Uninstall() 57 | if err != nil { 58 | t.Fatal("stop", err) 59 | } 60 | } 61 | 62 | func runService() { 63 | p := &program{} 64 | s, err := service.New(p, sc) 65 | if err != nil { 66 | log.Fatal(err) 67 | } 68 | err = s.Run() 69 | if err != nil { 70 | log.Fatal(err) 71 | } 72 | } 73 | 74 | type program struct{} 75 | 76 | func (p *program) Start(s service.Service) error { 77 | go p.run() 78 | return nil 79 | } 80 | func (p *program) run() { 81 | // Do work here 82 | } 83 | func (p *program) Stop(s service.Service) error { 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /_vendor/github.com/kardianos/service/service_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Daniel Theophanes. 2 | // Use of this source code is governed by a zlib-style 3 | // license that can be found in the LICENSE file.package service 4 | 5 | // +build linux darwin 6 | 7 | package service 8 | 9 | import ( 10 | "fmt" 11 | "log/syslog" 12 | "os/exec" 13 | ) 14 | 15 | func newSysLogger(name string, errs chan<- error) (Logger, error) { 16 | w, err := syslog.New(syslog.LOG_INFO, name) 17 | if err != nil { 18 | return nil, err 19 | } 20 | return sysLogger{w, errs}, nil 21 | } 22 | 23 | type sysLogger struct { 24 | *syslog.Writer 25 | errs chan<- error 26 | } 27 | 28 | func (s sysLogger) send(err error) error { 29 | if err != nil && s.errs != nil { 30 | s.errs <- err 31 | } 32 | return err 33 | } 34 | 35 | func (s sysLogger) Error(v ...interface{}) error { 36 | return s.send(s.Writer.Err(fmt.Sprint(v...))) 37 | } 38 | func (s sysLogger) Warning(v ...interface{}) error { 39 | return s.send(s.Writer.Warning(fmt.Sprint(v...))) 40 | } 41 | func (s sysLogger) Info(v ...interface{}) error { 42 | return s.send(s.Writer.Info(fmt.Sprint(v...))) 43 | } 44 | func (s sysLogger) Errorf(format string, a ...interface{}) error { 45 | return s.send(s.Writer.Err(fmt.Sprintf(format, a...))) 46 | } 47 | func (s sysLogger) Warningf(format string, a ...interface{}) error { 48 | return s.send(s.Writer.Warning(fmt.Sprintf(format, a...))) 49 | } 50 | func (s sysLogger) Infof(format string, a ...interface{}) error { 51 | return s.send(s.Writer.Info(fmt.Sprintf(format, a...))) 52 | } 53 | 54 | func run(command string, arguments ...string) error { 55 | cmd := exec.Command(command, arguments...) 56 | out, err := cmd.CombinedOutput() 57 | if err != nil { 58 | return fmt.Errorf("%q failed: %v, %s", command, err, out) 59 | } 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /_vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | isatty for golang 4 | 5 | ## Usage 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "github.com/mattn/go-isatty" 13 | "os" 14 | ) 15 | 16 | func main() { 17 | if isatty.IsTerminal(os.Stdout.Fd()) { 18 | fmt.Println("Is Terminal") 19 | } else { 20 | fmt.Println("Is Not Terminal") 21 | } 22 | } 23 | ``` 24 | 25 | ## Installation 26 | 27 | ``` 28 | $ go get github.com/mattn/go-isatty 29 | ``` 30 | 31 | # License 32 | 33 | MIT 34 | 35 | # Author 36 | 37 | Yasuhiro Matsumoto (a.k.a mattn) 38 | -------------------------------------------------------------------------------- /_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_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd 2 | 3 | package isatty 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ioctlReadTermios = syscall.TIOCGETA 11 | 12 | // IsTerminal return true if the file descriptor is terminal. 13 | func IsTerminal(fd uintptr) bool { 14 | var termios syscall.Termios 15 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 16 | return err == 0 17 | } 18 | -------------------------------------------------------------------------------- /_vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package isatty 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | // IsTerminal return true if the file descriptor is terminal. 13 | func IsTerminal(fd uintptr) bool { 14 | var termios syscall.Termios 15 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 16 | return err == 0 17 | } 18 | -------------------------------------------------------------------------------- /_vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package isatty 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 11 | var procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var st uint32 16 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 17 | return r != 0 && e == 0 18 | } 19 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See github.com/timeglass/glass/_vendor/golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /_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.github.com/timeglass/glass/_vendor/golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://github.com/timeglass/glass/_vendor/golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://github.com/timeglass/glass/_vendor/golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /_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.github.com/timeglass/glass/_vendor/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/README: -------------------------------------------------------------------------------- 1 | This repository holds supplemental Go packages for low-level interactions with the operating system. 2 | 3 | To submit changes to this repository, see http://github.com/timeglass/glass/_vendor/golang.org/doc/contribute.html. 4 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/asm.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 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for 386, Plan 9 9 | // 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-32 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-36 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$4-4 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for amd64, Plan 9 9 | // 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-64 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-56 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$8-8 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/const_plan9.go: -------------------------------------------------------------------------------- 1 | package plan9 2 | 3 | // Plan 9 Constants 4 | 5 | // Open modes 6 | const ( 7 | O_RDONLY = 0 8 | O_WRONLY = 1 9 | O_RDWR = 2 10 | O_TRUNC = 16 11 | O_CLOEXEC = 32 12 | O_EXCL = 0x1000 13 | ) 14 | 15 | // Rfork flags 16 | const ( 17 | RFNAMEG = 1 << 0 18 | RFENVG = 1 << 1 19 | RFFDG = 1 << 2 20 | RFNOTEG = 1 << 3 21 | RFPROC = 1 << 4 22 | RFMEM = 1 << 5 23 | RFNOWAIT = 1 << 6 24 | RFCNAMEG = 1 << 10 25 | RFCENVG = 1 << 11 26 | RFCFDG = 1 << 12 27 | RFREND = 1 << 13 28 | RFNOMNT = 1 << 14 29 | ) 30 | 31 | // Qid.Type bits 32 | const ( 33 | QTDIR = 0x80 34 | QTAPPEND = 0x40 35 | QTEXCL = 0x20 36 | QTMOUNT = 0x10 37 | QTAUTH = 0x08 38 | QTTMP = 0x04 39 | QTFILE = 0x00 40 | ) 41 | 42 | // Dir.Mode bits 43 | const ( 44 | DMDIR = 0x80000000 45 | DMAPPEND = 0x40000000 46 | DMEXCL = 0x20000000 47 | DMMOUNT = 0x10000000 48 | DMAUTH = 0x08000000 49 | DMTMP = 0x04000000 50 | DMREAD = 0x4 51 | DMWRITE = 0x2 52 | DMEXEC = 0x1 53 | ) 54 | 55 | const ( 56 | STATMAX = 65535 57 | ERRMAX = 128 58 | STATFIXLEN = 49 59 | ) 60 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/env_plan9.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 | // Plan 9 environment variables. 6 | 7 | package plan9 8 | 9 | import ( 10 | "syscall" 11 | ) 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 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/env_unset.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 go1.4 6 | 7 | package plan9 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/errors_plan9.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 | package plan9 6 | 7 | import "syscall" 8 | 9 | // Constants 10 | const ( 11 | // Invented values to support what package os expects. 12 | O_CREAT = 0x02000 13 | O_APPEND = 0x00400 14 | O_NOCTTY = 0x00000 15 | O_NONBLOCK = 0x00000 16 | O_SYNC = 0x00000 17 | O_ASYNC = 0x00000 18 | 19 | S_IFMT = 0x1f000 20 | S_IFIFO = 0x1000 21 | S_IFCHR = 0x2000 22 | S_IFDIR = 0x4000 23 | S_IFBLK = 0x6000 24 | S_IFREG = 0x8000 25 | S_IFLNK = 0xa000 26 | S_IFSOCK = 0xc000 27 | ) 28 | 29 | // Errors 30 | var ( 31 | EINVAL = syscall.NewError("bad arg in system call") 32 | ENOTDIR = syscall.NewError("not a directory") 33 | EISDIR = syscall.NewError("file is a directory") 34 | ENOENT = syscall.NewError("file does not exist") 35 | EEXIST = syscall.NewError("file already exists") 36 | EMFILE = syscall.NewError("no free file descriptors") 37 | EIO = syscall.NewError("i/o error") 38 | ENAMETOOLONG = syscall.NewError("file name too long") 39 | EINTR = syscall.NewError("interrupted") 40 | EPERM = syscall.NewError("permission denied") 41 | EBUSY = syscall.NewError("no free devices") 42 | ETIMEDOUT = syscall.NewError("connection timed out") 43 | EPLAN9 = syscall.NewError("not supported by plan 9") 44 | 45 | // The following errors do not correspond to any 46 | // Plan 9 system messages. Invented to support 47 | // what package os and others expect. 48 | EACCES = syscall.NewError("access permission denied") 49 | EAFNOSUPPORT = syscall.NewError("address family not supported by protocol") 50 | ) 51 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 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.# Copyright 2009 The Go Authors. All rights reserved. 5 | # Use of this source code is governed by a BSD-style 6 | # license that can be found in the LICENSE file. 7 | 8 | COMMAND="mksysnum_plan9.sh $@" 9 | 10 | cat <= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/syscall_test.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 plan9 6 | 7 | package plan9_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/plan9" 13 | ) 14 | 15 | func testSetGetenv(t *testing.T, key, value string) { 16 | err := plan9.Setenv(key, value) 17 | if err != nil { 18 | t.Fatalf("Setenv failed to set %q: %v", value, err) 19 | } 20 | newvalue, found := plan9.Getenv(key) 21 | if !found { 22 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 23 | } 24 | if newvalue != value { 25 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 26 | } 27 | } 28 | 29 | func TestEnv(t *testing.T) { 30 | testSetGetenv(t, "TESTENV", "AVALUE") 31 | // make sure TESTENV gets set to "", not deleted 32 | testSetGetenv(t, "TESTENV", "") 33 | } 34 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/plan9/zsysnum_plan9.go: -------------------------------------------------------------------------------- 1 | // mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h 2 | // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT 3 | 4 | package plan9 5 | 6 | const ( 7 | SYS_SYSR1 = 0 8 | SYS_BIND = 2 9 | SYS_CHDIR = 3 10 | SYS_CLOSE = 4 11 | SYS_DUP = 5 12 | SYS_ALARM = 6 13 | SYS_EXEC = 7 14 | SYS_EXITS = 8 15 | SYS_FAUTH = 10 16 | SYS_SEGBRK = 12 17 | SYS_OPEN = 14 18 | SYS_OSEEK = 16 19 | SYS_SLEEP = 17 20 | SYS_RFORK = 19 21 | SYS_PIPE = 21 22 | SYS_CREATE = 22 23 | SYS_FD2PATH = 23 24 | SYS_BRK_ = 24 25 | SYS_REMOVE = 25 26 | SYS_NOTIFY = 28 27 | SYS_NOTED = 29 28 | SYS_SEGATTACH = 30 29 | SYS_SEGDETACH = 31 30 | SYS_SEGFREE = 32 31 | SYS_SEGFLUSH = 33 32 | SYS_RENDEZVOUS = 34 33 | SYS_UNMOUNT = 35 34 | SYS_SEMACQUIRE = 37 35 | SYS_SEMRELEASE = 38 36 | SYS_SEEK = 39 37 | SYS_FVERSION = 40 38 | SYS_ERRSTR = 41 39 | SYS_STAT = 42 40 | SYS_FSTAT = 43 41 | SYS_WSTAT = 44 42 | SYS_FWSTAT = 45 43 | SYS_MOUNT = 46 44 | SYS_AWAIT = 47 45 | SYS_PREAD = 50 46 | SYS_PWRITE = 51 47 | SYS_TSEMACQUIRE = 52 48 | SYS_NSEC = 53 49 | ) 50 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/asm.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 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /_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_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-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /_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-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 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 | // 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 ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /_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 ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /_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 ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /_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 ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /_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 ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /_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_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 | // 8 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.goc 9 | // 10 | 11 | TEXT ·sysvicall6(SB), 7, $0-64 12 | JMP syscall·sysvicall6(SB) 13 | 14 | TEXT ·rawSysvicall6(SB), 7, $0-64 15 | JMP syscall·rawSysvicall6(SB) 16 | 17 | TEXT ·dlopen(SB), 7, $0-16 18 | JMP syscall·dlopen(SB) 19 | 20 | TEXT ·dlclose(SB), 7, $0-8 21 | JMP syscall·dlclose(SB) 22 | 23 | TEXT ·dlsym(SB), 7, $0-16 24 | JMP syscall·dlsym(SB) 25 | -------------------------------------------------------------------------------- /_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 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/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 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 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/env_unset.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 go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/export_test.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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 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 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 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 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /_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 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | 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) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /_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/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+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 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | 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 '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 <= 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_bsd_test.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 openbsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/unix" 13 | ) 14 | 15 | const MNT_WAIT = 1 16 | 17 | func TestGetfsstat(t *testing.T) { 18 | n, err := unix.Getfsstat(nil, MNT_WAIT) 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | data := make([]unix.Statfs_t, n) 24 | n, err = unix.Getfsstat(data, MNT_WAIT) 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | 29 | empty := unix.Statfs_t{} 30 | for _, stat := range data { 31 | if stat == empty { 32 | t.Fatal("an empty Statfs_t struct was returned") 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = int32(sec) 40 | tv.Usec = int32(usec) 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint32(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint32(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 76 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = nsec / 1e9 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/syscall_no_getwd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = nsec % 1e9 / 1e3 24 | tv.Sec = nsec / 1e9 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /_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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = nsec % 1e9 / 1e3 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | 36 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 37 | // TODO(aram): implement this, see issue 5847. 38 | panic("unimplemented") 39 | } 40 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/syscall_test.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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/unix" 14 | ) 15 | 16 | func testSetGetenv(t *testing.T, key, value string) { 17 | err := unix.Setenv(key, value) 18 | if err != nil { 19 | t.Fatalf("Setenv failed to set %q: %v", value, err) 20 | } 21 | newvalue, found := unix.Getenv(key) 22 | if !found { 23 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 24 | } 25 | if newvalue != value { 26 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 27 | } 28 | } 29 | 30 | func TestEnv(t *testing.T) { 31 | testSetGetenv(t, "TESTENV", "AVALUE") 32 | // make sure TESTENV gets set to "", not deleted 33 | testSetGetenv(t, "TESTENV", "") 34 | } 35 | 36 | func TestItoa(t *testing.T) { 37 | // Make most negative integer: 0x8000... 38 | i := 1 39 | for i<<1 != 0 { 40 | i <<= 1 41 | } 42 | if i >= 0 { 43 | t.Fatal("bad math") 44 | } 45 | s := unix.Itoa(i) 46 | f := fmt.Sprint(i) 47 | if s != f { 48 | t.Fatalf("itoa(%d) = %s, want %s", i, s, f) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.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 amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/asm.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 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/env_unset.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 go1.4 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/env_windows.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 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/eventlog.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 windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/exec_windows.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 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/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 windows,race 6 | 7 | package windows 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/windows/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 windows,!race 6 | 7 | package windows 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/windows/registry/export_test.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 windows 6 | 7 | package registry 8 | 9 | func (k Key) SetValue(name string, valtype uint32, data []byte) error { 10 | return k.setValue(name, valtype, data) 11 | } 12 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/registry/syscall.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 windows 6 | 7 | package registry 8 | 9 | import "syscall" 10 | 11 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 12 | 13 | const ( 14 | _REG_OPTION_NON_VOLATILE = 0 15 | 16 | _REG_CREATED_NEW_KEY = 1 17 | _REG_OPENED_EXISTING_KEY = 2 18 | 19 | _ERROR_NO_MORE_ITEMS syscall.Errno = 259 20 | ) 21 | 22 | //sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW 23 | //sys regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW 24 | //sys regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW 25 | //sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegEnumValueW 26 | //sys regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) = advapi32.RegDeleteValueW 27 | 28 | //sys expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW 29 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/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 windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/debug/log.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 windows 6 | 7 | package debug 8 | 9 | import ( 10 | "os" 11 | "strconv" 12 | ) 13 | 14 | // Log interface allows different log implementations to be used. 15 | type Log interface { 16 | Close() error 17 | Info(eid uint32, msg string) error 18 | Warning(eid uint32, msg string) error 19 | Error(eid uint32, msg string) error 20 | } 21 | 22 | // ConsoleLog provides access to the console. 23 | type ConsoleLog struct { 24 | Name string 25 | } 26 | 27 | // New creates new ConsoleLog. 28 | func New(source string) *ConsoleLog { 29 | return &ConsoleLog{Name: source} 30 | } 31 | 32 | // Close closes console log l. 33 | func (l *ConsoleLog) Close() error { 34 | return nil 35 | } 36 | 37 | func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { 38 | s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" 39 | _, err := os.Stdout.Write([]byte(s)) 40 | return err 41 | } 42 | 43 | // Info writes an information event msg with event id eid to the console l. 44 | func (l *ConsoleLog) Info(eid uint32, msg string) error { 45 | return l.report("info", eid, msg) 46 | } 47 | 48 | // Warning writes an warning event msg with event id eid to the console l. 49 | func (l *ConsoleLog) Warning(eid uint32, msg string) error { 50 | return l.report("warn", eid, msg) 51 | } 52 | 53 | // Error writes an error event msg with event id eid to the console l. 54 | func (l *ConsoleLog) Error(eid uint32, msg string) error { 55 | return l.report("error", eid, msg) 56 | } 57 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/debug/service.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 windows 6 | 7 | // Package debug provides facilities to execute svc.Handler on console. 8 | // 9 | package debug 10 | 11 | import ( 12 | "os" 13 | "os/signal" 14 | "syscall" 15 | 16 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc" 17 | ) 18 | 19 | // Run executes service name by calling appropriate handler function. 20 | // The process is running on console, unlike real service. Use Ctrl+C to 21 | // send "Stop" command to your service. 22 | func Run(name string, handler svc.Handler) error { 23 | cmds := make(chan svc.ChangeRequest) 24 | changes := make(chan svc.Status) 25 | 26 | sig := make(chan os.Signal) 27 | signal.Notify(sig) 28 | 29 | go func() { 30 | status := svc.Status{State: svc.Stopped} 31 | for { 32 | select { 33 | case <-sig: 34 | cmds <- svc.ChangeRequest{svc.Stop, status} 35 | case status = <-changes: 36 | } 37 | } 38 | }() 39 | 40 | _, errno := handler.Execute([]string{name}, cmds, changes) 41 | if errno != 0 { 42 | return syscall.Errno(errno) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/event.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 windows 6 | 7 | package svc 8 | 9 | import ( 10 | "errors" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 13 | ) 14 | 15 | // event represents auto-reset, initially non-signaled Windows event. 16 | // It is used to communicate between go and asm parts of this package. 17 | type event struct { 18 | h windows.Handle 19 | } 20 | 21 | func newEvent() (*event, error) { 22 | h, err := windows.CreateEvent(nil, 0, 0, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return &event{h: h}, nil 27 | } 28 | 29 | func (e *event) Close() error { 30 | return windows.CloseHandle(e.h) 31 | } 32 | 33 | func (e *event) Set() error { 34 | return windows.SetEvent(e.h) 35 | } 36 | 37 | func (e *event) Wait() error { 38 | s, err := windows.WaitForSingleObject(e.h, windows.INFINITE) 39 | switch s { 40 | case windows.WAIT_OBJECT_0: 41 | break 42 | case windows.WAIT_FAILED: 43 | return err 44 | default: 45 | return errors.New("unexpected result from WaitForSingleObject") 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/eventlog/log.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 windows 6 | 7 | // Package eventlog implements access to Windows event log. 8 | // 9 | package eventlog 10 | 11 | import ( 12 | "errors" 13 | "syscall" 14 | 15 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 16 | ) 17 | 18 | // Log provides access to the system log. 19 | type Log struct { 20 | Handle windows.Handle 21 | } 22 | 23 | // Open retrieves a handle to the specified event log. 24 | func Open(source string) (*Log, error) { 25 | return OpenRemote("", source) 26 | } 27 | 28 | // OpenRemote does the same as Open, but on different computer host. 29 | func OpenRemote(host, source string) (*Log, error) { 30 | if source == "" { 31 | return nil, errors.New("Specify event log source") 32 | } 33 | var s *uint16 34 | if host != "" { 35 | s = syscall.StringToUTF16Ptr(host) 36 | } 37 | h, err := windows.RegisterEventSource(s, syscall.StringToUTF16Ptr(source)) 38 | if err != nil { 39 | return nil, err 40 | } 41 | return &Log{Handle: h}, nil 42 | } 43 | 44 | // Close closes event log l. 45 | func (l *Log) Close() error { 46 | return windows.DeregisterEventSource(l.Handle) 47 | } 48 | 49 | func (l *Log) report(etype uint16, eid uint32, msg string) error { 50 | ss := []*uint16{syscall.StringToUTF16Ptr(msg)} 51 | return windows.ReportEvent(l.Handle, etype, 0, eid, 0, 1, 0, &ss[0], nil) 52 | } 53 | 54 | // Info writes an information event msg with event id eid to the end of event log l. 55 | // When EventCreate.exe is used, eid must be between 1 and 1000. 56 | func (l *Log) Info(eid uint32, msg string) error { 57 | return l.report(windows.EVENTLOG_INFORMATION_TYPE, eid, msg) 58 | } 59 | 60 | // Warning writes an warning event msg with event id eid to the end of event log l. 61 | // When EventCreate.exe is used, eid must be between 1 and 1000. 62 | func (l *Log) Warning(eid uint32, msg string) error { 63 | return l.report(windows.EVENTLOG_WARNING_TYPE, eid, msg) 64 | } 65 | 66 | // Error writes an error event msg with event id eid to the end of event log l. 67 | // When EventCreate.exe is used, eid must be between 1 and 1000. 68 | func (l *Log) Error(eid uint32, msg string) error { 69 | return l.report(windows.EVENTLOG_ERROR_TYPE, eid, msg) 70 | } 71 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/eventlog/log_test.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 windows 6 | 7 | package eventlog_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/eventlog" 13 | ) 14 | 15 | func TestLog(t *testing.T) { 16 | if testing.Short() { 17 | t.Skip("skipping test in short mode - it modifies system logs") 18 | } 19 | 20 | const name = "mylog" 21 | const supports = eventlog.Error | eventlog.Warning | eventlog.Info 22 | err := eventlog.InstallAsEventCreate(name, supports) 23 | if err != nil { 24 | t.Fatalf("Install failed: %s", err) 25 | } 26 | defer func() { 27 | err = eventlog.Remove(name) 28 | if err != nil { 29 | t.Fatalf("Remove failed: %s", err) 30 | } 31 | }() 32 | 33 | l, err := eventlog.Open(name) 34 | if err != nil { 35 | t.Fatalf("Open failed: %s", err) 36 | } 37 | defer l.Close() 38 | 39 | err = l.Info(1, "info") 40 | if err != nil { 41 | t.Fatalf("Info failed: %s", err) 42 | } 43 | err = l.Warning(2, "warning") 44 | if err != nil { 45 | t.Fatalf("Warning failed: %s", err) 46 | } 47 | err = l.Error(3, "error") 48 | if err != nil { 49 | t.Fatalf("Error failed: %s", err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/example/beep.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/example/install.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "path/filepath" 13 | 14 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/eventlog" 15 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/mgr" 16 | ) 17 | 18 | func exePath() (string, error) { 19 | prog := os.Args[0] 20 | p, err := filepath.Abs(prog) 21 | if err != nil { 22 | return "", err 23 | } 24 | fi, err := os.Stat(p) 25 | if err == nil { 26 | if !fi.Mode().IsDir() { 27 | return p, nil 28 | } 29 | err = fmt.Errorf("%s is directory", p) 30 | } 31 | if filepath.Ext(p) == "" { 32 | p += ".exe" 33 | fi, err := os.Stat(p) 34 | if err == nil { 35 | if !fi.Mode().IsDir() { 36 | return p, nil 37 | } 38 | err = fmt.Errorf("%s is directory", p) 39 | } 40 | } 41 | return "", err 42 | } 43 | 44 | func installService(name, desc string) error { 45 | exepath, err := exePath() 46 | if err != nil { 47 | return err 48 | } 49 | m, err := mgr.Connect() 50 | if err != nil { 51 | return err 52 | } 53 | defer m.Disconnect() 54 | s, err := m.OpenService(name) 55 | if err == nil { 56 | s.Close() 57 | return fmt.Errorf("service %s already exists", name) 58 | } 59 | s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started") 60 | if err != nil { 61 | return err 62 | } 63 | defer s.Close() 64 | err = eventlog.InstallAsEventCreate(name, eventlog.Error|eventlog.Warning|eventlog.Info) 65 | if err != nil { 66 | s.Delete() 67 | return fmt.Errorf("SetupEventLogSource() failed: %s", err) 68 | } 69 | return nil 70 | } 71 | 72 | func removeService(name string) error { 73 | m, err := mgr.Connect() 74 | if err != nil { 75 | return err 76 | } 77 | defer m.Disconnect() 78 | s, err := m.OpenService(name) 79 | if err != nil { 80 | return fmt.Errorf("service %s is not installed", name) 81 | } 82 | defer s.Close() 83 | err = s.Delete() 84 | if err != nil { 85 | return err 86 | } 87 | err = eventlog.Remove(name) 88 | if err != nil { 89 | return fmt.Errorf("RemoveEventLogSource() failed: %s", err) 90 | } 91 | return nil 92 | } 93 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/example/main.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 windows 6 | 7 | // Example service program that beeps. 8 | // 9 | // The program demonstrates how to create Windows service and 10 | // install / remove it on a computer. It also shows how to 11 | // stop / start / pause / continue any service, and how to 12 | // write to event log. It also shows how to use debug 13 | // facilities available in debug package. 14 | // 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "log" 20 | "os" 21 | "strings" 22 | 23 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc" 24 | ) 25 | 26 | func usage(errmsg string) { 27 | fmt.Fprintf(os.Stderr, 28 | "%s\n\n"+ 29 | "usage: %s \n"+ 30 | " where is one of\n"+ 31 | " install, remove, debug, start, stop, pause or continue.\n", 32 | errmsg, os.Args[0]) 33 | os.Exit(2) 34 | } 35 | 36 | func main() { 37 | const svcName = "myservice" 38 | 39 | isIntSess, err := svc.IsAnInteractiveSession() 40 | if err != nil { 41 | log.Fatalf("failed to determine if we are running in an interactive session: %v", err) 42 | } 43 | if !isIntSess { 44 | runService(svcName, false) 45 | return 46 | } 47 | 48 | if len(os.Args) < 2 { 49 | usage("no command specified") 50 | } 51 | 52 | cmd := strings.ToLower(os.Args[1]) 53 | switch cmd { 54 | case "debug": 55 | runService(svcName, true) 56 | return 57 | case "install": 58 | err = installService(svcName, "my service") 59 | case "remove": 60 | err = removeService(svcName) 61 | case "start": 62 | err = startService(svcName) 63 | case "stop": 64 | err = controlService(svcName, svc.Stop, svc.Stopped) 65 | case "pause": 66 | err = controlService(svcName, svc.Pause, svc.Paused) 67 | case "continue": 68 | err = controlService(svcName, svc.Continue, svc.Running) 69 | default: 70 | usage(fmt.Sprintf("invalid command %s", cmd)) 71 | } 72 | if err != nil { 73 | log.Fatalf("failed to %s %s: %v", cmd, svcName, err) 74 | } 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/example/manage.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc" 14 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/mgr" 15 | ) 16 | 17 | func startService(name string) error { 18 | m, err := mgr.Connect() 19 | if err != nil { 20 | return err 21 | } 22 | defer m.Disconnect() 23 | s, err := m.OpenService(name) 24 | if err != nil { 25 | return fmt.Errorf("could not access service: %v", err) 26 | } 27 | defer s.Close() 28 | err = s.Start("is", "manual-started") 29 | if err != nil { 30 | return fmt.Errorf("could not start service: %v", err) 31 | } 32 | return nil 33 | } 34 | 35 | func controlService(name string, c svc.Cmd, to svc.State) error { 36 | m, err := mgr.Connect() 37 | if err != nil { 38 | return err 39 | } 40 | defer m.Disconnect() 41 | s, err := m.OpenService(name) 42 | if err != nil { 43 | return fmt.Errorf("could not access service: %v", err) 44 | } 45 | defer s.Close() 46 | status, err := s.Control(c) 47 | if err != nil { 48 | return fmt.Errorf("could not send control=%d: %v", c, err) 49 | } 50 | timeout := time.Now().Add(10 * time.Second) 51 | for status.State != to { 52 | if timeout.Before(time.Now()) { 53 | return fmt.Errorf("timeout waiting for service to go to state=%d", to) 54 | } 55 | time.Sleep(300 * time.Millisecond) 56 | status, err = s.Query() 57 | if err != nil { 58 | return fmt.Errorf("could not retrieve service status: %v", err) 59 | } 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/example/service.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 windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc" 14 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/debug" 15 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc/eventlog" 16 | ) 17 | 18 | var elog debug.Log 19 | 20 | type myservice struct{} 21 | 22 | func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { 23 | const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue 24 | changes <- svc.Status{State: svc.StartPending} 25 | fasttick := time.Tick(500 * time.Millisecond) 26 | slowtick := time.Tick(2 * time.Second) 27 | tick := fasttick 28 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 29 | loop: 30 | for { 31 | select { 32 | case <-tick: 33 | beep() 34 | elog.Info(1, "beep") 35 | case c := <-r: 36 | switch c.Cmd { 37 | case svc.Interrogate: 38 | changes <- c.CurrentStatus 39 | // Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4 40 | time.Sleep(100 * time.Millisecond) 41 | changes <- c.CurrentStatus 42 | case svc.Stop, svc.Shutdown: 43 | break loop 44 | case svc.Pause: 45 | changes <- svc.Status{State: svc.Paused, Accepts: cmdsAccepted} 46 | tick = slowtick 47 | case svc.Continue: 48 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 49 | tick = fasttick 50 | default: 51 | elog.Error(1, fmt.Sprintf("unexpected control request #%d", c)) 52 | } 53 | } 54 | } 55 | changes <- svc.Status{State: svc.StopPending} 56 | return 57 | } 58 | 59 | func runService(name string, isDebug bool) { 60 | var err error 61 | if isDebug { 62 | elog = debug.New(name) 63 | } else { 64 | elog, err = eventlog.Open(name) 65 | if err != nil { 66 | return 67 | } 68 | } 69 | defer elog.Close() 70 | 71 | elog.Info(1, fmt.Sprintf("starting %s service", name)) 72 | run := svc.Run 73 | if isDebug { 74 | run = debug.Run 75 | } 76 | err = run(name, &myservice{}) 77 | if err != nil { 78 | elog.Error(1, fmt.Sprintf("%s service failed: %v", name, err)) 79 | return 80 | } 81 | elog.Info(1, fmt.Sprintf("%s service stopped", name)) 82 | } 83 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 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 windows 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/go12.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 windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/go13.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 windows 6 | // +build go1.3 7 | 8 | package svc 9 | 10 | import "unsafe" 11 | 12 | const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 | 14 | // Should be a built-in for unsafe.Pointer? 15 | func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 16 | return unsafe.Pointer(uintptr(p) + x) 17 | } 18 | 19 | // funcPC returns the entry PC of the function f. 20 | // It assumes that f is a func value. Otherwise the behavior is undefined. 21 | func funcPC(f interface{}) uintptr { 22 | return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) 23 | } 24 | 25 | // from sys_386.s and sys_amd64.s 26 | func servicectlhandler(ctl uint32) uintptr 27 | func servicemain(argc uint32, argv **uint16) 28 | 29 | func getServiceMain(r *uintptr) { 30 | *r = funcPC(servicemain) 31 | } 32 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/mgr/service.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 windows 6 | 7 | package mgr 8 | 9 | import ( 10 | "syscall" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 13 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows/svc" 14 | ) 15 | 16 | // TODO(brainman): Use EnumDependentServices to enumerate dependent services. 17 | 18 | // TODO(brainman): Use EnumServicesStatus to enumerate services in the specified service control manager database. 19 | 20 | // Service is used to access Windows service. 21 | type Service struct { 22 | Name string 23 | Handle windows.Handle 24 | } 25 | 26 | // Delete marks service s for deletion from the service control manager database. 27 | func (s *Service) Delete() error { 28 | return windows.DeleteService(s.Handle) 29 | } 30 | 31 | // Close relinquish access to the service s. 32 | func (s *Service) Close() error { 33 | return windows.CloseServiceHandle(s.Handle) 34 | } 35 | 36 | // Start starts service s. 37 | // args will be passed to svc.Handler.Execute. 38 | func (s *Service) Start(args ...string) error { 39 | var p **uint16 40 | if len(args) > 0 { 41 | vs := make([]*uint16, len(args)) 42 | for i, _ := range vs { 43 | vs[i] = syscall.StringToUTF16Ptr(args[i]) 44 | } 45 | p = &vs[0] 46 | } 47 | return windows.StartService(s.Handle, uint32(len(args)), p) 48 | } 49 | 50 | // Control sends state change request c to the servce s. 51 | func (s *Service) Control(c svc.Cmd) (svc.Status, error) { 52 | var t windows.SERVICE_STATUS 53 | err := windows.ControlService(s.Handle, uint32(c), &t) 54 | if err != nil { 55 | return svc.Status{}, err 56 | } 57 | return svc.Status{ 58 | State: svc.State(t.CurrentState), 59 | Accepts: svc.Accepted(t.ControlsAccepted), 60 | }, nil 61 | } 62 | 63 | // Query returns current status of service s. 64 | func (s *Service) Query() (svc.Status, error) { 65 | var t windows.SERVICE_STATUS 66 | err := windows.QueryServiceStatus(s.Handle, &t) 67 | if err != nil { 68 | return svc.Status{}, err 69 | } 70 | return svc.Status{ 71 | State: svc.State(t.CurrentState), 72 | Accepts: svc.Accepted(t.ControlsAccepted), 73 | }, nil 74 | } 75 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/security.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 windows 6 | 7 | package svc 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 13 | ) 14 | 15 | func allocSid(subAuth0 uint32) (*windows.SID, error) { 16 | var sid *windows.SID 17 | err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY, 18 | 1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return sid, nil 23 | } 24 | 25 | // IsAnInteractiveSession determines if calling process is running interactively. 26 | // It queries the process token for membership in the Interactive group. 27 | // http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s 28 | func IsAnInteractiveSession() (bool, error) { 29 | interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID) 30 | if err != nil { 31 | return false, err 32 | } 33 | defer windows.FreeSid(interSid) 34 | 35 | serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID) 36 | if err != nil { 37 | return false, err 38 | } 39 | defer windows.FreeSid(serviceSid) 40 | 41 | t, err := windows.OpenCurrentProcessToken() 42 | if err != nil { 43 | return false, err 44 | } 45 | defer t.Close() 46 | 47 | gs, err := t.GetTokenGroups() 48 | if err != nil { 49 | return false, err 50 | } 51 | p := unsafe.Pointer(&gs.Groups[0]) 52 | groups := (*[2 << 20]windows.SIDAndAttributes)(p)[:gs.GroupCount] 53 | for _, g := range groups { 54 | if windows.EqualSid(g.Sid, interSid) { 55 | return true, nil 56 | } 57 | if windows.EqualSid(g.Sid, serviceSid) { 58 | return false, nil 59 | } 60 | } 61 | return false, nil 62 | } 63 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/sys_386.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 windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL argc+0(FP), AX 10 | MOVL AX, ·sArgc(SB) 11 | MOVL argv+4(FP), AX 12 | MOVL AX, ·sArgv(SB) 13 | 14 | PUSHL BP 15 | PUSHL BX 16 | PUSHL SI 17 | PUSHL DI 18 | 19 | SUBL $12, SP 20 | 21 | MOVL ·sName(SB), AX 22 | MOVL AX, (SP) 23 | MOVL $·servicectlhandler(SB), AX 24 | MOVL AX, 4(SP) 25 | MOVL ·cRegisterServiceCtrlHandlerW(SB), AX 26 | MOVL SP, BP 27 | CALL AX 28 | MOVL BP, SP 29 | CMPL AX, $0 30 | JE exit 31 | MOVL AX, ·ssHandle(SB) 32 | 33 | MOVL ·goWaitsH(SB), AX 34 | MOVL AX, (SP) 35 | MOVL ·cSetEvent(SB), AX 36 | MOVL SP, BP 37 | CALL AX 38 | MOVL BP, SP 39 | 40 | MOVL ·cWaitsH(SB), AX 41 | MOVL AX, (SP) 42 | MOVL $-1, AX 43 | MOVL AX, 4(SP) 44 | MOVL ·cWaitForSingleObject(SB), AX 45 | MOVL SP, BP 46 | CALL AX 47 | MOVL BP, SP 48 | 49 | exit: 50 | ADDL $12, SP 51 | 52 | POPL DI 53 | POPL SI 54 | POPL BX 55 | POPL BP 56 | 57 | MOVL 0(SP), CX 58 | ADDL $12, SP 59 | JMP CX 60 | 61 | // I do not know why, but this seems to be the only way to call 62 | // ctlHandlerProc on Windows 7. 63 | 64 | // func servicectlhandler(ctl uint32) uintptr 65 | TEXT ·servicectlhandler(SB),7,$0 66 | MOVL ·ctlHandlerProc(SB), CX 67 | JMP CX 68 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/svc/sys_amd64.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 windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL CX, ·sArgc(SB) 10 | MOVL DX, ·sArgv(SB) 11 | 12 | SUBQ $32, SP // stack for the first 4 syscall params 13 | 14 | MOVQ ·sName(SB), CX 15 | MOVQ $·servicectlhandler(SB), DX 16 | MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX 17 | CALL AX 18 | CMPQ AX, $0 19 | JE exit 20 | MOVQ AX, ·ssHandle(SB) 21 | 22 | MOVQ ·goWaitsH(SB), CX 23 | MOVQ ·cSetEvent(SB), AX 24 | CALL AX 25 | 26 | MOVQ ·cWaitsH(SB), CX 27 | MOVQ $4294967295, DX 28 | MOVQ ·cWaitForSingleObject(SB), AX 29 | CALL AX 30 | 31 | exit: 32 | ADDQ $32, SP 33 | RET 34 | 35 | // I do not know why, but this seems to be the only way to call 36 | // ctlHandlerProc on Windows 7. 37 | 38 | // func servicectlhandler(ctl uint32) uintptr 39 | TEXT ·servicectlhandler(SB),7,$0 40 | MOVQ ·ctlHandlerProc(SB), AX 41 | JMP AX 42 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/syscall_test.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 windows 6 | 7 | package windows_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 13 | ) 14 | 15 | func testSetGetenv(t *testing.T, key, value string) { 16 | err := windows.Setenv(key, value) 17 | if err != nil { 18 | t.Fatalf("Setenv failed to set %q: %v", value, err) 19 | } 20 | newvalue, found := windows.Getenv(key) 21 | if !found { 22 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 23 | } 24 | if newvalue != value { 25 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 26 | } 27 | } 28 | 29 | func TestEnv(t *testing.T) { 30 | testSetGetenv(t, "TESTENV", "AVALUE") 31 | // make sure TESTENV gets set to "", not deleted 32 | testSetGetenv(t, "TESTENV", "") 33 | } 34 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/syscall_windows_test.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 | package windows_test 6 | 7 | import ( 8 | "io/ioutil" 9 | "os" 10 | "path/filepath" 11 | "syscall" 12 | "testing" 13 | 14 | "github.com/timeglass/glass/_vendor/golang.org/x/sys/windows" 15 | ) 16 | 17 | func TestWin32finddata(t *testing.T) { 18 | dir, err := ioutil.TempDir("", "go-build") 19 | if err != nil { 20 | t.Fatalf("failed to create temp directory: %v", err) 21 | } 22 | defer os.RemoveAll(dir) 23 | 24 | path := filepath.Join(dir, "long_name.and_extension") 25 | f, err := os.Create(path) 26 | if err != nil { 27 | t.Fatalf("failed to create %v: %v", path, err) 28 | } 29 | f.Close() 30 | 31 | type X struct { 32 | fd windows.Win32finddata 33 | got byte 34 | pad [10]byte // to protect ourselves 35 | 36 | } 37 | var want byte = 2 // it is unlikely to have this character in the filename 38 | x := X{got: want} 39 | 40 | pathp, _ := windows.UTF16PtrFromString(path) 41 | h, err := windows.FindFirstFile(pathp, &(x.fd)) 42 | if err != nil { 43 | t.Fatalf("FindFirstFile failed: %v", err) 44 | } 45 | err = windows.FindClose(h) 46 | if err != nil { 47 | t.Fatalf("FindClose failed: %v", err) 48 | } 49 | 50 | if x.got != want { 51 | t.Fatalf("memory corruption: want=%d got=%d", want, x.got) 52 | } 53 | } 54 | 55 | func abort(funcname string, err error) { 56 | panic(funcname + " failed: " + err.Error()) 57 | } 58 | 59 | func ExampleLoadLibrary() { 60 | h, err := windows.LoadLibrary("kernel32.dll") 61 | if err != nil { 62 | abort("LoadLibrary", err) 63 | } 64 | defer windows.FreeLibrary(h) 65 | proc, err := windows.GetProcAddress(h, "GetVersion") 66 | if err != nil { 67 | abort("GetProcAddress", err) 68 | } 69 | r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0) 70 | major := byte(r) 71 | minor := uint8(r >> 8) 72 | build := uint16(r >> 16) 73 | print("windows version ", major, ".", minor, " (Build ", build, ")\n") 74 | } 75 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/ztypes_windows_386.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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /_vendor/golang.org/x/sys/windows/ztypes_windows_amd64.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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /command/init.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Init struct { 14 | *command 15 | } 16 | 17 | func NewInit() *Init { 18 | return &Init{newCommand()} 19 | } 20 | 21 | func (c *Init) Name() string { 22 | return "init" 23 | } 24 | 25 | func (c *Init) Description() string { 26 | return fmt.Sprintf("Install hooks, start timer and pull measuremnets for the current repository, if hooks already exists they are truncated and rewritten.") 27 | } 28 | 29 | func (c *Init) Usage() string { 30 | return "Initiate Timeglass for the current repository" 31 | } 32 | 33 | func (c *Init) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Init) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Init) Run(ctx *cli.Context) error { 42 | c.Println("Writing version control hooks...") 43 | dir, err := os.Getwd() 44 | if err != nil { 45 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 46 | } 47 | 48 | vc, err := vcs.GetVCS(dir) 49 | if err != nil { 50 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 51 | } 52 | 53 | err = vc.Hook() 54 | if err != nil { 55 | return errwrap.Wrapf("Failed to write hooks: {{err}}", err) 56 | } 57 | 58 | c.Println("Hooks written!") 59 | err = NewStart().Run(ctx) 60 | if err != nil { 61 | return err 62 | } 63 | 64 | err = NewPull().Run(ctx) 65 | if err != nil { 66 | if errwrap.Contains(err, vcs.ErrNoRemote.Error()) { 67 | c.Println("No remote found, skipping pull") 68 | } else { 69 | return err 70 | } 71 | } 72 | 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /command/install.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | 8 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 9 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 10 | ) 11 | 12 | type Install struct { 13 | *command 14 | } 15 | 16 | func NewInstall() *Install { 17 | return &Install{newCommand()} 18 | } 19 | 20 | func (c *Install) Name() string { 21 | return "install" 22 | } 23 | 24 | func (c *Install) Description() string { 25 | return fmt.Sprintf("Runs the glass-daemon executable with both install and start. It requires admin privileges on windows and linux.") 26 | } 27 | 28 | func (c *Install) Usage() string { 29 | return "Install and start the background service" 30 | } 31 | 32 | func (c *Install) Flags() []cli.Flag { 33 | return []cli.Flag{} 34 | } 35 | 36 | func (c *Install) Action() func(ctx *cli.Context) { 37 | return c.command.Action(c.Run) 38 | } 39 | 40 | func (c *Install) Run(ctx *cli.Context) error { 41 | c.Println("Installing the Timeglass background service...") 42 | 43 | //attempt to install 44 | cmd := exec.Command("glass-daemon", "install") 45 | cmd.Stderr = os.Stderr 46 | cmd.Stdout = os.Stdout 47 | 48 | err := cmd.Run() 49 | if err != nil { 50 | return errwrap.Wrapf(fmt.Sprintf("Failed to install Daemon: {{err}}"), err) 51 | } 52 | 53 | c.Println("Starting the Timeglass background service...") 54 | 55 | //attempt to start 56 | cmd = exec.Command("glass-daemon", "start") 57 | cmd.Stderr = os.Stderr 58 | cmd.Stdout = os.Stdout 59 | err = cmd.Run() 60 | if err != nil { 61 | return errwrap.Wrapf(fmt.Sprintf("Failed to start Daemon: {{err}}"), err) 62 | } 63 | 64 | c.Println("Done!") 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /command/pause.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Pause struct { 14 | *command 15 | } 16 | 17 | func NewPause() *Pause { 18 | return &Pause{newCommand()} 19 | } 20 | 21 | func (c *Pause) Name() string { 22 | return "pause" 23 | } 24 | 25 | func (c *Pause) Description() string { 26 | return fmt.Sprintf("Pauses the timer, running 'glass start' or editing a file in the repository resumes the timer") 27 | } 28 | 29 | func (c *Pause) Usage() string { 30 | return "Manually Pause the timer, go get some coffee" 31 | } 32 | 33 | func (c *Pause) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Pause) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Pause) Run(ctx *cli.Context) error { 42 | dir, err := os.Getwd() 43 | if err != nil { 44 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 45 | } 46 | 47 | vc, err := vcs.GetVCS(dir) 48 | if err != nil { 49 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 50 | } 51 | 52 | c.Printf("Pausing timer...") 53 | 54 | client := NewClient() 55 | err = client.PauseTimer(vc.Root()) 56 | if err != nil { 57 | return errwrap.Wrapf(fmt.Sprintf("Failed to pause timer: {{err}}"), err) 58 | } 59 | 60 | c.Printf("Done!") 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /command/pull.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Pull struct { 14 | *command 15 | } 16 | 17 | func NewPull() *Pull { 18 | return &Pull{newCommand()} 19 | } 20 | 21 | func (c *Pull) Name() string { 22 | return "pull" 23 | } 24 | 25 | func (c *Pull) Description() string { 26 | return fmt.Sprintf("Pull the Timeglass notes branch from the remote repository. Provide the remote's name as the first argument, if no argument is provided it tries to pull from to the VCS default remote") 27 | } 28 | 29 | func (c *Pull) Usage() string { 30 | return "Pull measurements from a remote repository" 31 | } 32 | 33 | func (c *Pull) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Pull) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Pull) Run(ctx *cli.Context) error { 42 | dir, err := os.Getwd() 43 | if err != nil { 44 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 45 | } 46 | 47 | vc, err := vcs.GetVCS(dir) 48 | if err != nil { 49 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 50 | } 51 | 52 | remote := ctx.Args().First() 53 | if remote == "" { 54 | remote, err = vc.DefaultRemote() 55 | if err != nil { 56 | return errwrap.Wrapf("Failed to determine default remote: {{err}}", err) 57 | } 58 | } 59 | 60 | err = vc.Pull(remote) 61 | if err != nil { 62 | if err == vcs.ErrNoRemoteTimeData { 63 | c.Printf("Remote '%s' has no time data (yet), nothing to pull\n", remote) 64 | return nil 65 | } 66 | 67 | return errwrap.Wrapf("Failed to pull time data: {{err}}", err) 68 | } 69 | 70 | c.Println("Time data was pulled successfully") 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /command/punch.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "time" 8 | 9 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 10 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 11 | "github.com/timeglass/glass/_vendor/github.com/mattn/go-isatty" 12 | 13 | "github.com/timeglass/glass/vcs" 14 | ) 15 | 16 | type Punch struct { 17 | *command 18 | } 19 | 20 | func NewPunch() *Punch { 21 | return &Punch{newCommand()} 22 | } 23 | 24 | func (c *Punch) Name() string { 25 | return "punch" 26 | } 27 | 28 | func (c *Punch) Description() string { 29 | return fmt.Sprintf("Writes time to the metadata of the last commit, should be provided in the following format: 6h20m12s") 30 | } 31 | 32 | func (c *Punch) Usage() string { 33 | return "Manually register time spent on the last commit" 34 | } 35 | 36 | func (c *Punch) Flags() []cli.Flag { 37 | return []cli.Flag{} 38 | } 39 | 40 | func (c *Punch) Action() func(ctx *cli.Context) { 41 | return c.command.Action(c.Run) 42 | } 43 | 44 | func (c *Punch) Run(ctx *cli.Context) error { 45 | dir, err := os.Getwd() 46 | if err != nil { 47 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 48 | } 49 | 50 | var input string 51 | if isatty.IsTerminal(os.Stdin.Fd()) { 52 | c.Println("Reading input from argument...") 53 | input = ctx.Args().First() 54 | } else { 55 | c.Println("Reading input from Stdin...") 56 | bytes, err := ioutil.ReadAll(os.Stdin) 57 | if err != nil { 58 | return errwrap.Wrapf("Failed to read time from Stdin: {{err}}", err) 59 | } 60 | input = string(bytes) 61 | } 62 | 63 | if input == "" { 64 | return fmt.Errorf("Please provide the time you spent as the first argument") 65 | } 66 | 67 | t, err := time.ParseDuration(input) 68 | if err != nil { 69 | return errwrap.Wrapf(fmt.Sprintf("Failed to parse provided argument '%s' as a valid duration (e.g 1h2m10s): {{err}}", input), err) 70 | } 71 | 72 | //write the vcs 73 | vc, err := vcs.GetVCS(dir) 74 | if err != nil { 75 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 76 | } 77 | 78 | c.Printf("Persisting %s to version control...", t) 79 | err = vc.Persist(t) 80 | if err != nil { 81 | return errwrap.Wrapf("Failed to log time into VCS: {{err}}", err) 82 | } 83 | 84 | c.Println("Done!") 85 | return nil 86 | } 87 | -------------------------------------------------------------------------------- /command/reset.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Reset struct { 14 | *command 15 | } 16 | 17 | func NewReset() *Reset { 18 | return &Reset{newCommand()} 19 | } 20 | 21 | func (c *Reset) Name() string { 22 | return "reset" 23 | } 24 | 25 | func (c *Reset) Description() string { 26 | return fmt.Sprintf("Allows for setting the timer of the current repository to 0, this will discard the current measurement without saving") 27 | } 28 | 29 | func (c *Reset) Usage() string { 30 | return "Manually reset the current timer to 0s" 31 | } 32 | 33 | func (c *Reset) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Reset) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Reset) Run(ctx *cli.Context) error { 42 | dir, err := os.Getwd() 43 | if err != nil { 44 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 45 | } 46 | 47 | vc, err := vcs.GetVCS(dir) 48 | if err != nil { 49 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 50 | } 51 | 52 | c.Printf("Resetting timer to 0s...") 53 | 54 | client := NewClient() 55 | err = client.ResetTimer(vc.Root()) 56 | if err != nil { 57 | return errwrap.Wrapf(fmt.Sprintf("Failed to reset timer: {{err}}"), err) 58 | } 59 | 60 | c.Printf("Timer is reset!") 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /command/start.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Start struct { 14 | *command 15 | } 16 | 17 | func NewStart() *Start { 18 | return &Start{newCommand()} 19 | } 20 | 21 | func (c *Start) Name() string { 22 | return "start" 23 | } 24 | 25 | func (c *Start) Description() string { 26 | return fmt.Sprintf("Creates a new timer for the current repository, if it is currently paused the timer continues.") 27 | } 28 | 29 | func (c *Start) Usage() string { 30 | return "Manually start timer for the current repository" 31 | } 32 | 33 | func (c *Start) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Start) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Start) Run(ctx *cli.Context) error { 42 | dir, err := os.Getwd() 43 | if err != nil { 44 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 45 | } 46 | 47 | vc, err := vcs.GetVCS(dir) 48 | if err != nil { 49 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 50 | } 51 | 52 | c.Println("Starting timer...") 53 | 54 | client := NewClient() 55 | err = client.CreateTimer(vc.Root()) 56 | if err != nil { 57 | return errwrap.Wrapf("Failed to create timer: {{err}}", err) 58 | } 59 | 60 | c.Println("Timer started!") 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /command/stop.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | 10 | "github.com/timeglass/glass/vcs" 11 | ) 12 | 13 | type Stop struct { 14 | *command 15 | } 16 | 17 | func NewStop() *Stop { 18 | return &Stop{newCommand()} 19 | } 20 | 21 | func (c *Stop) Name() string { 22 | return "stop" 23 | } 24 | 25 | func (c *Stop) Description() string { 26 | return fmt.Sprintf("Timer for the current repository is removed and any measurements are discarde without being saved") 27 | } 28 | 29 | func (c *Stop) Usage() string { 30 | return "Shuts down the timer and discard any measurements" 31 | } 32 | 33 | func (c *Stop) Flags() []cli.Flag { 34 | return []cli.Flag{} 35 | } 36 | 37 | func (c *Stop) Action() func(ctx *cli.Context) { 38 | return c.command.Action(c.Run) 39 | } 40 | 41 | func (c *Stop) Run(ctx *cli.Context) error { 42 | dir, err := os.Getwd() 43 | if err != nil { 44 | return errwrap.Wrapf("Failed to fetch current working dir: {{err}}", err) 45 | } 46 | 47 | vc, err := vcs.GetVCS(dir) 48 | if err != nil { 49 | return errwrap.Wrapf("Failed to setup VCS: {{err}}", err) 50 | } 51 | 52 | c.Println("Deleting timer...") 53 | 54 | client := NewClient() 55 | err = client.DeleteTimer(vc.Root()) 56 | if err != nil { 57 | return errwrap.Wrapf(fmt.Sprintf("Failed to delete timer: {{err}}"), err) 58 | } 59 | 60 | c.Println("Timer deleted!") 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /command/types.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "io/ioutil" 5 | "log" 6 | "os" 7 | 8 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 9 | ) 10 | 11 | type command struct { 12 | *log.Logger 13 | } 14 | 15 | func newCommand() *command { 16 | return &command{ 17 | log.New(os.Stderr, "glass: ", log.Ltime), 18 | } 19 | } 20 | 21 | func (c *command) Action(fn func(c *cli.Context) error) func(ctx *cli.Context) { 22 | return func(ctx *cli.Context) { 23 | if ctx.GlobalBool("silent") { 24 | c.Logger = log.New(ioutil.Discard, "", 0) 25 | } 26 | 27 | err := fn(ctx) 28 | if err != nil { 29 | c.Fatal(err) 30 | return 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /command/uninstall.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | 8 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 9 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 10 | ) 11 | 12 | type Uninstall struct { 13 | *command 14 | } 15 | 16 | func NewUninstall() *Uninstall { 17 | return &Uninstall{newCommand()} 18 | } 19 | 20 | func (c *Uninstall) Name() string { 21 | return "uninstall" 22 | } 23 | 24 | func (c *Uninstall) Description() string { 25 | return fmt.Sprintf("Runs the glass-daemon executable with both stop and uninstall. It requires admin privileges on windows and linux.") 26 | } 27 | 28 | func (c *Uninstall) Usage() string { 29 | return "Stop and uninstall the background service" 30 | } 31 | 32 | func (c *Uninstall) Flags() []cli.Flag { 33 | return []cli.Flag{} 34 | } 35 | 36 | func (c *Uninstall) Action() func(ctx *cli.Context) { 37 | return c.command.Action(c.Run) 38 | } 39 | 40 | func (c *Uninstall) Run(ctx *cli.Context) error { 41 | c.Println("Stopping the Timeglass background service...") 42 | 43 | //attempt to stop 44 | cmd := exec.Command("glass-daemon", "stop") 45 | cmd.Stderr = os.Stderr 46 | cmd.Stdout = os.Stdout 47 | err := cmd.Run() 48 | if err != nil { 49 | return errwrap.Wrapf(fmt.Sprintf("Failed to stop Daemon: {{err}}"), err) 50 | } 51 | 52 | c.Println("Uninstalling the Timeglass background service...") 53 | 54 | //attempt to Uninstall 55 | cmd = exec.Command("glass-daemon", "uninstall") 56 | cmd.Stderr = os.Stderr 57 | cmd.Stdout = os.Stdout 58 | 59 | err = cmd.Run() 60 | if err != nil { 61 | return errwrap.Wrapf(fmt.Sprintf("Failed to Uninstall Daemon: {{err}}"), err) 62 | } 63 | 64 | c.Println("Done!") 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /docs/manual_installation.md: -------------------------------------------------------------------------------- 1 | # Manual Installation 2 | If you're on linx and/or like to have more control over how you install Timeglass we provide two ways for manual installation. If you have a 64bit architecture it is possible to just [download the prebuild binaries](https://github.com/timeglass/glass/releases/latest) and go to step 2, else you should build from source. 3 | 4 | ## Step 1: Building from Source (optional) 5 | 6 | First, you'll need install the go toolchain, instructions are [here](https://golang.org/doc/install). With Go installed you can simply run `go get` for _both_ binaries: 7 | 8 | ``` 9 | go get -u github.com/timeglass/glass 10 | go get -u github.com/timeglass/glass/glass-daemon 11 | ``` 12 | 13 | The source code will now be in your workspace and binaries are found in `$GOPATH/bin`. If you want to rebuild the binaries at a later point your can use the build script in the root of the project like so: `./make.bash build` 14 | 15 | ## Step 2: Placing the Binaries in your PATH 16 | 17 | If you downloaded the prebuild binaries you'll first need to unzip them and the copy the contents to a directory thats in your PATH (e.g. /usr/local/bin). If you build from source the binaries are probably already in your path, if not you must copy or link them there yourself. 18 | 19 | Check that this was done successfull by opening a new terminal window and running: `glass`. You should see all the *Timeglass* commands that are now available to you. 20 | 21 | 22 | ## Step 3: Installing the Background Service 23 | 24 | An important part of *Timeglass* is the monitoring of file system activity. For this it needs a small background process that is always running, lucky this service can be installed and started by running a single command: `glass install`, if the output is empty everything went as expected. 25 | 26 | _NOTE1: **On OSX and linux** this service is currently installed for all accounts and requires you to use sudo: `sudo glass install`_ 27 | 28 | _NOTE2: **On Windows** this service requires administration privileges so either 'run as Administrator' or log in as the Administrator and run the install command_ 29 | -------------------------------------------------------------------------------- /docs/query.md: -------------------------------------------------------------------------------- 1 | #Querying your Measurements 2 | _Timeglass_ attaches the time you spent as metadata to Git commits. This means you have the full power of Git at your disposal when it comes to querying. This also means that retrieving data will always consists of two steps: 3 | 4 | 1. First, select the work you're interested in by fetching a list of commit hashes (seperated by newlines) from Git using either `git rev-list` or `git log --pretty=%H`. 5 | 2. Second, pipe this list into `glass sum` to add all time entries together. It will output thet total time in a human readable format (e.g 1h59m10s) 6 | 7 | Because querying Git can be a science in it own right we included some common patterns below. Have question about your data that isn't answers by any of the examples below? [let us know](https://github.com/timeglass/glass/issues/9) 8 | 9 | ## How much time was spent on... 10 | 11 | ##### ...all commits since "yesterday"? 12 | git log --since="1 days ago" --pretty=%H | glass sum 13 | 14 | ##### ...all commits authored by "advanderveer" since "this morning"? 15 | git log --author=advanderveer --since="9am" --pretty=%H | glass sum 16 | 17 | ##### ...all commits since "May 20"? 18 | git log --since="may 20" --pretty=%H | glass sum 19 | 20 | ##### ...all commits up up to and including the current HEAD? 21 | git rev-list --all | glass sum 22 | 23 | ##### ...all commits authored by "advanderveer" since tag "v0.5.0"? 24 | git rev-list --author=advanderveer v0.5.0..HEAD | glass sum 25 | 26 | ##### ...all commits authored by "advanderveer" up to an including current HEAD? 27 | git rev-list --all --author=advanderveer | glass sum 28 | 29 | ##### ...commits in the current branch (given the current branch is not master)? 30 | git rev-list master..HEAD | glass sum 31 | 32 | ##### ...commits of the branch that were merged in commit "d2192a058" 33 | git rev-list d2192a058^..d2192a058 | glass sum 34 | 35 | NOTE: To show all merges that occured: `git log --merges --format=oneline` 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeglass/glass/e7312876059e35eea800b935df8b77a1ce2c9ec5/docs/screenshot.png -------------------------------------------------------------------------------- /docs/sharing.md: -------------------------------------------------------------------------------- 1 | #Sharing data with others 2 | Once you've recorded some time you might want to share your measurements with others. Timeglass uses git-notes and thus stores measurements as metadata in a seperate branch. By default, a "pre-push" hook is installed that automatically pushes your time measurements to the remote whenever you issues a `git push` for regular commits. 3 | 4 | If you disabled this behaviour in the [configuration](/docs/config.md) or if you want to push time data manually you can use: 5 | 6 | ``` 7 | glass push [remote] 8 | ``` 9 | _NOTE: Remote is optional and defaults to "origin" if not specified._ 10 | 11 | Similarly, if you wish to retrieve time measurements from the remote you can use the pull command. 12 | 13 | ``` 14 | glass pull [remote] 15 | ``` 16 | 17 | After you've pulled time data from the remote you can happely [query](/docs/query.md) it however you like. 18 | 19 | -------------------------------------------------------------------------------- /docs/uninstall.md: -------------------------------------------------------------------------------- 1 | # Uninstalling 2 | First off, if you're uninstalling because of some unexpectedly behaviour feel free to create [an issue](https://github.com/timeglass/glass/issues) that explains your problems. I love being in converstation with the user and create the best experience possible. 3 | 4 | That being said, you can do the following in order to remove Timeglass from a single repository: 5 | 6 | 1. Stop the timer by running `glass stop`. If its not running thats OK, you can skip this step. 7 | 2. Remove the git hooks timeglass creates from the `.git/hooks` directory of your repo. The following files are created during installation: 8 | 9 | - .git/hooks/prepare-commit-msg 10 | - .git/hooks/post-commit 11 | - .git/hooks/pre-push 12 | 13 | If you would like to continue and remove Timeglass from your system entirely, you can continue with the following: 14 | 15 | 1. Uninstall the background process by running `sudo glass uninstall`. If its not running thats OK, you can skip this step. Windows requires you to run this command as the administrator. 16 | 2. Remove the system-wide data directory: `/Library/Timeglass` on OSX, `/var/lib/timeglass` on Linux and `%PROGRAMDATA%\Timeglass` or `%ALLUSERSPROFILE%\Timeglass` on Windows. 17 | 3. Remove the binaries itself from were you installed them, they're named `glass` and `glass-daemon`. 18 | -------------------------------------------------------------------------------- /glass-daemon/errors.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "runtime" 6 | "strings" 7 | 8 | "github.com/timeglass/glass/_vendor/github.com/kardianos/service" 9 | ) 10 | 11 | // give some more extensive information about the nature 12 | // of a service control error 13 | func ReportServiceControlErrors(err error) { 14 | if strings.Contains(err.Error(), "Unknown action") { 15 | log.Fatalf("Given action is invalid, only supports: %q", service.ControlAction) 16 | } 17 | 18 | if runtime.GOOS == "windows" { 19 | if strings.Contains(err.Error(), "Access is denied") { 20 | log.Fatalf("Don't have permission for service controls, make sure you run this as the administrator") 21 | } 22 | } 23 | 24 | log.Fatalf("Failed to handle service control: %s", err) 25 | } 26 | -------------------------------------------------------------------------------- /glass-daemon/keeper_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "testing" 9 | "time" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestLoadSave(t *testing.T) { 15 | dir, err := ioutil.TempDir("", fmt.Sprintf("glass_keeper")) 16 | assert.NoError(t, err) 17 | 18 | k, err := NewKeeper(dir) 19 | assert.NoError(t, err) 20 | 21 | _, err = ioutil.ReadFile(filepath.Join(dir, "ledger.json")) 22 | assert.Error(t, err) 23 | assert.True(t, os.IsNotExist(err)) 24 | 25 | err = k.Load() 26 | assert.NoError(t, err) 27 | 28 | k.Save() 29 | data, err := ioutil.ReadFile(filepath.Join(dir, "ledger.json")) 30 | assert.NoError(t, err) 31 | assert.Contains(t, string(data), "timers") 32 | } 33 | 34 | func TestStartSave(t *testing.T) { 35 | dir, err := ioutil.TempDir("", "glass_keeper") 36 | assert.NoError(t, err) 37 | 38 | k, err := NewKeeper(dir) 39 | assert.NoError(t, err) 40 | 41 | go k.Start() 42 | defer k.Stop() 43 | 44 | <-time.After(time.Millisecond * 10) 45 | 46 | data, err := ioutil.ReadFile(filepath.Join(dir, "ledger.json")) 47 | assert.NoError(t, err) 48 | assert.Contains(t, string(data), "timers") 49 | } 50 | 51 | func TestAddRemoveTimer(t *testing.T) { 52 | dir, err := ioutil.TempDir("", "glass_keeper") 53 | assert.NoError(t, err) 54 | 55 | pdir := filepath.Join(dir, "project_x") 56 | err = os.Mkdir(pdir, 0755) 57 | assert.NoError(t, err) 58 | 59 | k, err := NewKeeper(dir) 60 | assert.NoError(t, err) 61 | 62 | go k.Start() 63 | defer k.Stop() 64 | 65 | timer, err := NewTimer(pdir) 66 | assert.NoError(t, err) 67 | 68 | //add new timer 69 | err = k.Add(timer) 70 | assert.NoError(t, err) 71 | assert.False(t, timer.IsPaused()) 72 | 73 | <-time.After(time.Millisecond * 40) 74 | data, err := ioutil.ReadFile(filepath.Join(dir, "ledger.json")) 75 | assert.NoError(t, err) 76 | assert.Contains(t, string(data), "latency") 77 | 78 | //remove the timer 79 | err = k.Remove(timer.Dir()) 80 | assert.NoError(t, err) 81 | 82 | <-time.After(time.Millisecond * 40) 83 | data, err = ioutil.ReadFile(filepath.Join(dir, "ledger.json")) 84 | assert.NoError(t, err) 85 | assert.NotContains(t, string(data), "latency") 86 | assert.True(t, timer.IsPaused()) 87 | } 88 | -------------------------------------------------------------------------------- /glass-daemon/logger.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "path/filepath" 7 | 8 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 9 | ) 10 | 11 | type Logger struct { 12 | file *os.File 13 | path string 14 | 15 | io.Writer 16 | } 17 | 18 | func NewLogger(w io.Writer) (*Logger, error) { 19 | l := &Logger{} 20 | path, err := SystemTimeglassPathCreateIfNotExist() 21 | if err != nil { 22 | return nil, errwrap.Wrapf("Failed to find Timeglass system path: {{err}}", err) 23 | } 24 | 25 | l.path = filepath.Join(path, "daemon.log") 26 | l.file, err = os.OpenFile(l.path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | l.Writer = io.MultiWriter(l.file, w) 32 | return l, nil 33 | } 34 | 35 | func (l *Logger) Path() string { 36 | return l.path 37 | } 38 | 39 | func (l *Logger) Close() error { 40 | return l.file.Close() 41 | } 42 | -------------------------------------------------------------------------------- /glass-daemon/paths.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "runtime" 8 | 9 | "github.com/timeglass/glass/_vendor/github.com/hashicorp/errwrap" 10 | ) 11 | 12 | // returns the system path were all 13 | // timeglass related data is stored for 14 | // this machine 15 | func SystemTimeglassPath() (string, error) { 16 | if runtime.GOOS == "windows" { 17 | //@see http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx 18 | //win 7/vista 19 | if path := os.Getenv("PROGRAMDATA"); path != "" { 20 | return filepath.Join(path, "Timeglass"), nil 21 | } else if path = os.Getenv("ALLUSERSPROFILE"); path != "" { 22 | return filepath.Join(path, "Timeglass"), nil 23 | } 24 | 25 | return "", fmt.Errorf("Expected environmnet variable 'PROGRAMDATA' or 'ALLUSERPROFILE'") 26 | } else if runtime.GOOS == "darwin" { 27 | //osx we can actually create user specific services, and as such, store data for the user specifically 28 | return filepath.Join("/", "Library", "Timeglass"), nil 29 | } else if runtime.GOOS == "linux" { 30 | return filepath.Join("/var/lib", "timeglass"), nil 31 | } 32 | 33 | return "", fmt.Errorf("Operating system is not yet supported") 34 | } 35 | 36 | func SystemTimeglassPathCreateIfNotExist() (string, error) { 37 | path, err := SystemTimeglassPath() 38 | if err != nil { 39 | return "", err 40 | } 41 | 42 | err = os.MkdirAll(path, 0755) 43 | if err != nil { 44 | return "", errwrap.Wrapf(fmt.Sprintf("Failed to create Timeglass system dir '%s': {{err}}", path), err) 45 | } 46 | 47 | return path, nil 48 | } 49 | -------------------------------------------------------------------------------- /glass-daemon/server_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "net/http" 7 | "net/http/httptest" 8 | "net/url" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestApiRoot(t *testing.T) { 15 | dir, err := ioutil.TempDir("", fmt.Sprintf("glass_keeper")) 16 | assert.NoError(t, err) 17 | 18 | k, err := NewKeeper(dir) 19 | assert.NoError(t, err) 20 | 21 | go k.Start() 22 | defer k.Stop() 23 | 24 | svr, err := NewServer(":0", k) 25 | assert.NoError(t, err) 26 | 27 | r, err := http.NewRequest("GET", "/api/", nil) 28 | assert.NoError(t, err) 29 | 30 | w := httptest.NewRecorder() 31 | svr.api(w, r) 32 | 33 | assert.Contains(t, w.Body.String(), "version") 34 | assert.Contains(t, w.Body.String(), "timers") 35 | } 36 | 37 | func TestCreateInfoRemoveTimer(t *testing.T) { 38 | dir, err := ioutil.TempDir("", fmt.Sprintf("glass_keeper")) 39 | assert.NoError(t, err) 40 | 41 | k, err := NewKeeper(dir) 42 | assert.NoError(t, err) 43 | 44 | go k.Start() 45 | defer k.Stop() 46 | 47 | svr, err := NewServer(":0", k) 48 | assert.NoError(t, err) 49 | 50 | params := &url.Values{ 51 | "dir": []string{dir}, 52 | } 53 | 54 | //Create 55 | r, err := http.NewRequest("GET", "/api/timers.create?"+params.Encode(), nil) 56 | assert.NoError(t, err) 57 | w := httptest.NewRecorder() 58 | svr.timersCreate(w, r) 59 | 60 | assert.Equal(t, http.StatusCreated, w.Code) 61 | 62 | //Info 63 | r, err = http.NewRequest("GET", "/api/timers.info?"+params.Encode(), nil) 64 | assert.NoError(t, err) 65 | w = httptest.NewRecorder() 66 | svr.timersInfo(w, r) 67 | 68 | assert.Equal(t, http.StatusOK, w.Code) 69 | assert.Contains(t, w.Body.String(), "latency") 70 | 71 | //Delete 72 | r, err = http.NewRequest("GET", "/api/timers.delete?"+params.Encode(), nil) 73 | assert.NoError(t, err) 74 | w = httptest.NewRecorder() 75 | svr.timersDelete(w, r) 76 | 77 | assert.Equal(t, http.StatusNoContent, w.Code) 78 | 79 | //Info 80 | r, err = http.NewRequest("GET", "/api/timers.info?"+params.Encode(), nil) 81 | assert.NoError(t, err) 82 | w = httptest.NewRecorder() 83 | svr.timersInfo(w, r) 84 | 85 | assert.Equal(t, http.StatusInternalServerError, w.Code) 86 | } 87 | -------------------------------------------------------------------------------- /glass-daemon/util_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "testing" 9 | "time" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func setupTestProject(t *testing.T) string { 15 | dir, err := ioutil.TempDir("", fmt.Sprintf("glass_keeper")) 16 | assert.NoError(t, err) 17 | 18 | pdir := filepath.Join(dir, "project_x") 19 | err = os.Mkdir(pdir, 0755) 20 | assert.NoError(t, err) 21 | 22 | err = ioutil.WriteFile(filepath.Join(pdir, "timeglass.json"), []byte(`{"mbu": "5ms"}`), 0755) 23 | assert.NoError(t, err) 24 | 25 | <-time.After(time.Millisecond * 20) 26 | return pdir 27 | } 28 | 29 | func writeProjectFile(t *testing.T, dir, path, content string) { 30 | err := ioutil.WriteFile(filepath.Join(dir, path), []byte(content), 0755) 31 | assert.NoError(t, err) 32 | } 33 | 34 | func moveProjectFile(t *testing.T, from, to string) { 35 | err := os.Rename(from, to) 36 | assert.NoError(t, err) 37 | } 38 | 39 | func assertTime(t *testing.T, timer *Timer, expected time.Duration) { 40 | assert.InDelta(t, float64(expected), float64(timer.Time()), float64(timer.timerData.MBU+time.Millisecond)) 41 | } 42 | -------------------------------------------------------------------------------- /installers/msi/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj -------------------------------------------------------------------------------- /installers/msi/glass.wixproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets 4 | Timeglass Setup (x64) 5 | Package 6 | false 7 | bin\ 8 | 9 | 10 | 11 | 12 | x64 13 | 3.5 14 | {3f8a1956-3256-46e1-8477-a99cb06b6c23} 15 | 2.0 16 | 17 | obj\ 18 | False 19 | True 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /installers/msi/make.bash: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | cp ../../bin/windows_amd64/* ./ 4 | 5 | VERSION=$(cat ../../VERSION) 6 | sed -i "s/\sVersion=".*"/ Version=\"$VERSION\"/" Product.wxs 7 | 8 | $WINDIR/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe glass.wixproject -------------------------------------------------------------------------------- /installers/pkg/.gitignore: -------------------------------------------------------------------------------- 1 | glass-daemon/* 2 | glass/* 3 | bin/* 4 | 5 | *.pkg -------------------------------------------------------------------------------- /installers/pkg/distribution.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | glass.pkg 17 | 18 | 19 | 20 | glass-daemon.pkg 21 | -------------------------------------------------------------------------------- /installers/pkg/make.bash: -------------------------------------------------------------------------------- 1 | VERSION=`cat ../../VERSION` 2 | echo "Copying version $VERSION binaries..." 3 | 4 | mkdir -p ./glass-daemon 5 | cp ../../bin/darwin_amd64/glass-daemon ./glass-daemon 6 | mkdir -p ./glass 7 | cp ../../bin/darwin_amd64/glass ./glass 8 | 9 | echo "Building daemon component package..." 10 | pkgbuild --root ./glass-daemon \ 11 | --identifier com.timeglass.glass-daemon \ 12 | --install-location /Applications/Timeglass \ 13 | --scripts ./scripts/glass-daemon \ 14 | --version $VERSION \ 15 | glass-daemon.pkg 16 | 17 | echo "Building cli component package..." 18 | pkgbuild --root ./glass \ 19 | --identifier com.timeglass.glass \ 20 | --install-location /Applications/Timeglass \ 21 | --scripts ./scripts/glass \ 22 | --version $VERSION \ 23 | glass.pkg 24 | 25 | echo "Building product...." 26 | productbuild --distribution distribution.xml \ 27 | Timeglass.pkg 28 | 29 | echo "Signing product..." 30 | productsign --sign "Developer ID Installer: A.L. VEER" Timeglass.pkg 'bin/Timeglass Setup (x64).pkg' -------------------------------------------------------------------------------- /installers/pkg/scripts/glass-daemon/postinstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec > /tmp/glass-install.log 3 | env 4 | 5 | # DSTROOT=/Users/advanderveer/Documents/Projects/go/bin 6 | DAEMON=$DSTROOT/glass-daemon 7 | # DAEMON=/Users/advanderveer/Documents/Projects/go/bin/glass-daemon 8 | 9 | #remove cli symlink if it exists already 10 | if [ -f /usr/local/bin/glass-daemon ]; then 11 | echo "Removing old daemon symlink..." 12 | rm /usr/local/bin/glass-daemon 13 | fi 14 | 15 | #create cli symlink 16 | echo "Adding new daemon symlink..." 17 | ln -s $DSTROOT/glass-daemon /usr/local/bin/glass-daemon 18 | chmod +x /usr/local/bin/glass-daemon 19 | 20 | # unload agent if its loadedecho "aaaaa" > /tmp/cccccc 21 | if /bin/launchctl list | grep -q "com.timeglass.glass-daemon" 22 | then 23 | echo "Stopping and uninstalling old daemon..." 24 | $DSTROOT/glass-daemon stop 25 | $DSTROOT/glass-daemon uninstall 26 | fi 27 | 28 | #install 29 | echo "Installing and starting new daemon..." 30 | $DSTROOT/glass-daemon install 31 | $DSTROOT/glass-daemon start 32 | echo "Done!" -------------------------------------------------------------------------------- /installers/pkg/scripts/glass/postinstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #remove cli symlink if it exists already 4 | if [ -f /usr/local/bin/glass ]; then 5 | rm /usr/local/bin/glass 6 | fi 7 | 8 | #create cli symlink 9 | ln -s $DSTROOT/glass /usr/local/bin/glass 10 | chmod +x /usr/local/bin/glass -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/timeglass/glass/_vendor/github.com/codegangsta/cli" 8 | 9 | "github.com/timeglass/glass/command" 10 | ) 11 | 12 | type Command interface { 13 | Name() string 14 | Description() string 15 | Usage() string 16 | Run(c *cli.Context) error 17 | Action() func(ctx *cli.Context) 18 | Flags() []cli.Flag 19 | } 20 | 21 | var Version = "0.0.0" 22 | var Build = "gobuild" 23 | 24 | func main() { 25 | app := cli.NewApp() 26 | app.Author = "Ad van der Veer" 27 | app.Email = "advanderveer@gmail.com" 28 | app.Name = "Timeglass" 29 | app.Usage = "Automated time tracking for code repositories" 30 | app.Version = fmt.Sprintf("%s (%s)", Version, Build) 31 | 32 | app.Flags = []cli.Flag{ 33 | cli.BoolFlag{ 34 | Name: "silent,s", 35 | Usage: "supress all output over Stderr", 36 | }, 37 | } 38 | 39 | cmds := []Command{ 40 | command.NewInstall(), //install daemon and start service 41 | command.NewUninstall(), //stop daemon and uninstall service 42 | command.NewInit(), //write hooks, create timer and pull time data 43 | command.NewStart(), //create timer for current directory, start measuring 44 | command.NewPause(), //pause timer for the current directory, restart on file activity 45 | command.NewStatus(), //fetch info of the timer for the current directory 46 | command.NewReset(), //reset the timer to 0s 47 | command.NewStop(), //remove timer for current directory, discarding meaurement 48 | command.NewPush(), //push notes branch to remote 49 | command.NewPull(), //pull notes branch from remote 50 | command.NewPunch(), //persist time measurement to current HEAD commit 51 | command.NewSum(), //sum total time of each commit given 52 | } 53 | 54 | for _, c := range cmds { 55 | app.Commands = append(app.Commands, cli.Command{ 56 | Name: c.Name(), 57 | Usage: c.Usage(), 58 | Action: c.Action(), 59 | Description: c.Description(), 60 | Flags: c.Flags(), 61 | }) 62 | } 63 | 64 | app.Run(os.Args) 65 | } 66 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // This is the functional testing suite, 4 | // it goes through serveral complete usage scenarios 5 | 6 | import ( 7 | "testing" 8 | ) 9 | 10 | // executes "getting started" steps: 11 | // - download and unzip to PATH 12 | // - install daemon 13 | // - write configuration file to repo 14 | // - create git repo and init glass 15 | // - wait for a timeout 16 | // - run status and assert measured time 17 | // - wakup with a file edit 18 | // - run status again and assert increased time 19 | 20 | func TestGettingStartedSteps(t *testing.T) { 21 | 22 | //@todo implement 23 | 24 | } 25 | -------------------------------------------------------------------------------- /timeglass.json: -------------------------------------------------------------------------------- 1 | { 2 | "MBU": "1m10s", 3 | "commit_message": " [spent {{.}}]", 4 | "auto_push": true 5 | } 6 | -------------------------------------------------------------------------------- /vcs/vcs.go: -------------------------------------------------------------------------------- 1 | package vcs 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strings" 7 | "time" 8 | ) 9 | 10 | var ErrNoRemote = errors.New("Version control has no remote") 11 | var ErrNoRemoteTimeData = errors.New("Remote doesn't have any time data") 12 | var ErrNoLocalTimeData = errors.New("Local clone doesn't have any time data") 13 | var ErrNoCommitTimeData = errors.New("Commit doesn't have any time data") 14 | 15 | type VCS interface { 16 | Name() string 17 | Root() string 18 | IsAvailable() bool 19 | Hook() error 20 | Push(string, string) error 21 | Pull(string) error 22 | DefaultRemote() (string, error) 23 | Persist(time.Duration) error 24 | Show(string) (TimeData, error) 25 | } 26 | 27 | type TimeData interface { 28 | Total() time.Duration 29 | } 30 | 31 | func GetVCS(dir string) (VCS, error) { 32 | var supported = []VCS{ 33 | NewGit(dir), 34 | } 35 | 36 | var checked = []string{} 37 | for _, vcs := range supported { 38 | if vcs.IsAvailable() { 39 | return vcs, nil 40 | } 41 | checked = append(checked, vcs.Name()) 42 | } 43 | 44 | return nil, fmt.Errorf("No supported Version Control System found in '%s', checked for: %s", dir, strings.Join(checked, ",")) 45 | } 46 | --------------------------------------------------------------------------------