aboutsummaryrefslogtreecommitdiff
path: root/ber/class.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/class.go
parent5d024539d5cc2f4deaa88f783533fd453b78586f (diff)
Broken, but a step in right direction
Diffstat (limited to 'ber/class.go')
-rw-r--r--ber/class.go37
1 files changed, 9 insertions, 28 deletions
diff --git a/ber/class.go b/ber/class.go
index b734964..ab455f1 100644
--- a/ber/class.go
+++ b/ber/class.go
@@ -1,5 +1,7 @@
package ber
+import "io"
+
type Class byte
const (
@@ -105,36 +107,15 @@ var tagNames = map[Tag]string{
func (t Tag) String() string { return tagNames[t] }
-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
+func Ident(r io.ByteReader) (Class, Kind, Tag) {
+ b, _ := r.ReadByte()
+ c := Class(b) & classMask
+ k := Kind(b) & kindMask
+ t := Tag(b) & tagMask
if t == tagMask {
- d, n = debase128(b[1:])
- t = Tag(d)
+ t = Tag(Debase128(r))
}
- return c, k, t, n + 1
-}
-
-func Unversal(b []byte) (int, bool) {
- c, _, t, _ := Ident(b)
- return int(t), c == classUniversal
-}
-
-func Application(b []byte) (int, bool) {
- c, _, t, _ := Ident(b)
- return int(t), c == classApplication
-}
-
-func ContextSpecific(b []byte) (int, bool) {
- c, _, t, _ := Ident(b)
- return int(t), c == classContextSpecific
-}
-
-func Private(b []byte) (int, bool) {
- c, _, t, _ := Ident(b)
- return int(t), c == classPrivate
+ return c, k, t
}
func MarshalClass(c Class, k Kind, t Tag) []byte {