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
22 #define nameUIDValidate dnValidate
24 /* unimplemented validators */
25 #define bitStringValidate NULL
27 /* recycled normalization routines */
28 #define faxNumberNormalize numericStringNormalize
29 #define phoneNumberNormalize numericStringNormalize
30 #define telexNumberNormalize numericStringNormalize
31 #define integerNormalize numericStringNormalize
32 #define nameUIDNormalize dnNormalize
34 /* unimplemented normalizers */
35 #define bitStringNormalize NULL
37 /* unimplemented pretters */
39 #define integerPretty NULL
41 /* recycled pretters */
42 #define nameUIDPretty dnPretty
44 /* recycled matching routines */
45 #define caseIgnoreMatch caseIgnoreIA5Match
46 #define caseIgnoreOrderingMatch caseIgnoreMatch
47 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
49 #define caseExactMatch caseExactIA5Match
50 #define caseExactOrderingMatch caseExactMatch
51 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
53 #define numericStringMatch caseIgnoreMatch
54 #define objectIdentifierMatch numericStringMatch
55 #define integerMatch numericStringMatch
56 #define telephoneNumberMatch numericStringMatch
57 #define telephoneNumberSubstringsMatch caseIgnoreIA5SubstringsMatch
58 #define generalizedTimeMatch numericStringMatch
59 #define generalizedTimeOrderingMatch numericStringMatch
60 #define uniqueMemberMatch dnMatch
62 /* unimplemented matching routines */
63 #define caseIgnoreListMatch NULL
64 #define caseIgnoreListSubstringsMatch NULL
65 #define bitStringMatch NULL
66 #define presentationAddressMatch NULL
67 #define protocolInformationMatch NULL
68 #define integerFirstComponentMatch NULL
70 #define OpenLDAPaciMatch 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
95 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
98 match = memcmp( value->bv_val,
99 ((struct berval *) assertedValue)->bv_val,
107 /* Index generation function */
108 int octetStringIndexer(
113 struct berval *prefix,
114 struct berval **values,
115 struct berval ***keysp )
119 struct berval **keys;
120 lutil_MD5_CTX MD5context;
121 unsigned char MD5digest[16];
122 struct berval digest;
123 digest.bv_val = MD5digest;
124 digest.bv_len = sizeof(MD5digest);
126 for( i=0; values[i] != NULL; i++ ) {
127 /* just count them */
132 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
134 slen = strlen( syntax->ssyn_oid );
135 mlen = strlen( mr->smr_oid );
137 for( i=0; values[i] != NULL; i++ ) {
138 lutil_MD5Init( &MD5context );
139 if( prefix != NULL && prefix->bv_len > 0 ) {
140 lutil_MD5Update( &MD5context,
141 prefix->bv_val, prefix->bv_len );
143 lutil_MD5Update( &MD5context,
144 syntax->ssyn_oid, slen );
145 lutil_MD5Update( &MD5context,
147 lutil_MD5Update( &MD5context,
148 values[i]->bv_val, values[i]->bv_len );
149 lutil_MD5Final( MD5digest, &MD5context );
151 keys[i] = ber_bvdup( &digest );
161 /* Index generation function */
162 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(
780 struct berval *prefix,
781 struct berval **values,
782 struct berval ***keysp )
786 struct berval **keys;
787 lutil_MD5_CTX MD5context;
788 unsigned char MD5digest[16];
789 struct berval digest;
790 digest.bv_val = MD5digest;
791 digest.bv_len = sizeof(MD5digest);
793 for( i=0; values[i] != NULL; i++ ) {
794 /* just count them */
799 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
801 slen = strlen( syntax->ssyn_oid );
802 mlen = strlen( mr->smr_oid );
804 for( i=0; values[i] != NULL; i++ ) {
805 struct berval *value = values[i];
807 lutil_MD5Init( &MD5context );
808 if( prefix != NULL && prefix->bv_len > 0 ) {
809 lutil_MD5Update( &MD5context,
810 prefix->bv_val, prefix->bv_len );
812 lutil_MD5Update( &MD5context,
813 syntax->ssyn_oid, slen );
814 lutil_MD5Update( &MD5context,
816 lutil_MD5Update( &MD5context,
817 value->bv_val, value->bv_len );
818 lutil_MD5Final( MD5digest, &MD5context );
820 keys[i] = ber_bvdup( &digest );
828 /* Index generation function */
829 int caseExactIA5Filter(
834 struct berval *prefix,
836 struct berval ***keysp )
839 struct berval **keys;
840 lutil_MD5_CTX MD5context;
841 unsigned char MD5digest[LUTIL_MD5_BYTES];
842 struct berval *value;
843 struct berval digest;
844 digest.bv_val = MD5digest;
845 digest.bv_len = sizeof(MD5digest);
847 slen = strlen( syntax->ssyn_oid );
848 mlen = strlen( mr->smr_oid );
850 value = (struct berval *) assertValue;
852 keys = ch_malloc( sizeof( struct berval * ) * 2 );
854 lutil_MD5Init( &MD5context );
855 if( prefix != NULL && prefix->bv_len > 0 ) {
856 lutil_MD5Update( &MD5context,
857 prefix->bv_val, prefix->bv_len );
859 lutil_MD5Update( &MD5context,
860 syntax->ssyn_oid, slen );
861 lutil_MD5Update( &MD5context,
863 lutil_MD5Update( &MD5context,
864 value->bv_val, value->bv_len );
865 lutil_MD5Final( MD5digest, &MD5context );
867 keys[0] = ber_bvdup( &digest );
874 /* Substrings Index generation function */
875 int caseExactIA5SubstringsIndexer(
880 struct berval *prefix,
881 struct berval **values,
882 struct berval ***keysp )
886 struct berval **keys;
887 lutil_MD5_CTX MD5context;
888 unsigned char MD5digest[16];
889 struct berval digest;
890 digest.bv_val = MD5digest;
891 digest.bv_len = sizeof(MD5digest);
894 for( i=0; values[i] != NULL; i++ ) {
895 /* count number of indices to generate */
896 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
900 if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
901 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
902 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
903 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
905 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
909 if( flags & SLAP_INDEX_SUBSTR_ANY ) {
910 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
911 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
915 if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
916 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
917 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
918 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
920 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
927 /* no keys to generate */
932 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
934 slen = strlen( syntax->ssyn_oid );
935 mlen = strlen( mr->smr_oid );
938 for( i=0; values[i] != NULL; i++ ) {
940 struct berval *value;
943 if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
945 if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
946 ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
948 char pre = SLAP_INDEX_SUBSTR_PREFIX;
949 max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
951 for( j=0; j<max; j++ ) {
952 lutil_MD5Init( &MD5context );
953 if( prefix != NULL && prefix->bv_len > 0 ) {
954 lutil_MD5Update( &MD5context,
955 prefix->bv_val, prefix->bv_len );
958 lutil_MD5Update( &MD5context,
959 &pre, sizeof( pre ) );
960 lutil_MD5Update( &MD5context,
961 syntax->ssyn_oid, slen );
962 lutil_MD5Update( &MD5context,
964 lutil_MD5Update( &MD5context,
966 SLAP_INDEX_SUBSTR_MAXLEN );
967 lutil_MD5Final( MD5digest, &MD5context );
969 keys[nkeys++] = ber_bvdup( &digest );
973 max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
974 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
976 for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
979 if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
980 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
981 lutil_MD5Init( &MD5context );
982 if( prefix != NULL && prefix->bv_len > 0 ) {
983 lutil_MD5Update( &MD5context,
984 prefix->bv_val, prefix->bv_len );
986 lutil_MD5Update( &MD5context,
987 &pre, sizeof( pre ) );
988 lutil_MD5Update( &MD5context,
989 syntax->ssyn_oid, slen );
990 lutil_MD5Update( &MD5context,
992 lutil_MD5Update( &MD5context,
994 lutil_MD5Final( MD5digest, &MD5context );
996 keys[nkeys++] = ber_bvdup( &digest );
999 if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
1000 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1001 lutil_MD5Init( &MD5context );
1002 if( prefix != NULL && prefix->bv_len > 0 ) {
1003 lutil_MD5Update( &MD5context,
1004 prefix->bv_val, prefix->bv_len );
1006 lutil_MD5Update( &MD5context,
1007 &pre, sizeof( pre ) );
1008 lutil_MD5Update( &MD5context,
1009 syntax->ssyn_oid, slen );
1010 lutil_MD5Update( &MD5context,
1011 mr->smr_oid, mlen );
1012 lutil_MD5Update( &MD5context,
1013 &value->bv_val[value->bv_len-j], j );
1014 lutil_MD5Final( MD5digest, &MD5context );
1016 keys[nkeys++] = ber_bvdup( &digest );
1030 return LDAP_SUCCESS;
1033 int caseExactIA5SubstringsFilter(
1038 struct berval *prefix,
1040 struct berval ***keysp )
1042 SubstringsAssertion *sa = assertValue;
1044 ber_len_t nkeys = 0;
1045 size_t slen, mlen, klen;
1046 struct berval **keys;
1047 lutil_MD5_CTX MD5context;
1048 unsigned char MD5digest[LUTIL_MD5_BYTES];
1049 struct berval *value;
1050 struct berval digest;
1052 if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
1053 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1058 if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
1060 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1061 if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1062 /* don't bother accounting for stepping */
1063 nkeys += sa->sa_any[i]->bv_len -
1064 ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1069 if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
1070 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1077 return LDAP_SUCCESS;
1080 digest.bv_val = MD5digest;
1081 digest.bv_len = sizeof(MD5digest);
1083 slen = strlen( syntax->ssyn_oid );
1084 mlen = strlen( mr->smr_oid );
1086 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1089 if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
1090 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1092 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1093 value = sa->sa_initial;
1095 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1096 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1098 lutil_MD5Init( &MD5context );
1099 if( prefix != NULL && prefix->bv_len > 0 ) {
1100 lutil_MD5Update( &MD5context,
1101 prefix->bv_val, prefix->bv_len );
1103 lutil_MD5Update( &MD5context,
1104 &pre, sizeof( pre ) );
1105 lutil_MD5Update( &MD5context,
1106 syntax->ssyn_oid, slen );
1107 lutil_MD5Update( &MD5context,
1108 mr->smr_oid, mlen );
1109 lutil_MD5Update( &MD5context,
1110 value->bv_val, klen );
1111 lutil_MD5Final( MD5digest, &MD5context );
1113 keys[nkeys++] = ber_bvdup( &digest );
1116 if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
1118 pre = SLAP_INDEX_SUBSTR_PREFIX;
1119 klen = SLAP_INDEX_SUBSTR_MAXLEN;
1121 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1122 if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
1126 value = sa->sa_any[i];
1129 j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
1130 j += SLAP_INDEX_SUBSTR_STEP )
1132 lutil_MD5Init( &MD5context );
1133 if( prefix != NULL && prefix->bv_len > 0 ) {
1134 lutil_MD5Update( &MD5context,
1135 prefix->bv_val, prefix->bv_len );
1137 lutil_MD5Update( &MD5context,
1138 &pre, sizeof( pre ) );
1139 lutil_MD5Update( &MD5context,
1140 syntax->ssyn_oid, slen );
1141 lutil_MD5Update( &MD5context,
1142 mr->smr_oid, mlen );
1143 lutil_MD5Update( &MD5context,
1144 &value->bv_val[j], klen );
1145 lutil_MD5Final( MD5digest, &MD5context );
1147 keys[nkeys++] = ber_bvdup( &digest );
1152 if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
1153 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1155 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1156 value = sa->sa_final;
1158 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1159 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1161 lutil_MD5Init( &MD5context );
1162 if( prefix != NULL && prefix->bv_len > 0 ) {
1163 lutil_MD5Update( &MD5context,
1164 prefix->bv_val, prefix->bv_len );
1166 lutil_MD5Update( &MD5context,
1167 &pre, sizeof( pre ) );
1168 lutil_MD5Update( &MD5context,
1169 syntax->ssyn_oid, slen );
1170 lutil_MD5Update( &MD5context,
1171 mr->smr_oid, mlen );
1172 lutil_MD5Update( &MD5context,
1173 &value->bv_val[value->bv_len-klen], klen );
1174 lutil_MD5Final( MD5digest, &MD5context );
1176 keys[nkeys++] = ber_bvdup( &digest );
1187 return LDAP_SUCCESS;
1196 struct berval *value,
1197 void *assertedValue )
1199 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
1202 match = strncasecmp( value->bv_val,
1203 ((struct berval *) assertedValue)->bv_val,
1208 return LDAP_SUCCESS;
1211 static char *strcasechr( const char *str, int c )
1213 char *lower = strchr( str, TOLOWER(c) );
1214 char *upper = strchr( str, TOUPPER(c) );
1216 if( lower && upper ) {
1217 return lower < upper ? lower : upper;
1218 } else if ( lower ) {
1226 caseIgnoreIA5SubstringsMatch(
1231 struct berval *value,
1232 void *assertedValue )
1235 SubstringsAssertion *sub = assertedValue;
1236 struct berval left = *value;
1240 /* Add up asserted input length */
1241 if( sub->sa_initial ) {
1242 inlen += sub->sa_initial->bv_len;
1245 for(i=0; sub->sa_any[i] != NULL; i++) {
1246 inlen += sub->sa_any[i]->bv_len;
1249 if( sub->sa_final ) {
1250 inlen += sub->sa_final->bv_len;
1253 if( sub->sa_initial ) {
1254 if( inlen > left.bv_len ) {
1259 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
1260 sub->sa_initial->bv_len );
1266 left.bv_val += sub->sa_initial->bv_len;
1267 left.bv_len -= sub->sa_initial->bv_len;
1268 inlen -= sub->sa_initial->bv_len;
1271 if( sub->sa_final ) {
1272 if( inlen > left.bv_len ) {
1277 match = strncasecmp( sub->sa_final->bv_val,
1278 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
1279 sub->sa_final->bv_len );
1285 left.bv_len -= sub->sa_final->bv_len;
1286 inlen -= sub->sa_final->bv_len;
1290 for(i=0; sub->sa_any[i]; i++) {
1295 if( inlen > left.bv_len ) {
1296 /* not enough length */
1301 if( sub->sa_any[i]->bv_len == 0 ) {
1305 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
1312 idx = p - left.bv_val;
1313 assert( idx < left.bv_len );
1315 if( idx >= left.bv_len ) {
1316 /* this shouldn't happen */
1323 if( sub->sa_any[i]->bv_len > left.bv_len ) {
1324 /* not enough left */
1329 match = strncasecmp( left.bv_val,
1330 sub->sa_any[i]->bv_val,
1331 sub->sa_any[i]->bv_len );
1340 left.bv_val += sub->sa_any[i]->bv_len;
1341 left.bv_len -= sub->sa_any[i]->bv_len;
1342 inlen -= sub->sa_any[i]->bv_len;
1348 return LDAP_SUCCESS;
1351 /* Index generation function */
1352 int caseIgnoreIA5Indexer(
1357 struct berval *prefix,
1358 struct berval **values,
1359 struct berval ***keysp )
1363 struct berval **keys;
1364 lutil_MD5_CTX MD5context;
1365 unsigned char MD5digest[16];
1366 struct berval digest;
1367 digest.bv_val = MD5digest;
1368 digest.bv_len = sizeof(MD5digest);
1370 for( i=0; values[i] != NULL; i++ ) {
1371 /* just count them */
1376 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
1378 slen = strlen( syntax->ssyn_oid );
1379 mlen = strlen( mr->smr_oid );
1381 for( i=0; values[i] != NULL; i++ ) {
1382 struct berval *value = ber_bvdup( values[i] );
1383 ldap_pvt_str2upper( value->bv_val );
1385 lutil_MD5Init( &MD5context );
1386 if( prefix != NULL && prefix->bv_len > 0 ) {
1387 lutil_MD5Update( &MD5context,
1388 prefix->bv_val, prefix->bv_len );
1390 lutil_MD5Update( &MD5context,
1391 syntax->ssyn_oid, slen );
1392 lutil_MD5Update( &MD5context,
1393 mr->smr_oid, mlen );
1394 lutil_MD5Update( &MD5context,
1395 value->bv_val, value->bv_len );
1396 lutil_MD5Final( MD5digest, &MD5context );
1398 ber_bvfree( value );
1400 keys[i] = ber_bvdup( &digest );
1405 return LDAP_SUCCESS;
1408 /* Index generation function */
1409 int caseIgnoreIA5Filter(
1414 struct berval *prefix,
1416 struct berval ***keysp )
1419 struct berval **keys;
1420 lutil_MD5_CTX MD5context;
1421 unsigned char MD5digest[LUTIL_MD5_BYTES];
1422 struct berval *value;
1423 struct berval digest;
1424 digest.bv_val = MD5digest;
1425 digest.bv_len = sizeof(MD5digest);
1427 slen = strlen( syntax->ssyn_oid );
1428 mlen = strlen( mr->smr_oid );
1430 value = ber_bvdup( (struct berval *) assertValue );
1431 ldap_pvt_str2upper( value->bv_val );
1433 keys = ch_malloc( sizeof( struct berval * ) * 2 );
1435 lutil_MD5Init( &MD5context );
1436 if( prefix != NULL && prefix->bv_len > 0 ) {
1437 lutil_MD5Update( &MD5context,
1438 prefix->bv_val, prefix->bv_len );
1440 lutil_MD5Update( &MD5context,
1441 syntax->ssyn_oid, slen );
1442 lutil_MD5Update( &MD5context,
1443 mr->smr_oid, mlen );
1444 lutil_MD5Update( &MD5context,
1445 value->bv_val, value->bv_len );
1446 lutil_MD5Final( MD5digest, &MD5context );
1448 keys[0] = ber_bvdup( &digest );
1451 ber_bvfree( value );
1455 return LDAP_SUCCESS;
1458 /* Substrings Index generation function */
1459 int caseIgnoreIA5SubstringsIndexer(
1464 struct berval *prefix,
1465 struct berval **values,
1466 struct berval ***keysp )
1470 struct berval **keys;
1471 lutil_MD5_CTX MD5context;
1472 unsigned char MD5digest[16];
1473 struct berval digest;
1474 digest.bv_val = MD5digest;
1475 digest.bv_len = sizeof(MD5digest);
1478 for( i=0; values[i] != NULL; i++ ) {
1479 /* count number of indices to generate */
1480 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
1484 if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
1485 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1486 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
1487 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
1489 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
1493 if( flags & SLAP_INDEX_SUBSTR_ANY ) {
1494 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1495 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1499 if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
1500 if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1501 nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
1502 ( SLAP_INDEX_SUBSTR_MINLEN - 1);
1504 nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
1511 /* no keys to generate */
1513 return LDAP_SUCCESS;
1516 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1518 slen = strlen( syntax->ssyn_oid );
1519 mlen = strlen( mr->smr_oid );
1522 for( i=0; values[i] != NULL; i++ ) {
1524 struct berval *value;
1526 if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
1528 value = ber_bvdup( values[i] );
1529 ldap_pvt_str2upper( value->bv_val );
1531 if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
1532 ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
1534 char pre = SLAP_INDEX_SUBSTR_PREFIX;
1535 max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
1537 for( j=0; j<max; j++ ) {
1538 lutil_MD5Init( &MD5context );
1539 if( prefix != NULL && prefix->bv_len > 0 ) {
1540 lutil_MD5Update( &MD5context,
1541 prefix->bv_val, prefix->bv_len );
1544 lutil_MD5Update( &MD5context,
1545 &pre, sizeof( pre ) );
1546 lutil_MD5Update( &MD5context,
1547 syntax->ssyn_oid, slen );
1548 lutil_MD5Update( &MD5context,
1549 mr->smr_oid, mlen );
1550 lutil_MD5Update( &MD5context,
1552 SLAP_INDEX_SUBSTR_MAXLEN );
1553 lutil_MD5Final( MD5digest, &MD5context );
1555 keys[nkeys++] = ber_bvdup( &digest );
1559 max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1560 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1562 for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
1565 if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
1566 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1567 lutil_MD5Init( &MD5context );
1568 if( prefix != NULL && prefix->bv_len > 0 ) {
1569 lutil_MD5Update( &MD5context,
1570 prefix->bv_val, prefix->bv_len );
1572 lutil_MD5Update( &MD5context,
1573 &pre, sizeof( pre ) );
1574 lutil_MD5Update( &MD5context,
1575 syntax->ssyn_oid, slen );
1576 lutil_MD5Update( &MD5context,
1577 mr->smr_oid, mlen );
1578 lutil_MD5Update( &MD5context,
1580 lutil_MD5Final( MD5digest, &MD5context );
1582 keys[nkeys++] = ber_bvdup( &digest );
1585 if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
1586 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1587 lutil_MD5Init( &MD5context );
1588 if( prefix != NULL && prefix->bv_len > 0 ) {
1589 lutil_MD5Update( &MD5context,
1590 prefix->bv_val, prefix->bv_len );
1592 lutil_MD5Update( &MD5context,
1593 &pre, sizeof( pre ) );
1594 lutil_MD5Update( &MD5context,
1595 syntax->ssyn_oid, slen );
1596 lutil_MD5Update( &MD5context,
1597 mr->smr_oid, mlen );
1598 lutil_MD5Update( &MD5context,
1599 &value->bv_val[value->bv_len-j], j );
1600 lutil_MD5Final( MD5digest, &MD5context );
1602 keys[nkeys++] = ber_bvdup( &digest );
1607 ber_bvfree( value );
1618 return LDAP_SUCCESS;
1621 int caseIgnoreIA5SubstringsFilter(
1626 struct berval *prefix,
1628 struct berval ***keysp )
1630 SubstringsAssertion *sa = assertValue;
1632 ber_len_t nkeys = 0;
1633 size_t slen, mlen, klen;
1634 struct berval **keys;
1635 lutil_MD5_CTX MD5context;
1636 unsigned char MD5digest[LUTIL_MD5_BYTES];
1637 struct berval *value;
1638 struct berval digest;
1640 if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
1641 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1646 if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
1648 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1649 if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
1650 /* don't bother accounting for stepping */
1651 nkeys += sa->sa_any[i]->bv_len -
1652 ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
1657 if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
1658 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1665 return LDAP_SUCCESS;
1668 digest.bv_val = MD5digest;
1669 digest.bv_len = sizeof(MD5digest);
1671 slen = strlen( syntax->ssyn_oid );
1672 mlen = strlen( mr->smr_oid );
1674 keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
1677 if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
1678 sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1680 pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
1681 value = ber_bvdup( sa->sa_initial );
1682 ldap_pvt_str2upper( value->bv_val );
1684 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1685 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1687 lutil_MD5Init( &MD5context );
1688 if( prefix != NULL && prefix->bv_len > 0 ) {
1689 lutil_MD5Update( &MD5context,
1690 prefix->bv_val, prefix->bv_len );
1692 lutil_MD5Update( &MD5context,
1693 &pre, sizeof( pre ) );
1694 lutil_MD5Update( &MD5context,
1695 syntax->ssyn_oid, slen );
1696 lutil_MD5Update( &MD5context,
1697 mr->smr_oid, mlen );
1698 lutil_MD5Update( &MD5context,
1699 value->bv_val, klen );
1700 lutil_MD5Final( MD5digest, &MD5context );
1702 ber_bvfree( value );
1703 keys[nkeys++] = ber_bvdup( &digest );
1706 if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
1708 pre = SLAP_INDEX_SUBSTR_PREFIX;
1709 klen = SLAP_INDEX_SUBSTR_MAXLEN;
1711 for( i=0; sa->sa_any[i] != NULL; i++ ) {
1712 if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
1716 value = ber_bvdup( sa->sa_any[i] );
1717 ldap_pvt_str2upper( value->bv_val );
1720 j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
1721 j += SLAP_INDEX_SUBSTR_STEP )
1723 lutil_MD5Init( &MD5context );
1724 if( prefix != NULL && prefix->bv_len > 0 ) {
1725 lutil_MD5Update( &MD5context,
1726 prefix->bv_val, prefix->bv_len );
1728 lutil_MD5Update( &MD5context,
1729 &pre, sizeof( pre ) );
1730 lutil_MD5Update( &MD5context,
1731 syntax->ssyn_oid, slen );
1732 lutil_MD5Update( &MD5context,
1733 mr->smr_oid, mlen );
1734 lutil_MD5Update( &MD5context,
1735 &value->bv_val[j], klen );
1736 lutil_MD5Final( MD5digest, &MD5context );
1738 keys[nkeys++] = ber_bvdup( &digest );
1741 ber_bvfree( value );
1745 if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
1746 sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
1748 pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
1749 value = ber_bvdup( sa->sa_final );
1750 ldap_pvt_str2upper( value->bv_val );
1752 klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
1753 ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
1755 lutil_MD5Init( &MD5context );
1756 if( prefix != NULL && prefix->bv_len > 0 ) {
1757 lutil_MD5Update( &MD5context,
1758 prefix->bv_val, prefix->bv_len );
1760 lutil_MD5Update( &MD5context,
1761 &pre, sizeof( pre ) );
1762 lutil_MD5Update( &MD5context,
1763 syntax->ssyn_oid, slen );
1764 lutil_MD5Update( &MD5context,
1765 mr->smr_oid, mlen );
1766 lutil_MD5Update( &MD5context,
1767 &value->bv_val[value->bv_len-klen], klen );
1768 lutil_MD5Final( MD5digest, &MD5context );
1770 ber_bvfree( value );
1771 keys[nkeys++] = ber_bvdup( &digest );
1782 return LDAP_SUCCESS;
1786 numericStringNormalize(
1789 struct berval **normalized )
1791 /* similiar to IA5StringNormalize except removes all spaces */
1792 struct berval *newval;
1795 newval = ch_malloc( sizeof( struct berval ) );
1799 /* Ignore initial whitespace */
1800 while ( ASCII_SPACE( *p ) ) {
1806 return LDAP_INVALID_SYNTAX;
1809 newval->bv_val = ch_strdup( p );
1810 p = q = newval->bv_val;
1813 if ( ASCII_SPACE( *p ) ) {
1814 /* Ignore whitespace */
1821 assert( *newval->bv_val );
1822 assert( newval->bv_val < p );
1825 /* cannot start with a space */
1826 assert( !ASCII_SPACE(*newval->bv_val) );
1828 /* cannot end with a space */
1829 assert( !ASCII_SPACE( q[-1] ) );
1831 /* null terminate */
1834 newval->bv_len = q - newval->bv_val;
1835 *normalized = newval;
1837 return LDAP_SUCCESS;
1841 objectIdentifierFirstComponentMatch(
1846 struct berval *value,
1847 void *assertedValue )
1849 int rc = LDAP_SUCCESS;
1851 struct berval *asserted = (struct berval *) assertedValue;
1855 if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
1856 return LDAP_INVALID_SYNTAX;
1859 /* trim leading white space */
1860 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
1864 /* grab next word */
1865 oid.bv_val = &value->bv_val[i];
1866 oid.bv_len = value->bv_len - i;
1867 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < oid.bv_len; i++ ) {
1872 /* insert attributeTypes, objectclass check here */
1873 if( OID_LEADCHAR(asserted->bv_val[0]) ) {
1874 rc = objectIdentifierMatch( &match, flags, syntax, mr, &oid, asserted );
1877 char *stored = ch_malloc( oid.bv_len + 1 );
1878 AC_MEMCPY( stored, oid.bv_val, oid.bv_len );
1879 stored[oid.bv_len] = '\0';
1881 if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
1882 MatchingRule *asserted_mr = mr_find( asserted->bv_val );
1883 MatchingRule *stored_mr = mr_find( stored );
1885 if( asserted_mr == NULL ) {
1886 rc = SLAPD_COMPARE_UNDEFINED;
1888 match = asserted_mr != stored_mr;
1891 } else if ( !strcmp( syntax->ssyn_oid,
1892 SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
1894 AttributeType *asserted_at = at_find( asserted->bv_val );
1895 AttributeType *stored_at = at_find( stored );
1897 if( asserted_at == NULL ) {
1898 rc = SLAPD_COMPARE_UNDEFINED;
1900 match = asserted_at != stored_at;
1903 } else if ( !strcmp( syntax->ssyn_oid,
1904 SLAP_SYNTAX_OBJECTCLASSES_OID ) )
1906 ObjectClass *asserted_oc = oc_find( asserted->bv_val );
1907 ObjectClass *stored_oc = oc_find( stored );
1909 if( asserted_oc == NULL ) {
1910 rc = SLAPD_COMPARE_UNDEFINED;
1912 match = asserted_oc != stored_oc;
1919 Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
1920 "%d\n\t\"%s\"\n\t\"%s\"\n",
1921 match, value->bv_val, asserted->bv_val );
1923 if( rc == LDAP_SUCCESS ) *matchp = match;
1928 check_time_syntax (struct berval *val,
1932 static int ceiling[9] = { 99, 99, 11, 30, 23, 59, 59, 12, 59 };
1933 static int mdays[2][12] = {
1934 /* non-leap years */
1935 { 30, 27, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30 },
1937 { 30, 28, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30 }
1940 int part, c, tzoffset, leapyear = 0 ;
1942 if( val->bv_len == 0 ) {
1943 return LDAP_INVALID_SYNTAX;
1946 p = (char *)val->bv_val;
1947 e = p + val->bv_len;
1949 /* Ignore initial whitespace */
1950 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1954 if (e - p < 13 - (2 * start)) {
1955 return LDAP_INVALID_SYNTAX;
1958 for (part = 0; part < 9; part++) {
1962 for (part = start; part < 7; part++) {
1964 if ((part == 6) && (c == 'Z' || c == '+' || c == '-')) {
1971 return LDAP_INVALID_SYNTAX;
1973 if (c < 0 || c > 9) {
1974 return LDAP_INVALID_SYNTAX;
1980 return LDAP_INVALID_SYNTAX;
1982 if (c < 0 || c > 9) {
1983 return LDAP_INVALID_SYNTAX;
1988 if (part == 2 || part == 3) {
1991 if (parts[part] < 0) {
1992 return LDAP_INVALID_SYNTAX;
1994 if (parts[part] > ceiling[part]) {
1995 return LDAP_INVALID_SYNTAX;
1999 /* leapyear check for the Gregorian calendar (year>1581) */
2000 if (((parts[1] % 4 == 0) && (parts[1] != 0)) ||
2001 ((parts[0] % 4 == 0) && (parts[1] == 0)))
2006 if (parts[3] > mdays[leapyear][parts[2]]) {
2007 return LDAP_INVALID_SYNTAX;
2012 tzoffset = 0; /* UTC */
2013 } else if (c != '+' && c != '-') {
2014 return LDAP_INVALID_SYNTAX;
2018 } else /* c == '+' */ {
2023 return LDAP_INVALID_SYNTAX;
2026 for (part = 7; part < 9; part++) {
2028 if (c < 0 || c > 9) {
2029 return LDAP_INVALID_SYNTAX;
2034 if (c < 0 || c > 9) {
2035 return LDAP_INVALID_SYNTAX;
2039 if (parts[part] < 0 || parts[part] > ceiling[part]) {
2040 return LDAP_INVALID_SYNTAX;
2045 /* Ignore trailing whitespace */
2046 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
2050 return LDAP_INVALID_SYNTAX;
2053 switch ( tzoffset ) {
2054 case -1: /* negativ offset to UTC, ie west of Greenwich */
2055 parts[4] += parts[7];
2056 parts[5] += parts[8];
2057 for (part = 6; --part > 0; ) { /* offset is just hhmm, no seconds */
2061 c = mdays[leapyear][parts[2]];
2063 if (parts[part] > c) {
2064 parts[part] -= c + 1;
2069 case 1: /* positive offset to UTC, ie east of Greenwich */
2070 parts[4] -= parts[7];
2071 parts[5] -= parts[8];
2072 for (part = 6; --part > 0; ) {
2076 /* first arg to % needs to be non negativ */
2077 c = mdays[leapyear][(parts[2] - 1 + 12) % 12];
2079 if (parts[part] < 0) {
2080 parts[part] += c + 1;
2085 case 0: /* already UTC */
2089 return LDAP_SUCCESS;
2096 struct berval **normalized )
2101 rc = check_time_syntax(val, 1, parts);
2102 if (rc != LDAP_SUCCESS) {
2107 out = ch_malloc( sizeof(struct berval) );
2109 return LBER_ERROR_MEMORY;
2112 out->bv_val = ch_malloc( 14 );
2113 if ( out->bv_val == NULL ) {
2115 return LBER_ERROR_MEMORY;
2118 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ",
2119 parts[1], parts[2] + 1, parts[3] + 1,
2120 parts[4], parts[5], parts[6] );
2124 return LDAP_SUCCESS;
2134 return check_time_syntax(in, 1, parts);
2138 generalizedTimeValidate(
2144 return check_time_syntax(in, 0, parts);
2148 generalizedTimeNormalize(
2151 struct berval **normalized )
2156 rc = check_time_syntax(val, 0, parts);
2157 if (rc != LDAP_SUCCESS) {
2162 out = ch_malloc( sizeof(struct berval) );
2164 return LBER_ERROR_MEMORY;
2167 out->bv_val = ch_malloc( 16 );
2168 if ( out->bv_val == NULL ) {
2170 return LBER_ERROR_MEMORY;
2173 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ",
2174 parts[0], parts[1], parts[2] + 1, parts[3] + 1,
2175 parts[4], parts[5], parts[6] );
2179 return LDAP_SUCCESS;
2183 nisNetgroupTripleValidate(
2185 struct berval *val )
2190 if ( val->bv_len == 0 ) {
2191 return LDAP_INVALID_SYNTAX;
2194 p = (char *)val->bv_val;
2195 e = p + val->bv_len;
2198 /* syntax does not allow leading white space */
2199 /* Ignore initial whitespace */
2200 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
2205 if ( *p != '(' /*')'*/ ) {
2206 return LDAP_INVALID_SYNTAX;
2209 for ( p++; ( p < e ) && ( *p != ')' ); p++ ) {
2213 return LDAP_INVALID_SYNTAX;
2216 } else if ( !ATTR_CHAR( *p ) ) {
2217 return LDAP_INVALID_SYNTAX;
2221 if ( ( commas != 2 ) || ( *p != /*'('*/ ')' ) ) {
2222 return LDAP_INVALID_SYNTAX;
2228 /* syntax does not allow trailing white space */
2229 /* Ignore trailing whitespace */
2230 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
2236 return LDAP_INVALID_SYNTAX;
2239 return LDAP_SUCCESS;
2243 bootParameterValidate(
2245 struct berval *val )
2249 if ( val->bv_len == 0 ) {
2250 return LDAP_INVALID_SYNTAX;
2253 p = (char *)val->bv_val;
2254 e = p + val->bv_len;
2257 for (; ( p < e ) && ( *p != '=' ); p++ ) {
2258 if ( !ATTR_CHAR( *p ) ) {
2259 return LDAP_INVALID_SYNTAX;
2264 return LDAP_INVALID_SYNTAX;
2268 for ( p++; ( p < e ) && ( *p != ':' ); p++ ) {
2269 if ( !ATTR_CHAR( *p ) ) {
2270 return LDAP_INVALID_SYNTAX;
2275 return LDAP_INVALID_SYNTAX;
2279 for ( p++; p < e; p++ ) {
2280 if ( !ATTR_CHAR( *p ) ) {
2281 return LDAP_INVALID_SYNTAX;
2285 return LDAP_SUCCESS;
2288 struct syntax_defs_rec {
2291 slap_syntax_validate_func *sd_validate;
2292 slap_syntax_transform_func *sd_normalize;
2293 slap_syntax_transform_func *sd_pretty;
2294 #ifdef SLAPD_BINARY_CONVERSION
2295 slap_syntax_transform_func *sd_ber2str;
2296 slap_syntax_transform_func *sd_str2ber;
2300 #define X_HIDE "X-HIDE 'TRUE' "
2301 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
2302 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
2304 struct syntax_defs_rec syntax_defs[] = {
2305 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
2306 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
2307 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
2308 0, NULL, NULL, NULL},
2309 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
2310 0, NULL, NULL, NULL},
2311 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
2312 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
2313 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
2314 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2315 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
2316 0, bitStringValidate, bitStringNormalize, NULL },
2317 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
2318 0, booleanValidate, NULL, NULL},
2319 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
2320 X_BINARY X_NOT_H_R ")",
2321 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2322 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
2323 X_BINARY X_NOT_H_R ")",
2324 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2325 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
2326 X_BINARY X_NOT_H_R ")",
2327 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2328 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
2329 0, NULL, NULL, NULL},
2330 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
2331 0, dnValidate, dnNormalize, dnPretty},
2332 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
2333 0, NULL, NULL, NULL},
2334 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
2335 0, NULL, NULL, NULL},
2336 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
2337 0, UTF8StringValidate, UTF8StringNormalize, NULL},
2338 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
2339 0, NULL, NULL, NULL},
2340 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
2341 0, NULL, NULL, NULL},
2342 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
2343 0, NULL, NULL, NULL},
2344 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
2345 0, NULL, NULL, NULL},
2346 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
2347 0, NULL, NULL, NULL},
2348 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
2349 0, IA5StringValidate, faxNumberNormalize, NULL},
2350 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
2351 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
2352 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
2353 0, generalizedTimeValidate, generalizedTimeNormalize, NULL},
2354 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
2355 0, NULL, NULL, NULL},
2356 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
2357 0, IA5StringValidate, IA5StringNormalize, NULL},
2358 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
2359 0, integerValidate, integerNormalize, integerPretty},
2360 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
2361 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
2362 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
2363 0, NULL, NULL, NULL},
2364 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
2365 0, NULL, NULL, NULL},
2366 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
2367 0, NULL, NULL, NULL},
2368 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
2369 0, NULL, NULL, NULL},
2370 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
2371 0, NULL, NULL, NULL},
2372 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
2373 0, nameUIDValidate, nameUIDNormalize, nameUIDPretty},
2374 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
2375 0, NULL, NULL, NULL},
2376 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
2377 0, IA5StringValidate, numericStringNormalize, NULL},
2378 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
2379 0, NULL, NULL, NULL},
2380 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
2381 0, oidValidate, NULL, NULL},
2382 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
2383 0, NULL, NULL, NULL},
2384 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
2385 0, blobValidate, NULL, NULL},
2386 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
2387 0, blobValidate, NULL, NULL},
2388 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
2389 0, NULL, NULL, NULL},
2390 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
2391 0, NULL, NULL, NULL},
2392 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
2393 0, printableStringValidate, NULL, NULL},
2394 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
2395 X_BINARY X_NOT_H_R ")",
2396 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
2397 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
2398 0, IA5StringValidate, phoneNumberNormalize, NULL},
2399 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
2400 0, NULL, NULL, NULL},
2401 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
2402 0, IA5StringValidate, telexNumberNormalize, NULL},
2403 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
2404 0, utcTimeValidate, utcTimeNormalize, NULL},
2405 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
2406 0, NULL, NULL, NULL},
2407 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
2408 0, NULL, NULL, NULL},
2409 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
2410 0, NULL, NULL, NULL},
2411 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
2412 0, NULL, NULL, NULL},
2413 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
2414 0, NULL, NULL, NULL},
2416 /* RFC 2307 NIS Syntaxes */
2417 {"( 1.3.6.1.1.1.0.0 DESC 'RFC2307 NIS Triple' )",
2418 0, nisNetgroupTripleValidate, NULL, NULL},
2419 {"( 1.3.6.1.1.1.0.1 DESC 'RFC2307 Boot Parameter' )",
2420 0, bootParameterValidate, NULL, NULL},
2422 /* OpenLDAP Experimental Syntaxes */
2423 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
2424 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
2427 /* OpenLDAP Void Syntax */
2428 {"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' " X_HIDE ")" ,
2429 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
2430 {NULL, 0, NULL, NULL, NULL}
2433 struct mrule_defs_rec {
2435 slap_mask_t mrd_usage;
2436 slap_mr_convert_func * mrd_convert;
2437 slap_mr_normalize_func * mrd_normalize;
2438 slap_mr_match_func * mrd_match;
2439 slap_mr_indexer_func * mrd_indexer;
2440 slap_mr_filter_func * mrd_filter;
2442 char * mrd_associated;
2446 * Other matching rules in X.520 that we do not use (yet):
2448 * 2.5.13.9 numericStringOrderingMatch
2449 * 2.5.13.13 booleanMatch
2450 * 2.5.13.15 integerOrderingMatch
2451 * 2.5.13.18 octetStringOrderingMatch
2452 * 2.5.13.19 octetStringSubstringsMatch
2453 * 2.5.13.25 uTCTimeMatch
2454 * 2.5.13.26 uTCTimeOrderingMatch
2455 * 2.5.13.31 directoryStringFirstComponentMatch
2456 * 2.5.13.32 wordMatch
2457 * 2.5.13.33 keywordMatch
2458 * 2.5.13.34 certificateExactMatch
2459 * 2.5.13.35 certificateMatch
2460 * 2.5.13.36 certificatePairExactMatch
2461 * 2.5.13.37 certificatePairMatch
2462 * 2.5.13.38 certificateListExactMatch
2463 * 2.5.13.39 certificateListMatch
2464 * 2.5.13.40 algorithmIdentifierMatch
2465 * 2.5.13.41 storedPrefixMatch
2466 * 2.5.13.42 attributeCertificateMatch
2467 * 2.5.13.43 readerAndKeyIDMatch
2468 * 2.5.13.44 attributeIntegrityMatch
2471 struct mrule_defs_rec mrule_defs[] = {
2473 * Other matching rules
2476 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
2477 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
2478 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2480 objectIdentifierMatch, caseIgnoreIA5Indexer, caseIgnoreIA5Filter,
2483 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
2484 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
2485 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2487 dnMatch, dnIndexer, dnFilter,
2490 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
2491 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2492 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2494 caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter,
2497 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
2498 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2501 caseIgnoreOrderingMatch, NULL, NULL,
2504 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
2505 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2506 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2508 caseIgnoreSubstringsMatch,
2509 caseIgnoreSubstringsIndexer,
2510 caseIgnoreSubstringsFilter,
2513 {"( 2.5.13.5 NAME 'caseExactMatch' "
2514 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2515 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2517 caseExactMatch, caseExactIndexer, caseExactFilter,
2520 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
2521 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
2524 caseExactOrderingMatch, NULL, NULL,
2527 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
2528 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2529 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2531 caseExactSubstringsMatch,
2532 caseExactSubstringsIndexer,
2533 caseExactSubstringsFilter,
2536 {"( 2.5.13.8 NAME 'numericStringMatch' "
2537 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
2538 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2540 caseIgnoreIA5Match, NULL, NULL,
2543 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
2544 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2545 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2547 caseIgnoreIA5SubstringsMatch,
2548 caseIgnoreIA5SubstringsIndexer,
2549 caseIgnoreIA5SubstringsFilter,
2552 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
2553 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
2554 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2556 caseIgnoreListMatch, NULL, NULL,
2559 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
2560 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2561 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2563 caseIgnoreListSubstringsMatch, NULL, NULL,
2566 {"( 2.5.13.13 NAME 'booleanMatch' "
2567 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
2568 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2570 booleanMatch, NULL, NULL,
2573 {"( 2.5.13.14 NAME 'integerMatch' "
2574 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
2575 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2577 integerMatch, NULL, NULL,
2580 {"( 2.5.13.16 NAME 'bitStringMatch' "
2581 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
2582 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2584 bitStringMatch, NULL, NULL,
2587 {"( 2.5.13.17 NAME 'octetStringMatch' "
2588 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
2589 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2591 octetStringMatch, octetStringIndexer, octetStringFilter,
2594 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
2595 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
2596 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2598 telephoneNumberMatch, NULL, NULL,
2601 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
2602 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
2603 SLAP_MR_SUBSTR | SLAP_MR_EXT,
2605 telephoneNumberSubstringsMatch, NULL, NULL,
2608 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
2609 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
2610 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2612 presentationAddressMatch, NULL, NULL,
2615 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
2616 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
2617 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2619 uniqueMemberMatch, NULL, NULL,
2622 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
2623 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
2624 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2626 protocolInformationMatch, NULL, NULL,
2629 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
2630 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
2631 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2633 generalizedTimeMatch, NULL, NULL,
2636 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
2637 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
2640 generalizedTimeOrderingMatch, NULL, NULL,
2643 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
2644 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
2645 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2647 integerFirstComponentMatch, NULL, NULL,
2650 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
2651 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
2652 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2654 objectIdentifierFirstComponentMatch, NULL, NULL,
2657 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
2658 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2659 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2661 caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
2664 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
2665 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2666 SLAP_MR_EQUALITY | SLAP_MR_EXT,
2668 caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
2671 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
2672 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2675 caseIgnoreIA5SubstringsMatch,
2676 caseIgnoreIA5SubstringsIndexer,
2677 caseIgnoreIA5SubstringsFilter,
2680 {"( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch' "
2681 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
2684 caseExactIA5SubstringsMatch,
2685 caseExactIA5SubstringsIndexer,
2686 caseExactIA5SubstringsFilter,
2689 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
2690 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
2693 OpenLDAPaciMatch, NULL, NULL,
2696 {NULL, SLAP_MR_NONE, NULL, NULL, NULL, NULL}
2705 /* we should only be called once (from main) */
2706 assert( schema_init_done == 0 );
2708 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
2709 res = register_syntax( syntax_defs[i].sd_desc,
2710 syntax_defs[i].sd_flags,
2711 syntax_defs[i].sd_validate,
2712 syntax_defs[i].sd_normalize,
2713 syntax_defs[i].sd_pretty
2714 #ifdef SLAPD_BINARY_CONVERSION
2716 syntax_defs[i].sd_ber2str,
2717 syntax_defs[i].sd_str2ber
2722 fprintf( stderr, "schema_init: Error registering syntax %s\n",
2723 syntax_defs[i].sd_desc );
2728 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
2729 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
2731 "schema_init: Ingoring unusable matching rule %s\n",
2732 mrule_defs[i].mrd_desc );
2736 res = register_matching_rule(
2737 mrule_defs[i].mrd_desc,
2738 mrule_defs[i].mrd_usage,
2739 mrule_defs[i].mrd_convert,
2740 mrule_defs[i].mrd_normalize,
2741 mrule_defs[i].mrd_match,
2742 mrule_defs[i].mrd_indexer,
2743 mrule_defs[i].mrd_filter,
2744 mrule_defs[i].mrd_associated );
2748 "schema_init: Error registering matching rule %s\n",
2749 mrule_defs[i].mrd_desc );
2753 schema_init_done = 1;
2754 return LDAP_SUCCESS;