This commit is contained in:
2018-11-04 15:58:15 +01:00
commit f956bcee28
1178 changed files with 584552 additions and 0 deletions

21
vendor/github.com/asticode/go-astitools/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Quentin Renard
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.

View File

@@ -0,0 +1,35 @@
package astibits
var hamming84tab = [256]uint8{
0x01, 0xff, 0xff, 0x08, 0xff, 0x0c, 0x04, 0xff, 0xff, 0x08, 0x08, 0x08, 0x06, 0xff, 0xff, 0x08,
0xff, 0x0a, 0x02, 0xff, 0x06, 0xff, 0xff, 0x0f, 0x06, 0xff, 0xff, 0x08, 0x06, 0x06, 0x06, 0xff,
0xff, 0x0a, 0x04, 0xff, 0x04, 0xff, 0x04, 0x04, 0x00, 0xff, 0xff, 0x08, 0xff, 0x0d, 0x04, 0xff,
0x0a, 0x0a, 0xff, 0x0a, 0xff, 0x0a, 0x04, 0xff, 0xff, 0x0a, 0x03, 0xff, 0x06, 0xff, 0xff, 0x0e,
0x01, 0x01, 0x01, 0xff, 0x01, 0xff, 0xff, 0x0f, 0x01, 0xff, 0xff, 0x08, 0xff, 0x0d, 0x05, 0xff,
0x01, 0xff, 0xff, 0x0f, 0xff, 0x0f, 0x0f, 0x0f, 0xff, 0x0b, 0x03, 0xff, 0x06, 0xff, 0xff, 0x0f,
0x01, 0xff, 0xff, 0x09, 0xff, 0x0d, 0x04, 0xff, 0xff, 0x0d, 0x03, 0xff, 0x0d, 0x0d, 0xff, 0x0d,
0xff, 0x0a, 0x03, 0xff, 0x07, 0xff, 0xff, 0x0f, 0x03, 0xff, 0x03, 0x03, 0xff, 0x0d, 0x03, 0xff,
0xff, 0x0c, 0x02, 0xff, 0x0c, 0x0c, 0xff, 0x0c, 0x00, 0xff, 0xff, 0x08, 0xff, 0x0c, 0x05, 0xff,
0x02, 0xff, 0x02, 0x02, 0xff, 0x0c, 0x02, 0xff, 0xff, 0x0b, 0x02, 0xff, 0x06, 0xff, 0xff, 0x0e,
0x00, 0xff, 0xff, 0x09, 0xff, 0x0c, 0x04, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x0e,
0xff, 0x0a, 0x02, 0xff, 0x07, 0xff, 0xff, 0x0e, 0x00, 0xff, 0xff, 0x0e, 0xff, 0x0e, 0x0e, 0x0e,
0x01, 0xff, 0xff, 0x09, 0xff, 0x0c, 0x05, 0xff, 0xff, 0x0b, 0x05, 0xff, 0x05, 0xff, 0x05, 0x05,
0xff, 0x0b, 0x02, 0xff, 0x07, 0xff, 0xff, 0x0f, 0x0b, 0x0b, 0xff, 0x0b, 0xff, 0x0b, 0x05, 0xff,
0xff, 0x09, 0x09, 0x09, 0x07, 0xff, 0xff, 0x09, 0x00, 0xff, 0xff, 0x09, 0xff, 0x0d, 0x05, 0xff,
0x07, 0xff, 0xff, 0x09, 0x07, 0x07, 0x07, 0xff, 0xff, 0x0b, 0x03, 0xff, 0x07, 0xff, 0xff, 0x0e,
}
func Hamming84Decode(i uint8) (o uint8, ok bool) {
o = hamming84tab[i]
if o == 0xff {
return
}
ok = true
return
}
func Hamming2418Decode(i uint32) (o uint32, ok bool) {
o = i
ok = true
return
}

26
vendor/github.com/asticode/go-astitools/bits/parity.go generated vendored Normal file
View File

@@ -0,0 +1,26 @@
package astibits
var parityTab = [256]uint8{
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
}
func Parity(i uint8) (o uint8, ok bool) {
ok = parityTab[i] == 1
o = i & 0x7f
return
}

17
vendor/github.com/asticode/go-astitools/byte/length.go generated vendored Normal file
View File

