newtmgr - revendor dependencies.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/264add5a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/264add5a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/264add5a Branch: refs/heads/1_0_0_b1_dev Commit: 264add5aefa47f9d947a2fac963f1f36d452569d Parents: 6da8e19 Author: Christopher Collins <[email protected]> Authored: Tue Nov 22 11:19:11 2016 -0800 Committer: Christopher Collins <[email protected]> Committed: Tue Nov 22 11:22:10 2016 -0800 ---------------------------------------------------------------------- newtmgr/Godeps/Godeps.json | 30 +- .../github.com/Sirupsen/logrus/.travis.yml | 9 +- .../vendor/github.com/Sirupsen/logrus/README.md | 5 + .../Sirupsen/logrus/json_formatter.go | 34 +- .../Sirupsen/logrus/text_formatter.go | 11 +- .../vendor/github.com/dustin/go-coap/.gitignore | 4 + .../vendor/github.com/dustin/go-coap/LICENSE | 20 + .../github.com/dustin/go-coap/README.markdown | 8 + .../vendor/github.com/dustin/go-coap/client.go | 66 ++ .../vendor/github.com/dustin/go-coap/message.go | 640 +++++++++++++++++++ .../github.com/dustin/go-coap/messagetcp.go | 69 ++ .../vendor/github.com/dustin/go-coap/server.go | 102 +++ .../vendor/github.com/dustin/go-coap/servmux.go | 94 +++ .../mitchellh/mapstructure/mapstructure.go | 8 - newtmgr/vendor/github.com/spf13/cast/caste.go | 1 + .../vendor/github.com/spf13/cobra/command.go | 22 +- .../vendor/github.com/spf13/pflag/.travis.yml | 3 +- newtmgr/vendor/github.com/spf13/pflag/flag.go | 4 +- .../golang.org/x/sys/unix/syscall_linux.go | 3 +- .../golang.org/x/sys/unix/zsyscall_linux_386.go | 15 +- .../x/sys/unix/zsyscall_linux_amd64.go | 15 +- .../golang.org/x/sys/unix/zsyscall_linux_arm.go | 15 +- .../x/sys/unix/zsyscall_linux_arm64.go | 15 +- .../x/sys/unix/zsyscall_linux_mips64.go | 15 +- .../x/sys/unix/zsyscall_linux_mips64le.go | 15 +- .../x/sys/unix/zsyscall_linux_ppc64.go | 15 +- .../x/sys/unix/zsyscall_linux_ppc64le.go | 15 +- .../x/sys/unix/zsyscall_linux_s390x.go | 21 +- .../x/sys/unix/zsyscall_linux_sparc64.go | 21 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 11 +- .../vendor/mynewt.apache.org/newt/util/util.go | 51 +- .../mynewt.apache.org/newt/yaml/decode.go | 2 +- 32 files changed, 1273 insertions(+), 86 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/Godeps/Godeps.json ---------------------------------------------------------------------- diff --git a/newtmgr/Godeps/Godeps.json b/newtmgr/Godeps/Godeps.json index 9619ad5..b2571e8 100644 --- a/newtmgr/Godeps/Godeps.json +++ b/newtmgr/Godeps/Godeps.json @@ -5,8 +5,12 @@ "Deps": [ { "ImportPath": "github.com/Sirupsen/logrus", - "Comment": "v0.10.0-38-g3ec0642", - "Rev": "3ec0642a7fb6488f65b06f9040adc67e3990296a" + "Comment": "v0.11.0-10-ga437dfd", + "Rev": "a437dfd2463eaedbec3dfe443e477d3b0a810b3f" + }, + { + "ImportPath": "github.com/dustin/go-coap", + "Rev": "75229d0ed26e3f08048d9220408dff03ef604f75" }, { "ImportPath": "github.com/inconshreveable/mousetrap", @@ -31,7 +35,7 @@ }, { "ImportPath": "github.com/mitchellh/mapstructure", - "Rev": "a6ef2f080c66d0a2e94e97cf74f80f772855da63" + "Rev": "f3009df150dadf309fdee4a54ed65c124afad715" }, { "ImportPath": "github.com/runtimeinc/gatt", @@ -67,11 +71,11 @@ }, { "ImportPath": "github.com/spf13/cast", - "Rev": "2580bc98dc0e62908119e4737030cc2fdfc45e4c" + "Rev": "24b6558033ffe202bf42f0f3b870dcc798dd2ba8" }, { "ImportPath": "github.com/spf13/cobra", - "Rev": "ec2fe7859914a5106dcab4e7901633d959bfc2f4" + "Rev": "9495bc009a56819bdb0ddbc1a373e29c140bc674" }, { "ImportPath": "github.com/spf13/jwalterweatherman", @@ -79,7 +83,7 @@ }, { "ImportPath": "github.com/spf13/pflag", - "Rev": "bf8481a6aebc13a8aab52e699ffe2e79771f5a3f" + "Rev": "5ccb023bc27df288a957c5e994cd44fd19619465" }, { "ImportPath": "github.com/tarm/serial", @@ -91,7 +95,7 @@ }, { "ImportPath": "golang.org/x/sys/unix", - "Rev": "9bb9f0998d48b31547d975974935ae9b48c7a03c" + "Rev": "b699b7032584f0953262cb2788a0ca19bb494703" }, { "ImportPath": "gopkg.in/fsnotify.v1", @@ -100,18 +104,18 @@ }, { "ImportPath": "mynewt.apache.org/newt/util", - "Comment": "pre_sterly_refactor-55-g1e49885", - "Rev": "1e49885a484a8975f6269d098d1469e0c31be19e" + "Comment": "pre_sterly_refactor-137-gfcecea4", + "Rev": "fcecea4b13ab467168e936a51ef01695833644d8" }, { "ImportPath": "mynewt.apache.org/newt/viper", - "Comment": "pre_sterly_refactor-55-g1e49885", - "Rev": "1e49885a484a8975f6269d098d1469e0c31be19e" + "Comment": "pre_sterly_refactor-137-gfcecea4", + "Rev": "fcecea4b13ab467168e936a51ef01695833644d8" }, { "ImportPath": "mynewt.apache.org/newt/yaml", - "Comment": "pre_sterly_refactor-55-g1e49885", - "Rev": "1e49885a484a8975f6269d098d1469e0c31be19e" + "Comment": "pre_sterly_refactor-137-gfcecea4", + "Rev": "fcecea4b13ab467168e936a51ef01695833644d8" } ] } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/Sirupsen/logrus/.travis.yml ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/Sirupsen/logrus/.travis.yml b/newtmgr/vendor/github.com/Sirupsen/logrus/.travis.yml index dee4eb2..ec7dd78 100644 --- a/newtmgr/vendor/github.com/Sirupsen/logrus/.travis.yml +++ b/newtmgr/vendor/github.com/Sirupsen/logrus/.travis.yml @@ -1,10 +1,9 @@ language: go go: - - 1.3 - - 1.4 - - 1.5 - 1.6 + - 1.7 - tip install: - - go get -t ./... -script: GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v ./... + - go get -t $(go list ./... | grep -v /examples/) +script: + - GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v $(go list ./... | grep -v /examples/) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/Sirupsen/logrus/README.md ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/Sirupsen/logrus/README.md b/newtmgr/vendor/github.com/Sirupsen/logrus/README.md index ab48929..f9cfb0a 100644 --- a/newtmgr/vendor/github.com/Sirupsen/logrus/README.md +++ b/newtmgr/vendor/github.com/Sirupsen/logrus/README.md @@ -228,8 +228,12 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v | [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | | [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| | [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| +| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)| | [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | +| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash | | [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) | +| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) | +| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) | #### Level logging @@ -367,6 +371,7 @@ entries. It should not be a feature of the application-level logger. | Tool | Description | | ---- | ----------- | |[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.| +|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper arround Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) | #### Testing http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/Sirupsen/logrus/json_formatter.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/Sirupsen/logrus/json_formatter.go b/newtmgr/vendor/github.com/Sirupsen/logrus/json_formatter.go index 2ad6dc5..f3729bf 100644 --- a/newtmgr/vendor/github.com/Sirupsen/logrus/json_formatter.go +++ b/newtmgr/vendor/github.com/Sirupsen/logrus/json_formatter.go @@ -5,9 +5,37 @@ import ( "fmt" ) +type fieldKey string +type FieldMap map[fieldKey]string + +const ( + FieldKeyMsg = "msg" + FieldKeyLevel = "level" + FieldKeyTime = "time" +) + +func (f FieldMap) resolve(key fieldKey) string { + if k, ok := f[key]; ok { + return k + } + + return string(key) +} + type JSONFormatter struct { // TimestampFormat sets the format used for marshaling timestamps. TimestampFormat string + + // FieldMap allows users to customize the names of keys for various fields. + // As an example: + // formatter := &JSONFormatter{ + // FieldMap: FieldMap{ + // FieldKeyTime: "@timestamp", + // FieldKeyLevel: "@level", + // FieldKeyLevel: "@message", + // }, + // } + FieldMap FieldMap } func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { @@ -29,9 +57,9 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { timestampFormat = DefaultTimestampFormat } - data["time"] = entry.Time.Format(timestampFormat) - data["msg"] = entry.Message - data["level"] = entry.Level.String() + data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) + data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message + data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() serialized, err := json.Marshal(data) if err != nil { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/Sirupsen/logrus/text_formatter.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/Sirupsen/logrus/text_formatter.go b/newtmgr/vendor/github.com/Sirupsen/logrus/text_formatter.go index cce61f2..9114b3c 100644 --- a/newtmgr/vendor/github.com/Sirupsen/logrus/text_formatter.go +++ b/newtmgr/vendor/github.com/Sirupsen/logrus/text_formatter.go @@ -122,7 +122,8 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin } for _, k := range keys { v := entry.Data[k] - fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) + fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) + f.appendValue(b, v) } } @@ -142,7 +143,11 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf b.WriteString(key) b.WriteByte('=') + f.appendValue(b, value) + b.WriteByte(' ') +} +func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { switch value := value.(type) { case string: if !needsQuoting(value) { @@ -155,11 +160,9 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf if !needsQuoting(errmsg) { b.WriteString(errmsg) } else { - fmt.Fprintf(b, "%q", value) + fmt.Fprintf(b, "%q", errmsg) } default: fmt.Fprint(b, value) } - - b.WriteByte(' ') } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/.gitignore ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/.gitignore b/newtmgr/vendor/github.com/dustin/go-coap/.gitignore new file mode 100644 index 0000000..1b76f80 --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/.gitignore @@ -0,0 +1,4 @@ +#* +*~ +/example/server/server +/example/subserver/subserver http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/LICENSE ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/LICENSE b/newtmgr/vendor/github.com/dustin/go-coap/LICENSE new file mode 100644 index 0000000..1ddd439 --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Dustin Sallings + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/README.markdown ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/README.markdown b/newtmgr/vendor/github.com/dustin/go-coap/README.markdown new file mode 100644 index 0000000..748fe6f --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/README.markdown @@ -0,0 +1,8 @@ +# Constrained Application Protocol Client and Server for go + +You can read more about CoAP in [RFC 7252][coap]. I also did +some preliminary work on `SUBSCRIBE` support from +[an early draft][shelby]. + +[shelby]: http://tools.ietf.org/html/draft-shelby-core-coap-01 +[coap]: http://tools.ietf.org/html/rfc7252 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/client.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/client.go b/newtmgr/vendor/github.com/dustin/go-coap/client.go new file mode 100644 index 0000000..95cf03f --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/client.go @@ -0,0 +1,66 @@ +package coap + +import ( + "net" + "time" +) + +const ( + // ResponseTimeout is the amount of time to wait for a + // response. + ResponseTimeout = time.Second * 2 + // ResponseRandomFactor is a multiplier for response backoff. + ResponseRandomFactor = 1.5 + // MaxRetransmit is the maximum number of times a message will + // be retransmitted. + MaxRetransmit = 4 +) + +// Conn is a CoAP client connection. +type Conn struct { + conn *net.UDPConn + buf []byte +} + +// Dial connects a CoAP client. +func Dial(n, addr string) (*Conn, error) { + uaddr, err := net.ResolveUDPAddr(n, addr) + if err != nil { + return nil, err + } + + s, err := net.DialUDP("udp", nil, uaddr) + if err != nil { + return nil, err + } + + return &Conn{s, make([]byte, maxPktLen)}, nil +} + +// Send a message. Get a response if there is one. +func (c *Conn) Send(req Message) (*Message, error) { + err := Transmit(c.conn, nil, req) + if err != nil { + return nil, err + } + + if !req.IsConfirmable() { + return nil, nil + } + + rv, err := Receive(c.conn, c.buf) + if err != nil { + return nil, err + } + + return &rv, nil +} + +// Receive a message. +func (c *Conn) Receive() (*Message, error) { + rv, err := Receive(c.conn, c.buf) + if err != nil { + return nil, err + } + return &rv, nil +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/message.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/message.go b/newtmgr/vendor/github.com/dustin/go-coap/message.go new file mode 100644 index 0000000..c70ac8a --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/message.go @@ -0,0 +1,640 @@ +package coap + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "reflect" + "sort" + "strings" +) + +// COAPType represents the message type. +type COAPType uint8 + +const ( + // Confirmable messages require acknowledgements. + Confirmable COAPType = 0 + // NonConfirmable messages do not require acknowledgements. + NonConfirmable COAPType = 1 + // Acknowledgement is a message indicating a response to confirmable message. + Acknowledgement COAPType = 2 + // Reset indicates a permanent negative acknowledgement. + Reset COAPType = 3 +) + +var typeNames = [256]string{ + Confirmable: "Confirmable", + NonConfirmable: "NonConfirmable", + Acknowledgement: "Acknowledgement", + Reset: "Reset", +} + +func init() { + for i := range typeNames { + if typeNames[i] == "" { + typeNames[i] = fmt.Sprintf("Unknown (0x%x)", i) + } + } +} + +func (t COAPType) String() string { + return typeNames[t] +} + +// COAPCode is the type used for both request and response codes. +type COAPCode uint8 + +// Request Codes +const ( + GET COAPCode = 1 + POST COAPCode = 2 + PUT COAPCode = 3 + DELETE COAPCode = 4 +) + +// Response Codes +const ( + Created COAPCode = 65 + Deleted COAPCode = 66 + Valid COAPCode = 67 + Changed COAPCode = 68 + Content COAPCode = 69 + BadRequest COAPCode = 128 + Unauthorized COAPCode = 129 + BadOption COAPCode = 130 + Forbidden COAPCode = 131 + NotFound COAPCode = 132 + MethodNotAllowed COAPCode = 133 + NotAcceptable COAPCode = 134 + PreconditionFailed COAPCode = 140 + RequestEntityTooLarge COAPCode = 141 + UnsupportedMediaType COAPCode = 143 + InternalServerError COAPCode = 160 + NotImplemented COAPCode = 161 + BadGateway COAPCode = 162 + ServiceUnavailable COAPCode = 163 + GatewayTimeout COAPCode = 164 + ProxyingNotSupported COAPCode = 165 +) + +var codeNames = [256]string{ + GET: "GET", + POST: "POST", + PUT: "PUT", + DELETE: "DELETE", + Created: "Created", + Deleted: "Deleted", + Valid: "Valid", + Changed: "Changed", + Content: "Content", + BadRequest: "BadRequest", + Unauthorized: "Unauthorized", + BadOption: "BadOption", + Forbidden: "Forbidden", + NotFound: "NotFound", + MethodNotAllowed: "MethodNotAllowed", + NotAcceptable: "NotAcceptable", + PreconditionFailed: "PreconditionFailed", + RequestEntityTooLarge: "RequestEntityTooLarge", + UnsupportedMediaType: "UnsupportedMediaType", + InternalServerError: "InternalServerError", + NotImplemented: "NotImplemented", + BadGateway: "BadGateway", + ServiceUnavailable: "ServiceUnavailable", + GatewayTimeout: "GatewayTimeout", + ProxyingNotSupported: "ProxyingNotSupported", +} + +func init() { + for i := range codeNames { + if codeNames[i] == "" { + codeNames[i] = fmt.Sprintf("Unknown (0x%x)", i) + } + } +} + +func (c COAPCode) String() string { + return codeNames[c] +} + +// Message encoding errors. +var ( + ErrInvalidTokenLen = errors.New("invalid token length") + ErrOptionTooLong = errors.New("option is too long") + ErrOptionGapTooLarge = errors.New("option gap too large") +) + +// OptionID identifies an option in a message. +type OptionID uint8 + +/* + +-----+----+---+---+---+----------------+--------+--------+---------+ + | No. | C | U | N | R | Name | Format | Length | Default | + +-----+----+---+---+---+----------------+--------+--------+---------+ + | 1 | x | | | x | If-Match | opaque | 0-8 | (none) | + | 3 | x | x | - | | Uri-Host | string | 1-255 | (see | + | | | | | | | | | below) | + | 4 | | | | x | ETag | opaque | 1-8 | (none) | + | 5 | x | | | | If-None-Match | empty | 0 | (none) | + | 7 | x | x | - | | Uri-Port | uint | 0-2 | (see | + | | | | | | | | | below) | + | 8 | | | | x | Location-Path | string | 0-255 | (none) | + | 11 | x | x | - | x | Uri-Path | string | 0-255 | (none) | + | 12 | | | | | Content-Format | uint | 0-2 | (none) | + | 14 | | x | - | | Max-Age | uint | 0-4 | 60 | + | 15 | x | x | - | x | Uri-Query | string | 0-255 | (none) | + | 17 | x | | | | Accept | uint | 0-2 | (none) | + | 20 | | | | x | Location-Query | string | 0-255 | (none) | + | 35 | x | x | - | | Proxy-Uri | string | 1-1034 | (none) | + | 39 | x | x | - | | Proxy-Scheme | string | 1-255 | (none) | + | 60 | | | x | | Size1 | uint | 0-4 | (none) | + +-----+----+---+---+---+----------------+--------+--------+---------+ +*/ + +// Option IDs. +const ( + IfMatch OptionID = 1 + URIHost OptionID = 3 + ETag OptionID = 4 + IfNoneMatch OptionID = 5 + Observe OptionID = 6 + URIPort OptionID = 7 + LocationPath OptionID = 8 + URIPath OptionID = 11 + ContentFormat OptionID = 12 + MaxAge OptionID = 14 + URIQuery OptionID = 15 + Accept OptionID = 17 + LocationQuery OptionID = 20 + ProxyURI OptionID = 35 + ProxyScheme OptionID = 39 + Size1 OptionID = 60 +) + +// Option value format (RFC7252 section 3.2) +type valueFormat uint8 + +const ( + valueUnknown valueFormat = iota + valueEmpty + valueOpaque + valueUint + valueString +) + +type optionDef struct { + valueFormat valueFormat + minLen int + maxLen int +} + +var optionDefs = [256]optionDef{ + IfMatch: optionDef{valueFormat: valueOpaque, minLen: 0, maxLen: 8}, + URIHost: optionDef{valueFormat: valueString, minLen: 1, maxLen: 255}, + ETag: optionDef{valueFormat: valueOpaque, minLen: 1, maxLen: 8}, + IfNoneMatch: optionDef{valueFormat: valueEmpty, minLen: 0, maxLen: 0}, + Observe: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 3}, + URIPort: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + LocationPath: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + URIPath: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + ContentFormat: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + MaxAge: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 4}, + URIQuery: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + Accept: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 2}, + LocationQuery: optionDef{valueFormat: valueString, minLen: 0, maxLen: 255}, + ProxyURI: optionDef{valueFormat: valueString, minLen: 1, maxLen: 1034}, + ProxyScheme: optionDef{valueFormat: valueString, minLen: 1, maxLen: 255}, + Size1: optionDef{valueFormat: valueUint, minLen: 0, maxLen: 4}, +} + +// MediaType specifies the content type of a message. +type MediaType byte + +// Content types. +const ( + TextPlain MediaType = 0 // text/plain;charset=utf-8 + AppLinkFormat MediaType = 40 // application/link-format + AppXML MediaType = 41 // application/xml + AppOctets MediaType = 42 // application/octet-stream + AppExi MediaType = 47 // application/exi + AppJSON MediaType = 50 // application/json +) + +type option struct { + ID OptionID + Value interface{} +} + +func encodeInt(v uint32) []byte { + switch { + case v == 0: + return nil + case v < 256: + return []byte{byte(v)} + case v < 65536: + rv := []byte{0, 0} + binary.BigEndian.PutUint16(rv, uint16(v)) + return rv + case v < 16777216: + rv := []byte{0, 0, 0, 0} + binary.BigEndian.PutUint32(rv, uint32(v)) + return rv[1:] + default: + rv := []byte{0, 0, 0, 0} + binary.BigEndian.PutUint32(rv, uint32(v)) + return rv + } +} + +func decodeInt(b []byte) uint32 { + tmp := []byte{0, 0, 0, 0} + copy(tmp[4-len(b):], b) + return binary.BigEndian.Uint32(tmp) +} + +func (o option) toBytes() []byte { + var v uint32 + + switch i := o.Value.(type) { + case string: + return []byte(i) + case []byte: + return i + case MediaType: + v = uint32(i) + case int: + v = uint32(i) + case int32: + v = uint32(i) + case uint: + v = uint32(i) + case uint32: + v = i + default: + panic(fmt.Errorf("invalid type for option %x: %T (%v)", + o.ID, o.Value, o.Value)) + } + + return encodeInt(v) +} + +func parseOptionValue(optionID OptionID, valueBuf []byte) interface{} { + def := optionDefs[optionID] + if def.valueFormat == valueUnknown { + // Skip unrecognized options (RFC7252 section 5.4.1) + return nil + } + if len(valueBuf) < def.minLen || len(valueBuf) > def.maxLen { + // Skip options with illegal value length (RFC7252 section 5.4.3) + return nil + } + switch def.valueFormat { + case valueUint: + intValue := decodeInt(valueBuf) + if optionID == ContentFormat || optionID == Accept { + return MediaType(intValue) + } else { + return intValue + } + case valueString: + return string(valueBuf) + case valueOpaque, valueEmpty: + return valueBuf + } + // Skip unrecognized options (should never be reached) + return nil +} + +type options []option + +func (o options) Len() int { + return len(o) +} + +func (o options) Less(i, j int) bool { + if o[i].ID == o[j].ID { + return i < j + } + return o[i].ID < o[j].ID +} + +func (o options) Swap(i, j int) { + o[i], o[j] = o[j], o[i] +} + +func (o options) Minus(oid OptionID) options { + rv := options{} + for _, opt := range o { + if opt.ID != oid { + rv = append(rv, opt) + } + } + return rv +} + +// Message is a CoAP message. +type Message struct { + Type COAPType + Code COAPCode + MessageID uint16 + + Token, Payload []byte + + opts options +} + +// IsConfirmable returns true if this message is confirmable. +func (m Message) IsConfirmable() bool { + return m.Type == Confirmable +} + +// Options gets all the values for the given option. +func (m Message) Options(o OptionID) []interface{} { + var rv []interface{} + + for _, v := range m.opts { + if o == v.ID { + rv = append(rv, v.Value) + } + } + + return rv +} + +// Option gets the first value for the given option ID. +func (m Message) Option(o OptionID) interface{} { + for _, v := range m.opts { + if o == v.ID { + return v.Value + } + } + return nil +} + +func (m Message) optionStrings(o OptionID) []string { + var rv []string + for _, o := range m.Options(o) { + rv = append(rv, o.(string)) + } + return rv +} + +// Path gets the Path set on this message if any. +func (m Message) Path() []string { + return m.optionStrings(URIPath) +} + +// PathString gets a path as a / separated string. +func (m Message) PathString() string { + return strings.Join(m.Path(), "/") +} + +// SetPathString sets a path by a / separated string. +func (m *Message) SetPathString(s string) { + for s[0] == '/' { + s = s[1:] + } + m.SetPath(strings.Split(s, "/")) +} + +// SetPath updates or adds a URIPath attribute on this message. +func (m *Message) SetPath(s []string) { + m.SetOption(URIPath, s) +} + +// RemoveOption removes all references to an option +func (m *Message) RemoveOption(opID OptionID) { + m.opts = m.opts.Minus(opID) +} + +// AddOption adds an option. +func (m *Message) AddOption(opID OptionID, val interface{}) { + iv := reflect.ValueOf(val) + if (iv.Kind() == reflect.Slice || iv.Kind() == reflect.Array) && + iv.Type().Elem().Kind() == reflect.String { + for i := 0; i < iv.Len(); i++ { + m.opts = append(m.opts, option{opID, iv.Index(i).Interface()}) + } + return + } + m.opts = append(m.opts, option{opID, val}) +} + +// SetOption sets an option, discarding any previous value +func (m *Message) SetOption(opID OptionID, val interface{}) { + m.RemoveOption(opID) + m.AddOption(opID, val) +} + +const ( + extoptByteCode = 13 + extoptByteAddend = 13 + extoptWordCode = 14 + extoptWordAddend = 269 + extoptError = 15 +) + +// MarshalBinary produces the binary form of this Message. +func (m *Message) MarshalBinary() ([]byte, error) { + tmpbuf := []byte{0, 0} + binary.BigEndian.PutUint16(tmpbuf, m.MessageID) + + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |Ver| T | TKL | Code | Message ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Token (if any, TKL bytes) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Options (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |1 1 1 1 1 1 1 1| Payload (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + buf := bytes.Buffer{} + buf.Write([]byte{ + (1 << 6) | (uint8(m.Type) << 4) | uint8(0xf&len(m.Token)), + byte(m.Code), + tmpbuf[0], tmpbuf[1], + }) + buf.Write(m.Token) + + /* + 0 1 2 3 4 5 6 7 + +---------------+---------------+ + | | | + | Option Delta | Option Length | 1 byte + | | | + +---------------+---------------+ + \ \ + / Option Delta / 0-2 bytes + \ (extended) \ + +-------------------------------+ + \ \ + / Option Length / 0-2 bytes + \ (extended) \ + +-------------------------------+ + \ \ + / / + \ \ + / Option Value / 0 or more bytes + \ \ + / / + \ \ + +-------------------------------+ + + See parseExtOption(), extendOption() + and writeOptionHeader() below for implementation details + */ + + extendOpt := func(opt int) (int, int) { + ext := 0 + if opt >= extoptByteAddend { + if opt >= extoptWordAddend { + ext = opt - extoptWordAddend + opt = extoptWordCode + } else { + ext = opt - extoptByteAddend + opt = extoptByteCode + } + } + return opt, ext + } + + writeOptHeader := func(delta, length int) { + d, dx := extendOpt(delta) + l, lx := extendOpt(length) + + buf.WriteByte(byte(d<<4) | byte(l)) + + tmp := []byte{0, 0} + writeExt := func(opt, ext int) { + switch opt { + case extoptByteCode: + buf.WriteByte(byte(ext)) + case extoptWordCode: + binary.BigEndian.PutUint16(tmp, uint16(ext)) + buf.Write(tmp) + } + } + + writeExt(d, dx) + writeExt(l, lx) + } + + sort.Stable(&m.opts) + + prev := 0 + + for _, o := range m.opts { + b := o.toBytes() + writeOptHeader(int(o.ID)-prev, len(b)) + buf.Write(b) + prev = int(o.ID) + } + + if len(m.Payload) > 0 { + buf.Write([]byte{0xff}) + } + + buf.Write(m.Payload) + + return buf.Bytes(), nil +} + +func parseMessage(data []byte) (Message, error) { + rv := Message{} + return rv, rv.UnmarshalBinary(data) +} + +// UnmarshalBinary parses the given binary slice as a Message. +func (m *Message) UnmarshalBinary(data []byte) error { + if len(data) < 4 { + return errors.New("short packet") + } + + if data[0]>>6 != 1 { + return errors.New("invalid version") + } + + m.Type = COAPType((data[0] >> 4) & 0x3) + tokenLen := int(data[0] & 0xf) + if tokenLen > 8 { + return ErrInvalidTokenLen + } + + m.Code = COAPCode(data[1]) + m.MessageID = binary.BigEndian.Uint16(data[2:4]) + + if tokenLen > 0 { + m.Token = make([]byte, tokenLen) + } + if len(data) < 4+tokenLen { + return errors.New("truncated") + } + copy(m.Token, data[4:4+tokenLen]) + b := data[4+tokenLen:] + prev := 0 + + parseExtOpt := func(opt int) (int, error) { + switch opt { + case extoptByteCode: + if len(b) < 1 { + return -1, errors.New("truncated") + } + opt = int(b[0]) + extoptByteAddend + b = b[1:] + case extoptWordCode: + if len(b) < 2 { + return -1, errors.New("truncated") + } + opt = int(binary.BigEndian.Uint16(b[:2])) + extoptWordAddend + b = b[2:] + } + return opt, nil + } + + for len(b) > 0 { + if b[0] == 0xff { + b = b[1:] + break + } + + delta := int(b[0] >> 4) + length := int(b[0] & 0x0f) + + if delta == extoptError || length == extoptError { + return errors.New("unexpected extended option marker") + } + + b = b[1:] + + delta, err := parseExtOpt(delta) + if err != nil { + return err + } + length, err = parseExtOpt(length) + if err != nil { + return err + } + + if len(b) < length { + return errors.New("truncated") + } + + oid := OptionID(prev + delta) + opval := parseOptionValue(oid, b[:length]) + b = b[length:] + prev = int(oid) + + if opval != nil { + m.opts = append(m.opts, option{ID: oid, Value: opval}) + } + } + m.Payload = b + return nil +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/messagetcp.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/messagetcp.go b/newtmgr/vendor/github.com/dustin/go-coap/messagetcp.go new file mode 100644 index 0000000..09354b9 --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/messagetcp.go @@ -0,0 +1,69 @@ +package coap + +import ( + "encoding/binary" + "errors" + "io" +) + +// TcpMessage is a CoAP Message that can encode itself for TCP +// transport. +type TcpMessage struct { + Message +} + +func (m *TcpMessage) MarshalBinary() ([]byte, error) { + bin, err := m.Message.MarshalBinary() + if err != nil { + return nil, err + } + + /* + A CoAP TCP message looks like: + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Length |Ver| T | TKL | Code | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Token (if any, TKL bytes) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Options (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |1 1 1 1 1 1 1 1| Payload (if any) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + l := []byte{0, 0} + binary.BigEndian.PutUint16(l, uint16(len(bin))) + + return append(l, bin...), nil +} + +func (m *TcpMessage) UnmarshalBinary(data []byte) error { + if len(data) < 4 { + return errors.New("short packet") + } + + return m.Message.UnmarshalBinary(data) +} + +// Decode reads a single message from its input. +func Decode(r io.Reader) (*TcpMessage, error) { + var ln uint16 + err := binary.Read(r, binary.BigEndian, &ln) + if err != nil { + return nil, err + } + + packet := make([]byte, ln) + _, err = io.ReadFull(r, packet) + if err != nil { + return nil, err + } + + m := TcpMessage{} + + err = m.UnmarshalBinary(packet) + return &m, err +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/server.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/server.go b/newtmgr/vendor/github.com/dustin/go-coap/server.go new file mode 100644 index 0000000..945af2c --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/server.go @@ -0,0 +1,102 @@ +// Package coap provides a CoAP client and server. +package coap + +import ( + "log" + "net" + "time" +) + +const maxPktLen = 1500 + +// Handler is a type that handles CoAP messages. +type Handler interface { + // Handle the message and optionally return a response message. + ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message +} + +type funcHandler func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message + +func (f funcHandler) ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + return f(l, a, m) +} + +// FuncHandler builds a handler from a function. +func FuncHandler(f func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message) Handler { + return funcHandler(f) +} + +func handlePacket(l *net.UDPConn, data []byte, u *net.UDPAddr, + rh Handler) { + + msg, err := parseMessage(data) + if err != nil { + log.Printf("Error parsing %v", err) + return + } + + rv := rh.ServeCOAP(l, u, &msg) + if rv != nil { + Transmit(l, u, *rv) + } +} + +// Transmit a message. +func Transmit(l *net.UDPConn, a *net.UDPAddr, m Message) error { + d, err := m.MarshalBinary() + if err != nil { + return err + } + + if a == nil { + _, err = l.Write(d) + } else { + _, err = l.WriteTo(d, a) + } + return err +} + +// Receive a message. +func Receive(l *net.UDPConn, buf []byte) (Message, error) { + l.SetReadDeadline(time.Now().Add(ResponseTimeout)) + + nr, _, err := l.ReadFromUDP(buf) + if err != nil { + return Message{}, err + } + return parseMessage(buf[:nr]) +} + +// ListenAndServe binds to the given address and serve requests forever. +func ListenAndServe(n, addr string, rh Handler) error { + uaddr, err := net.ResolveUDPAddr(n, addr) + if err != nil { + return err + } + + l, err := net.ListenUDP(n, uaddr) + if err != nil { + return err + } + + return Serve(l, rh) +} + +// Serve processes incoming UDP packets on the given listener, and processes +// these requests forever (or until the listener is closed). +func Serve(listener *net.UDPConn, rh Handler) error { + buf := make([]byte, maxPktLen) + for { + nr, addr, err := listener.ReadFromUDP(buf) + if err != nil { + if neterr, ok := err.(net.Error); ok && (neterr.Temporary() || neterr.Timeout()) { + time.Sleep(5 * time.Millisecond) + continue + } + return err + } + tmp := make([]byte, nr) + copy(tmp, buf) + go handlePacket(listener, tmp, addr, rh) + } +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/dustin/go-coap/servmux.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/dustin/go-coap/servmux.go b/newtmgr/vendor/github.com/dustin/go-coap/servmux.go new file mode 100644 index 0000000..23132f1 --- /dev/null +++ b/newtmgr/vendor/github.com/dustin/go-coap/servmux.go @@ -0,0 +1,94 @@ +package coap + +import ( + "net" +) + +// ServeMux provides mappings from a common endpoint to handlers by +// request path. +type ServeMux struct { + m map[string]muxEntry +} + +type muxEntry struct { + h Handler + pattern string +} + +// NewServeMux creates a new ServeMux. +func NewServeMux() *ServeMux { return &ServeMux{m: make(map[string]muxEntry)} } + +// Does path match pattern? +func pathMatch(pattern, path string) bool { + if len(pattern) == 0 { + // should not happen + return false + } + n := len(pattern) + if pattern[n-1] != '/' { + return pattern == path + } + return len(path) >= n && path[0:n] == pattern +} + +// Find a handler on a handler map given a path string +// Most-specific (longest) pattern wins +func (mux *ServeMux) match(path string) (h Handler, pattern string) { + var n = 0 + for k, v := range mux.m { + if !pathMatch(k, path) { + continue + } + if h == nil || len(k) > n { + n = len(k) + h = v.h + pattern = v.pattern + } + } + return +} + +func notFoundHandler(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + if m.IsConfirmable() { + return &Message{ + Type: Acknowledgement, + Code: NotFound, + } + } + return nil +} + +var _ = Handler(&ServeMux{}) + +// ServeCOAP handles a single COAP message. The message arrives from +// the given listener having originated from the given UDPAddr. +func (mux *ServeMux) ServeCOAP(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message { + h, _ := mux.match(m.PathString()) + if h == nil { + h, _ = funcHandler(notFoundHandler), "" + } + // TODO: Rewrite path? + return h.ServeCOAP(l, a, m) +} + +// Handle configures a handler for the given path. +func (mux *ServeMux) Handle(pattern string, handler Handler) { + for pattern != "" && pattern[0] == '/' { + pattern = pattern[1:] + } + + if pattern == "" { + panic("http: invalid pattern " + pattern) + } + if handler == nil { + panic("http: nil handler") + } + + mux.m[pattern] = muxEntry{h: handler, pattern: pattern} +} + +// HandleFunc configures a handler for the given path. +func (mux *ServeMux) HandleFunc(pattern string, + f func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message) { + mux.Handle(pattern, FuncHandler(f)) +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/mitchellh/mapstructure/mapstructure.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/newtmgr/vendor/github.com/mitchellh/mapstructure/mapstructure.go index d1cb607..b0ab89b 100644 --- a/newtmgr/vendor/github.com/mitchellh/mapstructure/mapstructure.go +++ b/newtmgr/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -651,14 +651,6 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) fieldType := structType.Field(i) fieldKind := fieldType.Type.Kind() - if fieldType.Anonymous { - if fieldKind != reflect.Struct { - errors = appendErrors(errors, - fmt.Errorf("%s: unsupported type: %s", fieldType.Name, fieldKind)) - continue - } - } - // If "squash" is specified in the tag, we squash the field down. squash := false tagParts := strings.Split(fieldType.Tag.Get(d.config.TagName), ",") http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/spf13/cast/caste.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/cast/caste.go b/newtmgr/vendor/github.com/spf13/cast/caste.go index 23f59a1..23f0fe8 100644 --- a/newtmgr/vendor/github.com/spf13/cast/caste.go +++ b/newtmgr/vendor/github.com/spf13/cast/caste.go @@ -513,6 +513,7 @@ func StringToDate(s string) (time.Time, error) { "02 Jan 2006", "2006-01-02 15:04:05 -07:00", "2006-01-02 15:04:05 -0700", + "2006-01-02 15:04:05", }) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/spf13/cobra/command.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/cobra/command.go b/newtmgr/vendor/github.com/spf13/cobra/command.go index 8f6580a..4988931 100644 --- a/newtmgr/vendor/github.com/spf13/cobra/command.go +++ b/newtmgr/vendor/github.com/spf13/cobra/command.go @@ -231,12 +231,8 @@ func (c *Command) Usage() error { // HelpFunc returns either the function set by SetHelpFunc for this command // or a parent, or it returns a function with default help behavior. func (c *Command) HelpFunc() func(*Command, []string) { - cmd := c - for cmd != nil { - if cmd.helpFunc != nil { - return cmd.helpFunc - } - cmd = cmd.parent + if helpFunc := c.checkHelpFunc(); helpFunc != nil { + return helpFunc } return func(*Command, []string) { c.mergePersistentFlags() @@ -247,6 +243,20 @@ func (c *Command) HelpFunc() func(*Command, []string) { } } +// checkHelpFunc checks if there is helpFunc in ancestors of c. +func (c *Command) checkHelpFunc() func(*Command, []string) { + if c == nil { + return nil + } + if c.helpFunc != nil { + return c.helpFunc + } + if c.HasParent() { + return c.parent.checkHelpFunc() + } + return nil +} + // Help puts out the help for the command. // Used when a user calls help [command]. // Can be defined by user by overriding HelpFunc. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/spf13/pflag/.travis.yml ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/pflag/.travis.yml b/newtmgr/vendor/github.com/spf13/pflag/.travis.yml index 0a7c136..707bdc3 100644 --- a/newtmgr/vendor/github.com/spf13/pflag/.travis.yml +++ b/newtmgr/vendor/github.com/spf13/pflag/.travis.yml @@ -3,9 +3,8 @@ sudo: false language: go go: - - 1.5.4 - 1.6.3 - - 1.7 + - 1.7.3 - tip matrix: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/github.com/spf13/pflag/flag.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/pflag/flag.go b/newtmgr/vendor/github.com/spf13/pflag/flag.go index 4258f45..fa81564 100644 --- a/newtmgr/vendor/github.com/spf13/pflag/flag.go +++ b/newtmgr/vendor/github.com/spf13/pflag/flag.go @@ -514,7 +514,7 @@ func (f *FlagSet) FlagUsages() string { if len(flag.NoOptDefVal) > 0 { switch flag.Value.Type() { case "string": - line += fmt.Sprintf("[=%q]", flag.NoOptDefVal) + line += fmt.Sprintf("[=\"%s\"]", flag.NoOptDefVal) case "bool": if flag.NoOptDefVal != "true" { line += fmt.Sprintf("[=%s]", flag.NoOptDefVal) @@ -534,7 +534,7 @@ func (f *FlagSet) FlagUsages() string { line += usage if !flag.defaultIsZeroValue() { if flag.Value.Type() == "string" { - line += fmt.Sprintf(" (default %q)", flag.DefValue) + line += fmt.Sprintf(" (default \"%s\")", flag.DefValue) } else { line += fmt.Sprintf(" (default %s)", flag.DefValue) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/syscall_linux.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/syscall_linux.go b/newtmgr/vendor/golang.org/x/sys/unix/syscall_linux.go index cfac4a4..74eae9b 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -899,6 +899,7 @@ func Getpgrp() (pid int) { //sysnb Getppid() (ppid int) //sys Getpriority(which int, who int) (prio int, err error) //sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) //sysnb Gettid() (tid int) //sys Getxattr(path string, attr string, dest []byte) (sz int, err error) //sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) @@ -911,7 +912,7 @@ func Getpgrp() (pid int) { //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT -//sysnb prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) = SYS_PRLIMIT64 +//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 //sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys read(fd int, p []byte) (n int, err error) //sys Removexattr(path string, attr string) (err error) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 80f6a1b..fa92387 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 078c8f0..b34d5c2 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 76e5f7c..2e5cb39 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index 72b7947..0d584cc 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index ba55509..bf6f360 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index 2b1cc84..8c86bd7 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 25f39db..f5d488b 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 70702b5..5183711 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index dbaa53b..4c7ed08 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -64,7 +64,7 @@ func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { @@ -87,7 +87,7 @@ func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -109,7 +109,7 @@ func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func unlinkat(dirfd int, path string, flags int) (err error) { +func Unlinkat(dirfd int, path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 08ee5d0..beb83e4 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -64,7 +64,7 @@ func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { @@ -87,7 +87,7 @@ func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -109,7 +109,7 @@ func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func unlinkat(dirfd int, path string, flags int) (err error) { +func Unlinkat(dirfd int, path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { @@ -572,6 +572,17 @@ func Getrusage(who int, rusage *Rusage) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Gettid() (tid int) { r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) tid = int(r0) @@ -762,8 +773,8 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) +func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) if e1 != 0 { err = errnoErr(e1) } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/newtmgr/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 817ac9c..35f11bd 100644 --- a/newtmgr/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/newtmgr/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -1,6 +1,6 @@ // +build arm,linux // Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_linux.go +// cgo -godefs types_linux.go | go run mkpost.go package unix @@ -155,6 +155,15 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Family uint16 Port uint16 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/mynewt.apache.org/newt/util/util.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/mynewt.apache.org/newt/util/util.go b/newtmgr/vendor/mynewt.apache.org/newt/util/util.go index 298c1b0..21c67bb 100644 --- a/newtmgr/vendor/mynewt.apache.org/newt/util/util.go +++ b/newtmgr/vendor/mynewt.apache.org/newt/util/util.go @@ -105,11 +105,13 @@ func ChildNewtError(parent error) *NewtError { } // Print Silent, Quiet and Verbose aware status messages to stdout. -func StatusMessage(level int, message string, args ...interface{}) { +func WriteMessage(f *os.File, level int, message string, + args ...interface{}) { + if Verbosity >= level { str := fmt.Sprintf(message, args...) - os.Stdout.WriteString(str) - os.Stdout.Sync() + f.WriteString(str) + f.Sync() if logFile != nil { logFile.WriteString(str) @@ -117,11 +119,14 @@ func StatusMessage(level int, message string, args ...interface{}) { } } +// Print Silent, Quiet and Verbose aware status messages to stdout. +func StatusMessage(level int, message string, args ...interface{}) { + WriteMessage(os.Stdout, level, message, args...) +} + // Print Silent, Quiet and Verbose aware status messages to stderr. func ErrorMessage(level int, message string, args ...interface{}) { - if Verbosity >= level { - fmt.Fprintf(os.Stderr, message, args...) - } + WriteMessage(os.Stderr, level, message, args...) } func NodeExist(path string) bool { @@ -373,7 +378,8 @@ func CopyFile(srcFile string, dstFile string) error { return ChildNewtError(err) } - out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode()) + out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, + info.Mode()) if err != nil { return ChildNewtError(err) } @@ -383,13 +389,6 @@ func CopyFile(srcFile string, dstFile string) error { return ChildNewtError(err) } - if err := in.Close(); err != nil { - return err - } - if err := out.Close(); err != nil { - return err - } - return nil } @@ -559,3 +558,27 @@ func FileContentsChanged(path string, newContents []byte) (bool, error) { rc := bytes.Compare(oldContents, newContents) return rc != 0, nil } + +func CIdentifier(s string) string { + s = strings.Replace(s, "/", "_", -1) + s = strings.Replace(s, "-", "_", -1) + s = strings.Replace(s, " ", "_", -1) + + return s +} + +func IntMax(a, b int) int { + if a > b { + return a + } else { + return b + } +} + +func IntMin(a, b int) int { + if a < b { + return a + } else { + return b + } +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/264add5a/newtmgr/vendor/mynewt.apache.org/newt/yaml/decode.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/mynewt.apache.org/newt/yaml/decode.go b/newtmgr/vendor/mynewt.apache.org/newt/yaml/decode.go index 8244bd6..46588fe 100644 --- a/newtmgr/vendor/mynewt.apache.org/newt/yaml/decode.go +++ b/newtmgr/vendor/mynewt.apache.org/newt/yaml/decode.go @@ -110,7 +110,7 @@ func genValue(strVal string) interface{} { func stringValue(value interface{}) string { switch value.(type) { case int: - return strconv.FormatInt(value.(int64), 10) + return strconv.FormatInt(int64(value.(int)), 10) case bool: return strconv.FormatBool(value.(bool))
