From 54caa4e7e085e177ff05b719ae247d21fe8c257e Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 26 Sep 2015 12:04:34 +0200 Subject: Replace with new implementation --- ber/new/class.go | 135 ------------------------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 ber/new/class.go (limited to 'ber/new/class.go') diff --git a/ber/new/class.go b/ber/new/class.go deleted file mode 100644 index 094c804..0000000 --- a/ber/new/class.go +++ /dev/null @@ -1,135 +0,0 @@ -package ber - -import "fmt" - -type Header struct { - Class - Kind - Tag -} - -type Class int - -const ( - classUniversal Class = iota << 6 - classApplication - classContextSpecific - classPrivate - classMask Class = 3 << 6 -) - -var classNames = map[Class]string{ - classUniversal: "Universal", - classApplication: "Application", - classContextSpecific: "Context-specific", - classPrivate: "Private", -} - -func (c Class) String() string { return classNames[c] } - -type Kind int - -const ( - kindPrimitive Kind = iota << 5 - kindConstructed - kindMask Kind = 1 << 5 -) - -var kindNames = map[Kind]string{ - kindPrimitive: "Primitive", - kindConstructed: "Constructed", -} - -func (k Kind) String() string { return kindNames[k] } - -type Tag int - -const ( - tagEOT Tag = iota - tagBoolean - tagInteger - tagBitString - tagOctetString - tagNull - tagObjectIdentifier - tagObjectDescriptor - tagInstanceOf - tagReal - tagEnumerated - tagEmbeddedPDV - tagUTF8String - tagRelativeOID - _ - _ - tagSequence // SequenceOf - tagSet // SetOf - tagNumericString - tagPrintableString - tagTeletexString // T61String - tagVideotexString - tagIA5String - tagUTCTime - tagGeneralizedTime - tagGraphicString - tagVisibleString // ISO646String - tagGeneralString - tagUniversalString - tagCharacterString - tagBMPString - tagMask Tag = (1 << 5) - 1 -) - -var tagNames = map[Tag]string{ - tagEOT: "End-of-Content", - tagBoolean: "Boolean", - tagInteger: "Integer", - tagBitString: "Bit String", - tagOctetString: "Octet String", - tagNull: "Null", - tagObjectIdentifier: "Object Identifier", - tagObjectDescriptor: "Object Descriptor", - tagInstanceOf: "Instance Of", - tagReal: "Real", - tagEnumerated: "Enumerated", - tagEmbeddedPDV: "Embedded PDV", - tagUTF8String: "UTF8 String", - tagRelativeOID: "Relative OID", - tagSequence: "Sequence (Of)", - tagSet: "Set (Of)", - tagNumericString: "Numeric String", - tagPrintableString: "Printable String", - tagTeletexString: "Teletext String", - tagVideotexString: "Videotex String", - tagIA5String: "IA5 String", - tagUTCTime: "UTC Time", - tagGeneralizedTime: "Generalized Time", - tagGraphicString: "Graphic String", - tagVisibleString: "Visible String", - tagGeneralString: "General String", - tagUniversalString: "Universal String", - tagCharacterString: "Character String", - tagBMPString: "BMP String", -} - -func (t Tag) String() string { return tagNames[t] } - -func (s *state) ident() Header { - b, _ := s.ReadByte() - tag := Tag(b) & tagMask - if tag == tagMask { - tag = Tag(s.unmarshalBase128()) - } - return Header{ - Class: Class(b) & classMask, - Kind: Kind(b) & kindMask, - Tag: tag, - } -} - -func (h Header) String() string { - f := "%v %v %v" - if h.Class != classUniversal { - f = "%v %v %d" - } - return fmt.Sprintf(f, h.Class, h.Kind, h.Tag) -} -- cgit v1.2.3