aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/libldapschema
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2019-11-26 19:14:00 -0900
committerDavid M. Syzdek <david@syzdek.net>2019-11-26 19:14:00 -0900
commit3157e90a7c16e5b0326d71932877b664cb9303ec (patch)
treed24546f8bb061801ae5137a44a4419cd74581ec0 /lib/libldapschema
parent58724c95ff1c326e365ecea3d61ca149d5e2c263 (diff)
downloadldap-utils-3157e90a7c16e5b0326d71932877b664cb9303ec.tar.gz
ldap-utils-3157e90a7c16e5b0326d71932877b664cb9303ec.tar.bz2
ldap-utils-3157e90a7c16e5b0326d71932877b664cb9303ec.tar.xz
ldap-utils-3157e90a7c16e5b0326d71932877b664cb9303ec.zip
libldapschema: adding initial support for matchingRules
Diffstat (limited to 'lib/libldapschema')
-rw-r--r--lib/libldapschema/libldapschema.h10
-rw-r--r--lib/libldapschema/lldap.c22
-rw-r--r--lib/libldapschema/llexer.c179
-rw-r--r--lib/libldapschema/llexer.h5
-rw-r--r--lib/libldapschema/lmemory.c24
-rw-r--r--lib/libldapschema/lmemory.h4
-rw-r--r--lib/libldapschema/loutput.c47
-rw-r--r--lib/libldapschema/lquery.c49
8 files changed, 332 insertions, 8 deletions
diff --git a/lib/libldapschema/libldapschema.h b/lib/libldapschema/libldapschema.h
index 19fb624..ec47bbb 100644
--- a/lib/libldapschema/libldapschema.h
+++ b/lib/libldapschema/libldapschema.h
@@ -82,6 +82,8 @@ struct ldap_schema
82 size_t syntaxes_len; ///< length of syntaxes array 82 size_t syntaxes_len; ///< length of syntaxes array
83 LDAPSchemaAlias ** attrs; ///< array of attributeTypes 83 LDAPSchemaAlias ** attrs; ///< array of attributeTypes
84 size_t attrs_len; ///< length of attributeTypes array 84 size_t attrs_len; ///< length of attributeTypes array
85 LDAPSchemaAlias ** mtchngrls; ///< array of objectClasses
86 size_t mtchngrls_len; ///< length of objectClasses array
85 LDAPSchemaAlias ** objclses; ///< array of objectClasses 87 LDAPSchemaAlias ** objclses; ///< array of objectClasses
86 size_t objclses_len; ///< length of objectClasses array 88 size_t objclses_len; ///< length of objectClasses array
87 char ** schema_errs; ///< list of schema errors discovered 89 char ** schema_errs; ///< list of schema errors discovered
@@ -148,6 +150,9 @@ struct ldap_schema_attributetype
148 size_t min_upper; 150 size_t min_upper;
149 LDAPSchemaAttributeType * sup; 151 LDAPSchemaAttributeType * sup;
150 char * sup_name; 152 char * sup_name;
153 LDAPSchemaMatchingRule * equality;
154 LDAPSchemaMatchingRule * ordering;
155 LDAPSchemaMatchingRule * substr;
151 char ** names; 156 char ** names;
152 LDAPSchemaObjectclass ** allowed_by; 157 LDAPSchemaObjectclass ** allowed_by;
153 LDAPSchemaObjectclass ** required_by; 158 LDAPSchemaObjectclass ** required_by;
@@ -196,6 +201,11 @@ struct ldap_schema_syntax
196struct ldap_schema_matchingrule 201struct ldap_schema_matchingrule
197{ 202{
198 LDAPSchemaModel model; 203 LDAPSchemaModel model;
204 LDAPSchemaSyntax * syntax;
205 LDAPSchemaAttributeType ** used_by;
206 size_t used_by_len;
207 char ** names;
208 size_t names_len;
199}; 209};
200 210
201 211
diff --git a/lib/libldapschema/lldap.c b/lib/libldapschema/lldap.c
index 1ee7777..edefb71 100644
--- a/lib/libldapschema/lldap.c
+++ b/lib/libldapschema/lldap.c
@@ -152,6 +152,22 @@ int ldapschema_fetch(LDAPSchema * lsd, LDAP * ld)
152 ldap_value_free_len(vals); 152 ldap_value_free_len(vals);
153 }; 153 };
154 154
155 // process matchingRule
156 if ((vals = ldap_get_values_len(ld, msg, "matchingRules")) != NULL)
157 {
158 for(x = 0; ((vals[x])); x++)
159 {
160 if ( ((ptr = ldapschema_parse_matchingrule(lsd, vals[x])) == NULL) &&
161 (lsd->errcode != LDAPSCHEMA_SCHEMA_ERROR) )
162 {
163 ldap_value_free_len(vals);
164 ldap_msgfree(res);
165 return(-1);
166 };
167 };
168 ldap_value_free_len(vals);
169 };
170
155 // process attributeTypes 171 // process attributeTypes
156 if ((vals = ldap_get_values_len(ld, msg, "attributeTypes")) != NULL) 172 if ((vals = ldap_get_values_len(ld, msg, "attributeTypes")) != NULL)
157 { 173 {
@@ -197,6 +213,12 @@ int ldapschema_fetch(LDAPSchema * lsd, LDAP * ld)
197 attr->min_upper = attrsup->min_upper; 213 attr->min_upper = attrsup->min_upper;
198 if (!(attr->usage)) 214 if (!(attr->usage))
199 attr->usage = attrsup->usage; 215 attr->usage = attrsup->usage;
216 if (!(attr->equality))
217 attr->equality = attrsup->equality;
218 if (!(attr->ordering))
219 attr->ordering = attrsup->ordering;
220 if (!(attr->substr))
221 attr->substr = attrsup->substr;
200 }; 222 };
201 }; 223 };
202 }; 224 };
diff --git a/lib/libldapschema/llexer.c b/lib/libldapschema/llexer.c
index b009e6a..fa6439f 100644
--- a/lib/libldapschema/llexer.c
+++ b/lib/libldapschema/llexer.c
@@ -588,18 +588,24 @@ LDAPSchemaAttributeType * ldapschema_parse_attributetype(LDAPSchema * lsd, const
588 else if (!(strcasecmp(argv[pos], "EQUALITY"))) 588 else if (!(strcasecmp(argv[pos], "EQUALITY")))
589 { 589 {
590 pos++; 590 pos++;
591 if ((alias = ldapschema_find_alias(lsd, argv[pos], lsd->mtchngrls, lsd->mtchngrls_len)) != NULL)
592 attr->equality = alias->matchingrule;
591 } 593 }
592 594
593 // inteprets attributeType ORDERING 595 // inteprets attributeType ORDERING
594 else if (!(strcasecmp(argv[pos], "ORDERING"))) 596 else if (!(strcasecmp(argv[pos], "ORDERING")))
595 { 597 {
596 pos++; 598 pos++;
599 if ((alias = ldapschema_find_alias(lsd, argv[pos], lsd->mtchngrls, lsd->mtchngrls_len)) != NULL)
600 attr->ordering = alias->matchingrule;
597 } 601 }
598 602
599 // inteprets attributeType SUBSTR 603 // inteprets attributeType SUBSTR
600 else if (!(strcasecmp(argv[pos], "SUBSTR"))) 604 else if (!(strcasecmp(argv[pos], "SUBSTR")))
601 { 605 {
602 pos++; 606 pos++;
607 if ((alias = ldapschema_find_alias(lsd, argv[pos], lsd->mtchngrls, lsd->mtchngrls_len)) != NULL)
608 attr->substr = alias->matchingrule;
603 } 609 }
604 610
605 // inteprets attributeType SYNTAX 611 // inteprets attributeType SYNTAX
@@ -732,6 +738,179 @@ int ldapschema_parse_ext(LDAPSchema * lsd, LDAPSchemaModel * model, const char *
732} 738}
733 739
734 740
741/// parses a matching rule definition string
742/// @param[in] lsd Reference to pointer used to store allocated ldap_schema struct.
743/// @param[in] def Reference to pointer used to store allocated ldap_schema struct.
744///
745/// @return If the definition was successfully parsed, an LDAPSchemaMatchingRule
746/// object is added to the schema returned. NULL is returned if
747/// an error was encountered. Use ldapschema_errno() to obtain
748/// the error.
749/// @see ldapschema_errno, ldapschema_syntax_free
750LDAPSchemaMatchingRule * ldapschema_parse_matchingrule(LDAPSchema * lsd, const struct berval * def)
751{
752 //
753 // RFC 4512 LDAP Models June 2006
754 //
755 // 4.1.3. Matching Rules
756 //
757 // Matching rules are used in performance of attribute value assertions,
758 // such as in performance of a Compare operation. They are also used in
759 // evaluating search filters, determining which individual values are to
760 // be added or deleted during performance of a Modify operation, and in
761 // comparing distinguished names.
762 //
763 // Each matching rule is identified by an object identifier (OID) and,
764 // optionally, one or more short names (descriptors).
765 //
766 // Matching rule definitions are written according to the ABNF:
767 //
768 // MatchingRuleDescription = LPAREN WSP
769 // numericoid ; object identifier
770 // [ SP "NAME" SP qdescrs ] ; short names (descriptors)
771 // [ SP "DESC" SP qdstring ] ; description
772 // [ SP "OBSOLETE" ] ; not active
773 // SP "SYNTAX" SP numericoid ; assertion syntax
774 // extensions WSP RPAREN ; extensions
775 //
776 // where:
777 // <numericoid> is object identifier assigned to this matching rule;
778 // NAME <qdescrs> are short names (descriptors) identifying this
779 // matching rule;
780 // DESC <qdstring> is a short descriptive string;
781 // OBSOLETE indicates this matching rule is not active;
782 // SYNTAX identifies the assertion syntax (the syntax of the assertion
783 // value) by object identifier; and
784 //
785 char ** argv;
786 int64_t pos;
787 int argc;
788 int err;
789 LDAPSchemaMatchingRule * rule;
790 //LDAPSchemaSyntax * syntax;
791
792
793 // parses definition
794 argv = NULL;
795 if ((argc = ldapschema_definition_split_len(lsd, NULL, def, &argv)) == -1)
796 return(NULL);
797
798 // initialize matchingRule
799 if ((rule = (LDAPSchemaMatchingRule *)ldapschema_model_initialize(lsd, argv[0], LDAPSCHEMA_MATCHINGRULE, def)) == NULL)
800 {
801 ldapschema_value_free(argv);
802 return(NULL);
803 };
804
805 // processes attribute definition
806 for(pos = 1; pos < argc; pos++)
807 {
808 // inteprets extensions
809 if (!(strncasecmp(argv[pos], "X-", 2)))
810 {
811 if ((err = ldapschema_parse_ext(lsd, &rule->model, argv[pos], argv[pos+1])))
812 {
813 ldapschema_matchingrule_free(rule);
814 ldapschema_value_free(argv);
815 return(NULL);
816 };
817 pos++;
818 }
819
820 // inteprets attributeType NAME
821 else if (!(strcasecmp(argv[pos], "NAME")))
822 {
823 pos++;
824 if (argv[pos][0] == '(')
825 {
826 if ((err = ldapschema_definition_split(lsd, &rule->model, argv[pos], strlen(argv[pos]), &rule->names)) == -1)
827 {
828 ldapschema_value_free(argv);
829 ldapschema_matchingrule_free(rule);
830 return(NULL);
831 };
832 rule->names_len = (size_t)ldapschema_count_values(rule->names);
833 }
834 else
835 {
836 if ((rule->names = malloc(sizeof(char *)*2)) == NULL)
837 {
838 lsd->errcode = LDAPSCHEMA_NO_MEMORY;
839 ldapschema_value_free(argv);
840 ldapschema_matchingrule_free(rule);
841 return(NULL);
842 };
843 rule->names[1] = NULL;
844 rule->names_len = 1;
845 if ((rule->names[0] = strdup(argv[pos])) == NULL)
846 {
847 lsd->errcode = LDAPSCHEMA_NO_MEMORY;
848 ldapschema_value_free(argv);
849 ldapschema_matchingrule_free(rule);
850 return(NULL);
851 };
852 };
853 }
854
855 // inteprets syntax DESC
856 else if (!(strcasecmp(argv[pos], "DESC")))
857 {
858 pos++;
859 if (pos >= argc)
860 {
861 lsd->errcode = LDAPSCHEMA_SCHEMA_ERROR;
862 ldapschema_value_free(argv);
863 ldapschema_matchingrule_free(rule);
864 return(NULL);
865 };
866 if ((rule->model.desc))
867 free(rule->model.desc);
868 if ((rule->model.desc = strdup(argv[pos])) == NULL)
869 {
870 lsd->errcode = LDAPSCHEMA_NO_MEMORY;
871 ldapschema_value_free(argv);
872 ldapschema_matchingrule_free(rule);
873 return(NULL);
874 };
875 }
876
877 // inteprets matchingRule OBSOLETE
878 else if (!(strcasecmp(argv[pos], "OBSOLETE")))
879 {
880 rule->model.flags |= LDAPSCHEMA_O_OBSOLETE;
881 }
882
883 // inteprets attributeType SYNTAX
884 else if (!(strcasecmp(argv[pos], "SYNTAX")))
885 {
886 pos++;
887 rule->syntax = ldapschema_oid(lsd, argv[pos], LDAPSCHEMA_SYNTAX);
888 }
889
890 // handle unknown parameters
891 else
892 {
893 lsd->errcode = LDAPSCHEMA_SCHEMA_ERROR;
894 ldapschema_value_free(argv);
895 ldapschema_matchingrule_free(rule);
896 return(NULL);
897 };
898 };
899 ldapschema_value_free(argv);
900
901 // register matchingRule
902 if ((err = ldapschema_model_register(lsd, &rule->model)) != LDAP_SUCCESS)
903 {
904 ldapschema_matchingrule_free(rule);
905 return(NULL);
906 };
907
908
909 return(rule);
910}
911
912
913
735/// parses an LDAP objectClass definition string 914/// parses an LDAP objectClass definition string
736/// @param[in] lsd Reference to pointer used to store allocated ldap_schema struct. 915/// @param[in] lsd Reference to pointer used to store allocated ldap_schema struct.
737/// @param[in] def Reference to pointer used to store allocated ldap_schema struct. 916/// @param[in] def Reference to pointer used to store allocated ldap_schema struct.
diff --git a/lib/libldapschema/llexer.h b/lib/libldapschema/llexer.h
index 6f36b8d..c84a37a 100644
--- a/lib/libldapschema/llexer.h
+++ b/lib/libldapschema/llexer.h
@@ -96,6 +96,11 @@ ldapschema_parse_ext(
96 const char * key, 96 const char * key,
97 const char * valstr ); 97 const char * valstr );
98 98
99LDAPSchemaMatchingRule *
100ldapschema_parse_matchingrule(
101 LDAPSchema * lsd,
102 const struct berval * def );
103
99LDAPSchemaObjectclass * 104LDAPSchemaObjectclass *
100ldapschema_parse_objectclass( 105ldapschema_parse_objectclass(
101 LDAPSchema * lsd, 106 LDAPSchema * lsd,
diff --git a/lib/libldapschema/lmemory.c b/lib/libldapschema/lmemory.c
index b79143a..9eef1b3 100644
--- a/lib/libldapschema/lmemory.c
+++ b/lib/libldapschema/lmemory.c
@@ -220,6 +220,15 @@ void ldapschema_free(LDAPSchema * lsd)
220 }; 220 };
221 lsd->attrs = NULL; 221 lsd->attrs = NULL;
222 222
223 // frees matching rules list
224 if ((lsd->mtchngrls))
225 {
226 for(pos = 0; pos < lsd->mtchngrls_len; pos++)
227 free(lsd->mtchngrls[pos]);
228 free(lsd->mtchngrls);
229 };
230 lsd->mtchngrls = NULL;
231
223 // frees objectclass list 232 // frees objectclass list
224 if ((lsd->objclses)) 233 if ((lsd->objclses))
225 { 234 {
@@ -391,6 +400,21 @@ int ldapschema_insert(LDAPSchema * lsd, void *** listp, size_t * lenp, void * ob
391 return(LDAPSCHEMA_SUCCESS); 400 return(LDAPSCHEMA_SUCCESS);
392} 401}
393 402
403
404void ldapschema_matchingrule_free(LDAPSchemaMatchingRule * rule)
405{
406 assert(rule != NULL);
407
408 if ((rule->used_by))
409 free(rule->used_by);
410 ldapschema_object_free(&rule->model);
411
412 free(rule);
413
414 return;
415}
416
417
394void ldapschema_memfree(void * p) 418void ldapschema_memfree(void * p)
395{ 419{
396 if (!(p)) 420 if (!(p))
diff --git a/lib/libldapschema/lmemory.h b/lib/libldapschema/lmemory.h
index 639f21c..bacc476 100644
--- a/lib/libldapschema/lmemory.h
+++ b/lib/libldapschema/lmemory.h
@@ -73,6 +73,10 @@ LDAPSchemaCur
73ldapschema_curalloc( 73ldapschema_curalloc(
74 LDAPSchema * lsd ); 74 LDAPSchema * lsd );
75 75
76void
77ldapschema_matchingrule_free(
78 LDAPSchemaMatchingRule * rule);
79
76LDAPSchemaModel * 80LDAPSchemaModel *
77ldapschema_model_initialize( 81ldapschema_model_initialize(
78 LDAPSchema * lsd, 82 LDAPSchema * lsd,
diff --git a/lib/libldapschema/loutput.c b/lib/libldapschema/loutput.c
index 3a73952..a9831fd 100644
--- a/lib/libldapschema/loutput.c
+++ b/lib/libldapschema/loutput.c
@@ -124,6 +124,11 @@ ldapschema_print_obj_attributetype(
124 LDAPSchemaAttributeType * attr ); 124 LDAPSchemaAttributeType * attr );
125 125
126void 126void
127ldapschema_print_obj_matchingrule(
128 LDAPSchema * lsd,
129 LDAPSchemaMatchingRule * mtchngrl );
130
131void
127ldapschema_print_obj_model( 132ldapschema_print_obj_model(
128 LDAPSchema * lsd, 133 LDAPSchema * lsd,
129 LDAPSchemaModel * model ); 134 LDAPSchemaModel * model );
@@ -167,6 +172,12 @@ void ldapschema_print( LDAPSchema * lsd, LDAPSchemaModel * mod )
167 ldapschema_print_obj_attributetype(lsd, (LDAPSchemaAttributeType *)mod); 172 ldapschema_print_obj_attributetype(lsd, (LDAPSchemaAttributeType *)mod);
168 return; 173 return;
169 174
175 case LDAPSCHEMA_MATCHINGRULE:
176 if (mod->size != sizeof(LDAPSchemaMatchingRule))
177 return;
178 ldapschema_print_obj_matchingrule(lsd, (LDAPSchemaMatchingRule *)mod);
179 return;
180
170 case LDAPSCHEMA_OBJECTCLASS: 181 case LDAPSCHEMA_OBJECTCLASS:
171 if (mod->size != sizeof(LDAPSchemaObjectclass)) 182 if (mod->size != sizeof(LDAPSchemaObjectclass))
172 return; 183 return;
@@ -432,6 +443,7 @@ void ldapschema_print_obj_attributetype( LDAPSchema * lsd, LDAPSchemaAttributeTy
432 size_t flags; 443 size_t flags;
433 char buff[256]; 444 char buff[256];
434 LDAPSchemaSyntax * syntax; 445 LDAPSchemaSyntax * syntax;
446 LDAPSchemaMatchingRule * mtchngrl;
435 447
436 assert(lsd != NULL); 448 assert(lsd != NULL);
437 assert(attr != NULL); 449 assert(attr != NULL);
@@ -461,6 +473,13 @@ void ldapschema_print_obj_attributetype( LDAPSchema * lsd, LDAPSchemaAttributeTy
461 473
462 ldapschema_print_spec(lsd, attr->model.spec); 474 ldapschema_print_spec(lsd, attr->model.spec);
463 475
476 if ((mtchngrl = attr->equality) != NULL)
477 ldapschema_print_line("equality:", ((mtchngrl->names)) ? mtchngrl->names[0] : mtchngrl->model.oid);
478 if ((mtchngrl = attr->ordering) != NULL)
479 ldapschema_print_line("ordering:", ((mtchngrl->names)) ? mtchngrl->names[0] : mtchngrl->model.oid);
480 if ((mtchngrl = attr->substr) != NULL)
481 ldapschema_print_line("substr:", ((mtchngrl->names)) ? mtchngrl->names[0] : mtchngrl->model.oid);
482
464 // print syntax information 483 // print syntax information
465 ldapschema_print_unsigned("min upper bound:", attr->min_upper); 484 ldapschema_print_unsigned("min upper bound:", attr->min_upper);
466 if ((syntax = attr->syntax) != NULL) 485 if ((syntax = attr->syntax) != NULL)
@@ -489,6 +508,34 @@ void ldapschema_print_obj_attributetype( LDAPSchema * lsd, LDAPSchemaAttributeTy
489} 508}
490 509
491 510
511void ldapschema_print_obj_matchingrule(LDAPSchema * lsd, LDAPSchemaMatchingRule * mtchngrl)
512{
513 char buff[256];
514
515 assert(lsd != NULL);
516 assert(mtchngrl != NULL);
517
518 ldapschema_print_type(lsd, &mtchngrl->model);
519 ldapschema_print_list("name(s):", mtchngrl->names);
520 ldapschema_print_line("description:", mtchngrl->model.desc);
521 ldapschema_print_flags(lsd, &mtchngrl->model);
522
523 if ((mtchngrl->syntax))
524 {
525 if ((mtchngrl->syntax->model.desc))
526 snprintf(buff, sizeof(buff), "%s ( %s )", mtchngrl->syntax->model.oid, mtchngrl->syntax->model.desc);
527 else
528 snprintf(buff, sizeof(buff), "%s", mtchngrl->syntax->model.oid);
529 ldapschema_print_line("syntax:", buff);
530 };
531
532 ldapschema_print_extensions(lsd, &mtchngrl->model);
533 ldapschema_print_definition(lsd, &mtchngrl->model);
534
535 return;
536}
537
538
492void ldapschema_print_obj_model(LDAPSchema * lsd, LDAPSchemaModel * model) 539void ldapschema_print_obj_model(LDAPSchema * lsd, LDAPSchemaModel * model)
493{ 540{
494 assert(lsd != NULL); 541 assert(lsd != NULL);
diff --git a/lib/libldapschema/lquery.c b/lib/libldapschema/lquery.c
index b898de2..27f2fa3 100644
--- a/lib/libldapschema/lquery.c
+++ b/lib/libldapschema/lquery.c
@@ -107,8 +107,14 @@ size_t ldapschema_count_ldapsyntaxes(LDAPSchema * lsd)
107 107
108size_t ldapschema_count_matchingrules(LDAPSchema * lsd) 108size_t ldapschema_count_matchingrules(LDAPSchema * lsd)
109{ 109{
110 size_t idx;
111 size_t cnt;
110 assert(lsd != NULL); 112 assert(lsd != NULL);
111 return(0); 113 cnt = 0;
114 for(idx = 0; (idx < lsd->oids_len); idx++)
115 if (lsd->oids[idx].model->type == LDAPSCHEMA_MATCHINGRULE)
116 cnt++;
117 return(cnt);
112} 118}
113 119
114 120
@@ -223,9 +229,15 @@ LDAPSchemaSyntax * ldapschema_find_ldapsyntax(LDAPSchema * lsd,
223LDAPSchemaMatchingRule * ldapschema_find_matchingrule(LDAPSchema * lsd, 229LDAPSchemaMatchingRule * ldapschema_find_matchingrule(LDAPSchema * lsd,
224 const char * name) 230 const char * name)
225{ 231{
232 const LDAPSchemaAlias * alias;
233
226 assert(lsd != NULL); 234 assert(lsd != NULL);
227 assert(name != NULL); 235 assert(name != NULL);
228 return(NULL); 236
237 if ((alias = ldapschema_find_alias(lsd, name, lsd->mtchngrls, lsd->mtchngrls_len)) == NULL)
238 return(NULL);
239
240 return(alias->matchingrule);
229} 241}
230 242
231 243
@@ -301,6 +313,10 @@ const LDAPSchemaMatchingRule * ldapschema_first_matchingrule(LDAPSchema * lsd,
301 return(NULL); 313 return(NULL);
302 *curp = cur; 314 *curp = cur;
303 315
316 for(cur->cursor = 0; (cur->cursor < lsd->oids_len); cur->cursor++)
317 if (lsd->oids[cur->cursor].model->type == LDAPSCHEMA_MATCHINGRULE)
318 return(lsd->oids[cur->cursor].matchingrule);
319
304 return(NULL); 320 return(NULL);
305} 321}
306 322
@@ -378,13 +394,30 @@ int ldapschema_get_info_ldapsyntax(LDAPSchema * lsd,
378 394
379 395
380int ldapschema_get_info_matchingrule(LDAPSchema * lsd, 396int ldapschema_get_info_matchingrule(LDAPSchema * lsd,
381 const LDAPSchemaMatchingRule * matchingrule, int field, void * outvalue ) 397 const LDAPSchemaMatchingRule * mtchngrl, int field, void * outvalue )
382{ 398{
383 assert(lsd != NULL); 399 char *** oa; // output char ** (array of strings)
384 assert(matchingrule != NULL); 400
385 assert(field != 0); 401 assert(lsd != NULL);
386 assert(outvalue != 0); 402 assert(mtchngrl != NULL);
387 return(ldapschema_get_info_model(lsd, &matchingrule->model, field, outvalue)); 403 assert(field != 0);
404 assert(outvalue != 0);
405
406 oa = outvalue;
407
408 switch(field)
409 {
410 // char ** values (arrays of strings)
411 case LDAPSCHEMA_FLD_NAME: if ((*oa = ldapschema_value_dup(mtchngrl->names)) == NULL) return(LDAPSCHEMA_NO_MEMORY); return(0);
412
413 // misc
414 case LDAPSCHEMA_FLD_SYNTAX: *(LDAPSchemaSyntax **)outvalue = mtchngrl->syntax; return(0);
415
416 default:
417 break;
418 };
419
420 return(ldapschema_get_info_model(lsd, &mtchngrl->model, field, outvalue));
388} 421}
389 422
390 423