aboutsummaryrefslogtreecommitdiff
path: root/goldap/attribute_description.go
blob: 04bb03d20d2d0ea273b0ffaa4e57723317c8315b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package message

import "fmt"

//
//        AttributeDescription ::= LDAPString
//                                -- Constrained to <attributedescription>
//                                -- [RFC4512]

func (description AttributeDescription) Pointer() *AttributeDescription { return &description }

func readAttributeDescription(bytes *Bytes) (ret AttributeDescription, err error) {
	var ldapstring LDAPString
	ldapstring, err = readLDAPString(bytes)
	if err != nil {
		err = LdapError{fmt.Sprintf("readAttributeDescription:\n%s", err.Error())}
		return
	}
	// @TODO: check RFC4512
	ret = AttributeDescription(ldapstring)
	return
}

func readTaggedAttributeDescription(bytes *Bytes, class int, tag int) (ret AttributeDescription, err error) {
	var ldapstring LDAPString
	ldapstring, err = readTaggedLDAPString(bytes, class, tag)
	// @TODO: check RFC4512
	if err != nil {
		err = LdapError{fmt.Sprintf("readTaggedAttributeDescription:\n%s", err.Error())}
		return
	}
	ret = AttributeDescription(ldapstring)
	return
}

func (description AttributeDescription) size() int {
	return LDAPString(description).size()
}

func (description AttributeDescription) sizeTagged(tag int) int {
	return LDAPString(description).sizeTagged(tag)
}

func (description AttributeDescription) write(bytes *Bytes) int {
	return LDAPString(description).write(bytes)
}

func (description AttributeDescription) writeTagged(bytes *Bytes, class int, tag int) int {
	return LDAPString(description).writeTagged(bytes, class, tag)
}