mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
Update dependencies
This commit is contained in:
parent
d18c4ece0c
commit
4bccc611c3
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/syncthing/protocol",
|
"ImportPath": "github.com/syncthing/protocol",
|
||||||
"Rev": "15bf5f583a88b7aaf0a5b810fcf5fb21da0a3b3f"
|
"Rev": "3450b5f80cbf69777693cb4762685817ee2489ad"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/syndtr/goleveldb/leveldb",
|
"ImportPath": "github.com/syndtr/goleveldb/leveldb",
|
||||||
|
388
Godeps/_workspace/src/github.com/bkaradzic/go-lz4/reader.go
generated
vendored
388
Godeps/_workspace/src/github.com/bkaradzic/go-lz4/reader.go
generated
vendored
@ -1,194 +1,194 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
* list of conditions and the following disclaimer.
|
* list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
* SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lz4
|
package lz4
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrCorrupt indicates the input was corrupt
|
// ErrCorrupt indicates the input was corrupt
|
||||||
ErrCorrupt = errors.New("corrupt input")
|
ErrCorrupt = errors.New("corrupt input")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mlBits = 4
|
mlBits = 4
|
||||||
mlMask = (1 << mlBits) - 1
|
mlMask = (1 << mlBits) - 1
|
||||||
runBits = 8 - mlBits
|
runBits = 8 - mlBits
|
||||||
runMask = (1 << runBits) - 1
|
runMask = (1 << runBits) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
type decoder struct {
|
type decoder struct {
|
||||||
src []byte
|
src []byte
|
||||||
dst []byte
|
dst []byte
|
||||||
spos uint32
|
spos uint32
|
||||||
dpos uint32
|
dpos uint32
|
||||||
ref uint32
|
ref uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) readByte() (uint8, error) {
|
func (d *decoder) readByte() (uint8, error) {
|
||||||
if int(d.spos) == len(d.src) {
|
if int(d.spos) == len(d.src) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
b := d.src[d.spos]
|
b := d.src[d.spos]
|
||||||
d.spos++
|
d.spos++
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) getLen() (uint32, error) {
|
func (d *decoder) getLen() (uint32, error) {
|
||||||
|
|
||||||
length := uint32(0)
|
length := uint32(0)
|
||||||
ln, err := d.readByte()
|
ln, err := d.readByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, ErrCorrupt
|
return 0, ErrCorrupt
|
||||||
}
|
}
|
||||||
for ln == 255 {
|
for ln == 255 {
|
||||||
length += 255
|
length += 255
|
||||||
ln, err = d.readByte()
|
ln, err = d.readByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, ErrCorrupt
|
return 0, ErrCorrupt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
length += uint32(ln)
|
length += uint32(ln)
|
||||||
|
|
||||||
return length, nil
|
return length, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) cp(length, decr uint32) {
|
func (d *decoder) cp(length, decr uint32) {
|
||||||
|
|
||||||
if int(d.ref+length) < int(d.dpos) {
|
if int(d.ref+length) < int(d.dpos) {
|
||||||
copy(d.dst[d.dpos:], d.dst[d.ref:d.ref+length])
|
copy(d.dst[d.dpos:], d.dst[d.ref:d.ref+length])
|
||||||
} else {
|
} else {
|
||||||
for ii := uint32(0); ii < length; ii++ {
|
for ii := uint32(0); ii < length; ii++ {
|
||||||
d.dst[d.dpos+ii] = d.dst[d.ref+ii]
|
d.dst[d.dpos+ii] = d.dst[d.ref+ii]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.dpos += length
|
d.dpos += length
|
||||||
d.ref += length - decr
|
d.ref += length - decr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) finish(err error) error {
|
func (d *decoder) finish(err error) error {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode returns the decoded form of src. The returned slice may be a
|
// Decode returns the decoded form of src. The returned slice may be a
|
||||||
// subslice of dst if it was large enough to hold the entire decoded block.
|
// subslice of dst if it was large enough to hold the entire decoded block.
|
||||||
func Decode(dst, src []byte) ([]byte, error) {
|
func Decode(dst, src []byte) ([]byte, error) {
|
||||||
|
|
||||||
if len(src) < 4 {
|
if len(src) < 4 {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
uncompressedLen := binary.LittleEndian.Uint32(src)
|
uncompressedLen := binary.LittleEndian.Uint32(src)
|
||||||
|
|
||||||
if uncompressedLen == 0 {
|
if uncompressedLen == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if uncompressedLen > MaxInputSize {
|
if uncompressedLen > MaxInputSize {
|
||||||
return nil, ErrTooLarge
|
return nil, ErrTooLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
if dst == nil || len(dst) < int(uncompressedLen) {
|
if dst == nil || len(dst) < int(uncompressedLen) {
|
||||||
dst = make([]byte, uncompressedLen)
|
dst = make([]byte, uncompressedLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
d := decoder{src: src, dst: dst[:uncompressedLen], spos: 4}
|
d := decoder{src: src, dst: dst[:uncompressedLen], spos: 4}
|
||||||
|
|
||||||
decr := []uint32{0, 3, 2, 3}
|
decr := []uint32{0, 3, 2, 3}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
code, err := d.readByte()
|
code, err := d.readByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return d.dst, d.finish(err)
|
return d.dst, d.finish(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
length := uint32(code >> mlBits)
|
length := uint32(code >> mlBits)
|
||||||
if length == runMask {
|
if length == runMask {
|
||||||
ln, err := d.getLen()
|
ln, err := d.getLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
length += ln
|
length += ln
|
||||||
}
|
}
|
||||||
|
|
||||||
if int(d.spos+length) > len(d.src) {
|
if int(d.spos+length) > len(d.src) {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
for ii := uint32(0); ii < length; ii++ {
|
for ii := uint32(0); ii < length; ii++ {
|
||||||
d.dst[d.dpos+ii] = d.src[d.spos+ii]
|
d.dst[d.dpos+ii] = d.src[d.spos+ii]
|
||||||
}
|
}
|
||||||
|
|
||||||
d.spos += length
|
d.spos += length
|
||||||
d.dpos += length
|
d.dpos += length
|
||||||
|
|
||||||
if int(d.spos) == len(d.src) {
|
if int(d.spos) == len(d.src) {
|
||||||
return d.dst, nil
|
return d.dst, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if int(d.spos+2) >= len(d.src) {
|
if int(d.spos+2) >= len(d.src) {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
back := uint32(d.src[d.spos]) | uint32(d.src[d.spos+1])<<8
|
back := uint32(d.src[d.spos]) | uint32(d.src[d.spos+1])<<8
|
||||||
|
|
||||||
if back > d.dpos {
|
if back > d.dpos {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
d.spos += 2
|
d.spos += 2
|
||||||
d.ref = d.dpos - back
|
d.ref = d.dpos - back
|
||||||
|
|
||||||
length = uint32(code & mlMask)
|
length = uint32(code & mlMask)
|
||||||
if length == mlMask {
|
if length == mlMask {
|
||||||
ln, err := d.getLen()
|
ln, err := d.getLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
length += ln
|
length += ln
|
||||||
}
|
}
|
||||||
|
|
||||||
literal := d.dpos - d.ref
|
literal := d.dpos - d.ref
|
||||||
if literal < 4 {
|
if literal < 4 {
|
||||||
d.cp(4, decr[literal])
|
d.cp(4, decr[literal])
|
||||||
} else {
|
} else {
|
||||||
length += 4
|
length += 4
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.dpos+length > uncompressedLen {
|
if d.dpos+length > uncompressedLen {
|
||||||
return nil, ErrCorrupt
|
return nil, ErrCorrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
d.cp(length, 0)
|
d.cp(length, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
376
Godeps/_workspace/src/github.com/bkaradzic/go-lz4/writer.go
generated
vendored
376
Godeps/_workspace/src/github.com/bkaradzic/go-lz4/writer.go
generated
vendored
@ -1,188 +1,188 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
* list of conditions and the following disclaimer.
|
* list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
* SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lz4
|
package lz4
|
||||||
|
|
||||||
import "encoding/binary"
|
import "encoding/binary"
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
minMatch = 4
|
minMatch = 4
|
||||||
hashLog = 17
|
hashLog = 17
|
||||||
hashTableSize = 1 << hashLog
|
hashTableSize = 1 << hashLog
|
||||||
hashShift = (minMatch * 8) - hashLog
|
hashShift = (minMatch * 8) - hashLog
|
||||||
incompressible uint32 = 128
|
incompressible uint32 = 128
|
||||||
uninitHash = 0x88888888
|
uninitHash = 0x88888888
|
||||||
|
|
||||||
// MaxInputSize is the largest buffer than can be compressed in a single block
|
// MaxInputSize is the largest buffer than can be compressed in a single block
|
||||||
MaxInputSize = 0x7E000000
|
MaxInputSize = 0x7E000000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrTooLarge indicates the input buffer was too large
|
// ErrTooLarge indicates the input buffer was too large
|
||||||
ErrTooLarge = errors.New("input too large")
|
ErrTooLarge = errors.New("input too large")
|
||||||
)
|
)
|
||||||
|
|
||||||
type encoder struct {
|
type encoder struct {
|
||||||
src []byte
|
src []byte
|
||||||
dst []byte
|
dst []byte
|
||||||
hashTable []uint32
|
hashTable []uint32
|
||||||
pos uint32
|
pos uint32
|
||||||
anchor uint32
|
anchor uint32
|
||||||
dpos uint32
|
dpos uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompressBound returns the maximum length of a lz4 block, given it's uncompressed length
|
// CompressBound returns the maximum length of a lz4 block, given it's uncompressed length
|
||||||
func CompressBound(isize int) int {
|
func CompressBound(isize int) int {
|
||||||
if isize > MaxInputSize {
|
if isize > MaxInputSize {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return isize + ((isize) / 255) + 16 + 4
|
return isize + ((isize) / 255) + 16 + 4
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *encoder) writeLiterals(length, mlLen, pos uint32) {
|
func (e *encoder) writeLiterals(length, mlLen, pos uint32) {
|
||||||
|
|
||||||
ln := length
|
ln := length
|
||||||
|
|
||||||
var code byte
|
var code byte
|
||||||
if ln > runMask-1 {
|
if ln > runMask-1 {
|
||||||
code = runMask
|
code = runMask
|
||||||
} else {
|
} else {
|
||||||
code = byte(ln)
|
code = byte(ln)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mlLen > mlMask-1 {
|
if mlLen > mlMask-1 {
|
||||||
e.dst[e.dpos] = (code << mlBits) + byte(mlMask)
|
e.dst[e.dpos] = (code << mlBits) + byte(mlMask)
|
||||||
} else {
|
} else {
|
||||||
e.dst[e.dpos] = (code << mlBits) + byte(mlLen)
|
e.dst[e.dpos] = (code << mlBits) + byte(mlLen)
|
||||||
}
|
}
|
||||||
e.dpos++
|
e.dpos++
|
||||||
|
|
||||||
if code == runMask {
|
if code == runMask {
|
||||||
ln -= runMask
|
ln -= runMask
|
||||||
for ; ln > 254; ln -= 255 {
|
for ; ln > 254; ln -= 255 {
|
||||||
e.dst[e.dpos] = 255
|
e.dst[e.dpos] = 255
|
||||||
e.dpos++
|
e.dpos++
|
||||||
}
|
}
|
||||||
|
|
||||||
e.dst[e.dpos] = byte(ln)
|
e.dst[e.dpos] = byte(ln)
|
||||||
e.dpos++
|
e.dpos++
|
||||||
}
|
}
|
||||||
|
|
||||||
for ii := uint32(0); ii < length; ii++ {
|
for ii := uint32(0); ii < length; ii++ {
|
||||||
e.dst[e.dpos+ii] = e.src[pos+ii]
|
e.dst[e.dpos+ii] = e.src[pos+ii]
|
||||||
}
|
}
|
||||||
|
|
||||||
e.dpos += length
|
e.dpos += length
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode returns the encoded form of src. The returned array may be a
|
// Encode returns the encoded form of src. The returned array may be a
|
||||||
// sub-slice of dst if it was large enough to hold the entire output.
|
// sub-slice of dst if it was large enough to hold the entire output.
|
||||||
func Encode(dst, src []byte) ([]byte, error) {
|
func Encode(dst, src []byte) ([]byte, error) {
|
||||||
|
|
||||||
if len(src) >= MaxInputSize {
|
if len(src) >= MaxInputSize {
|
||||||
return nil, ErrTooLarge
|
return nil, ErrTooLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
if n := CompressBound(len(src)); len(dst) < n {
|
if n := CompressBound(len(src)); len(dst) < n {
|
||||||
dst = make([]byte, n)
|
dst = make([]byte, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
e := encoder{src: src, dst: dst, hashTable: make([]uint32, hashTableSize)}
|
e := encoder{src: src, dst: dst, hashTable: make([]uint32, hashTableSize)}
|
||||||
|
|
||||||
binary.LittleEndian.PutUint32(dst, uint32(len(src)))
|
binary.LittleEndian.PutUint32(dst, uint32(len(src)))
|
||||||
e.dpos = 4
|
e.dpos = 4
|
||||||
|
|
||||||
var (
|
var (
|
||||||
step uint32 = 1
|
step uint32 = 1
|
||||||
limit = incompressible
|
limit = incompressible
|
||||||
)
|
)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if int(e.pos)+12 >= len(e.src) {
|
if int(e.pos)+12 >= len(e.src) {
|
||||||
e.writeLiterals(uint32(len(e.src))-e.anchor, 0, e.anchor)
|
e.writeLiterals(uint32(len(e.src))-e.anchor, 0, e.anchor)
|
||||||
return e.dst[:e.dpos], nil
|
return e.dst[:e.dpos], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence := uint32(e.src[e.pos+3])<<24 | uint32(e.src[e.pos+2])<<16 | uint32(e.src[e.pos+1])<<8 | uint32(e.src[e.pos+0])
|
sequence := uint32(e.src[e.pos+3])<<24 | uint32(e.src[e.pos+2])<<16 | uint32(e.src[e.pos+1])<<8 | uint32(e.src[e.pos+0])
|
||||||
|
|
||||||
hash := (sequence * 2654435761) >> hashShift
|
hash := (sequence * 2654435761) >> hashShift
|
||||||
ref := e.hashTable[hash] + uninitHash
|
ref := e.hashTable[hash] + uninitHash
|
||||||
e.hashTable[hash] = e.pos - uninitHash
|
e.hashTable[hash] = e.pos - uninitHash
|
||||||
|
|
||||||
if ((e.pos-ref)>>16) != 0 || uint32(e.src[ref+3])<<24|uint32(e.src[ref+2])<<16|uint32(e.src[ref+1])<<8|uint32(e.src[ref+0]) != sequence {
|
if ((e.pos-ref)>>16) != 0 || uint32(e.src[ref+3])<<24|uint32(e.src[ref+2])<<16|uint32(e.src[ref+1])<<8|uint32(e.src[ref+0]) != sequence {
|
||||||
if e.pos-e.anchor > limit {
|
if e.pos-e.anchor > limit {
|
||||||
limit <<= 1
|
limit <<= 1
|
||||||
step += 1 + (step >> 2)
|
step += 1 + (step >> 2)
|
||||||
}
|
}
|
||||||
e.pos += step
|
e.pos += step
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if step > 1 {
|
if step > 1 {
|
||||||
e.hashTable[hash] = ref - uninitHash
|
e.hashTable[hash] = ref - uninitHash
|
||||||
e.pos -= step - 1
|
e.pos -= step - 1
|
||||||
step = 1
|
step = 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
limit = incompressible
|
limit = incompressible
|
||||||
|
|
||||||
ln := e.pos - e.anchor
|
ln := e.pos - e.anchor
|
||||||
back := e.pos - ref
|
back := e.pos - ref
|
||||||
|
|
||||||
anchor := e.anchor
|
anchor := e.anchor
|
||||||
|
|
||||||
e.pos += minMatch
|
e.pos += minMatch
|
||||||
ref += minMatch
|
ref += minMatch
|
||||||
e.anchor = e.pos
|
e.anchor = e.pos
|
||||||
|
|
||||||
for int(e.pos) < len(e.src)-5 && e.src[e.pos] == e.src[ref] {
|
for int(e.pos) < len(e.src)-5 && e.src[e.pos] == e.src[ref] {
|
||||||
e.pos++
|
e.pos++
|
||||||
ref++
|
ref++
|
||||||
}
|
}
|
||||||
|
|
||||||
mlLen := e.pos - e.anchor
|
mlLen := e.pos - e.anchor
|
||||||
|
|
||||||
e.writeLiterals(ln, mlLen, anchor)
|
e.writeLiterals(ln, mlLen, anchor)
|
||||||
e.dst[e.dpos] = uint8(back)
|
e.dst[e.dpos] = uint8(back)
|
||||||
e.dst[e.dpos+1] = uint8(back >> 8)
|
e.dst[e.dpos+1] = uint8(back >> 8)
|
||||||
e.dpos += 2
|
e.dpos += 2
|
||||||
|
|
||||||
if mlLen > mlMask-1 {
|
if mlLen > mlMask-1 {
|
||||||
mlLen -= mlMask
|
mlLen -= mlMask
|
||||||
for mlLen > 254 {
|
for mlLen > 254 {
|
||||||
mlLen -= 255
|
mlLen -= 255
|
||||||
|
|
||||||
e.dst[e.dpos] = 255
|
e.dst[e.dpos] = 255
|
||||||
e.dpos++
|
e.dpos++
|
||||||
}
|
}
|
||||||
|
|
||||||
e.dst[e.dpos] = byte(mlLen)
|
e.dst[e.dpos] = byte(mlLen)
|
||||||
e.dpos++
|
e.dpos++
|
||||||
}
|
}
|
||||||
|
|
||||||
e.anchor = e.pos
|
e.anchor = e.pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
generated
vendored
6
Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
generated
vendored
@ -321,10 +321,10 @@ func generateDiagram(output io.Writer, s structInfo) {
|
|||||||
case "bool":
|
case "bool":
|
||||||
fmt.Fprintf(output, "| %s |V|\n", center(name+" (V=0 or 1)", 59))
|
fmt.Fprintf(output, "| %s |V|\n", center(name+" (V=0 or 1)", 59))
|
||||||
fmt.Fprintln(output, line)
|
fmt.Fprintln(output, line)
|
||||||
case "uint16":
|
case "int16", "uint16":
|
||||||
fmt.Fprintf(output, "| %s | %s |\n", center("0x0000", 29), center(name, 29))
|
fmt.Fprintf(output, "| %s | %s |\n", center("0x0000", 29), center(name, 29))
|
||||||
fmt.Fprintln(output, line)
|
fmt.Fprintln(output, line)
|
||||||
case "uint32":
|
case "int32", "uint32":
|
||||||
fmt.Fprintf(output, "| %s |\n", center(name, 61))
|
fmt.Fprintf(output, "| %s |\n", center(name, 61))
|
||||||
fmt.Fprintln(output, line)
|
fmt.Fprintln(output, line)
|
||||||
case "int64", "uint64":
|
case "int64", "uint64":
|
||||||
@ -374,6 +374,8 @@ func generateXdr(output io.Writer, s structInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch tn {
|
switch tn {
|
||||||
|
case "int16", "int32":
|
||||||
|
fmt.Fprintf(output, "\tint %s%s;\n", fn, suf)
|
||||||
case "uint16", "uint32":
|
case "uint16", "uint32":
|
||||||
fmt.Fprintf(output, "\tunsigned int %s%s;\n", fn, suf)
|
fmt.Fprintf(output, "\tunsigned int %s%s;\n", fn, suf)
|
||||||
case "int64":
|
case "int64":
|
||||||
|
Loading…
Reference in New Issue
Block a user