diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2015-09-26 15:33:37 +0200 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2015-09-26 15:33:37 +0200 |
commit | b25dfbc64fddad8d27521f00666e41ec5a57c5cb (patch) | |
tree | e37c422b82071ef5627cc22e91f1dfcb184870c2 /ber/dump.go | |
parent | 0a6d80154a138f8240ba18fc670854021aeee648 (diff) |
Return proper string value
Diffstat (limited to 'ber/dump.go')
-rw-r--r-- | ber/dump.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/ber/dump.go b/ber/dump.go index 6faca25..4b4b1b9 100644 --- a/ber/dump.go +++ b/ber/dump.go @@ -8,33 +8,32 @@ func Dump(b []byte) string { return newState(b).dump(0) } -func (s *state) dump(indent int) string { +func (s *state) dump(indent int) (ret string) { if s.Len() == 0 { return "" } - //fmt.Printf("%*s%x %x\n", 2*indent, "", s.Len(), s.Bytes()) for s.Len() > 0 { h := s.unmarshalClass() - fmt.Printf("%*s%v: ", 2*indent, "", h) + ret += fmt.Sprintf("%*s%v: ", 2*indent, "", h) if h.Class == classUniversal && h.Kind == kindPrimitive { switch h.Tag { case tagInteger, tagEnumerated: - fmt.Println(s.unmarshalInt()) + ret += fmt.Sprintln(s.unmarshalInt()) case tagBoolean: - fmt.Println(s.unmarshalBool()) + ret += fmt.Sprintln(s.unmarshalBool()) case tagObjectIdentifier: - fmt.Println(s.unmarshalOID()) + ret += fmt.Sprintln(s.unmarshalOID()) case tagBitString: - fmt.Println(s.unmarshalBitString()) + ret += fmt.Sprintln(s.unmarshalBitString()) case tagIA5String, tagOctetString: - fmt.Println(s.unmarshalString()) + ret += fmt.Sprintln(s.unmarshalString()) default: - fmt.Println(s.next()) + ret += fmt.Sprintln(s.next()) } } else { - fmt.Println("→") - s.subState().dump(indent + 1) + ret += fmt.Sprintln("→") + ret += s.subState().dump(indent + 1) } } - return s.dump(indent) + return ret + s.dump(indent) } |