aboutsummaryrefslogtreecommitdiff
path: root/ber/dump.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-25 15:07:15 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-25 15:07:15 +0200
commit0559b7d4eab07cacf0f005e8e756c1d04470e0c7 (patch)
tree45f327235303491747140bb10f92edce922b7d98 /ber/dump.go
parent5d024539d5cc2f4deaa88f783533fd453b78586f (diff)
Broken, but a step in right direction
Diffstat (limited to 'ber/dump.go')
-rw-r--r--ber/dump.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/ber/dump.go b/ber/dump.go
index 64a2672..da2c8bf 100644
--- a/ber/dump.go
+++ b/ber/dump.go
@@ -1,9 +1,12 @@
package ber
-import "fmt"
+import (
+ "bytes"
+ "fmt"
+)
func Dump(b []byte) string {
- return dump(b, 0)
+ return dump(bytes.NewBuffer(b), 0)
}
func short(b []byte) string {
@@ -13,8 +16,8 @@ func short(b []byte) string {
return fmt.Sprint(b)
}
-func dump(b []byte, indent int) (s string) {
- class, kind, tag, _, value, rest := Split(b)
+func dump(r *bytes.Buffer, indent int) (s string) {
+ class, kind, tag, _, value := Split(r)
s += fmt.Sprintf("%*s", indent*2, "")
@@ -39,11 +42,11 @@ func dump(b []byte, indent int) (s string) {
}
if len(value) > 0 && kind != kindPrimitive {
- s += dump(value, indent+1)
+ s += dump(bytes.NewBuffer(value), indent+1)
}
- if len(rest) > 0 {
- s += dump(rest, indent)
+ if r.Len() > 0 {
+ s += dump(r, indent)
}
return
}