aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-25 22:43:12 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-25 22:43:12 +0200
commit4083fc0161bcf1a669ad0af50145ed92c8b776ce (patch)
treeb6fa593bce22b755839f31535d9337077d24ff3e /ber
parentdc9820adf986a2dacce8c179e060c43a1653f6c6 (diff)
minor tweaking
Diffstat (limited to 'ber')
-rw-r--r--ber/new/class.go10
-rw-r--r--ber/new/common.go4
-rw-r--r--ber/new/dump.go16
3 files changed, 18 insertions, 12 deletions
diff --git a/ber/new/class.go b/ber/new/class.go
index 7e4bfd3..f0bdff8 100644
--- a/ber/new/class.go
+++ b/ber/new/class.go
@@ -1,5 +1,7 @@
package ber
+import "fmt"
+
type Header struct {
Class
Kind
@@ -123,3 +125,11 @@ func (s *state) ident() Header {
Tag: tag,
}
}
+
+func (h Header) String() string {
+ f := "%v %v %v"
+ if h.Kind != kindPrimitive {
+ f = "%v %v %d"
+ }
+ return fmt.Sprintf(f, h.Class, h.Kind, h.Tag)
+}
diff --git a/ber/new/common.go b/ber/new/common.go
index 823dc23..feb257e 100644
--- a/ber/new/common.go
+++ b/ber/new/common.go
@@ -15,9 +15,9 @@ func newState(b []byte) *state {
}
func (s *state) subState() *state {
- ss := &state{}
+ ss := state{}
ss.Write(s.next())
- return ss
+ return &ss
}
func (s *state) next() []byte {
diff --git a/ber/new/dump.go b/ber/new/dump.go
index 8293fa5..42ca123 100644
--- a/ber/new/dump.go
+++ b/ber/new/dump.go
@@ -12,19 +12,15 @@ func (s *state) dump(ident int) string {
if s.Len() == 0 {
return ""
}
+ fmt.Printf("%x %x\n", s.Len(), s.Bytes())
h := s.ident()
fmt.Printf("%*s", 2*ident, "")
- fmt.Printf("%v %x\n", h, s.Bytes())
- if h.Kind == kindConstructed {
- return s.subState().dump(ident + 1)
- }
- switch h.Tag {
- case tagInteger:
- fmt.Println(h.Tag, s.unmarshalInt())
- // here be dragons
- }
+ fmt.Println(h)
for s.Len() > 0 {
- s.dump(ident)
+ if h.Kind == kindConstructed {
+ return s.subState().dump(ident + 1)
+ }
+ s.next()
}
return ""
}