aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-06-30 19:15:48 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-06-30 19:15:48 +0200
commit6905df6e3b4f00786311a07f30ad32c9a9de7213 (patch)
treefaaeeb5efefac9a638c544ffaaf19f61955f86e3 /ber
parent50b0ac29b852743325bd9d57b1660f2f90b6d3c4 (diff)
Multi-byte indentifier
Diffstat (limited to 'ber')
-rw-r--r--ber/class.go14
-rw-r--r--ber/class_test.go2
2 files changed, 12 insertions, 4 deletions
diff --git a/ber/class.go b/ber/class.go
index 04a796a..f2915fe 100644
--- a/ber/class.go
+++ b/ber/class.go
@@ -34,7 +34,7 @@ var kindNames = map[Kind]string{
func (k Kind) String() string { return kindNames[k] }
-type Tag byte
+type Tag int
const (
EOT Tag = iota
@@ -105,6 +105,14 @@ var tagNames = map[Tag]string{
func (t Tag) String() string { return tagNames[t] }
-func Ident(b byte) (Class, Kind, Tag) {
- return Class(b) & classMask, Kind(b) & kindMask, Tag(b) & tagMask
+func Ident(b []byte) (Class, Kind, Tag, int) {
+ var d, n int
+ c := Class(b[0]) & classMask
+ k := Kind(b[0]) & kindMask
+ t := Tag(b[0]) & tagMask
+ if t == tagMask {
+ d, n = debase128(b[1:])
+ t = Tag(d)
+ }
+ return c, k, t, n + 1
}
diff --git a/ber/class_test.go b/ber/class_test.go
index 9b91981..d56cd87 100644
--- a/ber/class_test.go
+++ b/ber/class_test.go
@@ -10,7 +10,7 @@ var berTestData = []byte{
func ExampleIdent() {
for _, test := range berTestData {
- c, k, t := Ident(test)
+ c, k, t, _ := Ident([]byte{test})
if c == Universal {
fmt.Printf("%#x: %v %v %v\n",
test, c, k, t)