Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
include subentryNameForm definition (X.501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Coretta authored and Jesse Coretta committed Oct 18, 2024
1 parent 7efc010 commit 1917a7d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ var (
rfc2307Macros map[string]string = rfc2307.Macros

x501AttributeTypes x501.AttributeTypeDefinitions = x501.AllAttributeTypes
x501NameForms x501.NameFormDefinitions = x501.AllNameForms
rfc2079AttributeTypes rfc2079.AttributeTypeDefinitions = rfc2079.AllAttributeTypes
rfc2307AttributeTypes rfc2307.AttributeTypeDefinitions = rfc2307.AllAttributeTypes
rfc2589AttributeTypes rfc2589.AttributeTypeDefinitions = rfc2589.AllAttributeTypes
Expand Down
24 changes: 24 additions & 0 deletions internal/x501/nf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package x501

type NameFormDefinitions []NameFormDefinition
type NameFormDefinition string

func (r NameFormDefinitions) Len() int {
return len(r)
}

var AllNameForms NameFormDefinitions
var SubentryNameForm NameFormDefinition

func (r NameFormDefinition) String() string {
return string(r)
}

func init() {

SubentryNameForm = NameFormDefinition(`( 2.5.15.16 NAME 'subentryNameForm' OC subentry MUST cn X-ORIGIN 'X.501' )`)
AllNameForms = NameFormDefinitions{
SubentryNameForm,
}

}
29 changes: 29 additions & 0 deletions nf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ func (r Schema) loadNameForms() (err error) {
if !r.IsZero() {
funks := []func() error{
r.loadRFC4403NameForms,
r.loadX501NameForms,
}

for i := 0; i < len(funks) && err == nil; i++ {
Expand Down Expand Up @@ -1063,3 +1064,31 @@ func (r Schema) loadRFC4403NameForms() (err error) {

return
}

/*
LoadX501NameForm returns an error following an attempt to load all
[ITU-T Rec. X.501] [NameForm] slices into the receiver instance.
[ITU-T Rec. X.501]: https://www.itu.int/rec/T-REC-X.501
*/
func (r Schema) LoadX501NameForms() error {
return r.loadX501NameForms()
}

func (r Schema) loadX501NameForms() (err error) {

var i int
for i = 0; i < len(x501NameForms) && err == nil; i++ {
nf := x501NameForms[i]
err = r.ParseNameForm(string(nf))
}

if want := x501NameForms.Len(); i != want {
if err == nil {
err = mkerr("Unexpected number of X.501 NameForms parsed: want " +
itoa(want) + ", got " + itoa(i))
}
}

return
}

0 comments on commit 1917a7d

Please sign in to comment.