diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
commit | 477d7014edc787ba9a977acd19fcbfc55531768b (patch) | |
tree | ac8b65be8634fa9526cd727da60893244d11e88a /goldap/controls.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/controls.go')
-rw-r--r-- | goldap/controls.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/goldap/controls.go b/goldap/controls.go new file mode 100644 index 0000000..da3ddaf --- /dev/null +++ b/goldap/controls.go @@ -0,0 +1,44 @@ +package message + +import "fmt" + +// +// Controls ::= SEQUENCE OF control Control + +func readTaggedControls(bytes *Bytes, class int, tag int) (controls Controls, err error) { + err = bytes.ReadSubBytes(class, tag, controls.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readTaggedControls:\n%s", err.Error())} + return + } + return +} +func (controls *Controls) readComponents(bytes *Bytes) (err error) { + for bytes.HasMoreData() { + var control Control + control, err = readControl(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + *controls = append(*controls, control) + } + return +} +func (controls Controls) Pointer() *Controls { return &controls } + +func (controls Controls) writeTagged(bytes *Bytes, class int, tag int) (size int) { + for i := len(controls) - 1; i >= 0; i-- { + size += controls[i].write(bytes) + } + size += bytes.WriteTagAndLength(class, isCompound, tag, size) + return +} + +func (controls Controls) sizeTagged(tag int) (size int) { + for _, control := range controls { + size += control.size() + } + size += sizeTagAndLength(tag, size) + return +} |