aboutsummaryrefslogtreecommitdiff
path: root/ber/bits.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-14 23:22:04 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-14 23:22:04 +0200
commit6d033680eb74abe871e7b261e6911d646f9e365b (patch)
tree8c6e72f422aacc24320827d243651a1a60c6b5b2 /ber/bits.go
parenta1a7ee2520f375ab85a6e2a4a170e7e5116be1f4 (diff)
Rename Bits into BitString
Diffstat (limited to 'ber/bits.go')
-rw-r--r--ber/bits.go48
1 files changed, 0 insertions, 48 deletions
diff --git a/ber/bits.go b/ber/bits.go
deleted file mode 100644
index 180228d..0000000
--- a/ber/bits.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package ber
-
-// BitString
-type Bits []bool
-
-func UnmarshalBitString(b []byte) (bs Bits) {
- padding := int(b[0])
- length := (len(b)-1)*8 - padding
- for i := 0; i < length; i++ {
- x := 1 + i/8
- y := 7 - uint(i%8)
- bit := b[x]&(1<<y) != 0
- bs = append(bs, bit)
- }
- return
-}
-
-func MarshalBitString(bs Bits) (b []byte) {
- padding := (8 - len(bs)%8) % 8
- length := len(bs) / 8
- if padding != 0 {
- length++
- }
- b = make([]byte, length+1)
- b[0] = byte(padding)
- for i, bi := range bs {
- x := 1 + i/8
- y := 7 - uint(i%8)
- if bi {
- b[x] |= 1 << y
- }
- }
- return
-}
-
-func (bs Bits) String() (s string) {
- bmap := map[bool]string{
- true: "1",
- false: "0",
- }
- for i, bit := range bs {
- if i > 0 && i%4 == 0 {
- s += " "
- }
- s += bmap[bit]
- }
- return
-}