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 /* approx matching rules */
57 #define directoryStringApproxMatchOID "1.3.6.1.4.1.4203.666.4.4"
58 #define directoryStringApproxMatch NULL
59 #define IA5StringApproxMatchOID "1.3.6.1.4.1.4203.666.4.5"
60 #define IA5StringApproxMatch NULL
62 /* unimplemented matching routines */
63 #define caseIgnoreListMatch NULL
64 #define caseIgnoreListSubstringsMatch NULL
65 #define bitStringMatch NULL
66 #define presentationAddressMatch NULL
67 #define uniqueMemberMatch NULL
68 #define protocolInformationMatch NULL
69 #define integerFirstComponentMatch NULL
71 #define OpenLDAPaciMatch NULL
72 #define authPasswordMatch NULL
74 /* recycled indexing/filtering routines */
75 #define caseIgnoreIndexer caseIgnoreIA5Indexer
76 #define caseIgnoreFilter caseIgnoreIA5Filter
77 #define caseExactIndexer caseExactIA5Indexer
78 #define caseExactFilter caseExactIA5Filter
79 #define dnIndexer caseIgnoreIndexer
80 #define dnFilter caseIgnoreFilter
82 #define caseIgnoreSubstringsIndexer caseIgnoreIA5SubstringsIndexer
83 #define caseIgnoreSubstringsFilter caseIgnoreIA5SubstringsFilter
84 #define caseExactSubstringsIndexer caseExactIA5SubstringsIndexer
85 #define caseExactSubstringsFilter caseExactIA5SubstringsFilter
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 u = (ldap_unicode_t *) ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
545 bv->bv_val = (char *) u;
547 for(i=0; i < len; i++ ) {
549 * IA5StringValidate should have been called to ensure
550 * input is limited to IA5.
552 u[i] = in->bv_val[i];
564 struct berval **normalized )
566 struct berval *newval;
569 newval = ch_malloc( sizeof( struct berval ) );
573 /* Ignore initial whitespace */
574 while ( ASCII_SPACE( *p ) ) {
580 return LDAP_INVALID_SYNTAX;
583 newval->bv_val = ch_strdup( p );
584 p = q = newval->bv_val;
587 if ( ASCII_SPACE( *p ) ) {
590 /* Ignore the extra whitespace */
591 while ( ASCII_SPACE( *p ) ) {
599 assert( *newval->bv_val );
600 assert( newval->bv_val < p );
603 /* cannot start with a space */
604 assert( !ASCII_SPACE(*newval->bv_val) );
607 * If the string ended in space, backup the pointer one
608 * position. One is enough because the above loop collapsed
609 * all whitespace to a single space.
612 if ( ASCII_SPACE( q[-1] ) ) {
616 /* cannot end with a space */
617 assert( !ASCII_SPACE( q[-1] ) );
622 newval->bv_len = q - newval->bv_val;
623 *normalized = newval;
634 struct berval *value,
635 void *assertedValue )
637 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
640 match = strncmp( value->bv_val,
641 ((struct berval *) assertedValue)->bv_val,
650 caseExactIA5SubstringsMatch(
655 struct berval *value,
656 void *assertedValue )
659 SubstringsAssertion *sub = assertedValue;
660 struct berval left = *value;
664 /* Add up asserted input length */
665 if( sub->sa_initial ) {
666 inlen += sub->sa_initial->bv_len;
669 for(i=0; sub->sa_any[i] != NULL; i++) {
670 inlen += sub->sa_any[i]->bv_len;
673 if( sub->sa_final ) {
674 inlen += sub->sa_final->bv_len;
677 if( sub->sa_initial ) {
678 if( inlen > left.bv_len ) {
683 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
684 sub->sa_initial->bv_len );
690 left.bv_val += sub->sa_initial->bv_len;
691 left.bv_len -= sub->sa_initial->bv_len;
692 inlen -= sub->sa_initial->bv_len;
695 if( sub->sa_final ) {
696 if( inlen > left.bv_len ) {
701 match = strncmp( sub->sa_final->bv_val,
702 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
703 sub->sa_final->bv_len );
709 left.bv_len -= sub->sa_final->bv_len;
710 inlen -= sub->sa_final->bv_len;
714 for(i=0; sub->sa_any[i]; i++) {
719 if( inlen > left.bv_len ) {
720 /* not enough length */
725 if( sub->sa_any[i]->bv_len == 0 ) {
729 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
736 idx = p - left.bv_val;
737 assert( idx < left.bv_len );
739 if( idx >= left.bv_len ) {
740 /* this shouldn't happen */
747 if( sub->sa_any[i]->bv_len > left.bv_len ) {
748 /* not enough left */
753 match = strncmp( left.bv_val,
754 sub->sa_any[i]->bv_val,
755 sub->sa_any[i]->bv_len );
763 left.bv_val += sub->sa_any[i]->bv_len;
764 left.bv_len -= sub->sa_any[i]->bv_len;
765 inlen -= sub->sa_any[i]->bv_len;
774 /* Index generation function */
775 int caseExactIA5Indexer(
779 struct berval *prefix,
780 struct berval **values,
781 struct berval ***keysp )
785 struct berval **keys;
786 lutil_MD5_CTX MD5context;
787 unsigned char MD5digest[16];
788 struct berval digest;
789 digest.bv_val = MD5digest;
790 digest.bv_len = sizeof(MD5digest);
792 for( i=0; values[i] != NULL; i++ ) {
793 /* just count them */
798 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
800 slen = strlen( syntax->ssyn_oid );
801 mlen = strlen( mr->smr_oid );
803 for( i=0; values[i] != NULL; i++ ) {
804 struct berval *value = values[i];
806 lutil_MD5Init( &MD5context );
807 if( prefix != NULL && prefix->bv_len > 0 ) {
808 lutil_MD5Update( &MD5context,
809 prefix->bv_val, prefix->bv_len );
811 lutil_MD5Update( &MD5context,
812 syntax->ssyn_oid, slen );
813 lutil_MD5Update( &MD5context,
815 lutil_MD5Update( &MD5context,
816 value->bv_val, value->bv_len );
817 lutil_MD5Final( MD5digest, &MD5context );
819 keys[i] = ber_bvdup( &digest );
827 /* Index generation function */
828 int caseExactIA5Filter(
832 struct berval *prefix,
834 struct berval ***keysp )
837 struct berval **keys;
838 lutil_MD5_CTX MD5context;
839 unsigned char MD5digest[LUTIL_MD5_BYTES];
840 struct berval *value;
841 struct berval digest;
842 digest.bv_val = MD5digest;
843 digest.bv_len = sizeof(MD5digest);
845 slen = strlen( syntax->ssyn_oid );
846 mlen = strlen( mr->smr_oid );
848 value = (struct berval *) assertValue;
850 keys = ch_malloc( sizeof( struct berval * ) * 2 );
852 lutil_MD5Init( &MD5context );
853 if( prefix != NULL && prefix->bv_len > 0 ) {
854 lutil_MD5Update( &MD5context,
855 prefix->bv_val, prefix->bv_len );
857 lutil_MD5Update( &MD5context,
858 syntax->ssyn_oid, slen );
859 lutil_MD5Update( &MD5context,
861 lutil_MD5Update( &MD5context,
862 value->bv_val, value->bv_len );
863 lutil_MD5Final( MD5digest, &MD5context );
865 keys[0] = ber_bvdup( &digest );
872 /* Substrings Index generation function */
873 int caseExactIA5SubstringsIndexer(
877 struct berval *prefix,
878 struct berval **values,
879 struct berval ***keysp )
883 struct berval **keys;
884 lutil_MD5_CTX MD5context;
885 unsigned char MD5digest[16];
886 struct berval digest;
887 digest.bv_val = MD5digest;
888 digest.bv_len = sizeof(MD5digest);
891 for( i=0; values[i] != NULL; i++ ) {
892 /* count number of indices to generate */
893 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
897 if( flags & SLAP_MR_SUBSTR_INITIAL ) {
898 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
899 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
900 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
902 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
906 if( flags & SLAP_MR_SUBSTR_ANY ) {
907 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
908 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
912 if( flags & SLAP_MR_SUBSTR_FINAL ) {
913 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
914 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
915 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
917 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
924 /* no keys to generate */
929 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
931 slen = strlen( syntax->ssyn_oid );
932 mlen = strlen( mr->smr_oid );
935 for( i=0; values[i] != NULL; i++ ) {
937 struct berval *value;
940 if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
942 if( ( flags & SLAP_MR_SUBSTR_ANY ) &&
943 ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
945 char pre = SLAP_INDEX_SUBSTR_PREFIX;
946 max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
948 for( j=0; j<max; j++ ) {
949 lutil_MD5Init( &MD5context );
950 if( prefix != NULL && prefix->bv_len > 0 ) {
951 lutil_MD5Update( &MD5context,
952 prefix->bv_val, prefix->bv_len );
955 lutil_MD5Update( &MD5context,
956 &pre, sizeof( pre ) );
957 lutil_MD5Update( &MD5context,
958 syntax->ssyn_oid, slen );
959 lutil_MD5Update( &MD5context,
961 lutil_MD5Update( &MD5context,
963 SLAP_INDEX_SUBSTR_MAXLEN );
964 lutil_MD5Final( MD5digest, &MD5context );
966 keys[nkeys++] = ber_bvdup( &digest );
970 max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
971 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
973 for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
976 if( flags & SLAP_MR_SUBSTR_INITIAL ) {
977 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
978 lutil_MD5Init( &MD5context );
979 if( prefix != NULL && prefix->bv_len > 0 ) {
980 lutil_MD5Update( &MD5context,
981 prefix->bv_val, prefix->bv_len );
983 lutil_MD5Update( &MD5context,
984 &pre, sizeof( pre ) );
985 lutil_MD5Update( &MD5context,
986 syntax->ssyn_oid, slen );
987 lutil_MD5Update( &MD5context,
989 lutil_MD5Update( &MD5context,
991 lutil_MD5Final( MD5digest, &MD5context );
993 keys[nkeys++] = ber_bvdup( &digest );
996 if( flags & SLAP_MR_SUBSTR_FINAL ) {
997 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
998 lutil_MD5Init( &MD5context );
999 if( prefix != NULL && prefix->bv_len > 0 ) {
1000 lutil_MD5Update( &MD5context,
1001 prefix->bv_val, prefix->bv_len );
1003 lutil_MD5Update( &MD5context,
1004 &pre, sizeof( pre ) );
1005 lutil_MD5Update( &MD5context,
1006 syntax->ssyn_oid, slen );
1007 lutil_MD5Update( &MD5context,
1008 mr->smr_oid, mlen );
1009 lutil_MD5Update( &MD5context,
1010 &value->bv_val[value->bv_len-j], j );
1011 lutil_MD5Final( MD5digest, &MD5context );
1013 keys[nkeys++] = ber_bvdup( &digest );
1021 return LDAP_SUCCESS;
1024 int caseExactIA5SubstringsFilter(
1028 struct berval *prefix,
1030 struct berval ***keysp )
1032 SubstringsAssertion *sa = assertValue;
1034 ber_len_t nkeys = 0;
1035 size_t slen, mlen, klen;
1036 struct berval **keys;
1037 lutil_MD5_CTX MD5context;
1038 unsigned char MD5digest[LUTIL_MD5_BYTES];
1039 struct berval *value;
1040 struct berval digest;
1042 if( sa->sa_initial != NULL &&
1043 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1050 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1051 if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1052 /* don't bother accounting for stepping */
1053 nkeys += sa->sa_any[i]->bv_len -
1054 ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1059 if( sa->sa_final != NULL &&
1060 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1067 return LDAP_SUCCESS;
1070 digest.bv_val = MD5digest;
1071 digest.bv_len = sizeof(MD5digest);
1073 slen = strlen( syntax->ssyn_oid );
1074 mlen = strlen( mr->smr_oid );
1076 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1079 if( sa->sa_initial != NULL &&
1080 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1082 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1083 value = sa->sa_initial;
1085 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1086 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1088 lutil_MD5Init( &MD5context );
1089 if( prefix != NULL && prefix->bv_len > 0 ) {
1090 lutil_MD5Update( &MD5context,
1091 prefix->bv_val, prefix->bv_len );
1093 lutil_MD5Update( &MD5context,
1094 &pre, sizeof( pre ) );
1095 lutil_MD5Update( &MD5context,
1096 syntax->ssyn_oid, slen );
1097 lutil_MD5Update( &MD5context,
1098 mr->smr_oid, mlen );
1099 lutil_MD5Update( &MD5context,
1100 value->bv_val, klen );
1101 lutil_MD5Final( MD5digest, &MD5context );
1103 keys[nkeys++] = ber_bvdup( &digest );
1108 pre = SLAP_INDEX_SUBSTR_PREFIX;
1109 klen = SLAP_INDEX_SUBSTR_MAXLEN;
1111 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1112 if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
1116 value = sa->sa_any[i];
1118 for(j=0; j<sa->sa_any[i]->bv_len; j+= SLAP_INDEX_SUBSTR_STEP ) {
1120 lutil_MD5Init( &MD5context );
1121 if( prefix != NULL && prefix->bv_len > 0 ) {
1122 lutil_MD5Update( &MD5context,
1123 prefix->bv_val, prefix->bv_len );
1125 lutil_MD5Update( &MD5context,
1126 &pre, sizeof( pre ) );
1127 lutil_MD5Update( &MD5context,
1128 syntax->ssyn_oid, slen );
1129 lutil_MD5Update( &MD5context,
1130 mr->smr_oid, mlen );
1131 lutil_MD5Update( &MD5context,
1132 &value->bv_val[j], klen );
1133 lutil_MD5Final( MD5digest, &MD5context );
1135 keys[nkeys++] = ber_bvdup( &digest );
1140 if( sa->sa_final != NULL &&
1141 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1143 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1144 value = sa->sa_final;
1146 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1147 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1149 lutil_MD5Init( &MD5context );
1150 if( prefix != NULL && prefix->bv_len > 0 ) {
1151 lutil_MD5Update( &MD5context,
1152 prefix->bv_val, prefix->bv_len );
1154 lutil_MD5Update( &MD5context,
1155 &pre, sizeof( pre ) );
1156 lutil_MD5Update( &MD5context,
1157 syntax->ssyn_oid, slen );
1158 lutil_MD5Update( &MD5context,
1159 mr->smr_oid, mlen );
1160 lutil_MD5Update( &MD5context,
1161 &value->bv_val[value->bv_len-klen], klen );
1162 lutil_MD5Final( MD5digest, &MD5context );
1164 keys[nkeys++] = ber_bvdup( &digest );
1170 return LDAP_SUCCESS;
1179 struct berval *value,
1180 void *assertedValue )
1182 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
1185 match = strncasecmp( value->bv_val,
1186 ((struct berval *) assertedValue)->bv_val,
1191 return LDAP_SUCCESS;
1194 static char *strcasechr( const char *str, int c )
1196 char *lower = strchr( str, TOLOWER(c) );
1197 char *upper = strchr( str, TOUPPER(c) );
1199 if( lower && upper ) {
1200 return lower < upper ? lower : upper;
1201 } else if ( lower ) {
1209 caseIgnoreIA5SubstringsMatch(
1214 struct berval *value,
1215 void *assertedValue )
1218 SubstringsAssertion *sub = assertedValue;
1219 struct berval left = *value;
1223 /* Add up asserted input length */
1224 if( sub->sa_initial ) {
1225 inlen += sub->sa_initial->bv_len;
1228 for(i=0; sub->sa_any[i] != NULL; i++) {
1229 inlen += sub->sa_any[i]->bv_len;
1232 if( sub->sa_final ) {
1233 inlen += sub->sa_final->bv_len;
1236 if( sub->sa_initial ) {
1237 if( inlen > left.bv_len ) {
1242 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
1243 sub->sa_initial->bv_len );
1249 left.bv_val += sub->sa_initial->bv_len;
1250 left.bv_len -= sub->sa_initial->bv_len;
1251 inlen -= sub->sa_initial->bv_len;
1254 if( sub->sa_final ) {
1255 if( inlen > left.bv_len ) {
1260 match = strncasecmp( sub->sa_final->bv_val,
1261 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
1262 sub->sa_final->bv_len );
1268 left.bv_len -= sub->sa_final->bv_len;
1269 inlen -= sub->sa_final->bv_len;
1273 for(i=0; sub->sa_any[i]; i++) {
1278 if( inlen > left.bv_len ) {
1279 /* not enough length */
1284 if( sub->sa_any[i]->bv_len == 0 ) {
1288 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
1295 idx = p - left.bv_val;
1296 assert( idx < left.bv_len );
1298 if( idx >= left.bv_len ) {
1299 /* this shouldn't happen */
1306 if( sub->sa_any[i]->bv_len > left.bv_len ) {
1307 /* not enough left */
1312 match = strncasecmp( left.bv_val,
1313 sub->sa_any[i]->bv_val,
1314 sub->sa_any[i]->bv_len );
1323 left.bv_val += sub->sa_any[i]->bv_len;
1324 left.bv_len -= sub->sa_any[i]->bv_len;
1325 inlen -= sub->sa_any[i]->bv_len;
1331 return LDAP_SUCCESS;
1334 /* Index generation function */
1335 int caseIgnoreIA5Indexer(
1339 struct berval *prefix,
1340 struct berval **values,
1341 struct berval ***keysp )
1345 struct berval **keys;
1346 lutil_MD5_CTX MD5context;
1347 unsigned char MD5digest[16];
1348 struct berval digest;
1349 digest.bv_val = MD5digest;
1350 digest.bv_len = sizeof(MD5digest);
1352 for( i=0; values[i] != NULL; i++ ) {
1353 /* just count them */
1358 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
1360 slen = strlen( syntax->ssyn_oid );
1361 mlen = strlen( mr->smr_oid );
1363 for( i=0; values[i] != NULL; i++ ) {
1364 struct berval *value = ber_bvdup( values[i] );
1365 ldap_pvt_str2upper( value->bv_val );
1367 lutil_MD5Init( &MD5context );
1368 if( prefix != NULL && prefix->bv_len > 0 ) {
1369 lutil_MD5Update( &MD5context,
1370 prefix->bv_val, prefix->bv_len );
1372 lutil_MD5Update( &MD5context,
1373 syntax->ssyn_oid, slen );
1374 lutil_MD5Update( &MD5context,
1375 mr->smr_oid, mlen );
1376 lutil_MD5Update( &MD5context,
1377 value->bv_val, value->bv_len );
1378 lutil_MD5Final( MD5digest, &MD5context );
1380 ber_bvfree( value );
1382 keys[i] = ber_bvdup( &digest );
1387 return LDAP_SUCCESS;
1390 /* Index generation function */
1391 int caseIgnoreIA5Filter(
1395 struct berval *prefix,
1397 struct berval ***keysp )
1400 struct berval **keys;
1401 lutil_MD5_CTX MD5context;
1402 unsigned char MD5digest[LUTIL_MD5_BYTES];
1403 struct berval *value;
1404 struct berval digest;
1405 digest.bv_val = MD5digest;
1406 digest.bv_len = sizeof(MD5digest);
1408 slen = strlen( syntax->ssyn_oid );
1409 mlen = strlen( mr->smr_oid );
1411 value = ber_bvdup( (struct berval *) assertValue );
1412 ldap_pvt_str2upper( value->bv_val );
1414 keys = ch_malloc( sizeof( struct berval * ) * 2 );
1416 lutil_MD5Init( &MD5context );
1417 if( prefix != NULL && prefix->bv_len > 0 ) {
1418 lutil_MD5Update( &MD5context,
1419 prefix->bv_val, prefix->bv_len );
1421 lutil_MD5Update( &MD5context,
1422 syntax->ssyn_oid, slen );
1423 lutil_MD5Update( &MD5context,
1424 mr->smr_oid, mlen );
1425 lutil_MD5Update( &MD5context,
1426 value->bv_val, value->bv_len );
1427 lutil_MD5Final( MD5digest, &MD5context );
1429 keys[0] = ber_bvdup( &digest );
1432 ber_bvfree( value );
1435 return LDAP_SUCCESS;
1438 /* Substrings Index generation function */
1439 int caseIgnoreIA5SubstringsIndexer(
1443 struct berval *prefix,
1444 struct berval **values,
1445 struct berval ***keysp )
1449 struct berval **keys;
1450 lutil_MD5_CTX MD5context;
1451 unsigned char MD5digest[16];
1452 struct berval digest;
1453 digest.bv_val = MD5digest;
1454 digest.bv_len = sizeof(MD5digest);
1457 for( i=0; values[i] != NULL; i++ ) {
1458 /* count number of indices to generate */
1459 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
1463 if( flags & SLAP_MR_SUBSTR_INITIAL ) {
1464 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1465 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
1466 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
1468 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
1472 if( flags & SLAP_MR_SUBSTR_ANY ) {
1473 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1474 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1478 if( flags & SLAP_MR_SUBSTR_FINAL ) {
1479 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1480 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
1481 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
1483 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
1490 /* no keys to generate */
1492 return LDAP_SUCCESS;
1495 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1497 slen = strlen( syntax->ssyn_oid );
1498 mlen = strlen( mr->smr_oid );
1501 for( i=0; values[i] != NULL; i++ ) {
1503 struct berval *value;
1505 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
1507 value = ber_bvdup( values[i] );
1508 ldap_pvt_str2upper( value->bv_val );
1510 if( ( flags & SLAP_MR_SUBSTR_ANY ) &&
1511 ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
1513 char pre = SLAP_INDEX_SUBSTR_PREFIX;
1514 max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
1516 for( j=0; j<max; j++ ) {
1517 lutil_MD5Init( &MD5context );
1518 if( prefix != NULL && prefix->bv_len > 0 ) {
1519 lutil_MD5Update( &MD5context,
1520 prefix->bv_val, prefix->bv_len );
1523 lutil_MD5Update( &MD5context,
1524 &pre, sizeof( pre ) );
1525 lutil_MD5Update( &MD5context,
1526 syntax->ssyn_oid, slen );
1527 lutil_MD5Update( &MD5context,
1528 mr->smr_oid, mlen );
1529 lutil_MD5Update( &MD5context,
1531 SLAP_INDEX_SUBSTR_MAXLEN );
1532 lutil_MD5Final( MD5digest, &MD5context );
1534 keys[nkeys++] = ber_bvdup( &digest );
1538 max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1539 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1541 for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
1544 if( flags & SLAP_MR_SUBSTR_INITIAL ) {
1545 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1546 lutil_MD5Init( &MD5context );
1547 if( prefix != NULL && prefix->bv_len > 0 ) {
1548 lutil_MD5Update( &MD5context,
1549 prefix->bv_val, prefix->bv_len );
1551 lutil_MD5Update( &MD5context,
1552 &pre, sizeof( pre ) );
1553 lutil_MD5Update( &MD5context,
1554 syntax->ssyn_oid, slen );
1555 lutil_MD5Update( &MD5context,
1556 mr->smr_oid, mlen );
1557 lutil_MD5Update( &MD5context,
1559 lutil_MD5Final( MD5digest, &MD5context );
1561 keys[nkeys++] = ber_bvdup( &digest );
1564 if( flags & SLAP_MR_SUBSTR_FINAL ) {
1565 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1566 lutil_MD5Init( &MD5context );
1567 if( prefix != NULL && prefix->bv_len > 0 ) {
1568 lutil_MD5Update( &MD5context,
1569 prefix->bv_val, prefix->bv_len );
1571 lutil_MD5Update( &MD5context,
1572 &pre, sizeof( pre ) );
1573 lutil_MD5Update( &MD5context,
1574 syntax->ssyn_oid, slen );
1575 lutil_MD5Update( &MD5context,
1576 mr->smr_oid, mlen );
1577 lutil_MD5Update( &MD5context,
1578 &value->bv_val[value->bv_len-j], j );
1579 lutil_MD5Final( MD5digest, &MD5context );
1581 keys[nkeys++] = ber_bvdup( &digest );
1586 ber_bvfree( value );
1591 return LDAP_SUCCESS;
1594 int caseIgnoreIA5SubstringsFilter(
1598 struct berval *prefix,
1600 struct berval ***keysp )
1602 SubstringsAssertion *sa = assertValue;
1604 ber_len_t nkeys = 0;
1605 size_t slen, mlen, klen;
1606 struct berval **keys;
1607 lutil_MD5_CTX MD5context;
1608 unsigned char MD5digest[LUTIL_MD5_BYTES];
1609 struct berval *value;
1610 struct berval digest;
1612 if( sa->sa_initial != NULL &&
1613 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1620 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1621 if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1622 /* don't bother accounting for stepping */
1623 nkeys += sa->sa_any[i]->bv_len -
1624 ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1629 if( sa->sa_final != NULL &&
1630 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1637 return LDAP_SUCCESS;
1640 digest.bv_val = MD5digest;
1641 digest.bv_len = sizeof(MD5digest);
1643 slen = strlen( syntax->ssyn_oid );
1644 mlen = strlen( mr->smr_oid );
1646 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1649 if( sa->sa_initial != NULL &&
1650 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1652 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1653 value = ber_bvdup( sa->sa_initial );
1654 ldap_pvt_str2upper( value->bv_val );
1656 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1657 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1659 lutil_MD5Init( &MD5context );
1660 if( prefix != NULL && prefix->bv_len > 0 ) {
1661 lutil_MD5Update( &MD5context,
1662 prefix->bv_val, prefix->bv_len );
1664 lutil_MD5Update( &MD5context,
1665 &pre, sizeof( pre ) );
1666 lutil_MD5Update( &MD5context,
1667 syntax->ssyn_oid, slen );
1668 lutil_MD5Update( &MD5context,
1669 mr->smr_oid, mlen );
1670 lutil_MD5Update( &MD5context,
1671 value->bv_val, klen );
1672 lutil_MD5Final( MD5digest, &MD5context );
1674 ber_bvfree( value );
1675 keys[nkeys++] = ber_bvdup( &digest );
1680 pre = SLAP_INDEX_SUBSTR_PREFIX;
1681 klen = SLAP_INDEX_SUBSTR_MAXLEN;
1683 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1684 if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
1688 value = ber_bvdup( sa->sa_any[i] );
1689 ldap_pvt_str2upper( value->bv_val );
1691 for(j=0; j<sa->sa_any[i]->bv_len; j+= SLAP_INDEX_SUBSTR_STEP ) {
1692 lutil_MD5Init( &MD5context );
1693 if( prefix != NULL && prefix->bv_len > 0 ) {
1694 lutil_MD5Update( &MD5context,
1695 prefix->bv_val, prefix->bv_len );
1697 lutil_MD5Update( &MD5context,
1698 &pre, sizeof( pre ) );
1699 lutil_MD5Update( &MD5context,
1700 syntax->ssyn_oid, slen );
1701 lutil_MD5Update( &MD5context,
1702 mr->smr_oid, mlen );
1703 lutil_MD5Update( &MD5context,
1704 &value->bv_val[j], klen );
1705 lutil_MD5Final( MD5digest, &MD5context );
1707 keys[nkeys++] = ber_bvdup( &digest );
1710 ber_bvfree( value );
1714 if( sa->sa_final != NULL &&
1715 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1717 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1718 value = ber_bvdup( sa->sa_final );
1719 ldap_pvt_str2upper( value->bv_val );
1721 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1722 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1724 lutil_MD5Init( &MD5context );
1725 if( prefix != NULL && prefix->bv_len > 0 ) {
1726 lutil_MD5Update( &MD5context,
1727 prefix->bv_val, prefix->bv_len );
1729 lutil_MD5Update( &MD5context,
1730 &pre, sizeof( pre ) );
1731 lutil_MD5Update( &MD5context,
1732 syntax->ssyn_oid, slen );
1733 lutil_MD5Update( &MD5context,
1734 mr->smr_oid, mlen );
1735 lutil_MD5Update( &MD5context,
1736 &value->bv_val[value->bv_len-klen], klen );
1737 lutil_MD5Final( MD5digest, &MD5context );
1739 ber_bvfree( value );
1740 keys[nkeys++] = ber_bvdup( &digest );
1746 return LDAP_SUCCESS;
1750 numericStringNormalize(
1753 struct berval **normalized )
1755 /* similiar to IA5StringNormalize except removes all spaces */
1756 struct berval *newval;
1759 newval = ch_malloc( sizeof( struct berval ) );
1763 /* Ignore initial whitespace */
1764 while ( ASCII_SPACE( *p ) ) {
1770 return LDAP_INVALID_SYNTAX;
1773 newval->bv_val = ch_strdup( p );
1774 p = q = newval->bv_val;
1777 if ( ASCII_SPACE( *p ) ) {
1778 /* Ignore whitespace */
1785 assert( *newval->bv_val );
1786 assert( newval->bv_val < p );
1789 /* cannot start with a space */
1790 assert( !ASCII_SPACE(*newval->bv_val) );
1792 /* cannot end with a space */
1793 assert( !ASCII_SPACE( q[-1] ) );
1795 /* null terminate */
1798 newval->bv_len = q - newval->bv_val;
1799 *normalized = newval;
1801 return LDAP_SUCCESS;
1805 objectIdentifierFirstComponentMatch(
1810 struct berval *value,
1811 void *assertedValue )
1813 int rc = LDAP_SUCCESS;
1815 struct berval *asserted = (struct berval *) assertedValue;
1819 if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
1820 return LDAP_INVALID_SYNTAX;
1823 /* trim leading white space */
1824 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
1828 /* grab next word */
1829 oid.bv_val = &value->bv_val[i];
1830 oid.bv_len = value->bv_len - i;
1831 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < oid.bv_len; i++ ) {
1836 /* insert attributeTypes, objectclass check here */
1837 if( OID_LEADCHAR(asserted->bv_val[0]) ) {
1838 rc = objectIdentifierMatch( &match, flags, syntax, mr, &oid, asserted );
1841 char *stored = ch_malloc( oid.bv_len + 1 );
1842 AC_MEMCPY( stored, oid.bv_val, oid.bv_len );
1843 stored[oid.bv_len] = '\0';
1845 if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
1846 MatchingRule *asserted_mr = mr_find( asserted->bv_val );
1847 MatchingRule *stored_mr = mr_find( stored );
1849 if( asserted_mr == NULL ) {
1850 rc = SLAPD_COMPARE_UNDEFINED;
1852 match = asserted_mr != stored_mr;
1855 } else if ( !strcmp( syntax->ssyn_oid,
1856 SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
1858 AttributeType *asserted_at = at_find( asserted->bv_val );
1859 AttributeType *stored_at = at_find( stored );
1861 if( asserted_at == NULL ) {
1862 rc = SLAPD_COMPARE_UNDEFINED;
1864 match = asserted_at != stored_at;
1867 } else if ( !strcmp( syntax->ssyn_oid,
1868 SLAP_SYNTAX_OBJECTCLASSES_OID ) )
1870 ObjectClass *asserted_oc = oc_find( asserted->bv_val );
1871 ObjectClass *stored_oc = oc_find( stored );
1873 if( asserted_oc == NULL ) {
1874 rc = SLAPD_COMPARE_UNDEFINED;
1876 match = asserted_oc != stored_oc;
1883 Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
1884 "%d\n\t\"%s\"\n\t\"%s\"\n",
1885 match, value->bv_val, asserted->bv_val );
1887 if( rc == LDAP_SUCCESS ) *matchp = match;
1892 check_time_syntax (struct berval *val,
1896 static int ceiling[9] = { 99, 99, 11, 30, 23, 59, 59, 12, 59 };
1897 static int mdays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1899 int part, c, neg = 0;
1901 if( val->bv_len == 0 )
1902 return LDAP_INVALID_SYNTAX;
1904 p = (char *)val->bv_val;
1905 e = p + val->bv_len;
1907 /* Ignore initial whitespace */
1908 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1912 if (e - p < 13 - (2 * start))
1913 return LDAP_INVALID_SYNTAX;
1915 for (part = 0; part < 9; part++)
1918 for (part = start; part < 7; part++) {
1931 return LDAP_INVALID_SYNTAX;
1933 return LDAP_INVALID_SYNTAX;
1938 return LDAP_INVALID_SYNTAX;
1940 return LDAP_INVALID_SYNTAX;
1944 if (part == 2 || part == 3)
1946 if (parts[part] < 0)
1947 return LDAP_INVALID_SYNTAX;
1948 if (parts[part] > ceiling[part])
1949 return LDAP_INVALID_SYNTAX;
1951 if (parts[2] == 1) {
1952 if (parts[3] > mdays[parts[2]])
1953 return LDAP_INVALID_SYNTAX;
1954 if (parts[1] & 0x03) {
1955 /* FIXME: This is an incomplete leap-year
1956 * check that fails in 2100, 2200, 2300,
1957 * 2500, 2600, 2700, ...
1959 if (parts[3] > mdays[parts[2]] - 1)
1960 return LDAP_INVALID_SYNTAX;
1966 } else if (c != '+' && c != '-') {
1967 return LDAP_INVALID_SYNTAX;
1972 return LDAP_INVALID_SYNTAX;
1973 for (part = 7; part < 9; part++) {
1976 return LDAP_INVALID_SYNTAX;
1981 return LDAP_INVALID_SYNTAX;
1984 if (parts[part] < 0 || parts[part] > ceiling[part])
1985 return LDAP_INVALID_SYNTAX;
1989 /* Ignore trailing whitespace */
1990 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1994 return LDAP_INVALID_SYNTAX;
1997 parts[4] += parts[7];
1998 parts[5] += parts[8];
1999 for (part = 7; --part > 0; ) {
2003 /* FIXME: This is an incomplete leap-year
2004 * check that fails in 2100, 2200, 2300,
2005 * 2500, 2600, 2700, ...
2007 c = mdays[parts[2]];
2011 if (parts[part] > c) {
2012 parts[part] -= c + 1;
2017 parts[4] -= parts[7];
2018 parts[5] -= parts[8];
2019 for (part = 7; --part > 0; ) {
2023 /* FIXME: This is an incomplete leap-year
2024 * check that fails in 2100, 2200, 2300,
2025 * 2500, 2600, 2700, ...
2027 c = mdays[(parts[2] - 1) % 12];
2031 if (parts[part] < 0) {
2032 parts[part] += c + 1;
2038 return LDAP_SUCCESS;
2045 struct berval **normalized )
2050 rc = check_time_syntax(val, 1, parts);
2051 if (rc != LDAP_SUCCESS) {
2056 out = ch_malloc( sizeof(struct berval) );
2058 return LBER_ERROR_MEMORY;
2060 out->bv_val = ch_malloc( 14 );
2061 if ( out->bv_val == NULL ) {
2063 return LBER_ERROR_MEMORY;
2066 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ",
2067 parts[1], parts[2] + 1, parts[3] + 1,
2068 parts[4], parts[5], parts[6] );
2072 return LDAP_SUCCESS;
2082 return check_time_syntax(in, 1, parts);
2086 generalizedTimeValidate(
2092 return check_time_syntax(in, 0, parts);
2096 generalizedTimeNormalize(
2099 struct berval **normalized )
2104 rc = check_time_syntax(val, 0, parts);
2105 if (rc != LDAP_SUCCESS) {
2110 out = ch_malloc( sizeof(struct berval) );
2112 return LBER_ERROR_MEMORY;
2114 out->bv_val = ch_malloc( 16 );
2115 if ( out->bv_val == NULL ) {
2117 return LBER_ERROR_MEMORY;
2120 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ",
2121 parts[0], parts[1], parts[2] + 1, parts[3] + 1,
2122 parts[4], parts[5], parts[6] );
2126 return LDAP_SUCCESS;
2129 struct syntax_defs_rec {
2132 slap_syntax_validate_func *sd_validate;
2133 slap_syntax_transform_func *sd_normalize;
2134 slap_syntax_transform_func *sd_pretty;
2135 #ifdef SLAPD_BINARY_CONVERSION
2136 slap_syntax_transform_func *sd_ber2str;
2137 slap_syntax_transform_func *sd_str2ber;
2141 #define X_HIDE "X-HIDE 'TRUE' "
2142 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
2143 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
2145 struct syntax_defs_rec syntax_defs[] = {
2146 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
2147 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
2148 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
2149 0, NULL, NULL, NULL},
2150 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
2151 0, NULL, NULL, NULL},
2152 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
2153 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
2154 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
2155 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2156 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
2157 0, bitStringValidate, bitStringNormalize, NULL },
2158 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
2159 0, booleanValidate, NULL, NULL},
2160 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
2161 X_BINARY X_NOT_H_R ")",
2162 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2163 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
2164 X_BINARY X_NOT_H_R ")",
2165 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2166 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
2167 X_BINARY X_NOT_H_R ")",
2168 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2169 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
2170 0, NULL, NULL, NULL},
2171 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
2172 0, dnValidate, dnNormalize, dnPretty},
2173 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
2174 0, NULL, NULL, NULL},
2175 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
2176 0, NULL, NULL, NULL},
2177 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
2178 0, UTF8StringValidate, UTF8StringNormalize, NULL},
2179 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
2180 0, NULL, NULL, NULL},
2181 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
2182 0, NULL, NULL, NULL},
2183 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
2184 0, NULL, NULL, NULL},
2185 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
2186 0, NULL, NULL, NULL},
2187 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
2188 0, NULL, NULL, NULL},
2189 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
2190 0, IA5StringValidate, faxNumberNormalize, NULL},
2191 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
2192 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
2193 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
2194 0, generalizedTimeValidate, generalizedTimeNormalize, NULL},
2195 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
2196 0, NULL, NULL, NULL},
2197 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
2198 0, IA5StringValidate, IA5StringNormalize, NULL},
2199 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
2200 0, integerValidate, integerNormalize, integerPretty},
2201 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
2202 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
2203 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
2204 0, NULL, NULL, NULL},
2205 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
2206 0, NULL, NULL, NULL},
2207 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
2208 0, NULL, NULL, NULL},
2209 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
2210 0, NULL, NULL, NULL},
2211 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
2212 0, NULL, NULL, NULL},
2213 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
2214 0, NULL, NULL, NULL},
2215 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
2216 0, NULL, NULL, NULL},
2217 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
2218 0, IA5StringValidate, numericStringNormalize, NULL},
2219 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
2220 0, NULL, NULL, NULL},
2221 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
2222 0, oidValidate, NULL, NULL},
2223 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
2224 0, NULL, NULL, NULL},
2225 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
2226 0, blobValidate, NULL, NULL},
2227 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
2228 0, blobValidate, NULL, NULL},
2229 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
2230 0, NULL, NULL, NULL},
2231 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
2232 0, NULL, NULL, NULL},
2233 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
2234 0, printableStringValidate, NULL, NULL},
2235 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
2236 X_BINARY X_NOT_H_R ")",
2237 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2238 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
2239 0, IA5StringValidate, phoneNumberNormalize, NULL},
2240 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
2241 0, NULL, NULL, NULL},
2242 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
2243 0, IA5StringValidate, telexNumberNormalize, NULL},
2244 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
2245 0, utcTimeValidate, utcTimeNormalize, NULL},
2246 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
2247 0, NULL, NULL, NULL},
2248 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
2249 0, NULL, NULL, NULL},
2250 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
2251 0, NULL, NULL, NULL},
2252 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
2253 0, NULL, NULL, NULL},
2254 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
2255 0, NULL, NULL, NULL},
2257 /* OpenLDAP Experimental Syntaxes */
2258 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
2259 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */, NULL, NULL},
2260 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
2261 0, NULL, NULL, NULL},
2262 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
2263 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
2264 #if 0 /* not needed */
2265 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
2266 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
2269 {NULL, 0, NULL, NULL, NULL}
2272 struct mrule_defs_rec {
2275 slap_mr_convert_func * mrd_convert;
2276 slap_mr_normalize_func * mrd_normalize;
2277 slap_mr_match_func * mrd_match;
2278 slap_mr_indexer_func * mrd_indexer;
2279 slap_mr_filter_func * mrd_filter;
2281 char * mrd_associated;
2285 * Other matching rules in X.520 that we do not use (yet):
2287 * 2.5.13.9 numericStringOrderingMatch
2288 * 2.5.13.13 booleanMatch
2289 * 2.5.13.15 integerOrderingMatch
2290 * 2.5.13.18 octetStringOrderingMatch
2291 * 2.5.13.19 octetStringSubstringsMatch
2292 * 2.5.13.25 uTCTimeMatch
2293 * 2.5.13.26 uTCTimeOrderingMatch
2294 * 2.5.13.31 directoryStringFirstComponentMatch
2295 * 2.5.13.32 wordMatch
2296 * 2.5.13.33 keywordMatch
2297 * 2.5.13.34 certificateExactMatch
2298 * 2.5.13.35 certificateMatch
2299 * 2.5.13.36 certificatePairExactMatch
2300 * 2.5.13.37 certificatePairMatch
2301 * 2.5.13.38 certificateListExactMatch
2302 * 2.5.13.39 certificateListMatch
2303 * 2.5.13.40 algorithmIdentifierMatch
2304 * 2.5.13.41 storedPrefixMatch
2305 * 2.5.13.42 attributeCertificateMatch
2306 * 2.5.13.43 readerAndKeyIDMatch
2307 * 2.5.13.44 attributeIntegrityMatch
2310 struct mrule_defs_rec mrule_defs[] = {
2312 * EQUALITY matching rules must be listed after associated APPROX
2313 * matching rules. So, we list all APPROX matching rules first.
2315 {"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
2316 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2317 SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
2319 directoryStringApproxMatch, NULL, NULL,
2322 {"( " IA5StringApproxMatchOID " NAME 'IA5StringApproxMatch' "
2323 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2324 SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
2326 IA5StringApproxMatch, NULL, NULL,
2330 * Other matching rules
2333 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
2334 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
2335 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2337 objectIdentifierMatch, caseIgnoreIA5Indexer, caseIgnoreIA5Filter,
2340 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
2341 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
2342 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2344 dnMatch, dnIndexer, dnFilter,
2347 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
2348 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2349 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2351 caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter,
2352 directoryStringApproxMatchOID },
2354 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
2355 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2358 caseIgnoreOrderingMatch, NULL, NULL,
2361 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
2362 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2363 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2365 caseIgnoreSubstringsMatch,
2366 caseIgnoreSubstringsIndexer,
2367 caseIgnoreSubstringsFilter,
2370 {"( 2.5.13.5 NAME 'caseExactMatch' "
2371 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2372 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2374 caseExactMatch, caseExactIndexer, caseExactFilter,
2375 directoryStringApproxMatchOID },
2377 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
2378 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2381 caseExactOrderingMatch, NULL, NULL,
2384 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
2385 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2386 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2388 caseExactSubstringsMatch,
2389 caseExactSubstringsIndexer,
2390 caseExactSubstringsFilter,
2393 {"( 2.5.13.8 NAME 'numericStringMatch' "
2394 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
2395 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2397 caseIgnoreIA5Match, NULL, NULL,
2400 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
2401 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2402 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2404 caseIgnoreIA5SubstringsMatch,
2405 caseIgnoreIA5SubstringsIndexer,
2406 caseIgnoreIA5SubstringsFilter,
2409 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
2410 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
2411 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2413 caseIgnoreListMatch, NULL, NULL,
2416 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
2417 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2418 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2420 caseIgnoreListSubstringsMatch, NULL, NULL,
2423 {"( 2.5.13.13 NAME 'booleanMatch' "
2424 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
2425 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2427 booleanMatch, NULL, NULL,
2430 {"( 2.5.13.14 NAME 'integerMatch' "
2431 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
2432 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2434 integerMatch, NULL, NULL,
2437 {"( 2.5.13.16 NAME 'bitStringMatch' "
2438 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
2439 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2441 bitStringMatch, NULL, NULL,
2444 {"( 2.5.13.17 NAME 'octetStringMatch' "
2445 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
2446 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2448 octetStringMatch, octetStringIndexer, octetStringFilter,
2451 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
2452 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
2453 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2455 telephoneNumberMatch, NULL, NULL,
2458 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
2459 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2460 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2462 telephoneNumberSubstringsMatch, NULL, NULL,
2465 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
2466 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
2467 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2469 presentationAddressMatch, NULL, NULL,
2472 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
2473 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
2474 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2476 uniqueMemberMatch, NULL, NULL,
2479 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
2480 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
2481 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2483 protocolInformationMatch, NULL, NULL,
2486 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
2487 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
2488 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2490 generalizedTimeMatch, NULL, NULL,
2493 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
2494 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
2497 generalizedTimeOrderingMatch, NULL, NULL,
2500 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
2501 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
2502 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2504 integerFirstComponentMatch, NULL, NULL,
2507 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
2508 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
2509 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2511 objectIdentifierFirstComponentMatch, NULL, NULL,
2514 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
2515 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2516 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2518 caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
2519 IA5StringApproxMatchOID },
2521 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
2522 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2523 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2525 caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
2526 IA5StringApproxMatchOID },
2528 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
2529 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2532 caseIgnoreIA5SubstringsMatch,
2533 caseIgnoreIA5SubstringsIndexer,
2534 caseIgnoreIA5SubstringsFilter,
2537 {"( 1.3.6.1.4.1.4203.666.4.3 NAME 'caseExactIA5SubstringsMatch' "
2538 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2541 caseExactIA5SubstringsMatch,
2542 caseExactIA5SubstringsIndexer,
2543 caseExactIA5SubstringsFilter,
2546 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
2547 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
2550 authPasswordMatch, NULL, NULL,
2553 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
2554 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
2557 OpenLDAPaciMatch, NULL, NULL,
2560 {NULL, SLAP_MR_NONE, NULL, NULL, NULL, NULL}
2569 /* we should only be called once (from main) */
2570 assert( schema_init_done == 0 );
2572 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
2573 res = register_syntax( syntax_defs[i].sd_desc,
2574 syntax_defs[i].sd_flags,
2575 syntax_defs[i].sd_validate,
2576 syntax_defs[i].sd_normalize,
2577 syntax_defs[i].sd_pretty
2578 #ifdef SLAPD_BINARY_CONVERSION
2580 syntax_defs[i].sd_ber2str,
2581 syntax_defs[i].sd_str2ber
2586 fprintf( stderr, "schema_init: Error registering syntax %s\n",
2587 syntax_defs[i].sd_desc );
2592 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
2593 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
2595 "schema_init: Ingoring unusable matching rule %s\n",
2596 mrule_defs[i].mrd_desc );
2600 res = register_matching_rule(
2601 mrule_defs[i].mrd_desc,
2602 mrule_defs[i].mrd_usage,
2603 mrule_defs[i].mrd_convert,
2604 mrule_defs[i].mrd_normalize,
2605 mrule_defs[i].mrd_match,
2606 mrule_defs[i].mrd_indexer,
2607 mrule_defs[i].mrd_filter,
2608 mrule_defs[i].mrd_associated );
2612 "schema_init: Error registering matching rule %s\n",
2613 mrule_defs[i].mrd_desc );
2617 schema_init_done = 1;
2618 return LDAP_SUCCESS;