@@ -0,0 +1,17 @@
package astibyte
// ToLength forces the length of a []byte
func ToLength(i []byte, rpl byte, length int) []byte {
if len(i) == length {
return i
} else if len(i) > length {
return i[:length]
} else {
var o = make([]byte, length)
o = i
for idx := 0; idx < length-len(i); idx++ {
o = append(o, rpl)
}
return o
}
}

29
vendor/github.com/asticode/go-astitools/byte/pad.go generated vendored Normal file
View File

@@ -0,0 +1,29 @@
package astibyte
// PadLeft adds n rpl to the left of i so that len is length
func PadLeft(i []byte, rpl byte, length int) []byte {
if len(i) >= length {
return i
} else {
var o = make([]byte, length)
o = i
for idx := 0; idx < length-len(i); idx++ {
o = append([]byte{rpl}, o...)
}
return o
}
}
// PadRight adds n rpl to the right of i so that len is length
func PadRight(i []byte, rpl byte, length int) []byte {
if len(i) >= length {
return i
} else {
var o = make([]byte, length)
o = i
for idx := 0; idx < length-len(i); idx++ {
o = append(o, rpl)
}
return o
}
}

54
vendor/github.com/asticode/go-astitools/map/map.go generated vendored Normal file
View File

@@ -0,0 +1,54 @@
package astimap
// Map represents a bi-directional map
type Map struct {
defaultA interface{}
defaultB interface{}
mapAToB map[interface{}]interface{}
mapBToA map[interface{}]interface{}
}
// NewMap builds a new *Map
func NewMap(defaultA, defaultB interface{}) *Map {
return &Map{
defaultA: defaultA,
defaultB: defaultB,
mapAToB: make(map[interface{}]interface{}),
mapBToA: make(map[interface{}]interface{}),
}
}
// A retrieves a based on b
func (m *Map) A(b interface{}) interface{} {
if a, ok := m.mapBToA[b]; ok {
return a
}
return m.defaultA
}
// B retrieves b based on a
func (m *Map) B(a interface{}) interface{} {
if b, ok := m.mapAToB[a]; ok {
return b
}
return m.defaultB
}
// InA checks whether a exists
func (m *Map) InA(a interface{}) (ok bool) {
_, ok = m.mapAToB[a]
return
}
// InB checks whether b exists
func (m *Map) InB(b interface{}) (ok bool) {
_, ok = m.mapBToA[b]
return
}
// Set sets a key/value couple
func (m *Map) Set(a, b interface{}) *Map {
m.mapAToB[a] = b
m.mapBToA[b] = a
return m
}

43
vendor/github.com/asticode/go-astitools/ptr/astiptr.go generated vendored Normal file
View File

@@ -0,0 +1,43 @@
package astiptr
import "time"
// Bool transforms a bool into a *bool
func Bool(i bool) *bool {
return &i
}
// Duration transforms a time.Duration into a *time.Duration
func Duration(i time.Duration) *time.Duration {
return &i
}
// Float transforms a float64 into a *float64
func Float(i float64) *float64 {
return &i
}
// Int transforms an int into an *int
func Int(i int) *int {
return &i
}
// Int64 transforms an int64 into an *int64
func Int64(i int64) *int64 {
return &i
}
// Str transforms a string into a *string
func Str(i string) *string {
return &i
}
// UInt8 transforms a uint8 into a *uint8
func UInt8(i uint8) *uint8 {
return &i
}
// UInt32 transforms a uint32 into a *uint32
func UInt32(i uint32) *uint32 {
return &i
}

View File

@@ -0,0 +1,15 @@
package astistring
// ToLength forces the length of a string
func ToLength(i, rpl string, length int) string {
if len(i) == length {
return i
} else if len(i) > length {
return i[:length]
} else {
for idx := 0; idx <= length-len(i); idx++ {
i += rpl
}
return i
}
}

35
vendor/github.com/asticode/go-astitools/string/rand.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
package astistring
import (
"math/rand"
"time"
)
const (
letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)
var src = rand.NewSource(time.Now().UnixNano())
// RandomString generates a random string
// https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
func RandomString(n int) string {
b := make([]byte, n)
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
if remain == 0 {
cache, remain = src.Int63(), letterIdxMax
}
if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
b[i] = letterBytes[idx]
i--
}
cache >>= letterIdxBits
remain--
}
return string(b)
}