diff options
Diffstat (limited to 'ber')
-rw-r--r-- | ber/new/dump.go | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/ber/new/dump.go b/ber/new/dump.go index 5baaf1e..f3ba672 100644 --- a/ber/new/dump.go +++ b/ber/new/dump.go @@ -12,32 +12,22 @@ func Dump(b []byte) string { } func (s *state) dump(ident int) string { + if s.Len() == 0 { + return "" + } h := s.ident() fmt.Printf("%*s", 2*ident, "") fmt.Printf("%v %x\n", h, s.Bytes()) if h.Kind == kindConstructed { - s.subState().dump(ident + 1) + return s.subState().dump(ident + 1) } - if h.Class == classUniversal { - /* - switch h.Tag { - case tagInteger: - fmt.Println(h.Tag, s.unmarshalInt()) - case tagObjectIdentifier: - fmt.Println(h.Tag, s.unmarshalOID()) - case tagBitString: - fmt.Println(h.Tag, s.unmarshalBitString()) - case tagIA5String, tagOctetString: - fmt.Println(h.Tag, s.unmarshalString()) - case tagBoolean: - fmt.Println(h.Tag, s.unmarshalBool()) - default: - fmt.Println(h.Tag, s.next()) - } - */ + switch h.Tag { + case tagInteger: + fmt.Println(h.Tag, s.unmarshalInt()) + // here be dragons } - if s.Len() > 0 { - s.subState().dump(ident) + for s.Len() > 0 { + s.dump(ident) } return "" } |