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 /* recycled normalization routines */
24 #define faxNumberNormalize numericStringNormalize
25 #define phoneNumberNormalize numericStringNormalize
26 #define telexNumberNormalize numericStringNormalize
28 /* recycled matching routines */
29 #define caseIgnoreMatch caseIgnoreIA5Match
30 #define caseIgnoreOrderingMatch caseIgnoreMatch
31 #define caseIgnoreSubstringsMatch caseIgnoreIA5SubstringsMatch
33 #define caseExactMatch caseExactIA5Match
34 #define caseExactOrderingMatch caseExactMatch
35 #define caseExactSubstringsMatch caseExactIA5SubstringsMatch
37 #define numericStringMatch caseIgnoreMatch
38 #define objectIdentifierMatch numericStringMatch
39 #define integerMatch numericStringMatch
40 #define telephoneNumberMatch numericStringMatch
41 #define generalizedTimeMatch numericStringMatch
42 #define generalizedTimeOrderingMatch numericStringMatch
44 /* unimplemented matching routines */
45 #define caseIgnoreListMatch NULL
46 #define caseIgnoreListSubstringsMatch NULL
47 #define bitStringMatch NULL
48 #define telephoneNumberSubstringsMatch NULL
49 #define presentationAddressMatch NULL
50 #define uniqueMemberMatch NULL
51 #define protocolInformationMatch NULL
52 #define integerFirstComponentMatch NULL
54 #define OpenLDAPaciMatch NULL
55 #define authPasswordMatch NULL
57 /* unimplied indexer/filter routines */
58 #define dnIndexer NULL
60 #define caseIgnoreIA5SubstringsIndexer NULL
61 #define caseIgnoreIA5SubstringsFilter NULL
63 /* recycled indexing/filtering routines */
64 #define caseIgnoreIndexer caseIgnoreIA5Indexer
65 #define caseIgnoreFilter caseIgnoreIA5Filter
66 #define caseExactIndexer caseExactIA5Indexer
67 #define caseExactFilter caseExactIA5Filter
68 #define caseExactIA5Indexer caseIgnoreIA5Indexer
69 #define caseExactIA5Filter caseIgnoreIA5Filter
71 #define caseIgnoreSubstringsIndexer caseIgnoreIA5SubstringsIndexer
72 #define caseIgnoreSubstringsFilter caseIgnoreIA5SubstringsFilter
73 #define caseExactSubstringsIndexer caseExactIA5SubstringsIndexer
74 #define caseExactSubstringsFilter caseExactIA5SubstringsFilter
75 #define caseExactIA5SubstringsFilter caseIgnoreIA5SubstringsFilter
76 #define caseExactIA5SubstringsIndexer caseIgnoreIA5SubstringsIndexer
88 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
91 match = memcmp( value->bv_val,
92 ((struct berval *) assertedValue)->bv_val,
100 /* Index generation function */
101 int octetStringIndexer(
105 struct berval *prefix,
106 struct berval **values,
107 struct berval ***keysp )
111 struct berval **keys;
112 lutil_MD5_CTX MD5context;
113 unsigned char MD5digest[16];
114 struct berval digest;
115 digest.bv_val = MD5digest;
116 digest.bv_len = sizeof(MD5digest);
118 for( i=0; values[i] != NULL; i++ ) {
119 /* just count them */
124 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
126 slen = strlen( syntax->ssyn_oid );
127 mlen = strlen( mr->smr_oid );
129 for( i=0; values[i] != NULL; i++ ) {
130 lutil_MD5Init( &MD5context );
131 if( prefix != NULL && prefix->bv_len > 0 ) {
132 lutil_MD5Update( &MD5context,
133 prefix->bv_val, prefix->bv_len );
135 lutil_MD5Update( &MD5context,
136 syntax->ssyn_oid, slen );
137 lutil_MD5Update( &MD5context,
139 lutil_MD5Update( &MD5context,
140 values[i]->bv_val, values[i]->bv_len );
141 lutil_MD5Final( MD5digest, &MD5context );
143 keys[i] = ber_bvdup( &digest );
153 /* Index generation function */
154 int octetStringFilter(
158 struct berval *prefix,
160 struct berval ***keysp )
163 struct berval **keys;
164 lutil_MD5_CTX MD5context;
165 unsigned char MD5digest[LUTIL_MD5_BYTES];
166 struct berval *value = (struct berval *) assertValue;
167 struct berval digest;
168 digest.bv_val = MD5digest;
169 digest.bv_len = sizeof(MD5digest);
171 slen = strlen( syntax->ssyn_oid );
172 mlen = strlen( mr->smr_oid );
174 keys = ch_malloc( sizeof( struct berval * ) * 2 );
176 lutil_MD5Init( &MD5context );
177 if( prefix != NULL && prefix->bv_len > 0 ) {
178 lutil_MD5Update( &MD5context,
179 prefix->bv_val, prefix->bv_len );
181 lutil_MD5Update( &MD5context,
182 syntax->ssyn_oid, slen );
183 lutil_MD5Update( &MD5context,
185 lutil_MD5Update( &MD5context,
186 value->bv_val, value->bv_len );
187 lutil_MD5Final( MD5digest, &MD5context );
189 keys[0] = ber_bvdup( &digest );
205 if( in->bv_len == 0 ) return LDAP_SUCCESS;
207 dn = ch_strdup( in->bv_val );
209 rc = dn_validate( dn ) == NULL
210 ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
220 struct berval **normalized )
222 struct berval *out = ber_bvdup( val );
224 if( out->bv_len != 0 ) {
226 #ifdef USE_DN_NORMALIZE
227 dn = dn_normalize( out->bv_val );
229 dn = dn_validate( out->bv_val );
234 return LDAP_INVALID_SYNTAX;
238 out->bv_len = strlen( dn );
251 struct berval *value,
252 void *assertedValue )
255 struct berval *asserted = (struct berval *) assertedValue;
257 match = value->bv_len - asserted->bv_len;
260 #ifdef USE_DN_NORMALIZE
261 match = strcmp( value->bv_val, asserted->bv_val );
263 match = strcasecmp( value->bv_val, asserted->bv_val );
267 Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n",
268 match, value->bv_val, asserted->bv_val );
279 /* any value allowed */
288 /* any value allowed */
299 unsigned char *u = in->bv_val;
301 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
302 /* get the length indicated by the first byte */
303 len = LDAP_UTF8_CHARLEN( u );
305 /* should not be zero */
306 if( len == 0 ) return LDAP_INVALID_SYNTAX;
308 /* make sure len corresponds with the offset
309 to the next character */
310 if( LDAP_UTF8_OFFSET( u ) != len ) return LDAP_INVALID_SYNTAX;
313 if( count != 0 ) return LDAP_INVALID_SYNTAX;
322 struct berval **normalized )
324 struct berval *newval;
327 newval = ch_malloc( sizeof( struct berval ) );
331 /* Ignore initial whitespace */
332 while ( ldap_utf8_isspace( p ) ) {
338 return LDAP_INVALID_SYNTAX;
341 newval->bv_val = ch_strdup( p );
342 p = q = newval->bv_val;
348 if ( ldap_utf8_isspace( p ) ) {
349 len = LDAP_UTF8_COPY(q,p);
354 /* Ignore the extra whitespace */
355 while ( ldap_utf8_isspace( p ) ) {
359 len = LDAP_UTF8_COPY(q,p);
366 assert( *newval->bv_val );
367 assert( newval->bv_val < p );
370 /* cannot start with a space */
371 assert( !ldap_utf8_isspace(newval->bv_val) );
374 * If the string ended in space, backup the pointer one
375 * position. One is enough because the above loop collapsed
376 * all whitespace to a single space.
383 /* cannot end with a space */
384 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
389 newval->bv_len = q - newval->bv_val;
390 *normalized = newval;
402 if( val->bv_len == 0 ) return 0;
404 if( OID_LEADCHAR(val->bv_val[0]) ) {
406 for(i=1; i < val->bv_len; i++) {
407 if( OID_SEPARATOR( val->bv_val[i] ) ) {
408 if( dot++ ) return 1;
409 } else if ( OID_CHAR( val->bv_val[i] ) ) {
412 return LDAP_INVALID_SYNTAX;
416 return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX;
418 } else if( DESC_LEADCHAR(val->bv_val[0]) ) {
419 for(i=1; i < val->bv_len; i++) {
420 if( !DESC_CHAR(val->bv_val[i] ) ) {
421 return LDAP_INVALID_SYNTAX;
428 return LDAP_INVALID_SYNTAX;
438 for(i=0; i < val->bv_len; i++) {
439 if( !ASCII_DIGIT(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
446 printableStringValidate(
452 for(i=0; i < val->bv_len; i++) {
453 if( !isprint(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
466 for(i=0; i < val->bv_len; i++) {
467 if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
477 struct berval **out )
480 ber_len_t i, len = in->bv_len;
481 struct berval *bv = ch_malloc( sizeof(struct berval) );
483 bv->bv_len = len * sizeof( ldap_unicode_t );
484 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
486 for(i=0; i < len; i++ ) {
488 * IA5StringValidate should have been called to ensure
489 * input is limited to IA5.
491 u[i] = in->bv_val[i];
503 struct berval **normalized )
505 struct berval *newval;
508 newval = ch_malloc( sizeof( struct berval ) );
512 /* Ignore initial whitespace */
513 while ( ASCII_SPACE( *p ) ) {
519 return LDAP_INVALID_SYNTAX;
522 newval->bv_val = ch_strdup( p );
523 p = q = newval->bv_val;
526 if ( ASCII_SPACE( *p ) ) {
529 /* Ignore the extra whitespace */
530 while ( ASCII_SPACE( *p ) ) {
538 assert( *newval->bv_val );
539 assert( newval->bv_val < p );
542 /* cannot start with a space */
543 assert( !ASCII_SPACE(*newval->bv_val) );
546 * If the string ended in space, backup the pointer one
547 * position. One is enough because the above loop collapsed
548 * all whitespace to a single space.
551 if ( ASCII_SPACE( q[-1] ) ) {
555 /* cannot end with a space */
556 assert( !ASCII_SPACE( q[-1] ) );
561 newval->bv_len = q - newval->bv_val;
562 *normalized = newval;
573 struct berval *value,
574 void *assertedValue )
576 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
579 match = strncmp( value->bv_val,
580 ((struct berval *) assertedValue)->bv_val,
589 caseExactIA5SubstringsMatch(
594 struct berval *value,
595 void *assertedValue )
598 SubstringsAssertion *sub = assertedValue;
599 struct berval left = *value;
603 /* Add up asserted input length */
604 if( sub->sa_initial ) {
605 inlen += sub->sa_initial->bv_len;
608 for(i=0; sub->sa_any[i] != NULL; i++) {
609 inlen += sub->sa_any[i]->bv_len;
612 if( sub->sa_final ) {
613 inlen += sub->sa_final->bv_len;
616 if( sub->sa_initial ) {
617 if( inlen > left.bv_len ) {
622 match = strncmp( sub->sa_initial->bv_val, left.bv_val,
623 sub->sa_initial->bv_len );
629 left.bv_val += sub->sa_initial->bv_len;
630 left.bv_len -= sub->sa_initial->bv_len;
631 inlen -= sub->sa_initial->bv_len;
634 if( sub->sa_final ) {
635 if( inlen > left.bv_len ) {
640 match = strncmp( sub->sa_final->bv_val,
641 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
642 sub->sa_final->bv_len );
648 left.bv_len -= sub->sa_final->bv_len;
649 inlen -= sub->sa_final->bv_len;
653 for(i=0; sub->sa_any[i]; i++) {
658 if( inlen > left.bv_len ) {
659 /* not enough length */
664 if( sub->sa_any[i]->bv_len == 0 ) {
668 p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
675 idx = p - left.bv_val;
676 assert( idx < left.bv_len );
678 if( idx >= left.bv_len ) {
679 /* this shouldn't happen */
686 if( sub->sa_any[i]->bv_len > left.bv_len ) {
687 /* not enough left */
692 match = strncmp( left.bv_val,
693 sub->sa_any[i]->bv_val,
694 sub->sa_any[i]->bv_len );
702 left.bv_val += sub->sa_any[i]->bv_len;
703 left.bv_len -= sub->sa_any[i]->bv_len;
704 inlen -= sub->sa_any[i]->bv_len;
719 struct berval *value,
720 void *assertedValue )
722 int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
725 match = strncasecmp( value->bv_val,
726 ((struct berval *) assertedValue)->bv_val,
734 static char *strcasechr( const char *str, int c )
736 char *lower = strchr( str, TOLOWER(c) );
737 char *upper = strchr( str, TOUPPER(c) );
739 if( lower && upper ) {
740 return lower < upper ? lower : upper;
741 } else if ( lower ) {
749 caseIgnoreIA5SubstringsMatch(
754 struct berval *value,
755 void *assertedValue )
758 SubstringsAssertion *sub = assertedValue;
759 struct berval left = *value;
763 /* Add up asserted input length */
764 if( sub->sa_initial ) {
765 inlen += sub->sa_initial->bv_len;
768 for(i=0; sub->sa_any[i] != NULL; i++) {
769 inlen += sub->sa_any[i]->bv_len;
772 if( sub->sa_final ) {
773 inlen += sub->sa_final->bv_len;
776 if( sub->sa_initial ) {
777 if( inlen > left.bv_len ) {
782 match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
783 sub->sa_initial->bv_len );
789 left.bv_val += sub->sa_initial->bv_len;
790 left.bv_len -= sub->sa_initial->bv_len;
791 inlen -= sub->sa_initial->bv_len;
794 if( sub->sa_final ) {
795 if( inlen > left.bv_len ) {
800 match = strncasecmp( sub->sa_final->bv_val,
801 &left.bv_val[left.bv_len - sub->sa_final->bv_len],
802 sub->sa_final->bv_len );
808 left.bv_len -= sub->sa_final->bv_len;
809 inlen -= sub->sa_final->bv_len;
813 for(i=0; sub->sa_any[i]; i++) {
818 if( inlen > left.bv_len ) {
819 /* not enough length */
824 if( sub->sa_any[i]->bv_len == 0 ) {
828 p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
835 idx = p - left.bv_val;
836 assert( idx < left.bv_len );
838 if( idx >= left.bv_len ) {
839 /* this shouldn't happen */
846 if( sub->sa_any[i]->bv_len > left.bv_len ) {
847 /* not enough left */
852 match = strncasecmp( left.bv_val,
853 sub->sa_any[i]->bv_val,
854 sub->sa_any[i]->bv_len );
863 left.bv_val += sub->sa_any[i]->bv_len;
864 left.bv_len -= sub->sa_any[i]->bv_len;
865 inlen -= sub->sa_any[i]->bv_len;
874 /* Index generation function */
875 int caseIgnoreIA5Indexer(
879 struct berval *prefix,
880 struct berval **values,
881 struct berval ***keysp )
885 struct berval **keys;
886 lutil_MD5_CTX MD5context;
887 unsigned char MD5digest[16];
888 struct berval digest;
889 digest.bv_val = MD5digest;
890 digest.bv_len = sizeof(MD5digest);
892 for( i=0; values[i] != NULL; i++ ) {
893 /* just count them */
898 keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
900 slen = strlen( syntax->ssyn_oid );
901 mlen = strlen( mr->smr_oid );
903 for( i=0; values[i] != NULL; i++ ) {
904 struct berval *value = ber_bvdup( values[i] );
905 ldap_pvt_str2upper( value->bv_val );
907 lutil_MD5Init( &MD5context );
908 if( prefix != NULL && prefix->bv_len > 0 ) {
909 lutil_MD5Update( &MD5context,
910 prefix->bv_val, prefix->bv_len );
912 lutil_MD5Update( &MD5context,
913 syntax->ssyn_oid, slen );
914 lutil_MD5Update( &MD5context,
916 lutil_MD5Update( &MD5context,
917 value->bv_val, value->bv_len );
918 lutil_MD5Final( MD5digest, &MD5context );
922 keys[i] = ber_bvdup( &digest );
930 /* Index generation function */
931 int caseIgnoreIA5Filter(
935 struct berval *prefix,
937 struct berval ***keysp )
940 struct berval **keys;
941 lutil_MD5_CTX MD5context;
942 unsigned char MD5digest[LUTIL_MD5_BYTES];
943 struct berval *value;
944 struct berval digest;
945 digest.bv_val = MD5digest;
946 digest.bv_len = sizeof(MD5digest);
948 slen = strlen( syntax->ssyn_oid );
949 mlen = strlen( mr->smr_oid );
951 value = ber_bvdup( (struct berval *) assertValue );
952 ldap_pvt_str2upper( value->bv_val );
954 keys = ch_malloc( sizeof( struct berval * ) * 2 );
956 lutil_MD5Init( &MD5context );
957 if( prefix != NULL && prefix->bv_len > 0 ) {
958 lutil_MD5Update( &MD5context,
959 prefix->bv_val, prefix->bv_len );
961 lutil_MD5Update( &MD5context,
962 syntax->ssyn_oid, slen );
963 lutil_MD5Update( &MD5context,
965 lutil_MD5Update( &MD5context,
966 value->bv_val, value->bv_len );
967 lutil_MD5Final( MD5digest, &MD5context );
969 keys[0] = ber_bvdup( &digest );
979 numericStringNormalize(
982 struct berval **normalized )
984 /* similiar to IA5StringNormalize except removes all spaces */
985 struct berval *newval;
988 newval = ch_malloc( sizeof( struct berval ) );
992 /* Ignore initial whitespace */
993 while ( ASCII_SPACE( *p ) ) {
999 return LDAP_INVALID_SYNTAX;
1002 newval->bv_val = ch_strdup( p );
1003 p = q = newval->bv_val;
1006 if ( ASCII_SPACE( *p ) ) {
1007 /* Ignore whitespace */
1014 assert( *newval->bv_val );
1015 assert( newval->bv_val < p );
1018 /* cannot start with a space */
1019 assert( !ASCII_SPACE(*newval->bv_val) );
1021 /* cannot end with a space */
1022 assert( !ASCII_SPACE( q[-1] ) );
1024 /* null terminate */
1027 newval->bv_len = q - newval->bv_val;
1028 *normalized = newval;
1030 return LDAP_SUCCESS;
1034 objectIdentifierFirstComponentMatch(
1039 struct berval *value,
1040 void *assertedValue )
1042 int rc = LDAP_SUCCESS;
1044 struct berval *asserted = (struct berval *) assertedValue;
1048 if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
1049 return LDAP_INVALID_SYNTAX;
1052 /* trim leading white space */
1053 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
1057 /* grab next word */
1058 oid.bv_val = &value->bv_val[i];
1059 oid.bv_len = value->bv_len - i;
1060 for( i=1; ASCII_SPACE(value->bv_val[i]) && i < oid.bv_len; i++ ) {
1065 /* insert attributeTypes, objectclass check here */
1066 if( OID_LEADCHAR(asserted->bv_val[0]) ) {
1067 rc = objectIdentifierMatch( &match, use, syntax, mr, &oid, asserted );
1070 char *stored = ch_malloc( oid.bv_len + 1 );
1071 memcpy( stored, oid.bv_val, oid.bv_len );
1072 stored[oid.bv_len] = '\0';
1074 if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
1075 MatchingRule *asserted_mr = mr_find( asserted->bv_val );
1076 MatchingRule *stored_mr = mr_find( stored );
1078 if( asserted_mr == NULL ) {
1079 rc = SLAPD_COMPARE_UNDEFINED;
1081 match = asserted_mr != stored_mr;
1084 } else if ( !strcmp( syntax->ssyn_oid,
1085 SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
1087 AttributeType *asserted_at = at_find( asserted->bv_val );
1088 AttributeType *stored_at = at_find( stored );
1090 if( asserted_at == NULL ) {
1091 rc = SLAPD_COMPARE_UNDEFINED;
1093 match = asserted_at != stored_at;
1096 } else if ( !strcmp( syntax->ssyn_oid,
1097 SLAP_SYNTAX_OBJECTCLASSES_OID ) )
1099 ObjectClass *asserted_oc = oc_find( asserted->bv_val );
1100 ObjectClass *stored_oc = oc_find( stored );
1102 if( asserted_oc == NULL ) {
1103 rc = SLAPD_COMPARE_UNDEFINED;
1105 match = asserted_oc != stored_oc;
1112 Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
1113 "%d\n\t\"%s\"\n\t\"%s\"\n",
1114 match, value->bv_val, asserted->bv_val );
1116 if( rc == LDAP_SUCCESS ) *matchp = match;
1121 check_time_syntax (struct berval *val,
1125 static int ceiling[9] = { 99, 99, 11, 30, 23, 59, 59, 12, 59 };
1126 static int mdays[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1128 int part, c, neg = 0;
1130 if( val->bv_len == 0 )
1131 return LDAP_INVALID_SYNTAX;
1133 p = (char *)val->bv_val;
1134 e = p + val->bv_len;
1136 /* Ignore initial whitespace */
1137 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1141 if (e - p < 13 - (2 * start))
1142 return LDAP_INVALID_SYNTAX;
1144 for (part = 0; part < 9; part++)
1147 for (part = start; part < 7; part++) {
1160 return LDAP_INVALID_SYNTAX;
1162 return LDAP_INVALID_SYNTAX;
1167 return LDAP_INVALID_SYNTAX;
1169 return LDAP_INVALID_SYNTAX;
1173 if (part == 2 || part == 3)
1175 if (parts[part] < 0)
1176 return LDAP_INVALID_SYNTAX;
1177 if (parts[part] > ceiling[part])
1178 return LDAP_INVALID_SYNTAX;
1180 if (parts[2] == 1) {
1181 if (parts[3] > mdays[parts[2]])
1182 return LDAP_INVALID_SYNTAX;
1183 if (parts[1] & 0x03) {
1184 /* FIXME: This is an incomplete leap-year
1185 * check that fails in 2100, 2200, 2300,
1186 * 2500, 2600, 2700, ...
1188 if (parts[3] > mdays[parts[2]] - 1)
1189 return LDAP_INVALID_SYNTAX;
1195 } else if (c != '+' && c != '-') {
1196 return LDAP_INVALID_SYNTAX;
1201 return LDAP_INVALID_SYNTAX;
1202 for (part = 7; part < 9; part++) {
1205 return LDAP_INVALID_SYNTAX;
1210 return LDAP_INVALID_SYNTAX;
1213 if (parts[part] < 0 || parts[part] > ceiling[part])
1214 return LDAP_INVALID_SYNTAX;
1218 /* Ignore trailing whitespace */
1219 while ( ( p < e ) && ASCII_SPACE( *p ) ) {
1223 return LDAP_INVALID_SYNTAX;
1226 parts[4] += parts[7];
1227 parts[5] += parts[8];
1228 for (part = 7; --part > 0; ) {
1232 /* FIXME: This is an incomplete leap-year
1233 * check that fails in 2100, 2200, 2300,
1234 * 2500, 2600, 2700, ...
1236 c = mdays[parts[2]];
1240 if (parts[part] > c) {
1241 parts[part] -= c + 1;
1246 parts[4] -= parts[7];
1247 parts[5] -= parts[8];
1248 for (part = 7; --part > 0; ) {
1252 /* FIXME: This is an incomplete leap-year
1253 * check that fails in 2100, 2200, 2300,
1254 * 2500, 2600, 2700, ...
1256 c = mdays[(parts[2] - 1) % 12];
1260 if (parts[part] < 0) {
1261 parts[part] += c + 1;
1267 return LDAP_SUCCESS;
1274 struct berval **normalized )
1279 rc = check_time_syntax(val, 1, parts);
1280 if (rc != LDAP_SUCCESS) {
1285 out = ch_malloc( sizeof(struct berval) );
1287 return LBER_ERROR_MEMORY;
1289 out->bv_val = ch_malloc( 14 );
1290 if ( out->bv_val == NULL ) {
1292 return LBER_ERROR_MEMORY;
1295 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ",
1296 parts[1], parts[2] + 1, parts[3] + 1,
1297 parts[4], parts[5], parts[6] );
1301 return LDAP_SUCCESS;
1311 return check_time_syntax(in, 1, parts);
1315 generalizedTimeNormalize(
1318 struct berval **normalized )
1323 rc = check_time_syntax(val, 0, parts);
1324 if (rc != LDAP_SUCCESS) {
1329 out = ch_malloc( sizeof(struct berval) );
1331 return LBER_ERROR_MEMORY;
1333 out->bv_val = ch_malloc( 16 );
1334 if ( out->bv_val == NULL ) {
1336 return LBER_ERROR_MEMORY;
1339 sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ",
1340 parts[0], parts[1], parts[2] + 1, parts[3] + 1,
1341 parts[4], parts[5], parts[6] );
1345 return LDAP_SUCCESS;
1349 generalizedTimeValidate(
1355 return check_time_syntax(in, 0, parts);
1358 struct syntax_defs_rec {
1361 slap_syntax_validate_func *sd_validate;
1362 slap_syntax_transform_func *sd_normalize;
1363 slap_syntax_transform_func *sd_pretty;
1364 #ifdef SLAPD_BINARY_CONVERSION
1365 slap_syntax_transform_func *sd_ber2str;
1366 slap_syntax_transform_func *sd_str2ber;
1370 #define X_HIDE "X-HIDE 'TRUE' "
1371 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
1372 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
1374 struct syntax_defs_rec syntax_defs[] = {
1375 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
1376 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
1377 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
1378 0, NULL, NULL, NULL},
1379 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
1380 0, NULL, NULL, NULL},
1381 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
1382 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
1383 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
1384 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1385 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
1386 0, NULL, NULL, NULL},
1387 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
1388 0, NULL, NULL, NULL},
1389 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
1390 X_BINARY X_NOT_H_R ")",
1391 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1392 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
1393 X_BINARY X_NOT_H_R ")",
1394 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1395 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
1396 X_BINARY X_NOT_H_R ")",
1397 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1398 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
1399 0, NULL, NULL, NULL},
1400 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
1401 0, dnValidate, dnNormalize, NULL},
1402 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
1403 0, NULL, NULL, NULL},
1404 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
1405 0, NULL, NULL, NULL},
1406 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
1407 0, UTF8StringValidate, UTF8StringNormalize, NULL},
1408 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
1409 0, NULL, NULL, NULL},
1410 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
1411 0, NULL, NULL, NULL},
1412 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
1413 0, NULL, NULL, NULL},
1414 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
1415 0, NULL, NULL, NULL},
1416 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
1417 0, NULL, NULL, NULL},
1418 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
1419 0, IA5StringValidate, faxNumberNormalize, NULL},
1420 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
1421 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1422 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
1423 0, generalizedTimeValidate, generalizedTimeNormalize, NULL},
1424 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
1425 0, NULL, NULL, NULL},
1426 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
1427 0, IA5StringValidate, IA5StringNormalize, NULL},
1428 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
1429 0, integerValidate, NULL, NULL},
1430 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
1431 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
1432 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
1433 0, NULL, NULL, NULL},
1434 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
1435 0, NULL, NULL, NULL},
1436 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
1437 0, NULL, NULL, NULL},
1438 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
1439 0, NULL, NULL, NULL},
1440 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
1441 0, NULL, NULL, NULL},
1442 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
1443 0, NULL, NULL, NULL},
1444 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
1445 0, NULL, NULL, NULL},
1446 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
1447 0, IA5StringValidate, numericStringNormalize, NULL},
1448 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
1449 0, NULL, NULL, NULL},
1450 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
1451 0, oidValidate, NULL, NULL},
1452 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
1453 0, NULL, NULL, NULL},
1454 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
1455 0, blobValidate, NULL, NULL},
1456 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
1457 0, blobValidate, NULL, NULL},
1458 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
1459 0, NULL, NULL, NULL},
1460 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
1461 0, NULL, NULL, NULL},
1462 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
1463 0, printableStringValidate, NULL, NULL},
1464 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
1465 X_BINARY X_NOT_H_R ")",
1466 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
1467 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
1468 0, IA5StringValidate, phoneNumberNormalize, NULL},
1469 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
1470 0, NULL, NULL, NULL},
1471 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
1472 0, IA5StringValidate, telexNumberNormalize, NULL},
1473 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
1474 0, utcTimeValidate, utcTimeNormalize, NULL},
1475 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
1476 0, NULL, NULL, NULL},
1477 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
1478 0, NULL, NULL, NULL},
1479 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
1480 0, NULL, NULL, NULL},
1481 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
1482 0, NULL, NULL, NULL},
1483 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
1484 0, NULL, NULL, NULL},
1486 /* OpenLDAP Experimental Syntaxes */
1487 {"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
1488 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */, NULL, NULL},
1489 {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
1490 0, NULL, NULL, NULL},
1491 {"( 1.3.6.1.4.1.4203.666.2.3 DESC 'OpenLDAP void' " X_HIDE ")" ,
1492 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1493 #if 0 /* not needed */
1494 {"( 1.3.6.1.4.1.4203.666.2.4 DESC 'OpenLDAP DN' " X_HIDE ")" ,
1495 SLAP_SYNTAX_HIDE, inValidate, NULL, NULL},
1498 {NULL, 0, NULL, NULL, NULL}
1501 struct mrule_defs_rec {
1504 slap_mr_convert_func * mrd_convert;
1505 slap_mr_normalize_func * mrd_normalize;
1506 slap_mr_match_func * mrd_match;
1507 slap_mr_indexer_func * mrd_indexer;
1508 slap_mr_filter_func * mrd_filter;
1512 * Other matching rules in X.520 that we do not use:
1514 * 2.5.13.9 numericStringOrderingMatch
1515 * 2.5.13.13 booleanMatch
1516 * 2.5.13.15 integerOrderingMatch
1517 * 2.5.13.18 octetStringOrderingMatch
1518 * 2.5.13.19 octetStringSubstringsMatch
1519 * 2.5.13.25 uTCTimeMatch
1520 * 2.5.13.26 uTCTimeOrderingMatch
1521 * 2.5.13.31 directoryStringFirstComponentMatch
1522 * 2.5.13.32 wordMatch
1523 * 2.5.13.33 keywordMatch
1524 * 2.5.13.34 certificateExactMatch
1525 * 2.5.13.35 certificateMatch
1526 * 2.5.13.36 certificatePairExactMatch
1527 * 2.5.13.37 certificatePairMatch
1528 * 2.5.13.38 certificateListExactMatch
1529 * 2.5.13.39 certificateListMatch
1530 * 2.5.13.40 algorithmIdentifierMatch
1531 * 2.5.13.41 storedPrefixMatch
1532 * 2.5.13.42 attributeCertificateMatch
1533 * 2.5.13.43 readerAndKeyIDMatch
1534 * 2.5.13.44 attributeIntegrityMatch
1537 struct mrule_defs_rec mrule_defs[] = {
1538 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
1539 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1540 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1541 NULL, NULL, objectIdentifierMatch,
1542 caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
1544 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
1545 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
1546 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1547 NULL, NULL, dnMatch, dnIndexer, dnFilter},
1549 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
1550 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1551 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1552 NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
1554 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
1555 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1557 NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
1559 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
1560 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1561 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1562 NULL, NULL, caseIgnoreSubstringsMatch,
1563 caseIgnoreSubstringsIndexer, caseIgnoreSubstringsFilter},
1565 /* Next three are not in the RFC's, but are needed for compatibility */
1566 {"( 2.5.13.5 NAME 'caseExactMatch' "
1567 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1568 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1569 NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
1571 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
1572 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
1574 NULL, NULL, caseExactOrderingMatch, NULL, NULL},
1576 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
1577 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1578 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1579 NULL, NULL, caseExactSubstringsMatch,
1580 caseExactSubstringsIndexer, caseExactSubstringsFilter},
1582 {"( 2.5.13.8 NAME 'numericStringMatch' "
1583 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
1584 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1585 NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
1587 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
1588 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1589 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1590 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1591 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1593 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
1594 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
1595 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1596 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
1598 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
1599 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1600 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1601 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
1603 {"( 2.5.13.14 NAME 'integerMatch' "
1604 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1605 SLAP_MR_NONE | SLAP_MR_EXT,
1606 NULL, NULL, integerMatch, NULL, NULL},
1608 {"( 2.5.13.16 NAME 'bitStringMatch' "
1609 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
1610 SLAP_MR_NONE | SLAP_MR_EXT,
1611 NULL, NULL, bitStringMatch, NULL, NULL},
1613 {"( 2.5.13.17 NAME 'octetStringMatch' "
1614 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1615 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1616 NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
1618 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
1619 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
1620 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1621 NULL, NULL, telephoneNumberMatch, NULL, NULL},
1623 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
1624 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
1625 SLAP_MR_SUBSTR | SLAP_MR_EXT,
1626 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
1628 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
1629 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
1630 SLAP_MR_NONE | SLAP_MR_EXT,
1631 NULL, NULL, presentationAddressMatch, NULL, NULL},
1633 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
1634 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
1635 SLAP_MR_NONE | SLAP_MR_EXT,
1636 NULL, NULL, uniqueMemberMatch, NULL, NULL},
1638 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
1639 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
1640 SLAP_MR_NONE | SLAP_MR_EXT,
1641 NULL, NULL, protocolInformationMatch, NULL, NULL},
1643 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
1644 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1645 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1646 NULL, NULL, generalizedTimeMatch, NULL, NULL},
1648 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
1649 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
1651 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
1653 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
1654 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
1655 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1656 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
1658 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
1659 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
1660 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1661 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
1663 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
1664 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1665 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1666 NULL, NULL, caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1668 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
1669 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1670 SLAP_MR_EQUALITY | SLAP_MR_EXT,
1671 NULL, NULL, caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
1673 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
1674 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
1676 NULL, NULL, caseIgnoreIA5SubstringsMatch,
1677 caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
1679 {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
1680 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
1682 NULL, NULL, authPasswordMatch, NULL, NULL},
1684 {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
1685 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
1687 NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
1689 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
1698 /* we should only be called once (from main) */
1699 assert( schema_init_done == 0 );
1701 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
1702 res = register_syntax( syntax_defs[i].sd_desc,
1703 syntax_defs[i].sd_flags,
1704 syntax_defs[i].sd_validate,
1705 syntax_defs[i].sd_normalize,
1706 syntax_defs[i].sd_pretty
1707 #ifdef SLAPD_BINARY_CONVERSION
1709 syntax_defs[i].sd_ber2str,
1710 syntax_defs[i].sd_str2ber
1715 fprintf( stderr, "schema_init: Error registering syntax %s\n",
1716 syntax_defs[i].sd_desc );
1721 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
1722 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
1724 "schema_init: Ingoring unusable matching rule %s\n",
1725 mrule_defs[i].mrd_desc );
1729 res = register_matching_rule(
1730 mrule_defs[i].mrd_desc,
1731 mrule_defs[i].mrd_usage,
1732 mrule_defs[i].mrd_convert,
1733 mrule_defs[i].mrd_normalize,
1734 mrule_defs[i].mrd_match,
1735 mrule_defs[i].mrd_indexer,
1736 mrule_defs[i].mrd_filter );
1740 "schema_init: Error registering matching rule %s\n",
1741 mrule_defs[i].mrd_desc );
1745 schema_init_done = 1;
1746 return LDAP_SUCCESS;