1 /* schema_init.c - init builtin schema */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
18 #include "lutil_md5.h"
20 /* recycled validatation routines */
21 #define berValidate blobValidate
23 /* unimplemented validators */
24 #define bitStringValidate NULL
25 #define booleanValidate NULL
27 /* recycled normalization routines */
28 #define faxNumberNormalize numericStringNormalize
29 #define phoneNumberNormalize numericStringNormalize
30 #define telexNumberNormalize numericStringNormalize
31 #define integerNormalize numericStringNormalize
33 /* unimplemented normalizers */
34 #define bitStringNormalize NULL
35 #define booleanNormalize NULL
37 /* unimplemented pretters */
38 #define booleanPretty NULL
40 #define integerPretty NULL
42 /* recycled matching routines */
43 #define caseIgnoreMatch caseIgnoreIA5Match
44 #define caseIgnoreOrderingMatch caseIgnoreMatch
45 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
47 #define caseExactMatch caseExactIA5Match
48 #define caseExactOrderingMatch caseExactMatch
49 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
51 #define numericStringMatch caseIgnoreMatch
52 #define objectIdentifierMatch numericStringMatch
53 #define integerMatch numericStringMatch
54 #define telephoneNumberMatch numericStringMatch
55 #define telephoneNumberSubstringsMatch caseIgnoreIA5SubstringsMatch
56 #define generalizedTimeMatch numericStringMatch
57 #define generalizedTimeOrderingMatch numericStringMatch
59 /* unimplemented matching routines */
60 #define caseIgnoreListMatch NULL
61 #define caseIgnoreListSubstringsMatch NULL
62 #define bitStringMatch NULL
63 #define presentationAddressMatch NULL
64 #define uniqueMemberMatch NULL
65 #define protocolInformationMatch NULL
66 #define integerFirstComponentMatch NULL
68 #define OpenLDAPaciMatch NULL
69 #define authPasswordMatch NULL
71 /* unimplied indexer/filter routines */
72 #define caseIgnoreIA5SubstringsIndexer NULL
73 #define caseIgnoreIA5SubstringsFilter NULL
75 /* recycled indexing/filtering routines */
76 #define caseIgnoreIndexer caseIgnoreIA5Indexer
77 #define caseIgnoreFilter caseIgnoreIA5Filter
78 #define caseExactIndexer caseExactIA5Indexer
79 #define caseExactFilter caseExactIA5Filter
80 #define dnIndexer caseIgnoreIndexer
81 #define dnFilter caseIgnoreFilter
83 #define caseIgnoreSubstringsIndexer caseIgnoreIA5SubstringsIndexer
84 #define caseIgnoreSubstringsFilter caseIgnoreIA5SubstringsFilter
85 #define caseExactSubstringsIndexer caseExactIA5SubstringsIndexer
86 #define caseExactSubstringsFilter caseExactIA5SubstringsFilter
87 #define caseExactIA5SubstringsFilter caseIgnoreIA5SubstringsFilter
88 #define caseExactIA5SubstringsIndexer caseIgnoreIA5SubstringsIndexer
100 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
103 match = memcmp( value->bv_val,
104 ((struct berval *) assertedValue)->bv_val,
112 /* Index generation function */
113 int octetStringIndexer(
117 struct berval *prefix,
118 struct berval **values,
119 struct berval ***keysp )
123 struct berval **keys;
124 lutil_MD5_CTX MD5context;
125 unsigned char MD5digest[16];
126 struct berval digest;
127 digest.bv_val = MD5digest;
128 digest.bv_len = sizeof(MD5digest);
130 for( i=0; values[i] != NULL; i++ ) {
131 /* just count them */
136 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
138 slen = strlen( syntax->ssyn_oid );
139 mlen = strlen( mr->smr_oid );
141 for( i=0; values[i] != NULL; i++ ) {
142 lutil_MD5Init( &MD5context );
143 if( prefix != NULL && prefix->bv_len > 0 ) {
144 lutil_MD5Update( &MD5context,
145 prefix->bv_val, prefix->bv_len );
147 lutil_MD5Update( &MD5context,
148 syntax->ssyn_oid, slen );
149 lutil_MD5Update( &MD5context,
151 lutil_MD5Update( &MD5context,
152 values[i]->bv_val, values[i]->bv_len );
153 lutil_MD5Final( MD5digest, &MD5context );
155 keys[i] = ber_bvdup( &digest );
165 /* Index generation function */
166 int octetStringFilter(
170 struct berval *prefix,
172 struct berval ***keysp )
175 struct berval **keys;
176 lutil_MD5_CTX MD5context;
177 unsigned char MD5digest[LUTIL_MD5_BYTES];
178 struct berval *value = (struct berval *) assertValue;
179 struct berval digest;
180 digest.bv_val = MD5digest;
181 digest.bv_len = sizeof(MD5digest);
183 slen = strlen( syntax->ssyn_oid );
184 mlen = strlen( mr->smr_oid );
186 keys = ch_malloc( sizeof( struct berval * ) * 2 );
188 lutil_MD5Init( &MD5context );
189 if( prefix != NULL && prefix->bv_len > 0 ) {
190 lutil_MD5Update( &MD5context,
191 prefix->bv_val, prefix->bv_len );
193 lutil_MD5Update( &MD5context,
194 syntax->ssyn_oid, slen );
195 lutil_MD5Update( &MD5context,
197 lutil_MD5Update( &MD5context,
198 value->bv_val, value->bv_len );
199 lutil_MD5Final( MD5digest, &MD5context );
201 keys[0] = ber_bvdup( &digest );
217 if( in->bv_len == 0 ) return LDAP_SUCCESS;
219 dn = ch_strdup( in->bv_val );
221 rc = dn_validate( dn ) == NULL
222 ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
232 struct berval **normalized )
234 struct berval *out = ber_bvdup( val );
236 if( out->bv_len != 0 ) {
238 #ifdef USE_DN_NORMALIZE
239 dn = dn_normalize( out->bv_val );
241 dn = dn_validate( out->bv_val );
246 return LDAP_INVALID_SYNTAX;
250 out->bv_len = strlen( dn );
263 struct berval *value,
264 void *assertedValue )
267 struct berval *asserted = (struct berval *) assertedValue;
269 match = value->bv_len - asserted->bv_len;
272 #ifdef USE_DN_NORMALIZE
273 match = strcmp( value->bv_val, asserted->bv_val );
275 match = strcasecmp( value->bv_val, asserted->bv_val );
279 Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n",
280 match, value->bv_val, asserted->bv_val );
291 /* any value allowed */
300 /* any value allowed */
311 unsigned char *u = in->bv_val;
313 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
314 /* get the length indicated by the first byte */
315 len = LDAP_UTF8_CHARLEN( u );
317 /* should not be zero */
318 if( len == 0 ) return LDAP_INVALID_SYNTAX;
320 /* make sure len corresponds with the offset
321 to the next character */
322 if( LDAP_UTF8_OFFSET( u ) != len ) return LDAP_INVALID_SYNTAX;
325 if( count != 0 ) return LDAP_INVALID_SYNTAX;
334 struct berval **normalized )
336 struct berval *newval;
339 newval = ch_malloc( sizeof( struct berval ) );
343 /* Ignore initial whitespace */
344 while ( ldap_utf8_isspace( p ) ) {
350 return LDAP_INVALID_SYNTAX;
353 newval->bv_val = ch_strdup( p );
354 p = q = newval->bv_val;
360 if ( ldap_utf8_isspace( p ) ) {
361 len = LDAP_UTF8_COPY(q,p);
366 /* Ignore the extra whitespace */
367 while ( ldap_utf8_isspace( p ) ) {
371 len = LDAP_UTF8_COPY(q,p);
378 assert( *newval->bv_val );
379 assert( newval->bv_val < p );
382 /* cannot start with a space */
383 assert( !ldap_utf8_isspace(newval->bv_val) );
386 * If the string ended in space, backup the pointer one
387 * position. One is enough because the above loop collapsed
388 * all whitespace to a single space.
395 /* cannot end with a space */
396 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
401 newval->bv_len = q - newval->bv_val;
402 *normalized = newval;
414 if( val->bv_len == 0 ) return 0;
416 if( OID_LEADCHAR(val->bv_val[0]) ) {
418 for(i=1; i < val->bv_len; i++) {
419 if( OID_SEPARATOR( val->bv_val[i] ) ) {
420 if( dot++ ) return 1;
421 } else if ( OID_CHAR( val->bv_val[i] ) ) {
424 return LDAP_INVALID_SYNTAX;
428 return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX;
430 } else if( DESC_LEADCHAR(val->bv_val[0]) ) {
431 for(i=1; i < val->bv_len; i++) {
432 if( !DESC_CHAR(val->bv_val[i] ) ) {
433 return LDAP_INVALID_SYNTAX;
440 return LDAP_INVALID_SYNTAX;
450 for(i=0; i < val->bv_len; i++) {
451 if( !ASCII_DIGIT(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
458 printableStringValidate(
464 for(i=0; i < val->bv_len; i++) {
465 if( !isprint(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
478 for(i=0; i < val->bv_len; i++) {
479 if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
489 struct berval **out )
492 ber_len_t i, len = in->bv_len;
493 struct berval *bv = ch_malloc( sizeof(struct berval) );
495 bv->bv_len = len * sizeof( ldap_unicode_t );
496 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
498 for(i=0; i < len; i++ ) {
500 * IA5StringValidate should have been called to ensure
501 * input is limited to IA5.
503 u[i] = in->bv_val[i];
515 struct berval **normalized )
517 struct berval *newval;
520 newval = ch_malloc( sizeof( struct berval ) );
524 /* Ignore initial whitespace */
525 while ( ASCII_SPACE( *p ) ) {
531 return LDAP_INVALID_SYNTAX;
534 newval->bv_val = ch_strdup( p );
535 p = q = newval->bv_val;
538 if ( ASCII_SPACE( *p ) ) {
541 /* Ignore the extra whitespace */
542 while ( ASCII_SPACE( *p ) ) {
550 assert( *newval->bv_val );
551 assert( newval->bv_val < p );
554 /* cannot start with a space */
555 assert( !ASCII_SPACE(*newval->bv_val) );
558 * If the string ended in space, backup the pointer one
559 * position. One is enough because the above loop collapsed
560 * all whitespace to a single space.
563 if ( ASCII_SPACE( q[-1] ) ) {
567 /* cannot end with a space */
568 assert( !ASCII_SPACE( q[-1] ) );
573 newval->bv_len = q - newval->bv_val;
574 *normalized = newval;
585 struct berval *value,
586 void *assertedValue )
588 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
591 match = strncmp( value->bv_val,
592 ((struct berval *) assertedValue)->bv_val,
601 caseExactIA5SubstringsMatch(
606 struct berval *value,
607 void *assertedValue )
610 SubstringsAssertion *sub = assertedValue;
611 struct berval left = *value;
615 /* Add up asserted input length */
616 if( sub->sa_initial ) {
617 inlen += sub->sa_initial->bv_len;
620 for(i=0; sub->sa_any[i] != NULL; i++) {
621 inlen += sub->sa_any[i]->bv_len;
624 if( sub->sa_final ) {
625 inlen += sub->sa_final->bv_len;
628 if( sub->sa_initial ) {
629 if( inlen > left.bv_len ) {
634 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
635 sub->sa_initial->bv_len );
641 left.bv_val += sub->sa_initial->bv_len;
642 left.bv_len -= sub->sa_initial->bv_len;
643 inlen -= sub->sa_initial->bv_len;
646 if( sub->sa_final ) {
647 if( inlen > left.bv_len ) {
652 match = strncmp( sub->sa_final->bv_val,
653 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
654 sub->sa_final->bv_len );
660 left.bv_len -= sub->sa_final->bv_len;
661 inlen -= sub->sa_final->bv_len;
665 for(i=0; sub->sa_any[i]; i++) {
670 if( inlen > left.bv_len ) {
671 /* not enough length */
676 if( sub->sa_any[i]->bv_len == 0 ) {
680 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
687 idx = p - left.bv_val;
688 assert( idx < left.bv_len );
690 if( idx >= left.bv_len ) {
691 /* this shouldn't happen */
698 if( sub->sa_any[i]->bv_len > left.bv_len ) {
699 /* not enough left */
704 match = strncmp( left.bv_val,
705 sub->sa_any[i]->bv_val,
706 sub->sa_any[i]->bv_len );
714 left.bv_val += sub->sa_any[i]->bv_len;
715 left.bv_len -= sub->sa_any[i]->bv_len;
716 inlen -= sub->sa_any[i]->bv_len;
725 /* Index generation function */
726 int caseExactIA5Indexer(
730 struct berval *prefix,
731 struct berval **values,
732 struct berval ***keysp )
736 struct berval **keys;
737 lutil_MD5_CTX MD5context;
738 unsigned char MD5digest[16];
739 struct berval digest;
740 digest.bv_val = MD5digest;
741 digest.bv_len = sizeof(MD5digest);
743 for( i=0; values[i] != NULL; i++ ) {
744 /* just count them */
749 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
751 slen = strlen( syntax->ssyn_oid );
752 mlen = strlen( mr->smr_oid );
754 for( i=0; values[i] != NULL; i++ ) {
755 struct berval *value = values[i];
757 lutil_MD5Init( &MD5context );
758 if( prefix != NULL && prefix->bv_len > 0 ) {
759 lutil_MD5Update( &MD5context,
760 prefix->bv_val, prefix->bv_len );
762 lutil_MD5Update( &MD5context,
763 syntax->ssyn_oid, slen );
764 lutil_MD5Update( &MD5context,
766 lutil_MD5Update( &MD5context,
767 value->bv_val, value->bv_len );
768 lutil_MD5Final( MD5digest, &MD5context );
770 keys[i] = ber_bvdup( &digest );
778 /* Index generation function */
779 int caseExactIA5Filter(
783 struct berval *prefix,
785 struct berval ***keysp )
788 struct berval **keys;
789 lutil_MD5_CTX MD5context;
790 unsigned char MD5digest[LUTIL_MD5_BYTES];
791 struct berval *value;
792 struct berval digest;
793 digest.bv_val = MD5digest;
794 digest.bv_len = sizeof(MD5digest);
796 slen = strlen( syntax->ssyn_oid );
797 mlen = strlen( mr->smr_oid );
799 value = (struct berval *) assertValue;
801 keys = ch_malloc( sizeof( struct berval * ) * 2 );
803 lutil_MD5Init( &MD5context );
804 if( prefix != NULL && prefix->bv_len > 0 ) {
805 lutil_MD5Update( &MD5context,
806 prefix->bv_val, prefix->bv_len );
808 lutil_MD5Update( &MD5context,
809 syntax->ssyn_oid, slen );
810 lutil_MD5Update( &MD5context,
812 lutil_MD5Update( &MD5context,
813 value->bv_val, value->bv_len );
814 lutil_MD5Final( MD5digest, &MD5context );
816 keys[0] = ber_bvdup( &digest );
829 struct berval *value,
830 void *assertedValue )
832 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
835 match = strncasecmp( value->bv_val,
836 ((struct berval *) assertedValue)->bv_val,
844 static char *strcasechr( const char *str, int c )
846 char *lower = strchr( str, TOLOWER(c) );
847 char *upper = strchr( str, TOUPPER(c) );
849 if( lower && upper ) {
850 return lower < upper ? lower : upper;
851 } else if ( lower ) {
859 caseIgnoreIA5SubstringsMatch(
864 struct berval *value,
865 void *assertedValue )
868 SubstringsAssertion *sub = assertedValue;
869 struct berval left = *value;
873 /* Add up asserted input length */
874 if( sub->sa_initial ) {
875 inlen += sub->sa_initial->bv_len;
878 for(i=0; sub->sa_any[i] != NULL; i++) {
879 inlen += sub->sa_any[i]->bv_len;
882 if( sub->sa_final ) {
883 inlen += sub->sa_final->bv_len;
886 if( sub->sa_initial ) {
887 if( inlen > left.bv_len ) {
892 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
893 sub->sa_initial->bv_len );
899 left.bv_val += sub->sa_initial->bv_len;
900 left.bv_len -= sub->sa_initial->bv_len;
901 inlen -= sub->sa_initial->bv_len;
904 if( sub->sa_final ) {
905 if( inlen > left.bv_len ) {
910 match = strncasecmp( sub->sa_final->bv_val,
911 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
912 sub->sa_final->bv_len );
918 left.bv_len -= sub->sa_final->bv_len;
919 inlen -= sub->sa_final->bv_len;
923 for(i=0; sub->sa_any[i]; i++) {
928 if( inlen > left.bv_len ) {
929 /* not enough length */
934 if( sub->sa_any[i]->bv_len == 0 ) {
938 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
945 idx = p - left.bv_val;
946 assert( idx < left.bv_len );
948 if( idx >= left.bv_len ) {
949 /* this shouldn't happen */
956 if( sub->sa_any[i]->bv_len > left.bv_len ) {
957 /* not enough left */
962 match = strncasecmp( left.bv_val,
963 sub->sa_any[i]->bv_val,
964 sub->sa_any[i]->bv_len );
973 left.bv_val += sub->sa_any[i]->bv_len;
974 left.bv_len -= sub->sa_any[i]->bv_len;
975 inlen -= sub->sa_any[i]->bv_len;
984 /* Index generation function */
985 int caseIgnoreIA5Indexer(
989 struct berval *prefix,
990 struct berval **values,
991 struct berval ***keysp )
995 struct berval **keys;
996 lutil_MD5_CTX MD5context;
997 unsigned char MD5digest[16];
998 struct berval digest;
999 digest.bv_val = MD5digest;
1000 digest.bv_len = sizeof(MD5digest);
1002 for( i=0; values[i] != NULL; i++ ) {
1003 /* just count them */
1008 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
1010 slen = strlen( syntax->ssyn_oid );
1011 mlen = strlen( mr->smr_oid );
1013 for( i=0; values[i] != NULL; i++ ) {
1014 struct berval *value = ber_bvdup( values[i] );
1015 ldap_pvt_str2upper( value->bv_val );
1017 lutil_MD5Init( &MD5context );
1018 if( prefix != NULL && prefix->bv_len > 0 ) {
1019 lutil_MD5Update( &MD5context,
1020 prefix->bv_val, prefix->bv_len );
1022 lutil_MD5Update( &MD5context,
1023 syntax->ssyn_oid, slen );
1024 lutil_MD5Update( &MD5context,
1025 mr->smr_oid, mlen );
1026 lutil_MD5Update( &MD5context,
1027 value->bv_val, value->bv_len );
1028 lutil_MD5Final( MD5digest, &MD5context );
1030 ber_bvfree( value );
1032 keys[i] = ber_bvdup( &digest );
1037 return LDAP_SUCCESS;
1040 /* Index generation function */
1041 int caseIgnoreIA5Filter(
1045 struct berval *prefix,
1047 struct berval ***keysp )
1050 struct berval **keys;
1051 lutil_MD5_CTX MD5context;
1052 unsigned char MD5digest[LUTIL_MD5_BYTES];
1053 struct berval *value;
1054 struct berval digest;
1055 digest.bv_val = MD5digest;
1056 digest.bv_len = sizeof(MD5digest);
1058 slen = strlen( syntax->ssyn_oid );
1059 mlen = strlen( mr->smr_oid );
1061 value = ber_bvdup( (struct berval *) assertValue );
1062 ldap_pvt_str2upper( value->bv_val );
1064 keys = ch_malloc( sizeof( struct berval * ) * 2 );
1066 lutil_MD5Init( &MD5context );
1067 if( prefix != NULL && prefix->bv_len > 0 ) {
1068 lutil_MD5Update( &MD5context,
1069 prefix->bv_val, prefix->bv_len );
1071 lutil_MD5Update( &MD5context,
1072 syntax->ssyn_oid, slen );
1073 lutil_MD5Update( &MD5context,
1074 mr->smr_oid, mlen );
1075 lutil_MD5Update( &MD5context,
1076 value->bv_val, value->bv_len );
1077 lutil_MD5Final( MD5digest, &MD5context );
1079 keys[0] = ber_bvdup( &digest );
1082 ber_bvfree( value );
1085 return LDAP_SUCCESS;
1089 numericStringNormalize(
1092 struct berval **normalized )
1094 /* similiar to IA5StringNormalize except removes all spaces */
1095 struct berval *newval;
1098 newval = ch_malloc( sizeof( struct berval ) );
1102 /* Ignore initial whitespace */
1103 while ( ASCII_SPACE( *p ) ) {
1109 return LDAP_INVALID_SYNTAX;
1112 newval->bv_val = ch_strdup( p );
1113 p = q = newval->bv_val;
1116 if ( ASCII_SPACE( *p ) ) {
1117 /* Ignore whitespace */
1124 assert( *newval->bv_val );
1125 assert( newval->bv_val < p );
1128 /* cannot start with a space */
1129 assert( !ASCII_SPACE(*newval->bv_val) );
1131 /* cannot end with a space */
1132 assert( !ASCII_SPACE( q[-1] ) );
1134 /* null terminate */
1137 newval->bv_len = q - newval->bv_val;
1138 *normalized = newval;
1140 return LDAP_SUCCESS;
1144 objectIdentifierFirstComponentMatch(
1149 struct berval *value,
1150 void *assertedValue )
1152 int rc = LDAP_SUCCESS;
1154 struct berval *asserted = (struct berval *) assertedValue;
1158 if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
1159 return LDAP_INVALID_SYNTAX;
1162 /* trim leading white space */
1163 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
1167 /* grab next word */
1168 oid.bv_val = &value->bv_val[i];
1169 oid.bv_len = value->bv_len - i;
1170 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < oid.bv_len; i++ ) {
1175 /* insert attributeTypes, objectclass check here */
1176 if( OID_LEADCHAR(asserted->bv_val[0]) ) {
1177 rc = objectIdentifierMatch( &match, use, syntax, mr, &oid, asserted );
1180 char *stored = ch_malloc( oid.bv_len + 1 );
1181 memcpy( stored, oid.bv_val, oid.bv_len );
1182 stored[oid.bv_len] = '\0';
1184 if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
1185 MatchingRule *asserted_mr = mr_find( asserted->bv_val );
1186 MatchingRule *stored_mr = mr_find( stored );
1188 if( asserted_mr == NULL ) {
1189 rc = SLAPD_COMPARE_UNDEFINED;
1191 match = asserted_mr != stored_mr;
1194 } else if ( !strcmp( syntax->ssyn_oid,
1195 SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
1197 AttributeType *asserted_at = at_find( asserted->bv_val );
1198 AttributeType *stored_at = at_find( stored );
1200 if( asserted_at == NULL ) {
1201 rc = SLAPD_COMPARE_UNDEFINED;
1203 match = asserted_at != stored_at;
1206 } else if ( !strcmp( syntax->ssyn_oid,
1207 SLAP_SYNTAX_OBJECTCLASSES_OID ) )
1209 ObjectClass *asserted_oc = oc_find( asserted->bv_val );
1210 ObjectClass *stored_oc = oc_find( stored );
1212 if( asserted_oc == NULL ) {
1213 rc = SLAPD_COMPARE_UNDEFINED;
1215 match = asserted_oc != stored_oc;
1222 Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
1223 "%d\n\t\"%s\"\n\t\"%s\"\n",
1224 match, value->bv_val, asserted->bv_val );
1226 if( rc == LDAP_SUCCESS ) *matchp = match;
1231 check_time_syntax (struct berval *val,
1235 static int ceiling[9] = { 99, 99, 11, 30, 23, 59, 59, 12, 59 };
1236 static int mdays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1238 int part, c, neg = 0;
1240 if( val->bv_len == 0 )
1241 return LDAP_INVALID_SYNTAX;
1243 p = (char *)val->bv_val;
1244 e = p + val->bv_len;
1246 /* Ignore initial whitespace */
1247 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1251 if (e - p < 13 - (2 * start))
1252 return LDAP_INVALID_SYNTAX;
1254 for (part = 0; part < 9; part++)
1257 for (part = start; part < 7; part++) {
1270 return LDAP_INVALID_SYNTAX;
1272 return LDAP_INVALID_SYNTAX;
1277 return LDAP_INVALID_SYNTAX;
1279 return LDAP_INVALID_SYNTAX;
1283 if (part == 2 || part == 3)
1285 if (parts[part] < 0)
1286 return LDAP_INVALID_SYNTAX;
1287 if (parts[part] > ceiling[part])
1288 return LDAP_INVALID_SYNTAX;
1290 if (parts[2] == 1) {
1291 if (parts[3] > mdays[parts[2]])
1292 return LDAP_INVALID_SYNTAX;
1293 if (parts[1] & 0x03) {
1294 /* FIXME: This is an incomplete leap-year
1295 * check that fails in 2100, 2200, 2300,
1296 * 2500, 2600, 2700, ...
1298 if (parts[3] > mdays[parts[2]] - 1)
1299 return LDAP_INVALID_SYNTAX;
1305 } else if (c != '+' && c != '-') {
1306 return LDAP_INVALID_SYNTAX;
1311 return LDAP_INVALID_SYNTAX;
1312 for (part = 7; part < 9; part++) {
1315 return LDAP_INVALID_SYNTAX;
1320 return LDAP_INVALID_SYNTAX;
1323 if (parts[part] < 0 || parts[part] > ceiling[part])
1324 return LDAP_INVALID_SYNTAX;
1328 /* Ignore trailing whitespace */
1329 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1333 return LDAP_INVALID_SYNTAX;
1336 parts[4] += parts[7];
1337 parts[5] += parts[8];
1338 for (part = 7; --part > 0; ) {
1342 /* FIXME: This is an incomplete leap-year
1343 * check that fails in 2100, 2200, 2300,
1344 * 2500, 2600, 2700, ...
1346 c = mdays[parts[2]];
1350 if (parts[part] > c) {
1351 parts[part] -= c + 1;
1356 parts[4] -= parts[7];
1357 parts[5] -= parts[8];
1358 for (part = 7; --part > 0; ) {
1362 /* FIXME: This is an incomplete leap-year
1363 * check that fails in 2100, 2200, 2300,
1364 * 2500, 2600, 2700, ...
1366 c = mdays[(parts[2] - 1) % 12];
1370 if (parts[part] < 0) {
1371 parts[part] += c + 1;
1377 return LDAP_SUCCESS;
1384 struct berval **normalized )
1389 rc = check_time_syntax(val, 1, parts);
1390 if (rc != LDAP_SUCCESS) {
1395 out = ch_malloc( sizeof(struct berval) );
1397 return LBER_ERROR_MEMORY;
1399 out->bv_val = ch_malloc( 14 );
1400 if ( out->bv_val == NULL ) {
1402 return LBER_ERROR_MEMORY;
1405 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ",
1406 parts[1], parts[2] + 1, parts[3] + 1,
1407 parts[4], parts[5], parts[6] );
1411 return LDAP_SUCCESS;
1421 return check_time_syntax(in, 1, parts);
1425 generalizedTimeNormalize(
1428 struct berval **normalized )
1433 rc = check_time_syntax(val, 0, parts);
1434 if (rc != LDAP_SUCCESS) {
1439 out = ch_malloc( sizeof(struct berval) );
1441 return LBER_ERROR_MEMORY;
1443 out->bv_val = ch_malloc( 16 );
1444 if ( out->bv_val == NULL ) {
1446 return LBER_ERROR_MEMORY;
1449 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ",
1450 parts[0], parts[1], parts[2] + 1, parts[3] + 1,
1451 parts[4], parts[5], parts[6] );
1455 return LDAP_SUCCESS;
1459 generalizedTimeValidate(
1465 return check_time_syntax(in, 0, parts);
1468 struct syntax_defs_rec {
1471 slap_syntax_validate_func *sd_validate;
1472 slap_syntax_transform_func *sd_normalize;
1473 slap_syntax_transform_func *sd_pretty;
1474 #ifdef SLAPD_BINARY_CONVERSION
1475 slap_syntax_transform_func *sd_ber2str;
1476 slap_syntax_transform_func *sd_str2ber;
1480 #define X_HIDE "X-HIDE 'TRUE' "
1481 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
1482 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
1484 struct syntax_defs_rec syntax_defs[] = {
1485 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
1486 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
1487 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
1488 0, NULL, NULL, NULL},
1489 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
1490 0, NULL, NULL, NULL},
1491 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
1492 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
1493 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
1494 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1495 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
1496 0, bitStringValidate, bitStringNormalize, NULL },
1497 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
1498 0, booleanValidate, booleanNormalize, booleanPretty},
1499 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
1500 X_BINARY X_NOT_H_R ")",
1501 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1502 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
1503 X_BINARY X_NOT_H_R ")",
1504 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1505 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
1506 X_BINARY X_NOT_H_R ")",
1507 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1508 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
1509 0, NULL, NULL, NULL},
1510 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
1511 0, dnValidate, dnNormalize, dnPretty},
1512 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
1513 0, NULL, NULL, NULL},
1514 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
1515 0, NULL, NULL, NULL},
1516 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
1517 0, UTF8StringValidate, UTF8StringNormalize, NULL},
1518 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
1519 0, NULL, NULL, NULL},
1520 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
1521 0, NULL, NULL, NULL},
1522 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
1523 0, NULL, NULL, NULL},
1524 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
1525 0, NULL, NULL, NULL},
1526 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
1527 0, NULL, NULL, NULL},
1528 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
1529 0, IA5StringValidate, faxNumberNormalize, NULL},
1530 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
1531 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1532 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
1533 0, generalizedTimeValidate, generalizedTimeNormalize, NULL},
1534 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
1535 0, NULL, NULL, NULL},
1536 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
1537 0, IA5StringValidate, IA5StringNormalize, NULL},
1538 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
1539 0, integerValidate, integerNormalize, integerPretty},
1540 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
1541 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1542 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
1543 0, NULL, NULL, NULL},
1544 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
1545 0, NULL, NULL, NULL},
1546 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
1547 0, NULL, NULL, NULL},
1548 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
1549 0, NULL, NULL, NULL},
1550 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
1551 0, NULL, NULL, NULL},
1552 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
1553 0, NULL, NULL, NULL},
1554 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
1555 0, NULL, NULL, NULL},
1556 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
1557 0, IA5StringValidate, numericStringNormalize, NULL},
1558 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
1559 0, NULL, NULL, NULL},
1560 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
1561 0, oidValidate, NULL, NULL},
1562 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
1563 0, NULL, NULL, NULL},
1564 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
1565 0, blobValidate, NULL, NULL},
1566 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
1567 0, blobValidate, NULL, NULL},
1568 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
1569 0, NULL, NULL, NULL},
1570 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
1571 0, NULL, NULL, NULL},
1572 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
1573 0, printableStringValidate, NULL, NULL},
1574 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
1575 X_BINARY X_NOT_H_R ")",
1576 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1577 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
1578 0, IA5StringValidate, phoneNumberNormalize, NULL},
1579 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
1580 0, NULL, NULL, NULL},
1581 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
1582 0, IA5StringValidate, telexNumberNormalize, NULL},
1583 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
1584 0, utcTimeValidate, utcTimeNormalize, NULL},
1585 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
1586 0, NULL, NULL, NULL},
1587 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
1588 0, NULL, NULL, NULL},
1589 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
1590 0, NULL, NULL, NULL},
1591 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
1592 0, NULL, NULL, NULL},
1593 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
1594 0, NULL, NULL, NULL},
1596 /* OpenLDAP Experimental Syntaxes */
1597 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
1598 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */, NULL, NULL},
1599 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
1600 0, NULL, NULL, NULL},
1601 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
1602 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1603 #if 0 /* not needed */
1604 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
1605 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1608 {NULL, 0, NULL, NULL, NULL}
1611 struct mrule_defs_rec {
1614 slap_mr_convert_func * mrd_convert;
1615 slap_mr_normalize_func * mrd_normalize;
1616 slap_mr_match_func * mrd_match;
1617 slap_mr_indexer_func * mrd_indexer;
1618 slap_mr_filter_func * mrd_filter;
1622 * Other matching rules in X.520 that we do not use:
1624 * 2.5.13.9 numericStringOrderingMatch
1625 * 2.5.13.13 booleanMatch
1626 * 2.5.13.15 integerOrderingMatch
1627 * 2.5.13.18 octetStringOrderingMatch
1628 * 2.5.13.19 octetStringSubstringsMatch
1629 * 2.5.13.25 uTCTimeMatch
1630 * 2.5.13.26 uTCTimeOrderingMatch
1631 * 2.5.13.31 directoryStringFirstComponentMatch
1632 * 2.5.13.32 wordMatch
1633 * 2.5.13.33 keywordMatch
1634 * 2.5.13.34 certificateExactMatch
1635 * 2.5.13.35 certificateMatch
1636 * 2.5.13.36 certificatePairExactMatch
1637 * 2.5.13.37 certificatePairMatch
1638 * 2.5.13.38 certificateListExactMatch
1639 * 2.5.13.39 certificateListMatch
1640 * 2.5.13.40 algorithmIdentifierMatch
1641 * 2.5.13.41 storedPrefixMatch
1642 * 2.5.13.42 attributeCertificateMatch
1643 * 2.5.13.43 readerAndKeyIDMatch
1644 * 2.5.13.44 attributeIntegrityMatch
1647 struct mrule_defs_rec mrule_defs[] = {
1648 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
1649 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1650 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1651 NULL, NULL, objectIdentifierMatch,
1652 caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
1654 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
1655 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
1656 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1657 NULL, NULL, dnMatch, dnIndexer, dnFilter},
1659 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
1660 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1661 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1662 NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
1664 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
1665 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1667 NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
1669 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
1670 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1671 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1672 NULL, NULL, caseIgnoreSubstringsMatch,
1673 caseIgnoreSubstringsIndexer, caseIgnoreSubstringsFilter},
1675 /* Next three are not in the RFC's, but are needed for compatibility */
1676 {"( 2.5.13.5 NAME 'caseExactMatch' "
1677 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1678 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1679 NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
1681 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
1682 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1684 NULL, NULL, caseExactOrderingMatch, NULL, NULL},
1686 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
1687 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1688 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1689 NULL, NULL, caseExactSubstringsMatch,
1690 caseExactSubstringsIndexer, caseExactSubstringsFilter},
1692 {"( 2.5.13.8 NAME 'numericStringMatch' "
1693 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
1694 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1695 NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
1697 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
1698 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1699 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1700 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1701 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1703 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
1704 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
1705 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1706 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
1708 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
1709 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1710 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1711 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
1713 {"( 2.5.13.14 NAME 'integerMatch' "
1714 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1715 SLAP_MR_NONE | SLAP_MR_EXT,
1716 NULL, NULL, integerMatch, NULL, NULL},
1718 {"( 2.5.13.16 NAME 'bitStringMatch' "
1719 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
1720 SLAP_MR_NONE | SLAP_MR_EXT,
1721 NULL, NULL, bitStringMatch, NULL, NULL},
1723 {"( 2.5.13.17 NAME 'octetStringMatch' "
1724 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1725 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1726 NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
1728 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
1729 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
1730 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1731 NULL, NULL, telephoneNumberMatch, NULL, NULL},
1733 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
1734 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1735 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1736 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
1738 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
1739 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
1740 SLAP_MR_NONE | SLAP_MR_EXT,
1741 NULL, NULL, presentationAddressMatch, NULL, NULL},
1743 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
1744 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
1745 SLAP_MR_NONE | SLAP_MR_EXT,
1746 NULL, NULL, uniqueMemberMatch, NULL, NULL},
1748 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
1749 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
1750 SLAP_MR_NONE | SLAP_MR_EXT,
1751 NULL, NULL, protocolInformationMatch, NULL, NULL},
1753 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
1754 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1755 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1756 NULL, NULL, generalizedTimeMatch, NULL, NULL},
1758 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
1759 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1761 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
1763 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
1764 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1765 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1766 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
1768 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
1769 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1770 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1771 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
1773 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
1774 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1775 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1776 NULL, NULL, caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1778 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
1779 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1780 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1781 NULL, NULL, caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1783 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
1784 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1786 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1787 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1789 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
1790 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1792 NULL, NULL, authPasswordMatch, NULL, NULL},
1794 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
1795 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
1797 NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
1799 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
1808 /* we should only be called once (from main) */
1809 assert( schema_init_done == 0 );
1811 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
1812 res = register_syntax( syntax_defs[i].sd_desc,
1813 syntax_defs[i].sd_flags,
1814 syntax_defs[i].sd_validate,
1815 syntax_defs[i].sd_normalize,
1816 syntax_defs[i].sd_pretty
1817 #ifdef SLAPD_BINARY_CONVERSION
1819 syntax_defs[i].sd_ber2str,
1820 syntax_defs[i].sd_str2ber
1825 fprintf( stderr, "schema_init: Error registering syntax %s\n",
1826 syntax_defs[i].sd_desc );
1831 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
1832 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
1834 "schema_init: Ingoring unusable matching rule %s\n",
1835 mrule_defs[i].mrd_desc );
1839 res = register_matching_rule(
1840 mrule_defs[i].mrd_desc,
1841 mrule_defs[i].mrd_usage,
1842 mrule_defs[i].mrd_convert,
1843 mrule_defs[i].mrd_normalize,
1844 mrule_defs[i].mrd_match,
1845 mrule_defs[i].mrd_indexer,
1846 mrule_defs[i].mrd_filter );
1850 "schema_init: Error registering matching rule %s\n",
1851 mrule_defs[i].mrd_desc );
1855 schema_init_done = 1;
1856 return LDAP_SUCCESS;