diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2015-10-07 17:26:05 +0200 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2015-10-07 17:26:05 +0200 |
commit | 5f3df5f1df86d1cd1f9881bd0c6e8e4324fbdb65 (patch) | |
tree | 65df8a23768375803c25172e27e0160b0f38d27a /ber/dump.go | |
parent | 08e9077fc4b72f5afb1685be13a9b63eb65b4cde (diff) |
Less clutter
Diffstat (limited to 'ber/dump.go')
-rw-r--r-- | ber/dump.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ber/dump.go b/ber/dump.go index e0edf94..fd1e45b 100644 --- a/ber/dump.go +++ b/ber/dump.go @@ -11,17 +11,17 @@ func Dump(b []byte) string { func (s *state) universal(h Header) string { switch h.Tag { case tagInteger, tagEnumerated: - return fmt.Sprintln(s.unmarshalInt()) + return fmt.Sprint(s.unmarshalInt()) case tagBoolean: - return fmt.Sprintln(s.unmarshalBool()) + return fmt.Sprint(s.unmarshalBool()) case tagObjectIdentifier: - return fmt.Sprintln(s.unmarshalOID()) + return fmt.Sprint(s.unmarshalOID()) case tagBitString: - return fmt.Sprintln(s.unmarshalBitString()) + return fmt.Sprint(s.unmarshalBitString()) case tagIA5String, tagOctetString: - return fmt.Sprintln(s.unmarshalString()) + return fmt.Sprint(s.unmarshalString()) default: - return fmt.Sprintln(s.next()) + return fmt.Sprint(s.next()) } } @@ -31,17 +31,23 @@ func (s *state) dump(indent int) (ret string) { } for s.Len() > 0 { h := s.unmarshalClass() - ret += fmt.Sprintf("%3d: %*s%v: ", s.Len(), 2*indent, "", h) + ret += fmt.Sprintf("%3d: %*s", s.Len(), 2*indent, "") switch h.Kind { case kindPrimitive: switch h.Class { case classUniversal: - ret += s.universal(h) + ret += fmt.Sprintln(h.Tag, "=", s.universal(h)) default: - ret += fmt.Sprintln(s.next()) + ret += fmt.Sprintln(h.Class, int(h.Tag), "=", + s.next()) } case kindConstructed: - ret += fmt.Sprintln("→") + switch h.Class { + case classUniversal: + ret += fmt.Sprintln(h.Tag, "→") + default: + ret += fmt.Sprintln(h.Class, int(h.Tag), "→") + } ret += s.subState().dump(indent + 1) } } |