Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(483)

Delta Between Two Patch Sets: src/pkg/crypto/openpgp/packet/compressed.go

Issue 4124054: code review 4124054: crypto/openpgp/packet: two more packet types. (Closed)
Left Patch Set: Created 14 years, 1 month ago
Right Patch Set: diff -r d9b414fc9626 https://go.googlecode.com/hg/ Created 14 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/crypto/openpgp/packet/compressed_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 "compress/flate"
9 "compress/zlib"
10 "crypto/openpgp/error"
11 "io"
12 "os"
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) os.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 default:
35 err = error.UnsupportedError("unknown compression algorithm: " + strconv.Itoa(int(buf[0])))
36 }
37
38 return err
39 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b