~ubuntu-branches/ubuntu/saucy/juju-core/saucy-proposed

« back to all changes in this revision

Viewing changes to src/code.google.com/p/go.crypto/openpgp/packet/compressed.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2011 The Go Authors. All rights reserved.
 
2
// Use of this source code is governed by a BSD-style
 
3
// license that can be found in the LICENSE file.
 
4
 
 
5
package packet
 
6
 
 
7
import (
 
8
        "code.google.com/p/go.crypto/openpgp/errors"
 
9
        "compress/bzip2"
 
10
        "compress/flate"
 
11
        "compress/zlib"
 
12
        "io"
 
13
        "strconv"
 
14
)
 
15
 
 
16
// Compressed represents a compressed OpenPGP packet. The decompressed contents
 
17
// will contain more OpenPGP packets. See RFC 4880, section 5.6.
 
18
type Compressed struct {
 
19
        Body io.Reader
 
20
}
 
21
 
 
22
func (c *Compressed) parse(r io.Reader) error {
 
23
        var buf [1]byte
 
24
        _, err := readFull(r, buf[:])
 
25
        if err != nil {
 
26
                return err
 
27
        }
 
28
 
 
29
        switch buf[0] {
 
30
        case 1:
 
31
                c.Body = flate.NewReader(r)
 
32
        case 2:
 
33
                c.Body, err = zlib.NewReader(r)
 
34
        case 3:
 
35
                c.Body = bzip2.NewReader(r)
 
36
        default:
 
37
                err = errors.UnsupportedError("unknown compression algorithm: " + strconv.Itoa(int(buf[0])))
 
38
        }
 
39
 
 
40
        return err
 
41
}