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
26 /* recycled normalization routines */
27 #define faxNumberNormalize numericStringNormalize
28 #define phoneNumberNormalize numericStringNormalize
29 #define telexNumberNormalize numericStringNormalize
30 #define integerNormalize numericStringNormalize
32 /* unimplemented normalizers */
33 #define bitStringNormalize NULL
35 /* unimplemented pretters */
37 #define integerPretty NULL
39 /* recycled matching routines */
40 #define caseIgnoreMatch caseIgnoreIA5Match
41 #define caseIgnoreOrderingMatch caseIgnoreMatch
42 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
44 #define caseExactMatch caseExactIA5Match
45 #define caseExactOrderingMatch caseExactMatch
46 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
48 #define numericStringMatch caseIgnoreMatch
49 #define objectIdentifierMatch numericStringMatch
50 #define integerMatch numericStringMatch
51 #define telephoneNumberMatch numericStringMatch
52 #define telephoneNumberSubstringsMatch caseIgnoreIA5SubstringsMatch
53 #define generalizedTimeMatch numericStringMatch
54 #define generalizedTimeOrderingMatch numericStringMatch
56 /* unimplemented matching routines */
57 #define caseIgnoreListMatch NULL
58 #define caseIgnoreListSubstringsMatch NULL
59 #define bitStringMatch NULL
60 #define presentationAddressMatch NULL
61 #define uniqueMemberMatch NULL
62 #define protocolInformationMatch NULL
63 #define integerFirstComponentMatch NULL
65 #define OpenLDAPaciMatch NULL
66 #define authPasswordMatch NULL
68 /* unimplied indexer/filter routines */
69 #define caseIgnoreIA5SubstringsIndexer NULL
70 #define caseIgnoreIA5SubstringsFilter NULL
72 /* recycled indexing/filtering routines */
73 #define caseIgnoreIndexer caseIgnoreIA5Indexer
74 #define caseIgnoreFilter caseIgnoreIA5Filter
75 #define caseExactIndexer caseExactIA5Indexer
76 #define caseExactFilter caseExactIA5Filter
77 #define dnIndexer caseIgnoreIndexer
78 #define dnFilter caseIgnoreFilter
80 #define caseIgnoreSubstringsIndexer caseIgnoreIA5SubstringsIndexer
81 #define caseIgnoreSubstringsFilter caseIgnoreIA5SubstringsFilter
82 #define caseExactSubstringsIndexer caseExactIA5SubstringsIndexer
83 #define caseExactSubstringsFilter caseExactIA5SubstringsFilter
84 #define caseExactIA5SubstringsFilter caseIgnoreIA5SubstringsFilter
85 #define caseExactIA5SubstringsIndexer caseIgnoreIA5SubstringsIndexer
97 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
100 match = memcmp( value->bv_val,
101 ((struct berval *) assertedValue)->bv_val,
109 /* Index generation function */
110 int octetStringIndexer(
114 struct berval *prefix,
115 struct berval **values,
116 struct berval ***keysp )
120 struct berval **keys;
121 lutil_MD5_CTX MD5context;
122 unsigned char MD5digest[16];
123 struct berval digest;
124 digest.bv_val = MD5digest;
125 digest.bv_len = sizeof(MD5digest);
127 for( i=0; values[i] != NULL; i++ ) {
128 /* just count them */
133 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
135 slen = strlen( syntax->ssyn_oid );
136 mlen = strlen( mr->smr_oid );
138 for( i=0; values[i] != NULL; i++ ) {
139 lutil_MD5Init( &MD5context );
140 if( prefix != NULL && prefix->bv_len > 0 ) {
141 lutil_MD5Update( &MD5context,
142 prefix->bv_val, prefix->bv_len );
144 lutil_MD5Update( &MD5context,
145 syntax->ssyn_oid, slen );
146 lutil_MD5Update( &MD5context,
148 lutil_MD5Update( &MD5context,
149 values[i]->bv_val, values[i]->bv_len );
150 lutil_MD5Final( MD5digest, &MD5context );
152 keys[i] = ber_bvdup( &digest );
162 /* Index generation function */
163 int octetStringFilter(
167 struct berval *prefix,
169 struct berval ***keysp )
172 struct berval **keys;
173 lutil_MD5_CTX MD5context;
174 unsigned char MD5digest[LUTIL_MD5_BYTES];
175 struct berval *value = (struct berval *) assertValue;
176 struct berval digest;
177 digest.bv_val = MD5digest;
178 digest.bv_len = sizeof(MD5digest);
180 slen = strlen( syntax->ssyn_oid );
181 mlen = strlen( mr->smr_oid );
183 keys = ch_malloc( sizeof( struct berval * ) * 2 );
185 lutil_MD5Init( &MD5context );
186 if( prefix != NULL && prefix->bv_len > 0 ) {
187 lutil_MD5Update( &MD5context,
188 prefix->bv_val, prefix->bv_len );
190 lutil_MD5Update( &MD5context,
191 syntax->ssyn_oid, slen );
192 lutil_MD5Update( &MD5context,
194 lutil_MD5Update( &MD5context,
195 value->bv_val, value->bv_len );
196 lutil_MD5Final( MD5digest, &MD5context );
198 keys[0] = ber_bvdup( &digest );
214 if( in->bv_len == 0 ) return LDAP_SUCCESS;
216 dn = ch_strdup( in->bv_val );
218 rc = dn_validate( dn ) == NULL
219 ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
229 struct berval **normalized )
231 struct berval *out = ber_bvdup( val );
233 if( out->bv_len != 0 ) {
235 #ifdef USE_DN_NORMALIZE
236 dn = dn_normalize( out->bv_val );
238 dn = dn_validate( out->bv_val );
243 return LDAP_INVALID_SYNTAX;
247 out->bv_len = strlen( dn );
260 struct berval *value,
261 void *assertedValue )
264 struct berval *asserted = (struct berval *) assertedValue;
266 match = value->bv_len - asserted->bv_len;
269 #ifdef USE_DN_NORMALIZE
270 match = strcmp( value->bv_val, asserted->bv_val );
272 match = strcasecmp( value->bv_val, asserted->bv_val );
276 Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n",
277 match, value->bv_val, asserted->bv_val );
288 /* any value allowed */
297 /* any value allowed */
302 * Handling boolean syntax and matching is quite rigid.
303 * A more flexible approach would be to allow a variety
304 * of strings to be normalized and prettied into TRUE
312 /* very unforgiving validation, requires no normalization
313 * before simplistic matching
316 if( in->bv_len == 4 ) {
317 if( !memcmp( in->bv_val, "TRUE", 4 ) ) {
320 } else if( in->bv_len == 5 ) {
321 if( !memcmp( in->bv_val, "FALSE", 5 ) ) {
326 return LDAP_INVALID_SYNTAX;
335 struct berval *value,
336 void *assertedValue )
338 /* simplistic matching allowed by rigid validation */
339 struct berval *asserted = (struct berval *) assertedValue;
340 *matchp = value->bv_len != asserted->bv_len;
351 unsigned char *u = in->bv_val;
353 if( !in->bv_len ) return LDAP_INVALID_SYNTAX;
355 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
356 /* get the length indicated by the first byte */
357 len = LDAP_UTF8_CHARLEN( u );
359 /* should not be zero */
360 if( len == 0 ) return LDAP_INVALID_SYNTAX;
362 /* make sure len corresponds with the offset
363 to the next character */
364 if( LDAP_UTF8_OFFSET( u ) != len ) return LDAP_INVALID_SYNTAX;
367 if( count != 0 ) return LDAP_INVALID_SYNTAX;
376 struct berval **normalized )
378 struct berval *newval;
381 newval = ch_malloc( sizeof( struct berval ) );
385 /* Ignore initial whitespace */
386 while ( ldap_utf8_isspace( p ) ) {
392 return LDAP_INVALID_SYNTAX;
395 newval->bv_val = ch_strdup( p );
396 p = q = newval->bv_val;
402 if ( ldap_utf8_isspace( p ) ) {
403 len = LDAP_UTF8_COPY(q,p);
408 /* Ignore the extra whitespace */
409 while ( ldap_utf8_isspace( p ) ) {
413 len = LDAP_UTF8_COPY(q,p);
420 assert( *newval->bv_val );
421 assert( newval->bv_val < p );
424 /* cannot start with a space */
425 assert( !ldap_utf8_isspace(newval->bv_val) );
428 * If the string ended in space, backup the pointer one
429 * position. One is enough because the above loop collapsed
430 * all whitespace to a single space.
437 /* cannot end with a space */
438 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
443 newval->bv_len = q - newval->bv_val;
444 *normalized = newval;
456 if( val->bv_len == 0 ) return 0;
458 if( OID_LEADCHAR(val->bv_val[0]) ) {
460 for(i=1; i < val->bv_len; i++) {
461 if( OID_SEPARATOR( val->bv_val[i] ) ) {
462 if( dot++ ) return 1;
463 } else if ( OID_CHAR( val->bv_val[i] ) ) {
466 return LDAP_INVALID_SYNTAX;
470 return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX;
472 } else if( DESC_LEADCHAR(val->bv_val[0]) ) {
473 for(i=1; i < val->bv_len; i++) {
474 if( !DESC_CHAR(val->bv_val[i] ) ) {
475 return LDAP_INVALID_SYNTAX;
482 return LDAP_INVALID_SYNTAX;
492 if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
494 for(i=0; i < val->bv_len; i++) {
495 if( !ASCII_DIGIT(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
502 printableStringValidate(
508 if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
510 for(i=0; i < val->bv_len; i++) {
511 if( !isprint(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
524 if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
526 for(i=0; i < val->bv_len; i++) {
527 if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
537 struct berval **out )
540 ber_len_t i, len = in->bv_len;
541 struct berval *bv = ch_malloc( sizeof(struct berval) );
543 bv->bv_len = len * sizeof( ldap_unicode_t );
544 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
546 for(i=0; i < len; i++ ) {
548 * IA5StringValidate should have been called to ensure
549 * input is limited to IA5.
551 u[i] = in->bv_val[i];
563 struct berval **normalized )
565 struct berval *newval;
568 newval = ch_malloc( sizeof( struct berval ) );
572 /* Ignore initial whitespace */
573 while ( ASCII_SPACE( *p ) ) {
579 return LDAP_INVALID_SYNTAX;
582 newval->bv_val = ch_strdup( p );
583 p = q = newval->bv_val;
586 if ( ASCII_SPACE( *p ) ) {
589 /* Ignore the extra whitespace */
590 while ( ASCII_SPACE( *p ) ) {
598 assert( *newval->bv_val );
599 assert( newval->bv_val < p );
602 /* cannot start with a space */
603 assert( !ASCII_SPACE(*newval->bv_val) );
606 * If the string ended in space, backup the pointer one
607 * position. One is enough because the above loop collapsed
608 * all whitespace to a single space.
611 if ( ASCII_SPACE( q[-1] ) ) {
615 /* cannot end with a space */
616 assert( !ASCII_SPACE( q[-1] ) );
621 newval->bv_len = q - newval->bv_val;
622 *normalized = newval;
633 struct berval *value,
634 void *assertedValue )
636 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
639 match = strncmp( value->bv_val,
640 ((struct berval *) assertedValue)->bv_val,
649 caseExactIA5SubstringsMatch(
654 struct berval *value,
655 void *assertedValue )
658 SubstringsAssertion *sub = assertedValue;
659 struct berval left = *value;
663 /* Add up asserted input length */
664 if( sub->sa_initial ) {
665 inlen += sub->sa_initial->bv_len;
668 for(i=0; sub->sa_any[i] != NULL; i++) {
669 inlen += sub->sa_any[i]->bv_len;
672 if( sub->sa_final ) {
673 inlen += sub->sa_final->bv_len;
676 if( sub->sa_initial ) {
677 if( inlen > left.bv_len ) {
682 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
683 sub->sa_initial->bv_len );
689 left.bv_val += sub->sa_initial->bv_len;
690 left.bv_len -= sub->sa_initial->bv_len;
691 inlen -= sub->sa_initial->bv_len;
694 if( sub->sa_final ) {
695 if( inlen > left.bv_len ) {
700 match = strncmp( sub->sa_final->bv_val,
701 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
702 sub->sa_final->bv_len );
708 left.bv_len -= sub->sa_final->bv_len;
709 inlen -= sub->sa_final->bv_len;
713 for(i=0; sub->sa_any[i]; i++) {
718 if( inlen > left.bv_len ) {
719 /* not enough length */
724 if( sub->sa_any[i]->bv_len == 0 ) {
728 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
735 idx = p - left.bv_val;
736 assert( idx < left.bv_len );
738 if( idx >= left.bv_len ) {
739 /* this shouldn't happen */
746 if( sub->sa_any[i]->bv_len > left.bv_len ) {
747 /* not enough left */
752 match = strncmp( left.bv_val,
753 sub->sa_any[i]->bv_val,
754 sub->sa_any[i]->bv_len );
762 left.bv_val += sub->sa_any[i]->bv_len;
763 left.bv_len -= sub->sa_any[i]->bv_len;
764 inlen -= sub->sa_any[i]->bv_len;
773 /* Index generation function */
774 int caseExactIA5Indexer(
778 struct berval *prefix,
779 struct berval **values,
780 struct berval ***keysp )
784 struct berval **keys;
785 lutil_MD5_CTX MD5context;
786 unsigned char MD5digest[16];
787 struct berval digest;
788 digest.bv_val = MD5digest;
789 digest.bv_len = sizeof(MD5digest);
791 for( i=0; values[i] != NULL; i++ ) {
792 /* just count them */
797 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
799 slen = strlen( syntax->ssyn_oid );
800 mlen = strlen( mr->smr_oid );
802 for( i=0; values[i] != NULL; i++ ) {
803 struct berval *value = values[i];
805 lutil_MD5Init( &MD5context );
806 if( prefix != NULL && prefix->bv_len > 0 ) {
807 lutil_MD5Update( &MD5context,
808 prefix->bv_val, prefix->bv_len );
810 lutil_MD5Update( &MD5context,
811 syntax->ssyn_oid, slen );
812 lutil_MD5Update( &MD5context,
814 lutil_MD5Update( &MD5context,
815 value->bv_val, value->bv_len );
816 lutil_MD5Final( MD5digest, &MD5context );
818 keys[i] = ber_bvdup( &digest );
826 /* Index generation function */
827 int caseExactIA5Filter(
831 struct berval *prefix,
833 struct berval ***keysp )
836 struct berval **keys;
837 lutil_MD5_CTX MD5context;
838 unsigned char MD5digest[LUTIL_MD5_BYTES];
839 struct berval *value;
840 struct berval digest;
841 digest.bv_val = MD5digest;
842 digest.bv_len = sizeof(MD5digest);
844 slen = strlen( syntax->ssyn_oid );
845 mlen = strlen( mr->smr_oid );
847 value = (struct berval *) assertValue;
849 keys = ch_malloc( sizeof( struct berval * ) * 2 );
851 lutil_MD5Init( &MD5context );
852 if( prefix != NULL && prefix->bv_len > 0 ) {
853 lutil_MD5Update( &MD5context,
854 prefix->bv_val, prefix->bv_len );
856 lutil_MD5Update( &MD5context,
857 syntax->ssyn_oid, slen );
858 lutil_MD5Update( &MD5context,
860 lutil_MD5Update( &MD5context,
861 value->bv_val, value->bv_len );
862 lutil_MD5Final( MD5digest, &MD5context );
864 keys[0] = ber_bvdup( &digest );
877 struct berval *value,
878 void *assertedValue )
880 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
883 match = strncasecmp( value->bv_val,
884 ((struct berval *) assertedValue)->bv_val,
892 static char *strcasechr( const char *str, int c )
894 char *lower = strchr( str, TOLOWER(c) );
895 char *upper = strchr( str, TOUPPER(c) );
897 if( lower && upper ) {
898 return lower < upper ? lower : upper;
899 } else if ( lower ) {
907 caseIgnoreIA5SubstringsMatch(
912 struct berval *value,
913 void *assertedValue )
916 SubstringsAssertion *sub = assertedValue;
917 struct berval left = *value;
921 /* Add up asserted input length */
922 if( sub->sa_initial ) {
923 inlen += sub->sa_initial->bv_len;
926 for(i=0; sub->sa_any[i] != NULL; i++) {
927 inlen += sub->sa_any[i]->bv_len;
930 if( sub->sa_final ) {
931 inlen += sub->sa_final->bv_len;
934 if( sub->sa_initial ) {
935 if( inlen > left.bv_len ) {
940 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
941 sub->sa_initial->bv_len );
947 left.bv_val += sub->sa_initial->bv_len;
948 left.bv_len -= sub->sa_initial->bv_len;
949 inlen -= sub->sa_initial->bv_len;
952 if( sub->sa_final ) {
953 if( inlen > left.bv_len ) {
958 match = strncasecmp( sub->sa_final->bv_val,
959 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
960 sub->sa_final->bv_len );
966 left.bv_len -= sub->sa_final->bv_len;
967 inlen -= sub->sa_final->bv_len;
971 for(i=0; sub->sa_any[i]; i++) {
976 if( inlen > left.bv_len ) {
977 /* not enough length */
982 if( sub->sa_any[i]->bv_len == 0 ) {
986 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
993 idx = p - left.bv_val;
994 assert( idx < left.bv_len );
996 if( idx >= left.bv_len ) {
997 /* this shouldn't happen */
1004 if( sub->sa_any[i]->bv_len > left.bv_len ) {
1005 /* not enough left */
1010 match = strncasecmp( left.bv_val,
1011 sub->sa_any[i]->bv_val,
1012 sub->sa_any[i]->bv_len );
1021 left.bv_val += sub->sa_any[i]->bv_len;
1022 left.bv_len -= sub->sa_any[i]->bv_len;
1023 inlen -= sub->sa_any[i]->bv_len;
1029 return LDAP_SUCCESS;
1032 /* Index generation function */
1033 int caseIgnoreIA5Indexer(
1037 struct berval *prefix,
1038 struct berval **values,
1039 struct berval ***keysp )
1043 struct berval **keys;
1044 lutil_MD5_CTX MD5context;
1045 unsigned char MD5digest[16];
1046 struct berval digest;
1047 digest.bv_val = MD5digest;
1048 digest.bv_len = sizeof(MD5digest);
1050 for( i=0; values[i] != NULL; i++ ) {
1051 /* just count them */
1056 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
1058 slen = strlen( syntax->ssyn_oid );
1059 mlen = strlen( mr->smr_oid );
1061 for( i=0; values[i] != NULL; i++ ) {
1062 struct berval *value = ber_bvdup( values[i] );
1063 ldap_pvt_str2upper( value->bv_val );
1065 lutil_MD5Init( &MD5context );
1066 if( prefix != NULL && prefix->bv_len > 0 ) {
1067 lutil_MD5Update( &MD5context,
1068 prefix->bv_val, prefix->bv_len );
1070 lutil_MD5Update( &MD5context,
1071 syntax->ssyn_oid, slen );
1072 lutil_MD5Update( &MD5context,
1073 mr->smr_oid, mlen );
1074 lutil_MD5Update( &MD5context,
1075 value->bv_val, value->bv_len );
1076 lutil_MD5Final( MD5digest, &MD5context );
1078 ber_bvfree( value );
1080 keys[i] = ber_bvdup( &digest );
1085 return LDAP_SUCCESS;
1088 /* Index generation function */
1089 int caseIgnoreIA5Filter(
1093 struct berval *prefix,
1095 struct berval ***keysp )
1098 struct berval **keys;
1099 lutil_MD5_CTX MD5context;
1100 unsigned char MD5digest[LUTIL_MD5_BYTES];
1101 struct berval *value;
1102 struct berval digest;
1103 digest.bv_val = MD5digest;
1104 digest.bv_len = sizeof(MD5digest);
1106 slen = strlen( syntax->ssyn_oid );
1107 mlen = strlen( mr->smr_oid );
1109 value = ber_bvdup( (struct berval *) assertValue );
1110 ldap_pvt_str2upper( value->bv_val );
1112 keys = ch_malloc( sizeof( struct berval * ) * 2 );
1114 lutil_MD5Init( &MD5context );
1115 if( prefix != NULL && prefix->bv_len > 0 ) {
1116 lutil_MD5Update( &MD5context,
1117 prefix->bv_val, prefix->bv_len );
1119 lutil_MD5Update( &MD5context,
1120 syntax->ssyn_oid, slen );
1121 lutil_MD5Update( &MD5context,
1122 mr->smr_oid, mlen );
1123 lutil_MD5Update( &MD5context,
1124 value->bv_val, value->bv_len );
1125 lutil_MD5Final( MD5digest, &MD5context );
1127 keys[0] = ber_bvdup( &digest );
1130 ber_bvfree( value );
1133 return LDAP_SUCCESS;
1137 numericStringNormalize(
1140 struct berval **normalized )
1142 /* similiar to IA5StringNormalize except removes all spaces */
1143 struct berval *newval;
1146 newval = ch_malloc( sizeof( struct berval ) );
1150 /* Ignore initial whitespace */
1151 while ( ASCII_SPACE( *p ) ) {
1157 return LDAP_INVALID_SYNTAX;
1160 newval->bv_val = ch_strdup( p );
1161 p = q = newval->bv_val;
1164 if ( ASCII_SPACE( *p ) ) {
1165 /* Ignore whitespace */
1172 assert( *newval->bv_val );
1173 assert( newval->bv_val < p );
1176 /* cannot start with a space */
1177 assert( !ASCII_SPACE(*newval->bv_val) );
1179 /* cannot end with a space */
1180 assert( !ASCII_SPACE( q[-1] ) );
1182 /* null terminate */
1185 newval->bv_len = q - newval->bv_val;
1186 *normalized = newval;
1188 return LDAP_SUCCESS;
1192 objectIdentifierFirstComponentMatch(
1197 struct berval *value,
1198 void *assertedValue )
1200 int rc = LDAP_SUCCESS;
1202 struct berval *asserted = (struct berval *) assertedValue;
1206 if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
1207 return LDAP_INVALID_SYNTAX;
1210 /* trim leading white space */
1211 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
1215 /* grab next word */
1216 oid.bv_val = &value->bv_val[i];
1217 oid.bv_len = value->bv_len - i;
1218 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < oid.bv_len; i++ ) {
1223 /* insert attributeTypes, objectclass check here */
1224 if( OID_LEADCHAR(asserted->bv_val[0]) ) {
1225 rc = objectIdentifierMatch( &match, flags, syntax, mr, &oid, asserted );
1228 char *stored = ch_malloc( oid.bv_len + 1 );
1229 memcpy( stored, oid.bv_val, oid.bv_len );
1230 stored[oid.bv_len] = '\0';
1232 if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
1233 MatchingRule *asserted_mr = mr_find( asserted->bv_val );
1234 MatchingRule *stored_mr = mr_find( stored );
1236 if( asserted_mr == NULL ) {
1237 rc = SLAPD_COMPARE_UNDEFINED;
1239 match = asserted_mr != stored_mr;
1242 } else if ( !strcmp( syntax->ssyn_oid,
1243 SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
1245 AttributeType *asserted_at = at_find( asserted->bv_val );
1246 AttributeType *stored_at = at_find( stored );
1248 if( asserted_at == NULL ) {
1249 rc = SLAPD_COMPARE_UNDEFINED;
1251 match = asserted_at != stored_at;
1254 } else if ( !strcmp( syntax->ssyn_oid,
1255 SLAP_SYNTAX_OBJECTCLASSES_OID ) )
1257 ObjectClass *asserted_oc = oc_find( asserted->bv_val );
1258 ObjectClass *stored_oc = oc_find( stored );
1260 if( asserted_oc == NULL ) {
1261 rc = SLAPD_COMPARE_UNDEFINED;
1263 match = asserted_oc != stored_oc;
1270 Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
1271 "%d\n\t\"%s\"\n\t\"%s\"\n",
1272 match, value->bv_val, asserted->bv_val );
1274 if( rc == LDAP_SUCCESS ) *matchp = match;
1279 check_time_syntax (struct berval *val,
1283 static int ceiling[9] = { 99, 99, 11, 30, 23, 59, 59, 12, 59 };
1284 static int mdays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1286 int part, c, neg = 0;
1288 if( val->bv_len == 0 )
1289 return LDAP_INVALID_SYNTAX;
1291 p = (char *)val->bv_val;
1292 e = p + val->bv_len;
1294 /* Ignore initial whitespace */
1295 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1299 if (e - p < 13 - (2 * start))
1300 return LDAP_INVALID_SYNTAX;
1302 for (part = 0; part < 9; part++)
1305 for (part = start; part < 7; part++) {
1318 return LDAP_INVALID_SYNTAX;
1320 return LDAP_INVALID_SYNTAX;
1325 return LDAP_INVALID_SYNTAX;
1327 return LDAP_INVALID_SYNTAX;
1331 if (part == 2 || part == 3)
1333 if (parts[part] < 0)
1334 return LDAP_INVALID_SYNTAX;
1335 if (parts[part] > ceiling[part])
1336 return LDAP_INVALID_SYNTAX;
1338 if (parts[2] == 1) {
1339 if (parts[3] > mdays[parts[2]])
1340 return LDAP_INVALID_SYNTAX;
1341 if (parts[1] & 0x03) {
1342 /* FIXME: This is an incomplete leap-year
1343 * check that fails in 2100, 2200, 2300,
1344 * 2500, 2600, 2700, ...
1346 if (parts[3] > mdays[parts[2]] - 1)
1347 return LDAP_INVALID_SYNTAX;
1353 } else if (c != '+' && c != '-') {
1354 return LDAP_INVALID_SYNTAX;
1359 return LDAP_INVALID_SYNTAX;
1360 for (part = 7; part < 9; part++) {
1363 return LDAP_INVALID_SYNTAX;
1368 return LDAP_INVALID_SYNTAX;
1371 if (parts[part] < 0 || parts[part] > ceiling[part])
1372 return LDAP_INVALID_SYNTAX;
1376 /* Ignore trailing whitespace */
1377 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1381 return LDAP_INVALID_SYNTAX;
1384 parts[4] += parts[7];
1385 parts[5] += parts[8];
1386 for (part = 7; --part > 0; ) {
1390 /* FIXME: This is an incomplete leap-year
1391 * check that fails in 2100, 2200, 2300,
1392 * 2500, 2600, 2700, ...
1394 c = mdays[parts[2]];
1398 if (parts[part] > c) {
1399 parts[part] -= c + 1;
1404 parts[4] -= parts[7];
1405 parts[5] -= parts[8];
1406 for (part = 7; --part > 0; ) {
1410 /* FIXME: This is an incomplete leap-year
1411 * check that fails in 2100, 2200, 2300,
1412 * 2500, 2600, 2700, ...
1414 c = mdays[(parts[2] - 1) % 12];
1418 if (parts[part] < 0) {
1419 parts[part] += c + 1;
1425 return LDAP_SUCCESS;
1432 struct berval **normalized )
1437 rc = check_time_syntax(val, 1, parts);
1438 if (rc != LDAP_SUCCESS) {
1443 out = ch_malloc( sizeof(struct berval) );
1445 return LBER_ERROR_MEMORY;
1447 out->bv_val = ch_malloc( 14 );
1448 if ( out->bv_val == NULL ) {
1450 return LBER_ERROR_MEMORY;
1453 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ",
1454 parts[1], parts[2] + 1, parts[3] + 1,
1455 parts[4], parts[5], parts[6] );
1459 return LDAP_SUCCESS;
1469 return check_time_syntax(in, 1, parts);
1473 generalizedTimeValidate(
1479 return check_time_syntax(in, 0, parts);
1483 generalizedTimeNormalize(
1486 struct berval **normalized )
1491 rc = check_time_syntax(val, 0, parts);
1492 if (rc != LDAP_SUCCESS) {
1497 out = ch_malloc( sizeof(struct berval) );
1499 return LBER_ERROR_MEMORY;
1501 out->bv_val = ch_malloc( 16 );
1502 if ( out->bv_val == NULL ) {
1504 return LBER_ERROR_MEMORY;
1507 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ",
1508 parts[0], parts[1], parts[2] + 1, parts[3] + 1,
1509 parts[4], parts[5], parts[6] );
1513 return LDAP_SUCCESS;
1516 struct syntax_defs_rec {
1519 slap_syntax_validate_func *sd_validate;
1520 slap_syntax_transform_func *sd_normalize;
1521 slap_syntax_transform_func *sd_pretty;
1522 #ifdef SLAPD_BINARY_CONVERSION
1523 slap_syntax_transform_func *sd_ber2str;
1524 slap_syntax_transform_func *sd_str2ber;
1528 #define X_HIDE "X-HIDE 'TRUE' "
1529 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
1530 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
1532 struct syntax_defs_rec syntax_defs[] = {
1533 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
1534 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
1535 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
1536 0, NULL, NULL, NULL},
1537 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
1538 0, NULL, NULL, NULL},
1539 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
1540 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
1541 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
1542 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1543 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
1544 0, bitStringValidate, bitStringNormalize, NULL },
1545 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
1546 0, booleanValidate, NULL, NULL},
1547 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
1548 X_BINARY X_NOT_H_R ")",
1549 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1550 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
1551 X_BINARY X_NOT_H_R ")",
1552 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1553 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
1554 X_BINARY X_NOT_H_R ")",
1555 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1556 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
1557 0, NULL, NULL, NULL},
1558 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
1559 0, dnValidate, dnNormalize, dnPretty},
1560 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
1561 0, NULL, NULL, NULL},
1562 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
1563 0, NULL, NULL, NULL},
1564 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
1565 0, UTF8StringValidate, UTF8StringNormalize, NULL},
1566 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
1567 0, NULL, NULL, NULL},
1568 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
1569 0, NULL, NULL, NULL},
1570 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
1571 0, NULL, NULL, NULL},
1572 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
1573 0, NULL, NULL, NULL},
1574 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
1575 0, NULL, NULL, NULL},
1576 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
1577 0, IA5StringValidate, faxNumberNormalize, NULL},
1578 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
1579 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1580 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
1581 0, generalizedTimeValidate, generalizedTimeNormalize, NULL},
1582 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
1583 0, NULL, NULL, NULL},
1584 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
1585 0, IA5StringValidate, IA5StringNormalize, NULL},
1586 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
1587 0, integerValidate, integerNormalize, integerPretty},
1588 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
1589 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1590 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
1591 0, NULL, NULL, NULL},
1592 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
1593 0, NULL, NULL, NULL},
1594 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
1595 0, NULL, NULL, NULL},
1596 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
1597 0, NULL, NULL, NULL},
1598 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
1599 0, NULL, NULL, NULL},
1600 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
1601 0, NULL, NULL, NULL},
1602 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
1603 0, NULL, NULL, NULL},
1604 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
1605 0, IA5StringValidate, numericStringNormalize, NULL},
1606 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
1607 0, NULL, NULL, NULL},
1608 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
1609 0, oidValidate, NULL, NULL},
1610 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
1611 0, NULL, NULL, NULL},
1612 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
1613 0, blobValidate, NULL, NULL},
1614 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
1615 0, blobValidate, NULL, NULL},
1616 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
1617 0, NULL, NULL, NULL},
1618 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
1619 0, NULL, NULL, NULL},
1620 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
1621 0, printableStringValidate, NULL, NULL},
1622 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
1623 X_BINARY X_NOT_H_R ")",
1624 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1625 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
1626 0, IA5StringValidate, phoneNumberNormalize, NULL},
1627 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
1628 0, NULL, NULL, NULL},
1629 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
1630 0, IA5StringValidate, telexNumberNormalize, NULL},
1631 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
1632 0, utcTimeValidate, utcTimeNormalize, NULL},
1633 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
1634 0, NULL, NULL, NULL},
1635 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
1636 0, NULL, NULL, NULL},
1637 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
1638 0, NULL, NULL, NULL},
1639 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
1640 0, NULL, NULL, NULL},
1641 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
1642 0, NULL, NULL, NULL},
1644 /* OpenLDAP Experimental Syntaxes */
1645 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
1646 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */, NULL, NULL},
1647 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
1648 0, NULL, NULL, NULL},
1649 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
1650 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1651 #if 0 /* not needed */
1652 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
1653 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1656 {NULL, 0, NULL, NULL, NULL}
1659 struct mrule_defs_rec {
1662 slap_mr_convert_func * mrd_convert;
1663 slap_mr_normalize_func * mrd_normalize;
1664 slap_mr_match_func * mrd_match;
1665 slap_mr_indexer_func * mrd_indexer;
1666 slap_mr_filter_func * mrd_filter;
1670 * Other matching rules in X.520 that we do not use (yet):
1672 * 2.5.13.9 numericStringOrderingMatch
1673 * 2.5.13.13 booleanMatch
1674 * 2.5.13.15 integerOrderingMatch
1675 * 2.5.13.18 octetStringOrderingMatch
1676 * 2.5.13.19 octetStringSubstringsMatch
1677 * 2.5.13.25 uTCTimeMatch
1678 * 2.5.13.26 uTCTimeOrderingMatch
1679 * 2.5.13.31 directoryStringFirstComponentMatch
1680 * 2.5.13.32 wordMatch
1681 * 2.5.13.33 keywordMatch
1682 * 2.5.13.34 certificateExactMatch
1683 * 2.5.13.35 certificateMatch
1684 * 2.5.13.36 certificatePairExactMatch
1685 * 2.5.13.37 certificatePairMatch
1686 * 2.5.13.38 certificateListExactMatch
1687 * 2.5.13.39 certificateListMatch
1688 * 2.5.13.40 algorithmIdentifierMatch
1689 * 2.5.13.41 storedPrefixMatch
1690 * 2.5.13.42 attributeCertificateMatch
1691 * 2.5.13.43 readerAndKeyIDMatch
1692 * 2.5.13.44 attributeIntegrityMatch
1695 struct mrule_defs_rec mrule_defs[] = {
1696 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
1697 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1698 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1699 NULL, NULL, objectIdentifierMatch,
1700 caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
1702 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
1703 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
1704 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1705 NULL, NULL, dnMatch, dnIndexer, dnFilter},
1707 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
1708 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1709 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1710 NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
1712 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
1713 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1715 NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
1717 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
1718 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1719 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1720 NULL, NULL, caseIgnoreSubstringsMatch,
1721 caseIgnoreSubstringsIndexer, caseIgnoreSubstringsFilter},
1723 {"( 2.5.13.5 NAME 'caseExactMatch' "
1724 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1725 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1726 NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
1728 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
1729 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1731 NULL, NULL, caseExactOrderingMatch, NULL, NULL},
1733 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
1734 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1735 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1736 NULL, NULL, caseExactSubstringsMatch,
1737 caseExactSubstringsIndexer, caseExactSubstringsFilter},
1739 {"( 2.5.13.8 NAME 'numericStringMatch' "
1740 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
1741 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1742 NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
1744 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
1745 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1746 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1747 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1748 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1750 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
1751 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
1752 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1753 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
1755 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
1756 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1757 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1758 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
1760 {"( 2.5.13.13 NAME 'booleanMatch' "
1761 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
1762 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1763 NULL, NULL, booleanMatch, NULL, NULL},
1765 {"( 2.5.13.14 NAME 'integerMatch' "
1766 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1767 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1768 NULL, NULL, integerMatch, NULL, NULL},
1770 {"( 2.5.13.16 NAME 'bitStringMatch' "
1771 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
1772 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1773 NULL, NULL, bitStringMatch, NULL, NULL},
1775 {"( 2.5.13.17 NAME 'octetStringMatch' "
1776 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1777 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1778 NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
1780 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
1781 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
1782 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1783 NULL, NULL, telephoneNumberMatch, NULL, NULL},
1785 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
1786 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1787 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1788 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
1790 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
1791 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
1792 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1793 NULL, NULL, presentationAddressMatch, NULL, NULL},
1795 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
1796 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
1797 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1798 NULL, NULL, uniqueMemberMatch, NULL, NULL},
1800 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
1801 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
1802 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1803 NULL, NULL, protocolInformationMatch, NULL, NULL},
1805 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
1806 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1807 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1808 NULL, NULL, generalizedTimeMatch, NULL, NULL},
1810 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
1811 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1813 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
1815 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
1816 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1817 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1818 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
1820 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
1821 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1822 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1823 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
1825 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
1826 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1827 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1829 caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1831 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
1832 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1833 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1835 caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1837 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
1838 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1840 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1841 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1843 {"( 1.3.6.1.4.1.4203.666.4.3 NAME 'caseExactIA5SubstringsMatch' "
1844 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1846 NULL, NULL, caseExactIA5SubstringsMatch,
1847 caseExactIA5SubstringsIndexer, caseExactIA5SubstringsFilter},
1849 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
1850 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1852 NULL, NULL, authPasswordMatch, NULL, NULL},
1854 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
1855 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
1857 NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
1859 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
1868 /* we should only be called once (from main) */
1869 assert( schema_init_done == 0 );
1871 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
1872 res = register_syntax( syntax_defs[i].sd_desc,
1873 syntax_defs[i].sd_flags,
1874 syntax_defs[i].sd_validate,
1875 syntax_defs[i].sd_normalize,
1876 syntax_defs[i].sd_pretty
1877 #ifdef SLAPD_BINARY_CONVERSION
1879 syntax_defs[i].sd_ber2str,
1880 syntax_defs[i].sd_str2ber
1885 fprintf( stderr, "schema_init: Error registering syntax %s\n",
1886 syntax_defs[i].sd_desc );
1891 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
1892 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
1894 "schema_init: Ingoring unusable matching rule %s\n",
1895 mrule_defs[i].mrd_desc );
1899 res = register_matching_rule(
1900 mrule_defs[i].mrd_desc,
1901 mrule_defs[i].mrd_usage,
1902 mrule_defs[i].mrd_convert,
1903 mrule_defs[i].mrd_normalize,
1904 mrule_defs[i].mrd_match,
1905 mrule_defs[i].mrd_indexer,
1906 mrule_defs[i].mrd_filter );
1910 "schema_init: Error registering matching rule %s\n",
1911 mrule_defs[i].mrd_desc );
1915 schema_init_done = 1;
1916 return LDAP_SUCCESS;