aboutsummaryrefslogtreecommitdiff
path: root/ber/new/dump.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-25 20:41:38 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-25 20:41:38 +0200
commit511cf41a779929b5c81b7429c37dc11bd9544182 (patch)
tree6ab421d4b7ec868c48b40da57e3de542831767dd /ber/new/dump.go
parent0559b7d4eab07cacf0f005e8e756c1d04470e0c7 (diff)
Rewrite from scratch
Diffstat (limited to 'ber/new/dump.go')
-rw-r--r--ber/new/dump.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/ber/new/dump.go b/ber/new/dump.go
new file mode 100644
index 0000000..5baaf1e
--- /dev/null
+++ b/ber/new/dump.go
@@ -0,0 +1,43 @@
+package ber
+
+import (
+ "bytes"
+ "fmt"
+)
+
+func Dump(b []byte) string {
+ buf := bytes.NewBuffer(b)
+ s := &state{*buf}
+ return s.dump(0)
+}
+
+func (s *state) dump(ident int) string {
+ 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)
+ }
+ 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())
+ }
+ */
+ }
+ if s.Len() > 0 {
+ s.subState().dump(ident)
+ }
+ return ""
+}